diff --git a/functions.php b/functions.php index 3bf8649..6b5dd26 100644 --- a/functions.php +++ b/functions.php @@ -601,6 +601,94 @@ function custom_meta_tags() { } +add_action('wpcf7_before_send_mail', 'my_custom_contact_form_handler', 10, 3); +function my_custom_contact_form_handler($contact_form, $abort, $submission) { + + + + // Получаем ID формы + $form_id = $contact_form->id(); + + + if ( $form_id == '0ddb83c' ) { + + // Получаем данные формы + $submission = WPCF7_Submission::get_instance(); + + if ($submission) { + + $posted_data = $submission->get_posted_data(); + + // Подключаемся к базе данных WordPress + global $wpdb; + + // Определяем таблицу в базе данных WordPress в зависимости от ID формы + $table_name = $wpdb->prefix . 'subusers'; + + $wpdb->insert( + $table_name, + array( + 'mail' => $posted_data['your-email'], + 'status' => 0, + 'date' => current_time('mysql') + ), + array( + '%s', // Формат для строкового поля + '%d', // Формат для цифрового поля + '%s' // Формат для поля с датой и временем + ) + ); + + } + } + +} + +function last_sticky_post() { + + //$pinned_post = get_field('pinned_post', 'options'); + + static $last = null; // array to pinned post + + if ( $last !== null){ + return $last; + } + + $sticky_posts = array_reverse(get_option('sticky_posts')); + + $published_sticky_posts = array(); + + foreach ($sticky_posts as $post_id) { + $post = get_post($post_id); + if ($post->post_status == 'publish') { + //$published_sticky_posts[] = $post_id; + $last = $post; + break; // Выходим из цикла, так как нашли последний опубликованный закрепленный пост + } + } + + return $last; + +} + + +add_action( 'phpmailer_init', 'agroxpert_send_smtp_email' ); + +function agroxpert_send_smtp_email( PHPMailer $phpmailer ) { + + $phpmailer->isSMTP(); + $phpmailer->Host = 'mail.vetandlife.ru'; + $phpmailer->SMTPAuth = true; + $phpmailer->Port = 465; + $phpmailer->Username = 'news@mail.agroexpert.press'; + $phpmailer->Password = 'O6K!]aZDNJ'; + $phpmailer->SMTPSecure = 'ssl'; + $phpmailer->From = 'news@mail.agroexpert.press'; + $phpmailer->FromName = 'Ветеринария и жизнь'; + +} + + add_action('wpcf7_mail_sent', 'my_custom_mail_sent' ); @@ -669,17 +757,4 @@ $hash_link.\n\n } -function agroxpert_send_smtp_email( PHPMailer $phpmailer ) { - $phpmailer->isSMTP(); - $phpmailer->Host = 'mail.vetandlife.ru'; - $phpmailer->SMTPAuth = true; - $phpmailer->Port = 465; - $phpmailer->Username = 'news@mail.agroexpert.press'; - $phpmailer->Password = 'O6K!]aZDNJ'; - $phpmailer->SMTPSecure = 'ssl'; - $phpmailer->From = 'news@mail.agroexpert.press'; - $phpmailer->FromName = 'Ветеринария и жизнь'; -} - -add_action( 'phpmailer_init', 'agroxpert_send_smtp_email' ); \ No newline at end of file diff --git a/partials/pinned-post-mob.php b/partials/pinned-post-mob.php index f4a44c9..d81ad6e 100644 --- a/partials/pinned-post-mob.php +++ b/partials/pinned-post-mob.php @@ -1,12 +1,6 @@ ID; diff --git a/partials/pinned-post.php b/partials/pinned-post.php index dfd691f..37da94f 100644 --- a/partials/pinned-post.php +++ b/partials/pinned-post.php @@ -1,14 +1,6 @@