
WordPress
33
Вклад в тег
$template
- это название файла с шаблоном в папке с шаблонами.$args
- Массив для замены значений в письме.public function send_email( $template, $args ) {
ob_start();
include APA_PATH . "/templates/emails/{$template}.php";
$content = ob_get_clean();
foreach ( $args as $key => $value ) {
if ( ! is_array( $value ) && ! is_object( $value ) ) {
$search = '{$' . $key . '}';
$content = str_replace( $search, $value, $content );
}
}
$message = $content;
wp_mail( $this->getEmailTo(), $this->getEmailSubject(), $message, $header );
}
$content
ob_start();
include APA_PATH . "/templates/emails/{$template}.php";
$content = ob_get_clean();
{$user_name}
заменяем на реальные значения с массива и заменяем в переменной $content
foreach ( $args as $key => $value ) {
if ( ! is_array( $value ) && ! is_object( $value ) ) {
$search = '{$' . $key . '}';
$content = str_replace( $search, $value, $content );
}
}
$message = $content;
wp_mail( $this->getEmailTo(), $this->getEmailSubject(), $message, $header );
wp_mail()
- это функция из вордпресс add_action('pre_get_posts', 'filter');
function filter($query)
{
if (!is_admin() && $query->is_main_query() && !is_single() &&
((isset($_GET['pa_class']) || isset($_GET['pa_size']) || isset($_GET['pa_material']))
)
) {
if (is_woocommerce()) {
if ((isset($_GET['pa_class']) && !empty($_GET['pa_class'])) ||
(isset($_GET['pa_size']) && !empty($_GET['pa_size'])) ||
(isset($_GET['pa_color']) && !empty($_GET['pa_color'])) ||
(isset($_GET['pa_material']) && !empty($_GET['pa_material']))
) {
if ((isset($_GET['pa_class']) && !empty($_GET['pa_class']))) {
$tax[] = array(
'taxonomy' => 'pa_class',
'field' => 'slug',
'terms' => $_GET['pa_class']
);
}
if ((isset($_GET['pa_color']) && !empty($_GET['pa_color']))) {
$tax[] = array(
'taxonomy' => 'pa_color',
'field' => 'slug',
'terms' => $_GET['pa_color']
);
}
if ((isset($_GET['pa_size']) && !empty($_GET['pa_size']))) {
$tax[] = array(
'taxonomy' => 'pa_size',
'field' => 'slug',
'terms' => $_GET['pa_size']
);
}
if ((isset($_GET['pa_material']) && !empty($_GET['pa_material']))) {
$tax[] = array(
'taxonomy' => 'pa_material',
'field' => 'slug',
'terms' => $_GET['pa_material']
);
}
$query->set('tax_query', $tax);
}
}
} elseif (is_search()) {
$query->set('post_type', 'product');
}
}