Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../src/deprecat.../frontend
File: breadcrumbs.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Backwards compatibility class for breadcrumbs.
[2] Fix | Delete
*
[3] Fix | Delete
* @package Yoast\YoastSEO\Backwards_Compatibility
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
use Yoast\WP\SEO\Memoizers\Meta_Tags_Context_Memoizer;
[7] Fix | Delete
use Yoast\WP\SEO\Presenters\Breadcrumbs_Presenter;
[8] Fix | Delete
use Yoast\WP\SEO\Surfaces\Helpers_Surface;
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Class WPSEO_Breadcrumbs
[12] Fix | Delete
*
[13] Fix | Delete
* @codeCoverageIgnore Because of deprecation.
[14] Fix | Delete
*/
[15] Fix | Delete
class WPSEO_Breadcrumbs {
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Instance of this class.
[19] Fix | Delete
*
[20] Fix | Delete
* @var WPSEO_Breadcrumbs
[21] Fix | Delete
*/
[22] Fix | Delete
public static $instance;
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Last used 'before' string.
[26] Fix | Delete
*
[27] Fix | Delete
* @var string
[28] Fix | Delete
*/
[29] Fix | Delete
public static $before = '';
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* Last used 'after' string.
[33] Fix | Delete
*
[34] Fix | Delete
* @var string
[35] Fix | Delete
*/
[36] Fix | Delete
public static $after = '';
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* The memoizer for the meta tags context.
[40] Fix | Delete
*
[41] Fix | Delete
* @var Meta_Tags_Context_Memoizer
[42] Fix | Delete
*/
[43] Fix | Delete
protected $context_memoizer;
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* The helpers surface.
[47] Fix | Delete
*
[48] Fix | Delete
* @var Helpers_Surface
[49] Fix | Delete
*/
[50] Fix | Delete
protected $helpers;
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* The replace vars helper
[54] Fix | Delete
*
[55] Fix | Delete
* @var WPSEO_Replace_Vars
[56] Fix | Delete
*/
[57] Fix | Delete
protected $replace_vars;
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* WPSEO_Breadcrumbs constructor.
[61] Fix | Delete
*/
[62] Fix | Delete
public function __construct() {
[63] Fix | Delete
$this->context_memoizer = YoastSEO()->classes->get( Meta_Tags_Context_Memoizer::class );
[64] Fix | Delete
$this->helpers = YoastSEO()->classes->get( Helpers_Surface::class );
[65] Fix | Delete
$this->replace_vars = YoastSEO()->classes->get( WPSEO_Replace_Vars::class );
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Get breadcrumb string using the singleton instance of this class.
[70] Fix | Delete
*
[71] Fix | Delete
* @param string $before Optional string to prepend.
[72] Fix | Delete
* @param string $after Optional string to append.
[73] Fix | Delete
* @param bool $display Echo or return flag.
[74] Fix | Delete
*
[75] Fix | Delete
* @return string Returns the breadcrumbs as a string.
[76] Fix | Delete
*/
[77] Fix | Delete
public static function breadcrumb( $before = '', $after = '', $display = true ) {
[78] Fix | Delete
// Remember the last used before/after for use in case the object goes __toString().
[79] Fix | Delete
self::$before = $before;
[80] Fix | Delete
self::$after = $after;
[81] Fix | Delete
$output = $before . self::get_instance()->render() . $after;
[82] Fix | Delete
[83] Fix | Delete
if ( $display === true ) {
[84] Fix | Delete
echo $output;
[85] Fix | Delete
[86] Fix | Delete
return '';
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
return $output;
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Magic method to use in case the class would be send to string.
[94] Fix | Delete
*
[95] Fix | Delete
* @return string The rendered breadcrumbs.
[96] Fix | Delete
*/
[97] Fix | Delete
public function __toString() {
[98] Fix | Delete
return self::$before . $this->render() . self::$after;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* Retrieves an instance of the class.
[103] Fix | Delete
*
[104] Fix | Delete
* @return static The instance.
[105] Fix | Delete
*/
[106] Fix | Delete
public static function get_instance() {
[107] Fix | Delete
if ( is_null( self::$instance ) ) {
[108] Fix | Delete
self::$instance = new self();
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
return self::$instance;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Returns the collected links for the breadcrumbs.
[116] Fix | Delete
*
[117] Fix | Delete
* @return array The collected links.
[118] Fix | Delete
*/
[119] Fix | Delete
public function get_links() {
[120] Fix | Delete
$context = $this->context_memoizer->for_current_page();
[121] Fix | Delete
[122] Fix | Delete
return $context->presentation->breadcrumbs;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* Renders the breadcrumbs.
[127] Fix | Delete
*
[128] Fix | Delete
* @return string The rendered breadcrumbs.
[129] Fix | Delete
*/
[130] Fix | Delete
private function render() {
[131] Fix | Delete
$presenter = new Breadcrumbs_Presenter();
[132] Fix | Delete
$context = $this->context_memoizer->for_current_page();
[133] Fix | Delete
/** This filter is documented in src/integrations/front-end-integration.php */
[134] Fix | Delete
$presentation = apply_filters( 'wpseo_frontend_presentation', $context->presentation, $context );
[135] Fix | Delete
$presenter->presentation = $presentation;
[136] Fix | Delete
$presenter->replace_vars = $this->replace_vars;
[137] Fix | Delete
$presenter->helpers = $this->helpers;
[138] Fix | Delete
[139] Fix | Delete
return $presenter->present();
[140] Fix | Delete
}
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function