PluginProbe
WDesignKit – AI Templates, Widget Builder & MCP Workflow / 2.7.1
WDesignKit – AI Templates, Widget Builder & MCP Workflow v2.7.1
2.7.1 2.7.0 2.6.6 2.6.5 2.6.4 2.6.3 2.6.2 2.6.1 2.6.0 2.5.5 2.5.4 2.5.3 2.5.2 2.5.1 2.5.0 2.4.0 2.3.3 2.3.2 2.3.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 All 130 releases
wdesignkit / includes / widget-load / elementor / class-wdkit-elementor-files-load.php

class-wdkit-elementor-files-load.php in WDesignKit – AI Templates, Widget Builder & MCP Workflow 2.7.1, at includes/widget-load/elementor/class-wdkit-elementor-files-load.php

135 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Exit if accessed directly.
4 *
5 * @link https://posimyth.com/
6 * @since 1.0.0
7 *
8 * @package Wdesignkit
9 * @subpackage Wdesignkit/includes/elementor
10 * */
11
12 /**
13 * Exit if accessed directly.
14 * */
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 if ( ! class_exists( 'Wdkit_Elementor_Files_Load' ) ) {
20
21 /**
22 * This class used for only elementor widget load
23 *
24 * @since 1.0.0
25 */
26 class Wdkit_Elementor_Files_Load {
27 /**
28 * Instance
29 *
30 * @since 1.0.0
31 * @access private
32 * @static
33 * @var \Elementor_Test_Addon\Plugin The single instance of the class.
34 */
35 private static $instance = null;
36
37 /**
38 * Instance
39 *
40 * Ensures only one instance of the class is loaded or can be loaded.
41 *
42 * @since 1.0.0
43 * @static
44 * @return \Elementor_Test_Addon\Plugin An instance of the class.
45 */
46 public static function instance() {
47 if ( is_null( self::$instance ) ) {
48 self::$instance = new self();
49 }
50
51 return self::$instance;
52 }
53
54 /**
55 * Constructor
56 *
57 * Perform some compatibility checks to make sure basic requirements are meet.
58 * If all compatibility checks pass, initialize the functionality.
59 *
60 * @since 1.0.0
61 */
62 public function __construct() {
63 add_action( 'elementor/init', array( $this, 'wdkit_init' ) );
64 }
65
66 /**
67 * Initialize
68 *
69 * Load the addons functionality only after Elementor is initialized.
70 *
71 * Fired by `elementor/init` action hook.
72 *
73 * @since 1.0.0
74 */
75 public function wdkit_init() {
76 require_once WDKIT_INCLUDES . 'widget-load/elementor/wb-controller.php';
77
78 $this->wdkit_register_categories();
79 add_action( 'elementor/widgets/register', array( $this, 'wdkit_register_widgets' ) );
80 }
81
82 /**
83 *
84 * Add elementor widgets list
85 *
86 * @since 1.0.0
87 *
88 * @param string $widgets_manager elementor widget structure.
89 */
90 public function wdkit_register_widgets( $widgets_manager ) {
91 if ( ! defined( 'WDKIT_BUILDER_PATH' ) || ! function_exists( 'wdesignkit_get_widget_registry' ) ) {
92 return false;
93 }
94
95 foreach ( wdesignkit_get_widget_registry( 'elementor' ) as $entry ) {
96 if ( ! file_exists( $entry['file'] ) ) {
97 continue;
98 }
99
100 require_once $entry['file'];
101
102 if ( class_exists( $entry['class'] ) ) {
103 $widgets_manager->register( new $entry['class']() );
104 }
105 }
106 }
107
108 /**
109 *
110 * Add elementor categories list
111 *
112 * @since 1.0.0
113 */
114 public function wdkit_register_categories() {
115 $elementor = \Elementor\Plugin::$instance;
116
117 $category_list = get_option( 'wkit_builder' );
118
119 if ( ! empty( $category_list ) ) {
120 foreach ( $category_list as $value ) {
121 $elementor->elements_manager->add_category(
122 $value,
123 array(
124 'title' => esc_html( $value ),
125 'icon' => 'fa fa-plug',
126 )
127 );
128 }
129 }
130 }
131 }
132
133 Wdkit_Elementor_Files_Load::instance();
134 }
135