| 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_can( 'manage_options' ) && ! current_user_can( 'wppm_admin' ) ) { |
| 9 |
wp_send_json_error( 'Unauthorized', 403 ); |
| 10 |
} |
| 11 |
|
| 12 |
if ( check_ajax_referer( 'wppm_set_ap_proj_list', '_ajax_nonce', false ) != 1 ) { |
| 13 |
wp_send_json_error( 'Unauthorised request!', 401 ); |
| 14 |
} |
| 15 |
|
| 16 |
$fields = array( |
| 17 |
'list-header-button-background-color', |
| 18 |
'list-header-button-hover-color', |
| 19 |
'list-header-button-text-color', |
| 20 |
'list-header-background-color', |
| 21 |
'list-header-text-color', |
| 22 |
'list-item-odd-background-color', |
| 23 |
'list-item-odd-text-color', |
| 24 |
'list-item-even-background-color', |
| 25 |
'list-item-even-text-color', |
| 26 |
'list-item-hover-background-color', |
| 27 |
'list-item-hover-text-color', |
| 28 |
); |
| 29 |
|
| 30 |
$clean = array(); |
| 31 |
|
| 32 |
foreach ( $fields as $field ) { |
| 33 |
if ( empty( $_POST[ $field ] ) ) { |
| 34 |
wp_send_json_error( 'Bad request', 400 ); |
| 35 |
} |
| 36 |
|
| 37 |
$value = sanitize_hex_color( wp_unslash( $_POST[ $field ] ) ); |
| 38 |
|
| 39 |
if ( empty( $value ) ) { |
| 40 |
wp_send_json_error( 'Invalid color value', 400 ); |
| 41 |
} |
| 42 |
|
| 43 |
$clean[ $field ] = $value; |
| 44 |
} |
| 45 |
|
| 46 |
update_option( 'wppm-ap-project-list', $clean ); |
| 47 |
|
| 48 |
do_action('wppm_set_ap_proj_list_settings'); |
| 49 |
echo wp_json_encode( array( |
| 50 |
'sucess_status' => 1, |
| 51 |
'messege' => esc_html__( 'Settings saved.', 'taskbuilder' ), |
| 52 |
) ); |
| 53 |
wp_die(); |