essential-addons-for-elementor-lite
Last commit date
admin
8 years ago
assets
8 years ago
elements
8 years ago
includes
8 years ago
essential_adons_elementor.php
8 years ago
readme.txt
8 years ago
essential_adons_elementor.php
334 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: Essential Addons for Elementor |
| 4 | * Description: The ultimate elements library for Elementor page builder plugin for WordPress. |
| 5 | * Plugin URI: https://essential-addons.com/elementor/ |
| 6 | * Author: Codetic |
| 7 | * Version: 2.7.0 |
| 8 | * Author URI: https://www.codetic.net |
| 9 | * |
| 10 | * Text Domain: essential-addons-elementor |
| 11 | */ |
| 12 | |
| 13 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 | |
| 15 | define( 'ESSENTIAL_ADDONS_EL_URL', plugins_url( '/', __FILE__ ) ); |
| 16 | define( 'ESSENTIAL_ADDONS_EL_PATH', plugin_dir_path( __FILE__ ) ); |
| 17 | |
| 18 | |
| 19 | require_once ESSENTIAL_ADDONS_EL_PATH.'includes/elementor-helper.php'; |
| 20 | require_once ESSENTIAL_ADDONS_EL_PATH.'includes/queries.php'; |
| 21 | require_once ESSENTIAL_ADDONS_EL_PATH.'includes/class-plugin-usage-tracker.php'; |
| 22 | require_once ESSENTIAL_ADDONS_EL_PATH.'admin/settings.php'; |
| 23 | |
| 24 | /** |
| 25 | * This function will return true for all activated modules |
| 26 | * |
| 27 | * @since v2.4.1 |
| 28 | */ |
| 29 | function eael_activated_modules() { |
| 30 | |
| 31 | $eael_default_keys = [ 'contact-form-7', 'count-down', 'creative-btn', 'fancy-text', 'img-comparison', 'instagram-gallery', 'interactive-promo', 'lightbox', 'post-block', 'post-grid', 'post-timeline', 'product-grid', 'team-members', 'testimonial-slider', 'testimonials', 'testimonials', 'weforms', 'static-product', 'call-to-action', 'flip-box', 'info-box', 'dual-header', 'price-table', 'flip-carousel', 'interactive-cards', 'ninja-form', 'gravity-form', 'caldera-form', 'wisdom_registered_setting', 'twitter-feed', 'facebook-feed', 'data-table', 'filter-gallery', 'image-accordion','content-ticker', 'tooltip', 'adv-accordion', 'adv-tabs' ]; |
| 32 | |
| 33 | $eael_default_settings = array_fill_keys( $eael_default_keys, true ); |
| 34 | $eael_get_settings = get_option( 'eael_save_settings', $eael_default_settings ); |
| 35 | $eael_new_settings = array_diff_key( $eael_default_settings, $eael_get_settings ); |
| 36 | |
| 37 | if( ! empty( $eael_new_settings ) ) { |
| 38 | $eael_updated_settings = array_merge( $eael_get_settings, $eael_new_settings ); |
| 39 | update_option( 'eael_save_settings', $eael_updated_settings ); |
| 40 | } |
| 41 | |
| 42 | return $eael_get_settings = get_option( 'eael_save_settings', $eael_default_settings ); |
| 43 | |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Acivate or Deactivate Modules |
| 48 | * |
| 49 | * @since v1.0.0 |
| 50 | */ |
| 51 | function add_eael_elements() { |
| 52 | |
| 53 | $is_component_active = eael_activated_modules(); |
| 54 | |
| 55 | // load elements |
| 56 | if( $is_component_active['post-grid'] ) { |
| 57 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/post-grid/post-grid.php'; |
| 58 | } |
| 59 | if( $is_component_active['post-timeline'] ) { |
| 60 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/post-timeline/post-timeline.php'; |
| 61 | } |
| 62 | if( $is_component_active['fancy-text'] ) { |
| 63 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/fancy-text/fancy-text.php'; |
| 64 | } |
| 65 | if( $is_component_active['creative-btn'] ) { |
| 66 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/creative-button/creative-button.php'; |
| 67 | } |
| 68 | if( $is_component_active['count-down'] ) { |
| 69 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/countdown/countdown.php'; |
| 70 | } |
| 71 | if( $is_component_active['team-members'] ) { |
| 72 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/team-members/team-members.php'; |
| 73 | } |
| 74 | if( $is_component_active['testimonials'] ) { |
| 75 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/testimonials/testimonials.php'; |
| 76 | } |
| 77 | |
| 78 | if ( function_exists( 'WC' ) && $is_component_active['product-grid'] ) { |
| 79 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/product-grid/product-grid.php'; |
| 80 | } |
| 81 | |
| 82 | if ( function_exists( 'wpcf7' ) && $is_component_active['contact-form-7'] ) { |
| 83 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/contact-form-7/contact-form-7.php'; |
| 84 | } |
| 85 | |
| 86 | if ( function_exists( 'WeForms' ) && $is_component_active['weforms'] ) { |
| 87 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/weforms/weforms.php'; |
| 88 | } |
| 89 | |
| 90 | if( $is_component_active['info-box'] ) { |
| 91 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/infobox/infobox.php'; |
| 92 | } |
| 93 | |
| 94 | if( $is_component_active['flip-box'] ) { |
| 95 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/flipbox/flipbox.php'; |
| 96 | } |
| 97 | |
| 98 | if( $is_component_active['call-to-action'] ) { |
| 99 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/call-to-action/call-to-action.php'; |
| 100 | } |
| 101 | |
| 102 | if( $is_component_active['dual-header'] ) { |
| 103 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/dual-color-header/dual-color-header.php'; |
| 104 | } |
| 105 | if( $is_component_active['price-table'] ) { |
| 106 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/pricing-table/pricing-table.php'; |
| 107 | } |
| 108 | if( function_exists( 'Ninja_Forms' ) && $is_component_active['ninja-form'] ) { |
| 109 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/ninja-form/ninja-form.php'; |
| 110 | } |
| 111 | if( class_exists( 'GFForms' ) && $is_component_active['gravity-form'] ) { |
| 112 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/gravity-form/gravity-form.php'; |
| 113 | } |
| 114 | if( class_exists( 'Caldera_Forms' ) && $is_component_active['caldera-form'] ) { |
| 115 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/caldera-forms/caldera-forms.php'; |
| 116 | } |
| 117 | if( $is_component_active['twitter-feed'] ) { |
| 118 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/twitter-feed/twitter-feed.php'; |
| 119 | } |
| 120 | if( $is_component_active['facebook-feed'] ) { |
| 121 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/facebook-feed/facebook-feed.php'; |
| 122 | } |
| 123 | if( $is_component_active['data-table'] ) { |
| 124 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/data-table/data-table.php'; |
| 125 | } |
| 126 | if( $is_component_active['filter-gallery'] ) { |
| 127 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/filterable-gallery/filterable-gallery.php'; |
| 128 | } |
| 129 | if( $is_component_active['image-accordion'] ) { |
| 130 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/image-accordion/image-accordion.php'; |
| 131 | } |
| 132 | if( $is_component_active['content-ticker'] ) { |
| 133 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/content-ticker/content-ticker.php'; |
| 134 | } |
| 135 | if( $is_component_active['tooltip'] ) { |
| 136 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/tooltip/tooltip.php'; |
| 137 | } |
| 138 | if( $is_component_active['adv-accordion'] ) { |
| 139 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/advance-accordion/advance-accordion.php'; |
| 140 | } |
| 141 | if( $is_component_active['adv-tabs'] ) { |
| 142 | require_once ESSENTIAL_ADDONS_EL_PATH.'elements/advance-tabs/advance-tabs.php'; |
| 143 | } |
| 144 | } |
| 145 | add_action('elementor/widgets/widgets_registered','add_eael_elements'); |
| 146 | |
| 147 | /** |
| 148 | * Load module's scripts and styles if any module is active. |
| 149 | * |
| 150 | * @since v1.0.0 |
| 151 | */ |
| 152 | function essential_addons_el_enqueue(){ |
| 153 | $is_component_active = eael_activated_modules(); |
| 154 | wp_enqueue_style('essential_addons_elementor-css',ESSENTIAL_ADDONS_EL_URL.'assets/css/essential-addons-elementor.css'); |
| 155 | wp_enqueue_style('essential_addons_elementor-slick-css',ESSENTIAL_ADDONS_EL_URL.'assets/slick/slick.css'); |
| 156 | |
| 157 | if( $is_component_active['fancy-text'] ) { |
| 158 | wp_enqueue_script('essential_addons_elementor-fancy-text-js',ESSENTIAL_ADDONS_EL_URL.'assets/js/fancy-text.js', array('jquery'),'1.0', true); |
| 159 | } |
| 160 | if( $is_component_active['count-down'] ) { |
| 161 | wp_enqueue_script('essential_addons_elementor-countdown-js',ESSENTIAL_ADDONS_EL_URL.'assets/js/countdown.min.js', array('jquery'),'1.0', true); |
| 162 | } |
| 163 | if( $is_component_active['post-grid'] || $is_component_active['twitter-feed'] || $is_component_active['facebook-feed'] ) { |
| 164 | wp_enqueue_script('essential_addons_elementor-masonry-js',ESSENTIAL_ADDONS_EL_URL.'assets/js/masonry.min.js', array('jquery'),'1.0', true); |
| 165 | } |
| 166 | if( $is_component_active['post-grid'] || $is_component_active['post-timeline'] ) { |
| 167 | wp_enqueue_script('essential_addons_elementor-load-more-js',ESSENTIAL_ADDONS_EL_URL.'assets/js/load-more.js', array('jquery'),'1.0', true); |
| 168 | } |
| 169 | if( $is_component_active['twitter-feed']) { |
| 170 | wp_enqueue_script('essential_addons_elementor-codebird-js',ESSENTIAL_ADDONS_EL_URL.'assets/social-feeds/codebird.js', array('jquery'),'1.0', true); |
| 171 | } |
| 172 | if( $is_component_active['twitter-feed'] || $is_component_active['facebook-feed'] ) { |
| 173 | wp_enqueue_script('essential_addons_elementor-doT-js',ESSENTIAL_ADDONS_EL_URL.'assets/social-feeds/doT.min.js', array('jquery'),'1.0', true); |
| 174 | wp_enqueue_script('essential_addons_elementor-moment-js',ESSENTIAL_ADDONS_EL_URL.'assets/social-feeds/moment.js', array('jquery'),'1.0', true); |
| 175 | wp_enqueue_script('essential_addons_elementor-socialfeed-js',ESSENTIAL_ADDONS_EL_URL.'assets/social-feeds/jquery.socialfeed.js', array('jquery'),'1.0', true); |
| 176 | } |
| 177 | |
| 178 | if( $is_component_active['filter-gallery'] ) { |
| 179 | wp_enqueue_script('essential_addons_mixitup-js',ESSENTIAL_ADDONS_EL_URL.'assets/js/mixitup.min.js', array('jquery'),'1.0', true); |
| 180 | wp_enqueue_script('essential_addons_magnific-popup-js',ESSENTIAL_ADDONS_EL_URL.'assets/js/jquery.magnific-popup.min.js', array('jquery'),'1.0', true); |
| 181 | } |
| 182 | |
| 183 | if( $is_component_active['content-ticker'] ) { |
| 184 | wp_enqueue_script('essential_addons_elementor-slick-js',ESSENTIAL_ADDONS_EL_URL.'assets/slick/slick.min.js', array('jquery'),'1.0', true); |
| 185 | } |
| 186 | |
| 187 | } |
| 188 | add_action( 'wp_enqueue_scripts', 'essential_addons_el_enqueue' ); |
| 189 | |
| 190 | |
| 191 | /** |
| 192 | * Editor Css |
| 193 | */ |
| 194 | add_action( 'elementor/editor/before_enqueue_scripts', function() { |
| 195 | |
| 196 | wp_register_style( 'essential_addons_elementor_editor-css', ESSENTIAL_ADDONS_EL_URL.'assets/css/essential-addons-editor.css'); |
| 197 | wp_enqueue_style( 'essential_addons_elementor_editor-css' ); |
| 198 | |
| 199 | } ); |
| 200 | |
| 201 | /** |
| 202 | * Creates an Action Menu |
| 203 | */ |
| 204 | function eael_add_settings_link( $links ) { |
| 205 | $settings_link = sprintf( '<a href="admin.php?page=eael-settings">' . __( 'Settings' ) . '</a>' ); |
| 206 | $go_pro_link = sprintf( '<a href="https://wpdeveloper.net/in/upgrade-essential-addons-elementor" target="_blank" style="color: #39b54a; font-weight: bold;">' . __( 'Go Pro' ) . '</a>' ); |
| 207 | array_push( $links, $settings_link, $go_pro_link ); |
| 208 | return $links; |
| 209 | } |
| 210 | $plugin = plugin_basename( __FILE__ ); |
| 211 | add_filter( "plugin_action_links_$plugin", 'eael_add_settings_link' ); |
| 212 | |
| 213 | /** |
| 214 | * Activation redirects |
| 215 | * |
| 216 | * @since v1.0.0 |
| 217 | */ |
| 218 | function eael_activate() { |
| 219 | add_option('eael_do_activation_redirect', true); |
| 220 | } |
| 221 | register_activation_hook(__FILE__, 'eael_activate'); |
| 222 | |
| 223 | /** |
| 224 | * Redirect to options page |
| 225 | * |
| 226 | * @since v1.0.0 |
| 227 | */ |
| 228 | function eael_redirect() { |
| 229 | if (get_option('eael_do_activation_redirect', false)) { |
| 230 | delete_option('eael_do_activation_redirect'); |
| 231 | if(!isset($_GET['activate-multi'])) |
| 232 | { |
| 233 | wp_redirect("admin.php?page=eael-settings"); |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | add_action('admin_init', 'eael_redirect'); |
| 238 | |
| 239 | /** |
| 240 | * Optional usage tracker |
| 241 | * |
| 242 | * @since v1.0.0 |
| 243 | */ |
| 244 | if( ! class_exists( 'Eael_Plugin_Usage_Tracker') ) { |
| 245 | require_once dirname( __FILE__ ) . '/includes/class-plugin-usage-tracker.php'; |
| 246 | } |
| 247 | if( ! function_exists( 'essential_addons_elementor_lite_start_plugin_tracking' ) ) { |
| 248 | function essential_addons_elementor_lite_start_plugin_tracking() { |
| 249 | $wisdom = new Eael_Plugin_Usage_Tracker( |
| 250 | __FILE__, |
| 251 | 'https://wpdeveloper.net', |
| 252 | array(), |
| 253 | true, |
| 254 | true, |
| 255 | 1 |
| 256 | ); |
| 257 | } |
| 258 | essential_addons_elementor_lite_start_plugin_tracking(); |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Admin Notice |
| 263 | * |
| 264 | * @since v1.0.0 |
| 265 | */ |
| 266 | function eael_admin_notice() { |
| 267 | if ( current_user_can( 'install_plugins' ) ) { |
| 268 | global $current_user ; |
| 269 | $user_id = $current_user->ID; |
| 270 | /* Check that the user hasn't already clicked to ignore the message */ |
| 271 | if ( ! get_user_meta($user_id, 'eael_ignore_notice260') ) { |
| 272 | echo '<div class="eael-admin-notice updated" style="display: flex; align-items: center; padding-left: 0; border-left-color: #EF4B53"><p style="width: 36px;">'; |
| 273 | echo '<img style="width: 100%; display: block;" src="' . plugins_url( '/', __FILE__ ).'admin/assets/images/icon-heart.svg'. '" ></p><p> '; |
| 274 | printf(__('<strong>Essential Addons for Elementor</strong> crossed <strong>100,000+</strong> downloads. Use the coupon code <strong>100K</strong> to redeem a <strong>25% </strong> discount on Pro. <a href="https://wpdeveloper.net/in/upgrade-essential-addons-elementor" target="_blank" style="text-decoration: none;"><span class="dashicons dashicons-smiley" style="margin-left: 10px;"></span> Grab the Deal</a> |
| 275 | <a href="%1$s" style="text-decoration: none; margin-left: 10px;"><span class="dashicons dashicons-dismiss"></span> Dismiss</a>'), admin_url( 'admin.php?page=eael-settings&eael_nag_ignore=0' )); |
| 276 | echo "</p></div>"; |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | add_action('admin_notices', 'eael_admin_notice'); |
| 281 | |
| 282 | |
| 283 | /** |
| 284 | * Nag Ignore |
| 285 | */ |
| 286 | function eael_nag_ignore() { |
| 287 | global $current_user; |
| 288 | $user_id = $current_user->ID; |
| 289 | /* If user clicks to ignore the notice, add that to their user meta */ |
| 290 | if ( isset($_GET['eael_nag_ignore']) && '0' == $_GET['eael_nag_ignore'] ) { |
| 291 | add_user_meta($user_id, 'eael_ignore_notice260', 'true', true); |
| 292 | } |
| 293 | } |
| 294 | add_action('admin_init', 'eael_nag_ignore'); |
| 295 | |
| 296 | |
| 297 | /** |
| 298 | * Check if Elementor is Installed or not |
| 299 | */ |
| 300 | if( ! function_exists( 'eael_is_elementor_active' ) ) : |
| 301 | function eael_is_elementor_active() { |
| 302 | $flie_path = 'elementor/elementor.php'; |
| 303 | $installed_plugins = get_plugins(); |
| 304 | return isset( $installed_plugins[$flie_path] ); |
| 305 | } |
| 306 | endif; |
| 307 | |
| 308 | /** |
| 309 | * This notice will appear if Elementor is not installed or activated or both |
| 310 | */ |
| 311 | function eael_is_failed_to_load() { |
| 312 | $elementor = 'elementor/elementor.php'; |
| 313 | if( eael_is_elementor_active() ) { |
| 314 | if( ! current_user_can( 'activate_plugins' ) ) { |
| 315 | return; |
| 316 | } |
| 317 | $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $elementor . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $elementor ); |
| 318 | $message = __( 'Essential Addons Elementor requires Elementor plugin to be active. Please activate Elementor to continue.', 'essential-addons-elementor' ); |
| 319 | $button_text = __( 'Activate Elementor', 'essential-addons-elementor' ); |
| 320 | } else { |
| 321 | if( ! current_user_can( 'activate_plugins' ) ) { |
| 322 | return; |
| 323 | } |
| 324 | $activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' ); |
| 325 | $message = sprintf( __( 'Essentail Addons Elementor requires %1$s"Elementor"%2$s plugin to be installed and activated. Please install Elementor to continue.', 'essential-addons-elementor' ), '<strong>', '</strong>' ); |
| 326 | $button_text = __( 'Install Elementor', 'essential-addons-elementor' ); |
| 327 | } |
| 328 | $button = '<p><a href="' . $activation_url . '" class="button-primary">' . $button_text . '</a></p>'; |
| 329 | printf( '<div class="error"><p>%1$s</p>%2$s</div>', esc_html( $message ), $button ); |
| 330 | } |
| 331 | |
| 332 | if( ! did_action( 'elementor/loaded' ) ) { |
| 333 | add_action( 'admin_notices', 'eael_is_failed_to_load' ); |
| 334 | } |