PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.8.23.4
Pods – Custom Content Types and Fields v2.8.23.4
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / src / Pods / Integrations / Service_Provider.php
pods / src / Pods / Integrations Last commit date
Enfold.php 2 weeks ago Genesis.php 2 weeks ago Jetpack.php 2 weeks ago Polylang.php 2 weeks ago Service_Provider.php 2 weeks ago WPML.php 2 weeks ago YARPP.php 2 weeks ago
Service_Provider.php
89 lines
1 <?php
2
3 namespace Pods\Integrations;
4
5 use Pods\Integration;
6 use tad_DI52_ServiceProvider;
7
8 /**
9 * Class Service_Provider
10 *
11 * Add third party integrations where needed.
12 * @todo Make all integrations inherit the Integration abstract class and use loops.
13 *
14 * @since 2.8.0
15 */
16 class Service_Provider extends tad_DI52_ServiceProvider {
17
18 protected $integrations = [];
19
20 /**
21 * Registers the classes and functionality needed for third party integrations.
22 *
23 * @since 2.8.0
24 */
25 public function register() {
26
27 $this->integrations = [
28 'polylang' => Polylang::class,
29 'wpml' => WPML::class,
30 'enfold' => Enfold::class,
31 ];
32
33 foreach ( $this->integrations as $integration ) {
34 $this->container->singleton( $integration, $integration );
35 }
36
37 $this->container->singleton( 'pods.integration.genesis', Genesis::class );
38 $this->container->singleton( 'pods.integration.yarpp', YARPP::class );
39 $this->container->singleton( 'pods.integration.jetpack', Jetpack::class );
40
41 $this->hooks();
42 }
43
44 /**
45 * Hooks all the methods and actions the class needs.
46 *
47 * @since 2.8.0
48 */
49 protected function hooks() {
50
51 add_filter( 'pods_admin_config_pod_fields_post_type_supported_features', $this->container->callback( 'pods.integration.genesis', 'add_post_type_supports' ) );
52 add_filter( 'pods_admin_config_pod_fields_post_type_supported_features', $this->container->callback( 'pods.integration.yarpp', 'add_post_type_supports' ) );
53 add_filter( 'pods_admin_config_pod_fields_post_type_supported_features', $this->container->callback( 'pods.integration.jetpack', 'add_post_type_supports' ) );
54
55 if ( ! did_action( 'plugins_loaded' ) ) {
56 add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
57 } else {
58 $this->plugins_loaded();
59 }
60 }
61
62 /**
63 * All plugins are loaded.
64 *
65 * @since 2.8.0
66 */
67 public function plugins_loaded() {
68
69 /**
70 * Filter what integration classes should run on the plugins_loaded hook.
71 *
72 * @since 2.8.0
73 *
74 * @param \Pods\Integration[] $integrations The list of integrations to run on plugins_loaded hook.
75 */
76 $integrations = apply_filters( 'pods_integrations_on_plugins_loaded', $this->integrations );
77 foreach ( $integrations as $class ) {
78 if ( is_string( $class ) ) {
79 $class = $this->container->make( $class );
80 }
81 if ( $class instanceof Integration ) {
82 if ( $class->is_active() ) {
83 $class->hook();
84 }
85 }
86 }
87 }
88 }
89