wp jquery cdnを読み込む

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
function include_jquery_cdn_loader() {
  if( !is_admin() ){
  //WP Default jQuery Load Deregister.
  wp_deregister_script('jquery');
  //jQuery CDN
  $jsCore = '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js';
 
  //jQuery CDN Check
  $core_url = @fopen('http:'.$jsCore, 'r');
  //jQuery CDN Server Down
  if( $core_url === false ){
      $jsCore = home_url( '/' ).'DIR_NAME/wp-includes/js/jquery/jquery.js';
  }
  wp_register_script( 'jquery', $jsCore, array(), null, false );
  wp_enqueue_script( 'jquery' );
  }
}
add_action('wp_enqueue_scripts', 'include_jquery_cdn_loader');
PAGE TOP