PluginProbe
Parse.ly / 3.0.0
Parse.ly v3.0.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.0.0, at src/Integrations/class-integrations.php

59 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 collection
4 *
5 * @package Parsely\Integrations
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 init hook.
17 *
18 * @since 2.6.0
19 */
20 class Integrations {
21 /**
22 * Collection of registered integrations.
23 *
24 * @var array
25 */
26 private $integrations = array();
27
28 /**
29 * Register an integration.
30 *
31 * @since 2.6.0
32 *
33 * @param string $key A unique identifier for the integration.
34 * @param string|object $class_or_object Fully-qualified class name, or an instantiated object.
35 * If a class name is passed, it will be instantiated.
36 * @return void
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 * Integrate each integration by calling the method that does the add_action() and add_filter() calls.
48 *
49 * @since 2.6.0
50 *
51 * @return void
52 */
53 public function integrate(): void {
54 foreach ( $this->integrations as $integration ) {
55 $integration->integrate();
56 }
57 }
58 }
59