| @@ -1,52 +1,52 @@ | ||
| 1 | -<?php | |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - exit; // Exit if accessed directly | |
| 4 | -} | |
| 5 | -global $current_user,$wpdb,$wppmfunction; | |
| 6 | - | |
| 7 | -// Task name | |
| 8 | -$name = isset($_POST['name']) ? sanitize_text_field(wp_unslash($_POST['name'])) : ''; | |
| 9 | -if($name) $args['name'] = $name; | |
| 10 | - | |
| 11 | -// Description | |
| 12 | -$task_description = ''; | |
| 13 | -if ( !empty( $_POST['wppm_task_description'] ) ) { | |
| 14 | - $task_description = wp_kses_post( | |
| 15 | - wp_unslash( $_POST['wppm_task_description'] ) | |
| 16 | - ); | |
| 17 | -} | |
| 18 | -if($task_description) $args['wppm_task_description'] = $task_description; | |
| 19 | - | |
| 20 | -//project | |
| 21 | -$wppm_task_project = isset($_POST['wppm_task_project']) | |
| 22 | - ? absint( wp_unslash( $_POST['wppm_task_project'] ) ) | |
| 23 | - : 0; | |
| 24 | -if($wppm_task_project) $args['wppm_task_project'] = $wppm_task_project; | |
| 25 | - | |
| 26 | -//Task start date | |
| 27 | -$text = isset($_POST['wppm_task_start_date']) ? sanitize_text_field(wp_unslash($_POST['wppm_task_start_date'])) : ''; | |
| 28 | -if($text) $args['wppm_task_start_date'] = wp_date("Y-m-d H:i:s" ,strtotime($text)); | |
| 29 | - | |
| 30 | -//Task end date | |
| 31 | -$text2 = isset($_POST['wppm_task_end_date']) ? sanitize_text_field(wp_unslash($_POST['wppm_task_end_date'])) : ''; | |
| 32 | -if($text2) $args['wppm_task_end_date'] = wp_date("Y-m-d H:i:s" ,strtotime($text2)); | |
| 33 | - | |
| 34 | -// Priority | |
| 35 | -$task_priority = isset($_POST['wppm_create_task_priority']) ? intval(sanitize_text_field(wp_unslash($_POST['wppm_create_task_priority']))) : ''; | |
| 36 | -if($task_priority) $args['wppm_create_task_priority'] = $task_priority; | |
| 37 | - | |
| 38 | -//Assign user | |
| 39 | -$arrVal = array(); | |
| 40 | -if ( isset( $_POST['user_names'] ) && is_array( $_POST['user_names'] ) ) { | |
| 41 | - $arrVal = array_map( | |
| 42 | - 'absint', | |
| 43 | - wp_unslash( $_POST['user_names'] ) | |
| 44 | - ); | |
| 45 | - $arrVal = array_unique( $arrVal ); | |
| 46 | -} | |
| 47 | -if($arrVal) $args['user_names'] = $wppmfunction->sanitize_array($arrVal); | |
| 48 | - | |
| 49 | -$args = apply_filters( 'wppm_before_create_task_args', $args); | |
| 50 | - | |
| 51 | -$task_id = WPPM_Functions::create_task($args); | |
| 52 | -do_action('wppm_after_task_created', $task_id); | |
| 1 | +<?php | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | + exit; // Exit if accessed directly | |
| 4 | +} | |
| 5 | +global $current_user,$wpdb,$wppmfunction; | |
| 6 | + | |
| 7 | +// Task name | |
| 8 | +$name = isset($_POST['name']) ? sanitize_text_field(wp_unslash($_POST['name'])) : ''; | |
| 9 | +if($name) $args['name'] = $name; | |
| 10 | + | |
| 11 | +// Description | |
| 12 | +$task_description = ''; | |
| 13 | +if ( !empty( $_POST['wppm_task_description'] ) ) { | |
| 14 | + $task_description = wp_kses_post( | |
| 15 | + wp_unslash( $_POST['wppm_task_description'] ) | |
| 16 | + ); | |
| 17 | +} | |
| 18 | +if($task_description) $args['wppm_task_description'] = $task_description; | |
| 19 | + | |
| 20 | +//project | |
| 21 | +$wppm_task_project = isset($_POST['wppm_task_project']) | |
| 22 | + ? absint( wp_unslash( $_POST['wppm_task_project'] ) ) | |
| 23 | + : 0; | |
| 24 | +if($wppm_task_project) $args['wppm_task_project'] = $wppm_task_project; | |
| 25 | + | |
| 26 | +//Task start date | |
| 27 | +$text = isset($_POST['wppm_task_start_date']) ? sanitize_text_field(wp_unslash($_POST['wppm_task_start_date'])) : ''; | |
| 28 | +if($text) $args['wppm_task_start_date'] = wp_date("Y-m-d H:i:s" ,strtotime($text)); | |
| 29 | + | |
| 30 | +//Task end date | |
| 31 | +$text2 = isset($_POST['wppm_task_end_date']) ? sanitize_text_field(wp_unslash($_POST['wppm_task_end_date'])) : ''; | |
| 32 | +if($text2) $args['wppm_task_end_date'] = wp_date("Y-m-d H:i:s" ,strtotime($text2)); | |
| 33 | + | |
| 34 | +// Priority | |
| 35 | +$task_priority = isset($_POST['wppm_create_task_priority']) ? intval(sanitize_text_field(wp_unslash($_POST['wppm_create_task_priority']))) : ''; | |
| 36 | +if($task_priority) $args['wppm_create_task_priority'] = $task_priority; | |
| 37 | + | |
| 38 | +//Assign user | |
| 39 | +$arrVal = array(); | |
| 40 | +if ( isset( $_POST['user_names'] ) && is_array( $_POST['user_names'] ) ) { | |
| 41 | + $arrVal = array_map( | |
| 42 | + 'absint', | |
| 43 | + wp_unslash( $_POST['user_names'] ) | |
| 44 | + ); | |
| 45 | + $arrVal = array_unique( $arrVal ); | |
| 46 | +} | |
| 47 | +if($arrVal) $args['user_names'] = $wppmfunction->sanitize_array($arrVal); | |
| 48 | + | |
| 49 | +$args = apply_filters( 'wppm_before_create_task_args', $args); | |
| 50 | + | |
| 51 | +$task_id = WPPM_Functions::create_task($args); | |
| 52 | +do_action('wppm_after_task_created', $task_id); | |