PluginProbe
User Frontend – Membership, User Registration, User Profile, User Directory & Content Restriction with Frontend Post Submission / trunk
User Frontend – Membership, User Registration, User Profile, User Directory & Content Restriction with Frontend Post Submission vtrunk
4.3.11 4.3.10 4.3.9 4.3.8 4.3.7 4.3.6 4.3.3 4.3.4 4.3.5 4.3.2 trunk 1.1 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.5 2.5.1 2.5.2 2.5.3 2.5.5 2.5.6 2.5.7 2.5.8 All 152 releases
wp-user-frontend / includes / Integrations.php

Integrations.php in User Frontend – Membership, User Registration, User Profile, User Directory & Content Restriction with Frontend Post Submission trunk, at includes/Integrations.php

85 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WeDevs\Wpuf;
4
5 /**
6 * The integration class to handle all integrations with our plugin
7 *
8 * @since 4.0.12
9 */
10 class Integrations {
11 /**
12 * Holds various class instances
13 *
14 * @since 4.0.12
15 *
16 * @var array
17 */
18 public $container = [];
19
20 private $integrations = [
21 'WeDevs_Dokan' => 'WPUF_Dokan_Integration',
22 'WC_Vendors' => 'WPUF_WC_Vendors_Integration',
23 'WCMp' => 'WPUF_WCMp_Integration',
24 'ACF' => 'WPUF_ACF_Compatibility',
25 'Tribe__Events__Main' => 'Events_Calendar\Events_Calendar_Integration',
26 'N8N' => 'WPUF_N8N_Integration',
27 ];
28
29 public function __construct() {
30 foreach ( $this->integrations as $external_class => $integration_class ) {
31 // Special case for N8N - always load since it's a service integration
32 if ( $external_class === 'N8N' ) {
33 $full_class_name = __NAMESPACE__ . '\\Integrations\\' . $integration_class;
34 try {
35 $this->container[ strtolower( $external_class ) ] = new $full_class_name();
36 } catch ( \Exception $e ) {
37 \WP_User_Frontend::log( 'integration', print_r( $external_class . ' integration failed', true ) );
38 }
39 } elseif ( class_exists( $external_class ) ) {
40 $full_class_name = __NAMESPACE__ . '\\Integrations\\' . $integration_class;
41 try {
42 $this->container[ strtolower( $external_class ) ] = new $full_class_name();
43 } catch ( \Exception $e ) {
44 \WP_User_Frontend::log( 'integration', print_r( $external_class . ' integration failed', true ) );
45 }
46 }
47 }
48
49 add_action( 'elementor/init', [ $this, 'init_elementor' ] );
50 }
51
52 /**
53 * Initialize Elementor integration
54 *
55 * @since 4.3.1
56 *
57 * @return void
58 */
59 public function init_elementor() {
60 try {
61 require_once __DIR__ . '/Integrations/Elementor/Elementor.php';
62 $this->container['elementor'] = new Integrations\Elementor\Elementor();
63 } catch ( \Exception $e ) {
64 \WP_User_Frontend::log( 'integration', 'Elementor integration failed: ' . $e->getMessage() );
65 }
66 }
67
68 /**
69 * Magic getter to bypass referencing objects
70 *
71 * @since 4.0.12
72 *
73 * @param string $prop
74 *
75 * @return null|object Class Instance
76 */
77 public function __get( $prop ) {
78 if ( array_key_exists( $prop, $this->container ) ) {
79 return $this->container[ $prop ];
80 }
81
82 return null;
83 }
84 }
85