functions.php 8.2 KB

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