functions.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. function dw_remove_block_library_css(){
  36. wp_dequeue_style( 'wp-block-library' );
  37. }
  38. add_action( 'wp_enqueue_scripts', 'dw_remove_block_library_css' );
  39. add_action( 'wp_enqueue_scripts', 'dw_scripts' );
  40. function dw_scripts() {
  41. global $post;
  42. wp_enqueue_style( 'style-min', get_template_directory_uri() . '/v3-style.min.css');
  43. wp_deregister_script('jquery');
  44. if ( is_page('about') ) {
  45. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  46. wp_enqueue_script( 'init', get_template_directory_uri() . '/js/about.js', '', '', true );
  47. }
  48. elseif ( is_page('studio') ) {
  49. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  50. wp_enqueue_script( 'init', get_template_directory_uri() . '/js/studio.js', '', '', true );
  51. }
  52. elseif ( is_page('music') ) {
  53. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', '', '', true );
  54. wp_enqueue_script( 'amp', get_template_directory_uri() . '/js/amp.min.js', '', '', true );
  55. wp_enqueue_script( 'chart', get_template_directory_uri() . '/js/chart.min.js', '', '', true );
  56. wp_enqueue_script( 'last-fm', get_template_directory_uri() . '/js/fm.js', '', '', true );
  57. }
  58. elseif ( is_page('art') ) {
  59. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  60. wp_enqueue_script( 'art', get_template_directory_uri() . '/js/art.js', '', '', true );
  61. }
  62. elseif ( is_page('contact') ) {
  63. require( get_template_directory() . '/inc/form.php' );
  64. //gravity_form_enqueue_scripts(1, false);
  65. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  66. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  67. wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', array(), '3', true);
  68. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  69. }
  70. elseif ( is_page('guests') ) {
  71. require( get_template_directory() . '/inc/form.php' );
  72. //gravity_form_enqueue_scripts(1, false);
  73. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  74. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  75. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  76. }
  77. elseif ( is_page('contract') ) {
  78. require( get_template_directory() . '/inc/form.php' );
  79. //gravity_form_enqueue_scripts(1, false);
  80. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  81. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  82. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  83. }
  84. elseif ( is_page('pay') ) {
  85. require( get_template_directory() . '/inc/form.php' );
  86. //gravity_form_enqueue_scripts(1, false);
  87. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  88. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  89. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', 'jquery', '', true );
  90. }
  91. elseif ( is_page('analytics') ) {
  92. require( get_template_directory() . '/inc/analytics.php' );
  93. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  94. wp_enqueue_script( 'dashboardjs', get_template_directory_uri() . '/js/analytics.js', '', '', true );
  95. }
  96. elseif ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  97. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  98. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.min.js', '', '', true );
  99. wp_enqueue_script( 'comment-reply' );
  100. }
  101. elseif ( is_page('desk') || is_archive() || is_search() ) {
  102. global $wp_rewrite;
  103. wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  104. wp_enqueue_script( 'desk', get_template_directory_uri() . '/js/desk.js', '', '', true );
  105. wp_enqueue_script( '_s_backbone-loop', get_template_directory_uri() . '/js/loop.js', array( 'jquery', 'backbone', 'underscore', 'wp-api' ), '1.0', true );
  106. $queried_object = get_queried_object();
  107. $local = array(
  108. 'loopType' => 'home',
  109. 'queriedObject' => $queried_object,
  110. 'pathInfo' => array(
  111. 'author_permastruct' => $wp_rewrite->get_author_permastruct(),
  112. 'host' => preg_replace( '#^http(s)?://#i', '', untrailingslashit( home_url() ) ),
  113. 'path' => _s_backbone_get_request_path(),
  114. 'use_trailing_slashes' => $wp_rewrite->use_trailing_slashes,
  115. 'parameters' => _s_backbone_get_request_parameters(),
  116. ),
  117. );
  118. if ( is_category() || is_tag() || is_tax() ) {
  119. $local['loopType'] = 'archive';
  120. $local['taxonomy'] = get_taxonomy( $queried_object->taxonomy );
  121. } elseif ( is_search() ) {
  122. $local['loopType'] = 'search';
  123. $local['searchQuery'] = get_search_query();
  124. } elseif ( is_author() ) {
  125. $local['loopType'] = 'author';
  126. }
  127. if ( is_paged() ) {
  128. $local['page'] = absint( get_query_var( 'paged' ) ) + 1;
  129. }
  130. wp_localize_script( '_s_backbone-loop', 'settings', $local );
  131. }
  132. else {
  133. //wp_deregister_script('mediaelement');
  134. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', '', '', true );
  135. //wp_enqueue_script( 'script-o-min', get_template_directory_uri() . '/js/script-o.min.js', 'jquery', '', true );
  136. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.min.js', '', '', true );
  137. //wp_enqueue_script( 'init-o-min', get_template_directory_uri() . '/js/init-o.min.js', 'jquery', '', true );
  138. wp_enqueue_script( 'mediaelement-me', get_template_directory_uri() .'/js/mediaelement-and-player.min.js', '', '', true);
  139. wp_enqueue_script( 'mediaelement-wp', get_template_directory_uri() .'/js/wp-mediaelement.min.js', '', '', true);
  140. }
  141. }
  142. add_action('wp_footer', 'dw_html5shim', 21);
  143. function dw_html5shim() { ?>
  144. <!--[if lt IE 9]><script src="<?php echo get_template_directory_uri() . '/js/html5shiv.min.js'?>"></script><![endif]-->
  145. <?php }
  146. add_action('wp_footer', 'dw_analytics', 22);
  147. function dw_analytics() { ?>
  148. <script>
  149. var _paq = _paq || [];
  150. _paq.push(['trackPageView']);
  151. _paq.push(['enableLinkTracking']);
  152. (function() {
  153. var u="//davidawindham.com/wik/";
  154. _paq.push(['setTrackerUrl', u+'piwik.php']);
  155. _paq.push(['setSiteId', 1]);
  156. var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
  157. g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  158. })();
  159. </script>
  160. <noscript><p><img src="//davidawindham.com/wik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
  161. <?php }
  162. ?>