| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user, $wpdb; |
| 7 |
if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;} |
| 8 |
|
| 9 |
$cat_name = isset($_POST) && isset($_POST['cat_name']) ? sanitize_text_field($_POST['cat_name']) : ''; |
| 10 |
if (!$cat_name) {exit;} |
| 11 |
$load_order = $wpdb->get_var("select max(load_order) from {$wpdb->prefix}wppm_project_categories"); |
| 12 |
|
| 13 |
$values=array( |
| 14 |
'name'=>sanitize_text_field($_POST['cat_name']), |
| 15 |
'load_order'=> ++$load_order |
| 16 |
); |
| 17 |
$wpdb->insert($wpdb->prefix.'wppm_project_categories',$values); |
| 18 |
echo '{ "sucess_status":"1","messege":"'.__('Category added successfully.','taskbuilder').'" }'; |
| 19 |
|
| 20 |
|