PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
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/surfaces/meta-surface.php +20 -14 18.228.5 View file →
@@ -133,9 +133,8 @@
133 133 if ( ! $indexable ) {
134 134 return false;
135 135 }
136 136
137 -
138 137 return $this->build_meta( $this->context_memoizer->get( $indexable, 'Home_Page' ) );
139 138 }
140 139
141 140 /**
@@ -145,11 +144,9 @@
145 144 *
146 145 * @return Meta|false The meta values. False if none could be found.
147 146 */
148 147 public function for_post_type_archive( $post_type = null ) {
149 - if ( $post_type === null ) {
150 - $post_type = \get_post_type();
151 - }
148 + $post_type ??= \get_post_type();
152 149
153 150 $indexable = $this->repository->find_for_post_type_archive( $post_type );
154 151
155 152 if ( ! $indexable ) {
@@ -185,9 +182,8 @@
185 182 if ( ! $indexable ) {
186 183 return false;
187 184 }
188 185
189 -
190 186 return $this->build_meta( $this->context_memoizer->get( $indexable, 'Error_Page' ) );
191 187 }
192 188
193 189 /**
@@ -220,13 +216,16 @@
220 216 if ( empty( $indexables ) ) {
221 217 return false;
222 218 }
223 219
220 + // Remove all false values.
221 + $indexables = \array_filter( $indexables );
222 +
224 223 return \array_map(
225 - function( $indexable ) {
224 + function ( $indexable ) {
226 225 return $this->build_meta( $this->context_memoizer->get( $indexable, 'Post_Type' ) );
227 226 },
228 - $indexables
227 + $indexables,
229 228 );
230 229 }
231 230
232 231 /**
@@ -271,11 +270,13 @@
271 270 *
272 271 * @return Meta|false The meta values. False if none could be found.
273 272 */
274 273 public function for_indexable( $indexable, $page_type = null ) {
275 - if ( \is_null( $page_type ) ) {
276 - $page_type = $this->indexable_helper->get_page_type_for_indexable( $indexable );
274 +
275 + if ( ! \is_a( $indexable, Indexable::class ) ) {
276 + return false;
277 277 }
278 + $page_type ??= $this->indexable_helper->get_page_type_for_indexable( $indexable );
278 279
279 280 return $this->build_meta( $this->context_memoizer->get( $indexable, $page_type ) );
280 281 }
281 282
@@ -287,13 +288,11 @@
287 288 *
288 289 * @return Meta|false The meta values. False if none could be found.
289 290 */
290 291 public function for_indexables( $indexables, $page_type = null ) {
291 - $closure = function( $indexable ) use ( $page_type ) {
292 - $this_page_type = $page_type;
293 - if ( \is_null( $this_page_type ) ) {
294 - $this_page_type = $this->indexable_helper->get_page_type_for_indexable( $indexable );
295 - }
292 + $closure = function ( $indexable ) use ( $page_type ) {
293 + $this_page_type = $page_type;
294 + $this_page_type ??= $this->indexable_helper->get_page_type_for_indexable( $indexable );
296 295
297 296 return $this->build_meta( $this->context_memoizer->get( $indexable, $this_page_type ) );
298 297 };
299 298
@@ -309,8 +308,15 @@
309 308 */
310 309 public function for_url( $url ) {
311 310 $url_parts = \wp_parse_url( $url );
312 311 $site_parts = \wp_parse_url( \site_url() );
312 +
313 + if ( ( ! \is_array( $url_parts ) || ! \is_array( $site_parts ) )
314 + || ! isset( $url_parts['host'], $url_parts['path'], $site_parts['host'], $site_parts['scheme'] )
315 + ) {
316 + return false;
317 + }
318 +
313 319 if ( $url_parts['host'] !== $site_parts['host'] ) {
314 320 return false;
315 321 }
316 322 // Ensure the scheme is consistent with values in the DB.