123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <?php
- /*************************************************
- // ######### cleanup migration ################ //
- **************************************************/
- add_action('set_current_user', 'hp_hide_admin_bar');
- function hp_hide_admin_bar() {
- show_admin_bar(false);
- }
- function hp_remove_comment_support() {
- remove_post_type_support( 'post', 'comments' );
- remove_post_type_support( 'page', 'comments' );
- }
- add_action('init', 'hp_remove_comment_support', 100);
- function hp_filter_media_comment_status( $open, $post_id ) {
- $post = get_post( $post_id );
- if( $post->post_type == 'attachment' ) {
- return false;
- }
- return $open;
- }
- add_filter( 'comments_open', 'hp_filter_media_comment_status', 10 , 2 );
- function hp_remove_default_img_sizes( $sizes ) {
- $targets = ['medium_large', '1536x1536', '2048x2048'];
- foreach($sizes as $size_index=>$size) {
- if(in_array($size, $targets)) {
- unset($sizes[$size_index]);
- }
- }
- return $sizes;
- }
- add_filter( 'intermediate_image_sizes', 'hp_remove_default_img_sizes', 10, 1);
- /****************************************
- // ########## Theme Setup ############ //
- *****************************************/
- function hp_theme_setup() {
- add_theme_support( 'disable-custom-colors' );
- add_theme_support( 'editor-color-palette', array(
- array(
- 'name' => __( 'Green' ),
- 'slug' => 'green',
- 'color' => '#325363',
- ),
- array(
- 'name' => __( 'Purple' ),
- 'slug' => 'purple',
- 'color' => '#343C70',
- ),
- array(
- 'name' => __( 'Blue' ),
- 'slug' => 'blue',
- 'color' => '#5177B0',
- ),
- array(
- 'name' => __( 'Red' ),
- 'slug' => 'red',
- 'color' => '#CC7C84',
- ),
- array(
- 'name' => __( 'Yellow' ),
- 'slug' => 'yellow',
- 'color' => '#E0DC67',
- ),
- array(
- 'name' => __( 'Teal' ),
- 'slug' => 'teal',
- 'color' => '#50A7AD',
- )
- ));
- }
- add_action( 'after_setup_theme', 'hp_theme_setup' );
- /*******************************************
- // ######### Recent News Widget ######### //
- *******************************************/
- class HP_News_Widget extends WP_Widget {
- public function __construct() {
- $options = array(
- 'classname' => 'news-widget',
- 'description' => 'News Widget',
- 'customize_selective_refresh' => true,
- );
- parent::__construct(
- 'news-widget', 'News Widget', $options
- );
- }
- public function widget( $args, $instance ) {
- $q_args = array(
- 'post_type' => 'post',
- 'posts_per_page' => '2'
- );
- $query = new WP_Query( $q_args );
- while ($query->have_posts()) {
- $query->the_post();
- echo $args['before_widget'];
- echo $args['before_title'] . apply_filters( 'widget_title', 'News' ) . $args['after_title'];
- the_title();
- echo get_the_excerpt();
- echo $args['after_widget'];
- }
- wp_reset_postdata();
- }
- }
- function hp_register_news_widget() {
- register_widget( 'HP_News_Widget' );
- }
- add_action( 'widgets_init', 'hp_register_news_widget' );
- /*******************************************
- // ######### Donation Menu Item ######### //
- *******************************************/
- function hp_donate_nav_item( $items, $args ) {
- if( $args->theme_location == 'primary' ) {
- $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>';
- }
- return $items;
- }
- add_filter('wp_nav_menu_items','hp_donate_nav_item',10,2);
- /*************************************
- ######### Seamless Donations #########
- **************************************/
- function hp_seamless_style() {
- if ( !is_page('donate') ) {
- wp_deregister_style('seamless_donations_css');
- }
- }
- add_action('wp_print_styles', 'hp_seamless_style', 100);
- function hp_seamless_scripts() {
- if ( !is_page('donate') ) {
- wp_dequeue_script( 'seamless_javascript_code' );
- wp_deregister_script( 'seamless_javascript_code' );
- wp_dequeue_script( 'seamless_javascript_uuid' );
- wp_deregister_script( 'seamless_javascript_uuid' );
- }
- }
- add_action( 'wp_enqueue_scripts', 'hp_seamless_scripts', 100);
- function hp_seamless_script() {
- if ( is_page(200) ) { ?>
- <script type="text/javascript">
- document.getElementById("dgx-donate-designated").checked = true;
- jQuery(document).ready(function($){
- $('.specific-fund').show();
- });
- </script>
- <div data-reveal='.specific-fund'></div>
- <?php }
- }
- add_action('wp_footer', 'hp_seamless_script', 0);
- function hp_seamless_redirect() {
- if ( is_singular(['donor','donation','funds'])) {
- wp_redirect( 'donate', 301 );
- exit;
- }
- }
- add_action( 'template_redirect', 'hp_seamless_redirect' );
- function hp_exclude_seamless_post_type($query) {
- if(is_admin() || !$query->is_main_query()) return;
- if($query->is_search()) {
- $post_type_to_remove = 'funds';
- $searchable = get_post_types(array('exclude_from_search' => false));
- if(is_array($searchable) && in_array($post_type_to_remove, $searchable)){
- $query->set('post_type', $searchable);
- }
- }
- }
- add_action('pre_get_posts', 'hp_exclude_seamless_post_type', 99 );
- function hp_remove_fund_custom_type() {
- global $wp_post_types;
- $wp_post_types['funds']->exclude_from_search = true;
- }
- add_action( 'init', 'hp_remove_fund_custom_type', 99 );
- function hp_remove_donor_custom_type() {
- global $wp_post_types;
- $wp_post_types['donor']->exclude_from_search = true;
- }
- add_action( 'init', 'hp_remove_donor_custom_type', 99 );
|