| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user, $wpdb, $wppmfunction; |
| 7 |
if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;} |
| 8 |
if ( check_ajax_referer( 'wppm_set_priority_order', '_ajax_nonce', false ) != 1 ) { |
| 9 |
wp_send_json_error( 'Unauthorised request!', 401 ); |
| 10 |
} |
| 11 |
|
| 12 |
$load_orders = isset($_POST) && isset($_POST['load_orders']) ? $wppmfunction->sanitize_array($_POST['load_orders']) : array(); |
| 13 |
$priorities = $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}wppm_task_priorities"); |
| 14 |
if (is_array($load_orders)) { |
| 15 |
foreach($load_orders as $key=>$val){ |
| 16 |
$result = $wpdb->query("UPDATE ".$wpdb->prefix."wppm_task_priorities SET load_order=". $val." WHERE id=".$key ); |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
echo '{ "sucess_status":"1","messege":"'.__('Priority order saved.','taskbuilder').'" }'; |