PluginProbe ʕ •ᴥ•ʔ
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets / 4.0.8
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets v4.0.8
4.2.5 4.2.4 trunk 3.7.10 3.7.11 3.7.12 3.7.13 3.7.14 3.7.2 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8 3.8.1 3.8.10 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.8.9.1 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.5.1 4.0.6 4.0.6.1 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.2.0 4.2.1 4.2.2 4.2.3
widget-options / includes / ajax-functions.php
widget-options / includes Last commit date
admin 1 year ago pagebuilders 1 year ago widgets 1 year ago ajax-functions.php 2 years ago extras.php 1 year ago install.php 2 years ago scripts.php 1 year ago transient.php 3 years ago
ajax-functions.php
128 lines
1 <?php
2
3 /**
4 * AJAX Functions
5 *
6 * Process AJAX actions.
7 *
8 * @copyright Copyright (c) 2016, Jeffrey Carandang
9 * @since 4.0
10 */
11 // Exit if accessed directly
12 if (!defined('ABSPATH')) exit;
13
14 /**
15 * Save Options
16 *
17 * @since 1.0
18 * @return void
19 */
20 function widgetopts_ajax_save_settings()
21 {
22 $response = array('errors' => array());
23
24 if (!isset($_POST['method'])) return;
25 if (!isset($_POST['nonce'])) return;
26
27 if (!wp_verify_nonce($_POST['nonce'], 'widgetopts-settings-nonce')) {
28 return;
29 }
30
31 switch ($_POST['method']) {
32 case 'activate':
33 case 'deactivate':
34 if (!isset($_POST['module'])) return;
35
36 //update options
37 update_option('widgetopts_tabmodule-' . sanitize_text_field($_POST['module']), sanitize_text_field($_POST['method']));
38
39 //update global variable
40 widgetopts_update_option(sanitize_text_field($_POST['module']), sanitize_text_field($_POST['method']));
41 break;
42
43 case 'save':
44 $response['messages'] = array(__('Settings saved successfully.', 'widget-options'));
45 if (!isset($_POST['data'])) return;
46 parse_str($_POST['data']['--widgetopts-form-serialized-data'], $params);
47 $sanitized = widgetopts_sanitize_array($params);
48 update_option('widgetopts_tabmodule-settings', maybe_serialize($sanitized));
49
50 //reset options
51 widgetopts_update_option('settings', $sanitized);
52 break;
53
54 case 'deactivate_license':
55 global $extended_license;
56 $license = sanitize_text_field($_POST['data']['license-data']);
57 if (!empty($license)) {
58
59 if (isset($_POST['data']['shortname'])) {
60 $item_shortname = sanitize_text_field($_POST['data']['shortname']);
61 } else {
62 $item_shortname = 'widgetopts_' . preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower(WIDGETOPTS_PLUGIN_NAME)));
63 }
64 switch ($item_shortname) {
65 case 'widgetopts_sliding_widget_options':
66 global $widgetopts_sliding_license;
67 $data = $widgetopts_sliding_license->deactivate_license($license);
68 break;
69
70 default:
71 $data = $extended_license->deactivate_license($license);
72 break;
73 }
74
75 $response['button'] = sanitize_text_field($_POST['data']['button']);
76 if ($data == 'deactivated') {
77
78 $optiondata = get_option('widgetopts_license_keys');
79 $name = str_replace('widgetopts-license-btn-', '', sanitize_text_field($_POST['data']['button']));
80 $optiondata[$name] = '';
81 update_option('widgetopts_license_keys', $optiondata);
82
83 //remove license key on option
84 delete_option($item_shortname . '_license_key');
85
86 $response['messages'] = array(__('Successfully Deactivated.', 'widget-options'));
87 } else {
88 $response['messages'] = array(__('Deactivation Failed.', 'widget-options'));
89 }
90 $response['success'] = $data;
91 }
92
93 break;
94 case 'delete_widgetopts_update_transient':
95 update_option('widgetopts_upgrade', 0);
96 break;
97
98 default:
99 # code...
100 break;
101 }
102 $response['source'] = 'WIDGETOPTS_Response';
103 $response['response'] = 'success';
104 $response['closeModal'] = true;
105 $response = (object) $response;
106
107 //let devs do there action
108 do_action('widget_options_before_ajax_print', sanitize_text_field($_POST['method']));
109
110 echo json_encode($response);
111 die();
112 }
113 add_action('wp_ajax_widgetopts_ajax_settings', 'widgetopts_ajax_save_settings');
114
115 /* Hide the rating div
116 * @return json string
117 *
118 */
119 if (!function_exists('widgetopts_ajax_hide_rating')) :
120 function widgetopts_ajax_hide_rating()
121 {
122 update_option('widgetopts_RatingDiv', 'yes');
123 echo json_encode(array("success"));
124 exit;
125 }
126 add_action('wp_ajax_widgetopts_hideRating', 'widgetopts_ajax_hide_rating');
127 endif;
128