functions.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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( 'wp-block-styles' );
  10. add_theme_support( 'automatic-feed-links' );
  11. add_theme_support( 'responsive-embeds' );
  12. add_theme_support( 'menus' );
  13. add_theme_support( 'post-thumbnails' );
  14. add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
  15. add_theme_support( 'post-formats', array( 'aside', 'gallery', 'image', 'video', 'audio', 'quote', 'link', 'status', 'chat' ) );
  16. set_post_thumbnail_size( 150, 150, true );
  17. add_image_size( 'post-large', 770, 577, true );
  18. add_image_size( 'studio', 400, 300, true );
  19. add_theme_support( 'align-wide' );
  20. remove_action( 'init', 'wp_sitemaps_get_server' );
  21. }
  22. endif;
  23. add_action( 'after_setup_theme', 'dw_setup' );
  24. if ( ! function_exists( 'dw_plugs' ) ):
  25. function dw_plugs() {
  26. require( get_template_directory() . '/inc/smtp.php');
  27. //echo wp_mail( 'david@davidawindham.com', 'WP Mail Test', 'Mail is working' );
  28. if (!class_exists('dw_crumbs')) {
  29. //include_once(TEMPLATEPATH.'/inc/crumbs.php');
  30. }
  31. }
  32. endif;
  33. add_action( 'after_setup_theme', 'dw_plugs' );
  34. function dw_editor() {
  35. wp_enqueue_style( 'dw-gutenberg', get_theme_file_uri( '/css/editor.css' ), false, '1.0', 'all' );
  36. }
  37. add_action( 'enqueue_block_editor_assets', 'dw_editor' );
  38. function dw_remove_block_library_css(){
  39. wp_dequeue_style( 'wp-block-library' );
  40. }
  41. //add_action( 'wp_enqueue_scripts', 'dw_remove_block_library_css' );
  42. add_action( 'wp_enqueue_scripts', 'dw_scripts' );
  43. function dw_scripts() {
  44. global $post;
  45. wp_enqueue_style( 'style-min', get_template_directory_uri() . '/v3-style.min.css');
  46. wp_deregister_script('jquery');
  47. if ( is_page('about') ) {
  48. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  49. wp_enqueue_script( 'init', get_template_directory_uri() . '/js/about.js', '', '', true );
  50. }
  51. elseif ( is_page('studio') ) {
  52. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  53. wp_enqueue_script( 'init', get_template_directory_uri() . '/js/studio.js', '', '', true );
  54. }
  55. elseif ( is_page('music') ) {
  56. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/script.min.js', '', '', true );
  57. wp_enqueue_script( 'amp', get_template_directory_uri() . '/js/amp.min.js', '', '', true );
  58. wp_enqueue_script( 'chart', get_template_directory_uri() . '/js/chart.min.js', '', '', true );
  59. wp_enqueue_script( 'last-fm', get_template_directory_uri() . '/js/fm.js', '', '', true );
  60. }
  61. elseif ( is_page('art') ) {
  62. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  63. wp_enqueue_script( 'art', get_template_directory_uri() . '/js/art.js', '', '', true );
  64. }
  65. elseif ( is_page('contact') ) {
  66. require( get_template_directory() . '/inc/form.php' );
  67. //gravity_form_enqueue_scripts(1, false);
  68. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  69. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  70. wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', array(), '3', true);
  71. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  72. }
  73. elseif ( is_page('guests') ) {
  74. require( get_template_directory() . '/inc/form.php' );
  75. //gravity_form_enqueue_scripts(1, false);
  76. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  77. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  78. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  79. }
  80. elseif ( is_page('contract') ) {
  81. require( get_template_directory() . '/inc/form.php' );
  82. //gravity_form_enqueue_scripts(1, false);
  83. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  84. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  85. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  86. }
  87. elseif ( is_page('pay') ) {
  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/v3-script.min.js', 'jquery', '', true );
  93. }
  94. elseif ( is_page('analytics') ) {
  95. require( get_template_directory() . '/inc/analytics.php' );
  96. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.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( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  101. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.min.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/v3-script.min.js', '', '', true );
  107. wp_enqueue_script( 'desk', get_template_directory_uri() . '/js/desk.js', '', '', true );
  108. wp_enqueue_script( '_s_backbone-loop', get_template_directory_uri() . '/js/loop.js', array( 'jquery', 'backbone', 'underscore', 'wp-api' ), '1.0', true );
  109. $queried_object = get_queried_object();
  110. $local = array(
  111. 'loopType' => 'home',
  112. 'queriedObject' => $queried_object,
  113. 'pathInfo' => array(
  114. 'author_permastruct' => $wp_rewrite->get_author_permastruct(),
  115. 'host' => preg_replace( '#^http(s)?://#i', '', untrailingslashit( home_url() ) ),
  116. 'path' => _s_backbone_get_request_path(),
  117. 'use_trailing_slashes' => $wp_rewrite->use_trailing_slashes,
  118. 'parameters' => _s_backbone_get_request_parameters(),
  119. ),
  120. );
  121. if ( is_category() || is_tag() || is_tax() ) {
  122. $local['loopType'] = 'archive';
  123. $local['taxonomy'] = get_taxonomy( $queried_object->taxonomy );
  124. } elseif ( is_search() ) {
  125. $local['loopType'] = 'search';
  126. $local['searchQuery'] = get_search_query();
  127. } elseif ( is_author() ) {
  128. $local['loopType'] = 'author';
  129. }
  130. if ( is_paged() ) {
  131. $local['page'] = absint( get_query_var( 'paged' ) ) + 1;
  132. }
  133. wp_localize_script( '_s_backbone-loop', 'settings', $local );
  134. }
  135. else {
  136. //wp_deregister_script('mediaelement');
  137. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v3-script.min.js', '', '', true );
  138. //wp_enqueue_script( 'script-o-min', get_template_directory_uri() . '/js/script-o.min.js', 'jquery', '', true );
  139. wp_enqueue_script( 'init-o', get_template_directory_uri() . '/js/init-o.min.js', '', '', true );
  140. //wp_enqueue_script( 'init-o-min', get_template_directory_uri() . '/js/init-o.min.js', 'jquery', '', true );
  141. wp_enqueue_script( 'mediaelement-me', get_template_directory_uri() .'/js/mediaelement-and-player.min.js', '', '', true);
  142. wp_enqueue_script( 'mediaelement-wp', get_template_directory_uri() .'/js/wp-mediaelement.min.js', '', '', true);
  143. }
  144. }
  145. add_action('wp_footer', 'dw_html5shim', 21);
  146. function dw_html5shim() { ?>
  147. <!--[if lt IE 9]><script src="<?php echo get_template_directory_uri() . '/js/html5shiv.min.js'?>"></script><![endif]-->
  148. <?php }
  149. add_action('wp_footer', 'dw_analytics', 22);
  150. function dw_analytics() { ?>
  151. <script>
  152. var _paq = window._paq = window._paq || [];
  153. /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  154. _paq.push(['trackPageView']);
  155. _paq.push(['enableLinkTracking']);
  156. (function() {
  157. var u="https://davidawindham.com/wik/";
  158. _paq.push(['setTrackerUrl', u+'matomo.php']);
  159. _paq.push(['setSiteId', '1']);
  160. var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
  161. g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  162. })();
  163. </script>
  164. <noscript><p><img src="https://davidawindham.com/wik/matomo.php?idsite=1&amp;rec=1" style="border:0;" alt="" /></p></noscript>
  165. <?php }
  166. ?>