PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.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
wordpress-seo / src / integrations / third-party / woocommerce-post-edit.php

woocommerce-post-edit.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.5, at src/integrations/third-party/woocommerce-post-edit.php

50 lines 1.5 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\Third_Party;
4
5 use WP_Post;
6 use Yoast\WP\SEO\Conditionals\Admin\Post_Conditional;
7 use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
8 use Yoast\WP\SEO\Integrations\Integration_Interface;
9
10 /**
11 * A WooCommerce integration that runs in the post editor.
12 */
13 class WooCommerce_Post_Edit implements Integration_Interface {
14
15 /**
16 * Register the hooks for this integration to work.
17 *
18 * @return void
19 */
20 public function register_hooks() {
21 \add_filter( 'wpseo_post_edit_values', [ $this, 'remove_meta_description_date' ], 10, 2 );
22 }
23
24 /**
25 * Only run this integration when WooCommerce is active and the user is in the post editor.
26 *
27 * @return string[] The conditionals that should be met before this integration is loaded.
28 */
29 public static function get_conditionals() {
30 return [ WooCommerce_Conditional::class, Post_Conditional::class ];
31 }
32
33 /**
34 * Don't show the date in the Google preview for WooCommerce products,
35 * since Google does not show dates for product pages in the search results.
36 *
37 * @param array $values Key-value map of variables we enqueue in the JavaScript of the post editor.
38 * @param WP_Post $post The post currently opened in the editor.
39 *
40 * @return array The values, where the `metaDescriptionDate` is set to the empty string.
41 */
42 public function remove_meta_description_date( $values, $post ) {
43 if ( $post->post_type === 'product' ) {
44 $values['metaDescriptionDate'] = '';
45 }
46
47 return $values;
48 }
49 }
50