← All changes
|
includes/admin/projects/wppm_set_bulk_change_proj_status.php
+33
-33
6.0.2
→
6.0.6
View file →
| @@ -1,34 +1,34 @@ | ||
| 1 | -<?php | |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - exit; // Exit if accessed directly | |
| 4 | -} | |
| 5 | -global $wpdb,$wppmfunction,$current_user; | |
| 6 | -if ( check_ajax_referer( 'wppm_set_bulk_change_project_status', '_ajax_nonce', false ) != 1 ) { | |
| 7 | - wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 8 | -} | |
| 9 | - | |
| 10 | -$proj_ids = isset( $_POST['proj_ids'] ) ? array_filter( array_map( 'intval', explode( ',', sanitize_text_field( wp_unslash( $_POST['proj_ids'] ) ) ) ) ) : array(); | |
| 11 | -if ( ! $proj_ids ) { | |
| 12 | - wp_send_json_error( 'Missing project ids', 400 ); | |
| 13 | -} | |
| 14 | - | |
| 15 | -$proj_status = isset( $_POST['wppm_project_status']) ? absint(sanitize_text_field(wp_unslash($_POST['wppm_project_status']))) : ''; | |
| 16 | -if(!empty($proj_ids)){ | |
| 17 | - foreach($proj_ids as $proj_id){ | |
| 18 | - $project_data = $wppmfunction->get_project($proj_id); | |
| 19 | - $wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true ); | |
| 20 | - if ((($current_user->ID && $current_user->has_cap('manage_options')) || $wppmfunction->has_project_permission('change_project_status',$proj_id) || ($project_data['created_by']==$current_user->ID && $wppm_current_user_capability=='wppm_manager') || $wppm_current_user_capability=='wppm_admin')) { | |
| 21 | - | |
| 22 | - $status_id = isset($_POST['wppm_project_status']) ? absint(sanitize_text_field(wp_unslash($_POST['wppm_project_status']))) : 0 ; | |
| 23 | - if( !$status_id ){ | |
| 24 | - die(); | |
| 25 | - } | |
| 26 | - $old_status_id = $project_data['status']; | |
| 27 | - | |
| 28 | - if($status_id && $status_id!=$old_status_id){ | |
| 29 | - $wppmfunction->change_project_status( $proj_id, $status_id); | |
| 30 | - } | |
| 31 | - } | |
| 32 | - } | |
| 33 | -} | |
| 1 | +<?php | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | + exit; // Exit if accessed directly | |
| 4 | +} | |
| 5 | +global $wpdb,$wppmfunction,$current_user; | |
| 6 | +if ( check_ajax_referer( 'wppm_set_bulk_change_project_status', '_ajax_nonce', false ) != 1 ) { | |
| 7 | + wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 8 | +} | |
| 9 | + | |
| 10 | +$proj_ids = isset( $_POST['proj_ids'] ) ? array_filter( array_map( 'intval', explode( ',', sanitize_text_field( wp_unslash( $_POST['proj_ids'] ) ) ) ) ) : array(); | |
| 11 | +if ( ! $proj_ids ) { | |
| 12 | + wp_send_json_error( 'Missing project ids', 400 ); | |
| 13 | +} | |
| 14 | + | |
| 15 | +$proj_status = isset( $_POST['wppm_project_status']) ? absint(sanitize_text_field(wp_unslash($_POST['wppm_project_status']))) : ''; | |
| 16 | +if(!empty($proj_ids)){ | |
| 17 | + foreach($proj_ids as $proj_id){ | |
| 18 | + $project_data = $wppmfunction->get_project($proj_id); | |
| 19 | + $wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true ); | |
| 20 | + if ((($current_user->ID && $current_user->has_cap('manage_options')) || $wppmfunction->has_project_permission('change_project_status',$proj_id) || ($project_data['created_by']==$current_user->ID && $wppm_current_user_capability=='wppm_manager') || $wppm_current_user_capability=='wppm_admin')) { | |
| 21 | + | |
| 22 | + $status_id = isset($_POST['wppm_project_status']) ? absint(sanitize_text_field(wp_unslash($_POST['wppm_project_status']))) : 0 ; | |
| 23 | + if( !$status_id ){ | |
| 24 | + die(); | |
| 25 | + } | |
| 26 | + $old_status_id = $project_data['status']; | |
| 27 | + | |
| 28 | + if($status_id && $status_id!=$old_status_id){ | |
| 29 | + $wppmfunction->change_project_status( $proj_id, $status_id); | |
| 30 | + } | |
| 31 | + } | |
| 32 | + } | |
| 33 | +} | |
| 34 | 34 | do_action('wppm_after_set_bulk_change_project_status',$proj_ids, $proj_status); |