first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Product_Gallery_Assets' ) ) {
/**
* Define Jet_Woo_Product_Gallery_Assets class
*/
class Jet_Woo_Product_Gallery_Assets {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Constructor for the class
*/
public function init() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
add_action( 'elementor/frontend/before_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'elementor/frontend/after_enqueue_scripts', array(
'WC_Frontend_Scripts',
'localize_printed_scripts'
), 5 );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
}
public function enqueue_admin_assets() {
wp_enqueue_style(
'jet-woo-product-gallery-admin',
jet_woo_product_gallery()->plugin_url( 'assets/css/admin.css' ),
false,
jet_woo_product_gallery()->get_version()
);
}
/**
* Enqueue public-facing stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
public function enqueue_styles() {
if ( is_rtl() ) {
wp_enqueue_style(
'jet-woo-product-gallery',
jet_woo_product_gallery()->plugin_url( 'assets/css/jet-woo-product-gallery-rtl.css' ),
false,
jet_woo_product_gallery()->get_version()
);
} else {
wp_enqueue_style(
'jet-woo-product-gallery',
jet_woo_product_gallery()->plugin_url( 'assets/css/jet-woo-product-gallery.css' ),
false,
jet_woo_product_gallery()->get_version()
);
}
}
/**
* Enqueue plugin scripts only with elementor scripts
*
* @return void
*/
public function enqueue_scripts() {
wp_enqueue_script(
'jet-woo-product-gallery',
jet_woo_product_gallery()->plugin_url( 'assets/js/jet-woo-product-gallery.js' ),
array( 'jquery', 'elementor-frontend' ),
jet_woo_product_gallery()->get_version(),
true
);
wp_localize_script(
'jet-woo-product-gallery',
'jetWooProductGalleryData',
apply_filters( 'jet-woo-product-gallery/frontend/localize-data', array() )
);
}
/**
* Returns the instance.
*
* @since 1.0.0
* @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;
}
}
}
/**
* Returns instance of Jet_Woo_Product_Gallery_Assets
*
* @return object
*/
function jet_woo_product_gallery_assets() {
return Jet_Woo_Product_Gallery_Assets::get_instance();
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Gallery functions class
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Product_Gallery_Functions' ) ) {
/**
* Define Jet_Woo_Product_Gallery_Functions class
*/
class Jet_Woo_Product_Gallery_Functions {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
public function get_gallery_trigger_button( $icon = 'fa fa-search' ) {
echo '<a href="#" class="jet-woo-product-gallery__trigger">';
echo sprintf( '<i class="jet-woo-product-gallery__trigger-icon %s"></i>', $icon );
echo '</a>';
}
/**
* Returns carousel arrow
*
* @param array $classes Arrow additional classes list.
*
* @return string
*/
public function get_slider_arrow( $classes ) {
$format = apply_filters( 'jet-woo-product-gallery/slider/arrows-format', '<i class="%s jet-woo-slick-slider-arrow__icon"></i>', $classes );
return sprintf( $format, implode( ' ', $classes ) );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $shortcodes = array() ) {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self( $shortcodes );
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Woo_Product_Gallery_Functions
*
* @return object
*/
function jet_woo_product_gallery_functions() {
return Jet_Woo_Product_Gallery_Functions::get_instance();
}

View File

@@ -0,0 +1,372 @@
<?php
/**
* Jet Product Gallery tools class
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Product_Gallery_Tools' ) ) {
/**
* Define Jet_Woo_Product_Gallery_Tools class
*/
class Jet_Woo_Product_Gallery_Tools {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Returns columns classes string
*
* @param [type] $columns [description]
*
* @return [type] [description]
*/
public function col_classes( $columns = array() ) {
$columns = wp_parse_args( $columns, array(
'desk' => 1,
'tab' => 1,
'mob' => 1,
) );
$classes = array();
foreach ( $columns as $device => $cols ) {
if ( ! empty( $cols ) ) {
$classes[] = sprintf( 'col-%1$s-%2$s', $device, $cols );
}
}
return implode( ' ', $classes );
}
/**
* Returns disable columns gap nad rows gap classes string
*
* @param string $use_cols_gap [description]
* @param string $use_rows_gap [description]
*
* @return [type] [description]
*/
public function gap_classes( $use_cols_gap = 'yes', $use_rows_gap = 'yes' ) {
$result = array();
foreach ( array( 'cols' => $use_cols_gap, 'rows' => $use_rows_gap ) as $element => $value ) {
if ( 'yes' !== $value ) {
$result[] = sprintf( 'disable-%s-gap', $element );
}
}
return implode( ' ', $result );
}
/**
* Returns image size array in slug => name format
*
* @return array
*/
public function get_image_sizes() {
global $_wp_additional_image_sizes;
$sizes = get_intermediate_image_sizes();
$result = array();
foreach ( $sizes as $size ) {
if ( in_array( $size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
$result[ $size ] = ucwords( trim( str_replace( array( '-', '_' ), array( ' ', ' ' ), $size ) ) );
} else {
$result[ $size ] = sprintf(
'%1$s (%2$sx%3$s)',
ucwords( trim( str_replace( array( '-', '_' ), array( ' ', ' ' ), $size ) ) ),
$_wp_additional_image_sizes[ $size ]['width'],
$_wp_additional_image_sizes[ $size ]['height']
);
}
}
return array_merge( array( 'full' => esc_html__( 'Full', 'jet-woo-product-gallery' ), ), $result );
}
/**
* Returns icons data list.
*
* @return array
*/
public function get_theme_icons_data() {
$default = array(
'icons' => false,
'format' => 'fa %s',
'file' => false,
);
/**
* Filter default icon data before useing
*
* @var array
*/
$icon_data = apply_filters( 'jet-woo-product-gallery/controls/icon/data', $default );
$icon_data = array_merge( $default, $icon_data );
return $icon_data;
}
/**
* Returns allowed order by fields for options
*
* @return array
*/
public function verrtical_align_attr() {
return array(
'baseline' => esc_html__( 'Baseline', 'jet-woo-product-gallery' ),
'top' => esc_html__( 'Top', 'jet-woo-product-gallery' ),
'middle' => esc_html__( 'Middle', 'jet-woo-product-gallery' ),
'bottom' => esc_html__( 'Bottom', 'jet-woo-product-gallery' ),
'sub' => esc_html__( 'Sub', 'jet-woo-product-gallery' ),
'super' => esc_html__( 'Super', 'jet-woo-product-gallery' ),
'text-top' => esc_html__( 'Text Top', 'jet-woo-product-gallery' ),
'text-bottom' => esc_html__( 'Text Bottom', 'jet-woo-product-gallery' ),
);
}
/**
* Returns array with numbers in $index => $name format for numeric selects
*
* @param integer $to Max numbers
*
* @return array
*/
public function get_select_range( $to = 10 ) {
$range = range( 1, $to );
return array_combine( $range, $range );
}
/**
* Rturns image tag or raw SVG
*
* @param string $url image URL.
* @param array $attr [description]
*
* @return string
*/
public function get_image_by_url( $url = null, $attr = array() ) {
$url = esc_url( $url );
if ( empty( $url ) ) {
return;
}
$ext = pathinfo( $url, PATHINFO_EXTENSION );
$attr = array_merge( array( 'alt' => '' ), $attr );
if ( 'svg' !== $ext ) {
return sprintf( '<img src="%1$s"%2$s>', $url, $this->get_attr_string( $attr ) );
}
$base_url = network_site_url( '/' );
$svg_path = str_replace( $base_url, ABSPATH, $url );
$key = md5( $svg_path );
$svg = get_transient( $key );
if ( ! $svg ) {
$svg = file_get_contents( $svg_path );
}
if ( ! $svg ) {
return sprintf( '<img src="%1$s"%2$s>', $url, $this->get_attr_string( $attr ) );
}
set_transient( $key, $svg, DAY_IN_SECONDS );
unset( $attr['alt'] );
return sprintf( '<div%2$s>%1$s</div>', $svg, $this->get_attr_string( $attr ) );;
}
/**
* Return attributes string from attributes array.
*
* @param array $attr Attributes string.
* @return string
*/
public function get_attr_string( $attr = array() ) {
if ( empty( $attr ) || ! is_array( $attr ) ) {
return;
}
$result = '';
foreach ( $attr as $key => $value ) {
$result .= sprintf( ' %s="%s"', esc_attr( $key ), esc_attr( $value ) );
}
return $result;
}
/**
* Get post types options list
*
* @return array
*/
public function get_post_types() {
$post_types = get_post_types( array( 'public' => true ), 'objects' );
$deprecated = apply_filters(
'jet-woo-product-gallery/post-types-list/deprecated',
array( 'attachment', 'elementor_library' )
);
$result = array();
if ( empty( $post_types ) ) {
return $result;
}
foreach ( $post_types as $slug => $post_type ) {
if ( in_array( $slug, $deprecated ) ) {
continue;
}
$result[ $slug ] = $post_type->label;
}
return $result;
}
/**
* Return availbale arrows list
* @return [type] [description]
*/
public function get_available_prev_arrows_list() {
return apply_filters(
'jet-woo-product-gallery/carousel/available-arrows/prev',
array(
'fa fa-angle-left' => __( 'Angle', 'jet-woo-product-gallery' ),
'fa fa-chevron-left' => __( 'Chevron', 'jet-woo-product-gallery' ),
'fa fa-angle-double-left' => __( 'Angle Double', 'jet-woo-product-gallery' ),
'fa fa-arrow-left' => __( 'Arrow', 'jet-woo-product-gallery' ),
'fa fa-caret-left' => __( 'Caret', 'jet-woo-product-gallery' ),
'fa fa-long-arrow-left' => __( 'Long Arrow', 'jet-woo-product-gallery' ),
'fa fa-arrow-circle-left' => __( 'Arrow Circle', 'jet-woo-product-gallery' ),
'fa fa-chevron-circle-left' => __( 'Chevron Circle', 'jet-woo-product-gallery' ),
'fa fa-caret-square-o-left' => __( 'Caret Square', 'jet-woo-product-gallery' ),
)
);
}
/**
* Return availbale arrows list
* @return [type] [description]
*/
public function get_available_next_arrows_list() {
return apply_filters(
'jet-woo-product-gallery/carousel/available-arrows/next',
array(
'fa fa-angle-right' => __( 'Angle', 'jet-woo-product-gallery' ),
'fa fa-chevron-right' => __( 'Chevron', 'jet-woo-product-gallery' ),
'fa fa-angle-double-right' => __( 'Angle Double', 'jet-woo-product-gallery' ),
'fa fa-arrow-right' => __( 'Arrow', 'jet-woo-product-gallery' ),
'fa fa-caret-right' => __( 'Caret', 'jet-woo-product-gallery' ),
'fa fa-long-arrow-right' => __( 'Long Arrow', 'jet-woo-product-gallery' ),
'fa fa-arrow-circle-right' => __( 'Arrow Circle', 'jet-woo-product-gallery' ),
'fa fa-chevron-circle-right' => __( 'Chevron Circle', 'jet-woo-product-gallery' ),
'fa fa-caret-square-o-right' => __( 'Caret Square', 'jet-woo-product-gallery' ),
)
);
}
/**
* Trim text
*
* @since 1.0.0
* @return string
*/
public function trim_text( $text = '', $length = - 1, $trimmed_type = 'word', $after ) {
if ( '' === $text ) {
return $text;
}
if ( 0 === $length ) {
return '';
}
if ( - 1 !== $length ) {
if ( 'word' === $trimmed_type ) {
$text = wp_trim_words( $text, $length, $after );
} else {
$text = wp_html_excerpt( $text, $length, $after );
}
}
return $text;
}
public function is_builder_content_save() {
if ( ! isset( $_REQUEST['action'] ) || 'elementor_ajax' !== $_REQUEST['action'] ) {
return false;
}
if ( empty( $_REQUEST['actions'] ) ) {
return false;
}
if ( false === strpos( $_REQUEST['actions'], 'save_builder' ) ) {
return false;
}
return true;
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $shortcodes = array() ) {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self( $shortcodes );
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Woo_Product_Gallery_Tools
*
* @return object
*/
function jet_woo_product_gallery_tools() {
return Jet_Woo_Product_Gallery_Tools::get_instance();
}

View File

@@ -0,0 +1,178 @@
<?php
/**
* Class Jet Woo Gallery Video Integration
*
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Gallery_Video_Integration' ) ) {
/**
* Define Jet_Woo_Gallery_Video_Integration_class
*/
class Jet_Woo_Gallery_Video_Integration {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @access private
* @var object
*/
private static $instance = null;
/**
* Constructor for the class
*/
public function init() {
add_action( 'init', array( $this, 'add_product_meta' ), 99 );
}
/**
* Initialize template metabox
*
* @return void
*/
public function add_product_meta() {
new Cherry_X_Post_Meta( array(
'id' => 'gallery-video-settings',
'title' => esc_html__( 'Jet Product Gallery Video', 'jet-woo-product-gallery' ),
'page' => array( 'product' ),
'context' => 'side',
'priority' => 'low',
'callback_args' => false,
'builder_cb' => array( $this, 'get_builder' ),
'fields' => array(
'_jet_woo_product_video_type' => array(
'type' => 'select',
'element' => 'control',
'value' => 'youtube',
'options' => array(
'youtube' => __( 'Youtube', 'jet-woo-product-gallery' ),
'vimeo' => __( 'Vimeo', 'jet-woo-product-gallery' ),
'self_hosted' => __( 'Self Hosted', 'jet-woo-product-gallery' ),
),
'label' => __( 'Video Type:', 'jet-woo-product-gallery' ),
'class' => 'jet-woo-product-gallery-cx-select'
),
'_jet_woo_product_video_placeholder' => array(
'label' => __( 'Placeholder:', 'jet-woo-product-gallery' ),
'type' => 'media',
'element' => 'control',
'upload_button_text' => __( 'Choose Placeholder', 'jet-woo-product-gallery' ),
'multi_upload' => false,
'class' => 'jet-woo-product-gallery-cx-text'
),
'_jet_woo_product_vimeo_video_url' => array(
'label' => __( 'Video URL:', 'jet-woo-product-gallery' ),
'type' => 'text',
'element' => 'control',
'conditions' => array(
'_jet_woo_product_video_type' => 'vimeo',
),
),
'_jet_woo_product_youtube_video_url' => array(
'label' => __( 'Video URL:', 'jet-woo-product-gallery' ),
'type' => 'text',
'element' => 'control',
'conditions' => array(
'_jet_woo_product_video_type' => 'youtube',
),
),
'_jet_woo_product_self_hosted_video' => array(
'label' => __( 'Video:', 'jet-woo-product-gallery' ),
'type' => 'media',
'element' => 'control',
'upload_button_text' => __( 'Choose Video', 'jet-woo-product-gallery' ),
'multi_upload' => false,
'library_type' => 'video',
'conditions' => array(
'_jet_woo_product_video_type' => 'self_hosted',
),
),
),
) );
}
/**
* Return UI builder instance
*
* @return [type] [description]
*/
public function get_builder() {
$builder_data = jet_woo_product_gallery()->framework->get_included_module_data( 'cherry-x-interface-builder.php' );
return new CX_Interface_Builder(
array(
'path' => $builder_data['path'],
'url' => $builder_data['url'],
)
);
}
public function get_video_type() {
global $_product;
return get_post_field( '_jet_woo_product_video_type', $_product->get_id() );
}
public function get_video_custom_placeholder() {
global $_product;
return get_post_field( '_jet_woo_product_video_placeholder', $_product->get_id() );
}
public function get_youtube_video_url() {
global $_product;
return get_post_field( '_jet_woo_product_youtube_video_url', $_product->get_id() );
}
public function get_vimeo_video_url() {
global $_product;
return get_post_field( '_jet_woo_product_vimeo_video_url', $_product->get_id() );
}
public function get_self_hosted_video_id() {
global $_product;
return get_post_field( '_jet_woo_product_self_hosted_video', $_product->get_id() );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @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;
}
}
}
/**
* Returns instance of Jet_Woo_Gallery_Video_Integration
*
* @return object
*/
function jet_woo_gallery_video_integration() {
return Jet_Woo_Gallery_Video_Integration::get_instance();
}

View File

@@ -0,0 +1,199 @@
<?php
/**
* Class description
*
* @package package_name
* @author Cherry Team
* @license GPL-2.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Product_Gallery_Integration' ) ) {
/**
* Define Jet_Woo_Product_Gallery_Integration class
*/
class Jet_Woo_Product_Gallery_Integration {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Check if processing elementor widget
*
* @var boolean
*/
private $is_elementor_ajax = false;
/**
* Initalize integration hooks
*
* @return void
*/
public function init() {
add_action( 'elementor/init', array( $this, 'register_category' ) );
add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ), 10 );
add_action( 'wp_ajax_elementor_render_widget', array( $this, 'set_elementor_ajax' ), 10, - 1 );
add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_styles' ) );
}
/**
* Enqueue editor styles
*
* @return void
*/
public function editor_styles() {
// wp_enqueue_style(
// 'jet-woo-product-gallery-font',
// jet_woo_product_gallery()->plugin_url( 'assets/css/lib/jetwooproductgallery-font/css/jetwooproductgallery.css' ),
// array(),
// jet_woo_product_gallery()->get_version()
// );
}
/**
* Set $this->is_elementor_ajax to true on Elementor AJAX processing
*
* @return void
*/
public function set_elementor_ajax() {
$this->is_elementor_ajax = true;
}
/**
* Check if we currently in Elementor mode
*
* @return void
*/
public function in_elementor() {
$result = false;
if ( wp_doing_ajax() ) {
$result = $this->is_elementor_ajax;
} elseif ( Elementor\Plugin::instance()->editor->is_edit_mode()
|| Elementor\Plugin::instance()->preview->is_preview_mode() ) {
$result = true;
}
/**
* Allow to filter result before return
*
* @var bool $result
*/
return apply_filters( 'jet-woo-product-gallery/in-elementor', $result );
}
/**
* Register plugin widgets
*
* @param object $widgets_manager Elementor widgets manager instance.
*
* @return void
*/
public function register_widgets( $widgets_manager ) {
$product_gallery_available_widgets = jet_woo_product_gallery_settings()->get( 'product_gallery_available_widgets' );
require jet_woo_product_gallery()->plugin_path( 'includes/base/class-jet-woo-product-gallery-base.php' );
foreach ( glob( jet_woo_product_gallery()->plugin_path( 'includes/widgets/' ) . '*.php' ) as $file ) {
$slug = basename( $file, '.php' );
$enabled = isset( $product_gallery_available_widgets[ $slug ] ) ? $product_gallery_available_widgets[ $slug ] : '';
if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $product_gallery_available_widgets ) {
$this->register_widget( $file, $widgets_manager );
}
}
}
/**
* Register addon by file name
*
* @param string $file File name.
* @param object $widgets_manager Widgets manager instance.
*
* @return void
*/
public function register_widget( $file, $widgets_manager ) {
$base = basename( str_replace( '.php', '', $file ) );
$class = ucwords( str_replace( '-', ' ', $base ) );
$class = str_replace( ' ', '_', $class );
$class = sprintf( 'Elementor\%s', $class );
require $file;
if ( class_exists( $class ) ) {
$widgets_manager->register_widget_type( new $class );
}
}
/**
* Register cherry category for elementor if not exists
*
* @return void
*/
public function register_category() {
$elements_manager = Elementor\Plugin::instance()->elements_manager;
$jet_woo_product_gallery_cat = 'jet-woo-product-gallery';
$elements_manager->add_category(
$jet_woo_product_gallery_cat,
array(
'title' => esc_html__( 'Jet Product Gallery', 'jet-woo-product-gallery' ),
'icon' => 'font',
),
1
);
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $shortcodes = array() ) {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self( $shortcodes );
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Woo_Product_Gallery_Integration
*
* @return object
*/
function jet_woo_product_gallery_integration() {
return Jet_Woo_Product_Gallery_Integration::get_instance();
}

View File

@@ -0,0 +1,322 @@
<?php
/**
* Class description
*
* @package package_name
* @author Cherry Team
* @license GPL-2.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Product_Gallery_Settings' ) ) {
/**
* Define Jet_Woo_Product_Gallery_Settings class
*/
class Jet_Woo_Product_Gallery_Settings {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @access private
* @var object
*/
private static $instance = null;
/**
* [$key description]
* @var string
*/
public $key = 'jet-woo-product-gallery-settings';
/**
* [$builder description]
* @var null
*/
public $builder = null;
/**
* [$settings description]
* @var null
*/
public $settings = null;
/**
* Global Available Widgets array
*
* @var array
*/
public $product_gallery_available_widgets = array();
/**
* Init page
*/
public function init() {
add_action( 'admin_enqueue_scripts', array( $this, 'init_builder' ), 0 );
add_action( 'admin_menu', array( $this, 'register_page' ), 99 );
add_action( 'init', array( $this, 'save' ), 40 );
add_action( 'admin_notices', array( $this, 'saved_notice' ) );
foreach ( glob( jet_woo_product_gallery()->plugin_path( 'includes/widgets/' ) . '*.php' ) as $file ) {
$data = get_file_data( $file, array( 'class'=>'Class', 'name' => 'Name', 'slug'=>'Slug' ) );
$slug = basename( $file, '.php' );
$this->product_gallery_available_widgets[ $slug] = $data['name'];
}
}
/**
* Initialize page builder module if reqired
*
* @return [type] [description]
*/
public function init_builder() {
if ( ! isset( $_REQUEST['page'] ) || $this->key !== $_REQUEST['page'] ) {
return;
}
$builder_data = jet_woo_product_gallery()->framework->get_included_module_data( 'cherry-x-interface-builder.php' );
$this->builder = new CX_Interface_Builder(
array(
'path' => $builder_data['path'],
'url' => $builder_data['url'],
)
);
}
/**
* Show saved notice
*
* @return bool
*/
public function saved_notice() {
if ( ! isset( $_GET['settings-saved'] ) ) {
return false;
}
$message = esc_html__( 'Settings saved', 'jet-woo-product-gallery' );
printf( '<div class="notice notice-success is-dismissible"><p>%s</p></div>', $message );
return true;
}
/**
* Save settings
*
* @return void
*/
public function save() {
if ( ! isset( $_REQUEST['page'] ) || $this->key !== $_REQUEST['page'] ) {
return;
}
if ( ! isset( $_REQUEST['action'] ) || 'save-settings' !== $_REQUEST['action'] ) {
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$current = get_option( $this->key, array() );
$data = $_REQUEST;
unset( $data['action'] );
foreach ( $data as $key => $value ) {
$current[ $key ] = is_array( $value ) ? $value : esc_attr( $value );
}
update_option( $this->key, $current );
$redirect = add_query_arg(
array( 'dialog-saved' => true ),
$this->get_settings_page_link()
);
wp_redirect( $redirect );
die();
}
/**
* Return settings page URL
*
* @return string
*/
public function get_settings_page_link() {
return add_query_arg(
array(
'page' => $this->key,
),
esc_url( admin_url( 'admin.php' ) )
);
}
public function get( $setting, $default = false ) {
if ( null === $this->settings ) {
$this->settings = get_option( $this->key, array() );
}
return isset( $this->settings[ $setting ] ) ? $this->settings[ $setting ] : $default;
}
/**
* Register add/edit page
*
* @return void
*/
public function register_page() {
add_submenu_page(
'elementor',
esc_html__( 'Jet Product Gallery Settings', 'jet-woo-product-gallery' ),
esc_html__( 'Jet Product Gallery Settings', 'jet-woo-product-gallery' ),
'manage_options',
$this->key,
array( $this, 'render_page' )
);
}
/**
* Render settings page
*
* @return void
*/
public function render_page() {
foreach ( $this->product_gallery_available_widgets as $key => $value ) {
$default_product_gallery_available_widgets[ $key ] = 'true';
}
$this->builder->register_section(
array(
'jet_woo_product_gallery_settings' => array(
'type' => 'section',
'scroll' => false,
'title' => esc_html__( 'Jet Product Gallery Settings', 'jet-woo-product-gallery' ),
),
)
);
$this->builder->register_form(
array(
'jet_woo_product_gallery_settings_form' => array(
'type' => 'form',
'parent' => 'jet_woo_product_gallery_settings',
'action' => add_query_arg(
array( 'page' => $this->key, 'action' => 'save-settings' ),
esc_url( admin_url( 'admin.php' ) )
),
),
)
);
$this->builder->register_settings(
array(
'settings_top' => array(
'type' => 'settings',
'parent' => 'jet_woo_product_gallery_settings_form',
),
'settings_bottom' => array(
'type' => 'settings',
'parent' => 'jet_woo_product_gallery_settings_form',
),
)
);
$this->builder->register_component(
array(
'jet_woo_product_gallery_tab_vertical' => array(
'type' => 'component-tab-vertical',
'parent' => 'settings_top',
),
)
);
$this->builder->register_settings(
array(
'available_widgets_options' => array(
'parent' => 'jet_woo_product_gallery_tab_vertical',
'title' => esc_html__( 'Available Widgets', 'jet-woo-product-gallery' ),
),
)
);
$this->builder->register_control(
array(
'product_gallery_available_widgets' => array(
'type' => 'checkbox',
'id' => 'product_gallery_available_widgets',
'name' => 'product_gallery_available_widgets',
'parent' => 'available_widgets_options',
'value' => $this->get( 'product_gallery_available_widgets', $default_product_gallery_available_widgets ),
'options' => $this->product_gallery_available_widgets,
'title' => esc_html__( 'Global Available Widgets', 'jet-woo-product-gallery' ),
'description' => esc_html__( 'List of widgets that will be available when editing the page', 'jet-woo-product-gallery' ),
'class' => 'jet_woo_product_gallery_settings_form__checkbox-group'
),
)
);
$this->builder->register_html(
array(
'save_button' => array(
'type' => 'html',
'parent' => 'settings_bottom',
'class' => 'cx-component dialog-save',
'html' => '<button type="submit" class="button button-primary">' . esc_html__( 'Save', 'jet-woo-product-gallery' ) . '</button>',
),
)
);
echo '<div class="jet-woo-product-gallery-settings-page">';
$this->builder->render();
echo '</div>';
}
/**
* 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;
}
}
}
/**
* Returns instance of Jet_Woo_Product_Gallery_Settings
*
* @return object
*/
function jet_woo_product_gallery_settings() {
return Jet_Woo_Product_Gallery_Settings::get_instance();
}

View File

@@ -0,0 +1,85 @@
<?php
/**
* Class for the base update.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* Base updater class.
*
* @since 1.0.0
*/
class Jet_Woo_Product_Gallery_Base_Update {
/**
* Api parameters.
*
* @since 1.0.0
* @access protected
* @var array
*/
protected $api = array(
'version' => '',
'slug' => '',
'api_url' => 'http://jetproductgallery.zemez.io/updates/%s.json',
);
/**
* Init class parameters.
*
* @since 1.0.0
* @param array $attr Input attributes array.
* @return void
*/
protected function base_init( $attr = array() ) {
$this->api = array_merge( $this->api, $attr );
}
/**
* Check if update are available.
*
* @since 1.0.0
* @return array
*/
protected function check_update() {
$response = $this->remote_query();
if ( ! $response ) {
return array( 'version' => false );
}
if ( version_compare( $this->api['version'], $response->version, '<' ) ) {
return array(
'version' => $response->version,
'package' => $response->package,
);
}
return array( 'version' => false );
}
/**
* Remote request to updater API.
*
* @since 1.0.0
* @return array|bool
*/
protected function remote_query() {
$response = wp_remote_get( sprintf( $this->api['api_url'], $this->api['slug'] ) );
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != '200' ) {
return false;
}
$response = json_decode( $response['body'] );
return $response;
}
}

View File

@@ -0,0 +1,73 @@
<?php
/**
* Class for the update plugins.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
require jet_woo_product_gallery()->plugin_path( 'includes/updater/class-jet-woo-product-gallery-base-update.php' );
/**
* Define plugin updater class.
*
* @since 1.0.0
*/
class Jet_Woo_Product_Gallery_Plugin_Update extends Jet_Woo_Product_Gallery_Base_Update {
/**
* Init class parameters.
*
* @since 1.0.0
* @param array $attr Input attributes array.
* @return void
*/
public function init( $attr = array() ) {
$this->base_init( $attr );
/**
* Need for test update - set_site_transient( 'update_plugins', null );
*/
add_action( 'pre_set_site_transient_update_plugins', array( $this, 'update' ) );
}
/**
* Process update.
*
* @since 1.0.0
* @param object $data Update data.
* @return object
*/
public function update( $data ) {
$new_update = $this->check_update();
if ( $new_update['version'] ) {
$this->api['plugin'] = $this->api['slug'] . '/' . $this->api['slug'] . '.php';
$update = new stdClass();
$update->slug = $this->api['slug'];
$update->plugin = $this->api['plugin'];
$update->new_version = $new_update['version'];
$update->url = isset( $this->api['details_url'] ) ? $this->api['details_url'] : false;
$update->package = $new_update['package'];
$data->response[ $this->api['plugin'] ] = $update;
}
return $data;
}
}
if ( ! function_exists( 'jet_woo_product_gallery_updater' ) ) {
function jet_woo_product_gallery_updater() {
return new Jet_Woo_Product_Gallery_Plugin_Update();
}
}

View File

@@ -0,0 +1,488 @@
<?php
/**
* Class: Jet_Woo_Product_Gallery_Anchor_Nav
* Name: Gallery Anchor Nav
* Slug: jet-woo-product-gallery-anchor-nav
*/
namespace Elementor;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Repeater;
use Elementor\Scheme_Color;
use Elementor\Scheme_Typography;
use Elementor\Widget_Base;
use Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
class Jet_Woo_Product_Gallery_Anchor_Nav extends Jet_Woo_Product_Gallery_Base {
public function get_name() {
return 'jet-woo-product-gallery-anchor-nav';
}
public function get_title() {
return esc_html__( 'Gallery Anchor Navigation', 'jet-woo-product-gallery' );
}
public function get_script_depends() {
return array( 'zoom', 'wc-single-product', 'mediaelement', 'photoswipe-ui-default', 'photoswipe' );
}
public function get_style_depends() {
return array( 'mediaelement', 'photoswipe', 'photoswipe-default-skin' );
}
public function get_icon() {
return 'jetwoobuilder-icon-5';
}
public function get_categories() {
return array( 'jet-woo-product-gallery' );
}
public function register_product_gallery_controls() {
$this->start_controls_section(
'section_product_images',
array(
'label' => esc_html__( 'Images', 'jet-woo-product-gallery' ),
'tab' => Controls_Manager::TAB_CONTENT,
'show_label' => false,
)
);
$this->add_control(
'image_size',
array(
'label' => esc_html__( 'Image Size', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::SELECT,
'default' => '',
'options' => jet_woo_product_gallery_tools()->get_image_sizes(),
)
);
$this->end_controls_section();
$css_scheme = apply_filters(
'jet-woo-product-gallery-anchor-nav/css-scheme',
array(
'row' => '.jet-woo-product-gallery-anchor-nav',
'columns' => '.jet-woo-product-gallery-anchor-nav .jet-woo-product-gallery__image-item',
'items' => '.jet-woo-product-gallery-anchor-nav-items',
'item' => '.jet-woo-product-gallery__image-item',
'images' => '.jet-woo-product-gallery-anchor-nav .jet-woo-product-gallery__image',
'controller' => '.jet-woo-product-gallery-anchor-nav-controller',
'controller-bullet' => '.jet-woo-product-gallery-anchor-nav-controller .controller-item__bullet',
'controller-bullet-current' => '.jet-woo-product-gallery-anchor-nav-controller .current-item .controller-item__bullet',
)
);
$this->register_controls_images_style( $css_scheme );
$this->register_controls_controller_style( $css_scheme );
}
public function register_controls_images_style( $css_scheme ) {
$this->start_controls_section(
'section_gallery_images_style',
array(
'label' => esc_html__( 'Images', 'jet-woo-product-gallery' ),
'tab' => Controls_Manager::TAB_STYLE,
'show_label' => false,
)
);
$this->add_responsive_control(
'gallery_images_space_between',
array(
'label' => esc_html__( 'Space Between Images', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px',
),
'range' => array(
'px' => array(
'min' => 0,
'max' => 100,
),
),
'default' => array(
'size' => 5,
'unit' => 'px',
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['item'] . '+' . $css_scheme['item'] => 'margin-top: {{SIZE}}{{UNIT}};',
),
)
);
$this->add_group_control(
Group_Control_Border::get_type(),
array(
'name' => 'gallery_images_border',
'label' => esc_html__( 'Border', 'jet-woo-product-gallery' ),
'placeholder' => '1px',
'default' => '1px',
'selector' => '{{WRAPPER}} ' . $css_scheme['images'],
)
);
$this->add_control(
'gallery_images_border_radius',
array(
'label' => esc_html__( 'Border Radius', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['images'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
array(
'name' => 'gallery_images_shadow',
'selector' => '{{WRAPPER}} ' . $css_scheme['images'],
)
);
$this->add_control(
'gallery_images_background_color',
array(
'label' => esc_html__( 'Background Color', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['images'] => 'background-color: {{VALUE}}',
),
)
);
$this->end_controls_section();
}
public function register_controls_controller_style( $css_scheme ) {
$this->start_controls_section(
'section_controller_style',
array(
'label' => esc_html__( 'Navigation', 'jet-woo-product-gallery' ),
'tab' => Controls_Manager::TAB_STYLE,
'show_label' => false,
)
);
$this->add_responsive_control(
'controller_width',
array(
'label' => esc_html__( 'Width', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::SLIDER,
'render_type' => 'template',
'size_units' => array(
'px',
'%',
),
'range' => array(
'px' => array(
'min' => 70,
'max' => 500,
),
'%' => array(
'min' => 0,
'max' => 50,
),
),
'default' => array(
'size' => 150,
'unit' => 'px',
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller'] => 'max-width: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} ' . $css_scheme['items'] => 'max-width: calc(100% - {{SIZE}}{{UNIT}});',
),
)
);
$this->add_responsive_control(
'controller_offset_top',
array(
'label' => esc_html__( 'Offset Top (px)', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px'
),
'range' => array(
'px' => array(
'min' => 0,
'max' => 500,
),
),
'default' => array(
'size' => 0,
'unit' => 'px',
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller'] => 'margin-top: {{SIZE}}{{UNIT}};',
),
)
);
$this->add_responsive_control(
'controller_position',
array(
'label' => esc_html__( 'Position', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::CHOOSE,
'default' => 'left',
'options' => array(
'left' => array(
'title' => esc_html__( 'Left', 'jet-woo-product-gallery' ),
'icon' => 'fa fa-arrow-left',
),
'right' => array(
'title' => esc_html__( 'Right', 'jet-woo-product-gallery' ),
'icon' => 'fa fa-arrow-right',
),
),
'prefix_class' => 'jet-woo-product-gallery-anchor-nav-controller-',
)
);
$this->add_control(
'bullets_heading',
array(
'label' => esc_html__( 'Bullets', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
)
);
$this->add_responsive_control(
'controller_bullets_width',
array(
'label' => esc_html__( 'Width', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px',
),
'range' => array(
'px' => array(
'min' => 0,
'max' => 100,
),
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller-bullet'] => 'width: {{SIZE}}{{UNIT}};',
),
)
);
$this->add_responsive_control(
'controller_bullets_height',
array(
'label' => esc_html__( 'Height', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px',
),
'range' => array(
'px' => array(
'min' => 0,
'max' => 100,
),
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller-bullet'] => 'height: {{SIZE}}{{UNIT}};',
),
)
);
$this->start_controls_tabs( 'controller_bullets_style_tabs' );
$this->start_controls_tab(
'controller_bullets_normal_styles',
array(
'label' => esc_html__( 'Normal', 'jet-woo-product-gallery' ),
)
);
$this->add_control(
'controller_bullets_normal_background_color',
array(
'label' => esc_html__( 'Background Color', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller-bullet'] => 'background-color: {{VALUE}}',
),
)
);
$this->add_group_control(
Group_Control_Border::get_type(),
array(
'name' => 'controller_bullets_normal_border',
'label' => esc_html__( 'Border', 'jet-woo-product-gallery' ),
'placeholder' => '1px',
'default' => '1px',
'selector' => '{{WRAPPER}} ' . $css_scheme['controller-bullet'],
)
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
array(
'name' => 'controller_bullets_normal_shadow',
'selector' => '{{WRAPPER}} ' . $css_scheme['controller-bullet'],
)
);
$this->end_controls_tab();
$this->start_controls_tab(
'controller_bullets_hover_styles',
array(
'label' => esc_html__( 'Hover', 'jet-woo-product-gallery' ),
)
);
$this->add_control(
'controller_bullets_hover_background_color',
array(
'label' => esc_html__( 'Background Color', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller-bullet'] . ':hover' => 'background-color: {{VALUE}}',
),
)
);
$this->add_control(
'controller_bullets_hover_border_color',
array(
'label' => esc_html__( 'Border Color', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller-bullet'] . ':hover' => 'border-color: {{VALUE}}',
),
'condition' => array(
'controller_bullets_normal_border_border!' => '',
),
)
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
array(
'name' => 'controller_bullets_hover_shadow',
'selector' => '{{WRAPPER}} ' . $css_scheme['controller-bullet'] . ':hover',
)
);
$this->end_controls_tab();
$this->start_controls_tab(
'controller_bullets_current_styles',
array(
'label' => esc_html__( 'Current', 'jet-woo-product-gallery' ),
)
);
$this->add_control(
'controller_bullets_current_background_color',
array(
'label' => esc_html__( 'Background Color', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller-bullet-current'] => 'background-color: {{VALUE}}',
),
)
);
$this->add_control(
'controller_bullets_current_border_color',
array(
'label' => esc_html__( 'Border Color', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller-bullet-current'] => 'border-color: {{VALUE}}',
),
'condition' => array(
'controller_bullets_normal_border_border!' => '',
),
)
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
array(
'name' => 'controller_bullets_current_shadow',
'selector' => '{{WRAPPER}} ' . $css_scheme['controller-bullet-current'],
)
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_control(
'controller_bullets_border_radius',
array(
'label' => esc_html__( 'Border Radius', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller-bullet'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$this->add_responsive_control(
'controller_bullets_margin',
array(
'label' => esc_html__( 'Margin', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['controller-bullet'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$this->end_controls_section();
}
protected function render() {
global $post, $product, $_product;
$settings = $this->get_settings();
if ( ! empty( $settings['product_id'] ) ) {
$_product = wc_get_product( $settings['product_id'] );
} else {
$_product = wc_get_product();
}
if ( ! empty( $_product ) ) {
$this->__context = 'render';
$this->__open_wrap();
include $this->__get_global_template( 'index' );
$this->__close_wrap();
} else {
printf(
'<div class="jet-woo-product-gallery__content">%s</div>',
esc_html__( 'Not found product with current id', 'jet-woo-product-gallery' )
);
}
}
public function get_unique_controller_id() {
return uniqid( 'controller-item-id-', true );
}
}

View File

@@ -0,0 +1,223 @@
<?php
/**
* Class: Jet_Woo_Product_Gallery_Grid
* Name: Gallery Grid
* Slug: jet-woo-product-gallery-grid
*/
namespace Elementor;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Repeater;
use Elementor\Scheme_Color;
use Elementor\Scheme_Typography;
use Elementor\Widget_Base;
use Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
class Jet_Woo_Product_Gallery_Grid extends Jet_Woo_Product_Gallery_Base {
public function get_name() {
return 'jet-woo-product-gallery-grid';
}
public function get_title() {
return esc_html__( 'Gallery Grid', 'jet-woo-product-gallery' );
}
public function get_script_depends() {
return array( 'zoom', 'wc-single-product', 'mediaelement', 'photoswipe-ui-default', 'photoswipe' );
}
public function get_style_depends() {
return array( 'mediaelement', 'photoswipe', 'photoswipe-default-skin' );
}
public function get_icon() {
return 'jetwoobuilder-icon-5';
}
public function get_categories() {
return array( 'jet-woo-product-gallery' );
}
public function register_product_gallery_controls() {
$this->start_controls_section(
'section_product_images',
array(
'label' => esc_html__( 'Images', 'jet-woo-product-gallery' ),
'tab' => Controls_Manager::TAB_CONTENT,
'show_label' => false,
)
);
$this->add_control(
'image_size',
array(
'label' => esc_html__( 'Image Size', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::SELECT,
'default' => '',
'options' => jet_woo_product_gallery_tools()->get_image_sizes(),
)
);
$this->add_responsive_control(
'columns',
array(
'label' => esc_html__( 'Columns', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::NUMBER,
'default' => 3,
'desktop' => 4,
'tablet' => 3,
'mobile' => 2,
'min' => 1,
'max' => 6,
'step' => 1,
)
);
$this->end_controls_section();
$css_scheme = apply_filters(
'jet-woo-product-gallery-grid/css-scheme',
array(
'row' => '.jet-woo-product-gallery-grid',
'columns' => '.jet-woo-product-gallery-grid .jet-woo-product-gallery__image-item',
'images' => '.jet-woo-product-gallery-grid .jet-woo-product-gallery__image',
)
);
$this->register_controls_columns_style( $css_scheme );
$this->register_controls_images_style( $css_scheme );
}
public function register_controls_columns_style( $css_scheme ) {
$this->start_controls_section(
'section_columns_style',
array(
'label' => esc_html__( 'Columns', 'jet-woo-product-gallery' ),
'tab' => Controls_Manager::TAB_STYLE,
'show_label' => false,
)
);
$this->add_responsive_control(
'columns_padding',
array(
'label' => esc_html__( 'Columns Gutter', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['columns'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} ' . $css_scheme['row'] => 'margin-left: -{{LEFT}}{{UNIT}}; margin-right: -{{RIGHT}}{{UNIT}};',
),
)
);
$this->end_controls_section();
}
public function register_controls_images_style( $css_scheme ) {
$this->start_controls_section(
'section_gallery_images_style',
array(
'label' => esc_html__( 'Images', 'jet-woo-product-gallery' ),
'tab' => Controls_Manager::TAB_STYLE,
'show_label' => false,
)
);
$this->add_group_control(
Group_Control_Border::get_type(),
array(
'name' => 'gallery_images_border',
'label' => esc_html__( 'Border', 'jet-woo-product-gallery' ),
'placeholder' => '1px',
'default' => '1px',
'selector' => '{{WRAPPER}} ' . $css_scheme['images'],
)
);
$this->add_control(
'gallery_images_border_radius',
array(
'label' => esc_html__( 'Border Radius', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['images'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; overflow:hidden;',
),
)
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
array(
'name' => 'gallery_images_shadow',
'selector' => '{{WRAPPER}} ' . $css_scheme['images'],
)
);
$this->add_control(
'gallery_images_background_color',
array(
'label' => esc_html__( 'Background Color', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['images'] => 'background-color: {{VALUE}}',
),
)
);
$this->add_responsive_control(
'gallery_images_padding',
array(
'label' => esc_html__( 'Padding', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['images'] . ':not(.jet-woo-product-gallery--with-video)' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$this->end_controls_section();
}
protected function render() {
global $post, $product, $_product;
$settings = $this->get_settings();
if ( ! empty( $settings['product_id'] ) ) {
$_product = wc_get_product( $settings['product_id'] );
} else {
$_product = wc_get_product();
}
if ( ! empty( $_product ) ) {
$this->__context = 'render';
$this->__open_wrap();
include $this->__get_global_template( 'index' );
$this->__close_wrap();
} else {
printf(
'<div class="jet-woo-product-gallery__content">%s</div>',
esc_html__( 'Not found product with current id', 'jet-woo-product-gallery' )
);
}
}
}

View File

@@ -0,0 +1,466 @@
<?php
/**
* Class: Jet_Woo_Product_Gallery_Modern
* Name: Gallery Modern
* Slug: jet-woo-product-gallery-modern
*/
namespace Elementor;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Repeater;
use Elementor\Scheme_Color;
use Elementor\Scheme_Typography;
use Elementor\Widget_Base;
use Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
class Jet_Woo_Product_Gallery_Modern extends Jet_Woo_Product_Gallery_Base {
public function get_name() {
return 'jet-woo-product-gallery-modern';
}
public function get_title() {
return esc_html__( 'Gallery Modern', 'jet-woo-product-gallery' );
}
public function get_script_depends() {
return array( 'zoom', 'wc-single-product', 'mediaelement', 'photoswipe-ui-default', 'photoswipe' );
}
public function get_style_depends() {
return array( 'mediaelement', 'photoswipe', 'photoswipe-default-skin' );
}
public function get_icon() {
return 'jetwoobuilder-icon-5';
}
public function get_categories() {
return array( 'jet-woo-product-gallery' );
}
public function register_product_gallery_controls() {
$this->start_controls_section(
'section_product_images',
array(
'label' => esc_html__( 'Images', 'jet-woo-product-gallery' ),
'tab' => Controls_Manager::TAB_CONTENT,
'show_label' => false,
)
);
$this->add_control(
'image_size',
array(
'label' => esc_html__( 'Image Size', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::SELECT,
'default' => '',
'options' => jet_woo_product_gallery_tools()->get_image_sizes(),
)
);
$this->end_controls_section();
$css_scheme = apply_filters(
'jet-woo-product-gallery-modern/css-scheme',
array(
'wrapper' => '.jet-woo-product-gallery-modern',
'items' => '.jet-woo-product-gallery-modern .jet-woo-product-gallery__image-item',
'images' => '.jet-woo-product-gallery-modern .jet-woo-product-gallery__image',
'image-1' => '.jet-woo-product-gallery-modern .jet-woo-product-gallery__image-item:nth-child(5n+1)',
'image-2' => '.jet-woo-product-gallery-modern .jet-woo-product-gallery__image-item:nth-child(5n+2)',
'image-3' => '.jet-woo-product-gallery-modern .jet-woo-product-gallery__image-item:nth-child(5n+3)',
'image-4' => '.jet-woo-product-gallery-modern .jet-woo-product-gallery__image-item:nth-child(5n+4)',
'image-5' => '.jet-woo-product-gallery-modern .jet-woo-product-gallery__image-item:nth-child(5n+5)',
)
);
$this->register_controls_images_style( $css_scheme );
}
public function register_controls_images_style( $css_scheme ) {
$this->start_controls_section(
'section_gallery_images_style',
array(
'label' => esc_html__( 'Images', 'jet-woo-product-gallery' ),
'tab' => Controls_Manager::TAB_STYLE,
'show_label' => false,
)
);
$this->add_responsive_control(
'gallery_images_proportion_1',
array(
'label' => esc_html__( 'Images Proportion 1 (%)', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'%',
),
'range' => array(
'%' => array(
'min' => 10,
'max' => 90,
),
),
'default' => array(
'size' => 30,
'unit' => '%',
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image-2'] => 'max-width: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} ' . $css_scheme['image-3'] => 'max-width: calc(100% - {{SIZE}}{{UNIT}});',
),
)
);
$this->add_responsive_control(
'gallery_images_proportion_2',
array(
'label' => esc_html__( 'Images Proportion 2 (%)', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'%',
),
'range' => array(
'%' => array(
'min' => 10,
'max' => 90,
),
),
'default' => array(
'size' => 70,
'unit' => '%',
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image-4'] => 'max-width: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} ' . $css_scheme['image-5'] => 'max-width: calc(100% - {{SIZE}}{{UNIT}});',
),
)
);
$this->add_control(
'gallery_images_2_heading',
array(
'label' => esc_html__( 'Image 2', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
)
);
$this->add_responsive_control(
'gallery_images_2_alignment',
array(
'label' => esc_html__( 'Vertical Alignment', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::CHOOSE,
'label_block' => false,
'options' => array(
'flex-start' => array(
'title' => esc_html__( 'Top', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-top',
),
'center' => array(
'title' => esc_html__( 'Middle', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-middle',
),
'flex-end' => array(
'title' => esc_html__( 'Bottom', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-bottom',
),
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image-2'] => 'align-self: {{VALUE}};',
),
)
);
$this->add_responsive_control(
'gallery_images_2_margin',
array(
'label' => esc_html__( 'Margin', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'allowed_dimensions' => 'vertical',
'placeholder' => array(
'top' => '',
'right' => 'auto',
'bottom' => '',
'left' => 'auto',
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image-2'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$this->add_control(
'gallery_images_3_heading',
array(
'label' => esc_html__( 'Image 3', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
)
);
$this->add_responsive_control(
'gallery_images_3_alignment',
array(
'label' => esc_html__( 'Vertical Alignment', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::CHOOSE,
'label_block' => false,
'options' => array(
'flex-start' => array(
'title' => esc_html__( 'Top', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-top',
),
'center' => array(
'title' => esc_html__( 'Middle', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-middle',
),
'flex-end' => array(
'title' => esc_html__( 'Bottom', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-bottom',
),
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image-3'] => 'align-self: {{VALUE}};',
),
)
);
$this->add_responsive_control(
'gallery_images_3_margin',
array(
'label' => esc_html__( 'Margin', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'allowed_dimensions' => 'vertical',
'placeholder' => array(
'top' => '',
'right' => 'auto',
'bottom' => '',
'left' => 'auto',
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image-3'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$this->add_control(
'gallery_images_4_heading',
array(
'label' => esc_html__( 'Image 4', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
)
);
$this->add_responsive_control(
'gallery_images_4_alignment',
array(
'label' => esc_html__( 'Vertical Alignment', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::CHOOSE,
'label_block' => false,
'options' => array(
'flex-start' => array(
'title' => esc_html__( 'Top', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-top',
),
'center' => array(
'title' => esc_html__( 'Middle', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-middle',
),
'flex-end' => array(
'title' => esc_html__( 'Bottom', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-bottom',
),
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image-4'] => 'align-self: {{VALUE}};',
),
)
);
$this->add_responsive_control(
'gallery_images_4_margin',
array(
'label' => esc_html__( 'Margin', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'allowed_dimensions' => 'vertical',
'placeholder' => array(
'top' => '',
'right' => 'auto',
'bottom' => '',
'left' => 'auto',
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image-4'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$this->add_control(
'gallery_images_5_heading',
array(
'label' => esc_html__( 'Image 5', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
)
);
$this->add_responsive_control(
'gallery_images_5_alignment',
array(
'label' => esc_html__( 'Vertical Alignment', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::CHOOSE,
'label_block' => false,
'options' => array(
'flex-start' => array(
'title' => esc_html__( 'Top', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-top',
),
'center' => array(
'title' => esc_html__( 'Middle', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-middle',
),
'flex-end' => array(
'title' => esc_html__( 'Bottom', 'jet-woo-product-gallery' ),
'icon' => 'eicon-v-align-bottom',
),
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image-5'] => 'align-self: {{VALUE}};',
),
)
);
$this->add_responsive_control(
'gallery_images_5_margin',
array(
'label' => esc_html__( 'Margin', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'allowed_dimensions' => 'vertical',
'placeholder' => array(
'top' => '',
'right' => 'auto',
'bottom' => '',
'left' => 'auto',
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['image-5'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$this->add_group_control(
Group_Control_Border::get_type(),
array(
'name' => 'gallery_images_border',
'label' => esc_html__( 'Border', 'jet-woo-product-gallery' ),
'placeholder' => '1px',
'default' => '1px',
'selector' => '{{WRAPPER}} ' . $css_scheme['images'],
'separator' => 'before'
)
);
$this->add_control(
'gallery_images_border_radius',
array(
'label' => esc_html__( 'Border Radius', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['images'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; overflow:hidden;',
),
)
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
array(
'name' => 'gallery_images_shadow',
'exclude' => array(
'box_shadow_position',
),
'selector' => '{{WRAPPER}} ' . $css_scheme['images'],
)
);
$this->add_control(
'gallery_images_background_color',
array(
'label' => esc_html__( 'Background Color', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['images'] => 'background-color: {{VALUE}}',
),
)
);
$this->add_responsive_control(
'gallery_images_padding',
array(
'label' => esc_html__( 'Padding', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['items'] . ':not(.jet-woo-product-gallery--with-video)' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$this->add_responsive_control(
'gallery_images_margin',
array(
'label' => esc_html__( 'Outer offset', 'jet-woo-product-gallery' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['wrapper'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$this->end_controls_section();
}
protected function render() {
global $post, $product, $_product;
$settings = $this->get_settings();
if ( ! empty( $settings['product_id'] ) ) {
$_product = wc_get_product( $settings['product_id'] );
} else {
$_product = wc_get_product();
}
if ( ! empty( $_product ) ) {
$this->__context = 'render';
$this->__open_wrap();
include $this->__get_global_template( 'index' );
$this->__close_wrap();
} else {
printf(
'<div class="jet-woo-product-gallery__content">%s</div>',
esc_html__( 'Not found product with current id', 'jet-woo-product-gallery' )
);
}
}
}