| 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_task_list', '_ajax_nonce', false ) != 1 ) { |
| 13 |
wp_send_json_error( 'Unauthorised request!', 401 ); |
| 14 |
} |
| 15 |
|
| 16 |
$list_header_button_background_color = isset( $_POST['list-header-button-background-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-header-button-background-color'] ) ) : ''; |
| 17 |
if ( ! $list_header_button_background_color ) { |
| 18 |
wp_send_json_error( 'Bad request', 400 ); |
| 19 |
} |
| 20 |
|
| 21 |
$list_header_button_hover_color = isset( $_POST['list-header-button-hover-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-header-button-hover-color'] ) ) : ''; |
| 22 |
if ( ! $list_header_button_hover_color ) { |
| 23 |
wp_send_json_error( 'Bad request', 400 ); |
| 24 |
} |
| 25 |
|
| 26 |
$list_header_button_text_color = isset( $_POST['list-header-button-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-header-button-text-color'] ) ) : ''; |
| 27 |
if ( ! $list_header_button_text_color ) { |
| 28 |
wp_send_json_error( 'Bad request', 400 ); |
| 29 |
} |
| 30 |
|
| 31 |
$list_header_bg_color = isset( $_POST['list-header-background-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-header-background-color'] ) ) : ''; |
| 32 |
if ( ! $list_header_bg_color ) { |
| 33 |
wp_send_json_error( 'Bad request', 400 ); |
| 34 |
} |
| 35 |
|
| 36 |
$list_header_text_color = isset( $_POST['list-header-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-header-text-color'] ) ) : ''; |
| 37 |
if ( ! $list_header_text_color ) { |
| 38 |
wp_send_json_error( 'Bad request', 400 ); |
| 39 |
} |
| 40 |
|
| 41 |
$list_item_odd_bg_color = isset( $_POST['list-item-odd-background-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-item-odd-background-color'] ) ) : ''; |
| 42 |
if ( ! $list_item_odd_bg_color ) { |
| 43 |
wp_send_json_error( 'Bad request', 400 ); |
| 44 |
} |
| 45 |
|
| 46 |
$list_item_odd_text_color = isset( $_POST['list-item-odd-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-item-odd-text-color'] ) ) : ''; |
| 47 |
if ( ! $list_item_odd_text_color ) { |
| 48 |
wp_send_json_error( 'Bad request', 400 ); |
| 49 |
} |
| 50 |
|
| 51 |
$list_item_even_bg_color = isset( $_POST['list-item-even-background-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-item-even-background-color'] ) ) : ''; |
| 52 |
if ( ! $list_item_even_bg_color ) { |
| 53 |
wp_send_json_error( 'Bad request', 400 ); |
| 54 |
} |
| 55 |
|
| 56 |
$list_item_even_text_color = isset( $_POST['list-item-even-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-item-even-text-color'] ) ) : ''; |
| 57 |
if ( ! $list_item_even_text_color ) { |
| 58 |
wp_send_json_error( 'Bad request', 400 ); |
| 59 |
} |
| 60 |
|
| 61 |
$list_item_hover_bg_color = isset( $_POST['list-item-hover-background-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-item-hover-background-color'] ) ) : ''; |
| 62 |
if ( ! $list_item_hover_bg_color ) { |
| 63 |
wp_send_json_error( 'Bad request', 400 ); |
| 64 |
} |
| 65 |
|
| 66 |
$list_item_hover_text_color = isset( $_POST['list-item-hover-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['list-item-hover-text-color'] ) ) : ''; |
| 67 |
if ( ! $list_item_hover_text_color ) { |
| 68 |
wp_send_json_error( 'Bad request', 400 ); |
| 69 |
} |
| 70 |
|
| 71 |
update_option( |
| 72 |
'wppm-ap-task-list', |
| 73 |
array( |
| 74 |
'list-header-button-background-color'=>$list_header_button_background_color, |
| 75 |
'list-header-button-hover-color' =>$list_header_button_hover_color, |
| 76 |
'list-header-button-text-color' =>$list_header_button_text_color, |
| 77 |
'list-header-background-color' => $list_header_bg_color, |
| 78 |
'list-header-text-color' => $list_header_text_color, |
| 79 |
'list-item-odd-background-color' => $list_item_odd_bg_color, |
| 80 |
'list-item-odd-text-color' => $list_item_odd_text_color, |
| 81 |
'list-item-even-background-color' => $list_item_even_bg_color, |
| 82 |
'list-item-even-text-color' => $list_item_even_text_color, |
| 83 |
'list-item-hover-background-color' => $list_item_hover_bg_color, |
| 84 |
'list-item-hover-text-color' => $list_item_hover_text_color, |
| 85 |
) |
| 86 |
); |
| 87 |
do_action('wppm_set_ap_task_list_settings'); |
| 88 |
|
| 89 |
echo wp_json_encode( array( |
| 90 |
'sucess_status' => 1, |
| 91 |
'messege' => esc_html__( 'Settings saved.', 'taskbuilder' ), |
| 92 |
) ); |
| 93 |
wp_die(); |