plugin_path( 'framework/loader.php' ); $this->framework = new Jet_Woo_Widgets_CX_Loader( array( $this->plugin_path( 'framework/interface-builder/cherry-x-interface-builder.php' ), ) ); } /** * Returns plugin version * * @return string */ public function get_version() { return $this->version; } /** * Manually init required modules. * * @return void */ public function init() { if ( class_exists( 'WooCommerce' ) ) { $this->load_files(); jet_woo_widgets_assets()->init(); jet_woo_widgets_integration()->init(); jet_woo_widgets_settings()->init(); jet_woo_widgets_shortocdes()->init(); } if ( is_admin() ) { if ( ! $this->has_elementor() ) { $this->required_plugins_notice(); } } } /** * Show recommended plugins notice. * * @return void */ public function required_plugins_notice() { require $this->plugin_path( 'includes/lib/class-tgm-plugin-activation.php' ); add_action( 'tgmpa_register', array( $this, 'register_required_plugins' ) ); } /** * Register required plugins * * @return void */ public function register_required_plugins() { $plugins = array( array( 'name' => 'Elementor', 'slug' => 'elementor', 'required' => true, ), array( 'name' => 'WooCommerce', 'slug' => 'woocommerce', 'required' => true, ), ); $config = array( 'id' => 'jetwoo-widgets-for-elementor', 'default_path' => '', 'menu' => 'jet-woo-widgets-install-plugins', 'parent_slug' => 'plugins.php', 'capability' => 'manage_options', 'has_notices' => true, 'dismissable' => true, 'dismiss_msg' => '', 'is_automatic' => false, 'strings' => array( 'notice_can_install_required' => _n_noop( 'JetWoo Widgets for Elementor requires the following plugin: %1$s.', 'JetWoo Widgets for Elementor requires the following plugins: %1$s.', 'jetwoo-widgets-for-elementor' ), 'notice_can_install_recommended' => _n_noop( 'JetWoo Widgets for Elementor recommends the following plugin: %1$s.', 'JetWoo Widgets for Elementor recommends the following plugins: %1$s.', 'jetwoo-widgets-for-elementor' ), ), ); tgmpa( $plugins, $config ); } /** * Check if theme has elementor * * @return boolean */ public function has_elementor() { return defined( 'ELEMENTOR_VERSION' ); } /** * Returns utility instance * * @return object */ public function utility() { $utility = $this->get_core()->modules['cherry-utility']; return $utility->utility; } /** * Load required files. * * @return void */ public function load_files() { require $this->plugin_path( 'includes/class-jet-woo-widgets-assets.php' ); require $this->plugin_path( 'includes/class-jet-woo-widgets-tools.php' ); require $this->plugin_path( 'includes/integrations/base/class-jet-woo-widgets-integration.php' ); require $this->plugin_path( 'includes/class-jet-woo-widgets-template-functions.php' ); require $this->plugin_path( 'includes/class-jet-woo-widgets-shortcodes.php' ); require $this->plugin_path( 'includes/settings/class-jet-woo-widgets-settings.php' ); } /** * Returns path to file or dir inside plugin folder * * @param string $path Path inside plugin dir. * @return string */ public function plugin_path( $path = null ) { if ( ! $this->plugin_path ) { $this->plugin_path = trailingslashit( plugin_dir_path( __FILE__ ) ); } return $this->plugin_path . $path; } /** * Returns url to file or dir inside plugin folder * * @param string $path Path inside plugin dir. * @return string */ public function plugin_url( $path = null ) { if ( ! $this->plugin_url ) { $this->plugin_url = trailingslashit( plugin_dir_url( __FILE__ ) ); } return $this->plugin_url . $path; } /** * Loads the translation files. * * @since 1.0.0 * @access public * @return void */ public function lang() { load_plugin_textdomain( 'jetwoo-widgets-for-elementor', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } /** * Get the template path. * * @return string */ public function template_path() { return apply_filters( 'jet-woo-widgets/template-path', 'jet-woo-widgets/' ); } /** * Returns path to template file. * * @return string|bool */ public function get_template( $name = null ) { $template = locate_template( $this->template_path() . $name ); if ( ! $template ) { $template = $this->plugin_path( 'templates/' . $name ); } if ( file_exists( $template ) ) { return $template; } else { return false; } } /** * Do some stuff on plugin activation * * @since 1.0.0 * @return void */ public function activation() { } /** * Do some stuff on plugin activation * * @since 1.0.0 * @return void */ public function deactivation() { } /** * Returns the instance. * * @since 1.0.0 * @access public * @return object */ public static function get_instance() { // If the single instance hasn't been set, set it now. if ( null == self::$instance ) { self::$instance = new self; } return self::$instance; } } } if ( ! function_exists( 'jet_woo_widgets' ) ) { /** * Returns instanse of the plugin class. * * @since 1.0.0 * @return object */ function jet_woo_widgets() { return Jet_Woo_Widgets::get_instance(); } } jet_woo_widgets();