Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The status of "Send notification on post publish" checkbox is not saved for the Draft status #292

Open
alexmayer-uk opened this issue Apr 4, 2022 · 0 comments

Comments

@alexmayer-uk
Copy link

Description:

When "Automatically send a push notification...." option is selected in plugin dashboard and you create a new post - "Send notification on post publish" checkbox on the post page is pre-checked, as expected. But if you are not publishing immediately and if you unchecked this box and saved a draft, the box status is not saved and it becomes checked again as soon as the page refreshes, so that you need to uncheck it once more before publishing.

Steps to Reproduce Issue:

  1. Log in to WordPress.
  2. Create a new post and save as Draft
  3. Observe that "Send notification on post publish" checkbox is pre-checked.
  4. Uncheck "Send notification on post publish" checkbox and save as Draft again
  5. Observe that "Send notification on post publish" checkbox is checked again after the page is refreshed - the checkbox status is not saved.

A video illustrating the issue
https://www.loom.com/share/15fa23ca4f5e4bd8b75492e00d93ecdc

Anything else:

We've found this code in line 288 of this file: onesignal-admin.php
if ((get_post_meta($post->ID, 'onesignal_send_notification', true) === '1')) { $meta_box_checkbox_send_notification = true; } else { // We check the checkbox if: setting is enabled on Config page, post type is ONLY "post", and the post has not been published (new posts are status "auto-draft") $meta_box_checkbox_send_notification = ($settings_send_notification_on_wp_editor_post && // If setting is enabled $post->post_type === 'post' && // Post type must be type post for checkbox to be auto-checked !in_array($post->post_status, array('publish', 'private', 'trash', 'inherit'), true)); // Post is scheduled, incomplete, being edited, or is awaiting publication }
The fix:
Adding 'draft' to the array of post statuses fixes this behaviour and the checkbox status gets saved.
!in_array($post->post_status, array('publish', 'private', 'draft', 'trash', 'inherit'), true));
We have not found a simple way to hook into this without changing the plugin code.
Any ideas how to patch?

Thanks,
Alex Mayer
alex@acewebstudio.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant