PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 4.7.4
Responsive Menu – Create Mobile-Friendly Menu v4.7.4
4.7.4 4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 All 91 releases
responsive-menu / v4.0.0 / inc / classes / elementor / class-elementor-manager.php

class-elementor-manager.php in Responsive Menu – Create Mobile-Friendly Menu 4.7.4, at v4.0.0/inc/classes/elementor/class-elementor-manager.php

218 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor Manager class will handle the elementor related features of responsive menu.
4 *
5 * @category Class
6 * @package ElementorAwesomesauce
7 * @author Expresstech System
8 * @since 4.0.2
9 */
10
11 namespace RMP\Features\Inc\Elementor;
12
13 use RMP\Features\Inc\Traits\Singleton;
14 use RMP\Features\Inc\Elementor\Widgets\RMP_Widget;
15
16 // Security Note: Blocks direct access to the plugin PHP files.
17 defined( 'ABSPATH' ) || die();
18
19 /**
20 * Class Elementor_Manager
21 *
22 * @since 4.0.2
23 */
24 class Elementor_Manager {
25
26 use Singleton;
27
28 /**
29 * Minimum Elementor Version
30 *
31 * @since 4.0.2
32 * @var string Minimum Elementor version required to run the plugin.
33 */
34 const MINIMUM_ELEMENTOR_VERSION = '2.0.0';
35
36 /**
37 * Minimum PHP Version
38 *
39 * @since 4.0.2
40 * @var string Minimum PHP version required to run the plugin.
41 */
42 const MINIMUM_PHP_VERSION = '7.0';
43
44 /**
45 * Construct method.
46 */
47 protected function __construct() {
48 $this->setup_hooks();
49 }
50
51 /**
52 * To setup action/filter.
53 *
54 * @return void
55 */
56 protected function setup_hooks() {
57 add_action( 'plugins_loaded', array( $this, 'elementor_init' ) );
58 add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'elementor_enqueue_scripts' ) );
59 }
60
61 /**
62 * To enqueue scripts and styles in elementor admin.
63 *
64 * @param string $hook_suffix Admin page name.
65 *
66 * @return void
67 */
68 public function elementor_enqueue_scripts( $hook_suffix ) {
69 wp_enqueue_script(
70 'rmp_elementor_scripts',
71 RMP_PLUGIN_URL_V4 . '/assets/admin/js/rmp-elementor.js',
72 array( 'jquery' ),
73 RMP_PLUGIN_VERSION,
74 true
75 );
76 }
77
78 /**
79 * Initialize the plugin
80 *
81 * Validates that Elementor is already loaded.
82 * Checks for basic plugin requirements, if one check fail don't continue,
83 * if all check have passed include the plugin class.
84 *
85 * Fired by `plugins_loaded` action hook.
86 *
87 * @since 4.0.2
88 * @access public
89 */
90 public function elementor_init() {
91
92 // Check if Elementor installed and activated.
93 if ( ! did_action( 'elementor/loaded' ) ) {
94 add_action( 'admin_notices', array( $this, 'admin_notice_missing_main_plugin' ) );
95 return;
96 }
97
98 // Check for required Elementor version.
99 if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
100 add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) );
101 return;
102 }
103
104 // Check for required PHP version.
105 if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
106 add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) );
107 return;
108 }
109
110 add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) );
111 }
112
113 /**
114 * Admin notice
115 *
116 * Warning when the site doesn't have Elementor installed or activated.
117 *
118 * @since 4.0.2
119 * @access public
120 */
121 public function admin_notice_missing_main_plugin() {
122 return sprintf(
123 wp_kses(
124 '<div class="notice notice-warning is-dismissible"><p><strong>"%1$s"</strong> requires <strong>"%2$s"</strong> to be installed and activated.</p></div>',
125 array(
126 'div' => array(
127 'class' => array(),
128 'p' => array(),
129 'strong' => array(),
130 ),
131 )
132 ),
133 'Responsive menu elementor widget',
134 'Elementor'
135 );
136 }
137
138 /**
139 * Admin notice
140 *
141 * Warning when the site doesn't have a minimum required Elementor version.
142 *
143 * @since 4.0.2
144 * @access public
145 */
146 public function admin_notice_minimum_elementor_version() {
147 return sprintf(
148 wp_kses(
149 '<div class="notice notice-warning is-dismissible"><p><strong>"%1$s"</strong> requires <strong>"%2$s"</strong> version %3$s or greater.</p></div>',
150 array(
151 'div' => array(
152 'class' => array(),
153 'p' => array(),
154 'strong' => array(),
155 ),
156 )
157 ),
158 'Responsive menu elementor widget',
159 'Elementor',
160 self::MINIMUM_ELEMENTOR_VERSION
161 );
162 }
163
164 /**
165 * Admin notice
166 *
167 * Warning when the site doesn't have a minimum required PHP version.
168 *
169 * @since 4.0.2
170 * @access public
171 */
172 public function admin_notice_minimum_php_version() {
173 return sprintf(
174 wp_kses(
175 '<div class="notice notice-warning is-dismissible"><p><strong>"%1$s"</strong> requires <strong>"%2$s"</strong> version %3$s or greater.</p></div>',
176 array(
177 'div' => array(
178 'class' => array(),
179 'p' => array(),
180 'strong' => array(),
181 ),
182 )
183 ),
184 'Responsive menu elementor widget',
185 'Elementor',
186 self::MINIMUM_ELEMENTOR_VERSION
187 );
188 }
189
190 /**
191 * Include Widgets files
192 *
193 * Load widgets files
194 *
195 * @since 4.0.2
196 * @access private
197 */
198 private function include_widgets_files() {
199 require_once 'widgets/class-rmp-widget.php';
200 }
201
202 /**
203 * Register Widgets
204 *
205 * Register new Elementor widgets.
206 *
207 * @since 4.0.2
208 * @access public
209 */
210 public function register_widgets() {
211
212 // It's now safe to include Widgets files.
213 $this->include_widgets_files();
214
215 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new RMP_Widget() );
216 }
217 }
218