functions.php 8.1 KB

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