PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.6
28.6 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 All 130 releases
wordpress-seo / src / editors / application / seo / term-seo-information-repository.php

term-seo-information-repository.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.6, at src/editors/application/seo/term-seo-information-repository.php

65 lines 1.3 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\Editors\Application\Seo;
5
6 use WP_Term;
7 use Yoast\WP\SEO\Editors\Framework\Seo\Terms\Abstract_Term_Seo_Data_Provider;
8
9 /**
10 * The repository to get term related SEO data.
11 *
12 * @makePublic
13 */
14 class Term_Seo_Information_Repository {
15
16 /**
17 * The term.
18 *
19 * @var WP_Term
20 */
21 private $term;
22
23 /**
24 * The data providers.
25 *
26 * @var Abstract_Term_Seo_Data_Provider
27 */
28 private $seo_data_providers;
29
30 /**
31 * The constructor.
32 *
33 * @param Abstract_Term_Seo_Data_Provider ...$seo_data_providers The providers.
34 */
35 public function __construct( Abstract_Term_Seo_Data_Provider ...$seo_data_providers ) {
36 $this->seo_data_providers = $seo_data_providers;
37 }
38
39 /**
40 * The term.
41 *
42 * @param WP_Term $term The term.
43 *
44 * @return void
45 */
46 public function set_term( WP_Term $term ): void {
47 $this->term = $term;
48 }
49
50 /**
51 * Method to return the compiled SEO data.
52 *
53 * @return array<string> The specific seo data.
54 */
55 public function get_seo_data(): array {
56 $array = [];
57 foreach ( $this->seo_data_providers as $data_provider ) {
58 $data_provider->set_term( $this->term );
59 $array = \array_merge( $array, $data_provider->get_data()->to_legacy_array() );
60 }
61
62 return $array;
63 }
64 }
65