| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user,$wpdb,$wppmfunction; |
| 7 |
|
| 8 |
if (!($current_user->ID && $current_user->has_cap('manage_options') || ($current_user->ID && $current_user->has_cap('wppm_admin')))) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
if ( check_ajax_referer( 'wppm_set_ap_individual_task', '_ajax_nonce', false ) != 1 ) { |
| 13 |
wp_send_json_error( 'Unauthorised request!', 401 ); |
| 14 |
} |
| 15 |
|
| 16 |
$comment_primary_color = isset( $_POST['comment-primary-color'] ) ? sanitize_text_field( wp_unslash( $_POST['comment-primary-color'] ) ) : ''; |
| 17 |
if ( ! $comment_primary_color ) { |
| 18 |
wp_send_json_error( 'Bad request', 400 ); |
| 19 |
} |
| 20 |
|
| 21 |
$comment_secondary_color = isset( $_POST['comment-secondary-color'] ) ? sanitize_text_field( wp_unslash( $_POST['comment-secondary-color'] ) ) : ''; |
| 22 |
if ( ! $comment_secondary_color ) { |
| 23 |
wp_send_json_error( 'Bad request', 400 ); |
| 24 |
} |
| 25 |
|
| 26 |
$comment_date_color = isset( $_POST['comment-date-color'] ) ? sanitize_text_field( wp_unslash( $_POST['comment-date-color'] ) ) : ''; |
| 27 |
if ( ! $comment_date_color ) { |
| 28 |
wp_send_json_error( 'Bad request', 400 ); |
| 29 |
} |
| 30 |
|
| 31 |
$comment_date_hover_color = isset( $_POST['comment-date-hover-color'] ) ? sanitize_text_field( wp_unslash( $_POST['comment-date-hover-color'] ) ) : ''; |
| 32 |
if ( ! $comment_date_hover_color ) { |
| 33 |
wp_send_json_error( 'Bad request', 400 ); |
| 34 |
} |
| 35 |
|
| 36 |
$comment_send_btn_bg_color = isset( $_POST['comment-send-btn-bg-color']) ? sanitize_text_field( wp_unslash( $_POST['comment-send-btn-bg-color'] ) ) : ''; |
| 37 |
if ( ! $comment_send_btn_bg_color ) { |
| 38 |
wp_send_json_error( 'Bad request', 400 ); |
| 39 |
} |
| 40 |
|
| 41 |
$comment_send_btn_color = isset( $_POST['comment-send-btn-color']) ? sanitize_text_field( wp_unslash( $_POST['comment-send-btn-color'] ) ) : ''; |
| 42 |
if ( ! $comment_send_btn_color ) { |
| 43 |
wp_send_json_error( 'Bad request', 400 ); |
| 44 |
} |
| 45 |
|
| 46 |
$widget_header_bg_color = isset( $_POST['widget-header-bg-color'] ) ? sanitize_text_field( wp_unslash( $_POST['widget-header-bg-color'] ) ) : ''; |
| 47 |
if ( ! $widget_header_bg_color ) { |
| 48 |
wp_send_json_error( 'Bad request', 400 ); |
| 49 |
} |
| 50 |
|
| 51 |
$widget_header_text_color = isset( $_POST['widget-header-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['widget-header-text-color'] ) ) : ''; |
| 52 |
if ( ! $widget_header_text_color ) { |
| 53 |
wp_send_json_error( 'Bad request', 400 ); |
| 54 |
} |
| 55 |
|
| 56 |
$widget_body_bg_color = isset( $_POST['widget-body-bg-color'] ) ? sanitize_text_field( wp_unslash( $_POST['widget-body-bg-color'] ) ) : ''; |
| 57 |
if ( ! $widget_body_bg_color ) { |
| 58 |
wp_send_json_error( 'Bad request', 400 ); |
| 59 |
} |
| 60 |
|
| 61 |
$widget_body_label_color = isset( $_POST['widget-body-label-color'] ) ? sanitize_text_field( wp_unslash( $_POST['widget-body-label-color'] ) ) : ''; |
| 62 |
if ( ! $widget_body_label_color ) { |
| 63 |
wp_send_json_error( 'Bad request', 400 ); |
| 64 |
} |
| 65 |
|
| 66 |
$widget_body_text_color = isset( $_POST['widget-body-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['widget-body-text-color'] ) ) : ''; |
| 67 |
if ( ! $widget_body_text_color ) { |
| 68 |
wp_send_json_error( 'Bad request', 400 ); |
| 69 |
} |
| 70 |
|
| 71 |
update_option( |
| 72 |
'wppm-ap-individual-task', |
| 73 |
array( |
| 74 |
'comment-primary-color' => $comment_primary_color, |
| 75 |
'comment-secondary-color' => $comment_secondary_color, |
| 76 |
'comment-date-color' => $comment_date_color, |
| 77 |
'comment-date-hover-color' => $comment_date_hover_color, |
| 78 |
'comment-send-btn-bg-color' => $comment_send_btn_bg_color, |
| 79 |
'comment-send-btn-color' => $comment_send_btn_color, |
| 80 |
'widget-header-bg-color' => $widget_header_bg_color, |
| 81 |
'widget-header-text-color' => $widget_header_text_color, |
| 82 |
'widget-body-bg-color' => $widget_body_bg_color, |
| 83 |
'widget-body-label-color' => $widget_body_label_color, |
| 84 |
'widget-body-text-color' => $widget_body_text_color |
| 85 |
) |
| 86 |
); |
| 87 |
do_action('wppm_set_ap_individual_task_settings'); |
| 88 |
|
| 89 |
echo wp_json_encode( array( |
| 90 |
'sucess_status' => 1, |
| 91 |
'messege' => esc_html__( 'Settings saved.', 'taskbuilder' ), |
| 92 |
) ); |
| 93 |
wp_die(); |