PluginProbe
Borderless – Addons and Templates for Elementor / trunk
Borderless – Addons and Templates for Elementor vtrunk
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 78 releases
borderless / modules / elementor / elementor.php

elementor.php in Borderless – Addons and Templates for Elementor trunk, at modules/elementor/elementor.php

250 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // don't load directly
4 defined( 'ABSPATH' ) || exit;
5
6 final class Borderless_Elementor {
7
8 /**
9 * Plugin Version
10 */
11 const VERSION = '1.0.0';
12
13 /**
14 * Minimum Elementor Version
15 */
16 const MINIMUM_ELEMENTOR_VERSION = '2.0.0';
17
18 /**
19 * Minimum PHP Version
20 */
21 const MINIMUM_PHP_VERSION = '7.0';
22
23 /**
24 * Instance
25 *
26 * @var Borderless_Elementor The single instance of the class.
27 */
28 private static $_instance = null;
29
30 /**
31 * Instance
32 *
33 * Ensures only one instance of the class is loaded or can be loaded.
34 *
35 * @return Borderless_Elementor An instance of the class.
36 */
37 public static function instance() {
38
39 if ( is_null( self::$_instance ) ) {
40 self::$_instance = new self();
41 }
42 return self::$_instance;
43
44 }
45
46 /**
47 * Constructor
48 */
49 public function __construct() {
50
51 add_action( 'plugins_loaded', [ $this, 'on_plugins_loaded' ] );
52
53 require_once('assets.php');
54 borderless_elementor_assets()->init();
55
56 }
57
58 /**
59 * Load Textdomain
60 *
61 * Load plugin localization files.
62 *
63 * Fired by `init` action hook.
64 */
65 public function i18n() {
66
67 load_plugin_textdomain( 'borderless' );
68
69 }
70
71 /**
72 * On Plugins Loaded
73 *
74 * Checks if Elementor has loaded, and performs some compatibility checks.
75 * If All checks pass, inits the plugin.
76 *
77 * Fired by `plugins_loaded` action hook.
78 */
79 public function on_plugins_loaded() {
80
81 if ( $this->is_compatible() ) {
82 add_action( 'elementor/init', [ $this, 'init' ] );
83 }
84
85 }
86
87 /**
88 * Compatibility Checks
89 *
90 * Checks if the installed version of Elementor meets the plugin's minimum requirement.
91 * Checks if the installed PHP version meets the plugin's minimum requirement.
92 */
93 public function is_compatible() {
94
95 // Check if Elementor installed and activated
96 if ( ! did_action( 'elementor/loaded' ) ) {
97 //add_action( 'admin_notices', [ $this, 'admin_notice_missing_main_plugin' ] );
98 return false;
99 }
100
101 // Check for required Elementor version
102 if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
103 add_action( 'admin_notices', [ $this, 'admin_notice_minimum_elementor_version' ] );
104 return false;
105 }
106
107 // Check for required PHP version
108 if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
109 add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] );
110 return false;
111 }
112
113 return true;
114
115 }
116
117 /**
118 * Initialize the plugin
119 *
120 * Load the plugin only after Elementor (and other plugins) are loaded.
121 * Load the files required to run the plugin.
122 *
123 * Fired by `plugins_loaded` action hook.
124 */
125 public function init() {
126
127 $this->i18n();
128
129 // Add Plugin actions
130 add_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] );
131 add_action( 'elementor/elements/categories_registered', [ $this, 'register_borderless_elementor_category' ] );
132
133 }
134
135 /**
136 * Init Widgets
137 */
138 public function init_widgets() {
139
140 // Include Widget files
141 require_once('helper.php');
142 require_once('widgets/animated-text.php');
143 require_once('widgets/circular-progress-bar.php');
144 require_once('widgets/contact-form-7.php');
145 require_once('widgets/hero.php');
146 require_once('widgets/info-box.php');
147 require_once('widgets/marquee-text.php');
148 require_once('widgets/portfolio.php');
149 require_once('widgets/pricing-table.php');
150 require_once('widgets/progress-bar.php');
151 require_once('widgets/semi-circular-progress-bar.php');
152 require_once('widgets/slider.php');
153 require_once('widgets/split-hero.php');
154 require_once('widgets/team-member.php');
155 require_once('widgets/testimonial.php');
156
157 // Register widget
158 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Animated_Text() );
159 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Circular_Progress_Bar() );
160 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Contact_Form_7() );
161 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Hero() );
162 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Info_Box() );
163 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Marquee_text() );
164 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Portfolio() );
165 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Pricing_Table() );
166 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Progress_Bar() );
167 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Semi_Circular_Progress_Bar() );
168 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Slider() );
169 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Split_Hero() );
170 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Team_Member() );
171 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Testimonial() );
172
173 }
174
175 public function register_borderless_elementor_category( $elements_manager ) {
176 $elements_manager->add_category(
177 'borderless',
178 [
179 'title' => __( 'Borderless', 'borderless' ),
180 'icon' => 'borderless-icon-borderless',
181 ]
182 );
183 }
184
185 /**
186 * Admin notice
187 *
188 * Warning when the site doesn't have Elementor installed or activated.
189 */
190 public function admin_notice_missing_main_plugin() {
191
192 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
193
194 $message = sprintf(
195 /* translators: 1: Plugin name 2: Elementor */
196 esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'borderless' ),
197 '<strong>' . esc_html__( 'Borderless', 'borderless' ) . '</strong>',
198 '<strong>' . esc_html__( 'Elementor', 'borderless' ) . '</strong>'
199 );
200
201 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
202
203 }
204
205 /**
206 * Admin notice
207 *
208 * Warning when the site doesn't have a minimum required Elementor version.
209 */
210 public function admin_notice_minimum_elementor_version() {
211
212 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
213
214 $message = sprintf(
215 /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */
216 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'borderless' ),
217 '<strong>' . esc_html__( 'Elementor Test Extension', 'borderless' ) . '</strong>',
218 '<strong>' . esc_html__( 'Elementor', 'borderless' ) . '</strong>',
219 self::MINIMUM_ELEMENTOR_VERSION
220 );
221
222 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
223
224 }
225
226 /**
227 * Admin notice
228 *
229 * Warning when the site doesn't have a minimum required PHP version.
230 */
231 public function admin_notice_minimum_php_version() {
232
233 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
234
235 $message = sprintf(
236 /* translators: 1: Plugin name 2: PHP 3: Required PHP version */
237 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'borderless' ),
238 '<strong>' . esc_html__( 'Elementor Test Extension', 'borderless' ) . '</strong>',
239 '<strong>' . esc_html__( 'PHP', 'borderless' ) . '</strong>',
240 self::MINIMUM_PHP_VERSION
241 );
242
243 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
244
245 }
246
247 }
248
249 Borderless_Elementor::instance();
250