functions.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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_filter( 'big_image_size_threshold', '__return_false' );
  20. add_theme_support( 'align-wide' );
  21. remove_action( 'init', 'wp_sitemaps_get_server' );
  22. // added this to remove depreciation warning in v6.4.1 b/c front page doesn't have wp_header
  23. remove_action( 'wp_footer', 'the_block_template_skip_link' );
  24. // see changes @ https://core.trac.wordpress.org/changeset/56932
  25. }
  26. endif;
  27. add_action( 'after_setup_theme', 'dw_setup' );
  28. if ( ! function_exists( 'dw_plugs' ) ):
  29. function dw_plugs() {
  30. require( get_template_directory() . '/inc/smtp.php');
  31. //echo wp_mail( 'david@davidawindham.com', 'WP Mail Test', 'Mail is working' );
  32. if (!class_exists('dw_crumbs')) {
  33. //include_once(TEMPLATEPATH.'/inc/crumbs.php');
  34. }
  35. }
  36. endif;
  37. add_action( 'after_setup_theme', 'dw_plugs' );
  38. function dw_editor() {
  39. wp_enqueue_style( 'dw-gutenberg', get_theme_file_uri( '/css/editor.css' ), false, '1.0', 'all' );
  40. }
  41. add_action( 'enqueue_block_editor_assets', 'dw_editor' );
  42. function dw_remove_block_library_css(){
  43. wp_dequeue_style( 'wp-block-library' );
  44. }
  45. //add_action( 'wp_enqueue_scripts', 'dw_remove_block_library_css' );
  46. add_action( 'wp_enqueue_scripts', 'dw_scripts' );
  47. function dw_scripts() {
  48. global $post;
  49. wp_enqueue_style( 'style-min', get_template_directory_uri() . '/v4-style.min.css');
  50. wp_deregister_script('jquery');
  51. if ( is_page('about') ) {
  52. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  53. wp_enqueue_script( 'init', get_template_directory_uri() . '/js/about.js', '', '', true );
  54. }
  55. elseif ( is_page('studio') ) {
  56. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  57. wp_enqueue_script( 'init', get_template_directory_uri() . '/js/studio.js', '', '', true );
  58. }
  59. elseif ( is_page('music') ) {
  60. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  61. wp_enqueue_script( 'last-fm', get_template_directory_uri() . '/js/music.js', '', '', true );
  62. }
  63. elseif ( is_page('art') ) {
  64. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  65. wp_enqueue_script( 'art', get_template_directory_uri() . '/js/art.js', '', '', true );
  66. }
  67. elseif ( is_page('contact') ) {
  68. require( get_template_directory() . '/inc/form.php' );
  69. //gravity_form_enqueue_scripts(1, false);
  70. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  71. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  72. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  73. wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', array(), '3', true);
  74. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  75. }
  76. elseif ( is_page('guests') ) {
  77. require( get_template_directory() . '/inc/form.php' );
  78. //gravity_form_enqueue_scripts(1, false);
  79. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  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('contract') ) {
  85. require( get_template_directory() . '/inc/form.php' );
  86. //gravity_form_enqueue_scripts(1, false);
  87. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  88. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  89. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  90. wp_enqueue_script( 'form', get_template_directory_uri() . '/js/contact.js', '', '', true );
  91. }
  92. elseif ( is_page('pay') ) {
  93. require( get_template_directory() . '/inc/form.php' );
  94. //gravity_form_enqueue_scripts(1, false);
  95. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  96. wp_enqueue_style( 'gforms', get_template_directory_uri() . '/css/form.css');
  97. wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-3.1.0.min.js', array(), false, true);
  98. }
  99. elseif ( is_page('analytics') ) {
  100. require( get_template_directory() . '/inc/analytics.php' );
  101. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v4-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( 'scriptmin', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  106. wp_enqueue_script( 'single', get_template_directory_uri() . '/js/single.js', '', '', true );
  107. wp_enqueue_script( 'comment-reply' );
  108. }
  109. elseif ( is_page('desk') || is_archive() || is_search() ) {
  110. global $wp_rewrite;
  111. wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  112. wp_enqueue_script( 'desk', get_template_directory_uri() . '/js/desk.js', '', '', true );
  113. wp_enqueue_script( '_s_backbone-loop', get_template_directory_uri() . '/js/loop.js', array( 'jquery', 'backbone', 'underscore', 'wp-api' ), '1.0', true );
  114. $queried_object = get_queried_object();
  115. $local = array(
  116. 'loopType' => 'home',
  117. 'queriedObject' => $queried_object,
  118. 'pathInfo' => array(
  119. 'author_permastruct' => $wp_rewrite->get_author_permastruct(),
  120. 'host' => preg_replace( '#^http(s)?://#i', '', untrailingslashit( home_url() ) ),
  121. 'path' => _s_backbone_get_request_path(),
  122. 'use_trailing_slashes' => $wp_rewrite->use_trailing_slashes,
  123. 'parameters' => _s_backbone_get_request_parameters(),
  124. ),
  125. );
  126. if ( is_category() || is_tag() || is_tax() ) {
  127. $local['loopType'] = 'archive';
  128. $local['taxonomy'] = get_taxonomy( $queried_object->taxonomy );
  129. } elseif ( is_search() ) {
  130. $local['loopType'] = 'search';
  131. $local['searchQuery'] = get_search_query();
  132. } elseif ( is_author() ) {
  133. $local['loopType'] = 'author';
  134. }
  135. if ( is_paged() ) {
  136. $local['page'] = absint( get_query_var( 'paged' ) ) + 1;
  137. }
  138. wp_localize_script( '_s_backbone-loop', 'settings', $local );
  139. }
  140. else {
  141. //wp_deregister_script('mediaelement');
  142. wp_enqueue_script( 'scriptmin', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
  143. wp_enqueue_script( 'single', get_template_directory_uri() . '/js/single.js', '', '', true );
  144. wp_enqueue_script( 'mediaelement-me', get_template_directory_uri() .'/js/mediaelement-and-player.min.js', '', '', true);
  145. wp_enqueue_script( 'mediaelement-wp', get_template_directory_uri() .'/js/wp-mediaelement.min.js', '', '', true);
  146. }
  147. }
  148. add_action('wp_footer', 'dw_analytics', 22);
  149. function dw_analytics() { ?>
  150. <script>
  151. var _paq = window._paq = window._paq || [];
  152. /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  153. _paq.push(['trackPageView']);
  154. _paq.push(['enableLinkTracking']);
  155. (function() {
  156. var u="https://davidawindham.com/wik/";
  157. _paq.push(['setTrackerUrl', u+'matomo.php']);
  158. _paq.push(['setSiteId', '1']);
  159. var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
  160. g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  161. })();
  162. </script>
  163. <noscript><p><img src="https://davidawindham.com/wik/matomo.php?idsite=1&amp;rec=1" style="border:0;" alt="" /></p></noscript>
  164. <?php }
  165. ?>