Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
- $plugin = 'wp-super-cache/wp-cache.php';
- if ( !is_plugin_active($plugin) ) {
- // caching not active - just add body class filter hook and call it a day
- add_filter('body_class','awebsome_browsel_class_names');
- } else {
- // caching is enabled - add browser classes using AJAX calls
- add_action( 'init', 'enqueue_awebsome_browsel_scripts' ); // this does the ajax request
- // both logged in and not logged in users can send this AJAX request,
- add_action( 'wp_ajax_nopriv_awebsome-browsel', 'awebsome_browsel_ajax' );
- add_action( 'wp_ajax_awebsome-browsel', 'awebsome_browsel_ajax' );
- }
- function enqueue_awebsome_browsel_scripts ( ) {
- $ajaxurl = admin_url( 'admin-ajax.php' );
- $ajaxurl = array_filter(explode('/', $ajaxurl));
- array_shift($ajaxurl);
- array_shift($ajaxurl);
- $ajaxurl = '/' . implode('/',$ajaxurl);
- wp_enqueue_script( 'awebsome_browsel-ajax', plugin_dir_url( __FILE__ ) . 'js/fetch-body-classes.js', array('jquery') );
- wp_localize_script( 'awebsome_browsel-ajax', 'AwebsomeBrowsel', array( 'ajaxurl' => $ajaxurl ) );
- }
- function print_awebsome_browsel_scripts ( ) {
- wp_print_scripts( 'awebsome_browsel' );
- }
- function awebsome_browsel_ajax ( ) {
- echo awebsome_browsel_filter_UA();
- exit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement