$check being reset in class-s2-core.php
-
I think I may have found an odd bug. I have a fresh install of WP running Twenty Fifteen. I’m running a script that bulk-adds posts to WordPress via the wp_insert_post() function and assigns categories to each. The user can choose multiple if they wish.
The issue: some of the categories are set to be excluded from the email digests. When I pass a post through wp_insert_post() with only the excluded category selected, Subscribe2 behaves as expected. However, if I select an excluded category along with other categories that are not, the email is being sent out.
I discovered in class-s2-core.php that the $check flag in the publish() function was holding as “true” through line 444, as it should in this instance, but after it passed through the // do we have subscribers?, it was being reset and causing the email to be sent.
I ended up re-writing the line to read this instead:
// do we have subscribers? if($check) { return $post; } elseif ( empty($public) && empty($registered) ) { // if not, no sense doing anything else return $post; }
…and it resolves the issue. I wanted to report this, as I think it should be something that gets looked at for the next release.
Again, this only occurs when I’m using the wp_insert_post() function and assigning categories. From the dashboard and posts panels, it behaves as expected.
- The topic ‘$check being reset in class-s2-core.php’ is closed to new replies.