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,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();
}