PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.7.8
Shortcodes and extra features for Phlox theme v2.7.8
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / admin / includes / admin-ajax.php
auxin-elements / admin / includes Last commit date
classes 5 years ago compatibility 5 years ago metaboxes 5 years ago modules 9 years ago admin-ajax.php 5 years ago admin-hooks.php 5 years ago admin-the-functions.php 6 years ago index.php 5 years ago
admin-ajax.php
464 lines
1 <?php
2
3 function auxin_ajax_send_feedback(){
4
5 // skip if the form data is not receiced
6 if( empty( $_POST['form'] ) ){
7 wp_send_json_error( __( 'Data cannot be delivered, please try again.', 'auxin-elements' ) );
8 }
9
10 $form_data = $_POST['form'];
11
12 // extract the form data
13 $rate = ( ! empty( $form_data['theme_rate'] ) || $form_data['theme_rate'] === '0' ) ? $form_data['theme_rate'] : '';
14 $feedback = ! empty( $form_data['feedback'] ) ? $form_data['feedback'] : '';
15 $email = ! empty( $form_data['email'] ) ? $form_data['email'] : '';
16 $nonce = ! empty( $form_data['_wpnonce'] ) ? $form_data['_wpnonce'] : '';
17
18 if( ! wp_verify_nonce( $nonce, 'phlox_feedback' ) ){
19 wp_send_json_error( __( 'Authorization failed!', 'auxin-elements' ) );
20 }
21
22 if( $rate || $rate === '0' ){
23
24 global $wp_version;
25
26 $args = array(
27 'user-agent' => 'WordPress/'.$wp_version.'; '. get_home_url(),
28 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 5),
29 'body' => array(
30 'cat' => 'rating',
31 'action' => 'submit',
32 'item-slug' => 'phlox',
33 'rate' => $rate,
34 'client_key' => get_theme_mod( 'client_key', ''),
35 'item_version'=> THEME_VERSION,
36 'theme_slug' => THEME_ID,
37 'feedback' => $feedback
38 )
39 );
40 // send the rating through the api
41 $request = wp_remote_post( 'http://api.averta.net/envato/items/', $args );
42 update_option( 'auxin_show_rate_scale_notice', 0 );
43 set_theme_mod( 'rate_scale_notice_remind_later_date', 0 );
44 // if ( ! is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) === 200 ) {}
45
46 // store the user rating on the website
47 auxin_update_option( 'user_rating', $rate );
48
49 // send the feedback via email
50 $message = 'Rate: '. $rate . "\r\n" . 'Email: <' . $email . ">\r\n\r\n" . $feedback;
51 wp_mail( 'feedbacks'.'@'.'averta.net', 'Feedback from phlox dashboard:', $message );
52
53 wp_send_json_success( __( 'Sent Successfully. Thanks for your feedback!', 'auxin-elements' ) );
54
55 } else{
56 wp_send_json_error( __( 'An error occurred. Feedback could not be delivered, please try again.', 'auxin-elements' ) );
57 }
58
59 }
60
61 add_action( 'wp_ajax_send_feedback', 'auxin_ajax_send_feedback' );
62
63 /**
64 * Hide Feedback notice
65 */
66 function auxin_remove_feedback_notice() {
67 // skip if the form data is not receiced
68 if( empty( $_POST['form'] ) ){
69 wp_send_json_error( __( 'Data cannot be delivered, please try again.', 'auxin-elements' ) );
70 }
71
72 $form_data = $_POST['form'];
73
74 $nonce = ! empty( $form_data['_wpnonce'] ) ? $form_data['_wpnonce'] : '';
75
76 if( ! wp_verify_nonce( $nonce, 'phlox_feedback' ) ){
77 wp_send_json_error( __( 'Authorization failed!', 'auxin-elements' ) );
78 }
79
80 update_option( 'auxin_show_rate_scale_notice', 0 );
81 set_theme_mod( 'rate_scale_notice_remind_later_date', 0 );
82 wp_send_json_success();
83 }
84
85 add_action( 'wp_ajax_aux-remove-feedback-notice', 'auxin_remove_feedback_notice' );
86
87
88 /**
89 * Remind feedback
90 */
91 function auxin_ajax_remind_feedback() {
92 // skip if the form data is not receiced
93 if( empty( $_POST['form'] ) ){
94 wp_send_json_error( __( 'Data cannot be delivered, please try again.', 'auxin-elements' ) );
95 }
96
97 $form_data = $_POST['form'];
98
99 $nonce = ! empty( $form_data['_wpnonce'] ) ? $form_data['_wpnonce'] : '';
100
101 if( ! wp_verify_nonce( $nonce, 'phlox_feedback' ) ){
102 wp_send_json_error( __( 'Authorization failed!', 'auxin-elements' ) );
103 }
104
105 // reset feedback notice viewer
106 update_option( 'auxin_show_rate_scale_notice', 0 );
107 set_theme_mod( 'rate_scale_notice_remind_later_date', time() + DAY_IN_SECONDS * 3 );
108
109 wp_send_json_success();
110 }
111
112 add_action( 'wp_ajax_remind_feedback', 'auxin_ajax_remind_feedback' );
113
114
115
116 function auxin_ajax_isotope_filter_group(){
117 // Check nonce
118 if ( ! isset( $_POST['group'] ) ||! isset( $_POST['key'] ) || ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'aux-iso-group' ) ) {
119 wp_send_json_error( __( 'Token Error.', 'auxin-elements' ) );
120 }
121
122 if( false !== update_option( 'aux_isotope_group_' . $_POST['key'] , $_POST['group'] ) ) {
123 wp_send_json_success( __( 'It\'s Done.', 'auxin-elements' ) );
124 }
125
126 wp_send_json_error( __( 'An error occurred.', 'auxin-elements' ) );
127 }
128 add_action( 'wp_ajax_aux_isotope_group', 'auxin_ajax_isotope_filter_group' );
129
130
131 function auxin_ajax_filter_get_content() {
132
133 // Check nonce
134 if ( ! isset( $_POST['n'] ) || ! wp_verify_nonce( $_POST['n'], 'aux_ajax_filter_request' ) ) {
135 wp_send_json_error( 'Nonce check failed!', 403 );
136 }
137
138 $num = $_POST['num'];
139 $post_type = 'product';
140 $tax = $_POST['taxonomy'];
141 $term = $_POST['term'];
142 $image_class = 'aux-img-dynamic-dropshadow';
143 $width = $_POST['width'];
144 $height = $_POST['height'];
145 $order = $_POST['order'];
146 $orderby = $_POST['orderby'];
147 $size = array( 'width' => $width, 'height' => $height );
148
149 /*
150 * The WordPress Query class.
151 *
152 * @link http://codex.wordpress.org/Function_Reference/WP_Query
153 */
154 $args = array(
155 // Type & Status Parameters
156 'post_type' => $post_type,
157 'post_status' => 'publish',
158 // Pagination Parameters
159 'posts_per_page' => $num,
160 'nopaging' => false,
161 'order' => $order,
162 'orderby' => $orderby,
163 );
164
165 if ( 'all' !== $term ) {
166 // Taxonomy Parameters
167 $args['tax_query'] = array(
168 array(
169 'taxonomy' => $tax,
170 'field' => 'slug',
171 'terms' => $term,
172 'include_children' => true,
173 'operator' => 'IN',
174 )
175 );
176 }
177
178 $posts = get_posts( $args );
179
180 foreach ( $posts as $post ) {
181
182 $image_id = get_post_thumbnail_id( $post );
183 $product = wc_get_product( $post->ID );
184
185 $post->thumb = auxin_get_the_responsive_attachment(
186 $image_id,
187 array(
188 'quality' => 100,
189 'upscale' => true,
190 'crop' => true,
191 'add_hw' => true, // whether add width and height attr or not
192 'attr' => array(
193 'class' => 'auxshp-product-image auxshp-attachment ' . $image_class,
194 'data-original-width' => $width,
195 'data-original-height' => $height,
196 'data-original-src' => wp_get_attachment_image_src( $image_id, 'full' )[0]
197 ),
198 'size' => $size,
199 'image_sizes' => 'auto',
200 'srcset_sizes' => 'auto',
201 'original_src' => true
202 )
203 );
204
205 $post->price = $product->get_price_html();
206 $post->meta = wc_get_product_category_list( $product->get_id(), ', ', '<em class="auxshp-meta-terms">', '</em>' );
207 $post->badge = $product->is_on_sale() ? true : false;
208
209 if( auxin_get_option( 'product_index_ajax_add_to_cart', '0' ) ) {
210 $class = 'button aux-ajax-add-to-cart add_to_cart_button';
211 }
212
213 $post->cart = apply_filters( 'woocommerce_loop_add_to_cart_link',
214 sprintf( '<a rel="nofollow" href="%s" data-quantity="1" data-product_id="%s" data-product_sku="%s" data-verify_nonce="%s" class="%s"><i class="aux-ico auxicon-handbag"></i><span>%s</span></a>',
215 esc_url( $product->add_to_cart_url() ),
216 esc_attr( $product->get_id() ),
217 esc_attr( $product->get_sku() ),
218 esc_attr( wp_create_nonce( 'aux_add_to_cart-' . $product->get_id() ) ),
219 esc_attr( isset( $class ) ? $class : 'button add_to_cart_button' ),
220 esc_html( $product->add_to_cart_text() )
221 ),
222 $product );
223 }
224
225 wp_send_json_success( $posts );
226
227 }
228
229 add_action( 'wp_ajax_filter_get_content', 'auxin_ajax_filter_get_content' );
230 add_action( 'wp_ajax_noprive_filter_get_content', 'auxin_ajax_filter_get_content' );
231
232 /**
233 * wordpress ajax for dismissed notice
234 *
235 * @return json
236 */
237 function auxin_dismissed_notice(){
238 // Store it in the options table
239 if ( ! isset( $_POST['id'] ) || ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], '_notice_nonce' ) ) {
240 wp_send_json_error( __( 'Token Error.', 'auxin-elements' ) );
241 } else {
242 auxin_set_transient( 'auxin-notice-' . $_POST['id'], 1, $_POST['expiration'] );
243 wp_send_json_success( __( 'It\'s OK.', 'auxin-elements' ) );
244 }
245 }
246 add_action( 'wp_ajax_auxin_dismissed_notice', 'auxin_dismissed_notice' );
247
248 /**
249 * WordPress ajax to display activation form
250 *
251 * @return html
252 */
253 function auxin_display_actvation_form(){
254 if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'aux-activation-form' ) ) {
255 // This nonce is not valid.
256 wp_die( esc_html__( 'Security Token Error!', 'auxin-elements' ) );
257 }
258 ob_start();
259 ?>
260 <div class="aux-license-popup">
261 <button class="featherlight-close-icon featherlight-close" aria-label="Close"></button>
262 <img class="aux-popup-image" src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/activation.svg' ); ?>" />
263 <h2 class="aux-popup-title"><?php esc_html_e( 'License Activation', 'auxin-elements' ); ?></h2>
264 <p class="aux-popup-desc"><?php esc_html_e( 'Please activate your license to get automatic updates, premium support, and unlimited access to the template library and demo importer.', 'auxin-elements' ); printf('&nbsp;<a href="https://help.market.envato.com/hc/en-us/articles/202822600-Where-Is-My-Purchase-Code-" target="_blank">%s</a>', esc_html( 'how to find purchase code?', 'auxin-elements' ) ); ?></p>
265 <form class="auxin-form auxin-check-purchase" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post">
266 <div class="form-group">
267 <label class="form-label" for="aux-usermail"><?php esc_html_e( 'E-mail address', 'auxin-elements' ); ?></label>
268 <input class="form-control" type="text" name="usermail" value="<?php echo esc_attr( get_option('admin_email') ); ?>" required>
269 </div>
270
271 <div class="form-group">
272 <label class="form-label" for="aux-purchase"><?php esc_html_e( 'Purchase code', 'auxin-elements' ); ?></label>
273 <input class="form-control" type="text" name="purchase" required>
274 </div>
275
276 <?php wp_nonce_field( 'auxin-purchase-activation', 'security' ); ?>
277 <input type="hidden" name="action" value="auxin_purchase_activation">
278 <div class="button-group">
279 <button type="submit" class="aux-button aux-primary aux-medium aux-activate-license" value="submit">
280 <span><?php esc_html_e( 'Activate', 'auxin-elements' ); ?></span>
281 </button>
282 </div>
283 </form>
284 </div>
285 <?php
286 wp_die( ob_get_clean() );
287 }
288 add_action( 'wp_ajax_auxin_display_actvation_form', 'auxin_display_actvation_form' );
289
290 /**
291 * wordpress ajax for auxin purchase activation
292 *
293 * @return json
294 */
295 function auxin_purchase_activation(){
296
297 if ( ! isset( $_POST['usermail'] ) || ! isset( $_POST['purchase'] ) || ! isset( $_POST['security'] ) || ! wp_verify_nonce( $_POST['security'], 'auxin-purchase-activation' ) ) {
298 wp_send_json_error( array(
299 'message' => __( 'Token Error.', 'auxin-elements' ),
300 'buttonText' => __( 'Retry', 'auxin-elements' ),
301 ) );
302 }
303
304 $usermail = $_POST['usermail'];
305 $purchase_code = $_POST['purchase'];
306 $action = 'activate';
307
308 $result = Auxin_License_Activation::get_instance()->license_action( $usermail, $purchase_code, $action );
309
310 if( isset( $result['success'] ) && $result['success'] ){
311 $result['buttonText'] = __( 'Close', 'auxin-elements' );
312 wp_send_json_success( $result );
313 }
314
315 $result['buttonText'] = __( 'Retry', 'auxin-elements' );
316 wp_send_json_error( $result );
317
318 }
319 add_action( 'wp_ajax_auxin_purchase_activation', 'auxin_purchase_activation' );
320
321 /**
322 * wordpress ajax for auxin upgrader
323 *
324 * @return json
325 */
326 function auxin_ajax_upgrader(){
327 // Check ajax nonce field
328 check_ajax_referer( 'auxin-start-upgrading', 'nonce' );
329
330 if ( ! isset( $_POST['key'] ) || ! isset( $_POST['type'] ) ) {
331 wp_send_json_error( array(
332 'slug' => '',
333 'errorCode' => 'no_token_specified',
334 'errorMessage' => __( 'Token Error.', 'auxin-elements' )
335 ) );
336 }
337
338 $handler = new Auxin_Upgrader_Ajax_Handlers;
339 $handler->run( $_POST['key'], $_POST['type'] );
340 }
341 add_action( 'wp_ajax_auxin_start_upgrading', 'auxin_ajax_upgrader' );
342
343
344 /**
345 * wordpress ajax for auxin customizer export
346 *
347 * @return json
348 */
349 function auxin_customizer_export(){
350
351 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'auxin-export-control' ) ) {
352 wp_send_json_error( __( 'Token Error.', 'auxin-elements' ) );
353 }
354
355 // Get theme options
356 $theme_options = auxin_options();
357
358 // Get theme mods
359 $theme_mods = get_theme_mods();
360 $filters = array( 0, 'nav_menu_locations', 'custom_css_post_id', 'last_checked_version' );
361 foreach ( $filters as $filter ) {
362 if ( isset( $theme_mods[ $filter ] ) ) {
363 unset( $theme_mods[ $filter ] );
364 }
365 }
366
367 if( empty( $theme_options ) && empty( $theme_mods ) ){
368 wp_send_json_error( __( 'No data found!', 'auxin-elements' ) );
369 }
370
371 $b64_content = base64_encode( maybe_serialize( array(
372 'theme_options' => $theme_options,
373 'theme_mods' => $theme_mods
374 ) ) );
375
376 wp_send_json_success( array(
377 'content' => $b64_content,
378 'fileName' => THEME_ID . '_export_' . current_time('timestamp') . '.txt'
379 ) );
380
381 }
382 add_action( 'wp_ajax_auxin_customizer_export', 'auxin_customizer_export' );
383
384
385 /**
386 * wordpress ajax for auxin customizer import
387 *
388 * @return json
389 */
390 function auxin_customizer_import(){
391 // Check security
392 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'auxin-import-control' ) ) {
393 wp_send_json_error( __( 'Token Error.', 'auxin-elements' ) );
394 }
395
396 // Check input file
397 if ( ! isset( $_FILES['file'] ) || 0 < $_FILES['file']['error'] ) {
398 wp_send_json_error( __( 'Please upload a valid file.', 'auxin-elements' ) );
399 }
400
401 // Get and decode file content
402 global $wp_filesystem;
403 if ( empty($wp_filesystem) ) {
404 require_once( ABSPATH . '/wp-admin/includes/file.php' );
405 WP_Filesystem();
406 }
407 $json_content = $wp_filesystem->get_contents( $_FILES['file']['tmp_name'] );
408 $array_content = maybe_unserialize( base64_decode( $json_content ) );
409
410 // Check array empty
411 if ( empty( $array_content ) || ! is_array( $array_content ) ) {
412 wp_send_json_error( __( 'Invalid or Empty Data.', 'auxin-elements' ) );
413 }
414
415 if( isset( $array_content['theme_options'] ) ){
416 // Get image options names
417 $get_options = auxin_get_defined_options();
418 $custom_images = array();
419 foreach ( $get_options['fields'] as $key => $value ) {
420 if ( ! array_search( 'image', $value ) ) {
421 continue;
422 }
423 $custom_images[] = $value['id'];
424 }
425 // Update options
426 foreach ( $array_content['theme_options'] as $auxin_key => $auxin_value ) {
427 if ( in_array( $auxin_key, $custom_images ) && ! empty( $auxin_value ) ) {
428 continue;
429 }
430 // Update exclusive auxin options
431 auxin_update_option( $auxin_key , $auxin_value );
432 }
433 }
434
435 if( isset( $array_content['theme_mods'] ) ){
436 foreach ( $array_content['theme_mods'] as $theme_mods_key => $theme_mods_value ) {
437 // Start theme mods loop:
438 if( $theme_mods_key === 'custom_logo' ) {
439 continue;
440 }
441 // Update theme mods
442 set_theme_mod( $theme_mods_key , $theme_mods_value );
443 }
444 }
445
446 // force to flush dynamic asset files
447 delete_transient( 'auxin_' . AUXELS_SLUG . '_version' );
448
449 wp_send_json_success( __( 'Successfully Imported.', 'auxin-elements' ) );
450
451 }
452 add_action( 'wp_ajax_auxin_customizer_import', 'auxin_customizer_import' );
453
454
455 /**
456 * Ajax handler for auxin_template_library control to import template
457 *
458 * @return json
459 */
460 function auxin_template_control_importer() {
461 wp_send_json( auxin_template_importer( $_POST['id'], $_POST['template_type'], 'update_menu' ) );
462 }
463 add_action( 'wp_ajax_auxin_template_control_importer', 'auxin_template_control_importer' );
464