Repository URL to install this package:
<?php
/**
* Plugin Name: JetProductGallery For Elementor
* Plugin URI: https://crocoblock.com/plugins/jetproductgallery/
* Description: Your perfect tool for creating WooCommerce Single Product Gallery
* Version: 1.2.3
* Author: Crocoblock
* Author URI: https://crocoblock.com/
* Text Domain: jet-woo-product-gallery
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
*
* Elementor tested up to: 3.1
* Elementor Pro tested up to: 3.2
*
* WC tested up to: 5.1
* WC requires at least: 3.0
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die();
}
// If class `Jet_Woo_Product_Gallery` doesn't exists yet.
if ( ! class_exists( 'Jet_Woo_Product_Gallery' ) ) {
/**
* Sets up and initializes the plugin.
*/
class Jet_Woo_Product_Gallery {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @access private
* @var object
*/
private static $instance = null;
/**
* Plugin version
*
* @var string
*/
private $version = '1.2.3';
/**
* Holder for base plugin path
*
* @since 1.0.0
* @access private
* @var string
*/
private $plugin_path = null;
/**
* Holder for base plugin URL
*
* @since 1.0.0
* @access private
* @var string
*/
private $plugin_url = null;
/**
* Framework loader instance
*
* @var object
*/
public $module_loader;
/**
* Sets up needed actions/filters for the plugin to initialize.
*
* @return void
* @since 1.0.0
* @access public
*/
public function __construct() {
// Load the core functions/classes required by the rest of the plugin.
add_action( 'after_setup_theme', array( $this, 'module_loader' ), -20 );
// Internationalize the text strings used.
add_action( 'init', array( $this, 'lang' ), -999 );
// Load files.
add_action( 'init', array( $this, 'init' ), -999 );
// Jet Dashboard Init
add_action( 'init', array( $this, 'jet_dashboard_init' ), -999 );
// Register activation and deactivation hook.
register_activation_hook( __FILE__, array( $this, 'activation' ) );
register_deactivation_hook( __FILE__, array( $this, 'deactivation' ) );
}
/**
* Load plugin framework
*/
public function module_loader() {
require $this->plugin_path( 'includes/modules/loader.php' );
$this->module_loader = new Jet_Woo_Product_Gallery_CX_Loader(
array(
$this->plugin_path( 'includes/modules/interface-builder/cherry-x-interface-builder.php' ),
$this->plugin_path( 'includes/modules/post-meta/cherry-x-post-meta.php' ),
$this->plugin_path( 'includes/modules/vue-ui/cherry-x-vue-ui.php' ),
$this->plugin_path( 'includes/modules/jet-dashboard/jet-dashboard.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_product_gallery_assets()->init();
jet_woo_product_gallery_integration()->init();
jet_woo_gallery_video_integration()->init();
jet_woo_product_gallery_settings()->init();
add_action( 'wp_footer', array( $this, 'photoswipe_template' ) );
//Init Rest Api
new \Jet_Woo_Product_Gallery\Rest_Api();
if ( is_admin() ) {
if ( ! $this->has_elementor() || ! class_exists( 'WooCommerce' ) ) {
$this->required_plugins_notice();
}
//Init JetWooProductGallery Settings
new \Jet_Woo_Product_Gallery\Settings();
}
}
}
/**
* JetDashboard module initialize
*
* @return void
*/
public function jet_dashboard_init() {
if ( is_admin() ) {
$jet_dashboard_module_data = $this->module_loader->get_included_module_data( 'jet-dashboard.php' );
$jet_dashboard = \Jet_Dashboard\Dashboard::get_instance();
$jet_dashboard->init(
array(
'path' => $jet_dashboard_module_data['path'],
'url' => $jet_dashboard_module_data['url'],
'cx_ui_instance' => array( $this, 'jet_dashboard_ui_instance_init' ),
'plugin_data' => array(
'slug' => 'jet-woo-product-gallery',
'file' => 'jet-woo-product-gallery/jet-woo-product-gallery.php',
'version' => $this->get_version(),
'plugin_links' => array(
array(
'label' => esc_html__( 'Go to settings', 'jet-woo-product-gallery' ),
'url' => add_query_arg( array( 'page' => 'jet-dashboard-settings-page', 'subpage' => 'jet-woo-product-gallery-avaliable-addons' ), admin_url( 'admin.php' ) ),
'target' => '_self',
),
),
),
)
);
}
}
/**
* JetDashboard module UI instance initialize
*
* @return object
*/
public function jet_dashboard_ui_instance_init() {
$cx_ui_module_data = $this->module_loader->get_included_module_data( 'cherry-x-vue-ui.php' );
return new CX_Vue_UI( $cx_ui_module_data );
}
/**
* Require photoswipe template.
*
* @return void
*/
public function photoswipe_template() {
require $this->plugin_path( 'templates/photoswipe.php' );
}
/**
* 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' => 'jet-woo-product-gallery',
'default_path' => '',
'menu' => 'jet-woo-product-gallery-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(
'Jet Product Gallery for Elementor requires the following plugin: %1$s.',
'Jet Product Gallery for Elementor requires the following plugins: %1$s.',
'jet-woo-product-gallery'
),
'notice_can_install_recommended' => _n_noop(
'Jet Product Gallery for Elementor recommends the following plugin: %1$s.',
'Jet Product Gallery for Elementor recommends the following plugins: %1$s.',
'jet-woo-product-gallery'
),
),
);
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-product-gallery-assets.php' );
require $this->plugin_path( 'includes/class-jet-woo-product-gallery-tools.php' );
require $this->plugin_path( 'includes/class-jet-woo-product-gallery-functions.php' );
require $this->plugin_path( 'includes/integrations/class-jet-woo-product-gallery-integration.php' );
require $this->plugin_path( 'includes/integrations/class-jet-woo-gallery-video-integration.php' );
require $this->plugin_path( 'includes/settings/class-jet-woo-product-gallery-settings.php' );
require $this->plugin_path( 'includes/settings/jet-dashboard-settings/manager.php' );
require $this->plugin_path( 'includes/rest-api/rest-api.php' );
require $this->plugin_path( 'includes/rest-api/endpoints/base.php' );
require $this->plugin_path( 'includes/rest-api/endpoints/plugin-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
Loading ...