theme.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /*************************************************
  3. // ######### cleanup migration ################ //
  4. **************************************************/
  5. // define('TRIBE_DISABLE_TOOLBAR_ITEMS', true);
  6. add_action('set_current_user', 'hp_hide_admin_bar');
  7. function hp_hide_admin_bar() {
  8. show_admin_bar(false);
  9. }
  10. function hp_remove_comment_support() {
  11. remove_post_type_support( 'post', 'comments' );
  12. remove_post_type_support( 'page', 'comments' );
  13. }
  14. add_action('init', 'hp_remove_comment_support', 100);
  15. function hp_filter_media_comment_status( $open, $post_id ) {
  16. $post = get_post( $post_id );
  17. if( $post->post_type == 'attachment' ) {
  18. return false;
  19. }
  20. return $open;
  21. }
  22. add_filter( 'comments_open', 'hp_filter_media_comment_status', 10 , 2 );
  23. function hp_remove_default_img_sizes( $sizes ) {
  24. $targets = ['medium_large', '1536x1536', '2048x2048'];
  25. foreach($sizes as $size_index=>$size) {
  26. if(in_array($size, $targets)) {
  27. unset($sizes[$size_index]);
  28. }
  29. }
  30. return $sizes;
  31. }
  32. add_filter( 'intermediate_image_sizes', 'hp_remove_default_img_sizes', 10, 1);
  33. /****************************************
  34. // ########## Theme Setup ############ //
  35. *****************************************/
  36. function hp_theme_setup() {
  37. add_theme_support( 'disable-custom-colors' );
  38. add_theme_support( 'editor-color-palette', array(
  39. array(
  40. 'name' => __( 'Green' ),
  41. 'slug' => 'green',
  42. 'color' => '#325363',
  43. ),
  44. array(
  45. 'name' => __( 'Purple' ),
  46. 'slug' => 'purple',
  47. 'color' => '#343C70',
  48. ),
  49. array(
  50. 'name' => __( 'Blue' ),
  51. 'slug' => 'blue',
  52. 'color' => '#5177B0',
  53. ),
  54. array(
  55. 'name' => __( 'Red' ),
  56. 'slug' => 'red',
  57. 'color' => '#CC7C84',
  58. ),
  59. array(
  60. 'name' => __( 'Yellow' ),
  61. 'slug' => 'yellow',
  62. 'color' => '#E0DC67',
  63. ),
  64. array(
  65. 'name' => __( 'Teal' ),
  66. 'slug' => 'teal',
  67. 'color' => '#50A7AD',
  68. )
  69. ));
  70. }
  71. add_action( 'after_setup_theme', 'hp_theme_setup' );
  72. /*******************************************
  73. // ######### Donation Menu Item ######### //
  74. *******************************************/
  75. function hp_donate_nav_item( $items, $args ) {
  76. if( $args->theme_location == 'primary' ) {
  77. $items = $items .'<li id="donate-button" class="menu-item nav-item ps-lg-3">'."\n".'<a class="btn btn-outline-light" href="'.home_url().'/get-involved/donate" role="button">Donate <i class="bi bi-suit-heart-fill p-1 text-danger"></i></a></li>';
  78. }
  79. return $items;
  80. }
  81. add_filter('wp_nav_menu_items','hp_donate_nav_item',10,2);
  82. /*************************************
  83. ######### Seamless Donations #########
  84. **************************************/
  85. function hp_seamless_style() {
  86. if ( !is_page('donate') ) {
  87. wp_deregister_style('seamless_donations_css');
  88. }
  89. }
  90. add_action('wp_print_styles', 'hp_seamless_style', 100);
  91. function hp_seamless_scripts() {
  92. if ( !is_page('donate') ) {
  93. wp_dequeue_script( 'seamless_javascript_code' );
  94. wp_deregister_script( 'seamless_javascript_code' );
  95. wp_dequeue_script( 'seamless_javascript_uuid' );
  96. wp_deregister_script( 'seamless_javascript_uuid' );
  97. }
  98. }
  99. add_action( 'wp_enqueue_scripts', 'hp_seamless_scripts', 100);
  100. function hp_seamless_script() {
  101. if ( is_page(200) ) { ?>
  102. <script type="text/javascript">
  103. document.getElementById("dgx-donate-designated").checked = true;
  104. jQuery(document).ready(function($){
  105. $('.specific-fund').show();
  106. });
  107. </script>
  108. <div data-reveal='.specific-fund'></div>
  109. <?php }
  110. }
  111. add_action('wp_footer', 'hp_seamless_script', 0);
  112. function hp_seamless_redirect() {
  113. if ( is_singular(['donor','donation','funds'])) {
  114. wp_redirect( 'donate', 301 );
  115. exit;
  116. }
  117. }
  118. add_action( 'template_redirect', 'hp_seamless_redirect' );
  119. function hp_exclude_seamless_post_type($query) {
  120. if(is_admin() || !$query->is_main_query()) return;
  121. if($query->is_search()) {
  122. $post_type_to_remove = 'funds';
  123. $searchable = get_post_types(array('exclude_from_search' => false));
  124. if(is_array($searchable) && in_array($post_type_to_remove, $searchable)){
  125. $query->set('post_type', $searchable);
  126. }
  127. }
  128. }
  129. add_action('pre_get_posts', 'hp_exclude_seamless_post_type', 99 );
  130. function hp_remove_fund_custom_type() {
  131. global $wp_post_types;
  132. $wp_post_types['funds']->exclude_from_search = true;
  133. }
  134. add_action( 'init', 'hp_remove_fund_custom_type', 99 );
  135. function hp_remove_donor_custom_type() {
  136. global $wp_post_types;
  137. $wp_post_types['donor']->exclude_from_search = true;
  138. }
  139. add_action( 'init', 'hp_remove_donor_custom_type', 99 );