PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.6
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / integrations / breadcrumbs-integration.php

breadcrumbs-integration.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.6, at src/integrations/breadcrumbs-integration.php

81 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Integrations;
4
5 use WPSEO_Replace_Vars;
6 use Yoast\WP\SEO\Memoizers\Meta_Tags_Context_Memoizer;
7 use Yoast\WP\SEO\Presenters\Breadcrumbs_Presenter;
8 use Yoast\WP\SEO\Surfaces\Helpers_Surface;
9
10 /**
11 * Adds customizations to the front end for breadcrumbs.
12 */
13 class Breadcrumbs_Integration implements Integration_Interface {
14
15 /**
16 * The breadcrumbs presenter.
17 *
18 * @var Breadcrumbs_Presenter
19 */
20 private $presenter;
21
22 /**
23 * The meta tags context memoizer.
24 *
25 * @var Meta_Tags_Context_Memoizer
26 */
27 private $context_memoizer;
28
29 /**
30 * Breadcrumbs integration constructor.
31 *
32 * @param Helpers_Surface $helpers The helpers.
33 * @param WPSEO_Replace_Vars $replace_vars The replace vars.
34 * @param Meta_Tags_Context_Memoizer $context_memoizer The meta tags context memoizer.
35 */
36 public function __construct(
37 Helpers_Surface $helpers,
38 WPSEO_Replace_Vars $replace_vars,
39 Meta_Tags_Context_Memoizer $context_memoizer
40 ) {
41 $this->context_memoizer = $context_memoizer;
42 $this->presenter = new Breadcrumbs_Presenter();
43 $this->presenter->helpers = $helpers;
44 $this->presenter->replace_vars = $replace_vars;
45 }
46
47 /**
48 * Returns the conditionals based in which this loadable should be active.
49 *
50 * @return array The array of conditionals.
51 */
52 public static function get_conditionals() {
53 return [];
54 }
55
56 /**
57 * Registers the `wpseo_breadcrumb` shortcode.
58 *
59 * @codeCoverageIgnore
60 */
61 public function register_hooks() {
62 \add_shortcode( 'wpseo_breadcrumb', [ $this, 'render' ] );
63 }
64
65 /**
66 * Renders the breadcrumbs.
67 *
68 * @return string The rendered breadcrumbs.
69 */
70 public function render() {
71 $context = $this->context_memoizer->for_current_page();
72
73 /** This filter is documented in src/integrations/front-end-integration.php */
74 $presentation = \apply_filters( 'wpseo_frontend_presentation', $context->presentation, $context );
75
76 $this->presenter->presentation = $presentation;
77
78 return $this->presenter->present();
79 }
80 }
81