Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2. /**
  3. * JavascriptとCSSの設定
  4. */
  5. function my_scripts() {
  6. global $post;
  7.  
  8. // テーマ全体で必要なJavascriptとCSS
  9. wp_enqueue_style( 'theme-style', get_stylesheet_uri() );
  10. wp_enqueue_script( 'theme-script', get_template_directory_uri() . '/js/script.js', array( 'jquery' ), '', false );
  11.  
  12. //トップページに必要なJavascript
  13. if ( is_front_page() ){
  14. wp_enqueue_script( 'my-front-script', get_template_directory_uri() . '/js/jquery.front.js', array( 'jquery' ), '', false );
  15. }
  16.  
  17. }
  18. add_action( 'wp_enqueue_scripts', 'my_scripts' );
  19.  
  20.  
  21. /**
  22. * IE9以下の設定
  23. */
  24. function my_enqueue_lt_ie9() {
  25. global $is_IE;
  26.  
  27. // IEでない時はおしまい
  28. if ( ! $is_IE ) return;
  29.  
  30. // 必要ならファイルをインクルード
  31. if ( ! function_exists( 'wp_check_browser_version' ) )
  32. include_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
  33.  
  34. // IEバージョンによってenqueue
  35. $response = wp_check_browser_version();
  36. if ( 0 > version_compare( intval( $response['version'] ) , 9 ) ){
  37. wp_enqueue_script( 'my-html5', '//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js', array(), '', false );
  38.  
  39. }
  40. }
  41. add_action( 'wp_enqueue_scripts', 'my_enqueue_lt_ie9' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement