PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.1.4.3
Pods – Custom Content Types and Fields v3.1.4.3
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
WPGraphQL 1 day ago Enfold.php 1 day ago Genesis.php 1 day ago Jetpack.php 1 day ago Polylang.php 1 day ago Service_Provider.php 1 day ago WPML.php 1 day ago YARPP.php 1 day ago
Service_Provider.php
88 lines
1 <?php
2
3 namespace Pods\Integrations;
4
5 use Pods\Integration;
6
7 /**
8 * Class Service_Provider
9 *
10 * Add third party integrations where needed.
11 * @todo Make all integrations inherit the Integration abstract class and use loops.
12 *
13 * @since 2.8.0
14 */
15 class Service_Provider extends \Pods\Service_Provider_Base {
16
17 protected $integrations = [];
18
19 /**
20 * Registers the classes and functionality needed for third party integrations.
21 *
22 * @since 2.8.0
23 */
24 public function register() {
25
26 $this->integrations = [
27 'polylang' => Polylang::class,
28 'wpml' => WPML::class,
29 'enfold' => Enfold::class,
30 ];
31
32 foreach ( $this->integrations as $integration ) {
33 $this->container->singleton( $integration, $integration );
34 }
35
36 $this->container->singleton( 'pods.integration.genesis', Genesis::class );
37 $this->container->singleton( 'pods.integration.yarpp', YARPP::class );
38 $this->container->singleton( 'pods.integration.jetpack', Jetpack::class );
39
40 $this->hooks();
41 }
42
43 /**
44 * Hooks all the methods and actions the class needs.
45 *
46 * @since 2.8.0
47 */
48 protected function hooks() {
49
50 add_filter( 'pods_admin_config_pod_fields_post_type_supported_features', $this->container->callback( 'pods.integration.genesis', 'add_post_type_supports' ) );
51 add_filter( 'pods_admin_config_pod_fields_post_type_supported_features', $this->container->callback( 'pods.integration.yarpp', 'add_post_type_supports' ) );
52 add_filter( 'pods_admin_config_pod_fields_post_type_supported_features', $this->container->callback( 'pods.integration.jetpack', 'add_post_type_supports' ) );
53
54 if ( ! did_action( 'plugins_loaded' ) ) {
55 add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
56 } else {
57 $this->plugins_loaded();
58 }
59 }
60
61 /**
62 * All plugins are loaded.
63 *
64 * @since 2.8.0
65 */
66 public function plugins_loaded() {
67
68 /**
69 * Filter what integration classes should run on the plugins_loaded hook.
70 *
71 * @since 2.8.0
72 *
73 * @param \Pods\Integration[] $integrations The list of integrations to run on plugins_loaded hook.
74 */
75 $integrations = apply_filters( 'pods_integrations_on_plugins_loaded', $this->integrations );
76 foreach ( $integrations as $class ) {
77 if ( is_string( $class ) ) {
78 $class = $this->container->make( $class );
79 }
80 if ( $class instanceof Integration ) {
81 if ( $class->is_active() ) {
82 $class->hook();
83 }
84 }
85 }
86 }
87 }
88