Exclude doesn’t work
-
I’ve tested excluded categories, and it doesn’t work as i see i’m always get Post Category as 1
PHP Code
$s2_taxonomies = apply_filters( 's2_taxonomies', array( 'category' ) ); $post_cats = wp_get_post_categories($post->ID); // Fail gracefully if we have a post but no category assigned or a taxonomy error if ( is_wp_error( $post_cats ) || ( empty( $post_cats ) && 'post' === $post->post_type ) ) { return $post; } $wfile = fopen("log.txt", "a+"); fclose($wfile); $myfile = fopen("log.txt", "a+") or die("Unable to open file!"); $date = new DateTime(null, new DateTimeZone('Europe/Vilnius')); $txt = $date->format('Y-m-d H:i:s'); $txt .= "\n--- POST INFO ----\n"; $txt .= print_r($post, true); $txt .= "\n--- S2 Options ----\n"; $txt .= print_r($this->subscribe2_options, true); $check = false; // is the current post assigned to any categories // which should not generate a notification email? $excludes = explode( ',', $this->subscribe2_options['exclude'] ); $txt .= "\nPOST CATS \n"; $txt .= print_r($post_cats, true); $txt .= "\nEXCLUDED CATS \n"; $txt .= print_r($excludes, true); foreach ($excludes as $cat ) { $txt .= "\n FOREACH AS excludes as cat \n"; $txt .= "CAT ID:".$cat."\n"; if ( in_array( (int) $cat, $post_cats, true ) ) { $check = true; $txt .= "\nIN EXCLUDE\n"; } else { $txt .= "\nNOT IN EXCLUDE\n"; } } $txt .= "\n\n\n"; fwrite($myfile, $txt); fclose($myfile);
I wrote some debug in log file
2020-04-09 00:17:51 --- POST INFO ---- WP_Post Object ( [ID] => 2013 [post_author] => 1 [post_date] => 2020-04-09 00:17:51 [post_date_gmt] => 2020-04-08 21:17:51 [post_content] => <!-- wp:paragraph --> <p>BLABLABLA</p> <!-- /wp:paragraph --> [post_title] => Test1 [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => test1 [to_ping] => [pinged] => [post_modified] => 2020-04-09 00:17:51 [post_modified_gmt] => 2020-04-08 21:17:51 [post_content_filtered] => [post_parent] => 0 [guid] => https://karolisgecas.com/?p=2013 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) --- S2 Options ---- Array ( [autosub] => no [newreg_override] => no [wpregdef] => no [autoformat] => html_excerpt [show_autosub] => no [autosub_def] => no [comment_subs] => no [comment_def] => no [one_click_profile] => no [bcclimit] => 1 [admin_email] => subs [tracking] => [s2page] => 0 [stylesheet] => yes [embed] => no [pages] => no [password] => no [stickies] => no [private] => no [email_freq] => never [cron_order] => desc [compulsory] => 1 [exclude] => 35 [sender] => blogname [reg_override] => [show_meta] => 0 [show_button] => 1 [ajax] => 0 [widget] => 1 [counterwidget] => 0 [s2meta_default] => 0 [barred] => [exclude_formats] => [mailtext] => {BLOGNAME} has posted a new item, '{TITLE}' {POST} You may view the latest post at {PERMALINK} You received this e-mail because you asked to be notified when new updates are posted. Best regards, {MYNAME} {EMAIL} [notification_subject] => [{BLOGNAME}] {TITLE} [confirm_email] => {BLOGNAME} has received a request to {ACTION} for this email address. To complete your request please click on the link below: {LINK} If you did not request this, please feel free to disregard this notice! Thank you, {MYNAME}. [confirm_subject] => [{BLOGNAME}] Please confirm your request [remind_email] => This email address was subscribed for notifications at {BLOGNAME} ({BLOGLINK}) but the subscription remains incomplete. If you wish to complete your subscription please click on the link below: {LINK} If you do not wish to complete your subscription please ignore this email and your address will be removed from our database. Regards, {MYNAME} [remind_subject] => [{BLOGNAME}] Subscription Reminder [js_ip_updater] => [version] => 10.32 [dismiss_sender_warning] => 0 ) POST CATS Array ( [0] => 1 ) EXCLUDED CATS Array ( [0] => 35 ) FOREACH AS excludes as cat CAT ID:35 NOT IN EXCLUDE 2020-04-09 00:18:09 --- POST INFO ---- WP_Post Object ( [ID] => 2015 [post_author] => 1 [post_date] => 2020-04-09 00:18:09 [post_date_gmt] => 2020-04-08 21:18:09 [post_content] => <!-- wp:paragraph --> <p>BULBULBUL</p> <!-- /wp:paragraph --> [post_title] => Test2 [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => test2 [to_ping] => [pinged] => [post_modified] => 2020-04-09 00:18:09 [post_modified_gmt] => 2020-04-08 21:18:09 [post_content_filtered] => [post_parent] => 0 [guid] => https://karolisgecas.com/?p=2015 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) --- S2 Options ---- Array ( [autosub] => no [newreg_override] => no [wpregdef] => no [autoformat] => html_excerpt [show_autosub] => no [autosub_def] => no [comment_subs] => no [comment_def] => no [one_click_profile] => no [bcclimit] => 1 [admin_email] => subs [tracking] => [s2page] => 0 [stylesheet] => yes [embed] => no [pages] => no [password] => no [stickies] => no [private] => no [email_freq] => never [cron_order] => desc [compulsory] => 1 [exclude] => 35 [sender] => blogname [reg_override] => [show_meta] => 0 [show_button] => 1 [ajax] => 0 [widget] => 1 [counterwidget] => 0 [s2meta_default] => 0 [barred] => [exclude_formats] => [mailtext] => {BLOGNAME} has posted a new item, '{TITLE}' {POST} You may view the latest post at {PERMALINK} You received this e-mail because you asked to be notified when new updates are posted. Best regards, {MYNAME} {EMAIL} [notification_subject] => [{BLOGNAME}] {TITLE} [confirm_email] => {BLOGNAME} has received a request to {ACTION} for this email address. To complete your request please click on the link below: {LINK} If you did not request this, please feel free to disregard this notice! Thank you, {MYNAME}. [confirm_subject] => [{BLOGNAME}] Please confirm your request [remind_email] => This email address was subscribed for notifications at {BLOGNAME} ({BLOGLINK}) but the subscription remains incomplete. If you wish to complete your subscription please click on the link below: {LINK} If you do not wish to complete your subscription please ignore this email and your address will be removed from our database. Regards, {MYNAME} [remind_subject] => [{BLOGNAME}] Subscription Reminder [js_ip_updater] => [version] => 10.32 [dismiss_sender_warning] => 0 ) POST CATS Array ( [0] => 1 ) EXCLUDED CATS Array ( [0] => 35 ) FOREACH AS excludes as cat CAT ID:35 NOT IN EXCLUDE
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Exclude doesn’t work’ is closed to new replies.