functions.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. add_theme_support( 'align-wide' );
  18. }
  19. endif;
  20. add_action( 'after_setup_theme', 'dw_setup' );
  21. if ( ! function_exists( 'dw_plugs' ) ):
  22. function dw_plugs() {
  23. if (!class_exists('dw_smtp')) {
  24. //include_once(TEMPLATEPATH.'/inc/smtp.php');
  25. }
  26. if (!class_exists('dw_crumbs')) {
  27. //include_once(TEMPLATEPATH.'/inc/crumbs.php');
  28. }
  29. }
  30. endif;
  31. function dw_editor() {
  32. wp_enqueue_style( 'dw-gutenberg', get_theme_file_uri( '/css/editor.css' ), false, '1.0', 'all' );
  33. }
  34. add_action( 'enqueue_block_editor_assets', 'dw_editor' );
  35. add_action( 'wp_enqueue_scripts', 'dw_scripts' );
  36. function dw_scripts() {
  37. global $post;
  38. //wp_enqueue_style( 'style', get_stylesheet_uri() );
  39. wp_enqueue_style( 'style-min', get_template_directory_uri() . '/style.min.css');
  40. //wp_enqueue_style( 'style-o', get_template_directory_uri() . '/css/style-o.css');
  41. //wp_enqueue_style( 'style-o-min', get_template_directory_uri() . '/css/style-o.min.css');
  42. //wp_enqueue_style( 'boots', get_template_directory_uri() . '/css/boot.css');
  43. wp_deregister_script('jquery');
  44. if ( is_page('about') ) {
  45. //wp_enqueue_style( 'boot', get_template_directory_uri() . '/css/boot.css');
  46. //wp_enqueue_style( 'cal', get_template_directory_uri() . '/css/fullcalendar.css');
  47. //wp_enqueue_style( 'ani', get_template_directory_uri() . '/css/animate.css');
  48. //wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  49. //wp_enqueue_script( 'modern', get_template_directory_uri() . '/js/modernizr.js', 'jquery', '', true );
  50. //wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', '', true );
  51. //wp_enqueue_script( 'offcanvas', get_template_directory_uri() . '/js/jasny-bootstrap.js', 'jquery', '', true );
  52. //wp_enqueue_script( 'time', get_template_directory_uri() . '/js/moment.min.js', 'jquery', '', true );
  53. //wp_enqueue_script( 'cal', get_template_directory_uri() . '/js/fullcalendar.min.js', 'jquery', '', true );
  54. //wp_enqueue_script( 'valid', get_template_directory_uri() . '/js/validate.min.js', 'jquery', '', true );
  55. //wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js', 'jquery', '', true );
  56. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', 'jquery', '', true );
  57. wp_enqueue_script( 'init', get_template_directory_uri() . '/js/about.js', 'jquery', '', true );
  58. //wp_enqueue_script( 'init', get_template_directory_uri() . '/js/init.min.js', 'jquery', '', true );
  59. }
  60. elseif ( is_page('studio') ) {
  61. //wp_enqueue_style( 'ani', get_template_directory_uri() . '/css/animate.css');
  62. //wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  63. //wp_enqueue_script( 'modern', get_template_directory_uri() . '/js/modernizr.js', 'jquery', '', true );
  64. //wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', '', true );
  65. //wp_enqueue_script( 'offcanvas', get_template_directory_uri() . '/js/jasny-bootstrap.js', 'jquery', '', true );
  66. //wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js', 'jquery', '', true );
  67. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', '', '', true );
  68. wp_enqueue_script( 'init', get_template_directory_uri() . '/js/studio.js', 'jquery', '', true );
  69. }
  70. elseif ( is_page('music') ) {
  71. //wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', 'jquery', '', true );
  72. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', '', '', true );
  73. wp_enqueue_script( 'amp', get_template_directory_uri() . '/js/amp.min.js', '', '', true );
  74. wp_enqueue_script( 'chart', get_template_directory_uri() . '/js/chart.min.js', '', '', true );
  75. wp_enqueue_script( 'last-fm', get_template_directory_uri() . '/js/fm.js', '', '', true );
  76. }
  77. elseif ( is_page('art') ) {
  78. //wp_enqueue_style( 'ani', get_template_directory_uri() . '/css/animate.css');
  79. //wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
  80. //wp_enqueue_script( 'modern', get_template_directory_uri() . '/js/modernizr.js', 'jquery', '', true );
  81. //wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', '', true );
  82. //wp_enqueue_script( 'offcanvas', get_template_directory_uri() . '/js/jasny-bootstrap.js', 'jquery', '', true );
  83. //wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js', 'jquery', '', true );
  84. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', '', '', true );
  85. wp_enqueue_script( 'art', get_template_directory_uri() . '/js/art.js', 'jquery', '', true );
  86. }
  87. elseif ( is_page('contact') ) {
  88. require( get_template_directory() . '/inc/form.php' );
  89. //gravity_form_enqueue_scripts(1, false);
  90. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  91. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  92. //wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', 'jquery', '', true );
  93. //wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  94. wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', array(), '3', true);
  95. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  96. }
  97. elseif ( is_page('guests') ) {
  98. require( get_template_directory() . '/inc/form.php' );
  99. //gravity_form_enqueue_scripts(1, false);
  100. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  101. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  102. //wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', 'jquery', '', true );
  103. //wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  104. //wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', array(), '3', true);
  105. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  106. }
  107. elseif ( is_page('contract') ) {
  108. require( get_template_directory() . '/inc/form.php' );
  109. gravity_form_enqueue_scripts(1, false);
  110. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  111. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  112. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  113. }
  114. elseif ( is_page('pay') ) {
  115. require( get_template_directory() . '/inc/form.php' );
  116. //gravity_form_enqueue_scripts(1, false);
  117. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  118. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  119. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', 'jquery', '', true );
  120. //wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  121. //wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', array(), '3', true);
  122. //wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  123. }
  124. elseif ( is_page('analytics') ) {
  125. require( get_template_directory() . '/inc/analytics.php' );
  126. //wp_enqueue_style( 'dashboard', get_template_directory_uri() . '/css/analytics.css');
  127. //wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.4.min.js', array(), false, true);
  128. //wp_enqueue_script( 'script-o', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  129. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', '', '', true );
  130. wp_enqueue_script( 'dashboardjs', get_template_directory_uri() . '/js/analytics.js', '', '', true );
  131. }
  132. elseif ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  133. //wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/script-o.js', '', '', true );
  134. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', '', '', true );
  135. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.min.js', '', '', true );
  136. wp_enqueue_script( 'comment-reply' );
  137. }
  138. elseif ( is_page('desk') || is_archive() || is_search() ) {
  139. global $wp_rewrite;
  140. //wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true); //jquery dependents
  141. //wp_enqueue_style( 'ani', get_template_directory_uri() . '/css/animate.css');
  142. //wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.4.min.js', array(), false, true);
  143. //wp_enqueue_script( 'modern', get_template_directory_uri() . '/js/modernizr.js', 'jquery', '', true );
  144. //wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', '', true );
  145. //wp_enqueue_script( 'offcanvas', get_template_directory_uri() . '/js/jasny-bootstrap.js', 'jquery', '', true );
  146. //wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/scripts.js', 'jquery', '', true );
  147. wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/script.min.js', '', '', true );
  148. wp_enqueue_script( 'desk', get_template_directory_uri() . '/js/desk.js', '', '', true );
  149. wp_enqueue_script( '_s_backbone-loop', get_template_directory_uri() . '/js/loop.js', array( 'jquery', 'backbone', 'underscore', 'wp-api' ), '1.0', true );
  150. $queried_object = get_queried_object();
  151. $local = array(
  152. 'loopType' => 'home',
  153. 'queriedObject' => $queried_object,
  154. 'pathInfo' => array(
  155. 'author_permastruct' => $wp_rewrite->get_author_permastruct(),
  156. 'host' => preg_replace( '#^http(s)?://#i', '', untrailingslashit( home_url() ) ),
  157. 'path' => _s_backbone_get_request_path(),
  158. 'use_trailing_slashes' => $wp_rewrite->use_trailing_slashes,
  159. 'parameters' => _s_backbone_get_request_parameters(),
  160. ),
  161. );
  162. if ( is_category() || is_tag() || is_tax() ) {
  163. $local['loopType'] = 'archive';
  164. $local['taxonomy'] = get_taxonomy( $queried_object->taxonomy );
  165. } elseif ( is_search() ) {
  166. $local['loopType'] = 'search';
  167. $local['searchQuery'] = get_search_query();
  168. } elseif ( is_author() ) {
  169. $local['loopType'] = 'author';
  170. }
  171. if ( is_paged() ) {
  172. $local['page'] = absint( get_query_var( 'paged' ) ) + 1;
  173. }
  174. wp_localize_script( '_s_backbone-loop', 'settings', $local );
  175. }
  176. else {
  177. //wp_deregister_script('mediaelement');
  178. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', '', '', true );
  179. //wp_enqueue_script( 'script-o-min', get_template_directory_uri() . '/js/script-o.min.js', 'jquery', '', true );
  180. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.min.js', '', '', true );
  181. //wp_enqueue_script( 'init-o-min', get_template_directory_uri() . '/js/init-o.min.js', 'jquery', '', true );
  182. wp_enqueue_script( 'mediaelement-me', get_template_directory_uri() .'/js/mediaelement-and-player.min.js', '', '', true);
  183. wp_enqueue_script( 'mediaelement-wp', get_template_directory_uri() .'/js/wp-mediaelement.min.js', '', '', true);
  184. }
  185. }
  186. add_action('wp_footer', 'dw_html5shim', 21);
  187. function dw_html5shim() { ?>
  188. <!--[if lt IE 9]><script src="<?php echo get_template_directory_uri() . '/js/html5shiv.min.js'?>"></script><![endif]-->
  189. <?php }
  190. add_action('wp_footer', 'dw_analytics', 22);
  191. function dw_analytics() { ?>
  192. <script>
  193. var _paq = _paq || [];
  194. _paq.push(['trackPageView']);
  195. _paq.push(['enableLinkTracking']);
  196. (function() {
  197. var u="//davidawindham.com/wik/";
  198. _paq.push(['setTrackerUrl', u+'piwik.php']);
  199. _paq.push(['setSiteId', 1]);
  200. var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
  201. g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  202. })();
  203. </script>
  204. <noscript><p><img src="//davidawindham.com/wik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
  205. <?php }
  206. ?>