HEX
Server: LiteSpeed
System: Linux s882.use1.mysecurecloudhost.com 4.18.0-553.27.1.lve.el8.x86_64 #1 SMP Fri Nov 8 15:09:45 UTC 2024 x86_64
User: airservicecom (4307)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /home/airservicecom/public_html/wp-content/themes/air-service/includes/theme-ep-hooks.php
<?php

/**
 * Overrides Enfold Plus ALB Tab Name
 */
function enfold_child_tab_name(){
	return SITE_NAME;
}
add_filter( 'avf_ep_tab_name', 'enfold_child_tab_name', 1 );

/**
 * Button Colors
 * This hook will add/remove button color options on Buttons and Button Group
 */
function enfold_child_avf_color_options( $options ) {
	$options = array(
		'Blue' => 'blue',
		'Green' => 'green',
	);

	return $options;
}
add_filter( 'avf_ep_buttons_color_options', 'enfold_child_avf_color_options', 10, 1 );
/**
 * Button Styles
 * This hook will add/remove button color options on Buttons and Button Group
 */
function enfold_child_avf_style_options( $options ) {
	$options = array(
		'Main' => 'main',
		'Outline' => 'outline',
		'Link' => 'link'
	);

	return $options;
}
add_filter( 'avf_ep_buttons_style_options', 'enfold_child_avf_style_options', 10, 1 );

function enfold_child_avf_button_color_default($std) {
	$options = 'large';
	return $options;
}
add_filter( 'avf_ep_buttons_size_std', 'enfold_child_avf_button_color_default', 10, 1 );

/**
 * Overrides Enfold Plus Post Grid Template inclusion
 */
function enfold_child_posts_template_override( $template, $post_type, $post_id, $meta ){
	/**
	 * Default template override
	 */
	$post_template = THEME_INCLUDES . "loop-content-" . $post_type . ".php";
	if( file_exists( $post_template ) ) $template = $post_template;

	/**
	 * Other Usages
	 */
	/* 
	if( $meta['ep_class'] == 'custom_style' ) {
		$template = THEME_INCLUDES . "loop-content-custom-style-" . $post_type . ".php";
	}
	*/

	/*
	if( in_array( $post_type, array( 'post', 'news' ) ) ) {
		$template = THEME_INCLUDES . "loop-content-common.php";
	} 
	*/

	return $template;
}
add_filter( 'avf_ep_post_grid_post_template', 'enfold_child_posts_template_override', 10, 4 );
add_filter( 'avf_ep_post_slider_post_template', 'enfold_child_posts_template_override', 10, 4 );

/**
 * Overrides Enfold Plus Content Slider Template inclusion
 */
function enfold_child_slider_slide_template_override( $template, $atts, $meta ){
	/*
	if( strpos( $meta['custom_class'], 'custom' ) !== false ){
		$template = THEME_INCLUDES . "content-slider-custom.php";
	}
	*/

	return $template;
}
add_filter( 'avf_ep_content_slider_slide_template', 'enfold_child_slider_slide_template_override', 10, 3 );

/**
 * Overrides Enfold Plus Item Grid Template inclusion
 */
function enfold_child_item_grid_item_override( $template, $atts, $meta ){

	/*
	if( strpos( $meta['custom_class'], 'custom' ) !== false ){
		$template = THEME_INCLUDES . "item-grid-custom.php";
	}
	*/

	return $template;
}
add_filter( 'avf_ep_item_grid_item_template', 'enfold_child_item_grid_item_override', 10, 3 );

/**
 * Tab Slider Overrides
 */
function enfold_child_tab_slider_options( $options ) {
	
	$options[] = array(
		"name" 	=> __( "New option", 'avia_framework' ),
		"desc" 	=> __( "new option", 'avia_framework' ),
		"id" 	=> "new_option",
		"std" 	=> "",
		"type" 	=> "input"
	);
	
	
	return $options;
}
add_filter( 'avf_ep_tab_slider_options', 'enfold_child_tab_slider_options' );


function enfold_child_ig_options( $options ) {
	
	/*
	$options[] = array(	
		'name' 	=> __( 'Is Card Grid', 'avia_framework' ),
		'desc' 	=> __( 'Check to only display icon on hover', 'avia_framework' ),
		'id' 	=> 'icon_hover',
		'type' 	=> 'checkbox',
		'std' 	=> '',
		'lockable' => true,
	);

	$options[] = array(
		"name" 	=> __( "New option", 'avia_framework' ),
		"desc" 	=> __( "new option", 'avia_framework' ),
		"id" 	=> "new_option",
		"std" 	=> "",
		"type" 	=> "input",
		'required'	=> array( 'icon_hover', 'not', '' )
	);
	*/
	
	return $options;
}
add_filter( 'avf_ep_item_grid_item_options', 'enfold_child_ig_options' );


function enfold_child_tab_slider_control_override( $template, $atts, $meta ){
	/*
	if( $meta['ep_class'] == 'tabslider--simple' ) {
		$template = THEME_INCLUDES . "avia-shortcodes/tab_slider/tabslider--custom-control.php";
	}
	*/

	return $template;
}
add_filter( 'avf_ep_tab_slider_control_template', 'enfold_child_tab_slider_control_override', 10, 3 );

function enfold_child_tab_slider_slide_override( $template, $atts, $meta ){
	/*
	if( $meta['ep_class'] == 'tabslider--simple' ) {
		$template = THEME_INCLUDES . "avia-shortcodes/tab_slider/tabslider--custom-slide.php";
	}
	*/

	return $template;
}
add_filter( 'avf_ep_tab_slider_slide_template', 'enfold_child_tab_slider_slide_override', 10, 3 );

/**
 * Removes default heading font size
 */
function enfold_child_subheading_default_size( $heading ) {
	return '';
}
add_filter( 'avf_ep_subheading_default_size', 'enfold_child_subheading_default_size' );


/**
 * Featured Posts Hook before Posts Grid/Slider
 * Sets global
 */
function enfold_child_post_grid_before( $post_type, $post_id, $meta ){
    if( strpos( $meta['el_class'], 'featured-posts' ) !== false ){
	    $GLOBALS['excluded_posts'][] = $post_id;
    }    
}
add_action( 'ava_ep_post_grid_post_before', 'enfold_child_post_grid_before', 10, 3 );
add_action( 'ava_ep_post_slider_post_before', 'enfold_child_post_grid_before', 10, 3 );

/**
 * Post Query hook for Posts Grid/Slider
 */
function enfold_child_posts_query( $post_query, $meta ) {

	/**
	 * Featured Posts hook
	 */
    if( strpos( $meta['el_class'], 'featured-posts' ) !== false ){
        $post_query["meta_query"] = array(
            "relation" => "and",
            array(
                "key" => "is_featured",
                "compare" => "EXISTS"
            ),
            array(
                "key" => "is_featured",
                "value" => "0",
                "compare" => "!="
            )
        );
    } else {
    	if( isset( $GLOBALS["excluded_posts"] ) ) $post_query["post__not_in"] = $GLOBALS["excluded_posts"]; // used for featured posts query
    }


	/**
	 * Related Posts hook
	 */
	if( strpos( $meta['custom_class'], 'related-posts' ) !== false ){
        $current_post_id = get_the_ID();

        $post_query['post_type'] = get_post_type();
        $post_query['post__not_in'] = array( $current_post_id );

		/* Added option to have custom set of related posts, requires ACF Pro and fields properly set */
        if( have_rows( 'related_posts' ) ){
            $posts_to_include = array();

            while( have_rows( 'related_posts' ) ){
                the_row();
                $posts_to_include[] = get_sub_field( 'related_post' );
            }

            $post_query['post__in'] = $posts_to_include;
        } else {
            $taxonomy = 'post_tag';

            $terms = get_the_terms( $current_post_id, $taxonomy );

            if( ! empty( $terms ) ) {
                $terms_array = array_map(
                    function ( $term ) {
                        return (int) $term->term_id;
                    },
                    $terms
                );

                $post_query['tax_query'] = array(
                    array(
                        'taxonomy' => $taxonomy,
                        'terms' => $terms_array,
                    ),
                );
            }
        }
    }

	return $post_query;
}
add_filter( 'avf_ep_post_grid_query', 'enfold_child_posts_query', 10, 2 );
add_filter( 'avf_ep_post_slider_query', 'enfold_child_posts_query', 10, 2 );

/**
 * This hooks allows you to modify the set of classes a Posts Grid/Slider Item will get.
 */
function enfold_child_featured_post_item_classes( $classes, $slug, $post_id, $meta, $shortcode ){
	/**
	 * Removes default entry-cpt slug class from featured-posts
	 */
	if( strpos( $meta['el_class'], 'featured-posts' ) !== false ){
        $classes['slug_class'] = "entry-featured-{$slug}";
    }

	if( is_search() ) { // maybe add is_archive here 
		$classes['slug_class'] = "entry-search";
	}

    return $classes;
}
add_filter( 'avf_ep_post_item_classes', 'enfold_child_featured_post_item_classes', 10, 5 );

/**
 * Used for experimental archive/search view Posts Grid rendering
 */
function enfold_child_posts_query_object( $query_object, $meta ) {

    if ( is_archive() || is_search() ) {
        global $wp_query;
        $query_object = $wp_query;
    }

    return $query_object;
}
add_filter( 'avf_ep_post_grid_query_object', 'enfold_child_posts_query_object', 10, 2 );


/**
 * Post vars filters
 */
function enfold_child_post_item_link( $post_link, $post_type, $post_id, $meta, $shortcode ) {
    $post_link = enfold_child_custom_link( $post_id )['link'];

	return $post_link;
}
add_filter( 'avf_ep_post_item_link', 'enfold_child_post_item_link', 10, 5 );

function enfold_child_post_item_link_attrs( $post_link_attrs, $post_type, $post_id, $meta, $shortcode ) {
    $post_link_attrs = enfold_child_custom_link( $post_id )['attrs'];

	return $post_link_attrs;
}
add_filter( 'avf_ep_post_item_link_attrs', 'enfold_child_post_item_link_attrs', 10, 5 );

function enfold_child_post_item_content( $post_content, $post_type, $post_id, $meta, $shortcode ) {
    /*
    if( $post_type == 'team' ) {
        $post_content = get_field( 'job_title' );
    }
    */

	return $post_content;
}
add_filter( 'avf_ep_post_item_content', 'enfold_child_post_item_content', 10, 5 );

function enfold_child_post_item_date( $post_date, $post_type, $post_id, $meta, $shortcode ) {
    $post_date = enfold_child_format_date( $post_id, $post_date );
    
	return $post_date;
}
add_filter( 'avf_ep_post_item_date', 'enfold_child_post_item_date', 10, 5 );

/* 
function enfold_child_post_item_taxonomy( $post_taxonomy, $post_type, $post_id, $meta, $shortcode ) {
	return $post_taxonomy;
}
add_filter( 'avf_ep_post_item_taxonomy', 'enfold_child_post_item_taxonomy', 10, 5 );

function enfold_child_post_item_content_length( $post_content_length, $post_type, $post_id, $meta, $shortcode ) {
	return $post_content_length;
}
add_filter( 'avf_ep_post_item_content_length', 'enfold_child_post_item_content_length', 10, 5 );

function enfold_child_post_item_vars( $post_vars, $post_type, $post_id, $meta, $shortcode ) {
	return $post_vars;
}
add_filter( 'avf_ep_post_item_vars', 'enfold_child_post_item_vars', 10, 5 );
*/