functions.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. if ( ! function_exists( 'dw_setup' ) ):
  3. function dw_setup() {
  4. require( get_template_directory() . '/inc/utils.php' );
  5. require( get_template_directory() . '/inc/template.php' );
  6. require( get_template_directory() . '/inc/tweaks.php' );
  7. if ( ! isset( $content_width ) ) $content_width = 1310;
  8. add_theme_support( 'automatic-feed-links' );
  9. add_theme_support( 'menus' );
  10. add_theme_support( 'post-thumbnails' );
  11. add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
  12. add_theme_support( 'post-formats', array( 'aside', 'gallery', 'image', 'video', 'audio', 'quote', 'link', 'status', 'chat' ) );
  13. set_post_thumbnail_size( 150, 150, true );
  14. add_image_size( 'post-large', 770, 577, true );
  15. add_image_size( 'studio', 400, 300, true );
  16. }
  17. endif;
  18. add_action( 'after_setup_theme', 'dw_setup' );
  19. if ( ! function_exists( 'dw_plugs' ) ):
  20. function dw_plugs() {
  21. if (!class_exists('dw_smtp')) {
  22. include_once(TEMPLATEPATH.'/inc/smtp.php');
  23. }
  24. if (!class_exists('dw_crumbs')) {
  25. //include_once(TEMPLATEPATH.'/inc/crumbs.php');
  26. }
  27. }
  28. endif;
  29. function dw_editor() {
  30. //add_editor_style( 'style.css' );
  31. }
  32. add_action( 'init', 'dw_editor' );
  33. add_action( 'wp_enqueue_scripts', 'dw_scripts' );
  34. function dw_scripts() {
  35. global $post;
  36. wp_enqueue_style( 'style', get_stylesheet_uri() );
  37. //wp_enqueue_style( 'style-min', get_template_directory_uri() . '/css/style.min.css');
  38. //wp_enqueue_style( 'style-o', get_template_directory_uri() . '/css/style-o.css');
  39. //wp_enqueue_style( 'style-o-min', get_template_directory_uri() . '/css/style-o.min.css');
  40. wp_enqueue_style( 'boots', get_template_directory_uri() . '/css/boot.css');
  41. wp_deregister_script('jquery');
  42. if ( is_page('about') ) {
  43. wp_enqueue_style( 'boot', get_template_directory_uri() . '/css/boot.css');
  44. wp_enqueue_style( 'cal', get_template_directory_uri() . '/css/fullcalendar.css');
  45. wp_enqueue_style( 'ani', get_template_directory_uri() . '/css/animate.css');
  46. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  47. wp_enqueue_script( 'modern', get_template_directory_uri() . '/js/modernizr.js', 'jquery', '', true );
  48. wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', '', true );
  49. wp_enqueue_script( 'offcanvas', get_template_directory_uri() . '/js/jasny-bootstrap.js', 'jquery', '', true );
  50. wp_enqueue_script( 'time', get_template_directory_uri() . '/js/moment.min.js', 'jquery', '', true );
  51. wp_enqueue_script( 'cal', get_template_directory_uri() . '/js/fullcalendar.min.js', 'jquery', '', true );
  52. wp_enqueue_script( 'valid', get_template_directory_uri() . '/js/validate.min.js', 'jquery', '', true );
  53. wp_enqueue_script( 'smooth', get_template_directory_uri() . '/js/smooth.js', 'jquery', '', true );
  54. wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js', 'jquery', '', true );
  55. //wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', 'jquery', '', true );
  56. wp_enqueue_script( 'init', get_template_directory_uri() . '/js/init.js', 'jquery', '', true );
  57. //wp_enqueue_script( 'init', get_template_directory_uri() . '/js/init.min.js', 'jquery', '', true );
  58. }
  59. elseif ( is_page('studio') ) {
  60. wp_enqueue_style( 'ani', get_template_directory_uri() . '/css/animate.css');
  61. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  62. wp_enqueue_script( 'modern', get_template_directory_uri() . '/js/modernizr.js', 'jquery', '', true );
  63. wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', '', true );
  64. wp_enqueue_script( 'offcanvas', get_template_directory_uri() . '/js/jasny-bootstrap.js', 'jquery', '', true );
  65. wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js', 'jquery', '', true );
  66. wp_enqueue_script( 'init', get_template_directory_uri() . '/js/studio.js', 'jquery', '', true );
  67. }
  68. elseif ( is_page('music') ) {
  69. //wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', 'jquery', '', true );
  70. wp_enqueue_script( 'script-o-min', get_template_directory_uri() . '/js/script-o.min.js', 'jquery', '', true );
  71. wp_enqueue_script( 'amp', get_template_directory_uri() . '/js/amp.min.js', 'jquery', '', true );
  72. wp_enqueue_script( 'chart', get_template_directory_uri() . '/js/chart.min.js', 'jquery', '', true );
  73. wp_enqueue_script( 'last-fm', get_template_directory_uri() . '/js/fm.js', 'jquery', '', true );
  74. }
  75. elseif ( is_page('contact') ) {
  76. require( get_template_directory() . '/inc/form.php' );
  77. //gravity_form_enqueue_scripts(1, false);
  78. wp_enqueue_style( 'forms', get_template_directory_uri() . '/css/form.css');
  79. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  80. //wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  81. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/form.js', '', '', true );
  82. }
  83. elseif ( is_page('analytics') ) {
  84. require( get_template_directory() . '/inc/analytics.php' );
  85. wp_enqueue_style( 'dashboard', get_template_directory_uri() . '/css/analytics.css');
  86. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  87. //wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  88. wp_enqueue_script( 'dashboardjs', get_template_directory_uri() . '/js/analytics.js', '', '', true );
  89. }
  90. elseif ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  91. wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  92. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.js', '', '', true );
  93. wp_enqueue_script( 'comment-reply' );
  94. }
  95. elseif ( is_page('desk') || is_archive() || is_search() ) {
  96. global $wp_rewrite;
  97. //wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true); //jquery dependents
  98. wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  99. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.js', '', '', true );
  100. wp_enqueue_script( '_s_backbone-loop', get_template_directory_uri() . '/js/loop.js', array( 'jquery', 'backbone', 'underscore', 'wp-api' ), '1.0', true );
  101. $queried_object = get_queried_object();
  102. $local = array(
  103. 'loopType' => 'home',
  104. 'queriedObject' => $queried_object,
  105. 'pathInfo' => array(
  106. 'author_permastruct' => $wp_rewrite->get_author_permastruct(),
  107. 'host' => preg_replace( '#^http(s)?://#i', '', untrailingslashit( home_url() ) ),
  108. 'path' => _s_backbone_get_request_path(),
  109. 'use_trailing_slashes' => $wp_rewrite->use_trailing_slashes,
  110. 'parameters' => _s_backbone_get_request_parameters(),
  111. ),
  112. );
  113. if ( is_category() || is_tag() || is_tax() ) {
  114. $local['loopType'] = 'archive';
  115. $local['taxonomy'] = get_taxonomy( $queried_object->taxonomy );
  116. } elseif ( is_search() ) {
  117. $local['loopType'] = 'search';
  118. $local['searchQuery'] = get_search_query();
  119. } elseif ( is_author() ) {
  120. $local['loopType'] = 'author';
  121. }
  122. if ( is_paged() ) {
  123. $local['page'] = absint( get_query_var( 'paged' ) ) + 1;
  124. }
  125. wp_localize_script( '_s_backbone-loop', 'settings', $local );
  126. }
  127. else {
  128. wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  129. //wp_enqueue_script( 'script-o-min', get_template_directory_uri() . '/js/script-o.min.js', 'jquery', '', true );
  130. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.js', '', '', true );
  131. //wp_enqueue_script( 'init-o-min', get_template_directory_uri() . '/js/init-o.min.js', 'jquery', '', true );
  132. }
  133. }
  134. add_action('wp_footer', 'dw_html5shim', 21);
  135. function dw_html5shim() { ?>
  136. <!--[if lt IE 9]><script src="<?php echo get_template_directory_uri() . '/js/html5shiv.min.js'?>"></script><![endif]-->
  137. <?php }
  138. add_action('wp_footer', 'dw_analytics', 22);
  139. function dw_analytics() { ?>
  140. <script>
  141. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  142. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  143. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  144. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  145. ga('create', 'UA-1906067-6', 'davidawindham.com');
  146. ga('send', 'pageview');
  147. var _paq = _paq || [];
  148. _paq.push(['trackPageView']);
  149. _paq.push(['enableLinkTracking']);
  150. (function() {
  151. var u="//davidawindham.com/wik/";
  152. _paq.push(['setTrackerUrl', u+'piwik.php']);
  153. _paq.push(['setSiteId', 1]);
  154. var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
  155. g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  156. })();
  157. </script>
  158. <noscript><p><img src="//davidawindham.com/wik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
  159. <?php }
  160. ?>