public function update_schedule($old, $new) { if ($old == $new) { return; } // Schedule notifications event if notifications is active if (sm_is_notification_enabled()) { wp_clear_scheduled_hook('notification_event'); wp_schedule_event(time(), sm_get_notification_recurrence(), 'notification_event'); } else { wp_clear_scheduled_hook('notification_event'); } }
<form method="post" action="options.php"> <?php $settings = array('notifications' => sm_is_notification_enabled(), 'recurrence' => sm_get_notification_recurrence()); settings_fields('smartmockups_settings_notifications'); ?> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row" valign="top"> <label class="notifications" for="smartmockups_notifications"><?php _e('Notifications', SMART_MOCKUPS_DOMAIN); ?> </label> </th> <td> <input id="smartmockups_notifications" name="smartmockups_notifications" type="checkbox" value="1" <?php echo $settings['notifications'] ? 'checked' : ''; ?> /> <label for="smartmockups_notifications"><?php _e('Check this to enable scheduled notifications', SMART_MOCKUPS_DOMAIN); ?> </label> </td> </tr> <tr valign="top"> <th scope="row" valign="top"> <label class="notifications" for="smartmockups_notifications_recurrence"><?php _e('Recurrence', SMART_MOCKUPS_DOMAIN); ?> </label>