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
wordpress-seo / src / dashboard / application / configuration / dashboard-configuration.php

dashboard-configuration.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/dashboard/application/configuration/dashboard-configuration.php

157 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
4 namespace Yoast\WP\SEO\Dashboard\Application\Configuration;
5
6 use Yoast\WP\SEO\Dashboard\Application\Content_Types\Content_Types_Repository;
7 use Yoast\WP\SEO\Dashboard\Application\Endpoints\Endpoints_Repository;
8 use Yoast\WP\SEO\Dashboard\Application\Tracking\Setup_Steps_Tracking;
9 use Yoast\WP\SEO\Dashboard\Infrastructure\Browser_Cache\Browser_Cache_Configuration;
10 use Yoast\WP\SEO\Dashboard\Infrastructure\Integrations\Site_Kit;
11 use Yoast\WP\SEO\Dashboard\Infrastructure\Nonces\Nonce_Repository;
12 use Yoast\WP\SEO\Editors\Application\Analysis_Features\Enabled_Analysis_Features_Repository;
13 use Yoast\WP\SEO\Editors\Framework\Keyphrase_Analysis;
14 use Yoast\WP\SEO\Editors\Framework\Readability_Analysis;
15 use Yoast\WP\SEO\Helpers\Indexable_Helper;
16 use Yoast\WP\SEO\Helpers\User_Helper;
17
18 /**
19 * Responsible for the dashboard configuration.
20 */
21 class Dashboard_Configuration {
22
23 /**
24 * The content types repository.
25 *
26 * @var Content_Types_Repository
27 */
28 private $content_types_repository;
29
30 /**
31 * The indexable helper.
32 *
33 * @var Indexable_Helper
34 */
35 private $indexable_helper;
36
37 /**
38 * The user helper.
39 *
40 * @var User_Helper
41 */
42 private $user_helper;
43
44 /**
45 * The repository.
46 *
47 * @var Enabled_Analysis_Features_Repository
48 */
49 private $enabled_analysis_features_repository;
50
51 /**
52 * The endpoints repository.
53 *
54 * @var Endpoints_Repository
55 */
56 private $endpoints_repository;
57
58 /**
59 * The nonce repository.
60 *
61 * @var Nonce_Repository
62 */
63 private $nonce_repository;
64
65 /**
66 * The Site Kit integration data.
67 *
68 * @var Site_Kit
69 */
70 private $site_kit_integration_data;
71
72 /**
73 * The setup steps tracking data.
74 *
75 * @var Setup_Steps_Tracking
76 */
77 private $setup_steps_tracking;
78
79 /**
80 * The browser cache configuration.
81 *
82 * @var Browser_Cache_Configuration
83 */
84 private $browser_cache_configuration;
85
86 /**
87 * The constructor.
88 *
89 * @param Content_Types_Repository $content_types_repository The content types repository.
90 * @param Indexable_Helper $indexable_helper The indexable helper
91 * repository.
92 * @param User_Helper $user_helper The user helper.
93 * @param Enabled_Analysis_Features_Repository $enabled_analysis_features_repository The analysis feature.
94 * repository.
95 * @param Endpoints_Repository $endpoints_repository The endpoints repository.
96 * @param Nonce_Repository $nonce_repository The nonce repository.
97 * @param Site_Kit $site_kit_integration_data The Site Kit integration data.
98 * @param Setup_Steps_Tracking $setup_steps_tracking The setup steps tracking data.
99 * @param Browser_Cache_Configuration $browser_cache_configuration The browser cache configuration.
100 */
101 public function __construct(
102 Content_Types_Repository $content_types_repository,
103 Indexable_Helper $indexable_helper,
104 User_Helper $user_helper,
105 Enabled_Analysis_Features_Repository $enabled_analysis_features_repository,
106 Endpoints_Repository $endpoints_repository,
107 Nonce_Repository $nonce_repository,
108 Site_Kit $site_kit_integration_data,
109 Setup_Steps_Tracking $setup_steps_tracking,
110 Browser_Cache_Configuration $browser_cache_configuration
111 ) {
112 $this->content_types_repository = $content_types_repository;
113 $this->indexable_helper = $indexable_helper;
114 $this->user_helper = $user_helper;
115 $this->enabled_analysis_features_repository = $enabled_analysis_features_repository;
116 $this->endpoints_repository = $endpoints_repository;
117 $this->nonce_repository = $nonce_repository;
118 $this->site_kit_integration_data = $site_kit_integration_data;
119 $this->setup_steps_tracking = $setup_steps_tracking;
120 $this->browser_cache_configuration = $browser_cache_configuration;
121 }
122
123 /**
124 * Returns a configuration
125 *
126 * @return array<string, array<string>|array<string, string|array<string, array<string, int>>>>
127 */
128 public function get_configuration(): array {
129 $configuration = [
130 'contentTypes' => $this->content_types_repository->get_content_types(),
131 'indexablesEnabled' => $this->indexable_helper->should_index_indexables(),
132 'displayName' => $this->user_helper->get_current_user_display_name(),
133 'enabledAnalysisFeatures' => $this->enabled_analysis_features_repository->get_features_by_keys(
134 [
135 Readability_Analysis::NAME,
136 Keyphrase_Analysis::NAME,
137 ],
138 )->to_array(),
139 'endpoints' => $this->endpoints_repository->get_all_endpoints()->to_array(),
140 'nonce' => $this->nonce_repository->get_rest_nonce(),
141 'setupStepsTracking' => $this->setup_steps_tracking->to_array(),
142 ];
143
144 $site_kit_integration_data = $this->site_kit_integration_data->to_array();
145 if ( ! empty( $site_kit_integration_data ) ) {
146 $configuration['siteKitConfiguration'] = $site_kit_integration_data;
147 }
148
149 $browser_cache_configuration = $this->browser_cache_configuration->get_configuration();
150 if ( ! empty( $browser_cache_configuration ) ) {
151 $configuration['browserCache'] = $browser_cache_configuration;
152 }
153
154 return $configuration;
155 }
156 }
157