function appointments_update_appointment_status($app_id, $new_status) { global $wpdb; $app = appointments_get_appointment($app_id); if (!$app) { return false; } $old_status = $app->status; if ($old_status === $new_status) { return false; } $allowed_status = appointments_get_statuses(); if (!array_key_exists($new_status, $allowed_status)) { return false; } $table = appointments_get_table('appointments'); $result = $wpdb->update($table, array('status' => $new_status), array('ID' => $app_id), array('%s'), array('%d')); if ($result) { if ('removed' == $new_status) { do_action('app_removed', $app_id); } appointments_clear_appointment_cache($app_id); if ('removed' === $new_status) { appointments_send_removal_notification($app_id); } do_action('wpmudev_appointments_update_appointment_status', $app_id, $new_status, $old_status); return true; } return false; }
<div class="tablenav top"> <div class="alignleft actions"> <form id="app-bulk-change-form" method="post" action="<?php echo add_query_arg('page', 'appointments'); ?> " > <input type="hidden" value="appointments" name="page" /> <input type="hidden" value="1" name="app_status_change" /> <select name="app_new_status" style='float:none;'> <option value=""><?php _e('Bulk status change', 'appointments'); ?> </option> <?php foreach (appointments_get_statuses() as $value => $name) { echo '<option value="' . esc_attr($value) . '" class="hide-if-no-js">' . $name . '</option>'; } ?> </select> <input type="submit" class="button app-change-status-btn" value="<?php _e('Change Status', 'appointments'); ?> " /> </form> </div> <script type="text/javascript"> jQuery(document).ready(function($){ $(".app-change-status-btn").click(function(e){ var button = $(this); e.preventDefault();