Show Product sale end date on Woocommerce Product Page - wordpress

I have this code but it seems outdated
add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
global $product;
function custom_price_html( $price, $product ) {
if ( is_single() && $product->is_on_sale() && $sales_price_to != "" ) {
$sales_price_from = $product->get_date_on_sale_from();
$sales_price_to = $product->get_date_on_sale_to();
if( ! empty($sales_price_from) || ! empty($sales_price_to) ){
$sales_price_date_to = $sales_price_from->date( "j.m.Y");
$sales_price_date_from = $sales_price_to->date( "j.m.Y");
$sales_date = '<p class="offer_date">Angebot vom '.$sales_price_date_from.' bis '.$sales_price_date_to.'</p>';
} else {
$sales_date = $sales_price_from = $sales_price_to = '';
}
$price = str_replace( '</ins>', ' </ins> <b>(Offer from ' . $sales_price_date_from . ' till ' . $sales_price_date_to . ')</b>', $price );
}
return $price;
}
I want to display sale end date for simple and variable products.

You're using the $sales_price_to variable when it's not defined. Please use the below code, tested and works perfectly.
add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
function custom_price_html( $price, $product ) {
if ( is_single() && $product->is_on_sale() ) {
$sales_price_from = $product->get_date_on_sale_from();
$sales_price_to = $product->get_date_on_sale_to();
if( ! empty($sales_price_from) || ! empty($sales_price_to) ){
$sales_price_date_from = $sales_price_from->date( "j.m.Y");
$sales_price_date_to = $sales_price_to->date( "j.m.Y");
$sales_date = '<p class="offer_date">Angebot vom '.$sales_price_date_from.' bis '.$sales_price_date_to.'</p>';
} else {
$sales_date = $sales_price_from = $sales_price_to = '';
}
$price = str_replace( '</ins>', ' </ins> <b>(Offer from ' . $sales_price_date_from . ' till ' . $sales_price_date_to . ')</b>', $price );
}
return $price;
}

Related

How insert title attribute in a template Wordpress

my wordpress template does not display the title attribute of the menu (but if I change the template it is okay), how could i solve it? the website in www.imsdesign.eu
I am assuming that you added title attributes to you menu by doing below steps:
From your WordPress dashboard, go to your Menus page (Appearance > Menus)
Select the Menu that you want to edit from the list of your Menus.
Click on the configuration arrow on the right side of the Menu Item title, that when clicked opens the configuration box.
Click on the “Screen Options” on top of the page to reveal additional advanced menu properties.
Activate the option for Title Attribute by selecting the Title Attribute box to expose the settings box under the Menu item instantly.
Add your Title Attribute in the text box just below the Navigation label option.
If it is still not working that's mean that you WP theme does not has title attributes. To change it please find the correct WP template (probably header.php) and add title attributes to nav elements by using method the_title_attribute()
<?php
class FastwpAltiusMenu {
private static $nav_template = '';
private static $nav_overlay = '';
function __construct() {
global $fastwp_altius_data, $fastwp_altius_menu_type;
$templates = array();
$templates[1] = array( 'nav' => 'fastwp-menu-default', 'overlay' => '' );
$templates[2] = array( 'nav' => 'fastwp-menu-overlay', 'overlay' => 'fastwp-menu-overlay2' );
if( is_page() ) {
$fastwp_altius_meta_type = get_post_meta( get_the_ID(), 'p_nav_style', true );
if( $fastwp_altius_meta_type == 1 || $fastwp_altius_meta_type == 2 ) {
$fastwp_altius_data['nav_style'] = $fastwp_altius_meta_type;
}
}
$menu = !empty( $fastwp_altius_data['nav_style'] ) && in_array( (int) $fastwp_altius_data['nav_style'], array_keys( $templates ) ) ? (int) $fastwp_altius_data['nav_style'] : 1;
$fastwp_altius_menu_type= $menu;
self::$nav_template = $templates[$menu]['nav'];
self::$nav_overlay = $templates[$menu]['overlay'];
}
public static function nav( $echo = true ) {
if( (boolean) $echo ) {
echo get_template_part( 'fastwp/menu/' . self::$nav_template );
}
ob_start();
get_template_part( 'fastwp/menu/' . self::$nav_template );
$content = ob_get_contents();
ob_end_clean();
return $content;
}
public static function overlay( $echo = true ) {
$nav_overlay = self::$nav_overlay;
if( !empty( $nav_overlay ) ) {
if( (boolean) $echo ) {
echo get_template_part( 'fastwp/menu/' . $nav_overlay );
}
ob_start();
get_template_part( 'fastwp/menu/' . $nav_overlay );
$content = ob_get_contents();
ob_end_clean();
return $content;
}
}
}
class FastwpAltiusWalker {
var $one_page = false;
function __construct( $menu_id, $menu = 0 ) {
$this->override_menu = $menu;
$elements = $this->nice_elements( $menu_id );
$this->main_elements = isset( $elements['main'] ) ? $elements['main'] : array();
$this->subnav_elements = isset( $elements['subnav'] ) ? $elements['subnav'] : array();
}
function set_onePage() {
$this->one_page = true;
}
function add_one_page_section( $item ) {
if( $this->one_page ) {
global $fastwp_altius_one_page_sections;
if( $item->object == 'page' ) {
if( empty( $fastwp_altius_one_page_sections ) ) $fastwp_altius_one_page_sections = array();
$section_name = preg_replace( '/[^a-z0-9_]/i', '', str_replace( ' ', '_', $item->title ) );
if( in_array( $section_name, array_keys( $fastwp_altius_one_page_sections ) ) ) {
$section_name = $section_name . '_' . $item->ID;
}
$fastwp_altius_one_page_sections[$section_name] = $item->object_id;
return '#section-' . $section_name;
}
}
return $item->url;
}
function get_menu() {
$output = '';
if( !empty( $this->main_elements ) ) {
/* Add Visual Composer meta */
global $fastwp_altius_one_page_css_vc;
$fastwp_altius_one_page_css_vc = array();
foreach( $this->main_elements as $item ) {
$item = $item[0];
$typeparent = get_post_meta( $item->ID, '_menu_item_menutype', true );
/* Add Visual Composer meta */
if( isset( $item->object_id ) ) {
$fastwp_altius_one_page_css_vc[$item->object_id] = get_post_meta( $item->object_id, '_wpb_shortcodes_custom_css', true );
}
$a_classes = $li_classes = $a_atts = $li_atts = array();
if( get_the_ID() == $item->object_id ) {
$li_classes[] = 'current';
}
if( isset( $item->hasChildren ) && $item->hasChildren ) {
$a_classes[] = 'sf-with-ul';
}
if( isset( $this->subnav_elements[$item->ID] ) ) {
$li_classes[] = 'parentMenuItem';
}
if( !empty( $item->classes ) ) {
$a_classes[] = implode( ' ', $item->classes );
}
$childrens = '';
if( $typeparent == 'mega2' ) {
$li_classes[] = 'dropDown megaMenu';
$items_array = $this->levels_recursive_array( $item->ID );
unset( $items_array['subnav'] );
$items_per_col = ceil( count( $items_array ) / 2 );
$col1_items = $col2_items = '';
foreach( $items_array as $k => $mitem ) {
$typechild = get_post_meta( $mitem->ID, '_menu_item_menutype2', true );
if( $k >= $items_per_col ) {
$col2_items .= $this->link_type( $mitem, $typechild );
} else {
$col1_items .= $this->link_type( $mitem, $typechild );
}
}
$childrens = '<div class="megaMenuContent cols2 clearfix">';
$childrens .= '<ul>' . $col1_items . '</ul>';
$childrens .= '<ul>' . $col2_items . '</ul>';
$childrens .= '</div>';
} else if( $typeparent == 'mega3' ) {
$li_classes[] = 'dropDown megaMenu';
$items_array = $this->levels_recursive_array( $item->ID );
unset( $items_array['subnav'] );
$items_per_col = ceil( count( $items_array ) / 3 );
$col1_items = $col2_items = $col3_items = '';
foreach( $items_array as $k => $mitem ) {
$typechild = get_post_meta( $mitem->ID, '_menu_item_menutype2', true );
if( $k < $items_per_col ) {
$col1_items .= $this->link_type( $mitem, $typechild );
} else if( $k/2 >= $items_per_col ) {
$col3_items .= $this->link_type( $mitem, $typechild );
} else {
$col2_items .= $this->link_type( $mitem, $typechild );
}
}
$childrens = '<div class="megaMenuContent cols3 clearfix">';
$childrens .= '<ul>' . $col1_items . '</ul>';
$childrens .= '<ul>' . $col2_items . '</ul>';
$childrens .= '<ul>' . $col3_items . '</ul>';
$childrens .= '</div>';
} else {
$childrens = $this->levels_recursive( $item->ID );
}
$output .= sprintf( "\n" . '<li%s%s><a href="%s"%s%s>%s</a>%s</li>',
( !empty( $li_classes ) ? ' class="' . implode( $li_classes, ' ' ) . '"' : '' ),
( !empty( $li_atts ) ? ' ' . implode( ' ', $li_atts ) : '' ),
$this->add_one_page_section( $item ),
( !empty( $a_classes ) ? ' class="' . implode( $a_classes, ' ' ) . '"' : ' ' ),
( !empty( $a_atts ) ? ' ' . implode( ' ', $a_atts ) : '' ),
$item->title,
$childrens );
}
}
return $output;
}
function link_type( $item = '', $type = '' ) {
$li_classes = array();
if( get_the_ID() == $item->object_id ) {
$li_classes[] = 'current';
}
if( $type == 'title' ) {
return '<li class="megaMenuTitle' . ( !empty( $li_classes ) ? ' ' . implode( ' ', $li_classes ) : '' ) . '">' . $item->title . '</li>';
} else {
return '<li' . ( !empty( $li_classes ) ? ' class="' . implode( ' ', $li_classes ) . '"' : '' ) . '>' . $item->title . '</li>';
}
}
function levels_recursive( $parent = 0, $level = 1 ) {
if( empty( $parent ) ) return ;
$output = '';
if( isset( $this->subnav_elements[$parent] ) ) {
$output .= '<ul class="fastwp-menu-level-' . $level . '">';
foreach( $this->subnav_elements[$parent] as $item ) {
$output .= '<li' . ( $this->item_has_children( $item->ID ) ? ' class="dropDown"' : '' ) . '>' . $item->title . '';
$output .= $this->levels_recursive( $item->ID, ($level+1) );
$output .= '</li>';
}
$output .= '</ul>';
}
return $output;
}
function item_has_children( $item = '' ) {
if( in_array( $item, array_keys( $this->subnav_elements ) ) ) {
return true;
}
return false;
}
function levels_recursive_array( $parent = 0 ) {
if( empty( $parent ) ) return array();
$output = array();
if( isset( $this->subnav_elements[$parent] ) ) {
foreach( $this->subnav_elements[$parent] as $item ) {
$output[] = $item;
$output['subnav'] = $this->levels_recursive( $item->ID );
}
}
return $output;
}
function nice_elements( $menu_id ) {
$elements = array();
foreach( $this->get_elements( $menu_id ) as $element ) {
if( !empty( $element->menu_item_parent ) ) {
$elements['subnav'][$element->menu_item_parent][] = $element;
} else {
$elements['main'][$element->ID][] = $element;
}
}
return $elements;
}
function get_elements( $menu_id = 'primary' ) {
$locations = get_nav_menu_locations();
if( !empty( $this->override_menu ) ) {
$menu = $this->override_menu;
} else {
$menu = $locations[$menu_id];
}
$elems = wp_get_nav_menu_items( get_term( $menu, 'nav_menu' ), array( 'depth' => 1 ) );
$return_elems = array();
foreach( $elems as $elem ) {
$return_elems[] = $elem;
}
return $return_elems;
}
}

Show price next to the variations in WooCommerce

I am using the below code to display price next to the variations in WooCommerce. It works great if more than 2 variations but if only 2 variations it displays only the first variations price for both variations.
Any help with this would be great.
function display_price_in_variation_option_name( $term ) {
global $wpdb, $product;
if ( is_product() ) {
if ( $product instanceof WC_Product && $product->is_type( 'variable' ) ) {
foreach ( $product->get_available_variations() as $variation ) {
//$product_variation_id = $variation['variation_id'];
foreach ( $variation['attributes'] as $variation_attribute_name => $variation_attribute_value ) {
$result = $wpdb->get_col( "SELECT slug FROM {$wpdb->prefix}terms WHERE slug = '$variation_attribute_value'" );
if ( $term != $variation_attribute_value && $variation_attribute_value != $result[0] ) continue;
$product_price = wc_price( $variation['display_price'] );
$product_price = strip_tags( $product_price );
return $term . ' - (' . $product_price . ')';
}
}
}
}
return $term;
}
add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' );
This code is tested and works with multiple dropdowns and multiple attributes and product specific attributes like, attribute1 | attribute2 | attribute3.
// Add the prices next to the variations in WooCommerce
add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_names' );
function display_price_in_variation_option_names( $term_name ) {
global $wpdb, $product;
if ( is_product() && $product instanceof WC_Product && $product->is_type( 'variable' ) ) {
foreach ( $product->get_available_variations() as $variation ) {
foreach ( $variation['attributes'] as $variation_attribute_name => $variation_attribute_value ) {
$result = $wpdb->get_col( "SELECT slug FROM {$wpdb->prefix}terms WHERE slug = '$variation_attribute_value'" );
$taxonomy = str_replace( 'attribute_', '', $variation_attribute_name );
$term = get_term_by( 'slug', $variation_attribute_value, $taxonomy );
if ( $term_name == $variation_attribute_value ) {
$product_price = wc_price( $variation['display_price'] );
$product_price = strip_tags( $product_price );
return $term_name . ' - (' . $product_price . ')';
} else if( is_object($term) && $term->name == $term_name ) {
$product_price = wc_price( $variation['display_price'] );
$product_price = strip_tags( $product_price );
return $term_name . ' - (' . $product_price . ')';
}
}
}
}
return $term_name;
}

WooCommerce Currency Symbol

I am recently working with WooCommerce WordPress project for my client and I am editing a plugin for WooCommerce WordPress. I am trying to display the product price to include the currency code use this function
* #param mixed $item
* #param bool $inc_tax (default: false).
* #param bool $round (default: true).
* #return float
*/
public function get_item_total( $item, $inc_tax = false, $round = true ) {
$qty = ( ! empty( $item['qty'] ) ) ? $item['qty'] : 1;
if ( $inc_tax ) {
$price = ( $item['line_total'] + $item['line_tax'] ) / max( 1, $qty );
} else {
$price = $item['line_total'] / max( 1, $qty );
}
$price = '<span class="price">' . $round ? round( $price, wc_get_price_decimals() ) . '</span>' : '<span class="price">' . $price . '</span>' ;
return apply_filters( 'woocommerce_order_amount_item_total', $price, $this, $item, $inc_tax, $round );
}
But it spits out a number like 55 with out the currency symbol. is there anyway get the number with currency symbol like $55 ?
Thank you for all your help
ty rgdesign
This was the fix it works now
public function get_item_total( $item, $inc_tax = false, $round = true ) {
$qty = ( ! empty( $item['qty'] ) ) ? $item['qty'] : 1;
if ( $inc_tax ) {
$price = ( $item['line_total'] + $item['line_tax'] ) / max( 1, $qty );
} else {
$price = $item['line_total'] / max( 1, $qty );
}
$currency_symbol = get_woocommerce_currency_symbol();
$price = $round ? round($price, wc_get_price_decimals() ): $price;
$price = '<span class="price">' .$currency_symbol . $price .'</span>';
return apply_filters( 'woocommerce_order_amount_item_total',$price, $this, $item, $inc_tax, $round );
}
I found it to be very easy. Just insert the following code block to functions.php file under theme folder.
//Change the symbol of an existing currency
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
switch( $currency ) {
case 'USD': $currency_symbol = 'USD$'; break;
}
return $currency_symbol;
}

dont allow PO BOX shipping woocommerce not working

add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode');
function deny_pobox_postcode( $posted ) {
global $woocommerce;
$address = ( isset( $posted['shipping_address_1'] ) ) ? $posted['shipping_address_1'] : $posted['billing_address_1'];
$postcode = ( isset( $posted['shipping_postcode'] ) ) ? $posted['shipping_postcode'] : $posted['billing_postcode'];
$replace = array(" ", ".", ",");
$address = strtolower( str_replace( $replace, '', $address ) );
$postcode = strtolower( str_replace( $replace, '', $postcode ) );
if ( strstr( $address, 'pobox' ) || strstr( $postcode, 'pobox' ) ) {
$woocommerce->add_error( "Sorry, we don't ship to PO BOX addresses." );
}
}
i am getting:
fatal error :call to undefined add_error
when i am pasting on my function .php
add_error() has been renamed to wc_add_notice():
$woocommerce->wc_add_notice( "Sorry, we don't ship to PO BOX addresses." );
add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode');
function deny_pobox_postcode( $posted ) {
global $woocommerce;
$address = ( isset( $posted['shipping_address_1'] ) ) ?
$posted['shipping_address_1'] : $posted['billing_address_1'];
$postcode = ( isset( $posted['shipping_postcode'] ) ) ?
$posted['shipping_postcode'] : $posted['billing_postcode'];
$replace = array(" ", ".", ",");
$address = strtolower( str_replace( $replace, '', $address ) );
$postcode = strtolower( str_replace( $replace, '', $postcode ) );
if ( strstr( $address, 'pobox' ) || strstr( $postcode, 'pobox' ) ) {
$notice = sprintf( __( '%1$sSorry, we dont ship to PO BOX addresses..' , 'error' ) , '<strong>' , '</strong>' );
if ( version_compare( WC_VERSION, '2.3', '<' ) ) {
$woocommerce->add_error( $notice );
} else {
wc_add_notice( $notice, 'error' );
}
}
}
<?php
add_filter('woocommerce_package_rates',
'shomaris_hide_fedex_for_po_box_shipment',
10, 2);
function shomaris_hide_fedex_for_po_box_shipment($available_shipping_methods,
$package){
$shipping_method_to_hide = 'flat_rate:4';
// $shipping_method_to_hides = 'flat_rate:5';
global $woocommerce;
$address = ( !empty( $woocommerce->customer->get_shipping_address_1() ) ) ?
$woocommerce->customer->get_shipping_address_1() : $woocommerce->customer-
>get_billing_address_1();
$postcode = ( !empty( $woocommerce->customer->get_shipping_postcode() ) ) ?
$woocommerce->customer->get_shipping_postcode() : $woocommerce->customer-
>get_billing_postcode();
$replace = array(" ", ".", ",");
$address2 = strtolower( str_replace( $replace, '', $address ) );
if ( strstr( $address2, 'pobox' ) ) {
foreach ($available_shipping_methods as $shipping_method => $value) {
if( strpos( $shipping_method, $shipping_method_to_hide,
$shipping_method_to_hides ) !== false ) {
unset($available_shipping_methods[$shipping_method]);
}
}
}
return $available_shipping_methods;
}
?>

Woocommerce Breadcrumbs not displaying full path

Working on a woocommerce cart with many categories / sub categories / sub-sub cat's etc.
Bread crumbs default to only displaying the Home page, and whatever page your on... its kind of stupid.
So if I navigate to home/catalog/cat1/subcat1/product, the bread crumbs only display; home/catalog/product... What's the point of bread crumbs if you can't navigate your path backwards?
Has anyone else run into this problem?
If anyone else is looking, putting this in fuctions.php helped.
// Breadcrumbs Display Category Name //
function get_breadcrumb_category( $cat ) {
$post = get_post( $post->ID );
$post_type = $post->post_type;
$taxonomy = $cat;
$f_categories = wp_get_post_terms( $post->ID, $taxonomy );
$f_category = $f_categories[0];
if ( $f_category->parent != 0 ) {
$f_category_id = $f_category->parent;
$parent_array = get_term_by('id', $f_category_id, $taxonomy, 'ARRAY_A');
$f_category_name = $parent_array["name"];
$term_link = get_term_link( $f_category_id, $taxonomy );
} else {
$f_category_id = $f_category->term_id;
$f_category_name = $f_category->name;
$term_link = get_term_link( $f_category_id, $taxonomy );
}
if ( $f_categories && ! is_wp_error($f_categories) ) {
return '' . $f_category_name . '';
} else {
return '';
}
}
function x_breadcrumbs() {
if ( x_get_option( 'x_breadcrumb_display', '1' ) ) {
GLOBAL $post;
$is_ltr = ! is_rtl();
$stack = x_get_stack();
$delimiter = x_get_breadcrumb_delimiter();
$home_text = x_get_breadcrumb_home_text();
$home_link = home_url();
$current_before = x_get_breadcrumb_current_before();
$current_after = x_get_breadcrumb_current_after();
$page_title = get_the_title();
$blog_title = get_the_title( get_option( 'page_for_posts', true ) );
$post_parent = $post->post_parent;
if ( X_WOOCOMMERCE_IS_ACTIVE ) {
$shop_url = x_get_shop_link();
$shop_title = x_get_option( 'x_' . $stack . '_shop_title', __( 'The Shop', '__x__' ) );
$shop_link = '' . $shop_title . '';
}
echo '<div class="x-breadcrumbs">' . $home_text . '' . $delimiter;
if ( is_home() ) {
echo $current_before . $blog_title . $current_after;
} elseif ( is_category() ) {
$the_cat = get_category( get_query_var( 'cat' ), false );
if ( $the_cat->parent != 0 ) echo ''.get_the_title(102) .'';
echo $current_before . single_cat_title( '', false ) . $current_after;
} elseif ( x_is_product_category() ) {
if ( $is_ltr ) {
echo $shop_link . $delimiter . $current_before . single_cat_title( '', false ) . $current_after;
} else {
echo $current_before . single_cat_title( '', false ) . $current_after . $delimiter . $shop_link;
}
} elseif ( x_is_product_tag() ) {
if ( $is_ltr ) {
echo $shop_link . $delimiter . $current_before . single_tag_title( '', false ) . $current_after;
} else {
echo $current_before . single_tag_title( '', false ) . $current_after . $delimiter . $shop_link;
}
} elseif ( is_search() ) {
echo $current_before . __( 'Search Results for ', '__x__' ) . '“' . get_search_query() . '”' . $current_after;
} elseif ( is_singular( 'post' ) ) {
if ( get_option( 'page_for_posts' ) == is_front_page() ) {
echo $current_before . $page_title . $current_after;
} else {
if ( $is_ltr ) {
$f_category = get_the_category();
if ( $f_category[0]->parent != 0 ) {
$f_category_id = $f_category[0]->parent;
$f_category_name = get_cat_name( $f_category_id );
} else {
$f_category_id = $f_category[0]->term_id;
$f_category_name = $f_category[0]->name;
}
echo '' . $f_category_name . '' . $delimiter . $current_before . $page_title . $current_after;
} else {
echo $current_before . $page_title . $current_after . $delimiter . '' . $blog_title . '';
}
}
} elseif ( x_is_portfolio() ) {
echo $current_before . get_the_title() . $current_after;
} elseif ( x_is_portfolio_item() ) {
$link = x_get_parent_portfolio_link();
$title = x_get_parent_portfolio_title();
if ( $v = get_breadcrumb_category('portfolio-category') ) {
$portfolio_category = $delimiter . $v;
} else {
$portfolio_category = '';
}
if ( $is_ltr ) {
echo '' . $title . '' . $portfolio_category . $delimiter . $current_before . $page_title . $current_after;
} else {
echo $current_before . $page_title . $current_after . $portfolio_category . $delimiter . '' . $title . '';
}
} elseif ( x_is_product() ) {
if ( $v = get_breadcrumb_category('product_cat') ) {
$product_category = $delimiter . $v;
} else {
$product_category = '';
}
if ( $is_ltr ) {
echo $shop_link . $product_category . $delimiter . $current_before . $page_title . $current_after;
} else {
echo $current_before . $page_title . $current_after . $product_category . $delimiter . $shop_link;
}
} elseif ( x_is_buddypress() ) {
if ( bp_is_group() ) {
echo '' . x_get_option( 'x_buddypress_groups_title', __( 'Groups', '__x__' ) ) . '' . $delimiter . $current_before . x_buddypress_get_the_title() . $current_after;
} elseif ( bp_is_user() ) {
echo '' . x_get_option( 'x_buddypress_members_title', __( 'Members', '__x__' ) ) . '' . $delimiter . $current_before . x_buddypress_get_the_title() . $current_after;
} else {
echo $current_before . x_buddypress_get_the_title() . $current_after;
}
} elseif ( x_is_bbpress() ) {
remove_filter( 'bbp_no_breadcrumb', '__return_true' );
if ( bbp_is_forum_archive() ) {
echo $current_before . bbp_get_forum_archive_title() . $current_after;
} else {
echo bbp_get_breadcrumb();
}
add_filter( 'bbp_no_breadcrumb', '__return_true' );
} elseif ( is_page() && ! $post_parent ) {
echo $current_before . $page_title . $current_after;
} elseif ( is_page() && $post_parent ) {
$parent_id = $post_parent;
$breadcrumbs = array();
if ( is_rtl() ) {
echo $current_before . $page_title . $current_after . $delimiter;
}
while ( $parent_id ) {
$page = get_page( $parent_id );
$breadcrumbs[] = '' . get_the_title( $page->ID ) . '';
$parent_id = $page->post_parent;
}
if ( $is_ltr ) {
$breadcrumbs = array_reverse( $breadcrumbs );
}
for ( $i = 0; $i < count( $breadcrumbs ); $i++ ) {
echo $breadcrumbs[$i];
if ( $i != count( $breadcrumbs ) -1 ) echo $delimiter;
}
if ( $is_ltr ) {
echo $delimiter . $current_before . $page_title . $current_after;
}
} elseif ( is_tag() ) {
echo $current_before . single_tag_title( '', false ) . $current_after;
} elseif ( is_author() ) {
GLOBAL $author;
$userdata = get_userdata( $author );
echo $current_before . __( 'Posts by ', '__x__' ) . '“' . $userdata->display_name . $current_after . '”';
} elseif ( is_404() ) {
echo $current_before . __( '404 (Page Not Found)', '__x__' ) . $current_after;
} elseif ( is_archive() ) {
if ( x_is_shop() ) {
echo $current_before . $shop_title . $current_after;
} else {
echo $current_before . __( 'Archives ', '__x__' ) . $current_after;
}
}
echo '</div>';
}
}

Resources