load_dependencies(); $this->init_hooks(); } /** * Load required class files. */ private function load_dependencies() { foreach ( array( 'connection', 'catalog', 'connection-admin', 'orders', 'events', 'renderer', 'agent-commerce', 'agent-discovery' ) as $module ) { require_once SELECTIKA_PLUGIN_DIR . 'includes/class-selectika-' . $module . '.php'; } require_once SELECTIKA_PLUGIN_DIR . 'includes/class-selectika-loader.php'; require_once SELECTIKA_PLUGIN_DIR . 'includes/class-selectika-admin.php'; require_once SELECTIKA_PLUGIN_DIR . 'includes/class-selectika-shortcode.php'; require_once SELECTIKA_PLUGIN_DIR . 'includes/class-selectika-block.php'; require_once SELECTIKA_PLUGIN_DIR . 'includes/class-selectika-woocommerce.php'; } /** * Initialize hooks. */ private function init_hooks() { add_action( 'init', array( $this, 'init_components' ), 1 ); } /** * Initialize plugin components. */ public function init_components() { if ( get_option( 'selectika_schema_version' ) !== SELECTIKA_SCHEMA_VERSION ) { Selectika_Catalog::install(); Selectika_Orders::install(); Selectika_Events::install(); update_option( 'selectika_schema_version', SELECTIKA_SCHEMA_VERSION, false ); } $catalog = new Selectika_Catalog(); add_action( 'selectika_catalog_continue', array( $catalog, 'tick' ) ); Selectika_Catalog::schedule(); new Selectika_Connection_Admin(); new Selectika_Events(); new Selectika_Orders(); new Selectika_Agent_Commerce(); new Selectika_Agent_Discovery(); $this->loader = new Selectika_Loader(); $this->admin = new Selectika_Admin(); $this->shortcode = new Selectika_Shortcode(); $this->block = new Selectika_Block(); if ( class_exists( 'WooCommerce' ) ) { $this->woocommerce = new Selectika_WooCommerce(); } if ( defined( 'ELEMENTOR_VERSION' ) || class_exists( '\Elementor\Plugin' ) ) { add_action( 'elementor/widgets/register', array( $this, 'maybe_init_elementor' ) ); } else { add_action( 'elementor/loaded', array( $this, 'register_elementor_hook' ) ); } } /** * Register Elementor hook when Elementor loads late. */ public function register_elementor_hook() { add_action( 'elementor/widgets/register', array( $this, 'maybe_init_elementor' ) ); } /** * Initialize Elementor integration when Elementor registers widgets. * * @param \Elementor\Widgets_Manager $widgets_manager Widgets manager. */ public function maybe_init_elementor( $widgets_manager ) { require_once SELECTIKA_PLUGIN_DIR . 'widgets/class-selectika-elementor-widget.php'; $widgets_manager->register( new Selectika_Elementor_Widget() ); } /** * Get the loader instance. * * @return Selectika_Loader */ public function get_loader() { return $this->loader; } /** * Get the admin instance. * * @return Selectika_Admin */ public function get_admin() { return $this->admin; } /** * Get the shortcode instance. * * @return Selectika_Shortcode */ public function get_shortcode() { return $this->shortcode; } /** * Get the block instance. * * @return Selectika_Block */ public function get_block() { return $this->block; } /** * Get the WooCommerce instance. * * @return Selectika_WooCommerce|null */ public function get_woocommerce() { return $this->woocommerce; } }