Merge pull request #23057 from freer4/patch-1
Allow extension of WC_Breadcrumb class
This commit is contained in:
commit
986375862e
|
@ -18,7 +18,7 @@ class WC_Breadcrumb {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $crumbs = array();
|
||||
protected $crumbs = array();
|
||||
|
||||
/**
|
||||
* Add a crumb so we don't get lost.
|
||||
|
@ -92,7 +92,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Prepend the shop page to shop breadcrumbs.
|
||||
*/
|
||||
private function prepend_shop_page() {
|
||||
protected function prepend_shop_page() {
|
||||
$permalinks = wc_get_permalink_structure();
|
||||
$shop_page_id = wc_get_page_id( 'shop' );
|
||||
$shop_page = get_post( $shop_page_id );
|
||||
|
@ -106,21 +106,21 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Is home trail..
|
||||
*/
|
||||
private function add_crumbs_home() {
|
||||
protected function add_crumbs_home() {
|
||||
$this->add_crumb( single_post_title( '', false ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 404 trail.
|
||||
*/
|
||||
private function add_crumbs_404() {
|
||||
protected function add_crumbs_404() {
|
||||
$this->add_crumb( __( 'Error 404', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment trail.
|
||||
*/
|
||||
private function add_crumbs_attachment() {
|
||||
protected function add_crumbs_attachment() {
|
||||
global $post;
|
||||
|
||||
$this->add_crumbs_single( $post->post_parent, get_permalink( $post->post_parent ) );
|
||||
|
@ -133,7 +133,7 @@ class WC_Breadcrumb {
|
|||
* @param int $post_id Post ID.
|
||||
* @param string $permalink Post permalink.
|
||||
*/
|
||||
private function add_crumbs_single( $post_id = 0, $permalink = '' ) {
|
||||
protected function add_crumbs_single( $post_id = 0, $permalink = '' ) {
|
||||
if ( ! $post_id ) {
|
||||
global $post;
|
||||
} else {
|
||||
|
@ -184,7 +184,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Page trail.
|
||||
*/
|
||||
private function add_crumbs_page() {
|
||||
protected function add_crumbs_page() {
|
||||
global $post;
|
||||
|
||||
if ( $post->post_parent ) {
|
||||
|
@ -211,7 +211,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Product category trail.
|
||||
*/
|
||||
private function add_crumbs_product_category() {
|
||||
protected function add_crumbs_product_category() {
|
||||
$current_term = $GLOBALS['wp_query']->get_queried_object();
|
||||
|
||||
$this->prepend_shop_page();
|
||||
|
@ -222,7 +222,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Product tag trail.
|
||||
*/
|
||||
private function add_crumbs_product_tag() {
|
||||
protected function add_crumbs_product_tag() {
|
||||
$current_term = $GLOBALS['wp_query']->get_queried_object();
|
||||
|
||||
$this->prepend_shop_page();
|
||||
|
@ -234,7 +234,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Shop breadcrumb.
|
||||
*/
|
||||
private function add_crumbs_shop() {
|
||||
protected function add_crumbs_shop() {
|
||||
if ( intval( get_option( 'page_on_front' ) ) === wc_get_page_id( 'shop' ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Post type archive trail.
|
||||
*/
|
||||
private function add_crumbs_post_type_archive() {
|
||||
protected function add_crumbs_post_type_archive() {
|
||||
$post_type = get_post_type_object( get_post_type() );
|
||||
|
||||
if ( $post_type ) {
|
||||
|
@ -263,7 +263,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Category trail.
|
||||
*/
|
||||
private function add_crumbs_category() {
|
||||
protected function add_crumbs_category() {
|
||||
$this_category = get_category( $GLOBALS['wp_query']->get_queried_object() );
|
||||
|
||||
if ( 0 !== intval( $this_category->parent ) ) {
|
||||
|
@ -276,7 +276,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Tag trail.
|
||||
*/
|
||||
private function add_crumbs_tag() {
|
||||
protected function add_crumbs_tag() {
|
||||
$queried_object = $GLOBALS['wp_query']->get_queried_object();
|
||||
|
||||
/* translators: %s: tag name */
|
||||
|
@ -286,7 +286,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Add crumbs for date based archives.
|
||||
*/
|
||||
private function add_crumbs_date() {
|
||||
protected function add_crumbs_date() {
|
||||
if ( is_year() || is_month() || is_day() ) {
|
||||
$this->add_crumb( get_the_time( 'Y' ), get_year_link( get_the_time( 'Y' ) ) );
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Add crumbs for taxonomies
|
||||
*/
|
||||
private function add_crumbs_tax() {
|
||||
protected function add_crumbs_tax() {
|
||||
$this_term = $GLOBALS['wp_query']->get_queried_object();
|
||||
$taxonomy = get_taxonomy( $this_term->taxonomy );
|
||||
|
||||
|
@ -317,7 +317,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Add a breadcrumb for author archives.
|
||||
*/
|
||||
private function add_crumbs_author() {
|
||||
protected function add_crumbs_author() {
|
||||
global $author;
|
||||
|
||||
$userdata = get_userdata( $author );
|
||||
|
@ -332,7 +332,7 @@ class WC_Breadcrumb {
|
|||
* @param int $term_id Term ID.
|
||||
* @param string $taxonomy Taxonomy.
|
||||
*/
|
||||
private function term_ancestors( $term_id, $taxonomy ) {
|
||||
protected function term_ancestors( $term_id, $taxonomy ) {
|
||||
$ancestors = get_ancestors( $term_id, $taxonomy );
|
||||
$ancestors = array_reverse( $ancestors );
|
||||
|
||||
|
@ -348,7 +348,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Endpoints.
|
||||
*/
|
||||
private function endpoint_trail() {
|
||||
protected function endpoint_trail() {
|
||||
$endpoint = is_wc_endpoint_url() ? WC()->query->get_current_endpoint() : '';
|
||||
$endpoint_title = $endpoint ? WC()->query->get_endpoint_title( $endpoint ) : '';
|
||||
|
||||
|
@ -360,7 +360,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Add a breadcrumb for search results.
|
||||
*/
|
||||
private function search_trail() {
|
||||
protected function search_trail() {
|
||||
if ( is_search() ) {
|
||||
/* translators: %s: search term */
|
||||
$this->add_crumb( sprintf( __( 'Search results for “%s”', 'woocommerce' ), get_search_query() ), remove_query_arg( 'paged' ) );
|
||||
|
@ -370,7 +370,7 @@ class WC_Breadcrumb {
|
|||
/**
|
||||
* Add a breadcrumb for pagination.
|
||||
*/
|
||||
private function paged_trail() {
|
||||
protected function paged_trail() {
|
||||
if ( get_query_var( 'paged' ) && 'subcategories' !== woocommerce_get_loop_display_mode() ) {
|
||||
/* translators: %d: page number */
|
||||
$this->add_crumb( sprintf( __( 'Page %d', 'woocommerce' ), get_query_var( 'paged' ) ) );
|
||||
|
|
Loading…
Reference in New Issue