Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Your current code - class-wordpress-popular-posts-public.php, Method enqueue_scripts()
- $params = array(
- 'rest_api' => (int) $wp_rest_api,
- 'sampling_active' => (int) $this->admin_options['tools']['sampling']['active'],
- 'sampling_rate' => $this->admin_options['tools']['sampling']['rate'],
- 'ajax_url' => esc_url_raw( rest_url( 'wordpress-popular-posts/v1/popular-posts/' ) ),
- 'action' => 'update_views_ajax',
- 'ID' => $is_single,
- 'token' => ( $wp_rest_api ) ? wp_create_nonce( 'wp_rest' ) : wp_create_nonce( 'wpp-token' ),
- 'debug' => WP_DEBUG
- );
- wp_localize_script( 'wpp-js', 'wpp_params', $params );
- // WITH BORLABS CACHE SUPPORT
- $params = array(
- 'rest_api' => (int) $wp_rest_api,
- 'sampling_active' => (int) $this->admin_options['tools']['sampling']['active'],
- 'sampling_rate' => $this->admin_options['tools']['sampling']['rate'],
- 'ajax_url' => esc_url_raw( rest_url( 'wordpress-popular-posts/v1/popular-posts/' ) ),
- 'action' => 'update_views_ajax',
- 'ID' => $is_single,
- 'token' => ( $wp_rest_api ) ? wp_create_nonce( 'wp_rest' ) : wp_create_nonce( 'wpp-token' ),
- 'debug' => WP_DEBUG
- );
- if (function_exists('BorlabsCacheHelper') && method_exists(BorlabsCacheHelper(), 'localizeScript')) {
- $params['token'] = ($wp_rest_api) ? 'wp_create_nonce__wp_rest' : 'wp_create_nonce__wpp-token',
- // Same setup, just different function
- BorlabsCacheHelper()->localizeScript('wpp-js', 'wpp_params', $params);
- } else {
- wp_localize_script( 'wpp-js', 'wpp_params', $params );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement