Advertisement
Guest User

Untitled

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