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