| 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_modal_popup', '_ajax_nonce', false ) != 1 ) { |
| 13 |
wp_send_json_error( 'Unauthorised request!', 401 ); |
| 14 |
} |
| 15 |
|
| 16 |
$header_bg_color = isset( $_POST['header-bg-color'] ) ? sanitize_text_field( wp_unslash( $_POST['header-bg-color'] ) ) : ''; |
| 17 |
if ( ! $header_bg_color ) { |
| 18 |
wp_send_json_error( 'Bad request', 400 ); |
| 19 |
} |
| 20 |
|
| 21 |
$header_text_color = isset( $_POST['header-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['header-text-color'] ) ) : ''; |
| 22 |
if ( ! $header_text_color ) { |
| 23 |
wp_send_json_error( 'Bad request', 400 ); |
| 24 |
} |
| 25 |
|
| 26 |
$body_bg_color = isset( $_POST['body-bg-color'] ) ? sanitize_text_field( wp_unslash( $_POST['body-bg-color'] ) ) : ''; |
| 27 |
if ( ! $body_bg_color ) { |
| 28 |
wp_send_json_error( 'Bad request', 400 ); |
| 29 |
} |
| 30 |
|
| 31 |
$body_label_color = isset( $_POST['body-label-color'] ) ? sanitize_text_field( wp_unslash( $_POST['body-label-color'] ) ) : ''; |
| 32 |
if ( ! $body_label_color ) { |
| 33 |
wp_send_json_error( 'Bad request', 400 ); |
| 34 |
} |
| 35 |
|
| 36 |
$body_text_color = isset( $_POST['body-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['body-text-color'] ) ) : ''; |
| 37 |
if ( ! $body_text_color ) { |
| 38 |
wp_send_json_error( 'Bad request', 400 ); |
| 39 |
} |
| 40 |
|
| 41 |
$footer_bg_color = isset( $_POST['footer-bg-color'] ) ? sanitize_text_field( wp_unslash( $_POST['footer-bg-color'] ) ) : ''; |
| 42 |
if ( ! $footer_bg_color ) { |
| 43 |
wp_send_json_error( 'Bad request', 400 ); |
| 44 |
} |
| 45 |
|
| 46 |
$action_btn_bg_color = isset( $_POST['action-btn-bg-color'] ) ? sanitize_text_field( wp_unslash( $_POST['action-btn-bg-color'] ) ) : ''; |
| 47 |
if ( ! $action_btn_bg_color ) { |
| 48 |
wp_send_json_error( 'Bad request', 400 ); |
| 49 |
} |
| 50 |
|
| 51 |
$action_btn_text_color = isset( $_POST['action-btn-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['action-btn-text-color'] ) ) : ''; |
| 52 |
if ( ! $action_btn_bg_color ) { |
| 53 |
wp_send_json_error( 'Bad request', 400 ); |
| 54 |
} |
| 55 |
|
| 56 |
update_option( |
| 57 |
'wppm-ap-modal', |
| 58 |
array( |
| 59 |
'header-bg-color' => $header_bg_color, |
| 60 |
'header-text-color' => $header_text_color , |
| 61 |
'body-bg-color' => $body_bg_color , |
| 62 |
'body-label-color' => $body_label_color, |
| 63 |
'body-text-color' => $body_text_color, |
| 64 |
'footer-bg-color' => $footer_bg_color, |
| 65 |
'action-btn-bg-color'=>$action_btn_bg_color, |
| 66 |
'action-btn-text-color'=>$action_btn_text_color |
| 67 |
) |
| 68 |
); |
| 69 |
do_action('wppm_set_ap_modal_setting'); |
| 70 |
|
| 71 |
echo wp_json_encode( array( |
| 72 |
'sucess_status' => 1, |
| 73 |
'messege' => esc_html__( 'Settings saved.', 'taskbuilder' ), |
| 74 |
) ); |
| 75 |
wp_die(); |