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