PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.2
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 / class-collector.php

class-collector.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.2, at admin/class-collector.php

53 lines 984 B
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
6 */
7
8 /**
9 * Collects the data from the added collection objects.
10 */
11 class WPSEO_Collector {
12
13 /**
14 * Holds the collections.
15 *
16 * @var WPSEO_Collection[]
17 */
18 protected $collections = [];
19
20 /**
21 * Adds a collection object to the collections.
22 *
23 * @param WPSEO_Collection $collection The collection object to add.
24 */
25 public function add_collection( WPSEO_Collection $collection ) {
26 $this->collections[] = $collection;
27 }
28
29 /**
30 * Collects the data from the collection objects.
31 *
32 * @return array The collected data.
33 */
34 public function collect() {
35 $data = [];
36
37 foreach ( $this->collections as $collection ) {
38 $data = array_merge( $data, $collection->get() );
39 }
40
41 return $data;
42 }
43
44 /**
45 * Returns the collected data as a JSON encoded string.
46 *
47 * @return false|string The encode string.
48 */
49 public function get_as_json() {
50 return WPSEO_Utils::format_json_encode( $this->collect() );
51 }
52 }
53