Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordpres.../src/presente...
File: breadcrumbs-presenter.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Presenters;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Presentations\Indexable_Presentation;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Presenter class for the breadcrumbs.
[7] Fix | Delete
*/
[8] Fix | Delete
class Breadcrumbs_Presenter extends Abstract_Indexable_Presenter {
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* The id attribute.
[12] Fix | Delete
*
[13] Fix | Delete
* @var string
[14] Fix | Delete
*/
[15] Fix | Delete
private $id;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* The class name attribute.
[19] Fix | Delete
*
[20] Fix | Delete
* @var string
[21] Fix | Delete
*/
[22] Fix | Delete
private $class;
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* The wrapper element name.
[26] Fix | Delete
*
[27] Fix | Delete
* @var string
[28] Fix | Delete
*/
[29] Fix | Delete
private $wrapper;
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* Separator to use.
[33] Fix | Delete
*
[34] Fix | Delete
* @var string
[35] Fix | Delete
*/
[36] Fix | Delete
private $separator;
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* The element.
[40] Fix | Delete
*
[41] Fix | Delete
* @var string
[42] Fix | Delete
*/
[43] Fix | Delete
private $element;
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Presents the breadcrumbs.
[47] Fix | Delete
*
[48] Fix | Delete
* @return string The breadcrumbs HTML.
[49] Fix | Delete
*/
[50] Fix | Delete
public function present() {
[51] Fix | Delete
$breadcrumbs = $this->get();
[52] Fix | Delete
if ( ! \is_array( $breadcrumbs ) || empty( $breadcrumbs ) ) {
[53] Fix | Delete
return '';
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
$links = [];
[57] Fix | Delete
$total = \count( $breadcrumbs );
[58] Fix | Delete
foreach ( $breadcrumbs as $index => $breadcrumb ) {
[59] Fix | Delete
$links[ $index ] = $this->crumb_to_link( $breadcrumb, $index, $total );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
// Removes any effectively empty links.
[63] Fix | Delete
$links = \array_map( 'trim', $links );
[64] Fix | Delete
$links = \array_filter( $links );
[65] Fix | Delete
$output = \implode( $this->get_separator(), $links );
[66] Fix | Delete
[67] Fix | Delete
if ( empty( $output ) ) {
[68] Fix | Delete
return '';
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
$output = '<' . $this->get_wrapper() . $this->get_id() . $this->get_class() . '>' . $output . '</' . $this->get_wrapper() . '>';
[72] Fix | Delete
$output = $this->filter( $output );
[73] Fix | Delete
[74] Fix | Delete
$prefix = $this->helpers->options->get( 'breadcrumbs-prefix' );
[75] Fix | Delete
if ( $prefix !== '' ) {
[76] Fix | Delete
$output = "\t" . $prefix . "\n" . $output;
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
return $output;
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* Gets the raw value of a presentation.
[84] Fix | Delete
*
[85] Fix | Delete
* @return array The raw value.
[86] Fix | Delete
*/
[87] Fix | Delete
public function get() {
[88] Fix | Delete
return $this->presentation->breadcrumbs;
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* Filters the output.
[93] Fix | Delete
*
[94] Fix | Delete
* @param string $output The HTML output.
[95] Fix | Delete
*
[96] Fix | Delete
* @return string The filtered output.
[97] Fix | Delete
*/
[98] Fix | Delete
protected function filter( $output ) {
[99] Fix | Delete
/**
[100] Fix | Delete
* Filter: 'wpseo_breadcrumb_output' - Allow changing the HTML output of the Yoast SEO breadcrumbs class.
[101] Fix | Delete
*
[102] Fix | Delete
* @param string $output The HTML output.
[103] Fix | Delete
* @param Indexable_Presentation $presentation The presentation of an indexable.
[104] Fix | Delete
*/
[105] Fix | Delete
return \apply_filters( 'wpseo_breadcrumb_output', $output, $this->presentation );
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Create a breadcrumb element string.
[110] Fix | Delete
*
[111] Fix | Delete
* @param array $breadcrumb Link info array containing the keys:
[112] Fix | Delete
* 'text' => (string) link text.
[113] Fix | Delete
* 'url' => (string) link url.
[114] Fix | Delete
* (optional) 'title' => (string) link title attribute text.
[115] Fix | Delete
* @param int $index Index for the current breadcrumb.
[116] Fix | Delete
* @param int $total The total number of breadcrumbs.
[117] Fix | Delete
*
[118] Fix | Delete
* @return string The breadcrumb link.
[119] Fix | Delete
*/
[120] Fix | Delete
protected function crumb_to_link( $breadcrumb, $index, $total ) {
[121] Fix | Delete
$link = '';
[122] Fix | Delete
[123] Fix | Delete
if ( ! isset( $breadcrumb['text'] ) || ! \is_string( $breadcrumb['text'] ) || empty( $breadcrumb['text'] ) ) {
[124] Fix | Delete
return $link;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
$text = \trim( $breadcrumb['text'] );
[128] Fix | Delete
[129] Fix | Delete
if (
[130] Fix | Delete
$index < ( $total - 1 )
[131] Fix | Delete
&& isset( $breadcrumb['url'] )
[132] Fix | Delete
&& \is_string( $breadcrumb['url'] )
[133] Fix | Delete
&& ! empty( $breadcrumb['url'] )
[134] Fix | Delete
) {
[135] Fix | Delete
// If it's not the last element and we have a url.
[136] Fix | Delete
$link .= '<' . $this->get_element() . '>';
[137] Fix | Delete
$title_attr = isset( $breadcrumb['title'] ) ? ' title="' . \esc_attr( $breadcrumb['title'] ) . '"' : '';
[138] Fix | Delete
$link .= '<a href="' . \esc_url( $breadcrumb['url'] ) . '"' . $title_attr . '>' . $text . '</a>';
[139] Fix | Delete
$link .= '</' . $this->get_element() . '>';
[140] Fix | Delete
}
[141] Fix | Delete
elseif ( $index === ( $total - 1 ) ) {
[142] Fix | Delete
// If it's the last element.
[143] Fix | Delete
[144] Fix | Delete
if ( $this->helpers->options->get( 'breadcrumbs-boldlast' ) === true ) {
[145] Fix | Delete
$text = '<strong>' . $text . '</strong>';
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
$link .= '<' . $this->get_element() . ' class="breadcrumb_last" aria-current="page">' . $text . '</' . $this->get_element() . '>';
[149] Fix | Delete
}
[150] Fix | Delete
else {
[151] Fix | Delete
// It's not the last element and has no url.
[152] Fix | Delete
$link .= '<' . $this->get_element() . '>' . $text . '</' . $this->get_element() . '>';
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
/**
[156] Fix | Delete
* Filter: 'wpseo_breadcrumb_single_link' - Allow changing of each link being put out by the Yoast SEO breadcrumbs class.
[157] Fix | Delete
*
[158] Fix | Delete
* @param string $link_output The output string.
[159] Fix | Delete
* @param array $link The breadcrumb link array.
[160] Fix | Delete
*/
[161] Fix | Delete
return \apply_filters( 'wpseo_breadcrumb_single_link', $link, $breadcrumb );
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
/**
[165] Fix | Delete
* Retrieves HTML ID attribute.
[166] Fix | Delete
*
[167] Fix | Delete
* @return string The id attribute.
[168] Fix | Delete
*/
[169] Fix | Delete
protected function get_id() {
[170] Fix | Delete
if ( ! $this->id ) {
[171] Fix | Delete
/**
[172] Fix | Delete
* Filter: 'wpseo_breadcrumb_output_id' - Allow changing the HTML ID on the Yoast SEO breadcrumbs wrapper element.
[173] Fix | Delete
*
[174] Fix | Delete
* @param string $unsigned ID to add to the wrapper element.
[175] Fix | Delete
*/
[176] Fix | Delete
$this->id = \apply_filters( 'wpseo_breadcrumb_output_id', '' );
[177] Fix | Delete
if ( ! \is_string( $this->id ) ) {
[178] Fix | Delete
return '';
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
if ( $this->id !== '' ) {
[182] Fix | Delete
$this->id = ' id="' . \esc_attr( $this->id ) . '"';
[183] Fix | Delete
}
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
return $this->id;
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
/**
[190] Fix | Delete
* Retrieves HTML Class attribute.
[191] Fix | Delete
*
[192] Fix | Delete
* @return string The class attribute.
[193] Fix | Delete
*/
[194] Fix | Delete
protected function get_class() {
[195] Fix | Delete
if ( ! $this->class ) {
[196] Fix | Delete
/**
[197] Fix | Delete
* Filter: 'wpseo_breadcrumb_output_class' - Allow changing the HTML class on the Yoast SEO breadcrumbs wrapper element.
[198] Fix | Delete
*
[199] Fix | Delete
* @param string $unsigned Class to add to the wrapper element.
[200] Fix | Delete
*/
[201] Fix | Delete
$this->class = \apply_filters( 'wpseo_breadcrumb_output_class', '' );
[202] Fix | Delete
if ( ! \is_string( $this->class ) ) {
[203] Fix | Delete
return '';
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
if ( $this->class !== '' ) {
[207] Fix | Delete
$this->class = ' class="' . \esc_attr( $this->class ) . '"';
[208] Fix | Delete
}
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
return $this->class;
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
/**
[215] Fix | Delete
* Retrieves the wrapper element name.
[216] Fix | Delete
*
[217] Fix | Delete
* @return string The wrapper element name.
[218] Fix | Delete
*/
[219] Fix | Delete
protected function get_wrapper() {
[220] Fix | Delete
if ( ! $this->wrapper ) {
[221] Fix | Delete
$this->wrapper = \apply_filters( 'wpseo_breadcrumb_output_wrapper', 'span' );
[222] Fix | Delete
$this->wrapper = \tag_escape( $this->wrapper );
[223] Fix | Delete
if ( ! \is_string( $this->wrapper ) || $this->wrapper === '' ) {
[224] Fix | Delete
$this->wrapper = 'span';
[225] Fix | Delete
}
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
return $this->wrapper;
[229] Fix | Delete
}
[230] Fix | Delete
[231] Fix | Delete
/**
[232] Fix | Delete
* Retrieves the separator.
[233] Fix | Delete
*
[234] Fix | Delete
* @return string The separator.
[235] Fix | Delete
*/
[236] Fix | Delete
protected function get_separator() {
[237] Fix | Delete
if ( ! $this->separator ) {
[238] Fix | Delete
$this->separator = \apply_filters( 'wpseo_breadcrumb_separator', $this->helpers->options->get( 'breadcrumbs-sep' ) );
[239] Fix | Delete
$this->separator = ' ' . $this->separator . ' ';
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
return $this->separator;
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
/**
[246] Fix | Delete
* Retrieves the crumb element name.
[247] Fix | Delete
*
[248] Fix | Delete
* @return string The element to use.
[249] Fix | Delete
*/
[250] Fix | Delete
protected function get_element() {
[251] Fix | Delete
if ( ! $this->element ) {
[252] Fix | Delete
$this->element = \esc_attr( \apply_filters( 'wpseo_breadcrumb_single_link_wrapper', 'span' ) );
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
return $this->element;
[256] Fix | Delete
}
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function