Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/theme-to...
File: site-breadcrumbs.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Plugin Name: Site Breadcrumbs
[2] Fix | Delete
* Plugin URI: https://wordpress.com
[3] Fix | Delete
* Description: Quickly add breadcrumbs to the single view of a hierarchical post type or a hierarchical taxonomy.
[4] Fix | Delete
* Author: Automattic
[5] Fix | Delete
* Version: 1.0
[6] Fix | Delete
* Author URI: https://wordpress.com
[7] Fix | Delete
* License: GPL2 or later
[8] Fix | Delete
* Text Domain: jetpack
[9] Fix | Delete
*
[10] Fix | Delete
* @package automattic/jetpack
[11] Fix | Delete
*/
[12] Fix | Delete
[13] Fix | Delete
if ( ! class_exists( '\Automattic\Jetpack\Classic_Theme_Helper\Main' ) ) {
[14] Fix | Delete
[15] Fix | Delete
if ( ! function_exists( 'jetpack_breadcrumbs' ) ) {
[16] Fix | Delete
/**
[17] Fix | Delete
* Echos a set of breadcrumbs.
[18] Fix | Delete
*
[19] Fix | Delete
* Themes can call this function where the breadcrumbs should be outputted.
[20] Fix | Delete
*
[21] Fix | Delete
* @phan-suppress PhanRedefineFunction -- Covered by function_exists check.
[22] Fix | Delete
*/
[23] Fix | Delete
function jetpack_breadcrumbs() {
[24] Fix | Delete
_deprecated_function( __FUNCTION__, 'jetpack-13.8' );
[25] Fix | Delete
$taxonomy = is_category() ? 'category' : get_query_var( 'taxonomy' );
[26] Fix | Delete
$is_taxonomy_hierarchical = is_taxonomy_hierarchical( $taxonomy );
[27] Fix | Delete
[28] Fix | Delete
$post_type = is_page() ? 'page' : get_query_var( 'post_type' );
[29] Fix | Delete
$is_post_type_hierarchical = is_post_type_hierarchical( $post_type );
[30] Fix | Delete
[31] Fix | Delete
if ( ! ( $is_post_type_hierarchical || $is_taxonomy_hierarchical ) || is_front_page() ) {
[32] Fix | Delete
return;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
$breadcrumb = '';
[36] Fix | Delete
$position = 1;
[37] Fix | Delete
[38] Fix | Delete
if ( $is_post_type_hierarchical ) {
[39] Fix | Delete
$post_id = get_queried_object_id();
[40] Fix | Delete
$ancestors = array_reverse( get_post_ancestors( $post_id ) );
[41] Fix | Delete
if ( $ancestors ) {
[42] Fix | Delete
foreach ( $ancestors as $ancestor ) {
[43] Fix | Delete
$breadcrumb .= '<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><meta itemprop="position" content="' . esc_attr( $position ) . '"><a href="' . esc_url( get_permalink( $ancestor ) ) . '" itemprop="item"><span itemprop="name">' . esc_html( get_the_title( $ancestor ) ) . '</span></a></span>';
[44] Fix | Delete
++$position;
[45] Fix | Delete
}
[46] Fix | Delete
}
[47] Fix | Delete
$breadcrumb .= '<span class="current-page" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><meta itemprop="position" content="' . esc_attr( $position ) . '"><span itemprop="name">' . esc_html( get_the_title( $post_id ) ) . '</span></span>';
[48] Fix | Delete
} elseif ( $is_taxonomy_hierarchical ) {
[49] Fix | Delete
$current = get_term( get_queried_object_id(), $taxonomy );
[50] Fix | Delete
[51] Fix | Delete
if ( is_wp_error( $current ) ) {
[52] Fix | Delete
return;
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
if ( $current->parent ) {
[56] Fix | Delete
$breadcrumb = jetpack_get_term_parents( $current->parent, $taxonomy );
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
$breadcrumb .= '<span class="current-category" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><meta property="position" content="' . esc_attr( $position ) . '"><span itemprop="name">' . esc_html( $current->name ) . '</span></span>';
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
$home = '<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><meta itemprop="position" content="' . esc_attr( $position ) . '"><meta itemprop="position" content="0"><a href="' . esc_url( home_url( '/' ) ) . '" class="home-link" itemprop="item" rel="home"><span itemprop="name">' . esc_html__( 'Home', 'jetpack' ) . '</span></a></span>';
[63] Fix | Delete
[64] Fix | Delete
echo '<nav class="entry-breadcrumbs" itemscope itemtype="https://schema.org/BreadcrumbList">' . $home . $breadcrumb . '</nav>'; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
if ( ! function_exists( 'jetpack_get_term_parents' ) ) {
[70] Fix | Delete
/**
[71] Fix | Delete
* Return the parents for a given taxonomy term ID.
[72] Fix | Delete
*
[73] Fix | Delete
* @phan-suppress PhanRedefineFunction -- Covered by function_exists check.
[74] Fix | Delete
*
[75] Fix | Delete
* @param int $term Taxonomy term whose parents will be returned.
[76] Fix | Delete
* @param string $taxonomy Taxonomy name that the term belongs to.
[77] Fix | Delete
* @param array $visited Terms already added to prevent duplicates.
[78] Fix | Delete
*
[79] Fix | Delete
* @return string A list of links to the term parents.
[80] Fix | Delete
*/
[81] Fix | Delete
function jetpack_get_term_parents( $term, $taxonomy, $visited = array() ) {
[82] Fix | Delete
_deprecated_function( __FUNCTION__, 'jetpack-13.8' );
[83] Fix | Delete
$parent = get_term( $term, $taxonomy );
[84] Fix | Delete
[85] Fix | Delete
if ( is_wp_error( $parent ) ) {
[86] Fix | Delete
return $parent;
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
$chain = '';
[90] Fix | Delete
[91] Fix | Delete
if ( $parent->parent && ( $parent->parent !== $parent->term_id ) && ! in_array( $parent->parent, $visited, true ) ) {
[92] Fix | Delete
$visited[] = $parent->parent;
[93] Fix | Delete
$chain .= jetpack_get_term_parents( $parent->parent, $taxonomy, $visited );
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
$chain .= '<a href="' . esc_url( get_category_link( $parent->term_id ) ) . '">' . $parent->name . '</a>';
[97] Fix | Delete
[98] Fix | Delete
return $chain;
[99] Fix | Delete
}
[100] Fix | Delete
}
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function