← All changes
|
includes/admin/tasks/open_task/wppm_set_clone_task.php
+25
-12
5.0.4
→
6.0.6
View file →
| @@ -1,16 +1,30 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | -global $wpdb,$current_user,$wppmfunction; | |
| 6 | -$nonce_valid = false; | |
| 7 | -if ( isset($_POST['_ajax_nonce']) ) { | |
| 8 | - $nonce_valid = wp_verify_nonce($_POST['_ajax_nonce'], 'wppm_set_clone_task'); | |
| 5 | +global $wpdb, $current_user, $wppmfunction; | |
| 6 | +$is_internal_clone = ! empty( $internal_code_flag ); | |
| 7 | +if ( ! $is_internal_clone ) { | |
| 8 | + if ( | |
| 9 | + empty( $_POST['_ajax_nonce'] ) || | |
| 10 | + ! wp_verify_nonce( | |
| 11 | + sanitize_text_field( | |
| 12 | + wp_unslash( $_POST['_ajax_nonce'] ) | |
| 13 | + ), | |
| 14 | + 'wppm_set_clone_task' | |
| 15 | + ) | |
| 16 | + ) { | |
| 17 | + wp_send_json_error( | |
| 18 | + array( | |
| 19 | + 'message' => esc_html__( | |
| 20 | + 'Security check failed.', | |
| 21 | + 'taskbuilder' | |
| 22 | + ) | |
| 23 | + ) | |
| 24 | + ); | |
| 25 | + } | |
| 9 | 26 | } |
| 10 | -if ( ! $nonce_valid ) { | |
| 11 | - wp_send_json_error('Unauthorized request!', 403); | |
| 12 | -} | |
| 13 | 27 | $prev_task_id = isset($_POST['task_id']) ? absint(sanitize_text_field(wp_unslash($_POST['task_id']))) : $ptask_id ; |
| 14 | 28 | $task = $wppmfunction->get_task($prev_task_id); |
| 15 | 29 | if ( empty($task) ) { |
| 16 | 30 | wp_send_json_error('Invalid task', 404); |
| @@ -41,9 +55,10 @@ | ||
| 41 | 55 | 'wppm_create_task_priority'=>$task['priority'], |
| 42 | 56 | 'user_names'=>explode(",",$task['users']), |
| 43 | 57 | 'date_created'=>$task['date_created'], |
| 44 | 58 | 'task_auth_code'=> $wppmfunction->getRandomString(10), |
| 45 | - 'active'=>1 | |
| 59 | + 'active'=>1, | |
| 60 | + 'parent_task_id'=>isset($task['parent_task_id']) ? $task['parent_task_id'] : 0 | |
| 46 | 61 | ); |
| 47 | 62 | $task_id = $wppmfunction->create_task($values); |
| 48 | 63 | if(!isset($project_id) || $wppm_default_duplicate_project_email_notification==1){ |
| 49 | 64 | do_action('wppm_after_task_created', $task_id); |
| @@ -78,9 +93,9 @@ | ||
| 78 | 93 | } |
| 79 | 94 | if(!empty($task_comments)){ |
| 80 | 95 | $args = array(); |
| 81 | 96 | foreach($task_comments as $task_comment){ |
| 82 | - $task_comment_data = json_decode(json_encode($task_comment), true); | |
| 97 | + $task_comment_data = json_decode(wp_json_encode($task_comment), true); | |
| 83 | 98 | $attachment_ids = $task_comment_data['attachment_ids']; |
| 84 | 99 | $attachment_ids_array = explode(",",$attachment_ids); |
| 85 | 100 | if(!empty($attachment_ids_array)){ |
| 86 | 101 | $attachment_id = array(); |
| @@ -126,7 +141,5 @@ | ||
| 126 | 141 | } |
| 127 | 142 | } |
| 128 | 143 | } |
| 129 | 144 | do_action("wppm_after_task_clone",$prev_task_id,$task_id); |
| 130 | -wp_send_json_success(array( | |
| 131 | - 'task_id' => $task_id | |
| 132 | -)); | |
| 145 | +return $task_id; | |