PluginProbe
Ultra Addons Lite for Elementor / trunk
Ultra Addons Lite 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.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3
ut-elementor-addons-lite / ut-elementor-addons-lite.php

ut-elementor-addons-lite.php in Ultra Addons Lite for Elementor trunk, at ut-elementor-addons-lite.php

414 lines 17.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Ultra Addons Lite for Elementor
4 * Plugin URI: https://ultrapress.org/
5 * Description: Ultra Addons Lite for Elementor offers a variety of add-ons to enhance your page-building experience. Elevate your Elementor pages with creative elements and extensions, adding power and flexibility to your page builder. Our user-friendly elements are designed to simplify your next WordPress website build. Each element comes with a multitude of options, allowing you to control every aspect of your design. With your imagination, you can achieve virtually any design.
6 * Version: 1.3.3
7 * Requires at least: 6.0
8 * Author: UltraPress
9 * Author URI: https://ultrapress.org/
10 * License: GPL-2.0-or-later
11 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
12 * Domain Path: /languages
13 * Text Domain: ut-elementor-addons-lite
14 */
15
16 defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
17
18 // Check if the class UT_Elementor_Addons_Lite doesn't exist.
19 if ( ! class_exists( 'UT_Elementor_Addons_Lite' ) )
20 {
21
22 class UT_Elementor_Addons_Lite // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
23 {
24
25 /**
26 * Constructor function for initializing the plugin.
27 * - Defines constants.
28 * - Includes necessary files.
29 * - Hooks into various actions for plugin functionality.
30 */
31 function __construct()
32 {
33 $this->define_constants();
34 $this->ut_elementor_addons_lite_includes();
35 add_action( 'plugins_loaded', [ $this, 'ut_init_plugin'] );
36 add_action( 'elementor/init', [ $this, 'ut_elementor_addons_lite_widget_categories'] );
37 add_action( 'elementor/frontend/after_register_scripts', [ $this,'register_frontend_assets' ] );
38 add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'register_frontend_style' ] );
39 add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'ut_elementor_admin' ] );
40 add_action( 'elementor/widgets/widgets_registered', [ $this,'ut_elementor_addons_lite_register' ] );
41 add_action( 'admin_menu', array( $this, 'ut_add_admin_menu' ) );
42 add_action( 'init', array( $this, 'ut_custom_post_type_for_templates' ) );
43 add_action( 'admin_enqueue_scripts', array( $this, 'ut_enqueue_scripts' ) );
44 $this->ut_hf_setup();
45 add_action( 'wp_footer', [ $this, 'ut_apply_sticky_settings' ] );
46 }
47
48
49 /**
50 * Load custom post type and icon-related functions for Ultra Addons Lite
51 */
52 public function ut_custom_post_type_for_templates() {
53 require_once UTAL_PATH . 'includes/cpt.php';
54 require_once UTAL_PATH . 'includes/icon-functions.php';
55 }
56
57
58 /**
59 * Create Menu page
60 */
61 public function ut_add_admin_menu() {
62 if (class_exists('UTAP')) {
63 return;
64 }
65 $menu_slug = 'ultra-addons-lite-admin';
66 add_menu_page(
67 esc_html__( 'Ultra Addons Lite', 'ut-elementor-addons-lite' ),
68 esc_html__( 'Ultra Addons Lite', 'ut-elementor-addons-lite' ),
69 'manage_options',
70 $menu_slug,
71 array( $this, 'ut_admin_page' ),
72 'dashicons-editor-underline',
73 16
74 );
75
76 if ( class_exists( 'Elementor\Plugin' ) ) {
77 add_submenu_page(
78 $menu_slug,
79 esc_html__( 'Header Footer', 'ut-elementor-addons-lite' ),
80 esc_html__( 'Header Footer', 'ut-elementor-addons-lite' ),
81 'edit_pages',
82 'edit.php?post_type=ut_hf_builder'
83 );
84 }
85 }
86
87
88 /**
89 * Display the Ultra Addons Lite admin page in the WordPress dashboard
90 */
91 public function ut_admin_page() {
92 // Handle form submission
93 if ( isset( $_POST['ua_sticky_settings_nonce'] ) ) {
94 $nonce = sanitize_text_field( wp_unslash( $_POST['ua_sticky_settings_nonce'] ) );
95
96 if ( wp_verify_nonce( $nonce, 'ua_sticky_settings' ) ) {
97 $sticky_enabled = isset( $_POST['ut_enable_section_sticky'] ) ? 'yes' : 'no';
98 $transparent_enabled = isset( $_POST['ut_enable_header_tranparent'] ) ? 'yes' : 'no';
99
100 update_option( 'ua_enable_sticky', $sticky_enabled );
101 update_option( 'ua_enable_transparent', $transparent_enabled );
102
103 echo '<div class="ut-admin-setting-notice updated"><p>' . esc_html__( 'Settings saved.', 'ut-elementor-addons-lite' ) . '</p></div>';
104 }
105 }
106
107 $sticky = get_option( 'ua_enable_sticky', 'no' );
108 $transparent = get_option( 'ua_enable_transparent', 'no' );
109 ?>
110 <div class="ut-admin-setting-wrapper">
111 <h1 class="ut-admin-setting-title"><?php esc_html_e( 'Ultra Addons Lite', 'ut-elementor-addons-lite' ); ?></h1>
112 <form method="post" class="ut-admin-setting-form">
113 <?php wp_nonce_field( 'ua_sticky_settings', 'ua_sticky_settings_nonce' ); ?>
114
115 <div class="ut-admin-setting-field">
116 <label class="ut-admin-setting-switch">
117 <input type="checkbox" name="ut_enable_section_sticky" value="yes" <?php checked( $sticky, 'yes' ); ?> />
118 <span class="ut-admin-setting-slider"></span>
119 <span class="ut-admin-setting-label"><?php esc_html_e( 'Enable Sticky Section', 'ut-elementor-addons-lite' ); ?></span>
120 </label>
121 </div>
122
123 <div class="ut-admin-setting-field">
124 <label class="ut-admin-setting-switch">
125 <input type="checkbox" name="ut_enable_header_tranparent" value="yes" <?php checked( $transparent, 'yes' ); ?> />
126 <span class="ut-admin-setting-slider"></span>
127 <span class="ut-admin-setting-label"><?php esc_html_e( 'Enable Header Transparency', 'ut-elementor-addons-lite' ); ?></span>
128 </label>
129 </div>
130
131 <div class="ut-admin-setting-field">
132 <input type="submit" class="button button-primary ut-admin-setting-submit" value="<?php esc_attr_e( 'Save Settings', 'ut-elementor-addons-lite' ); ?>">
133 </div>
134 </form>
135 </div>
136 <?php
137 }
138
139
140 /**
141 * Apply Sticky / Transparent settings on front-end
142 */
143 public function ut_apply_sticky_settings() {
144 $sticky = get_option( 'ua_enable_sticky', 'no' );
145 $transparent = get_option( 'ua_enable_transparent', 'no' );
146
147 $classes = '';
148
149 if ( $sticky === 'yes' ) {
150 $classes .= ' ut-hf-sticky-header';
151 }
152
153 if ( $transparent === 'yes' ) {
154 $classes .= ' ut-hf-sticky-header-transparent';
155 }
156
157 if ( $classes ) {
158 $classes_value = trim( $classes );
159 $transparent_enabled = ( 'yes' === $transparent ) ? 'true' : 'false';
160 ?>
161 <script>
162 document.addEventListener('DOMContentLoaded', function() {
163 var el = document.getElementById('ut-head');
164 if (el) {
165 var classes = '<?php echo esc_js( $classes_value ); ?>'.split(' ');
166 classes.forEach(function(cls) {
167 if (cls.trim() !== '') {
168 el.classList.add(cls.trim());
169 }
170 });
171
172 // When transparent, give the header a solid background once the
173 // page is scrolled past it, instead of staying transparent forever.
174 if ( <?php echo esc_js( $transparent_enabled ); ?> ) {
175 var scrollThreshold = 50;
176 var toggleScrolledClass = function() {
177 el.classList.toggle('is-scrolled', window.scrollY > scrollThreshold);
178 };
179 window.addEventListener('scroll', toggleScrolledClass, { passive: true });
180 toggleScrolledClass();
181 }
182 }
183 });
184 </script>
185 <?php
186 }
187 }
188
189 /**
190 * Enqueue admin scripts
191 */
192 public function ut_enqueue_scripts() {
193 wp_enqueue_style(
194 'ut-backend',
195 UTAL_CSS_ADMIN_DIR . '/backend.css',
196 array(),
197 UTAL_PLUGIN_VERSION
198 );
199 }
200
201
202 /**
203 * Set up the Header & Footer Builder by defining paths and including necessary classes
204 */
205 function ut_hf_setup() {
206 define( 'UT_HEADER_FOOTER_PATH', plugin_dir_path( __FILE__ ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
207 define( 'UT_HEADER_FOOTER_URL', plugin_dir_url( __FILE__ ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
208 require_once UT_HEADER_FOOTER_PATH . 'modules/ut-hf-builder/inc/class-ut-hf-builder.php';
209 }
210
211
212 /**
213 * Initializes the plugin by checking if Elementor is loaded,
214 * and if not, displays an admin notice prompting to install Elementor.
215 */
216 function ut_init_plugin()
217 {
218 if ( ! did_action( 'elementor/loaded' ) )
219 {
220 add_action( 'admin_notices', 'utal_required_plugins_admin_notice' );
221 }
222 }
223
224
225 /**
226 * Defines constants used throughout the plugin.
227 * - Defines directory paths for CSS, JS, and package assets.
228 * - Defines the plugin directory path and version.
229 */
230 function define_constants()
231 {
232 defined( 'UTAL_IMG_DIR' ) or define( 'UTAL_IMG_DIR', plugin_dir_url( __FILE__ ) . 'assets/img' );
233 defined( 'UTAL_CSS_ADMIN_DIR' ) or define( 'UTAL_CSS_ADMIN_DIR', plugin_dir_url( __FILE__ ) . 'assets/admin' );
234 defined( 'UTAL_CSS_DIR' ) or define( 'UTAL_CSS_DIR', plugin_dir_url( __FILE__ ) . 'assets/css' );
235 defined( 'UTAL_JS_DIR' ) or define( 'UTAL_JS_DIR', plugin_dir_url( __FILE__ ) . 'assets/js' );
236 defined( 'UTAL_PACKAGE_DIR' ) or define( 'UTAL_PACKAGE_DIR', plugin_dir_url( __FILE__ ) . 'assets/package' );
237 defined( 'UTAL_PATH' ) or define( 'UTAL_PATH', plugin_dir_path( __FILE__ ) );
238 if ( ! defined( 'UTAL_PLUGIN_VERSION' ) ) {
239 $utal_plugin_data = get_file_data( __FILE__, [ 'Version' => 'Version' ] );
240 define( 'UTAL_PLUGIN_VERSION', $utal_plugin_data['Version'] );
241 }
242 }
243
244
245 /**
246 * Includes necessary files for plugin functionality.
247 * - Includes query functions.
248 * - Includes Elementor helper functions.
249 * - Includes file to make columns clickable.
250 */
251 function ut_elementor_addons_lite_includes()
252 {
253 require_once UTAL_PATH . 'includes/ajax-functions.php';
254 require_once UTAL_PATH . 'includes/queries.php';
255 require_once UTAL_PATH . 'includes/elementor-helper.php';
256 require_once UTAL_PATH . 'controls/make-column-clickable.php';
257 }
258
259
260 /**
261 * Registers widget categories for Ultra Addons Lite plugin.
262 * - Defines the category groups.
263 * - Iterates over the groups to add them to Elementor.
264 */
265 function ut_elementor_addons_lite_widget_categories()
266 {
267 $groups = array(
268 'ut-elementor-addons-lite' => esc_html__( 'Ultra Addons Lite', 'ut-elementor-addons-lite' )
269 );
270 foreach ( $groups as $key => $value )
271 {
272 \Elementor\Plugin::$instance
273 ->elements_manager
274 ->add_category( $key, ['title' => $value], 1 );
275 }
276 }
277
278
279 /**
280 * Registers all custom Elementor widgets for Ultra Addons Lite plugin.
281 * - Requires all widget files.
282 * - Checks if WooCommerce is active, if so, includes the products widget file.
283 */
284 function ut_elementor_addons_lite_register()
285 {
286 require_once plugin_dir_path( __FILE__ ) . 'elements/site-logo.php';
287 require_once plugin_dir_path( __FILE__ ) . 'elements/nav-menu.php';
288 require_once plugin_dir_path( __FILE__ ) . 'elements/search.php';
289 require_once plugin_dir_path( __FILE__ ) . 'elements/blog-grid.php';
290 require_once plugin_dir_path( __FILE__ ) . 'elements/blog-list.php';
291 require_once plugin_dir_path( __FILE__ ) . 'elements/blog-block.php';
292 require_once plugin_dir_path( __FILE__ ) . 'elements/slider.php';
293 require_once plugin_dir_path( __FILE__ ) . 'elements/testimonial.php';
294 require_once plugin_dir_path( __FILE__ ) . 'elements/content-ticker.php';
295 require_once plugin_dir_path( __FILE__ ) . 'elements/team.php';
296 require_once plugin_dir_path( __FILE__ ) . 'elements/flip-box.php';
297 require_once plugin_dir_path( __FILE__ ) . 'elements/progress-bar.php';
298 require_once plugin_dir_path( __FILE__ ) . 'elements/carousel.php';
299 require_once plugin_dir_path( __FILE__ ) . 'elements/funfact.php';
300 require_once plugin_dir_path( __FILE__ ) . 'elements/image-comparison.php';
301 require_once plugin_dir_path( __FILE__ ) . 'elements/icon-box.php';
302 require_once plugin_dir_path( __FILE__ ) . 'elements/tablepress.php';
303 require_once plugin_dir_path( __FILE__ ) . 'elements/video.php';
304 require_once plugin_dir_path( __FILE__ ) . 'elements/pricing-table.php';
305 require_once plugin_dir_path( __FILE__ ) . 'elements/calendly.php';
306 require_once plugin_dir_path( __FILE__ ) . 'elements/scroll-to-top.php';
307 require_once plugin_dir_path( __FILE__ ) . 'elements/marquee.php';
308 require_once plugin_dir_path( __FILE__ ) . 'elements/circle-text.php';
309 require_once plugin_dir_path( __FILE__ ) . 'elements/alert.php';
310 require_once plugin_dir_path( __FILE__ ) . 'elements/modal-popup.php';
311 require_once plugin_dir_path( __FILE__ ) . 'elements/typeout.php';
312 require_once plugin_dir_path( __FILE__ ) . 'elements/post-tab.php';
313 require_once plugin_dir_path( __FILE__ ) . 'elements/mailchimp.php';
314 require_once plugin_dir_path( __FILE__ ) . 'elements/contact-form.php';
315
316 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
317 if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) )
318 {
319 require_once plugin_dir_path( __FILE__ ) . 'elements/products.php';
320 }
321 }
322
323
324 /**
325 * Registers and enqueues frontend styles for Ultra Addons Lite plugin.
326 * - Registers various stylesheets required for frontend functionality.
327 * - Enqueues the main frontend stylesheet along with responsive styles and Font Awesome icons.
328 */
329 function register_frontend_style()
330 {
331 wp_register_style( 'jquery-lineProgressbar', UTAL_PACKAGE_DIR . '/progress-bar/jquery.lineProgressbar.min.css', array() , UTAL_PLUGIN_VERSION );
332 wp_register_style( 'slick', UTAL_CSS_DIR . '/slick.css', array() , UTAL_PLUGIN_VERSION );
333 wp_register_style( 'twentytwenty', UTAL_PACKAGE_DIR . '/image-comparision/twentytwenty.css', array() , UTAL_PLUGIN_VERSION );
334 wp_register_style( 'jquery-dataTables', UTAL_PACKAGE_DIR . '/tablepress/jquery.dataTables.min.css', array() , UTAL_PLUGIN_VERSION );
335 wp_enqueue_style( 'ut-elementor-addons-lite-frontend', UTAL_CSS_DIR . '/frontend.css', array() , UTAL_PLUGIN_VERSION );
336 wp_enqueue_style( 'ut-elementor-addons-lite-responsive', UTAL_CSS_DIR . '/responsive.css', array() , UTAL_PLUGIN_VERSION );
337 wp_enqueue_style( 'font-awesome-5-all', UTAL_CSS_DIR . '/all.min.css', array() , UTAL_PLUGIN_VERSION );
338 }
339
340
341 /**
342 * Enqueues custom styles for Elementor editor in the WordPress admin.
343 */
344 function ut_elementor_admin()
345 {
346 wp_enqueue_style( 'ut-elementor-editor', UTAL_CSS_DIR . '/admin/elementor-editor.css', array() , UTAL_PLUGIN_VERSION );
347 }
348
349
350 /**
351 * Registers frontend JavaScript assets.
352 */
353 function register_frontend_assets()
354 {
355 wp_register_script( 'ut-elementor-addons-lite-script', UTAL_JS_DIR . '/custom.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
356 wp_register_script( 'slick', UTAL_JS_DIR . '/slick.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
357 wp_register_script( 'waypoints', UTAL_JS_DIR . '/waypoints.min.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
358 wp_register_script( 'calendly', UTAL_JS_DIR . '/calendly.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
359 wp_register_script( 'jquery-lineProgressbar', UTAL_PACKAGE_DIR . '/progress-bar/jquery.lineProgressbar.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
360 wp_register_script( 'jquery-easypiechart', UTAL_PACKAGE_DIR . '/easypiechart/jquery.easypiechart.min.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
361 wp_register_script( 'jquery-event-move', UTAL_PACKAGE_DIR . '/image-comparision/jquery.event.move.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
362 wp_register_script( 'jquery-twentytwenty', UTAL_PACKAGE_DIR . '/image-comparision/jquery.twentytwenty.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
363 wp_register_script( 'jquery-dataTables', UTAL_PACKAGE_DIR . '/tablepress/jquery.dataTables.min.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
364 wp_register_script( 'ut-column-clickable', UTAL_JS_DIR . '/column-clickable.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
365 wp_register_script( 'circletype', UTAL_JS_DIR . '/circletype.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
366 wp_register_script( 'typed', UTAL_JS_DIR . '/typed.js', array( 'jquery' ), UTAL_PLUGIN_VERSION, true );
367 // Localize script for AJAX
368 wp_localize_script( 'ut-elementor-addons-lite-script', 'ultraLiteObj', array(
369 'ajaxurl' => admin_url('admin-ajax.php'),
370 'nonce' => wp_create_nonce('ultralite_nonce')
371 ));
372 }
373 }
374
375
376 /**
377 * Initializes the controls after Elementor controls are registered.
378 */
379 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
380 function init()
381 {
382 add_action( 'elementor/controls/controls_registered', [ $this, 'init_controls' ] );
383 }
384
385
386 /**
387 * Displays an admin notice if Elementor plugin is not installed and activated.
388 */
389 function utal_required_plugins_admin_notice() {
390 // Translators: This is the main part of the message.
391 $message_part1 = __( 'Ultra Addons Lite for Elementor requires Elementor to be installed and activated to function properly.', 'ut-elementor-addons-lite' );
392
393 // Translators: This is the installation link text.
394 $message_part2 = __( 'Please click here to install/activate Elementor.', 'ut-elementor-addons-lite' );
395
396 // Combine the parts with the installation link.
397 $message = sprintf(
398 '%1$s <a href="%2$s">%3$s</a>',
399 '<strong>' . esc_html( $message_part1 ) . '</strong>',
400 esc_url( admin_url( 'plugin-install.php?s=Elementor&tab=search&type=term' ) ),
401 esc_html( $message_part2 )
402 );
403
404 // Output the notice with escaping
405 printf( '<div class="notice notice-warning is-dismissible"><p style="padding: 5px 0">%1$s</p></div>', wp_kses_post( $message ) );
406 }
407
408
409 // Instantiate UT_Elementor_Addons_Lite object.
410 $utal_obj = new UT_Elementor_Addons_Lite();
411
412 }
413
414