Created
December 9, 2016 05:28
-
-
Save krishna19/978a7070964e138edf6538a5b13839f5 to your computer and use it in GitHub Desktop.
Replaces the default Avada breadcrumbs with the Yoast breadcrumbs included in the WordPress SEO plugin. Usage: Copy this file in your wp-content/mu-plugins/ folder (if that folder doesn't already exist, you will have to manually create it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Replace the default Avada Breadcrumbs with the Yoast SEO Breadcrumbs. | |
* Overrides the parent theme's themefusion_breadcrumb() function. | |
*/ | |
function themefusion_breadcrumb() { | |
// Early exit if the yoast_breadcrumb() function does not exist | |
if ( ! function_exists( 'yoast_breadcrumb' ) ) { | |
return; | |
} | |
return yoast_breadcrumb( '<p id="breadcrumbs" style="display:table-cell; vertical-align:middle;">','</p>', false ); | |
} | |
/** | |
* Replace the default Avada Title Bar. | |
* Overrides the parent theme's avada_current_page_title_bar() function. | |
*/ | |
function avada_current_page_title_bar( $post_id ) { | |
global $smof_data; | |
ob_start(); | |
if( $smof_data['breadcrumb'] ) { | |
if ( ( $smof_data['page_title_bar_bs'] == 'Breadcrumbs' && get_post_meta($post_id, 'pyre_page_title_breadcrumbs_search_bar', true) == 'breadcrumbs' ) || | |
( $smof_data['page_title_bar_bs'] != 'Breadcrumbs' && get_post_meta($post_id, 'pyre_page_title_breadcrumbs_search_bar', true) == 'breadcrumbs' ) || | |
( $smof_data['page_title_bar_bs'] == 'Breadcrumbs' && ( get_post_meta($post_id, 'pyre_page_title_breadcrumbs_search_bar', true) == 'default' || get_post_meta($post_id, 'pyre_page_title_breadcrumbs_search_bar', true) == '' ) ) ) { | |
echo themefusion_breadcrumb(); | |
} else if( ( $smof_data['page_title_bar_bs'] == 'Search Box' && get_post_meta($post_id, 'pyre_page_title_breadcrumbs_search_bar', true) == 'searchbar' ) || | |
( $smof_data['page_title_bar_bs'] != 'Search Box' && get_post_meta($post_id, 'pyre_page_title_breadcrumbs_search_bar', true) == 'searchbar' ) || | |
( $smof_data['page_title_bar_bs'] == 'Search Box' && ( get_post_meta($post_id, 'pyre_page_title_breadcrumbs_search_bar', true) == 'default' || get_post_meta($post_id, 'pyre_page_title_breadcrumbs_search_bar', true) == '' ) ) ) { | |
get_search_form(); | |
} | |
} | |
$secondary_content = ob_get_contents(); | |
ob_get_clean(); | |
$title = ''; | |
$subtitle = ''; | |
if( get_post_meta( $post_id, 'pyre_page_title_custom_text', true ) != '' ) { | |
$title = get_post_meta( $post_id, 'pyre_page_title_custom_text', true ); | |
} | |
if( get_post_meta( $post_id, 'pyre_page_title_custom_subheader', true ) != '' ) { | |
$subtitle = get_post_meta( $post_id, 'pyre_page_title_custom_subheader', true ); | |
} | |
if( ! $title ) { | |
$title = get_the_title(); | |
if( is_home() ) { | |
$title = $smof_data['blog_title']; | |
} | |
if( is_search() ) { | |
$title = __('Search results for:', 'Avada') . get_search_query(); | |
} | |
if( is_404() ) { | |
$title = __('Error 404 Page', 'Avada'); | |
} | |
if( ( class_exists( 'TribeEvents' ) && tribe_is_event() && ! is_single() && ! is_home() ) || | |
( class_exists( 'TribeEvents' ) && is_events_archive() ) || | |
( class_exists( 'TribeEvents' ) && is_events_archive() && is_404() ) | |
) { | |
$title = tribe_get_events_title(); | |
} | |
if( is_archive() && | |
! is_bbpress() | |
) { | |
if ( is_day() ) { | |
$title = __( 'Daily Archives:', 'Avada' ) . '<span> ' . get_the_date() . '</span>'; | |
} else if ( is_month() ) { | |
$title = __( 'Monthly Archives:', 'Avada' ) . '<span> ' . get_the_date( _x( 'F Y', 'monthly archives date format', 'Avada' ) ) . '</span>'; | |
} elseif ( is_year() ) { | |
$title = __( 'Yearly Archives:', 'Avada' ) . '<span> ' . get_the_date( _x( 'Y', 'yearly archives date format', 'Avada' ) ) . '</span>'; | |
} elseif ( is_author() ) { | |
$curauth = get_user_by( 'id', get_query_var( 'author' ) ); | |
$title = $curauth->nickname; | |
} elseif( is_post_type_archive() ) { | |
$title = post_type_archive_title( '', false ); | |
$sermon_settings = get_option('wpfc_options'); | |
if( is_array( $sermon_settings ) ) { | |
$title = $sermon_settings['archive_title']; | |
} | |
} else { | |
$title = single_cat_title( '', false ); | |
} | |
} | |
if( class_exists( 'Woocommerce' ) && is_woocommerce() && ( is_product() || is_shop() ) && ! is_search() ) { | |
if( ! is_product() ) { | |
$title = woocommerce_page_title( false ); | |
} | |
} | |
} | |
if ( ! $subtitle ) { | |
if( is_home() ) { | |
$subtitle = $smof_data['blog_subtitle']; | |
} | |
} | |
if( ! is_archive() && ! is_search() && ! ( is_home() && ! is_front_page() ) ) { | |
if( get_post_meta( $post_id, 'pyre_page_title', true ) == 'yes' || | |
( $smof_data['page_title_bar'] && get_post_meta( $post_id, 'pyre_page_title', true ) != 'no' ) | |
) { | |
if( get_post_meta( $post_id, 'pyre_page_title_text', true ) == 'no' ) { | |
$title = ''; | |
$subtitle = ''; | |
} | |
if( is_home() && is_front_page() && ! $smof_data['blog_show_page_title_bar'] ) { | |
// do nothing | |
} else { | |
avada_page_title_bar( $title, $subtitle, $secondary_content ); | |
} | |
} | |
} else { | |
if( is_home() && ! $smof_data['blog_show_page_title_bar'] ) { | |
// do nothing | |
} else { | |
if( $smof_data['page_title_bar'] ) { | |
avada_page_title_bar( $title, $subtitle, $secondary_content ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment