PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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
← All changes | src/deprecated/frontend/frontend.php +0 -280 28.5 → trunk View file →
@@ -1,280 +1,0 @@
1 -<?php
2 -/**
3 - * Backwards compatibility class for WPSEO_Frontend.
4 - *
5 - * @package Yoast\YoastSEO\Backwards_Compatibility
6 - */
7 -
8 -use Yoast\WP\SEO\Memoizers\Meta_Tags_Context_Memoizer;
9 -use Yoast\WP\SEO\Presenters\Canonical_Presenter;
10 -use Yoast\WP\SEO\Presenters\Meta_Description_Presenter;
11 -use Yoast\WP\SEO\Presenters\Rel_Next_Presenter;
12 -use Yoast\WP\SEO\Presenters\Rel_Prev_Presenter;
13 -use Yoast\WP\SEO\Presenters\Robots_Presenter;
14 -use Yoast\WP\SEO\Surfaces\Helpers_Surface;
15 -
16 -/**
17 - * Class WPSEO_Frontend
18 - *
19 - * @codeCoverageIgnore Because of deprecation.
20 - */
21 -class WPSEO_Frontend {
22 -
23 - /**
24 - * Instance of this class.
25 - *
26 - * @var WPSEO_Frontend
27 - */
28 - public static $instance;
29 -
30 - /**
31 - * The memoizer for the meta tags context.
32 - *
33 - * @var Meta_Tags_Context_Memoizer
34 - */
35 - private $context_memoizer;
36 -
37 - /**
38 - * The WPSEO Replace Vars object.
39 - *
40 - * @var WPSEO_Replace_Vars
41 - */
42 - private $replace_vars;
43 -
44 - /**
45 - * The helpers surface.
46 - *
47 - * @var Helpers_Surface
48 - */
49 - private $helpers;
50 -
51 - /**
52 - * WPSEO_Frontend constructor.
53 - */
54 - public function __construct() {
55 - $this->context_memoizer = YoastSEO()->classes->get( Meta_Tags_Context_Memoizer::class );
56 - $this->replace_vars = YoastSEO()->classes->get( WPSEO_Replace_Vars::class );
57 - $this->helpers = YoastSEO()->classes->get( Helpers_Surface::class );
58 - }
59 -
60 - /**
61 - * Catches call to methods that don't exist and might deprecated.
62 - *
63 - * @param string $method The called method.
64 - * @param array $arguments The given arguments.
65 - *
66 - * @return mixed
67 - */
68 - public function __call( $method, $arguments ) {
69 - _deprecated_function( $method, 'Yoast SEO 14.0' );
70 -
71 - $title_methods = [
72 - 'title',
73 - 'fix_woo_title',
74 - 'get_content_title',
75 - 'get_seo_title',
76 - 'get_taxonomy_title',
77 - 'get_author_title',
78 - 'get_title_from_options',
79 - 'get_default_title',
80 - 'force_wp_title',
81 - ];
82 - if ( in_array( $method, $title_methods, true ) ) {
83 - return $this->get_title();
84 - }
85 -
86 - return null;
87 - }
88 -
89 - /**
90 - * Retrieves an instance of the class.
91 - *
92 - * @return static The instance.
93 - */
94 - public static function get_instance() {
95 - self::$instance ??= new self();
96 -
97 - return self::$instance;
98 - }
99 -
100 - /**
101 - * Outputs the canonical value.
102 - *
103 - * @param bool $echo Whether or not to output the canonical element.
104 - * @param bool $un_paged Whether or not to return the canonical with or without pagination added to the URL.
105 - * @param bool $no_override Whether or not to return a manually overridden canonical.
106 - *
107 - * @return string|void
108 - */
109 - public function canonical( $echo = true, $un_paged = false, $no_override = false ) {
110 - _deprecated_function( __METHOD__, 'Yoast SEO 14.0' );
111 -
112 - $presentation = $this->get_current_page_presentation();
113 - $presenter = new Canonical_Presenter();
114 -
115 - /** This filter is documented in src/integrations/front-end-integration.php */
116 - $presenter->presentation = $presentation;
117 - $presenter->helpers = $this->helpers;
118 - $presenter->replace_vars = $this->replace_vars;
119 -
120 - if ( ! $echo ) {
121 - return $presenter->get();
122 - }
123 -
124 - echo $presenter->present();
125 - }
126 -
127 - /**
128 - * Retrieves the meta robots value.
129 - *
130 - * @return string
131 - */
132 - public function get_robots() {
133 - _deprecated_function( __METHOD__, 'Yoast SEO 14.0' );
134 -
135 - $presentation = $this->get_current_page_presentation();
136 - return $presentation->robots;
137 - }
138 -
139 - /**
140 - * Outputs the meta robots value.
141 - *
142 - * @return void
143 - */
144 - public function robots() {
145 - _deprecated_function( __METHOD__, 'Yoast SEO 14.0' );
146 -
147 - $presentation = $this->get_current_page_presentation();
148 - $presenter = new Robots_Presenter();
149 - $presenter->presentation = $presentation;
150 - $presenter->helpers = $this->helpers;
151 - $presenter->replace_vars = $this->replace_vars;
152 - echo $presenter->present();
153 - }
154 -
155 - /**
156 - * Determine $robots values for a single post.
157 - *
158 - * @param array $robots Robots data array.
159 - * @param int $post_id The post ID for which to determine the $robots values, defaults to current post.
160 - *
161 - * @return array
162 - */
163 - public function robots_for_single_post( $robots, $post_id = 0 ) {
164 - _deprecated_function( __METHOD__, 'Yoast SEO 14.0' );
165 -
166 - $presentation = $this->get_current_page_presentation();
167 -
168 - return $presentation->robots;
169 - }
170 -
171 - /**
172 - * Used for static home and posts pages as well as singular titles.
173 - *
174 - * @param object|null $object If filled, object to get the title for.
175 - *
176 - * @return string The content title.
177 - */
178 - private function get_title( $object = null ) {
179 - _deprecated_function( __METHOD__, 'Yoast SEO 14.0' );
180 -
181 - $presentation = $this->get_current_page_presentation();
182 - $title = $presentation->title;
183 -
184 - return $this->replace_vars->replace( $title, $presentation->source );
185 - }
186 -
187 - /**
188 - * This function adds paging details to the title.
189 - *
190 - * @param string $sep Separator used in the title.
191 - * @param string $seplocation Whether the separator should be left or right.
192 - * @param string $title The title to append the paging info to.
193 - *
194 - * @return string
195 - */
196 - public function add_paging_to_title( $sep, $seplocation, $title ) {
197 - _deprecated_function( __METHOD__, 'Yoast SEO 14.0' );
198 -
199 - return $title;
200 - }
201 -
202 - /**
203 - * Add part to title, while ensuring that the $seplocation variable is respected.
204 - *
205 - * @param string $sep Separator used in the title.
206 - * @param string $seplocation Whether the separator should be left or right.
207 - * @param string $title The title to append the title_part to.
208 - * @param string $title_part The part to append to the title.
209 - *
210 - * @return string
211 - */
212 - public function add_to_title( $sep, $seplocation, $title, $title_part ) {
213 - _deprecated_function( __METHOD__, 'Yoast SEO 14.0' );
214 -
215 - if ( $seplocation === 'right' ) {
216 - return $title . $sep . $title_part;
217 - }
218 -
219 - return $title_part . $sep . $title;
220 - }
221 -
222 - /**
223 - * Adds 'prev' and 'next' links to archives.
224 - *
225 - * @link http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html
226 - *
227 - * @return void
228 - */
229 - public function adjacent_rel_links() {
230 - _deprecated_function( __METHOD__, 'Yoast SEO 14.0' );
231 -
232 - $presentation = $this->get_current_page_presentation();
233 -
234 - $rel_prev_presenter = new Rel_Prev_Presenter();
235 - $rel_prev_presenter->presentation = $presentation;
236 - $rel_prev_presenter->helpers = $this->helpers;
237 - $rel_prev_presenter->replace_vars = $this->replace_vars;
238 - echo $rel_prev_presenter->present();
239 -
240 - $rel_next_presenter = new Rel_Next_Presenter();
241 - $rel_next_presenter->presentation = $presentation;
242 - $rel_next_presenter->helpers = $this->helpers;
243 - $rel_next_presenter->replace_vars = $this->replace_vars;
244 - echo $rel_next_presenter->present();
245 - }
246 -
247 - /**
248 - * Outputs the meta description element or returns the description text.
249 - *
250 - * @param bool $echo Echo or return output flag.
251 - *
252 - * @return string
253 - */
254 - public function metadesc( $echo = true ) {
255 - _deprecated_function( __METHOD__, 'Yoast SEO 14.0' );
256 -
257 - $presentation = $this->get_current_page_presentation();
258 - $presenter = new Meta_Description_Presenter();
259 - $presenter->presentation = $presentation;
260 - $presenter->helpers = $this->helpers;
261 - $presenter->replace_vars = $this->replace_vars;
262 -
263 - if ( ! $echo ) {
264 - return $presenter->get();
265 - }
266 - $presenter->present();
267 - }
268 -
269 - /**
270 - * Returns the current page presentation.
271 - *
272 - * @return Indexable_Presentation The current page presentation.
273 - */
274 - private function get_current_page_presentation() {
275 - $context = $this->context_memoizer->for_current_page();
276 -
277 - /** This filter is documented in src/integrations/front-end-integration.php */
278 - return apply_filters( 'wpseo_frontend_presentation', $context->presentation, $context );
279 - }
280 -}