| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user,$wpscfunction; |
| 7 |
|
| 8 |
if ( |
| 9 |
check_ajax_referer('set_general_settings', '_ajax_nonce', false) != 1 |
| 10 |
) wp_send_json_error('Unauthorised request!', 400); |
| 11 |
|
| 12 |
if (!($current_user->ID && $current_user->has_cap('manage_options'))) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
// Support page id |
| 17 |
$wpsc_support_page_id = isset($_POST) && isset($_POST['wpsc_support_page_id']) ? sanitize_text_field($_POST['wpsc_support_page_id']) : ''; |
| 18 |
update_option('wpsc_support_page_id',$wpsc_support_page_id); |
| 19 |
|
| 20 |
// Default Status |
| 21 |
$wpsc_default_ticket_status = isset($_POST) && isset($_POST['wpsc_default_ticket_status']) ? sanitize_text_field($_POST['wpsc_default_ticket_status']) : ''; |
| 22 |
update_option('wpsc_default_ticket_status',$wpsc_default_ticket_status); |
| 23 |
|
| 24 |
// Default Categories |
| 25 |
$wpsc_default_ticket_category = isset($_POST) && isset($_POST['wpsc_default_ticket_category']) ? sanitize_text_field($_POST['wpsc_default_ticket_category']) : ''; |
| 26 |
update_option('wpsc_default_ticket_category',$wpsc_default_ticket_category); |
| 27 |
|
| 28 |
// Default Priorities |
| 29 |
$wpsc_default_ticket_priority = isset($_POST) && isset($_POST['wpsc_default_ticket_priority']) ? sanitize_text_field($_POST['wpsc_default_ticket_priority']) : ''; |
| 30 |
update_option('wpsc_default_ticket_priority',$wpsc_default_ticket_priority); |
| 31 |
|
| 32 |
// Ticket status after customer reply |
| 33 |
$wpsc_ticket_status_after_customer_reply = isset($_POST) && isset($_POST['wpsc_ticket_status_after_customer_reply']) ? sanitize_text_field($_POST['wpsc_ticket_status_after_customer_reply']) : ''; |
| 34 |
update_option('wpsc_ticket_status_after_customer_reply',$wpsc_ticket_status_after_customer_reply); |
| 35 |
|
| 36 |
// Ticket status after agent reply |
| 37 |
$wpsc_ticket_status_after_agent_reply = isset($_POST) && isset($_POST['wpsc_ticket_status_after_agent_reply']) ? sanitize_text_field($_POST['wpsc_ticket_status_after_agent_reply']) : ''; |
| 38 |
update_option('wpsc_ticket_status_after_agent_reply',$wpsc_ticket_status_after_agent_reply); |
| 39 |
|
| 40 |
// Close ticket status |
| 41 |
$wpsc_close_ticket_status = isset($_POST) && isset($_POST['wpsc_close_ticket_status']) ? sanitize_text_field($_POST['wpsc_close_ticket_status']) : ''; |
| 42 |
update_option('wpsc_close_ticket_status',$wpsc_close_ticket_status); |
| 43 |
|
| 44 |
// Allow customer to close ticket |
| 45 |
$wpsc_allow_customer_close_ticket = isset($_POST) && isset($_POST['wpsc_allow_customer_close_ticket']) ? sanitize_text_field($_POST['wpsc_allow_customer_close_ticket']) : '1'; |
| 46 |
update_option('wpsc_allow_customer_close_ticket',$wpsc_allow_customer_close_ticket); |
| 47 |
|
| 48 |
// Reply form position |
| 49 |
$wpsc_reply_form_position = isset($_POST) && isset($_POST['wpsc_reply_form_position']) ? sanitize_text_field($_POST['wpsc_reply_form_position']) : '1'; |
| 50 |
update_option('wpsc_reply_form_position',$wpsc_reply_form_position); |
| 51 |
|
| 52 |
// Calender date format |
| 53 |
$wpsc_calender_date_format = isset($_POST) && isset($_POST['wpsc_calender_date_format']) ? sanitize_text_field($_POST['wpsc_calender_date_format']) : 'dd-mm-yy'; |
| 54 |
update_option('wpsc_calender_date_format',$wpsc_calender_date_format); |
| 55 |
|
| 56 |
$wpsc_ticket_alice = isset($_POST) && isset($_POST['wpsc_ticket_alice']) ? sanitize_text_field($_POST['wpsc_ticket_alice']) : 'Ticket'; |
| 57 |
update_option('wpsc_ticket_alice',$wpsc_ticket_alice); |
| 58 |
|
| 59 |
// Custom Login |
| 60 |
$wpsc_custom_login_url = isset($_POST) && isset($_POST['wpsc_custom_login_url']) ? sanitize_text_field($_POST['wpsc_custom_login_url']) : ''; |
| 61 |
update_option('wpsc_custom_login_url',$wpsc_custom_login_url); |
| 62 |
|
| 63 |
// Reply to close ticket |
| 64 |
$wpsc_allow_reply_to_close_ticket = isset($_POST) && isset($_POST['wpsc_allow_rtct']) ? $wpscfunction->sanitize_array($_POST['wpsc_allow_rtct']) : array(); |
| 65 |
update_option('wpsc_allow_reply_to_close_ticket',$wpsc_allow_reply_to_close_ticket); |
| 66 |
|
| 67 |
$wpsc_enable_default_login = isset($_POST) && isset($_POST['wpsc_default_login_setting']) ? sanitize_text_field($_POST['wpsc_default_login_setting']) : '1'; |
| 68 |
update_option('wpsc_default_login_setting',$wpsc_enable_default_login); |
| 69 |
|
| 70 |
//User Registration |
| 71 |
$wpsc_user_registration=isset($_POST) && isset($_POST['wpsc_user_registration']) ? sanitize_text_field($_POST['wpsc_user_registration']) : ''; |
| 72 |
update_option('wpsc_user_registration',$wpsc_user_registration); |
| 73 |
|
| 74 |
//User Registration Method |
| 75 |
|
| 76 |
$wpsc_user_registration_method = isset($_POST) && isset($_POST['wpsc_user_registration_method']) ? sanitize_text_field($_POST['wpsc_user_registration_method']) : ''; |
| 77 |
update_option('wpsc_user_registration_method',$wpsc_user_registration_method); |
| 78 |
|
| 79 |
//Custom user Registration Url |
| 80 |
$wpsc_custom_registration_url=isset($_POST) && isset($_POST['wpsc_custom_registration_url']) ? sanitize_text_field($_POST['wpsc_custom_registration_url']) : ''; |
| 81 |
update_option('wpsc_custom_registration_url',$wpsc_custom_registration_url); |
| 82 |
|
| 83 |
//allow create ticket |
| 84 |
$wpsc_allow_to_create_ticket = isset($_POST) && isset($_POST['wpsc_allow_to_create_ticket']) && is_array($_POST['wpsc_allow_to_create_ticket']) ? $wpscfunction->sanitize_array($_POST['wpsc_allow_to_create_ticket']) : array(); |
| 85 |
|
| 86 |
update_option('wpsc_allow_to_create_ticket',$wpsc_allow_to_create_ticket); |
| 87 |
|
| 88 |
do_action('wpsc_set_gerneral_settings'); |
| 89 |
|
| 90 |
echo '{ "sucess_status":"1","messege":"'.__('Settings saved.','supportcandy').'" }'; |
| 91 |
|