PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.8
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.8
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 / admin / formatter / class-post-metabox-formatter.php

class-post-metabox-formatter.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.8, at admin/formatter/class-post-metabox-formatter.php

96 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Admin\Formatter
6 */
7
8 use Yoast\WP\SEO\Editors\Application\Seo\Post_Seo_Information_Repository;
9
10 /**
11 * This class provides data for the post metabox by return its values for localization.
12 */
13 class WPSEO_Post_Metabox_Formatter implements WPSEO_Metabox_Formatter_Interface {
14
15 /**
16 * Holds the WordPress Post.
17 *
18 * @var WP_Post
19 */
20 private $post;
21
22 /**
23 * The permalink to follow.
24 *
25 * @var string
26 */
27 private $permalink;
28
29 /**
30 * Constructor.
31 *
32 * @param WP_Post|array $post Post object.
33 * @param array $options Title options to use.
34 * @param string $structure The permalink to follow.
35 */
36 public function __construct( $post, array $options, $structure ) {
37 $this->post = $post;
38 $this->permalink = $structure;
39 }
40
41 /**
42 * Determines whether the social templates should be used.
43 *
44 * @deprecated 23.1
45 * @codeCoverageIgnore
46 *
47 * @return void
48 */
49 public function use_social_templates() {
50 _deprecated_function( __METHOD__, 'Yoast SEO 23.1' );
51 }
52
53 /**
54 * Returns the translated values.
55 *
56 * @return array
57 */
58 public function get_values() {
59
60 $values = [
61 'metaDescriptionDate' => '',
62 ];
63
64 if ( $this->post instanceof WP_Post ) {
65
66 /** @var Post_Seo_Information_Repository $repo */
67 $repo = YoastSEO()->classes->get( Post_Seo_Information_Repository::class );
68 $repo->set_post( $this->post );
69
70 $values_to_set = [
71 'isInsightsEnabled' => $this->is_insights_enabled(),
72 ];
73
74 $values = ( $values_to_set + $values );
75 $values = ( $repo->get_seo_data() + $values );
76 }
77
78 /**
79 * Filter: 'wpseo_post_edit_values' - Allows changing the values Yoast SEO uses inside the post editor.
80 *
81 * @param array $values The key-value map Yoast SEO uses inside the post editor.
82 * @param WP_Post $post The post opened in the editor.
83 */
84 return apply_filters( 'wpseo_post_edit_values', $values, $this->post );
85 }
86
87 /**
88 * Determines whether the insights feature is enabled for this post.
89 *
90 * @return bool
91 */
92 protected function is_insights_enabled() {
93 return WPSEO_Options::get( 'enable_metabox_insights', false );
94 }
95 }
96