functions.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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('art') ) {
  76. wp_enqueue_style( 'ani', get_template_directory_uri() . '/css/animate.css');
  77. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  78. wp_enqueue_script( 'modern', get_template_directory_uri() . '/js/modernizr.js', 'jquery', '', true );
  79. wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', '', true );
  80. wp_enqueue_script( 'offcanvas', get_template_directory_uri() . '/js/jasny-bootstrap.js', 'jquery', '', true );
  81. wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js', 'jquery', '', true );
  82. wp_enqueue_script( 'last-fm', get_template_directory_uri() . '/js/art.js', 'jquery', '', true );
  83. }
  84. elseif ( is_page('contact') ) {
  85. require( get_template_directory() . '/inc/form.php' );
  86. //gravity_form_enqueue_scripts(1, false);
  87. wp_enqueue_style( 'forms', get_template_directory_uri() . '/css/form.css');
  88. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  89. //wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  90. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/form.js', '', '', true );
  91. }
  92. elseif ( is_page('analytics') ) {
  93. require( get_template_directory() . '/inc/analytics.php' );
  94. wp_enqueue_style( 'dashboard', get_template_directory_uri() . '/css/analytics.css');
  95. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  96. //wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  97. wp_enqueue_script( 'dashboardjs', get_template_directory_uri() . '/js/analytics.js', '', '', true );
  98. }
  99. elseif ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  100. wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  101. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.js', '', '', true );
  102. wp_enqueue_script( 'comment-reply' );
  103. }
  104. elseif ( is_page('desk') || is_archive() || is_search() ) {
  105. global $wp_rewrite;
  106. //wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true); //jquery dependents
  107. wp_enqueue_style( 'ani', get_template_directory_uri() . '/css/animate.css');
  108. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  109. wp_enqueue_script( 'modern', get_template_directory_uri() . '/js/modernizr.js', 'jquery', '', true );
  110. wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', '', true );
  111. wp_enqueue_script( 'offcanvas', get_template_directory_uri() . '/js/jasny-bootstrap.js', 'jquery', '', true );
  112. wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js', 'jquery', '', true );
  113. wp_enqueue_script( 'desk', get_template_directory_uri() . '/js/desk.js', '', '', true );
  114. wp_enqueue_script( '_s_backbone-loop', get_template_directory_uri() . '/js/loop.js', array( 'jquery', 'backbone', 'underscore', 'wp-api' ), '1.0', true );
  115. $queried_object = get_queried_object();
  116. $local = array(
  117. 'loopType' => 'home',
  118. 'queriedObject' => $queried_object,
  119. 'pathInfo' => array(
  120. 'author_permastruct' => $wp_rewrite->get_author_permastruct(),
  121. 'host' => preg_replace( '#^http(s)?://#i', '', untrailingslashit( home_url() ) ),
  122. 'path' => _s_backbone_get_request_path(),
  123. 'use_trailing_slashes' => $wp_rewrite->use_trailing_slashes,
  124. 'parameters' => _s_backbone_get_request_parameters(),
  125. ),
  126. );
  127. if ( is_category() || is_tag() || is_tax() ) {
  128. $local['loopType'] = 'archive';
  129. $local['taxonomy'] = get_taxonomy( $queried_object->taxonomy );
  130. } elseif ( is_search() ) {
  131. $local['loopType'] = 'search';
  132. $local['searchQuery'] = get_search_query();
  133. } elseif ( is_author() ) {
  134. $local['loopType'] = 'author';
  135. }
  136. if ( is_paged() ) {
  137. $local['page'] = absint( get_query_var( 'paged' ) ) + 1;
  138. }
  139. wp_localize_script( '_s_backbone-loop', 'settings', $local );
  140. }
  141. else {
  142. wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  143. //wp_enqueue_script( 'script-o-min', get_template_directory_uri() . '/js/script-o.min.js', 'jquery', '', true );
  144. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.js', '', '', true );
  145. //wp_enqueue_script( 'init-o-min', get_template_directory_uri() . '/js/init-o.min.js', 'jquery', '', true );
  146. }
  147. }
  148. add_action('wp_footer', 'dw_html5shim', 21);
  149. function dw_html5shim() { ?>
  150. <!--[if lt IE 9]><script src="<?php echo get_template_directory_uri() . '/js/html5shiv.min.js'?>"></script><![endif]-->
  151. <?php }
  152. add_action('wp_footer', 'dw_analytics', 22);
  153. function dw_analytics() { ?>
  154. <script>
  155. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  156. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  157. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  158. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  159. ga('create', 'UA-1906067-6', 'davidawindham.com');
  160. ga('send', 'pageview');
  161. var _paq = _paq || [];
  162. _paq.push(['trackPageView']);
  163. _paq.push(['enableLinkTracking']);
  164. (function() {
  165. var u="//davidawindham.com/wik/";
  166. _paq.push(['setTrackerUrl', u+'piwik.php']);
  167. _paq.push(['setSiteId', 1]);
  168. var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
  169. g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  170. })();
  171. </script>
  172. <noscript><p><img src="//davidawindham.com/wik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
  173. <?php }
  174. ?>