Advertisement
sonars

Unikanie duplikacji kodu jQuery przez pluginy w wordpressie

Dec 11th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. function load_jquery() {
  2.  
  3.     // only use this method is we're not in wp-admin
  4.     if (!is_admin()) {
  5.  
  6.         // deregister the original version of jQuery
  7.         wp_deregister_script('jquery');
  8.  
  9.         // discover the correct protocol to use
  10.         $protocol='http:';
  11.         if($_SERVER['HTTPS']=='on') {
  12.             $protocol='https:';
  13.         }
  14.  
  15.         // register the Google CDN version
  16.         wp_register_script('jquery', $protocol.'//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js', false, '1.5.2');
  17.  
  18.         // add it back into the queue
  19.         wp_enqueue_script('jquery');
  20.  
  21.     }
  22.  
  23. }
  24.  
  25. add_action('template_redirect', 'load_jquery');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement