Advertisement
Guest User

Untitled

a guest
Feb 8th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
  2. $plugin = 'wp-super-cache/wp-cache.php';
  3. if ( !is_plugin_active($plugin) ) {
  4.     // caching not active - just add body class filter hook and call it a day
  5.     add_filter('body_class','awebsome_browsel_class_names');
  6. } else {
  7.     // caching is enabled - add browser classes using AJAX calls
  8.     add_action( 'init', 'enqueue_awebsome_browsel_scripts' );   // this does the ajax request
  9.     // both logged in and not logged in users can send this AJAX request,
  10.     add_action( 'wp_ajax_nopriv_awebsome-browsel', 'awebsome_browsel_ajax' );
  11.     add_action( 'wp_ajax_awebsome-browsel', 'awebsome_browsel_ajax' );
  12.    
  13. }
  14.  
  15.  
  16. function enqueue_awebsome_browsel_scripts ( ) {
  17.     $ajaxurl = admin_url( 'admin-ajax.php' );
  18.     $ajaxurl = array_filter(explode('/', $ajaxurl));
  19.     array_shift($ajaxurl);
  20.     array_shift($ajaxurl);
  21.     $ajaxurl = '/' . implode('/',$ajaxurl);
  22.     wp_enqueue_script( 'awebsome_browsel-ajax', plugin_dir_url( __FILE__ ) . 'js/fetch-body-classes.js', array('jquery') );
  23.     wp_localize_script( 'awebsome_browsel-ajax', 'AwebsomeBrowsel', array( 'ajaxurl' => $ajaxurl ) );
  24. }
  25.  
  26. function print_awebsome_browsel_scripts ( ) {
  27.     wp_print_scripts( 'awebsome_browsel' );
  28. }
  29.  
  30. function awebsome_browsel_ajax ( ) {
  31.     echo awebsome_browsel_filter_UA();
  32.     exit();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement