PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 3.3.2
Strong Testimonials v3.3.2
3.3.2 3.3.1 trunk 1.0.1 2.30.9 2.31.10 2.32 2.32.1 2.32.2 2.32.3 2.32.4 2.33 2.34 2.35 2.36 2.37 2.38 2.38.1 2.39 2.39.1 2.39.2 2.39.3 2.40.0 2.40.1 2.40.2 2.40.3 2.40.4 2.40.5 2.40.6 2.40.7 2.41.0 2.41.1 2.50.0 2.50.1 2.50.2 2.50.3 2.50.4 2.51.0 2.51.1 2.51.2 2.51.3 2.51.4 2.51.5 2.51.6 2.51.7 2.51.8 2.51.9 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0
strong-testimonials / admin / views-ajax.php
strong-testimonials / admin Last commit date
challenge 1 year ago css 1 day ago img 1 year ago js 1 month ago menu 1 month ago partials 1 week ago rest-api 1 day ago scss 1 year ago settings 1 day ago uninstall 1 year ago wpchill 1 month ago admin-notices.php 5 months ago admin.php 1 month ago class-strong-testimonials-addons.php 1 month ago class-strong-testimonials-admin-category-list.php 1 year ago class-strong-testimonials-admin-list.php 1 year ago class-strong-testimonials-admin-scripts.php 1 month ago class-strong-testimonials-admin.php 1 month ago class-strong-testimonials-debug.php 5 months ago class-strong-testimonials-exporter.php 1 year ago class-strong-testimonials-help.php 1 year ago class-strong-testimonials-helper.php 1 month ago class-strong-testimonials-list-table.php 1 year ago class-strong-testimonials-lite-vs-pro-page.php 1 month ago class-strong-testimonials-post-editor.php 6 months ago class-strong-testimonials-review.php 1 year ago class-strong-testimonials-updater.php 1 month ago class-strong-testimonials-upsell.php 1 day ago class-strong-views-list-table.php 1 month ago class-walker-strong-category-checklist.php 1 year ago class-walker-strong-form-category-checklist.php 1 year ago class-wpmtst-onboarding.php 1 year ago compat.php 1 year ago custom-fields-ajax.php 1 year ago custom-fields.php 1 day ago form-preview.php 1 year ago view-list-order.php 1 year ago views-ajax.php 1 month ago views-validate.php 1 year ago views.php 1 month ago
views-ajax.php
299 lines
1 <?php
2 /**
3 * Views Ajax Functions
4 */
5
6
7 /**
8 * Check for forced options.
9 *
10 * @since 1.25.0
11 */
12 function wpmtst_force_check() {
13
14 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpmtst-admin-views-script-nonce' ) ) {//phpcs:ignore
15 wp_send_json_error( array( 'message' => __( 'Nonce does not exist.', 'strong-testimonials' ) ) );
16 die();
17 }
18
19 if ( ! current_user_can( 'manage_options' ) ) {
20 wp_send_json_error( array( 'message' => __( 'Insufficient capabilities.', 'strong-testimonials' ) ) );
21 die();
22 }
23
24 $atts = array( 'template' => isset( $_POST['template'] ) ? sanitize_text_field( wp_unslash( $_POST['template'] ) ) : 'default' );
25 $force = WPMST()->templates->get_template_config( $atts, 'force', false );
26 if ( $force ) {
27 wp_send_json_success( (array) $force );
28 }
29 wp_send_json_error();
30 }
31 add_action( 'wp_ajax_wpmtst_force_check', 'wpmtst_force_check' );
32
33
34 /**
35 * [Add New Field] Ajax receiver
36 *
37 * @since 1.21.0
38 */
39 function wpmtst_view_add_field_function() {
40
41 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpmtst-admin-views-script-nonce' ) ) { //phpcs:ignore
42 wp_send_json_error( array( 'message' => __( 'Nonce does not exist.', 'strong-testimonials' ) ) );
43 die();
44 }
45
46 if ( ! current_user_can( 'manage_options' ) ) {
47 wp_send_json_error( array( 'message' => __( 'Insufficient capabilities.', 'strong-testimonials' ) ) );
48 die();
49 }
50
51 $new_key = isset( $_POST['key'] ) ? absint( $_POST['key'] ) : 0;
52 $empty_field = array(
53 'field' => '',
54 'type' => 'text',
55 'class' => '',
56 );
57 $source = 'view[data]';
58 if ( isset( $_POST['source'] ) && ! empty( $_POST['source'] ) ) {
59 $source = sanitize_text_field( wp_unslash( $_POST['source'] ) );
60 }
61 wpmtst_view_field_inputs( $new_key, $empty_field, true, $source );
62 wp_die();
63 }
64 add_action( 'wp_ajax_wpmtst_view_add_field', 'wpmtst_view_add_field_function' );
65
66
67 /**
68 * [Field Type: Link] Ajax receiver
69 *
70 * @since 1.21.0
71 */
72 function wpmtst_view_add_field_link_function() {
73
74 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpmtst-admin-views-script-nonce' ) ) { //phpcs:ignore
75 wp_send_json_error( array( 'message' => __( 'Nonce does not exist.', 'strong-testimonials' ) ) );
76 die();
77 }
78
79 if ( ! current_user_can( 'manage_options' ) ) {
80 wp_send_json_error( array( 'message' => __( 'Insufficient capabilities.', 'strong-testimonials' ) ) );
81 die();
82 }
83
84 $key = isset( $_POST['key'] ) ? absint( $_POST['key'] ) : 0;
85 $field_name = isset( $_POST['fieldName'] ) ? sanitize_text_field( wp_unslash( $_POST['fieldName'] ) ) : 'new_field';
86 $type = isset( $_POST['fieldType'] ) ? sanitize_text_field( wp_unslash( $_POST['fieldType'] ) ) : 'text';
87 $empty_field = array(
88 'url' => '',
89 'link_text' => '',
90 'new_tab' => true,
91 );
92 $source = 'view[data]';
93 if ( isset( $_POST['source'] ) && ! empty( $_POST['source'] ) ) {
94 $source = sanitize_text_field( wp_unslash( $_POST['source'] ) );
95 }
96 wpmtst_view_field_link( $key, $field_name, $type, $empty_field, false, $source );
97 wp_die();
98 }
99 add_action( 'wp_ajax_wpmtst_view_add_field_link', 'wpmtst_view_add_field_link_function' );
100
101
102 /**
103 * [Field name change] Ajax receiver
104 *
105 * @since 1.24.0
106 */
107 function wpmtst_view_get_label_function() {
108
109 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpmtst-admin-views-script-nonce' ) ) { //phpcs:ignore
110 wp_send_json_error( array( 'message' => __( 'Nonce does not exist.', 'strong-testimonials' ) ) );
111 die();
112 }
113
114 if ( ! current_user_can( 'manage_options' ) ) {
115 wp_send_json_error( array( 'message' => __( 'Insufficient capabilities.', 'strong-testimonials' ) ) );
116 die();
117 }
118
119 $field = array( 'field' => isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : '' );
120 $label = wpmtst_get_field_label( $field );
121 echo esc_html( $label );
122 wp_die();
123 }
124 add_action( 'wp_ajax_wpmtst_view_get_label', 'wpmtst_view_get_label_function' );
125
126
127 /**
128 * [Field Type: Date] Ajax receiver
129 *
130 * @since 1.21.0
131 */
132 function wpmtst_view_add_field_date_function() {
133
134 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpmtst-admin-views-script-nonce' ) ) { //phpcs:ignore
135 wp_send_json_error( array( 'message' => __( 'Nonce does not exist.', 'strong-testimonials' ) ) );
136 die();
137 }
138
139 if ( ! current_user_can( 'manage_options' ) ) {
140 wp_send_json_error( array( 'message' => __( 'Insufficient capabilities.', 'strong-testimonials' ) ) );
141 die();
142 }
143
144 $key = isset( $_POST['key'] ) ? (int) sanitize_text_field( wp_unslash( $_POST['key'] ) ) : 0;
145 $empty_field = array( 'format' => '' );
146 $source = 'view[data]';
147 if ( isset( $_POST['source'] ) && ! empty( $_POST['source'] ) ) {
148 $source = sanitize_text_field( wp_unslash( $_POST['source'] ) );
149 }
150 wpmtst_view_field_date( $key, $empty_field, false, $source );
151 wp_die();
152 }
153 add_action( 'wp_ajax_wpmtst_view_add_field_date', 'wpmtst_view_add_field_date_function' );
154
155 /**
156 * [Field Type: Checkbox Value] Ajax receiver
157 *
158 * @since 2.40.4
159 */
160 function wpmtst_view_add_field_checkbox_function() {
161
162 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpmtst-admin-views-script-nonce' ) ) { //phpcs:ignore
163 wp_send_json_error( array( 'message' => __( 'Nonce does not exist.', 'strong-testimonials' ) ) );
164 die();
165 }
166
167 if ( ! current_user_can( 'manage_options' ) ) {
168 wp_send_json_error( array( 'message' => __( 'Insufficient capabilities.', 'strong-testimonials' ) ) );
169 die();
170 }
171
172 $key = isset( $_POST['key'] ) ? (int) sanitize_text_field( wp_unslash( $_POST['key'] ) ) : 0;
173 $field = array(
174 'field' => isset( $_POST['fieldName'] ) ? sanitize_text_field( wp_unslash( $_POST['fieldName'] ) ) : 'new_field',
175 'type' => isset( $_POST['fieldType'] ) ? sanitize_text_field( wp_unslash( $_POST['fieldType'] ) ) : 'text',
176 );
177 $empty_field = array(
178 'custom_label' => '',
179 'checked_value' => '',
180 'unchecked_value' => '',
181 );
182 $source = 'view[data]';
183 if ( isset( $_POST['source'] ) && ! empty( $_POST['source'] ) ) {
184 $source = sanitize_text_field( wp_unslash( $_POST['source'] ) );
185 }
186 wpmtst_view_field_checkbox( $key, $field, $empty_field, $source );
187 wp_die();
188 }
189 add_action( 'wp_ajax_wpmtst_view_add_field_checkbox', 'wpmtst_view_add_field_checkbox_function' );
190
191
192 /**
193 * Fetch the view mode description.
194 *
195 * @since 2.22.0
196 */
197 function wpmtst_view_get_mode_description() {
198
199 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpmtst-admin-views-script-nonce' ) ) { //phpcs:ignore
200 wp_send_json_error( array( 'message' => __( 'Nonce does not exist.', 'strong-testimonials' ) ) );
201 die();
202 }
203
204 if ( ! current_user_can( 'manage_options' ) ) {
205 wp_send_json_error( array( 'message' => __( 'Insufficient capabilities.', 'strong-testimonials' ) ) );
206 die();
207 }
208
209 $mode = isset( $_POST['mode'] ) ? sanitize_text_field( wp_unslash( $_POST['mode'] ) ) : 'display';
210 $options = Strong_Testimonials_Defaults::get_view_options();
211 if ( isset( $options['mode'][ $mode ]['description'] ) ) {
212 $description = $options['mode'][ $mode ]['description'];
213 $description = apply_filters( 'wpmtst_mode_description', $description, $mode );
214 echo wp_kses_post( $description );
215 }
216 wp_die();
217 }
218 add_action( 'wp_ajax_wpmtst_view_get_mode_description', 'wpmtst_view_get_mode_description' );
219
220
221 /**
222 * Get background color presets in View editor.
223 */
224 function wpmtst_get_background_preset_colors() {
225
226 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpmtst-admin-views-script-nonce' ) ) { //phpcs:ignore
227 wp_send_json_error( array( 'message' => __( 'Nonce does not exist.', 'strong-testimonials' ) ) );
228 die();
229 }
230
231 if ( ! current_user_can( 'manage_options' ) ) {
232 wp_send_json_error( array( 'message' => __( 'Insufficient capabilities.', 'strong-testimonials' ) ) );
233 die();
234 }
235
236 $preset = wpmtst_get_background_presets( isset( $_POST['key'] ) ? sanitize_text_field( wp_unslash( $_POST['key'] ) ) : 0 );
237 echo json_encode( $preset );
238 wp_die();
239 }
240 add_action( 'wp_ajax_wpmtst_get_background_preset_colors', 'wpmtst_get_background_preset_colors' );
241
242
243 /**
244 * [Restore Default Breakpoints] Ajax receiver.
245 *
246 * @since 2.32.2
247 */
248 function wpmtst_restore_default_breakpoints_function() {
249
250 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpmtst-admin-views-script-nonce' ) ) { //phpcs:ignore
251 wp_send_json_error( array( 'message' => __( 'Nonce does not exist.', 'strong-testimonials' ) ) );
252 die();
253 }
254
255 if ( ! current_user_can( 'manage_options' ) ) {
256 wp_send_json_error( array( 'message' => __( 'Insufficient capabilities.', 'strong-testimonials' ) ) );
257 die();
258 }
259
260 $options = Strong_Testimonials_Defaults::get_default_view();
261 $breakpoints = $options['slideshow_settings']['breakpoints'];
262 echo json_encode( $breakpoints );
263 wp_die();
264 }
265 add_action( 'wp_ajax_wpmtst_restore_default_breakpoints', 'wpmtst_restore_default_breakpoints_function' );
266
267
268 /**
269 * [Field Type: Category] Ajax receiver
270 *
271 * @since 3.1.8
272 */
273 function wpmtst_view_add_field_category_type_select() {
274 if ( ! isset( $_POST['nonce'] ) ) {
275 // Nonce doesn't exist.
276 wp_send_json_error( array( 'message' => __( 'Nonce does not exist.', 'strong-testimonials' ) ) );
277 }
278 check_ajax_referer( 'wpmtst-admin-views-script-nonce', 'nonce' );
279
280 if ( ! current_user_can( 'manage_options' ) ) {
281 wp_send_json_error( array( 'message' => __( 'Insufficient capabilities.', 'strong-testimonials' ) ) );
282 die();
283 }
284
285 $key = isset( $_POST['key'] ) ? absint( $_POST['key'] ) : 0;
286 $field_name = isset( $_POST['fieldName'] ) ? sanitize_text_field( wp_unslash( $_POST['fieldName'] ) ) : 'category';
287 $type = isset( $_POST['fieldType'] ) ? sanitize_text_field( wp_unslash( $_POST['fieldType'] ) ) : 'select';
288 $empty_field = array(
289 'url' => '',
290 'link_text' => '',
291 'new_tab' => true,
292 );
293 $source = 'view[data]';
294
295 wpmtst_view_field_category( $key, $field_name );
296 wp_die();
297 }
298 add_action( 'wp_ajax_wpmtst_view_add_field_category_type_select', 'wpmtst_view_add_field_category_type_select' );
299