Plugin Directory

Changeset 3448234


Ignore:
Timestamp:
01/27/2026 10:09:21 PM (3 weeks ago)
Author:
mominkhan08
Message:

Updating plugin code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • elite-kit/trunk/elite-kit-lite.php

    r3448222 r3448234  
    1515 */
    1616
    17 defined( 'ABSPATH' ) || exit;
    18 
    19 define( 'EKL_VERSION', time() );
    20 define( 'EKL_FILE', __FILE__ );
    21 define( 'EKL_PATH', __DIR__ );
    22 define( 'EKL_URL', plugins_url( '', EKL_FILE ) );
    23 define( 'EKL_ASSETS', EKL_URL . '/assets/' );
    24 define( 'EKL_ADMIN', EKL_PATH . '/admin/' );
    25 define( 'EKL_ADMIN_URL', EKL_URL . '/admin/' );
    26 define( 'EKL_WIDGET', EKL_PATH . '/widgets/' );
     17defined('ABSPATH') || exit;
     18
     19define('EKL_VERSION', time());
     20define('EKL_FILE', __FILE__);
     21define('EKL_PATH', __DIR__);
     22define('EKL_URL', plugins_url('', EKL_FILE));
     23define('EKL_ASSETS', EKL_URL . '/assets/');
     24define('EKL_ADMIN', EKL_PATH . '/admin/');
     25define('EKL_ADMIN_URL', EKL_URL . '/admin/');
     26define('EKL_WIDGET', EKL_PATH . '/widgets/');
    2727
    2828use EliteKit\Elementor\Classes as EliteKit_Classes;
     
    3131 * Main EliteKit Class.
    3232 */
    33 final class EliteKit {
    34     const VERSION                   = '1.0.7';
    35     const MINIMUM_ELEMENTOR_VERSION = '3.34.0';
    36     const MINIMUM_PHP_VERSION       = '7.4';
    37 
    38     public function __construct() {
    39         $this->init_plugin();
    40         register_activation_hook( __FILE__, array( $this, 'upon_activation' ) );
    41     }
    42 
    43     /**
    44      * Plugin activation hook.
    45      *
    46      * @access public
    47      */
    48     public function upon_activation() {
    49         $installed = get_option( 'elite_kit_lite_installed' );
    50 
    51         if ( ! $installed ) {
    52             update_option( 'elite_kit_lite_installed', time() );
    53         }
    54 
    55         update_option( 'elite_kit_lite_installed', EKL_VERSION );
    56     }
    57 
    58     /**
    59      * Hook into actions and filters.
    60      *
    61      * @access private
    62      */
    63     private function init_plugin() {
    64         add_action( 'init', array( $this, 'load_textdomain' ) );
    65 
    66         $this->load_widget_manager();
    67 
    68         add_action( 'plugins_loaded', array( $this, 'on_plugin_load' ) );
    69 
    70         // Declare WooCommerce HPOS compatibility
    71         add_action( 'before_woocommerce_init', array( $this, 'declare_woocommerce_hpos_compatibility' ) );
    72 
    73         // Prevent Elementor from being deactivated while Elite Kit is active
    74         add_filter( 'plugin_action_links_elementor/elementor.php', array( $this, 'disable_elementor_deactivation' ) );
    75     }
    76 
    77     /**
    78      * Disable Elementor deactivation link while Elite Kit is active.
    79      *
    80      * @param array $actions Plugin action links.
    81      * @return array Modified action links.
    82      */
    83     public function disable_elementor_deactivation( $actions ) {
    84         if ( isset( $actions['deactivate'] ) ) {
    85             $actions['deactivate'] = sprintf(
    86                 '<span style="color: #a0a5aa; cursor: not-allowed;" title="%s">%s</span>',
    87                 esc_attr__( 'Elite Kit requires Elementor. Please deactivate Elite Kit first.', 'elite-kit' ),
    88                 esc_html__( 'Deactivate', 'elite-kit' )
    89             );
    90         }
    91         return $actions;
    92     }
    93 
    94     /**
    95      * Load the plugin text domain for translation.
    96      */
    97     public function load_textdomain() {
    98         load_plugin_textdomain( 'elite-kit', false, plugin_basename( __DIR__ ) . '/languages' );
    99     }
    100 
    101     /**
    102      * Load the frontend class.
    103      */
    104     public function load_widget_manager() {
    105     }
    106 
    107     /**
    108      * Declare compatibility with WooCommerce HPOS (High-Performance Order Storage).
    109      *
    110      * @return void
    111      */
    112     public function declare_woocommerce_hpos_compatibility() {
    113         if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
    114             \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', EKL_FILE, true );
    115         }
    116     }
    117 
    118     /**
    119      * Load the plugin after Elementor (and other plugins) are loaded.
    120      */
    121     public function on_plugin_load() {
    122 
    123         //Function
    124         require EKL_PATH . '/inc/functions.php';
    125 
    126         require EKL_PATH . '/base.php';
    127         \EliteKit\Base\Base::instance()->init();
    128 
    129         if ( ! did_action( 'elementor/loaded' ) ) {
    130             add_action( 'admin_notices', array( $this, 'admin_notice_missing_main_plugin' ) );
    131 
    132             return;
    133         }
    134 
    135         // Check for required Elementor version.
    136         if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
    137             add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) );
    138 
    139             return;
    140         }
    141 
    142         // Check for required PHP version.
    143         if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
    144             add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) );
    145 
    146             return;
    147         }
    148         if ( is_admin() ) {
    149             add_action( 'admin_enqueue_scripts', array( \EliteKit\Admin\Admin::class, 'load_admin_scripts' ) );
    150         }
    151 
    152         if ( ek_is_adminbar_menu_enabled() ) {
    153             add_action( 'admin_enqueue_scripts', array( EliteKit\Elementor\Classes\Admin_Bar::class, 'enqueue_assets' ) );
    154         }
    155 
    156         add_action( 'elementor/editor/after_enqueue_scripts', array( EliteKit_Classes\Assets_Manager::class, 'register_widget_scripts' ) );
    157         add_action( 'elementor/frontend/after_enqueue_scripts', array( EliteKit_Classes\Assets_Manager::class, 'enqueue_styles' ) );
    158         add_action( 'wp_enqueue_scripts', array( EliteKit_Classes\Assets_Manager::class, 'frontend_register' ) );
    159         add_action( 'wp_enqueue_scripts', array( EliteKit_Classes\Assets_Manager::class, 'frontend_enqueue' ), 99 );
    160         add_action( 'elementor/css-file/post/enqueue', array( EliteKit_Classes\Assets_Manager::class, 'frontend_enqueue_exceptions' ) );
    161 
    162         // Add and move Elementor category.
    163         add_action( 'elementor/elements/categories_registered', array( $this, 'register_category_order_to_top' ) );
    164 
    165         // Register New Widgets.
    166         add_action( 'elementor/widgets/register', array( $this, 'on_widgets_registered' ) );
    167     }
    168 
    169 
    170     /**
    171      * Admin notice
    172      *
    173      * Warning when the site doesn't have Elementor installed or activated.
    174      */
    175     public function admin_notice_missing_main_plugin() {
    176         if ( ! current_user_can( 'activate_plugins' ) ) {
    177             return;
    178         }
    179 
    180         // Don't show on plugin installation, update, or activation pages
    181         global $pagenow;
    182         if ( in_array( $pagenow, array( 'update.php', 'plugins.php' ), true ) ) {
    183             // Check if we're in the middle of installing/activating a plugin
    184             if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'install-plugin', 'activate', 'activate-selected' ), true ) ) {
    185                 return;
    186             }
    187         }
    188 
    189         if ( $this->is_plugin_installed( 'elementor/elementor.php' ) ) {
    190             $activation_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=elementor/elementor.php&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_elementor/elementor.php' );
    191 
    192             $message     = __( 'Elite Kit Addons for Elementor requires Elementor plugin to be active. Please activate Elementor to continue.', 'elite-kit' );
    193             $button_text = __( 'Activate Elementor', 'elite-kit' );
    194         } else {
    195             $activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
    196 
    197             $message     = __( 'Elite Kit Addons for Elementor  requires Elementor  plugin to be installed and activated. Please install Elementor to continue.', 'elite-kit' );
    198             $button_text = __( 'Install Elementor', 'elite-kit' );
    199         }
    200         ?>
    201 
    202         <div class="error">
    203             <p><?php echo esc_html( $message ); ?></p>
    204             <p>
    205                 <a href="<?php echo esc_url( $activation_url ); ?>" class="button-primary">
    206                 <?php echo esc_html( $button_text ); ?>
    207                 </a>
    208             </p>
    209         </div>
    210         <?php
    211     }
    212 
    213     /**
    214      * Check if a plugin is installed
    215      */
    216     public function is_plugin_installed( $basename ) {
    217         if ( ! function_exists( 'get_plugins' ) ) {
    218             include_once ABSPATH . '/wp-admin/includes/plugin.php';
    219         }
    220 
    221         $installed_plugins = get_plugins();
    222 
    223         return isset( $installed_plugins[ $basename ] );
    224     }
    225 
    226     /**
    227      * Admin notice
    228      *
    229      * Warning when the site doesn't have a minimum required Elementor version.
    230      */
    231     public function admin_notice_minimum_elementor_version() {
    232         ?>
    233         <div class="notice notice-warning is-dismissible">
    234             <p>
    235             <?php esc_html__( 'Elite Kit requires Elementor plugin version 3.15.3 or greater.', 'elite-kit' ); ?>
    236             </p>
    237         </div>
    238         <?php
    239     }
    240 
    241     /**
    242      * Admin notice
    243      *
    244      * Warning when the site doesn't have a minimum required PHP version.
    245      *
    246      * @access public
    247      */
    248     public function admin_notice_minimum_php_version() {
    249         ?>
    250         <div class="notice notice-warning is-dismissible">
    251             <p>
    252             <?php esc_html__( 'Elite Kit requires PHP version 7.4 or greater.', 'elite-kit' ); ?>
    253             </p>
    254         </div>
    255         <?php
    256     }
    257 
    258     /**
    259      * Register a widget category and move the category to top in the elementor widget panel.
    260      *
    261      * @param \Elementor\Elements_Manager $elements_manager
    262      *
    263      * @return void
    264      */
    265     public function register_category_order_to_top( \Elementor\Elements_Manager $elements_manager ) {
    266         // Add our categories.
    267         $category_prefix = 'elite-kit-';
    268         $prefix_length   = strlen( $category_prefix );
    269 
    270         $elements_manager->add_category(
    271             $category_prefix . 'widgets',
    272             array(
    273                 'title' => __( 'Elite Kit', 'elite-kit' ),
    274                 'icon'  => 'fa fa-plug',
    275             )
    276         );
    277 
    278         $reorder_cats = function () use ( $category_prefix, $prefix_length ) {
    279             uksort(
    280                 $this->categories,
    281                 function ( $key_one, $key_two ) use ( $category_prefix, $prefix_length ) {
    282                     if ( substr( $key_one, 0, $prefix_length ) == $category_prefix ) {
    283                         return - 1;
    284                     }
    285                     if ( substr( $key_two, 0, $prefix_length ) == $category_prefix ) {
    286                         return 1;
    287                     }
    288 
    289                     return 0;
    290                 }
    291             );
    292         };
    293 
    294         $reorder_cats->call( $elements_manager );
    295     }
    296 
    297     /**
    298      * Init Widgets
    299      *
    300      * Include widgets files and register them
    301      *
    302      * @since 1.0.0
    303      *
    304      * @access public
    305      */
    306 
    307     public static function on_widgets_registered( $widgets_manager = null ) {
    308         include_once EKL_PATH . '/base/widget-base.php';
    309 
    310         $inactive_widgets = \EliteKit\Elementor\Classes\Widgets_Manager::get_inactive_widgets();
    311 
    312         foreach ( \EliteKit\Elementor\Classes\Widgets_Manager::get_free_widgets_map() as $widget_key => $data ) {
    313             if ( ! in_array( $widget_key, $inactive_widgets ) ) {
    314                 self::register_widget( $widget_key, $widgets_manager );
    315             }
    316         }
    317 
    318         /**
    319          * After widgets registered.
    320          *
    321          * Fires after Elite Kit widgets are registered.
    322          *
    323          * @since 1.0.0
    324          *
    325          * @param \EliteKit\Elementor\Classes\Widgets_Manager $widgets_manager The widgets manager.
    326          */
    327         do_action( 'EliteKit/widgets/register', $widgets_manager );
    328     }
    329 
    330     protected static function register_widget( $widget_key, $widgets_manager = null ) {
    331         $widget_file    = EKL_PATH . '/widgets/' . $widget_key . '/widget.php';
    332         $active_widgets = get_option( 'widgets', \EliteKit\Elementor\Classes\Widgets_Manager::get_default_widgets() );
    333 
    334         if ( ! in_array( $widget_key, $active_widgets, true ) ) {
    335             return;
    336         }
    337         if ( is_readable( $widget_file ) ) {
    338 
    339             include_once $widget_file;
    340 
    341             $widget_class = '\EliteKit\Elementor\Widget\\' . str_replace( '-', '_', $widget_key );
    342 
    343             if ( class_exists( $widget_class ) ) {
    344                 $widgets_manager->register( new $widget_class() );
    345             }
    346         }
    347     }
    348 
    349     /**
    350      * Main EliteKit Instance.
    351      */
    352     public static function instance() {
    353         static $instance = false;
    354 
    355         if ( ! $instance ) {
    356             $instance = new self();
    357         }
    358     }
     33final class EliteKit
     34{
     35    const VERSION                   = '1.0.7';
     36    const MINIMUM_ELEMENTOR_VERSION = '3.34.0';
     37    const MINIMUM_PHP_VERSION       = '7.4';
     38
     39    public function __construct()
     40    {
     41        $this->init_plugin();
     42        register_activation_hook(__FILE__, array( $this, 'upon_activation' ));
     43    }
     44
     45    /**
     46     * Plugin activation hook.
     47     *
     48     * @access public
     49     */
     50    public function upon_activation()
     51    {
     52        $installed = get_option('elite_kit_lite_installed');
     53
     54        if (! $installed ) {
     55            update_option('elite_kit_lite_installed', time());
     56        }
     57
     58        update_option('elite_kit_lite_installed', EKL_VERSION);
     59    }
     60
     61    /**
     62     * Hook into actions and filters.
     63     *
     64     * @access private
     65     */
     66    private function init_plugin()
     67    {
     68        add_action('init', array( $this, 'load_textdomain' ));
     69
     70        $this->load_widget_manager();
     71
     72        add_action('plugins_loaded', array( $this, 'on_plugin_load' ));
     73
     74        // Declare WooCommerce HPOS compatibility
     75        add_action('before_woocommerce_init', array( $this, 'declare_woocommerce_hpos_compatibility' ));
     76
     77        // Prevent Elementor from being deactivated while Elite Kit is active
     78        add_filter('plugin_action_links_elementor/elementor.php', array( $this, 'disable_elementor_deactivation' ));
     79    }
     80
     81    /**
     82     * Disable Elementor deactivation link while Elite Kit is active.
     83     *
     84     * @param  array $actions Plugin action links.
     85     * @return array Modified action links.
     86     */
     87    public function disable_elementor_deactivation( $actions )
     88    {
     89        if (isset($actions['deactivate']) ) {
     90            $actions['deactivate'] = sprintf(
     91                '<span style="color: #a0a5aa; cursor: not-allowed;" title="%s">%s</span>',
     92                esc_attr__('Elite Kit requires Elementor. Please deactivate Elite Kit first.', 'elite-kit'),
     93                esc_html__('Deactivate', 'elite-kit')
     94            );
     95        }
     96        return $actions;
     97    }
     98
     99    /**
     100     * Load the plugin text domain for translation.
     101     */
     102    public function load_textdomain()
     103    {
     104        load_plugin_textdomain('elite-kit', false, plugin_basename(__DIR__) . '/languages');
     105    }
     106
     107    /**
     108     * Load the frontend class.
     109     */
     110    public function load_widget_manager()
     111    {
     112    }
     113
     114    /**
     115     * Declare compatibility with WooCommerce HPOS (High-Performance Order Storage).
     116     *
     117     * @return void
     118     */
     119    public function declare_woocommerce_hpos_compatibility()
     120    {
     121        if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class) ) {
     122            \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', EKL_FILE, true);
     123        }
     124    }
     125
     126    /**
     127     * Load the plugin after Elementor (and other plugins) are loaded.
     128     */
     129    public function on_plugin_load()
     130    {
     131
     132        //Function
     133        include EKL_PATH . '/inc/functions.php';
     134
     135        include EKL_PATH . '/base.php';
     136        \EliteKit\Base\Base::instance()->init();
     137
     138        if (! did_action('elementor/loaded') ) {
     139            add_action('admin_notices', array( $this, 'admin_notice_missing_main_plugin' ));
     140
     141            return;
     142        }
     143
     144        // Check for required Elementor version.
     145        if (! version_compare(ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=') ) {
     146            add_action('admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ));
     147
     148            return;
     149        }
     150
     151        // Check for required PHP version.
     152        if (version_compare(PHP_VERSION, self::MINIMUM_PHP_VERSION, '<') ) {
     153            add_action('admin_notices', array( $this, 'admin_notice_minimum_php_version' ));
     154
     155            return;
     156        }
     157        if (is_admin() ) {
     158            add_action('admin_enqueue_scripts', array( \EliteKit\Admin\Admin::class, 'load_admin_scripts' ));
     159        }
     160
     161        if (ek_is_adminbar_menu_enabled() ) {
     162            add_action('admin_enqueue_scripts', array( EliteKit\Elementor\Classes\Admin_Bar::class, 'enqueue_assets' ));
     163        }
     164
     165        add_action('elementor/editor/after_enqueue_scripts', array( EliteKit_Classes\Assets_Manager::class, 'register_widget_scripts' ));
     166        add_action('elementor/frontend/after_enqueue_scripts', array( EliteKit_Classes\Assets_Manager::class, 'enqueue_styles' ));
     167        add_action('wp_enqueue_scripts', array( EliteKit_Classes\Assets_Manager::class, 'frontend_register' ));
     168        add_action('wp_enqueue_scripts', array( EliteKit_Classes\Assets_Manager::class, 'frontend_enqueue' ), 99);
     169        add_action('elementor/css-file/post/enqueue', array( EliteKit_Classes\Assets_Manager::class, 'frontend_enqueue_exceptions' ));
     170
     171        // Add and move Elementor category.
     172        add_action('elementor/elements/categories_registered', array( $this, 'register_category_order_to_top' ));
     173
     174        // Register New Widgets.
     175        add_action('elementor/widgets/register', array( $this, 'on_widgets_registered' ));
     176    }
     177
     178
     179    /**
     180     * Admin notice
     181     *
     182     * Warning when the site doesn't have Elementor installed or activated.
     183     */
     184    public function admin_notice_missing_main_plugin()
     185    {
     186        if (! current_user_can('activate_plugins') ) {
     187            return;
     188        }
     189
     190        // Don't show on plugin installation, update, or activation pages
     191        global $pagenow;
     192        if (in_array($pagenow, array( 'update.php', 'plugins.php' ), true) ) {
     193            // Check if we're in the middle of installing/activating a plugin
     194            if (isset($_GET['action']) && in_array($_GET['action'], array( 'install-plugin', 'activate', 'activate-selected' ), true) ) {
     195                return;
     196            }
     197        }
     198
     199        if ($this->is_plugin_installed('elementor/elementor.php') ) {
     200            $activation_url = wp_nonce_url('plugins.php?action=activate&amp;plugin=elementor/elementor.php&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_elementor/elementor.php');
     201
     202            $message     = __('Elite Kit Addons for Elementor requires Elementor plugin to be active. Please activate Elementor to continue.', 'elite-kit');
     203            $button_text = __('Activate Elementor', 'elite-kit');
     204        } else {
     205            $activation_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
     206
     207            $message     = __('Elite Kit Addons for Elementor  requires Elementor  plugin to be installed and activated. Please install Elementor to continue.', 'elite-kit');
     208            $button_text = __('Install Elementor', 'elite-kit');
     209        }
     210        ?>
     211
     212        <div class="error">
     213            <p><?php echo esc_html($message); ?></p>
     214            <p>
     215                <a href="<?php echo esc_url($activation_url); ?>" class="button-primary">
     216        <?php echo esc_html($button_text); ?>
     217                </a>
     218            </p>
     219        </div>
     220        <?php
     221    }
     222
     223    /**
     224     * Check if a plugin is installed
     225     */
     226    public function is_plugin_installed( $basename )
     227    {
     228        if (! function_exists('get_plugins') ) {
     229            include_once ABSPATH . '/wp-admin/includes/plugin.php';
     230        }
     231
     232        $installed_plugins = get_plugins();
     233
     234        return isset($installed_plugins[ $basename ]);
     235    }
     236
     237    /**
     238     * Admin notice
     239     *
     240     * Warning when the site doesn't have a minimum required Elementor version.
     241     */
     242    public function admin_notice_minimum_elementor_version()
     243    {
     244        ?>
     245        <div class="notice notice-warning is-dismissible">
     246            <p>
     247        <?php esc_html__('Elite Kit requires Elementor plugin version 3.15.3 or greater.', 'elite-kit'); ?>
     248            </p>
     249        </div>
     250        <?php
     251    }
     252
     253    /**
     254     * Admin notice
     255     *
     256     * Warning when the site doesn't have a minimum required PHP version.
     257     *
     258     * @access public
     259     */
     260    public function admin_notice_minimum_php_version()
     261    {
     262        ?>
     263        <div class="notice notice-warning is-dismissible">
     264            <p>
     265        <?php esc_html__('Elite Kit requires PHP version 7.4 or greater.', 'elite-kit'); ?>
     266            </p>
     267        </div>
     268        <?php
     269    }
     270
     271    /**
     272     * Register a widget category and move the category to top in the elementor widget panel.
     273     *
     274     * @param \Elementor\Elements_Manager $elements_manager
     275     *
     276     * @return void
     277     */
     278    public function register_category_order_to_top( \Elementor\Elements_Manager $elements_manager )
     279    {
     280        // Add our categories.
     281        $category_prefix = 'elite-kit-';
     282        $prefix_length   = strlen($category_prefix);
     283
     284        $elements_manager->add_category(
     285            $category_prefix . 'widgets',
     286            array(
     287            'title' => __('Elite Kit', 'elite-kit'),
     288            'icon'  => 'fa fa-plug',
     289            )
     290        );
     291
     292        $reorder_cats = function () use ( $category_prefix, $prefix_length ) {
     293            uksort(
     294                $this->categories,
     295                function ( $key_one, $key_two ) use ( $category_prefix, $prefix_length ) {
     296                    if (substr($key_one, 0, $prefix_length) == $category_prefix ) {
     297                            return - 1;
     298                    }
     299                    if (substr($key_two, 0, $prefix_length) == $category_prefix ) {
     300                        return 1;
     301                    }
     302
     303                    return 0;
     304                }
     305            );
     306        };
     307
     308        $reorder_cats->call($elements_manager);
     309    }
     310
     311    /**
     312     * Init Widgets
     313     *
     314     * Include widgets files and register them
     315     *
     316     * @since 1.0.0
     317     *
     318     * @access public
     319     */
     320    public static function on_widgets_registered( $widgets_manager = null )
     321    {
     322        include_once EKL_PATH . '/base/widget-base.php';
     323
     324        $inactive_widgets = \EliteKit\Elementor\Classes\Widgets_Manager::get_inactive_widgets();
     325
     326        foreach ( \EliteKit\Elementor\Classes\Widgets_Manager::get_free_widgets_map() as $widget_key => $data ) {
     327            if (! in_array($widget_key, $inactive_widgets) ) {
     328                self::register_widget($widget_key, $widgets_manager);
     329            }
     330        }
     331
     332        /**
     333         * After widgets registered.
     334         *
     335         * Fires after Elite Kit widgets are registered.
     336         *
     337         * @since 1.0.0
     338         *
     339         * @param \EliteKit\Elementor\Classes\Widgets_Manager $widgets_manager The widgets manager.
     340         */
     341        do_action('EliteKit/widgets/register', $widgets_manager);
     342    }
     343
     344    protected static function register_widget( $widget_key, $widgets_manager = null )
     345    {
     346        $widget_file    = EKL_PATH . '/widgets/' . $widget_key . '/widget.php';
     347        $active_widgets = get_option('widgets', \EliteKit\Elementor\Classes\Widgets_Manager::get_default_widgets());
     348
     349        if (! in_array($widget_key, $active_widgets, true) ) {
     350            return;
     351        }
     352        if (is_readable($widget_file) ) {
     353
     354            include_once $widget_file;
     355
     356            $widget_class = '\EliteKit\Elementor\Widget\\' . str_replace('-', '_', $widget_key);
     357
     358            if (class_exists($widget_class) ) {
     359                $widgets_manager->register(new $widget_class());
     360            }
     361        }
     362    }
     363
     364    /**
     365     * Main EliteKit Instance.
     366     */
     367    public static function instance()
     368    {
     369        static $instance = false;
     370
     371        if (! $instance ) {
     372            $instance = new self();
     373        }
     374    }
    359375}
    360376
     
    363379 */
    364380EliteKit::instance();
    365 // TODO: Show some messages if pro plugin is installed but not activated
    366 // TODO: In the admin menu, show 'pro' right beside settings and plugin info,like essential addons
    367 // TODO: @arafat Add the get pro button in the plugin activation button list
    368 
    369 // TODO: @arafat, integrate appsero to the plugin
    370 
    371 // TODO: @arafat at the dashboad and widgets loaders, use actions and filters with pro and free plugins.
    372 
    373 // TODO: @momin Test if TailwindCSS style breaks other theme setups or not.
    374 // TODO: @momin, when loading assets, create a folder for the vendor, and load third party libraries from there.
    375 
    376 // TODO: @arafat, remove the following code in production
    377 // TODO: @arafat, code with with activation hook, then use a filter in pro version, to change stuffs
    378 
    379 // TODO: @arafat, @momin, get feature ideas from https://feedback.bdthemes.com/b/6vr2250l/feature-requests
    380 //TODO: @momin create demos like this - https://demo.happyaddons.com/elementor-slider-widget-demo and add those to the menu items in the dashboard and the landing page
    381 
    382 
    383 //TODO: @arafat, learn how to do github tag release.
    384 
    385 //TODO: @arafat, plan out free vs pro features.
Note: See TracChangeset for help on using the changeset viewer.