| @@ -1,64 +1,68 @@ | ||
| 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_settings', '_ajax_nonce', false ) != 1 ) { | |
| 13 | - wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 14 | -} | |
| 15 | - | |
| 16 | -$tab_background_color = isset( $_POST['tab-background-color'] ) ? sanitize_text_field( wp_unslash( $_POST['tab-background-color'] ) ) : ''; | |
| 17 | -if ( ! $tab_background_color ) { | |
| 18 | - wp_send_json_error( 'Bad request', 400 ); | |
| 19 | -} | |
| 20 | - | |
| 21 | -$tab_text_color = isset( $_POST['tab-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['tab-text-color'] ) ) : ''; | |
| 22 | -if ( ! $tab_text_color ) { | |
| 23 | - wp_send_json_error( 'Bad request', 400 ); | |
| 24 | -} | |
| 25 | - | |
| 26 | -$add_new_button_bg_color = isset( $_POST['add-new-button-bg-color'] ) ? sanitize_text_field( wp_unslash( $_POST['add-new-button-bg-color'] ) ) : ''; | |
| 27 | -if ( ! $add_new_button_bg_color ) { | |
| 28 | - wp_send_json_error( 'Bad request', 400 ); | |
| 29 | -} | |
| 30 | - | |
| 31 | -$add_new_button_text_color = isset( $_POST['add-new-button-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['add-new-button-text-color'] ) ) : ''; | |
| 32 | -if ( ! $add_new_button_text_color ) { | |
| 33 | - wp_send_json_error( 'Bad request', 400 ); | |
| 34 | -} | |
| 35 | - | |
| 36 | -$add_new_button_hover_color = isset( $_POST['add-new-button-hover-color'] ) ? sanitize_text_field( wp_unslash( $_POST['add-new-button-hover-color'] ) ) : ''; | |
| 37 | -if ( ! $add_new_button_hover_color ) { | |
| 38 | - wp_send_json_error( 'Bad request', 400 ); | |
| 39 | -} | |
| 40 | - | |
| 41 | -$save_changes_button_bg_color = isset( $_POST['save-changes-button-bg-color'] ) ? sanitize_text_field( wp_unslash( $_POST['save-changes-button-bg-color'] ) ) : ''; | |
| 42 | -if ( ! $save_changes_button_bg_color ) { | |
| 43 | - wp_send_json_error( 'Bad request', 400 ); | |
| 44 | -} | |
| 45 | - | |
| 46 | -$save_changes_button_text_color = isset( $_POST['save-changes-button-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['save-changes-button-text-color'] ) ) : ''; | |
| 47 | -if ( ! $save_changes_button_text_color ) { | |
| 48 | - wp_send_json_error( 'Bad request', 400 ); | |
| 49 | -} | |
| 50 | -update_option( | |
| 51 | - 'wppm-ap-settings', | |
| 52 | - array( | |
| 53 | - 'tab-background-color' => $tab_background_color, | |
| 54 | - 'tab-text-color' => $tab_text_color , | |
| 55 | - 'add-new-button-bg-color'=>$add_new_button_bg_color, | |
| 56 | - 'add-new-button-text-color'=>$add_new_button_text_color, | |
| 57 | - 'add-new-button-hover-color'=>$add_new_button_hover_color, | |
| 58 | - 'save-changes-button-bg-color'=>$save_changes_button_bg_color, | |
| 59 | - 'save-changes-button-text-color'=>$save_changes_button_text_color | |
| 60 | - ) | |
| 61 | -); | |
| 62 | -do_action('wppm_set_ap_settings'); | |
| 63 | - | |
| 64 | -echo '{ "sucess_status":"1","messege":"'.__('Settings saved.','taskbuilder').'" }'; | |
| 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_settings', '_ajax_nonce', false ) != 1 ) { | |
| 13 | + wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 14 | +} | |
| 15 | + | |
| 16 | +$tab_background_color = isset( $_POST['tab-background-color'] ) ? sanitize_text_field( wp_unslash( $_POST['tab-background-color'] ) ) : ''; | |
| 17 | +if ( ! $tab_background_color ) { | |
| 18 | + wp_send_json_error( 'Bad request', 400 ); | |
| 19 | +} | |
| 20 | + | |
| 21 | +$tab_text_color = isset( $_POST['tab-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['tab-text-color'] ) ) : ''; | |
| 22 | +if ( ! $tab_text_color ) { | |
| 23 | + wp_send_json_error( 'Bad request', 400 ); | |
| 24 | +} | |
| 25 | + | |
| 26 | +$add_new_button_bg_color = isset( $_POST['add-new-button-bg-color'] ) ? sanitize_text_field( wp_unslash( $_POST['add-new-button-bg-color'] ) ) : ''; | |
| 27 | +if ( ! $add_new_button_bg_color ) { | |
| 28 | + wp_send_json_error( 'Bad request', 400 ); | |
| 29 | +} | |
| 30 | + | |
| 31 | +$add_new_button_text_color = isset( $_POST['add-new-button-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['add-new-button-text-color'] ) ) : ''; | |
| 32 | +if ( ! $add_new_button_text_color ) { | |
| 33 | + wp_send_json_error( 'Bad request', 400 ); | |
| 34 | +} | |
| 35 | + | |
| 36 | +$add_new_button_hover_color = isset( $_POST['add-new-button-hover-color'] ) ? sanitize_text_field( wp_unslash( $_POST['add-new-button-hover-color'] ) ) : ''; | |
| 37 | +if ( ! $add_new_button_hover_color ) { | |
| 38 | + wp_send_json_error( 'Bad request', 400 ); | |
| 39 | +} | |
| 40 | + | |
| 41 | +$save_changes_button_bg_color = isset( $_POST['save-changes-button-bg-color'] ) ? sanitize_text_field( wp_unslash( $_POST['save-changes-button-bg-color'] ) ) : ''; | |
| 42 | +if ( ! $save_changes_button_bg_color ) { | |
| 43 | + wp_send_json_error( 'Bad request', 400 ); | |
| 44 | +} | |
| 45 | + | |
| 46 | +$save_changes_button_text_color = isset( $_POST['save-changes-button-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['save-changes-button-text-color'] ) ) : ''; | |
| 47 | +if ( ! $save_changes_button_text_color ) { | |
| 48 | + wp_send_json_error( 'Bad request', 400 ); | |
| 49 | +} | |
| 50 | +update_option( | |
| 51 | + 'wppm-ap-settings', | |
| 52 | + array( | |
| 53 | + 'tab-background-color' => $tab_background_color, | |
| 54 | + 'tab-text-color' => $tab_text_color , | |
| 55 | + 'add-new-button-bg-color'=>$add_new_button_bg_color, | |
| 56 | + 'add-new-button-text-color'=>$add_new_button_text_color, | |
| 57 | + 'add-new-button-hover-color'=>$add_new_button_hover_color, | |
| 58 | + 'save-changes-button-bg-color'=>$save_changes_button_bg_color, | |
| 59 | + 'save-changes-button-text-color'=>$save_changes_button_text_color | |
| 60 | + ) | |
| 61 | +); | |
| 62 | +do_action('wppm_set_ap_settings'); | |
| 63 | + | |
| 64 | +echo wp_json_encode( array( | |
| 65 | + 'sucess_status' => 1, | |
| 66 | + 'messege' => esc_html__( 'Settings saved.', 'taskbuilder' ), | |
| 67 | +) ); | |
| 68 | +wp_die(); | |