We will take this into consideration, but my suggestion is to either check or uncheck the box before you publish or update the post depending on if you want to send a push notification or not.
The concept of clicking a checkbox to send a push when a post is published or updated should be a relatively simple and small decision to make without needing complexity around whether it should be checked or unchecked by default.
in many sites, you are right. In our case, the decision is up to the admin. We don’t want updates to trigger notifications and the current setup means we aren’t really using push notifications (because most updates are minor corrections and we can’t trust our contributors to remember to turn it off each time).
-
This reply was modified 10 months, 1 week ago by
oferlaor.
I added a post-update.js script:
document.addEventListener("DOMContentLoaded", () => {
const checkbox = document.querySelector("#os_update");
if (!checkbox) return;
// Get the element that shows the post status (e.g., "Published")
const statusEl = document.querySelector("#post-status-display");
const isPublished =
statusEl &&
(statusEl.textContent.trim().toLowerCase() === "published");
// only turn it off it if it's on and post is already published.
if (checkbox.checked && isPublished) checkbox.checked = false;
});
and then in the theme’s functions.php:
if (('post.php' === $hook) || ('post-new.php' === $hook)) {
wp_enqueue_script('htadmin', get_template_directory_uri() . '/assets/js/post-update.js', array(), '1.14', true);
}