PluginProbe
Parse.ly / 3.5.0
Parse.ly v3.5.0
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
wp-parsely / src / Integrations / class-integrations.php

class-integrations.php in Parse.ly 3.5.0, at src/Integrations/class-integrations.php

58 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 * Integrations: Integrations collection class
4 *
5 * @package Parsely
6 * @since 2.6.0
7 */
8
9 declare(strict_types=1);
10
11 namespace Parsely\Integrations;
12
13 /**
14 * Integrations are registered to this collection.
15 *
16 * The `integrate()` method is called on each registered integration, on the
17 * init hook.
18 *
19 * @since 2.6.0
20 */
21 class Integrations {
22 /**
23 * Collection of registered integrations.
24 *
25 * @var array
26 */
27 private $integrations = array();
28
29 /**
30 * Registers an integration.
31 *
32 * @since 2.6.0
33 *
34 * @param string $key A unique identifier for the integration.
35 * @param string|object $class_or_object Fully-qualified class name, or an instantiated object.
36 * If a class name is passed, it will be instantiated.
37 */
38 public function register( string $key, $class_or_object ): void {
39 // If a Foo::class or other fully qualified class name is passed, instantiate it.
40 if ( ! is_object( $class_or_object ) ) {
41 $class_or_object = new $class_or_object();
42 }
43 $this->integrations[ $key ] = $class_or_object;
44 }
45
46 /**
47 * Integrates each integration by calling the method that does the
48 * add_action() and add_filter() calls.
49 *
50 * @since 2.6.0
51 */
52 public function integrate(): void {
53 foreach ( $this->integrations as $integration ) {
54 $integration->integrate();
55 }
56 }
57 }
58