????
Current Path : /home2/morganrand/backup.morganrand.com/wp-content/themes/wanderfuls/framework/ |
Current File : /home2/morganrand/backup.morganrand.com/wp-content/themes/wanderfuls/framework/conditionals.php |
<?php /** * Conditonal functions * * @package Wanderfuls WordPress Theme * @subpackage Framework */ /*-------------------------------------------------------------------------------*/ /* - Conditionals > Core /*-------------------------------------------------------------------------------*/ /** * Check if the header supports aside content * * @since 3.0.0 */ function tb_header_supports_aside( $header_style = '' ) { // False by default $bool = false; // Get header style $header_style = $header_style ? $header_style : tb_global_obj( 'header_style' ); // Validate if ( 'two' == $header_style || 'three' == $header_style || 'four' == $header_style ) { $bool = true; } // Apply filters and return return apply_filters( 'tb_header_supports_aside', $bool ); } /*-------------------------------------------------------------------------------*/ /* - Conditionals > Menu /*-------------------------------------------------------------------------------*/ /** * Check if search icon should be in the nav * * @since 1.0.0 */ function tb_has_menu_search() { // Return false by default $return = false; // Get header style $header_style = tb_global_obj( 'header_style' ); // Always return true for the header style 2, we can hide via CSS if ( 'two' == $header_style ) { $return = true; } // Return true if enabled via the Customizer elseif ( tb_get_mod( 'main_search', true ) ) { $return = true; } // Apply filters $return = apply_filters( 'tb_has_menu_search', $return ); // Return return $return; } /*-------------------------------------------------------------------------------*/ /* - Conditionals > Blog /*-------------------------------------------------------------------------------*/ /** * Returns true if the current Query is a query related to standard blog posts. * * @since 1.6.0 */ function tb_is_blog_query() { // False by default $bool = false; // Return true for blog archives if ( is_search() ) { $bool = false; // Fixes wp bug } elseif ( is_home() || is_category() || is_tag() || is_date() || is_author() || is_page_template( 'templates/blog.php' ) ) { $bool = true; } // Apply filters $bool = apply_filters( 'tb_is_blog_query', $bool ); // Return bool return $bool; } /*-------------------------------------------------------------------------------*/ /* - Conditionals > Social Sharing /*-------------------------------------------------------------------------------*/ /** * Checks if there are any social sharing sites enabled * * @since 1.0.0 */ function tb_has_social_share_sites() { if ( tb_social_share_sites() ) { return true; } } /** * Checks if the social sharing style supports a custom heading * * @since 1.0.0 */ function tb_social_sharing_supports_heading() { $bool = false; if ( tb_social_share_sites() && 'horizontal' == tb_social_share_position() ) { $bool = true; } $bool = apply_filters( 'tb_social_sharing_supports_heading', $bool ); return $bool; } /*-------------------------------------------------------------------------------*/ /* - Conditionals > Other /*-------------------------------------------------------------------------------*/ /** * Checks if the current post is part of a post series. * * @since 2.0.0 */ function tb_is_post_in_series() { $terms = get_the_terms( get_the_id(), 'post_series' ); if ( $terms ) { return true; } else { return false; } } /** * Checks if on a theme portfolio category page. * * @since 1.6.0 */ if ( ! function_exists( 'tb_is_portfolio_tax' ) ) { function tb_is_portfolio_tax() { if ( ! is_search() && ( is_tax( 'portfolio_category' ) || is_tax( 'portfolio_tag' ) ) ) { return true; } else { return false; } } } /** * Checks if on a theme staff category page. * * @since 1.6.0 */ if ( ! function_exists( 'tb_is_staff_tax' ) ) { function tb_is_staff_tax() { if ( ! is_search() && ( is_tax( 'staff_category' ) || is_tax( 'staff_tag' ) ) ) { return true; } else { return false; } } } /** * Checks if on a theme testimonials category page. * * @since 1.6.0 */ if ( ! function_exists( 'tb_is_testimonials_tax' ) ) { function tb_is_testimonials_tax() { if ( ! is_search() && ( is_tax( 'testimonials_category' ) || is_tax( 'testimonials_tag' ) ) ) { return true; } else { return false; } } } /** * Checks if on the WooCommerce shop page. * * @since 1.6.0 */ function tb_is_woo_shop() { if ( ! TB_WOOCOMMERCE_ACTIVE ) { return false; } elseif ( function_exists( 'is_shop' ) && is_shop() ) { return true; } } /** * Checks if on a WooCommerce tax. * * @since 1.6.0 */ if ( ! function_exists( 'tb_is_woo_tax' ) ) { function tb_is_woo_tax() { if ( ! TB_WOOCOMMERCE_ACTIVE ) { return false; } elseif ( ! is_tax() ) { return false; } elseif ( function_exists( 'is_product_category' ) && function_exists( 'is_product_tag' ) ) { if ( is_product_category() || is_product_tag() ) { return true; } } } } /** * Checks if on singular WooCommerce product post. * * @since 1.6.0 */ function tb_is_woo_single() { if ( ! TB_WOOCOMMERCE_ACTIVE ) { return false; } elseif ( is_woocommerce() && is_singular( 'product' ) ) { return true; } } /** * Check if current user has social profiles defined. * * @since 1.0.0 */ function tb_author_has_social() { // Get global post object global $post; // Get post author $post_author = ! empty( $post->post_author ) ? $post->post_author : ''; // Return if there isn't any post author if ( ! $post_author ) { return; } if ( get_the_author_meta( 'tb_twitter', $post_author ) ) { return true; } elseif ( get_the_author_meta( 'tb_facebook', $post_author ) ) { return true; } elseif ( get_the_author_meta( 'tb_googleplus', $post_author ) ) { return true; } elseif ( get_the_author_meta( 'tb_linkedin', $post_author ) ) { return true; } elseif ( get_the_author_meta( 'tb_pinterest', $post_author ) ) { return true; } elseif ( get_the_author_meta( 'tb_instagram', $post_author ) ) { return true; } else { return false; } } /** * Check if a post has categories. * * This function is used for the next and previous posts so if a post is in a category it * will display next and previous posts from the same category. * * @since 1.0.0 */ if ( ! function_exists( 'tb_post_has_terms' ) ) { function tb_post_has_terms( $post_id = '', $post_type = '' ) { // Post data $post_id = $post_id ? $post_id : get_the_ID(); $post_type = $post_type ? $post_type : get_post_type( $post_id ); // Standard Posts if ( $post_type == 'post' ) { $terms = get_the_terms( $post_id, 'category'); if ( $terms ) { return true; } } // Portfolio elseif ( 'portfolio' == $post_type ) { $terms = get_the_terms( $post_id, 'portfolio_category'); if ( $terms ) { return true; } } // Staff elseif ( 'staff' == $post_type ) { $terms = get_the_terms( $post_id, 'staff_category'); if ( $terms ) { return true; } } // Testimonials elseif ( 'testimonials' == $post_type ) { $terms = get_the_terms( $post_id, 'testimonials_category'); if ( $terms ) { return true; } } } } /** * Check if the post edit links should display on the page * * @since 2.0.0 */ function tb_has_post_edit() { // Display by default $return = true; // If not singular we can bail completely if ( ! is_singular() ) { return false; } // Don't show on front-end composer if ( tb_is_front_end_composer() ) { return; } // Not needed for these pages if ( function_exists( 'is_cart' ) && is_cart() ) { return; } if ( function_exists( 'is_checkout' ) && is_checkout() ) { return; } // Apply filters $return = apply_filters( 'tb_has_post_edit', $return ); // Return bool return $return; } /** * Check if the next/previous links should display * * @since 2.0.0 */ function tb_has_next_prev() { // Display by default $return = true; // Not needed here if ( ! is_singular() || is_page() || is_singular( 'attachment' ) ) { return false; } // Check if it should be enabled on standard posts if ( is_singular( 'post' ) && ! tb_get_mod( 'blog_next_prev', true ) ) { $return = false; } // Apply filters $return = apply_filters( 'tb_has_next_prev', $return ); // Return bool return $return; } /** * Check if term description should display above the loop. * * By default the term description displays in the subheading in the page header, * however, there are some built-in settings to enable the term description above the loop. * This function returns true if the term description should display above the loop and not in the header. * * @since 2.0.0 */ function tb_has_term_description_above_loop( $return = false ) { // Return true for tags and categories only if ( 'above_loop' == tb_get_mod( 'category_description_position' ) && ( is_category() || is_tag() ) ) { $return = true; } // Apply filters $return = apply_filters( 'tb_has_term_description_above_loop', $return ); // Return return $return; } /** * Check if the readmore button should display * * @since 2.1.2 */ function tb_has_readmore() { // Display by default $bool = true; // Disable if posts are set to display full content if ( 'post' == get_post_type() && ! strpos( get_the_content(), 'more-link' ) && ! tb_get_mod( 'blog_exceprt', true ) ) { $bool = false; } // Don't show for password protected posts if ( post_password_required() ) { $bool = false; } // Apply filters $bool = apply_filters( 'tb_has_readmore', $bool ); // Return bool return $bool; }