functions.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. require get_template_directory() . '/inc/hp-cleaner.php';
  3. require get_template_directory() . '/inc/hp-nav-walker.php';
  4. require get_template_directory() . '/inc/hp-templates.php';
  5. function hp_scripts() {
  6. wp_enqueue_style( 'icons', get_template_directory_uri() . '/css/bootstrap-icons.css' );
  7. wp_enqueue_style( 'sass', get_template_directory_uri() . '/css/custom.css' );
  8. wp_enqueue_style( 'style', get_stylesheet_uri() );
  9. wp_enqueue_script('jquery');
  10. wp_enqueue_script('script', get_template_directory_uri() . '/js/script.min.js', array(), '', true );
  11. wp_enqueue_script('init', get_template_directory_uri() . '/js/init.js', array(), '', true );
  12. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  13. wp_enqueue_script( 'comment-reply' );
  14. }
  15. }
  16. add_action( 'wp_enqueue_scripts', 'hp_scripts' );
  17. if ( ! function_exists( 'hp_setup' ) ) :
  18. function hp_setup() {
  19. add_theme_support( 'automatic-feed-links' );
  20. add_theme_support( 'title-tag' );
  21. add_theme_support( 'post-thumbnails' );
  22. add_theme_support( 'nav-menus' );
  23. register_nav_menus( array(
  24. 'primary' => __( 'Primary' ),
  25. 'bottom' =>__( 'Bottom' ),
  26. 'top' =>__( 'Top' )
  27. ));
  28. add_theme_support( 'html5', array(
  29. 'comment-form',
  30. 'comment-list',
  31. 'caption',
  32. ));
  33. add_theme_support( 'customize-selective-refresh-widgets' );
  34. add_theme_support( 'editor-styles' );
  35. add_theme_support( 'disable-custom-colors' );
  36. add_theme_support( 'editor-color-palette', array(
  37. array(
  38. 'name' => __( 'Green' ),
  39. 'slug' => 'green',
  40. 'color' => '#325363',
  41. ),
  42. array(
  43. 'name' => __( 'Purple' ),
  44. 'slug' => 'purple',
  45. 'color' => '#343C70',
  46. ),
  47. array(
  48. 'name' => __( 'Blue' ),
  49. 'slug' => 'blue',
  50. 'color' => '#5177B0',
  51. ),
  52. array(
  53. 'name' => __( 'Red' ),
  54. 'slug' => 'red',
  55. 'color' => '#CC7C84',
  56. ),
  57. array(
  58. 'name' => __( 'Yellow' ),
  59. 'slug' => 'yellow',
  60. 'color' => '#E0DC67',
  61. ),
  62. array(
  63. 'name' => __( 'Teal' ),
  64. 'slug' => 'teal',
  65. 'color' => '#50A7AD',
  66. ),
  67. ));
  68. }
  69. endif;
  70. add_action( 'after_setup_theme', 'hp_setup' );
  71. function hp_content_width() {
  72. $GLOBALS['content_width'] = apply_filters( 'hp_content_width', 1170 );
  73. }
  74. add_action( 'after_setup_theme', 'hp_content_width', 0 );
  75. function hp_widgets_init() {
  76. register_sidebar( array(
  77. 'name' => esc_html__( 'Sidebar', 'hp-theme' ),
  78. 'id' => 'sidebar-1',
  79. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  80. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  81. 'after_widget' => '</section>',
  82. 'before_title' => '<h3 class="widget-title">',
  83. 'after_title' => '</h3>',
  84. ) );
  85. register_sidebar( array(
  86. 'name' => esc_html__( 'Footer 1', 'hp-theme' ),
  87. 'id' => 'footer-1',
  88. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  89. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  90. 'after_widget' => '</section>',
  91. 'before_title' => '<h3 class="widget-title">',
  92. 'after_title' => '</h3>',
  93. ) );
  94. register_sidebar( array(
  95. 'name' => esc_html__( 'Footer 2', 'hp-theme' ),
  96. 'id' => 'footer-2',
  97. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  98. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  99. 'after_widget' => '</section>',
  100. 'before_title' => '<h3 class="widget-title">',
  101. 'after_title' => '</h3>',
  102. ) );
  103. register_sidebar( array(
  104. 'name' => esc_html__( 'Footer 3', 'hp-theme' ),
  105. 'id' => 'footer-3',
  106. 'description' => esc_html__( 'Add widgets here.', 'hp-theme' ),
  107. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  108. 'after_widget' => '</section>',
  109. 'before_title' => '<h3 class="widget-title">',
  110. 'after_title' => '</h3>',
  111. ) );
  112. }
  113. add_action( 'widgets_init', 'hp_widgets_init' );
  114. /**********************************
  115. ######## Gutenberg Editor #########
  116. ***********************************/
  117. function hp_add_editor_styles() {
  118. add_editor_style([
  119. 'css/custom.css',
  120. 'style.css'
  121. ] );
  122. }
  123. add_action( 'admin_init', 'hp_add_editor_styles' );
  124. function hp_gutenberg_scripts() {
  125. wp_enqueue_script( 'hp-editor', get_stylesheet_directory_uri() . '/js/editor.js', array( 'wp-blocks', 'wp-dom' ), filemtime( get_stylesheet_directory() . '/js/editor.js' ), true );
  126. }
  127. add_action( 'enqueue_block_editor_assets', 'hp_gutenberg_scripts' );
  128. function hp_gutenberg_style() {
  129. echo '<style>.wp-block{max-width:992px;}.wp-block[data-align="wide"]{}.wp-block[data-align="full"]{max-width:none;}.editor-post-title__block .editor-post-title__input,.edit-post-visual-editor, .edit-post-visual-editor p{font-family: Helvetica, Arial, sans-serif;}</style>';
  130. }
  131. add_action('admin_head', 'hp_gutenberg_style');
  132. add_filter( 'render_block', function( $block_content, $block ) {
  133. $block_content = str_replace(
  134. 'wp-block-button__link',
  135. 'wp-block-button__link btn',
  136. $block_content
  137. );
  138. return $block_content;
  139. }, 5, 2 );
  140. /**********************************
  141. ###### Seamless Donations #########
  142. ***********************************/
  143. function hp_seamless_style() {
  144. if ( !is_page('donate') ) {
  145. wp_deregister_style('seamless_donations_css');
  146. }
  147. }
  148. add_action('wp_print_styles', 'hp_seamless_style', 100);
  149. function hp_seamless_scripts() {
  150. if ( !is_page('donate') ) {
  151. wp_dequeue_script( 'seamless_javascript_code' );
  152. wp_deregister_script( 'seamless_javascript_code' );
  153. wp_dequeue_script( 'seamless_javascript_uuid' );
  154. wp_deregister_script( 'seamless_javascript_uuid' );
  155. }
  156. }
  157. add_action( 'wp_enqueue_scripts', 'hp_seamless_scripts', 100);
  158. function hp_seamless_script() {
  159. if ( is_page(200) ) { ?>
  160. <script type="text/javascript">
  161. document.getElementById("dgx-donate-designated").checked = true;
  162. jQuery(document).ready(function($){
  163. $('.specific-fund').show();
  164. });
  165. </script>
  166. <div data-reveal='.specific-fund'></div>
  167. <?php }
  168. }
  169. add_action('wp_footer', 'hp_seamless_script', 0);
  170. function hp_seamless_redirect() {
  171. if ( is_singular(['donor','donation','funds'])) {
  172. wp_redirect( 'donate', 301 );
  173. exit;
  174. }
  175. }
  176. add_action( 'template_redirect', 'hp_seamless_redirect' );