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,612 @@
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
abstract class Jet_Woo_Builder_Base extends Widget_Base {
public $__context = 'render';
public $__processed_item = false;
public $__processed_index = 0;
public $__temp_query = null;
public $__product_data = false;
public $__new_icon_prefix = 'selected_';
public function get_jet_help_url() {
return false;
}
public function get_help_url() {
$url = $this->get_jet_help_url();
if ( ! empty( $url ) ) {
return add_query_arg(
array(
'utm_source' => 'need-help',
'utm_medium' => $this->get_name(),
'utm_campaign' => 'jetwoobuilder',
),
esc_url( $url )
);
}
return false;
}
/**
* Get globaly affected template
*
* @param [type] $name [description]
* @return [type] [description]
*/
public function __get_global_template( $name = null ) {
$template = call_user_func( array( $this, sprintf( '__get_%s_template', $this->__context ) ) );
if ( ! $template ) {
$template = jet_woo_builder()->get_template( $this->get_name() . '/global/' . $name . '.php' );
}
return $template;
}
/**
* Get front-end template
* @param [type] $name [description]
* @return [type] [description]
*/
public function __get_render_template( $name = null ) {
return jet_woo_builder()->get_template( $this->get_name() . '/render/' . $name . '.php' );
}
/**
* Get editor template
* @param [type] $name [description]
* @return [type] [description]
*/
public function __get_edit_template( $name = null ) {
return jet_woo_builder()->get_template( $this->get_name() . '/edit/' . $name . '.php' );
}
/**
* Get global looped template for settings
* Required only to process repeater settings.
*
* @param string $name Base template name.
* @param string $setting Repeater setting that provide data for template.
* @return void
*/
public function __get_global_looped_template( $name = null, $setting = null ) {
$templates = array(
'start' => $this->__get_global_template( $name . '-loop-start' ),
'loop' => $this->__get_global_template( $name . '-loop-item' ),
'end' => $this->__get_global_template( $name . '-loop-end' ),
);
call_user_func(
array( $this, sprintf( '__get_%s_looped_template', $this->__context ) ), $templates, $setting
);
}
/**
* Get render mode looped template
*
* @param array $templates [description]
* @param [type] $setting [description]
* @return [type] [description]
*/
public function __get_render_looped_template( $templates = array(), $setting = null ) {
$loop = $this->get_settings( $setting );
if ( empty( $loop ) ) {
return;
}
if ( ! empty( $templates['start'] ) ) {
include $templates['start'];
}
foreach ( $loop as $item ) {
$this->__processed_item = $item;
if ( ! empty( $templates['start'] ) ) {
include $templates['loop'];
}
$this->__processed_index++;
}
$this->__processed_item = false;
$this->__processed_index = 0;
if ( ! empty( $templates['end'] ) ) {
include $templates['end'];
}
}
/**
* Get edit mode looped template
*
* @param array $templates [description]
* @param [type] $setting [description]
* @return [type] [description]
*/
public function __get_edit_looped_template( $templates = array(), $setting = null ) {
?>
<# if ( settings.<?php echo $setting; ?> ) { #>
<?php
if ( ! empty( $templates['start'] ) ) {
include $templates['start'];
}
?>
<# _.each( settings.<?php echo $setting; ?>, function( item ) { #>
<?php
if ( ! empty( $templates['loop'] ) ) {
include $templates['loop'];
}
?>
<# } ); #>
<?php
if ( ! empty( $templates['end'] ) ) {
include $templates['end'];
}
?>
<# } #>
<?php
}
/**
* Get current looped item dependends from context.
*
* @param string $key Key to get from processed item
* @return mixed
*/
public function __loop_item( $keys = array(), $format = '%s' ) {
return call_user_func( array( $this, sprintf( '__%s_loop_item', $this->__context ) ), $keys, $format );
}
/**
* Loop edit item
*
* @param [type] $keys [description]
* @param string $format [description]
* @param boolean $nested_key [description]
* @return [type] [description]
*/
public function __edit_loop_item( $keys = array(), $format = '%s' ) {
$settings = $keys[0];
if ( isset( $keys[1] ) ) {
$settings .= '.' . $keys[1];
}
ob_start();
echo '<# if ( item.' . $settings . ' ) { #>';
printf( $format, '{{{ item.' . $settings . ' }}}' );
echo '<# } #>';
return ob_get_clean();
}
/**
* Loop render item
*
* @param string $format [description]
* @param [type] $key [description]
* @param boolean $nested_key [description]
* @return [type] [description]
*/
public function __render_loop_item( $keys = array(), $format = '%s' ) {
$item = $this->__processed_item;
$key = $keys[0];
$nested_key = isset( $keys[1] ) ? $keys[1] : false;
if ( empty( $item ) || ! isset( $item[ $key ] ) ) {
return false;
}
if ( false === $nested_key || ! is_array( $item[ $key ] ) ) {
$value = $item[ $key ];
} else {
$value = isset( $item[ $key ][ $nested_key ] ) ? $item[ $key ][ $nested_key ] : false;
}
if ( ! empty( $value ) ) {
return sprintf( $format, $value );
}
}
/**
* Include global template if any of passed settings is defined
*
* @param [type] $name [description]
* @param [type] $settings [description]
* @return [type] [description]
*/
public function __glob_inc_if( $name = null, $settings = array() ) {
$template = $this->__get_global_template( $name );
call_user_func( array( $this, sprintf( '__%s_inc_if', $this->__context ) ), $template, $settings );
}
/**
* Include render template if any of passed setting is not empty
*
* @param [type] $file [description]
* @param [type] $settings [description]
* @return [type] [description]
*/
public function __render_inc_if( $file = null, $settings = array() ) {
foreach ( $settings as $setting ) {
$val = $this->get_settings( $setting );
if ( ! empty( $val ) ) {
include $file;
return;
}
}
}
/**
* Include render template if any of passed setting is not empty
*
* @param [type] $file [description]
* @param [type] $settings [description]
* @return [type] [description]
*/
public function __edit_inc_if( $file = null, $settings = array() ) {
$condition = null;
$sep = null;
foreach ( $settings as $setting ) {
$condition .= $sep . 'settings.' . $setting;
$sep = ' || ';
}
?>
<# if ( <?php echo $condition; ?> ) { #>
<?php include $file; ?>
<# } #>
<?php
}
/**
* Open standard wrapper
*
* @return void
*/
public function __open_wrap() {
printf( '<div class="elementor-%s jet-woo-builder">', $this->get_name() );
}
/**
* Close standard wrapper
*
* @return void
*/
public function __close_wrap() {
echo '</div>';
}
/**
* Print HTML markup if passed setting not empty.
*
* @param string $setting Passed setting.
* @param string $format Required markup.
* @param array $args Additional variables to pass into format string.
* @param bool $echo Echo or return.
* @return string|void
*/
public function __html( $setting = null, $format = '%s' ) {
call_user_func( array( $this, sprintf( '__%s_html', $this->__context ) ), $setting, $format );
}
/**
* Returns HTML markup if passed setting not empty.
*
* @param string $setting Passed setting.
* @param string $format Required markup.
* @param array $args Additional variables to pass into format string.
* @param bool $echo Echo or return.
* @return string|void
*/
public function __get_html( $setting = null, $format = '%s' ) {
ob_start();
$this->__html( $setting, $format );
return ob_get_clean();
}
/**
* Print HTML template
*
* @param [type] $setting [description]
* @param [type] $format [description]
* @return [type] [description]
*/
public function __render_html( $setting = null, $format = '%s' ) {
if ( is_array( $setting ) ) {
$key = $setting[1];
$setting = $setting[0];
}
$val = $this->get_settings( $setting );
if ( ! is_array( $val ) && '0' === $val ) {
printf( $format, $val );
}
if ( is_array( $val ) && empty( $val[ $key ] ) ) {
return '';
}
if ( ! is_array( $val ) && empty( $val ) ) {
return '';
}
if ( is_array( $val ) ) {
printf( $format, $val[ $key ] );
} else {
printf( $format, $val );
}
}
/**
* Print underscore template
*
* @param [type] $setting [description]
* @param [type] $format [description]
* @return [type] [description]
*/
public function __edit_html( $setting = null, $format = '%s' ) {
if ( is_array( $setting ) ) {
$setting = $setting[0] . '.' . $setting[1];
}
echo '<# if ( settings.' . $setting . ' ) { #>';
printf( $format, '{{{ settings.' . $setting . ' }}}' );
echo '<# } #>';
}
/**
* Set editor product
*/
public function __set_editor_product() {
if ( ! jet_woo_builder_integration()->in_elementor() && ! wp_doing_ajax() ) {
return true;
}
global $post, $wp_query, $product;
$this->__temp_query = $wp_query;
/**
* @todo perfomance optimization.
* Get chahed product for widgets. Currently breaks description in tabs. Should be fixed
*
* $this->__product_data = jet_woo_builder_integration()->get_current_product();
*/
// $this->__product_data = jet_woo_builder_integration()->get_current_product();
//
// if ( $this->__product_data === true ){
// return true;
// }
if ( ! empty( $this->__product_data ) ) {
$wp_query = $this->__product_data['query'];
$post = $this->__product_data['post'];
$product = $this->__product_data['product'];
return true;
}
if ( 'product' === $post->post_type ) {
$product = wc_get_product( $post );
$this->__product_data = array(
'query' => $wp_query,
'post' => $post,
'product' => $product,
);
jet_woo_builder_integration()->set_current_product( $this->__product_data );
return true;
}
$sample_product = get_post_meta( $post->ID, '_sample_product', true );
$args = array(
'post_type' => 'product',
'post_status' => array( 'publish', 'pending', 'draft', 'future' ),
'posts_per_page' => 1,
);
if ( ! empty( $sample_product ) ) {
$args['p'] = $sample_product;
}
$wp_query = new \WP_Query( $args );
if ( $wp_query->have_posts() ) {
foreach ( $wp_query->posts as $post ) {
setup_postdata( $post );
$product = wc_get_product( $post );
}
$this->__product_data = array(
'query' => $wp_query,
'post' => $post,
'product' => $product,
);
jet_woo_builder_integration()->set_current_product( $this->__product_data );
return true;
} else {
esc_html_e( 'Please add at least one product with "publish", "pending", "draft" or "future" status', 'jet-woo-builder' );
return false;
}
}
/**
* Restore previous data to avoid conflicts.
*
* @return void
*/
public function __reset_editor_product() {
if ( ( isset( $_GET['action'] ) && 'elementor' === $_GET['action'] ) || wp_doing_ajax() ) {
global $wp_query;
$wp_query = $this->__temp_query;
wp_reset_postdata();
}
}
/**
* Add icon control
*
* @param string $id
* @param array $args
* @param object $instance
*/
public function __add_advanced_icon_control( $id, array $args = array(), $instance = null ) {
if ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '2.6.0', '>=' ) ) {
$_id = $id; // old control id
$id = $this->__new_icon_prefix . $id;
$args['type'] = Controls_Manager::ICONS;
$args['fa4compatibility'] = $_id;
unset( $args['file'] );
unset( $args['default'] );
if ( isset( $args['fa5_default'] ) ) {
$args['default'] = $args['fa5_default'];
unset( $args['fa5_default'] );
}
} else {
$args['type'] = Controls_Manager::ICON;
unset( $args['fa5_default'] );
}
if ( null !== $instance ) {
$instance->add_control( $id, $args );
} else {
$this->add_control( $id, $args );
}
}
/**
* Prepare icon control ID for condition.
*
* @param string $id Old icon control ID.
* @return string
*/
public function __prepare_icon_id_for_condition( $id ) {
if ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '2.6.0', '>=' ) ) {
return $this->__new_icon_prefix . $id . '[value]';
}
return $id;
}
/**
* Print HTML icon template
*
* @param array $setting
* @param string $format
* @param string $icon_class
* @param bool $echo
*
* @return void|string
*/
public function __render_icon( $setting = null, $format = '%s', $icon_class = '', $echo = true ) {
if ( false === $this->__processed_item ) {
$settings = $this->get_settings_for_display();
} else {
$settings = $this->__processed_item;
}
$new_setting = $this->__new_icon_prefix . $setting;
$migrated = isset( $settings['__fa4_migrated'][ $new_setting ] );
$is_new = empty( $settings[ $setting ] ) && class_exists( 'Elementor\Icons_Manager' ) && Icons_Manager::is_migration_allowed();
$icon_html = '';
if ( $is_new || $migrated ) {
$attr = array( 'aria-hidden' => 'true' );
if ( ! empty( $icon_class ) ) {
$attr['class'] = $icon_class;
}
if ( isset( $settings[ $new_setting ] ) ) {
ob_start();
Icons_Manager::render_icon( $settings[ $new_setting ], $attr );
$icon_html = ob_get_clean();
}
} else if ( ! empty( $settings[ $setting ] ) ) {
if ( empty( $icon_class ) ) {
$icon_class = $settings[ $setting ];
} else {
$icon_class .= ' ' . $settings[ $setting ];
}
$icon_html = sprintf( '<i class="%s" aria-hidden="true"></i>', $icon_class );
}
if ( empty( $icon_html ) ) {
return;
}
if ( ! $echo ) {
return sprintf( $format, $icon_html );
}
printf( $format, $icon_html );
}
}

View File

@@ -0,0 +1,254 @@
<?php
/**
* Abstract post type registration class
*/
if ( ! class_exists( 'Jet_Woo_Builder_Shortcode_Base' ) ) {
abstract class Jet_Woo_Builder_Shortcode_Base {
/**
* Information about shortcode
*
* @var array
*/
public $info = array();
/**
* Information about shortcode
*
* @var array
*/
public $settings = array();
/**
* User attributes
*
* @var array
*/
public $atts = array();
/**
* Initialize post type
* @return void
*/
public function __construct() {
add_shortcode( $this->get_tag(), array( $this, 'do_shortcode' ) );
}
/**
* Returns shortcode tag. Should be rewritten in shortcode class.
*
* @return string
*/
public function get_tag() {
}
/**
* This function should be rewritten in shortcode class with attributes array.
*
* @return [type] [description]
*/
public function get_atts() {
return array();
}
/**
* Retrieve single shortocde argument
*
* @return void
*/
public function get_attr( $name = null ) {
if ( isset( $this->atts[ $name ] ) ) {
return $this->atts[ $name ];
}
$allowed = $this->get_atts();
if ( isset( $allowed[ $name ] ) && isset( $allowed[ $name ]['default'] ) ) {
return $allowed[ $name ]['default'];
} else {
return false;
}
}
/**
* Return hidden atts array
*
* @return array
*/
public function _hidden_atts() {
return array(
'_element_id' => '',
);
}
/**
* Get widget settings
*
* @return array
*/
public function get_settings(){
return $this->settings;
}
/**
* Set widget settings
*
* @param array $settings
*
* @return array
*/
public function set_settings( $settings = array() ){
return $this->settings = $settings;
}
/**
* This is main shortcode callback and it should be rewritten in shortcode class
*
* @param string $content [description]
*
* @return [type] [description]
*/
public function _shortcode( $content = null ) {
}
/**
* Print HTML markup if passed text not empty.
*
* @param string $text Passed text.
* @param string $format Required markup.
* @param array $args Additional variables to pass into format string.
* @param bool $echo Echo or return.
*
* @return string|void
*/
public function html( $text = null, $format = '%s', $args = array(), $echo = true ) {
if ( empty( $text ) ) {
return '';
}
$args = array_merge( array( $text ), $args );
$result = vsprintf( $format, $args );
if ( $echo ) {
echo $result;
} else {
return $result;
}
}
/**
* Return default shortcode attributes
*
* @return array
*/
public function default_atts() {
$result = array();
foreach ( $this->get_atts() as $attr => $data ) {
$result[ $attr ] = isset( $data['default'] ) ? $data['default'] : false;
}
foreach ( $this->_hidden_atts() as $attr => $default ) {
$result[ $attr ] = $default;
}
return $result;
}
/**
* Shortcode callback
*
* @return string
*/
public function do_shortcode( $atts = array(), $content = null ) {
$atts = shortcode_atts( $this->default_atts(), $atts, $this->get_tag() );
$this->css_classes = array();
if ( null !== $content ) {
$content = do_shortcode( $content );
}
$this->atts = $atts;
return $this->_shortcode( $content );
}
/**
* Get template depends to shortcode slug.
*
* @param string $name Template file name (without extension).
*
* @return string
*/
public function get_template( $name ) {
return jet_woo_builder()->get_template( $this->get_tag() . '/global/' . $name . '.php' );
}
/**
* Custom query used to filter products by price.
*
* @since 3.6.0
*
* @param array $args Query args.
* @param WC_Query $wp_query WC_Query object.
*
* @return array
*/
public function price_filter_post_clauses( $args, $wp_query ) {
global $wpdb;
if ( ! isset( $_GET['max_price'] ) && ! isset( $_GET['min_price'] ) ) {
return $args;
}
$current_min_price = isset( $_GET['min_price'] ) ? floatval( wp_unslash( $_GET['min_price'] ) ) : 0; // WPCS: input var ok, CSRF ok.
$current_max_price = isset( $_GET['max_price'] ) ? floatval( wp_unslash( $_GET['max_price'] ) ) : PHP_INT_MAX; // WPCS: input var ok, CSRF ok.
/**
* Adjust if the store taxes are not displayed how they are stored.
* Kicks in when prices excluding tax are displayed including tax.
*/
if ( wc_tax_enabled() && 'incl' === get_option( 'woocommerce_tax_display_shop' ) && ! wc_prices_include_tax() ) {
$tax_class = apply_filters( 'woocommerce_price_filter_widget_tax_class', '' ); // Uses standard tax class.
$tax_rates = WC_Tax::get_rates( $tax_class );
if ( $tax_rates ) {
$current_min_price -= WC_Tax::get_tax_total( WC_Tax::calc_inclusive_tax( $current_min_price, $tax_rates ) );
$current_max_price -= WC_Tax::get_tax_total( WC_Tax::calc_inclusive_tax( $current_max_price, $tax_rates ) );
}
}
$args['join'] = $this->append_product_sorting_table_join( $args['join'] );
$args['where'] .= $wpdb->prepare(
' AND wc_product_meta_lookup.min_price >= %f AND wc_product_meta_lookup.max_price <= %f ',
$current_min_price,
$current_max_price
);
return $args;
}
/**
* Join wc_product_meta_lookup to posts if not already joined.
*
* @param string $sql SQL join.
* @return string
*/
private function append_product_sorting_table_join( $sql ) {
global $wpdb;
if ( ! strstr( $sql, 'wc_product_meta_lookup' ) ) {
$sql .= " LEFT JOIN {$wpdb->wc_product_meta_lookup} wc_product_meta_lookup ON $wpdb->posts.ID = wc_product_meta_lookup.product_id ";
}
return $sql;
}
}
}

View File

@@ -0,0 +1,152 @@
<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Builder_Assets' ) ) {
/**
* Define Jet_Woo_Builder_Assets class
*/
class Jet_Woo_Builder_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(){
$screen = get_current_screen();
if ( 'woocommerce_page_wc-settings' === $screen->base ){
wp_enqueue_style(
'jet-woo-builder-admin',
jet_woo_builder()->plugin_url( 'assets/css/admin.css' ),
false,
jet_woo_builder()->get_version()
);
}
}
/**
* Enqueue public-facing stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
public function enqueue_styles() {
$font_path = WC()->plugin_url() . '/assets/fonts/';
$inline_font = '@font-face {
font-family: "WooCommerce";
src: url("' . $font_path . 'WooCommerce.eot");
src: url("' . $font_path . 'WooCommerce.eot?#iefix") format("embedded-opentype"),
url("' . $font_path . 'WooCommerce.woff") format("woff"),
url("' . $font_path . 'WooCommerce.ttf") format("truetype"),
url("' . $font_path . 'WooCommerce.svg#WooCommerce") format("svg");
font-weight: normal;
font-style: normal;
}';
wp_enqueue_style(
'jet-woo-builder',
jet_woo_builder()->plugin_url( 'assets/css/jet-woo-builder.css' ),
false,
jet_woo_builder()->get_version()
);
wp_enqueue_style(
'jet-woo-builder-frontend',
jet_woo_builder()->plugin_url( 'assets/css/lib/jetwoobuilder-frontend-font/css/jetwoobuilder-frontend-font.css' ),
false,
jet_woo_builder()->get_version()
);
wp_add_inline_style(
'jet-woo-builder',
$inline_font
);
}
/**
* Enqueue plugin scripts only with elementor scripts
*
* @return void
*/
public function enqueue_scripts() {
wp_enqueue_script(
'jet-woo-builder',
jet_woo_builder()->plugin_url( 'assets/js/jet-woo-builder' . $this->suffix() . '.js' ),
array( 'jquery', 'elementor-frontend' ),
jet_woo_builder()->get_version(),
true
);
wp_localize_script(
'jet-woo-builder',
'jetWooBuilderData',
apply_filters( 'jet-woo-builder/frontend/localize-data', array() )
);
}
/**
* [suffix description]
* @return [type] [description]
*/
public function suffix() {
return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
}
/**
* 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_Builder_Assets
*
* @return object
*/
function jet_woo_builder_assets() {
return Jet_Woo_Builder_Assets::get_instance();
}

View File

@@ -0,0 +1,267 @@
<?php
/**
* DB upgrder class
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Builder_DB_Upgrader' ) ) {
/**
* Define Jet_Woo_Builder_DB_Upgrader class
*/
class Jet_Woo_Builder_DB_Upgrader {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @access private
* @var object
*/
private static $instance = null;
/**
* Setting key
*
* @var string
*/
public $key = null;
public $shop_key = null;
/**
* Constructor for the class
*/
public function init() {
$this->key = jet_woo_builder_settings()->key;
$this->shop_key = jet_woo_builder_shop_settings()->options_key;
/**
* Plugin initialized on new Jet_Woo_Builder_DB_Upgrader call.
* Please ensure, that it called only on admin context
*/
$this->init_upgrader();
}
/**
* Initialize upgrader module
*
* @return void
*/
public function init_upgrader() {
new CX_Db_Updater( array(
'slug' => 'jet-woo-builder',
'version' => '1.5.0',
'callbacks' => array(
'1.2.0' => array(
array( $this, 'update_db_1_2_0' ),
),
'1.3.0' => array(
array( $this, 'update_db_1_3_0' ),
),
'1.5.0' => array(
array( $this, 'update_db_1_5_0' ),
),
),
)
);
}
/**
* Update db updater 1.2.0
*
* @return void
*/
public function update_db_1_2_0() {
$current_version_settings = get_option( $this->key, false );
$current_version_settings_shop = get_option( $this->shop_key, false );
if ( $current_version_settings_shop ) {
if ( ! isset( $current_version_settings_shop['custom_archive_page'] ) ) {
$current_version_settings_shop['custom_archive_page'] = 'no';
}
if ( ! isset( $current_version_settings_shop['archive_template'] ) ) {
$current_version_settings_shop['archive_template'] = 'default';
}
if ( ! isset( $current_version_settings_shop['shortcode_template'] ) ) {
$current_version_settings_shop['shortcode_template'] = 'default';
}
if ( ! isset( $current_version_settings_shop['search_template'] ) ) {
$current_version_settings_shop['search_template'] = 'default';
}
if ( ! isset( $current_version_settings_shop['cross_sells_template'] ) ) {
$current_version_settings_shop['cross_sells_template'] = 'default';
}
if ( ! isset( $current_version_settings_shop['related_template'] ) ) {
$current_version_settings_shop['related_template'] = 'default';
}
if ( ! isset( $current_version_settings_shop['related_products_per_page'] ) ) {
$current_version_settings_shop['related_products_per_page'] = 3;
}
if ( ! isset( $current_version_settings_shop['up_sells_products_per_page'] ) ) {
$current_version_settings_shop['up_sells_products_per_page'] = 3;
}
if ( ! isset( $current_version_settings_shop['cross_sells_products_per_page'] ) ) {
$current_version_settings_shop['cross_sells_products_per_page'] = 3;
}
update_option( $this->shop_key, $current_version_settings_shop );
}
if ( $current_version_settings ) {
if ( isset( $current_version_settings['archive_product_available_widgets'] ) ) {
if ( ! isset( $current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-add-to-cart'] ) ) {
$current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-add-to-cart'] = 'true';
}
if ( ! isset( $current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-cats'] ) ) {
$current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-cats'] = 'true';
}
if ( ! isset( $current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-product-excerpt'] ) ) {
$current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-product-excerpt'] = 'true';
}
if ( ! isset( $current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-product-price'] ) ) {
$current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-product-price'] = 'true';
}
if ( ! isset( $current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-product-rating'] ) ) {
$current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-product-rating'] = 'true';
}
if ( ! isset( $current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-product-thumbnail'] ) ) {
$current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-product-thumbnail'] = 'true';
}
if ( ! isset( $current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-product-title'] ) ) {
$current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-product-title'] = 'true';
}
if ( ! isset( $current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-sale-badge'] ) ) {
$current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-sale-badge'] = 'true';
}
if ( ! isset( $current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-stock-status'] ) ) {
$current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-stock-status'] = 'true';
}
if ( ! isset( $current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-tags'] ) ) {
$current_version_settings['archive_product_available_widgets']['jet-woo-builder-archive-tags'] = 'true';
}
update_option( $this->key, $current_version_settings );
}
}
}
/**
* Update db updater 1.3.0
*
* @return void
*/
public function update_db_1_3_0() {
$current_version_settings = get_option( $this->key, false );
$current_version_settings_shop = get_option( $this->shop_key, false );
if ( $current_version_settings_shop ) {
if ( ! isset( $current_version_settings_shop['custom_shop_page'] ) ) {
$current_version_settings_shop['custom_shop_page'] = 'no';
}
if ( ! isset( $current_version_settings_shop['shop_template'] ) ) {
$current_version_settings_shop['shop_template'] = 'default';
}
if ( ! isset( $current_version_settings_shop['custom_archive_category_page'] ) ) {
$current_version_settings_shop['custom_archive_category_page'] = 'no';
}
if ( ! isset( $current_version_settings_shop['category_template'] ) ) {
$current_version_settings_shop['category_template'] = 'default';
}
update_option( $this->shop_key, $current_version_settings_shop );
}
if ( $current_version_settings ) {
if ( isset( $current_version_settings['archive_category_available_widgets'] ) ) {
if ( ! isset( $current_version_settings['archive_category_available_widgets']['jet-woo-builder-archive-category-count'] ) ) {
$current_version_settings['archive_category_available_widgets']['jet-woo-builder-archive-category-count'] = 'true';
}
if ( ! isset( $current_version_settings['archive_category_available_widgets']['jet-woo-builder-archive-category-description'] ) ) {
$current_version_settings['archive_category_available_widgets']['jet-woo-builder-archive-category-description'] = 'true';
}
if ( ! isset( $current_version_settings['archive_category_available_widgets']['jet-woo-builder-archive-category-thumbnail'] ) ) {
$current_version_settings['archive_category_available_widgets']['jet-woo-builder-archive-category-thumbnail'] = 'true';
}
if ( ! isset( $current_version_settings['archive_category_available_widgets']['jet-woo-builder-archive-category-title'] ) ) {
$current_version_settings['archive_category_available_widgets']['jet-woo-builder-archive-category-title'] = 'true';
}
}
if ( isset( $current_version_settings['shop_product_available_widgets'] ) ) {
if ( ! isset( $current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-description'] ) ) {
$current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-description'] = 'true';
}
if ( ! isset( $current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-loop'] ) ) {
$current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-loop'] = 'true';
}
if ( ! isset( $current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-navigation'] ) ) {
$current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-navigation'] = 'true';
}
if ( ! isset( $current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-notices'] ) ) {
$current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-notices'] = 'true';
}
if ( ! isset( $current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-ordering'] ) ) {
$current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-ordering'] = 'true';
}
if ( ! isset( $current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-page-title'] ) ) {
$current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-page-title'] = 'true';
}
if ( ! isset( $current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-pagination'] ) ) {
$current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-pagination'] = 'true';
}
if ( ! isset( $current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-result-count'] ) ) {
$current_version_settings['shop_product_available_widgets']['jet-woo-builder-products-result-count'] = 'true';
}
update_option( $this->key, $current_version_settings );
}
}
}
/**
* Update db updater 1.5.0
*
* @return void
*/
public function update_db_1_5_0() {
$current_version_settings_shop = get_option( $this->shop_key, false );
if ( $current_version_settings_shop ) {
if ( ! isset( $current_version_settings_shop['custom_taxonomy_template'] ) ) {
$current_version_settings_shop['custom_taxonomy_template'] = 'no';
}
update_option( $this->shop_key, $current_version_settings_shop );
}
}
/**
* 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_Builder_Template_Functions
*
* @return object
*/
function jet_woo_builder_db_upgrader() {
return Jet_Woo_Builder_DB_Upgrader::get_instance();
}

View File

@@ -0,0 +1,189 @@
<?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_Builder_Documents' ) ) {
/**
* Define Jet_Woo_Builder_Documents class
*/
class Jet_Woo_Builder_Documents {
protected $current_type = null;
/**
* Constructor for the class
*/
function __construct() {
add_action( 'elementor/documents/register', array( $this, 'register_elementor_document_types' ) );
if ( ! class_exists( 'Jet_Theme_Core' ) && ! class_exists( 'Jet_Engine' ) ) {
add_action( 'elementor/dynamic_tags/before_render', array( $this, 'switch_to_preview_query' ) );
add_action( 'elementor/dynamic_tags/after_render', array( $this, 'restore_current_query' ) );
}
add_filter( 'admin_body_class', array( $this, 'set_admin_body_class' ) );
}
/**
* Set admin body classes
*
* @param $classes
*
* @return string
*/
function set_admin_body_class( $classes ) {
if ( is_admin() ) {
$document = Elementor\Plugin::instance()->documents->get( get_the_ID() );
if ( $document ){
$classes .= ' ' . $document->get_name() . '-document';
}
}
return $classes;
}
/**
* Set currently processed document type
*
* @param [type] $type [description]
*/
public function set_current_type( $type ) {
$this->current_type = $type;
}
/**
* Get currently processed document type
*
* @param [type] $type [description]
*/
public function get_current_type() {
return $this->current_type;
}
/**
* Return true if currently processed certain type
*
* @param string $type
*
* @return bool
*/
public function is_document_type( $type = 'single' ){
$doc_types = $this->get_document_types();
if( $doc_types[ $type ]['slug'] === $this->get_current_type() ){
return true;
}
return false;
}
/**
* Switch to specific preview query
*
* @return void
*/
public function switch_to_preview_query() {
$current_post_id = get_the_ID();
$document = Elementor\Plugin::instance()->documents->get_doc_or_auto_save( $current_post_id );
if ( ! is_object( $document ) || ! method_exists( $document, 'get_preview_as_query_args' ) ) {
return;
}
$new_query_vars = $document->get_preview_as_query_args();
if ( empty( $new_query_vars ) ) {
return;
}
Elementor\Plugin::instance()->db->switch_to_query( $new_query_vars );
}
/**
* Restore default query
*
* @return void
*/
public function restore_current_query() {
Elementor\Plugin::instance()->db->restore_current_query();
}
/**
* Get registered document types
*
* @return [type] [description]
*/
public function get_document_types() {
return array(
'single' => array(
'slug' => jet_woo_builder_post_type()->slug(),
'name' => __( 'Single', 'jet-woo-builder' ),
'file' => 'includes/documents/class-jet-woo-builder-document-single.php',
'class' => 'Jet_Woo_Builder_Document',
),
'archive' => array(
'slug' => jet_woo_builder_post_type()->slug() . '-archive',
'name' => __( 'Archive', 'jet-woo-builder' ),
'file' => 'includes/documents/class-jet-woo-builder-document-archive-product.php',
'class' => 'Jet_Woo_Builder_Archive_Document_Product',
),
'category' => array(
'slug' => jet_woo_builder_post_type()->slug() . '-category',
'name' => __( 'Category', 'jet-woo-builder' ),
'file' => 'includes/documents/class-jet-woo-builder-document-archive-category.php',
'class' => 'Jet_Woo_Builder_Archive_Document_Category',
),
'shop' => array(
'slug' => jet_woo_builder_post_type()->slug() . '-shop',
'name' => __( 'Shop', 'jet-woo-builder' ),
'file' => 'includes/documents/class-jet-woo-builder-document-archive.php',
'class' => 'Jet_Woo_Builder_Shop_Document',
),
);
}
/**
* Register apropriate document types for 'jet-woo-builder' post type
*
* @param Elementor\Core\Documents_Manager $documents_manager [description]
*
* @return void
*/
public function register_elementor_document_types( $documents_manager ) {
require jet_woo_builder()->plugin_path( 'includes/documents/class-jet-woo-builder-document-base.php' );
$document_types = $this->get_document_types();
require jet_woo_builder()->plugin_path( 'includes/documents/class-jet-woo-builder-not-supported.php' );
$documents_manager->register_document_type( 'jet-woo-builder-not-supported', 'Jet_Woo_Builder_Document_Not_Supported' );
foreach ( $document_types as $type => $data ) {
require jet_woo_builder()->plugin_path( $data['file'] );
$documents_manager->register_document_type( $data['slug'], $data['class'] );
}
}
}
}

View File

@@ -0,0 +1,183 @@
<?php
/**
* Class Jet_Woo_Builder_Macros
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Builder_Macros' ) ) {
/**
* Define Jet_Woo_Builder_Macros class
*/
class Jet_Woo_Builder_Macros {
/**
* Return available macros list
*
* @return [type] [description]
*/
public function get_all() {
return apply_filters( 'jet-woo-builder/macros/macros-list', array(
'percentage_sale' => array( $this, 'get_percentage_sale' ),
'numeric_sale' => array( $this, 'get_numeric_sale' ),
) );
}
/**
* Return verbosed macros list
*
* @return [type] [description]
*/
public function verbose_macros_list() {
$macros = $this->get_all();
$result = '';
$sep = '';
foreach ( $macros as $key => $data ) {
$result .= $sep . '%' . $key . '%';
$sep = ', ';
}
return $result;
}
/**
* Can be used for sale price budge. Returns percentage sale for current product
*
* @param int $precision
*
* @return string
*/
public function get_percentage_sale( $field_value, $precision = 0 ) {
global $product;
$percentage_sale = '';
if ( 'variable' === $product->get_type() ) {
$prices = $this->sort_variation_price( $product );
if ( $prices['regular_min'] > 0 && $prices['regular_max'] > 0 ) {
$percentage_min = round( 100 - ( $prices['sale_min'] / $prices['regular_min'] * 100 ), $precision );
$percentage_max = round( 100 - ( $prices['sale_max'] / $prices['regular_max'] * 100 ), $precision );
$percentage_sale = ( ( $percentage_min != $percentage_max ) ? ( $percentage_min . '&#37;' . '-' . $percentage_max . '&#37;' ) : $percentage_max . '&#37;' );
}
} else {
$regular_price = (float) $product->get_regular_price();
$sale_price = (float) $product->get_price();
if ( $sale_price > 0 && $regular_price > 0 ) {
$percentage_sale = round( 100 - ( $sale_price / $regular_price * 100 ), $precision ) . '&#37;';
}
}
return 0 < $percentage_sale ? $percentage_sale : '';
}
/**
* Can be used for sale price budge. Returns numeric sale for current product
*
* @return string
*/
public function get_numeric_sale() {
global $product;
$numeric_sale = '';
if ( 'variable' === $product->get_type() ) {
$prices = $this->sort_variation_price( $product );
if ( $prices['regular_min'] > 0 && $prices['regular_max'] > 0 ) {
$numeric_min = wc_price( $prices['regular_min'] - $prices['sale_min'] );
$numeric_max = wc_price( $prices['regular_max'] - $prices['sale_max'] );
$numeric_sale = ( ( $numeric_min != $numeric_max ) ? ( $numeric_min . '-' . $numeric_max ) : $numeric_max );
}
} else {
$regular_price = (float) $product->get_regular_price();
$sale_price = (float) $product->get_price();
$numeric_sale = wc_price( $regular_price - $sale_price );
}
return $numeric_sale;
}
/**
* Sort prices for variable product
*
* @param $product
*
* @return array
*/
public function sort_variation_price( $product ) {
$prices = $product->get_variation_prices( true );
foreach ( $prices['price'] as $product_id => $price ) {
$product_obj = wc_get_product( $product_id );
$prices['price'][ $product_id ] = wc_get_price_to_display( $product_obj );
}
asort( $prices['price'] );
asort( $prices['regular_price'] );
return array(
'sale_min' => current( $prices['price'] ),
'sale_max' => end( $prices['price'] ),
'regular_min' => current( $prices['regular_price'] ),
'regular_max' => end( $prices['regular_price'] ),
);
}
/**
* Do macros inside string
*
* @param [type] $string [description]
* @param [type] $field_value [description]
*
* @return [type] [description]
*/
public function do_macros( $string, $field_value = null ) {
$macros = $this->get_all();
return preg_replace_callback(
'/%([a-z_-]+)(\|[a-z0-9_-]+)?%/',
function ( $matches ) use ( $macros, $field_value ) {
$found = $matches[1];
if ( ! isset( $macros[ $found ] ) ) {
return $matches[0];
}
$cb = $macros[ $found ];
if ( ! is_callable( $cb ) ) {
return $matches[0];
}
$args = isset( $matches[2] ) ? ltrim( $matches[2], '|' ) : false;
return call_user_func( $cb, $field_value, $args );
}, $string
);
}
}
}

View File

@@ -0,0 +1,298 @@
<?php
/**
* Class description
*
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Builder_Parser' ) ) {
/**
* Define Jet_Woo_Builder_Parser class
*/
class Jet_Woo_Builder_Parser {
public $processed_documents = array();
private $jet_engine_object = null;
/**
* Macros regular expression
*
* @return [type] [description]
*/
public function macros_regex() {
return '/\%\%([a-z-_]+)(\:\:(.*?))?\%\%/';
}
/**
* Returns template content by template ID
*
* @param [type] $template_id [description]
*
* @return [type] [description]
*/
public function get_template_content( $template_id ) {
$this->set_jet_engine_object();
$render_method = apply_filters(
'jet-woo-builder/get-template-content/render-method',
jet_woo_builder_shop_settings()->get( 'widgets_render_method', 'macros' )
);
if ( 'elementor' === $render_method ) {
return $this->render_elementor_content( $template_id );
}
$content = get_post_meta( $template_id, '_jet_woo_builder_content', true );
if ( ! $content ) {
return;
}
$this->set_elementor_data( $template_id );
$parsed = $this->parse_content( $content );
$this->reset_jet_engine_object();
return $parsed;
}
public function set_jet_engine_object() {
if ( ! function_exists( 'jet_engine' ) ) {
return;
}
if ( null === $this->jet_engine_object ) {
$this->jet_engine_object = jet_engine()->listings->data->get_current_object();
}
global $post;
jet_engine()->listings->data->set_current_object( $post );
}
public function reset_jet_engine_object() {
if ( ! function_exists( 'jet_engine' ) ) {
return;
}
jet_engine()->listings->data->set_current_object( $this->jet_engine_object );
}
/**
* Render content with usual Elementor method
*
* @param [type] $template_id [description]
* @return [type] [description]
*/
public function render_elementor_content( $template_id ) {
return Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $template_id );
}
public function parse_content( $content ) {
$parsed = preg_replace_callback( $this->macros_regex(), array( $this, 'replace_callback' ), $content );
return $parsed;
}
public function replace_callback( $matches ) {
if ( empty( $matches[1] ) ) {
return $matches[0];
}
$widget = $this->get_widget_from_macros( $matches[1] );
if ( ! $widget ) {
return $matches[0];
}
if ( ! is_callable( array( $widget, 'render_callback' ) ) ) {
return $matches[0];
}
$settings = array();
if ( ! empty( $matches[3] ) ) {
$settings = $this->get_parsed_settings( $matches[3] );
}
$args = apply_filters( 'jet-woo-builder/render-callback/custom-args', array() );
ob_start();
call_user_func( array( $widget, 'render_callback' ), $settings, $args );
$content = ob_get_clean();
return $content;
}
/**
* Get settings array from string
* @return [type] [description]
*/
public function get_parsed_settings( $settings_string ) {
$settings_string = str_replace( '::', '', $settings_string );
$raw = explode( '&&', $settings_string );
if ( empty( $raw ) ) {
return array();
}
$settings = array();
foreach ( $raw as $setting ) {
$setting = explode( '="', $setting );
$settings[ $setting[0] ] = rtrim( $setting[1], '"' );
}
return $settings;
}
/**
* Render macros string
*
* @return [type] [description]
*/
public function get_macros_string( $macros = '', $settings = array() ) {
$settings_string = '';
$sep = '';
if ( ! empty( $settings ) ) {
foreach ( $settings as $key => $value ) {
$settings_string .= '::';
if ( is_array( $value ) ) {
$value = implode( '|', $value );
}
$settings_string .= sprintf( '%3$s%1$s="%2$s"', $key, $value, $sep );
$sep = '&&';
}
}
return sprintf( '%%%%%1$s%2$s%%%%', $macros, $settings_string );
}
/**
* Get widget class name from macros
*
* @return string
*/
public function get_widget_from_macros( $macros ) {
$class_name = str_replace( array( '-', '_' ), ' ', $macros );
$class_name = ucwords( $class_name );
$class_name = str_replace( ' ', '_', $class_name );
$class_name = 'Elementor\\' . $class_name;
if ( ! class_exists( $class_name ) ) {
$file = glob( jet_woo_builder()->plugin_path( 'includes/widgets/' ) . 'archive-*/' . $macros . '.php' );
if ( ! file_exists( $file[0] ) ) {
return false;
} else {
require $file[0];
}
}
return $class_name;
}
public function set_elementor_data( $post_id ) {
if ( in_array( $post_id, $this->processed_documents ) ) {
return;
}
$document = Elementor\Plugin::$instance->documents->get_doc_for_frontend( $post_id );
// Change the current post, so widgets can use `documents->get_current`.
Elementor\Plugin::$instance->documents->switch_to_document( $document );
if ( $document->is_editable_by_current_user() ) {
$this->admin_bar_edit_documents[ $document->get_main_id() ] = $document;
}
if ( $document->is_autosave() ) {
$css_file = new Elementor\Core\Files\CSS\Post_Preview( $document->get_post()->ID );
} else {
$css_file = new Elementor\Core\Files\CSS\Post( $post_id );
}
$css_meta = $css_file->get_meta();
if ( 'inline' === $css_meta['status'] ) {
printf( '<style id="elementor-post-%1$s">%2$s</style>', $css_file->get_post_id(), $css_meta['css'] ); // XSS ok.
} else {
$css_file->enqueue();
}
$this->maybe_print_css_directly( $css_file );
Elementor\Plugin::$instance->documents->restore_document();
$this->processed_documents[] = $post_id;
}
public function maybe_print_css_directly( $css_file ) {
$plugin = Elementor\Plugin::instance();
if ( $plugin->editor->is_edit_mode() ) {
printf( '<link rel="stylesheet" type="text/css" href="%s">', $css_file->get_url() );
}
}
/**
* 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_Builder_Parser
*
* @return object
*/
function class_name() {
return Jet_Woo_Builder_Parser::get_instance();
}

View File

@@ -0,0 +1,688 @@
<?php
/**
* Jet Woo Builder post type template
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Builder_Post_Type' ) ) {
/**
* Define Jet_Woo_Builder_Post_Type class
*/
class Jet_Woo_Builder_Post_Type {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
protected $post_type = 'jet-woo-builder';
protected $meta_key = 'jet-woo-builder-item';
/**
* Constructor for the class
*/
public function init() {
$this->register_post_type();
$this->init_meta();
if ( is_admin() ) {
add_action( 'admin_menu', array( $this, 'add_templates_page' ), 22 );
}
add_filter( 'option_elementor_cpt_support', array( $this, 'set_option_support' ) );
add_filter( 'default_option_elementor_cpt_support', array( $this, 'set_option_support' ) );
add_filter( 'body_class', array( $this, 'set_body_class' ) );
add_filter( 'post_class', array( $this, 'set_post_class' ) );
add_filter( 'the_content', array( $this, 'add_product_wrapper' ), 1000000 );
add_action( 'init', array( $this, 'fix_documents_types' ), 99 );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_templates_popup' ) );
add_action( 'admin_action_jet_woo_new_template', array( $this, 'create_template' ) );
add_filter( 'post_row_actions', array( $this, 'remove_view_action' ), 10, 2 );
add_filter( 'get_sample_permalink_html', array( $this, 'remove_permalink_action' ), 10, 5 );
}
/**
* Remove permalink html
*
* @param $return
* @param $post_id
* @param $new_title
* @param $new_slug
* @param $post
*
* @return string
*/
public function remove_permalink_action( $return, $post_id, $new_title, $new_slug, $post ) {
if ( $this->post_type === $post->post_type ) {
return '';
}
return $return;
}
/**
* Actions posts
*
* @param [type] $actions [description]
* @param [type] $post [description]
* @return [type] [description]
*/
public function remove_view_action( $actions, $post ) {
if ( $this->post_type === $post->post_type ) {
unset( $actions['view'] );
}
return $actions;
}
/**
* Create new template
*
* @return [type] [description]
*/
public function create_template() {
if ( ! current_user_can( 'edit_posts' ) ) {
wp_die(
esc_html__( 'You don\'t have permissions to do this', 'jet-woo-builder' ),
esc_html__( 'Error', 'jet-woo-builder' )
);
}
$doc_types = jet_woo_builder()->documents->get_document_types();
$default_type = $doc_types['single']['slug'];
$type = isset( $_REQUEST['template_type'] ) ? $_REQUEST['template_type'] : $default_type;
$name = isset( $_REQUEST['template_name'] ) ? $_REQUEST['template_name'] : '';
$documents = Elementor\Plugin::instance()->documents;
$doc_type = $documents->get_document_type( $type );
$template_data = '';
$templates = array();
if ( $type === $doc_types['single']['slug'] ) {
$template = isset( $_REQUEST['template_single'] ) ? $_REQUEST['template_single'] : '';
$templates = $this->predesigned_single_templates();
} else if( $type === $doc_types['archive']['slug'] ) {
$template = isset( $_REQUEST['template_archive'] ) ? $_REQUEST['template_archive'] : '';
$templates = $this->predesigned_archive_templates();
} else if( $type === $doc_types['category']['slug'] ) {
$template = isset( $_REQUEST['template_category'] ) ? $_REQUEST['template_category'] : '';
$templates = $this->predesigned_category_templates();
} else if( $type === $doc_types['shop']['slug'] ) {
$template = isset( $_REQUEST['template_shop'] ) ? $_REQUEST['template_shop'] : '';
$templates = $this->predesigned_shop_templates();
}
if ( $template ) {
if ( ! isset( $templates[ $template ] ) ) {
wp_die(
esc_html__( 'This template not registered', 'jet-woo-builder' ),
esc_html__( 'Error', 'jet-woo-builder' )
);
}
$data = $templates[ $template ];
$content = $data['content'];
ob_start();
include $content;
$template_data = ob_get_clean();
}
$meta_input = array(
'_elementor_edit_mode' => 'builder',
$doc_type::TYPE_META_KEY => esc_attr( $type ),
);
if ( ! empty( $template_data ) ) {
$meta_input['_elementor_data'] = wp_slash( $template_data );
}
$post_data = array(
'post_type' => $this->slug(),
'meta_input' => $meta_input,
);
if ( $name ) {
$post_data['post_title'] = esc_attr( $name );
}
$template_id = wp_insert_post( $post_data );
if ( ! $template_id ) {
wp_die(
esc_html__( 'Can\'t create template. Please try again', 'jet-woo-builder' ),
esc_html__( 'Error', 'jet-woo-builder' )
);
}
wp_redirect( Elementor\Utils::get_edit_link( $template_id ) );
die();
}
/**
* Enqueue templates popup assets
*
* @return [type] [description]
*/
public function enqueue_templates_popup( $hook ) {
if ( 'edit.php' !== $hook ) {
return;
}
if ( ! isset( $_GET['post_type'] ) || $this->slug() !== $_GET['post_type'] ) {
return;
}
wp_enqueue_style(
'jet-woo-builder-template-popup',
jet_woo_builder()->plugin_url( 'assets/css/template-popup.css' )
);
wp_enqueue_script(
'jet-woo-builder-template-popup',
jet_woo_builder()->plugin_url( 'assets/js/template-popup.js' ),
array( 'jquery' ),
jet_woo_builder()->get_version(),
true
);
wp_localize_script( 'jet-woo-builder-template-popup', 'JetWooPopupSettings', array(
'button' => '<a href="#" class="page-title-action jet-woo-new-template">' . __( 'Create from predesigned template', 'jet-woo-builder' ) . '</a>',
) );
add_action( 'admin_footer', array( $this, 'template_popup' ) );
}
/**
* Returns predesigned templates for single product
*
* @return array
*/
public function predesigned_single_templates() {
$base_url = jet_woo_builder()->plugin_url( 'includes/templates/single/' );
$base_dir = jet_woo_builder()->plugin_path( 'includes/templates/single/' );
return apply_filters( 'jet-woo-builder/predesigned-single-templates', array(
'layout-1' => array(
'content' => $base_dir . 'layout-1/template.json',
'thumb' => $base_url . 'layout-1/thumbnail.png',
),
'layout-2' => array(
'content' => $base_dir . 'layout-2/template.json',
'thumb' => $base_url . 'layout-2/thumbnail.png',
),
'layout-3' => array(
'content' => $base_dir . 'layout-3/template.json',
'thumb' => $base_url . 'layout-3/thumbnail.png',
),
'layout-4' => array(
'content' => $base_dir . 'layout-4/template.json',
'thumb' => $base_url . 'layout-4/thumbnail.png',
),
'layout-5' => array(
'content' => $base_dir . 'layout-5/template.json',
'thumb' => $base_url . 'layout-5/thumbnail.png',
),
'layout-6' => array(
'content' => $base_dir . 'layout-6/template.json',
'thumb' => $base_url . 'layout-6/thumbnail.png',
),
'layout-7' => array(
'content' => $base_dir . 'layout-7/template.json',
'thumb' => $base_url . 'layout-7/thumbnail.png',
),
'layout-8' => array(
'content' => $base_dir . 'layout-8/template.json',
'thumb' => $base_url . 'layout-8/thumbnail.png',
),
) );
}
/**
* Returns predesigned templates for archive product
*
* @return array
*/
public function predesigned_archive_templates() {
$base_url = jet_woo_builder()->plugin_url( 'includes/templates/archive/' );
$base_dir = jet_woo_builder()->plugin_path( 'includes/templates/archive/' );
return apply_filters( 'jet-woo-builder/predesigned-archive-templates', array(
'layout-1' => array(
'content' => $base_dir . 'layout-1/template.json',
'thumb' => $base_url . 'layout-1/thumbnail.png',
),
'layout-2' => array(
'content' => $base_dir . 'layout-2/template.json',
'thumb' => $base_url . 'layout-2/thumbnail.png',
),
'layout-3' => array(
'content' => $base_dir . 'layout-3/template.json',
'thumb' => $base_url . 'layout-3/thumbnail.png',
),
'layout-4' => array(
'content' => $base_dir . 'layout-4/template.json',
'thumb' => $base_url . 'layout-4/thumbnail.png',
),
) );
}
/**
* Returns predesigned templates for category product
*
* @return array
*/
public function predesigned_category_templates() {
$base_url = jet_woo_builder()->plugin_url( 'includes/templates/category/' );
$base_dir = jet_woo_builder()->plugin_path( 'includes/templates/category/' );
return apply_filters( 'jet-woo-builder/predesigned-category-templates', array(
'layout-1' => array(
'content' => $base_dir . 'layout-1/template.json',
'thumb' => $base_url . 'layout-1/thumbnail.png',
),
'layout-2' => array(
'content' => $base_dir . 'layout-2/template.json',
'thumb' => $base_url . 'layout-2/thumbnail.png',
),
'layout-3' => array(
'content' => $base_dir . 'layout-3/template.json',
'thumb' => $base_url . 'layout-3/thumbnail.png',
),
'layout-4' => array(
'content' => $base_dir . 'layout-4/template.json',
'thumb' => $base_url . 'layout-4/thumbnail.png',
),
) );
}
/**
* Returns predesigned templates for shop product
*
* @return array
*/
public function predesigned_shop_templates() {
$base_url = jet_woo_builder()->plugin_url( 'includes/templates/shop/' );
$base_dir = jet_woo_builder()->plugin_path( 'includes/templates/shop/' );
return apply_filters( 'jet-woo-builder/predesigned-shop-templates', array(
'layout-1' => array(
'content' => $base_dir . 'layout-1/template.json',
'thumb' => $base_url . 'layout-1/thumbnail.png',
),
'layout-2' => array(
'content' => $base_dir . 'layout-2/template.json',
'thumb' => $base_url . 'layout-2/thumbnail.png',
),
'layout-3' => array(
'content' => $base_dir . 'layout-3/template.json',
'thumb' => $base_url . 'layout-3/thumbnail.png',
),
'layout-4' => array(
'content' => $base_dir . 'layout-4/template.json',
'thumb' => $base_url . 'layout-4/thumbnail.png',
),
) );
}
/**
* Template popup content
*
* @return [type] [description]
*/
public function template_popup() {
$action = add_query_arg(
array(
'action' => 'jet_woo_new_template',
),
esc_url( admin_url( 'admin.php' ) )
);
include jet_woo_builder()->get_template( 'template-popup.php' );
}
/**
* Maybe fix document types for Jet Woo templates
*
* @return void
*/
public function fix_documents_types() {
if ( ! isset( $_GET['fix_jet_woo_templates'] ) ) {
return;
}
$args = array(
'post_type' => $this->slug(),
'post_status' => array( 'publish', 'pending', 'draft', 'future' ),
'posts_per_page' => -1,
);
$wp_query = new WP_Query( $args );
$documents = Elementor\Plugin::instance()->documents;
$doc_type = $documents->get_document_type( $this->slug() );
if ( ! $wp_query->have_posts() ) {
return false;
}
foreach ( $wp_query->posts as $post ) {
update_post_meta( $post->ID, $doc_type::TYPE_META_KEY, $this->slug() );
}
}
/**
* Add .product wrapper to content
*
* @param string $content
*/
public function add_product_wrapper( $content ) {
if ( is_singular( $this->slug() ) && isset( $_GET['elementor-preview'] ) ) {
$content = sprintf( '<div class="product">%s</div>', $content );
}
return $content;
}
/**
* Add 'single-product' class to body on template pages
*
* @param array $classes Default classes list.
* @return array
*/
public function set_body_class( $classes ) {
if ( is_singular( $this->slug() ) ) {
$classes[] = 'single-product woocommerce';
}
return $classes;
}
/**
* Add 'product' class to post on template pages
*
* @param array $classes Default classes list.
* @return array
*/
public function set_post_class( $classes ) {
if ( is_singular( $this->slug() ) ) {
$classes[] = 'product';
}
return $classes;
}
/**
* Jet Woo Builder page
*/
public function add_templates_page() {
add_submenu_page(
'jet-dashboard',
esc_html__( 'Jet Woo Templates', 'jet-woo-builder' ),
esc_html__( 'Jet Woo Templates', 'jet-woo-builder' ),
'edit_pages',
'edit.php?post_type=' . $this->slug()
);
}
/**
* Returns post type slug
*
* @return string
*/
public function slug() {
return $this->post_type;
}
/**
* Returns Jet Woo Builder meta key
*
* @return string
*/
public function meta_key() {
return $this->meta_key;
}
/**
* Add elementor support for jet woo builder items.
*/
public function set_option_support( $value ) {
if ( empty( $value ) ) {
$value = array();
}
return array_merge( $value, array( $this->slug() ) );
}
/**
* Register post type
*
* @return void
*/
public function register_post_type() {
$labels = array(
'name' => esc_html__( 'Jet Woo Templates', 'jet-woo-builder' ),
'singular_name' => esc_html__( 'Jet Woo Template', 'jet-woo-builder' ),
'add_new' => esc_html__( 'Add New Template', 'jet-woo-builder' ),
'add_new_item' => esc_html__( 'Add New Template', 'jet-woo-builder' ),
'edit_item' => esc_html__( 'Edit Template', 'jet-woo-builder' ),
'menu_name' => esc_html__( 'Jet Woo Templates', 'jet-woo-builder' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'description',
'taxonomies' => array(),
'public' => true,
'show_ui' => true,
'show_in_menu' => false,
'show_in_admin_bar' => true,
'menu_position' => null,
'menu_icon' => null,
'show_in_nav_menus' => false,
'publicly_queryable' => true,
'exclude_from_search' => true,
'has_archive' => false,
'query_var' => true,
'can_export' => true,
'rewrite' => false,
'capability_type' => 'post',
'supports' => array( 'title' ),
);
register_post_type( $this->slug(), $args );
}
/**
* Initialize template metabox
*
* @return void
*/
public function init_meta() {
new Cherry_X_Post_Meta( array(
'id' => 'template-settings',
'title' => esc_html__( 'Template Settings', 'jet-woo-builder' ),
'page' => array( $this->slug() ),
'context' => 'normal',
'priority' => 'high',
'callback_args' => false,
'builder_cb' => array( $this, 'get_builder' ),
'fields' => array(
'_sample_product' => array(
'type' => 'select',
'element' => 'control',
'options' => false,
'options_callback' => array( $this, 'get_products' ),
'label' => esc_html__( 'Sample Product for Editing (if not selected - will be used latest added)', 'jet-woo-builder' ),
'sanitize_callback' => 'esc_attr',
),
),
) );
}
/**
* Return products list
*
* @return void
*/
public function get_products() {
$products = get_posts( array(
'post_type' => 'product',
'post_status' => array( 'publish', 'pending', 'draft', 'future' ),
'posts_per_page' => 100,
) );
$default = array(
'' => __( 'Select Product...', 'jet-woo-builder' ),
);
if ( empty( $products ) ) {
return $default;
}
$products = wp_list_pluck( $products, 'post_title', 'ID' );
return $default + $products;
}
/**
* Return UI builder instance
*
* @return [type] [description]
*/
public function get_builder() {
$builder_data = jet_woo_builder()->module_loader->get_included_module_data( 'cherry-x-interface-builder.php' );
return new CX_Interface_Builder(
array(
'path' => $builder_data['path'],
'url' => $builder_data['url'],
)
);
}
/**
* Return Templates list from options
*
* @return void
*/
public function get_templates_list( $type = 'all' ) {
$args = array(
'posts_per_page' => -1,
'post_status' => 'publish',
'post_type' => $this->slug(),
);
if ( 'all' !== $type ) {
$doc_types = jet_woo_builder()->documents->get_document_types();
$default_type = $doc_types['single']['slug'];
$type = isset( $doc_types[ $type ] ) ? $doc_types[ $type ]['slug'] : $default_type;
$documents = Elementor\Plugin::instance()->documents;
$doc_type = $documents->get_document_type( $type );
$args['meta_query'] = array(
array(
'key' => $doc_type::TYPE_META_KEY,
'value' => $type,
),
);
}
$templates = get_posts( $args );
return $templates;
}
/**
* Returns templates list for select options
*
* @return [type] [description]
*/
public function get_templates_list_for_options( $type = 'all' ) {
$templates = $this->get_templates_list( $type );
$default = array(
'' => esc_html__( 'Select Template...', 'jet-woo-builder' ),
);
if ( empty( $templates ) ) {
return $default;
}
return $default + wp_list_pluck( $templates, 'post_title', '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_Builder_Post_Type
*
* @return object
*/
function jet_woo_builder_post_type() {
return Jet_Woo_Builder_Post_Type::get_instance();
}

View File

@@ -0,0 +1,119 @@
<?php
/**
* Class description
*
* @package Jet Woo Builder
* @author Crocoblock
* @license GPL-2.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Builder_Shortcodes' ) ) {
/**
* Define Jet_Woo_Builder_Shortcodes class
*/
class Jet_Woo_Builder_Shortcodes {
/**
* 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 $shortocdes = array();
/**
* Initalize integration hooks
*
* @return void
*/
public function init() {
add_action( 'init', array( $this, 'register_shortcodes' ), 30 );
}
/**
* Register plugins shortcodes
*
* @return void
*/
public function register_shortcodes() {
require jet_woo_builder()->plugin_path( 'includes/base/class-jet-woo-builder-shortcode-base.php' );
foreach ( glob( jet_woo_builder()->plugin_path( 'includes/shortcodes/' ) . '*.php' ) as $file ) {
$this->register_shortcode( $file );
}
}
/**
* Call chortcode instance from passed file.
*
* @return void
*/
public function register_shortcode( $file ) {
$base = basename( str_replace( '.php', '', $file ) );
$class = ucwords( str_replace( '-', ' ', $base ) );
$class = str_replace( ' ', '_', $class );
require $file;
if ( ! class_exists( $class ) ) {
return;
}
$shortcode = new $class;
$this->shortocdes[ $shortcode->get_tag() ] = $shortcode;
}
/**
* Get shortcode class instance by tag
*
* @param [type] $tag [description]
* @return [type] [description]
*/
public function get_shortcode( $tag ) {
return isset( $this->shortocdes[ $tag ] ) ? $this->shortocdes[ $tag ] : false;
}
/**
* 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_Builder_Shortcodes
*
* @return object
*/
function jet_woo_builder_shortocdes() {
return Jet_Woo_Builder_Shortcodes::get_instance();
}

View File

@@ -0,0 +1,393 @@
<?php
/**
* WooCommerce template functions class
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Builder_Template_Functions' ) ) {
/**
* Define Jet_Woo_Builder_Template_Functions class
*/
class Jet_Woo_Builder_Template_Functions {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Returns sale badge
*
* @return string
*/
public function get_product_sale_flash( $badge_text = '' ) {
global $product;
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
if ( $product->is_on_sale() ) {
return sprintf( '<div class="jet-woo-product-badge jet-woo-product-badge__sale">%s</div>', $badge_text );
}
}
/**
* Returns stock status html
*
* @return string
*/
public function get_product_stock_status() {
global $product;
return wc_get_stock_html( $product );
}
/**
* Returns product thumbnail
*
* @param string $image_size
* @param bool $use_thumb_effect
* @param array $attr
*
* @return mixed|string|void
*/
public function get_product_thumbnail( $image_size = 'thumbnail_size', $use_thumb_effect = false, $attr = array() ) {
global $product;
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
$thumbnail_id = get_post_thumbnail_id( $product->get_id() );
$enable_thumb_effect = filter_var( jet_woo_builder_settings()->get( 'enable_product_thumb_effect' ), FILTER_VALIDATE_BOOLEAN );
$placeholder_src = apply_filters( 'jet-woo-builder/template-functions/product-thumbnail-placeholder', Elementor\Utils::get_placeholder_image_src() );
$attr = array( 'data-no-lazy' => '1' );
if ( empty( $thumbnail_id ) ) {
return sprintf( '<img src="%s" alt="">', $placeholder_src );
}
$html = wp_get_attachment_image( $thumbnail_id, $image_size, false, $attr );
if ( $use_thumb_effect && $enable_thumb_effect ) {
$html = $this->add_thumb_effect( $html, $product, $image_size, $attr );
}
return apply_filters( 'jet-woo-builder/template-functions/product-thumbnail', $html );
}
/**
* Add one more thumbnail for products in loop
*
* @param $html
* @param $product
* @param $image_size
* @param $attr
*
* @return string
*/
public function add_thumb_effect( $html, $product, $image_size, $attr ) {
$thumb_effect = jet_woo_builder_settings()->get( 'product_thumb_effect' );
$attachment_ids = $product->get_gallery_image_ids();
if ( empty( $attachment_ids[0] ) ) {
return $html;
}
if ( empty( $thumb_effect ) ) {
$thumb_effect = 'slide-left';
}
$effect = $thumb_effect;
$additional_id = $attachment_ids[0];
$additional_img = wp_get_attachment_image( $additional_id, $image_size, false, $attr );
$html = sprintf(
'<div class="jet-woo-product-thumbs effect-%3$s"><div class="jet-woo-product-thumbs__inner">%1$s%2$s</div></div>',
$html, $additional_img, $effect
);
return $html;
}
/**
* Returns category thumbnail
*
* @return string
*/
public function get_category_thumbnail( $category_id, $image_size = 'thumbnail_size' ) {
$thumbnail_id = get_term_meta( $category_id, 'thumbnail_id', true );
$placeholder_src = Elementor\Utils::get_placeholder_image_src();
if ( empty( $thumbnail_id ) ) {
return sprintf( '<img src="%s" alt="">', $placeholder_src );
}
$html = wp_get_attachment_image( $thumbnail_id, $image_size, false );
return apply_filters( 'jet-woo-builder/template-functions/category-thumbnail', $html );
}
/**
* Return product sku
*
* @param $product
* @param $settings
*
* @return string
*/
public function get_product_sku() {
global $product;
if ( ! $product ) {
return '';
}
if ( $product->get_sku() ) {
$sku = sprintf(
'<span class="sku">%s</span>',
$product->get_sku()
);
return apply_filters( 'jet-woo-builder/template-functions/sku', $sku );
}
}
/**
* Returns product title
*
* @return string
*/
public function get_product_title() {
global $product;
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
return get_the_title( $product->get_id() );
}
/**
* Returns product title
*
* @return string
*/
public function get_product_title_link() {
global $product;
return esc_url( get_permalink() );
}
/**
* Returns product title
*
* @return string
*/
public function get_product_rating() {
global $product;
if ( get_option( 'woocommerce_enable_review_rating' ) === 'no' ) {
return;
}
$format = apply_filters(
'jet-woo-builder/template-functions/product-rating',
'<span class="product-rating__stars">%s</span>'
);
$rating = $product->get_average_rating();
$count = 0;
$html = 0 < $rating ? sprintf( $format, wc_get_star_rating_html( $rating, $count ) ) : '';
return $html;
}
public function get_product_custom_rating( $icon = 'fa fa-star', $show_empty_rating ) {
global $product;
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
if ( get_option( 'woocommerce_enable_review_rating' ) === 'no' ) {
return false;
}
$rating = $product->get_average_rating();
if ( $rating > 0 || $show_empty_rating ){
$html = '<span class="product-rating__content">';
if ( ! is_rtl() ) {
for ( $i = 1; $i <= 5; $i ++ ) {
$is_active_class = ( $i <= $rating ) ? 'active' : '';
$html .= sprintf( '<span class="product-rating__icon %s %s"></span>', $icon, $is_active_class );
}
} else {
for ( $i = 5; $i >= 1; $i -- ) {
$is_active_class = ( $i <= $rating ) ? 'active' : '';
$html .= sprintf( '<span class="product-rating__icon %s %s"></span>', $icon, $is_active_class );
}
}
$html .= '</span>';
return $html;
} else {
return false;
}
}
/**
* Returns product price
*
* @return string
*/
public function get_product_price() {
global $product;
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
$price_html = $product->get_price_html();
return apply_filters( 'jet-woo-builder/template-functions/product-price', $price_html );
}
/**
* Returns product excerpt
*
* @return string
*/
public function get_product_excerpt() {
global $product;
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
if ( ! $product->get_short_description() ) {
return;
}
return apply_filters( 'jet-woo-builder/template-functions/product-excerpt', get_the_excerpt( $product->get_id() ) );
}
/**
* Returns product add to cart button
*
* @return string
*/
public function get_product_add_to_cart_button( $classes = array() ) {
global $product;
$args = array();
$ajax_add_to_cart_enabled = 'yes' === get_option( 'woocommerce_enable_ajax_add_to_cart' ) ? true : false;
if ( $product ) {
$defaults = apply_filters(
'jet-woo-builder/template-functions/product-add-to-cart-settings',
array(
'quantity' => 1,
'class' => implode( ' ', array_filter( array(
'button',
$classes,
'product_type_' . $product->get_type(),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
$product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() && $ajax_add_to_cart_enabled ? 'ajax_add_to_cart' : '',
) ) ),
'attributes' => array(
'data-product_id' => $product->get_id(),
'data-product_sku' => $product->get_sku(),
'aria-label' => $product->add_to_cart_description(),
'rel' => 'nofollow',
),
)
);
$args = wp_parse_args( $args, $defaults );
wc_get_template( 'loop/add-to-cart.php', $args );
}
}
/**
* Returns product categories list
*
* @return string
*/
public function get_product_categories_list() {
global $product;
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
$separator = '<span class="separator">&#44;&nbsp;</span></li><li>';
$before = '<ul><li>';
$after = '</li></ul>';
return get_the_term_list( $product->get_id(), 'product_cat', $before, $separator, $after );
}
/**
* Returns product categories list
*
* @return string
*/
public function get_product_tags_list() {
global $product;
$separator = '<span class="separator">&#44;&nbsp;</span></li><li>';
$before = '<ul><li>';
$after = '</li></ul>';
return get_the_term_list( $product->get_id(), 'product_tag', $before, $separator, $after );
}
/**
* 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_Builder_Template_Functions
*
* @return object
*/
function jet_woo_builder_template_functions() {
return Jet_Woo_Builder_Template_Functions::get_instance();
}

View File

@@ -0,0 +1,621 @@
<?php
/**
* Cherry addons tools class
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Builder_Tools' ) ) {
/**
* Define Jet_Woo_Builder_Tools class
*/
class Jet_Woo_Builder_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-builder' ), ), $result );
}
/**
* Get categories list.
*
* @return array
*/
public function get_categories() {
$categories = get_categories();
if ( empty( $categories ) || ! is_array( $categories ) ) {
return array();
}
return wp_list_pluck( $categories, 'name', 'term_id' );
}
/**
* 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-builder/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 orderby_arr() {
return array(
'none' => esc_html__( 'None', 'jet-woo-builder' ),
'ID' => esc_html__( 'ID', 'jet-woo-builder' ),
'author' => esc_html__( 'Author', 'jet-woo-builder' ),
'title' => esc_html__( 'Title', 'jet-woo-builder' ),
'name' => esc_html__( 'Name (slug)', 'jet-woo-builder' ),
'date' => esc_html__( 'Date', 'jet-woo-builder' ),
'modified' => esc_html__( 'Modified', 'jet-woo-builder' ),
'rand' => esc_html__( 'Rand', 'jet-woo-builder' ),
'comment_count' => esc_html__( 'Comment Count', 'jet-woo-builder' ),
'menu_order' => esc_html__( 'Menu Order', 'jet-woo-builder' ),
);
}
/**
* Returns allowed order fields for options
*
* @return array
*/
public function order_arr() {
return array(
'desc' => esc_html__( 'Descending', 'jet-woo-builder' ),
'asc' => esc_html__( 'Ascending', 'jet-woo-builder' ),
);
}
/**
* Returns allowed order by fields for options
*
* @return array
*/
public function vertical_align_attr() {
return array(
'baseline' => esc_html__( 'Baseline', 'jet-woo-builder' ),
'top' => esc_html__( 'Top', 'jet-woo-builder' ),
'middle' => esc_html__( 'Middle', 'jet-woo-builder' ),
'bottom' => esc_html__( 'Bottom', 'jet-woo-builder' ),
'sub' => esc_html__( 'Sub', 'jet-woo-builder' ),
'super' => esc_html__( 'Super', 'jet-woo-builder' ),
'text-top' => esc_html__( 'Text Top', 'jet-woo-builder' ),
'text-bottom' => esc_html__( 'Text Bottom', 'jet-woo-builder' ),
);
}
/**
* 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;
}
/**
* Returns carousel arrow
*
* @param array $classes Arrow additional classes list.
*
* @return string
*/
public function get_carousel_arrow( $classes ) {
$format = apply_filters( 'jet_woo_builder/carousel/arrows_format', '<div class="%s jet-arrow"></div>', $classes );
return sprintf( $format, implode( ' ', $classes ) );
}
/**
* 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-builder/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_builder/carousel/available_arrows/prev',
array(
'fa fa-angle-left' => __( 'Angle', 'jet-woo-builder' ),
'fa fa-chevron-left' => __( 'Chevron', 'jet-woo-builder' ),
'fa fa-angle-double-left' => __( 'Angle Double', 'jet-woo-builder' ),
'fa fa-arrow-left' => __( 'Arrow', 'jet-woo-builder' ),
'fa fa-caret-left' => __( 'Caret', 'jet-woo-builder' ),
'fa fa-long-arrow-left' => __( 'Long Arrow', 'jet-woo-builder' ),
'fa fa-arrow-circle-left' => __( 'Arrow Circle', 'jet-woo-builder' ),
'fa fa-chevron-circle-left' => __( 'Chevron Circle', 'jet-woo-builder' ),
'fa fa-caret-square-o-left' => __( 'Caret Square', 'jet-woo-builder' ),
)
);
}
/**
* Return availbale arrows list
* @return [type] [description]
*/
public function get_available_next_arrows_list() {
return apply_filters(
'jet_woo_builder/carousel/available_arrows/next',
array(
'fa fa-angle-right' => __( 'Angle', 'jet-woo-builder' ),
'fa fa-chevron-right' => __( 'Chevron', 'jet-woo-builder' ),
'fa fa-angle-double-right' => __( 'Angle Double', 'jet-woo-builder' ),
'fa fa-arrow-right' => __( 'Arrow', 'jet-woo-builder' ),
'fa fa-caret-right' => __( 'Caret', 'jet-woo-builder' ),
'fa fa-long-arrow-right' => __( 'Long Arrow', 'jet-woo-builder' ),
'fa fa-arrow-circle-right' => __( 'Arrow Circle', 'jet-woo-builder' ),
'fa fa-chevron-circle-right' => __( 'Chevron Circle', 'jet-woo-builder' ),
'fa fa-caret-square-o-right' => __( 'Caret Square', 'jet-woo-builder' ),
)
);
}
/**
* Return availbale rating icon list
* @return [type] [description]
*/
public function get_available_rating_icons_list() {
return apply_filters(
'jet_woo_builder/available_rating_list/icons',
array(
'jetwoo-front-icon-rating-1' => __( 'Rating 1', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-2' => __( 'Rating 2', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-3' => __( 'Rating 3', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-4' => __( 'Rating 4', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-5' => __( 'Rating 5', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-6' => __( 'Rating 6', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-7' => __( 'Rating 7', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-8' => __( 'Rating 8', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-9' => __( 'Rating 9', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-10' => __( 'Rating 10', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-11' => __( 'Rating 11', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-12' => __( 'Rating 12', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-13' => __( 'Rating 13', 'jet-woo-builder' ),
'jetwoo-front-icon-rating-14' => __( 'Rating 14', 'jet-woo-builder' ),
)
);
}
/**
* Apply carousel wrappers for shortcode content if carousel is enabled.
*
* @param string $content Module content.
* @param array $settings Module settings.
*
* @return string
*/
public function get_carousel_wrapper_atts( $content = null, $settings = array() ) {
if ( 'yes' !== $settings['carousel_enabled'] ) {
return $content;
}
$carousel_settings = array(
'carousel_direction' => $settings['carousel_direction'],
'columns' => $settings['columns'],
'columns_tablet' => $settings['columns_tablet'],
'columns_mobile' => $settings['columns_mobile'],
'autoplay_speed' => $settings['autoplay_speed'],
'autoplay' => $settings['autoplay'],
'infinite' => $settings['infinite'],
'centered' => $settings['centered'],
'pause_on_interactions' => $settings['pause_on_interactions'],
'speed' => $settings['speed'],
'arrows' => $settings['arrows'],
'prev_arrow' => ! is_rtl() ? $this->prepare_arrow( $settings['prev_arrow'] ) : $this->prepare_arrow( $settings['next_arrow'] ),
'next_arrow' => ! is_rtl() ? $this->prepare_arrow( $settings['next_arrow'] ) : $this->prepare_arrow( $settings['prev_arrow'] ),
'dots' => $settings['dots'],
'slides_to_scroll' => ( $settings['columns'] !== '1' ) ? $settings['slides_to_scroll'] : 1,
'effect' => isset( $settings['effect'] ) ? $settings['effect'] : 'slide',
);
$options = apply_filters( 'jet-woo-builder/tools/carousel/pre-options', $carousel_settings, $settings );
$options = array(
'direction' => $carousel_settings['carousel_direction'],
'slidesToShow' => array(
'desktop' => absint( $carousel_settings['columns'] ),
'tablet' => absint( $carousel_settings['columns_tablet'] ),
'mobile' => absint( $carousel_settings['columns_mobile'] ),
),
'slidesPerGroup' => absint( $carousel_settings['slides_to_scroll'] ),
'loop' => filter_var( $carousel_settings['infinite'], FILTER_VALIDATE_BOOLEAN ),
'centeredSlides' => filter_var( $carousel_settings['centered'], FILTER_VALIDATE_BOOLEAN ),
'speed' => absint( $carousel_settings['speed'] ),
);
if ( filter_var( $carousel_settings['autoplay'], FILTER_VALIDATE_BOOLEAN ) ) {
$options['autoplay'] = array(
'delay' => isset( $carousel_settings['autoplay_speed'] ) ? absint( $carousel_settings['autoplay_speed'] ) : '5000',
'disableOnInteraction' => filter_var( $carousel_settings['pause_on_interactions'], FILTER_VALIDATE_BOOLEAN ),
);
}
if ( 1 === absint( $carousel_settings['columns'] && 'fade' === $carousel_settings['effect'] ) ) {
$options['effect'] = $carousel_settings['effect'];
}
$options = apply_filters( 'jet-woo-builder/tools/carousel/options', $options, $settings );
$pagination = filter_var( $carousel_settings['dots'], FILTER_VALIDATE_BOOLEAN ) ? '<div class="swiper-pagination"></div>' : '';
$swiper_prev_arrow = filter_var( $carousel_settings['arrows'], FILTER_VALIDATE_BOOLEAN ) ? $this->get_carousel_arrow( array( $carousel_settings['prev_arrow'], 'prev-arrow', 'jet-swiper-button-prev' ) ) : '';
$swiper_next_arrow = filter_var( $carousel_settings['arrows'], FILTER_VALIDATE_BOOLEAN ) ? $this->get_carousel_arrow( array( $carousel_settings['next_arrow'], 'next-arrow', 'jet-swiper-button-next' ) ) : '';
$is_rtl = is_rtl() ? 'rtl' : 'ltr';
return sprintf(
'<div class="jet-woo-carousel swiper-container" data-slider_options="%1$s" dir="%6$s"> %2$s %3$s %4$s %5$s </div>',
htmlspecialchars( json_encode( $options ) ), $content, $pagination, $swiper_prev_arrow, $swiper_next_arrow, $is_rtl
);
}
/**
* Get term permalink.
*
* @since 1.0.0
* @return string
*/
public function get_term_permalink( $id = 0 ) {
return esc_url( get_category_link( $id ) );
}
/**
* 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 || '' === $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;
}
/**
* Return available HTML title tags list
*
* @return array
*/
public function get_available_title_html_tags() {
return array(
'h1' => esc_html__( 'H1', 'jet-elements' ),
'h2' => esc_html__( 'H2', 'jet-elements' ),
'h3' => esc_html__( 'H3', 'jet-elements' ),
'h4' => esc_html__( 'H4', 'jet-elements' ),
'h5' => esc_html__( 'H5', 'jet-elements' ),
'h6' => esc_html__( 'H6', 'jet-elements' ),
'div' => esc_html__( 'div', 'jet-elements' ),
'span' => esc_html__( 'span', 'jet-elements' ),
'p' => esc_html__( 'p', 'jet-elements' ),
);
}
/**
* Is FA5 migration.
*
* @return bool
*/
public static function is_fa5_migration() {
if ( defined( 'ELEMENTOR_VERSION' )
&& version_compare( ELEMENTOR_VERSION, '2.6.0', '>=' )
&& Elementor\Icons_Manager::is_migration_allowed()
) {
return true;
}
return false;
}
/**
* FA5 arrows map.
*
* @return array
*/
public static function get_fa5_arrows_map() {
return apply_filters(
'jet-search/fa5_arrows_map',
array(
'fa fa-angle-left' => 'fas fa-angle-left',
'fa fa-chevron-left' => 'fas fa-chevron-left',
'fa fa-angle-double-left' => 'fas fa-angle-double-left',
'fa fa-arrow-left' => 'fas fa-arrow-left',
'fa fa-caret-left' => 'fas fa-caret-left',
'fa fa-long-arrow-left' => 'fas fa-long-arrow-alt-left',
'fa fa-arrow-circle-left' => 'fas fa-arrow-circle-left',
'fa fa-chevron-circle-left' => 'fas fa-chevron-circle-left',
'fa fa-caret-square-o-left' => 'fas fa-caret-square-left',
'fa fa-angle-right' => 'fas fa-angle-right',
'fa fa-chevron-right' => 'fas fa-chevron-right',
'fa fa-angle-double-right' => 'fas fa-angle-double-right',
'fa fa-arrow-right' => 'fas fa-arrow-right',
'fa fa-caret-right' => 'fas fa-caret-right',
'fa fa-long-arrow-right' => 'fas fa-long-arrow-alt-right',
'fa fa-arrow-circle-right' => 'fas fa-arrow-circle-right',
'fa fa-chevron-circle-right' => 'fas fa-chevron-circle-right',
'fa fa-caret-square-o-right' => 'fas fa-caret-square-right',
)
);
}
/**
* Prepare arrow
*
* @param string $arrow
* @return string
*/
public static function prepare_arrow( $arrow ) {
if ( ! self::is_fa5_migration() ) {
return $arrow;
}
$fa5_arrows_map = self::get_fa5_arrows_map();
return isset( $fa5_arrows_map[ $arrow ] ) ? $fa5_arrows_map[ $arrow ] : $arrow;
}
/**
* 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_Builder_Tools
*
* @return object
*/
function jet_woo_builder_tools() {
return Jet_Woo_Builder_Tools::get_instance();
}

View File

@@ -0,0 +1,306 @@
<?php
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;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class Jet_Woo_Group_Control_Box_Style extends Elementor\Group_Control_Base {
protected static $fields;
public static function get_type() {
return 'jet-woo-box-style';
}
protected function init_fields() {
$fields = [];
$fields['background'] = array(
'label' => _x( 'Background Type', 'Background Control', 'jet-woo-builder' ),
'type' => Controls_Manager::CHOOSE,
'options' => array(
'color' => array(
'title' => _x( 'Classic', 'Background Control', 'jet-woo-builder' ),
'icon' => 'fa fa-paint-brush',
),
'gradient' => array(
'title' => _x( 'Gradient', 'Background Control', 'jet-woo-builder' ),
'icon' => 'fa fa-barcode',
),
),
'label_block' => false,
'render_type' => 'ui',
);
$fields['color'] = array(
'label' => _x( 'Color', 'Background Control', 'jet-woo-builder' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'title' => _x( 'Background Color', 'Background Control', 'jet-woo-builder' ),
'selectors' => array(
'{{SELECTOR}}' => 'background-color: {{VALUE}};',
),
'condition' => array(
'background' => array( 'color', 'gradient' ),
),
);
$fields['color_stop'] = array(
'label' => _x( 'Location', 'Background Control', 'jet-woo-builder' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array( '%' ),
'default' => array(
'unit' => '%',
'size' => 0,
),
'render_type' => 'ui',
'condition' => array(
'background' => array( 'gradient' ),
),
'of_type' => 'gradient',
);
$fields['color_b'] = array(
'label' => _x( 'Second Color', 'Background Control', 'jet-woo-builder' ),
'type' => Controls_Manager::COLOR,
'default' => '#f2295b',
'render_type' => 'ui',
'condition' => array(
'background' => array( 'gradient' ),
),
'of_type' => 'gradient',
);
$fields['color_b_stop'] = array(
'label' => _x( 'Location', 'Background Control', 'jet-woo-builder' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array( '%' ),
'default' => array(
'unit' => '%',
'size' => 100,
),
'render_type' => 'ui',
'condition' => array(
'background' => array( 'gradient' ),
),
'of_type' => 'gradient',
);
$fields['gradient_type'] = array(
'label' => _x( 'Type', 'Background Control', 'jet-woo-builder' ),
'type' => Controls_Manager::SELECT,
'options' => array(
'linear' => _x( 'Linear', 'Background Control', 'jet-woo-builder' ),
'radial' => _x( 'Radial', 'Background Control', 'jet-woo-builder' ),
),
'default' => 'linear',
'render_type' => 'ui',
'condition' => array(
'background' => array( 'gradient' ),
),
'of_type' => 'gradient',
);
$fields['gradient_angle'] = array(
'label' => _x( 'Angle', 'Background Control', 'jet-woo-builder' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array( 'deg' ),
'default' => array(
'unit' => 'deg',
'size' => 180,
),
'range' => array(
'deg' => array(
'step' => 10,
),
),
'selectors' => array(
'{{SELECTOR}}' => 'background-color: transparent; background-image: linear-gradient({{SIZE}}{{UNIT}}, {{color.VALUE}} {{color_stop.SIZE}}{{color_stop.UNIT}}, {{color_b.VALUE}} {{color_b_stop.SIZE}}{{color_b_stop.UNIT}})',
),
'condition' => array(
'background' => array( 'gradient' ),
'gradient_type' => 'linear',
),
'of_type' => 'gradient',
);
$fields['gradient_position'] = array(
'label' => _x( 'Position', 'Background Control', 'jet-woo-builder' ),
'type' => Controls_Manager::SELECT,
'options' => array(
'center center' => _x( 'Center Center', 'Background Control', 'jet-woo-builder' ),
'center left' => _x( 'Center Left', 'Background Control', 'jet-woo-builder' ),
'center right' => _x( 'Center Right', 'Background Control', 'jet-woo-builder' ),
'top center' => _x( 'Top Center', 'Background Control', 'jet-woo-builder' ),
'top left' => _x( 'Top Left', 'Background Control', 'jet-woo-builder' ),
'top right' => _x( 'Top Right', 'Background Control', 'jet-woo-builder' ),
'bottom center' => _x( 'Bottom Center', 'Background Control', 'jet-woo-builder' ),
'bottom left' => _x( 'Bottom Left', 'Background Control', 'jet-woo-builder' ),
'bottom right' => _x( 'Bottom Right', 'Background Control', 'jet-woo-builder' ),
),
'default' => 'center center',
'selectors' => array(
'{{SELECTOR}}' => 'background-color: transparent; background-image: radial-gradient(at {{VALUE}}, {{color.VALUE}} {{color_stop.SIZE}}{{color_stop.UNIT}}, {{color_b.VALUE}} {{color_b_stop.SIZE}}{{color_b_stop.UNIT}})',
),
'condition' => array(
'background' => array( 'gradient' ),
'gradient_type' => 'radial',
),
'of_type' => 'gradient',
);
$fields['box_font_color'] = array(
'label' => esc_html__( 'Font Color', 'jet-woo-builder' ),
'type' => Controls_Manager::COLOR,
'selectors' => array(
'{{SELECTOR}}' => 'color: {{VALUE}}',
),
);
$fields['box_font_size'] = array(
'label' => esc_html__( 'Font Size', 'jet-woo-builder' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px', 'em', 'rem',
),
'responsive' => true,
'range' => array(
'px' => array(
'min' => 5,
'max' => 500,
),
),
'selectors' => array(
'{{SELECTOR}}' => 'font-size: {{SIZE}}{{UNIT}}',
'{{SELECTOR}}:before' => 'font-size: {{SIZE}}{{UNIT}}',
),
);
$fields['box_size'] = array(
'label' => esc_html__( 'Box Size', 'jet-woo-builder' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px', 'em', '%',
),
'range' => array(
'px' => array(
'min' => 5,
'max' => 500,
),
),
'responsive' => true,
'selectors' => array(
'{{SELECTOR}}' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
),
);
$fields['box_border'] = array(
'label' => _x( 'Border Type', 'Border Control', 'jet-woo-builder' ),
'type' => Controls_Manager::SELECT,
'options' => array(
'' => esc_html__( 'None', 'jet-woo-builder' ),
'solid' => _x( 'Solid', 'Border Control', 'jet-woo-builder' ),
'double' => _x( 'Double', 'Border Control', 'jet-woo-builder' ),
'dotted' => _x( 'Dotted', 'Border Control', 'jet-woo-builder' ),
'dashed' => _x( 'Dashed', 'Border Control', 'jet-woo-builder' ),
),
'selectors' => array(
'{{SELECTOR}}' => 'border-style: {{VALUE}};',
),
);
$fields['box_border_width'] = array(
'label' => _x( 'Width', 'Border Control', 'jet-woo-builder' ),
'type' => Controls_Manager::DIMENSIONS,
'selectors' => array(
'{{SELECTOR}}' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
'condition' => array(
'box_border!' => '',
),
);
$fields['box_border_color'] = array(
'label' => _x( 'Color', 'Border Control', 'jet-woo-builder' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => array(
'{{SELECTOR}}' => 'border-color: {{VALUE}};',
),
'condition' => array(
'box_border!' => '',
),
);
$fields['box_border_radius'] = array(
'label' => esc_html__( 'Border Radius', 'jet-woo-builder' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{SELECTOR}}' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
);
$fields['allow_box_shadow'] = array(
'label' => _x( 'Box Shadow', 'Box Shadow Control', 'jet-woo-builder' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'jet-woo-builder' ),
'label_off' => esc_html__( 'No', 'jet-woo-builder' ),
'return_value' => 'yes',
'separator' => 'before',
'render_type' => 'ui',
);
$fields['box_shadow'] = array(
'label' => _x( 'Box Shadow', 'Box Shadow Control', 'jet-woo-builder' ),
'type' => Controls_Manager::BOX_SHADOW,
'condition' => array(
'allow_box_shadow!' => '',
),
'selectors' => array(
'{{SELECTOR}}' => 'box-shadow: {{HORIZONTAL}}px {{VERTICAL}}px {{BLUR}}px {{SPREAD}}px {{COLOR}} {{box_shadow_position.VALUE}};',
),
);
$fields['box_shadow_position'] = array(
'label' => _x( 'Position', 'Box Shadow Control', 'jet-woo-builder' ),
'type' => Controls_Manager::SELECT,
'options' => array(
' ' => _x( 'Outline', 'Box Shadow Control', 'jet-woo-builder' ),
'inset' => _x( 'Inset', 'Box Shadow Control', 'jet-woo-builder' ),
),
'condition' => array(
'allow_box_shadow!' => '',
),
'default' => ' ',
'render_type' => 'ui',
);
return $fields;
}
protected function prepare_fields( $fields ) {
array_walk( $fields, function ( &$field, $field_name ) {
if ( in_array( $field_name, array( 'popover_toggle' ) ) ) {
return;
}
$condition = array(
'popover_toggle!' => '',
);
if( isset( $field['condition'] ) ) {
$field['condition'] = array_merge( $field['condition'], $condition );
} else {
$field['condition'] = $condition;
}
} );
return parent::prepare_fields( $fields );
}
}

View File

@@ -0,0 +1,183 @@
<?php
use Elementor\Controls_Manager;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
class Jet_Woo_Builder_Archive_Document_Category extends Jet_Woo_Builder_Document_Base {
/**
* @access public
*/
public function get_name() {
return 'jet-woo-builder-category';
}
/**
* @access public
* @static
*/
public static function get_title() {
return __( 'Jet Woo Category Template', 'jet-woo-builder' );
}
protected function _register_controls() {
parent::_register_controls();
$this->start_controls_section(
'section_template_category_settings',
array(
'label' => esc_html__( 'Template Settings', 'jet-woo-builder' ),
'tab' => Controls_Manager::TAB_SETTINGS,
'show_label' => false,
)
);
$this->add_control(
'use_custom_template_category_columns',
array(
'label' => esc_html__( 'Use custom columns count', 'jet-woo-builder' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'jet-woo-builder' ),
'label_off' => esc_html__( 'No', 'jet-woo-builder' ),
'return_value' => 'yes',
'default' => '',
)
);
$this->add_responsive_control(
'template_category_columns_count',
array(
'label' => esc_html__( 'Template Columns', 'jet-woo-builder' ),
'type' => Controls_Manager::NUMBER,
'min' => 1,
'max' => 6,
'step' => 1,
'condition' => array(
'use_custom_template_category_columns' => 'yes'
)
)
);
$this->add_responsive_control(
'template_category_columns_horizontal_gutter',
array(
'label' => esc_html__( 'Template Columns Horizontal Gutter (px)', 'jet-woo-builder' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px',
),
'range' => array(
'px' => array(
'min' => 0,
'max' => 100,
),
),
'default' => array(
'size' => 10,
'unit' => 'px',
),
'selectors' => array(
'.woocommerce {{WRAPPER}} ' . '.products.jet-woo-builder-categories--columns .product.product-category' => 'padding-left: calc({{SIZE}}{{UNIT}}/2); padding-right: calc({{SIZE}}{{UNIT}}/2);',
'.woocommerce {{WRAPPER}} ' . '.products.jet-woo-builder-categories--columns' => 'margin-left: calc(-{{SIZE}}{{UNIT}}/2); margin-right: calc(-{{SIZE}}{{UNIT}}/2);',
),
'condition' => array(
'use_custom_template_category_columns' => 'yes'
)
)
);
$this->add_responsive_control(
'template_category_columns_vertical_gutter',
array(
'label' => esc_html__( 'Template Columns Vertical Gutter (px)', 'jet-woo-builder' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px',
),
'range' => array(
'px' => array(
'min' => 0,
'max' => 100,
),
),
'default' => array(
'size' => 10,
'unit' => 'px',
),
'selectors' => array(
'.woocommerce ' . '.products.jet-woo-builder-categories--columns .product.product-category' => 'margin-bottom: {{SIZE}}{{UNIT}}!important;',
),
'condition' => array(
'use_custom_template_category_columns' => 'yes'
)
)
);
$this->end_controls_section();
}
/**
* @since 2.0.0
* @access public
*
* @param $data
*
* @return bool
*/
public function save( $data = [] ) {
return $this->save_archive_templates( $data );
}
/**
* @access public
*/
public function get_wp_preview_url() {
$main_post_id = $this->get_main_id();
$product_category = $this->query_first_category();
return add_query_arg(
array(
'preview_nonce' => wp_create_nonce( 'post_preview_' . $main_post_id ),
'jet_woo_template' => $main_post_id,
),
esc_url( get_category_link( $product_category ) )
);
}
public function get_preview_as_query_args() {
jet_woo_builder()->documents->set_current_type( $this->get_name() );
$args = array();
$product_category = $this->query_first_category();
if ( ! empty( $product_category ) ) {
$args = array(
'posts_per_page' => - 1,
'post_type' => 'product',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $product_category
)
)
);
}
return $args;
}
}

View File

@@ -0,0 +1,197 @@
<?php
use Elementor\Controls_Manager;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
class Jet_Woo_Builder_Archive_Document_Product extends Jet_Woo_Builder_Document_Base {
/**
* @access public
*/
public function get_name() {
return 'jet-woo-builder-archive';
}
/**
* @access public
* @static
*/
public static function get_title() {
return __( 'Jet Woo Archive Template', 'jet-woo-builder' );
}
/**
* @since 2.0.0
* @access protected
*/
protected function _register_controls() {
parent::_register_controls();
$this->start_controls_section(
'section_template_settings',
array(
'label' => esc_html__( 'Template Settings', 'jet-woo-builder' ),
'tab' => Controls_Manager::TAB_SETTINGS,
'show_label' => false,
)
);
$this->add_control(
'use_custom_template_columns',
array(
'label' => esc_html__( 'Use custom columns count', 'jet-woo-builder' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'jet-woo-builder' ),
'label_off' => esc_html__( 'No', 'jet-woo-builder' ),
'return_value' => 'yes',
'default' => '',
)
);
$this->add_responsive_control(
'template_columns_count',
array(
'label' => esc_html__( 'Template Columns', 'jet-woo-builder' ),
'type' => Controls_Manager::NUMBER,
'min' => 1,
'max' => 6,
'step' => 1,
'condition' => array(
'use_custom_template_columns' => 'yes'
)
)
);
$this->add_responsive_control(
'template_columns_horizontal_gutter',
array(
'label' => esc_html__( 'Template Columns Horizontal Gutter (px)', 'jet-woo-builder' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px',
),
'range' => array(
'px' => array(
'min' => 0,
'max' => 100,
),
),
'default' => array(
'size' => 10,
'unit' => 'px',
),
'selectors' => array(
'.woocommerce {{WRAPPER}} ' . '.products.jet-woo-builder-products--columns .product:not(.product-category)' => 'padding-left: calc({{SIZE}}{{UNIT}}/2); padding-right: calc({{SIZE}}{{UNIT}}/2);',
'.woocommerce {{WRAPPER}} ' . '.products.jet-woo-builder-products--columns' => 'margin-left: calc(-{{SIZE}}{{UNIT}}/2); margin-right: calc(-{{SIZE}}{{UNIT}}/2);',
),
'condition' => array(
'use_custom_template_columns' => 'yes'
)
)
);
$this->add_responsive_control(
'template_columns_vertical_gutter',
array(
'label' => esc_html__( 'Template Columns Vertical Gutter (px)', 'jet-woo-builder' ),
'type' => Controls_Manager::SLIDER,
'size_units' => array(
'px',
),
'range' => array(
'px' => array(
'min' => 0,
'max' => 100,
),
),
'default' => array(
'size' => 10,
'unit' => 'px',
),
'selectors' => array(
'.woocommerce {{WRAPPER}} ' . '.products.jet-woo-builder-products--columns .product:not(.product-category)' => 'margin-bottom: {{SIZE}}{{UNIT}}!important;',
),
'condition' => array(
'use_custom_template_columns' => 'yes'
)
)
);
$this->end_controls_section();
}
/**
* @since 2.0.0
* @access public
*
* @param $data
*
* @return bool
*/
public function save( $data = [] ) {
return $this->save_archive_templates( $data );
}
/**
* @since 2.0.0
* @access public
*
* @param $data
*
* @return bool
*/
/**
* @access public
*/
public function get_wp_preview_url() {
$main_post_id = $this->get_main_id();
$sample_product = get_post_meta( $main_post_id, '_sample_product', true );
if ( ! $sample_product ) {
$sample_product = $this->query_first_product();
}
$product_id = $sample_product;
return add_query_arg(
array(
'preview_nonce' => wp_create_nonce( 'post_preview_' . $main_post_id ),
'jet_woo_template' => $main_post_id,
),
get_permalink( $product_id )
);
}
/**
* Return preview query args
* @return array
*/
public function get_preview_as_query_args() {
jet_woo_builder()->documents->set_current_type( $this->get_name() );
$args = array();
$product = $this->query_first_product();
if ( ! empty( $product ) ) {
$args = array(
'post_type' => 'product',
'p' => $product,
);
}
return $args;
}
}

View File

@@ -0,0 +1,54 @@
<?php
use Elementor\Controls_Manager;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
class Jet_Woo_Builder_Shop_Document extends Jet_Woo_Builder_Document_Base {
/**
* @access public
*/
public function get_name() {
return 'jet-woo-builder-shop';
}
/**
* @access public
* @static
*/
public static function get_title() {
return __( 'Jet Woo Shop Template', 'jet-woo-builder' );
}
public function get_preview_as_query_args() {
jet_woo_builder()->documents->set_current_type( $this->get_name() );
$args = array();
$products = get_posts( array(
'post_type' => 'product',
'posts_per_page' => 5,
) );
if ( ! empty( $products ) ) {
$args = array(
'post_type' => 'product',
'p' => $products,
);
}
wc_set_loop_prop( 'total', 20 );
wc_set_loop_prop( 'total_pages', 3 );
return $args;
}
}

View File

@@ -0,0 +1,228 @@
<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
class Jet_Woo_Builder_Document_Base extends Elementor\Core\Base\Document {
public $first_product = null;
public $first_category = null;
/**
* @access public
*/
public function get_name() {
return 'jet-woo-builder-archive-document';
}
public static function get_properties() {
$properties = parent::get_properties();
$properties['admin_tab_group'] = '';
return $properties;
}
/**
* Query for first product ID.
*
* @return int|bool
*/
public function query_first_product() {
if ( null !== $this->first_product ) {
return $this->first_product;
}
$args = array(
'post_type' => 'product',
'post_status' => array( 'publish', 'pending', 'draft', 'future' ),
'posts_per_page' => 1,
);
$sample_product = get_post_meta( $this->get_main_id(), '_sample_product', true );
if ( $sample_product ) {
$args['p'] = $sample_product;
}
$wp_query = new WP_Query( $args );
if ( ! $wp_query->have_posts() ) {
return false;
}
$post = $wp_query->posts;
return $this->first_product = $post[0]->ID;
}
/**
* Query for first product ID.
*
* @return int|bool
*/
public function query_first_category() {
if ( null !== $this->first_category ) {
return $this->first_category;
}
$product_categories = get_categories( array(
'taxonomy' => 'product_cat',
'orderby' => 'name',
'pad_counts' => false,
'hierarchical' => 1,
'hide_empty' => false
) );
if ( ! empty( $product_categories ) ) {
$product_category = $product_categories[0];
}
return $this->first_category = $product_category->term_id;
}
/**
* Save meta for current post
* @param $post_id
*/
public function save_template_item_to_meta( $post_id ) {
$content = Elementor\Plugin::instance()->frontend->get_builder_content( $post_id, false );
$content = preg_replace( '/<style>.*?<\/style>/', '', $content );
update_post_meta( $post_id, '_jet_woo_builder_content', $content );
}
public function enqueue_custom_fonts_epro( $post_css ){
if( class_exists( 'ElementorPro\Modules\AssetsManager\AssetTypes\Fonts\Custom_Fonts' ) ){
$custom_fonts_manager = new ElementorPro\Modules\AssetsManager\AssetTypes\Fonts\Custom_Fonts();
$fonts = $custom_fonts_manager->get_fonts();
if( !empty( $fonts ) ){
foreach ( $fonts as $font => $font_data ){
$custom_fonts_manager->enqueue_font( $font, $font_data, $post_css );
}
}
}
}
/**
* Save data for archive document types
*
* @param array $data
*
* @return bool
*/
public function save_archive_templates( $data = [] ){
if ( ! $this->is_editable_by_current_user() || empty( $data ) ) {
return false;
}
if ( ! empty( $data['settings'] ) ) {
if ( Elementor\DB::STATUS_AUTOSAVE === $data['settings']['post_status'] ) {
if ( ! defined( 'DOING_AUTOSAVE' ) ) {
define( 'DOING_AUTOSAVE', true );
}
}
$this->save_settings( $data['settings'] );
//Refresh post after save settings.
$this->post = get_post( $this->post->ID );
}
if ( ! empty( $data['elements'] ) ) {
$this->save_elements( $data['elements'] );
}
$this->save_template_type();
$this->save_version();
$this->save_template_item_to_meta( $this->post->ID );
// Update Post CSS
$post_css = new Elementor\Core\Files\CSS\Post( $this->post->ID );
$this->enqueue_custom_fonts_epro( $post_css );
$post_css->update();
return true;
}
/**
* Get elements data with new query
*
* @param [type] $data [description]
* @param boolean $with_html_content [description]
*
* @return [type] [description]
*/
public function get_elements_raw_data( $data = null, $with_html_content = false ) {
jet_woo_builder()->documents->switch_to_preview_query();
$editor_data = parent::get_elements_raw_data( $data, $with_html_content );
jet_woo_builder()->documents->restore_current_query();
return $editor_data;
}
/**
* Render current element
* @param $data
*
* @return string
* @throws Exception
*/
public function render_element( $data ) {
jet_woo_builder()->documents->switch_to_preview_query();
$render_html = parent::render_element( $data );
jet_woo_builder()->documents->restore_current_query();
return $render_html;
}
/**
* Return elements data
* @param string $status
*
* @return array
*/
public function get_elements_data( $status = 'publish' ) {
if ( ! isset( $_GET[ jet_woo_builder_post_type()->slug() ] ) || ! isset( $_GET['preview'] ) ) {
return parent::get_elements_data( $status );
}
jet_woo_builder()->documents->switch_to_preview_query();
$elements = parent::get_elements_data( $status );
jet_woo_builder()->documents->restore_current_query();
return $elements;
}
}

View File

@@ -0,0 +1,75 @@
<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
class Jet_Woo_Builder_Document extends Jet_Woo_Builder_Document_Base {
/**
* @access public
*/
public function get_name() {
return 'jet-woo-builder';
}
/**
* @access public
* @static
*/
public static function get_title() {
return __( 'Jet Woo Template Single', 'jet-woo-builder' );
}
/**
* @access public
*/
public function get_wp_preview_url() {
$main_post_id = $this->get_main_id();
$sample_product = get_post_meta( $main_post_id, '_sample_product', true );
if ( ! $sample_product ) {
$sample_product = $this->query_first_product();
}
$product_id = $sample_product;
return add_query_arg(
array(
'preview_nonce' => wp_create_nonce( 'post_preview_' . $main_post_id ),
'jet_woo_template' => $main_post_id,
),
get_permalink( $product_id )
);
}
/**
* Return preview query args
*
* @return array
*/
public function get_preview_as_query_args() {
jet_woo_builder()->documents->set_current_type( $this->get_name() );
$args = array();
$product = $this->query_first_product();
if ( ! empty( $product ) ) {
$args = array(
'post_type' => 'product',
'p' => $product,
);
}
return $args;
}
}

View File

@@ -0,0 +1,45 @@
<?php
//use Elementor\Controls_Manager;
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
class Jet_Woo_Builder_Document_Not_Supported extends Elementor\Modules\Library\Documents\Not_Supported {
/**
* Get document properties.
*
* Retrieve the document properties.
*
* @access public
* @static
*
* @return array Document properties.
*/
public static function get_properties() {
$properties = parent::get_properties();
$properties['cpt'] = [ 'jet-woo-builder' ];
return $properties;
}
/**
* Get document name.
*
* Retrieve the document name.
*
* @access public
*
* @return string Document name.
*/
public function get_name() {
return 'jet-woo-builder-not-supported';
}
public function save_template_type() {
// Do nothing.
}
}

View File

@@ -0,0 +1,503 @@
<?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_Builder_Integration' ) ) {
/**
* Define Jet_Woo_Builder_Integration class
*/
class Jet_Woo_Builder_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;
/**
* Holder for current product instance
*
* @var array
*/
private $current_product = 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, 'include_wc_hooks' ), 0 );
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/page_templates/canvas/before_content', array( $this, 'open_canvas_wrap' ) );
add_action( 'elementor/page_templates/canvas/after_content', array( $this, 'close_canvas_wrap' ) );
add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_styles' ) );
add_action( 'elementor/controls/controls_registered', array( $this, 'add_controls' ), 10 );
add_action( 'template_redirect', array( $this, 'set_track_product_view' ), 20 );
add_filter( 'post_class', array( $this, 'add_product_post_class' ), 20 );
$this->include_theme_integration_file();
$this->include_plugin_integration_file();
}
/**
* Set current product data
*/
public function set_current_product( $product_data = array() ) {
$this->current_product = $product_data;
}
/**
* Get current product data
* @return [type] [description]
*/
public function get_current_product() {
return $this->current_product;
}
/**
* Get current product data
* @return [type] [description]
*/
public function reset_current_product() {
return $this->current_product = false;
}
/**
* Enqueue editor styles
*
* @return void
*/
public function editor_styles() {
wp_enqueue_style(
'jet-woo-builder-font',
jet_woo_builder()->plugin_url( 'assets/css/lib/jetwoobuilder-font/css/jetwoobuilder.css' ),
array(),
jet_woo_builder()->get_version()
);
wp_enqueue_style(
'jet-woo-builder-icons-font',
jet_woo_builder()->plugin_url( 'assets/css/lib/jet-woo-builder-icons/jet-woo-builder-icons.css' ),
array(),
jet_woo_builder()->get_version()
);
wp_enqueue_style(
'jet-woo-builder-editor',
jet_woo_builder()->plugin_url( 'assets/css/editor.css' ),
array(),
jet_woo_builder()->get_version()
);
}
/**
* Include woocommerce front-end hooks
*
* @return [type] [description]
*/
public function include_wc_hooks() {
$elementor = Elementor\Plugin::instance();
$is_edit_mode = $elementor->editor->is_edit_mode();
if ( ! $is_edit_mode ) {
return;
}
if ( ! defined( 'WC_ABSPATH' ) ) {
return;
}
if ( ! file_exists( WC_ABSPATH . 'includes/wc-template-hooks.php' ) ) {
return;
}
$rewrite = apply_filters( 'jet-woo-builder/integration/rewrite-frontend-hooks', false );
if ( ! $rewrite ) {
include_once WC_ABSPATH . 'includes/wc-template-hooks.php';
}
remove_filter( 'woocommerce_product_loop_start', 'woocommerce_maybe_show_product_subcategories' );
}
public function add_product_post_class( $classes ) {
if (
is_archive() ||
'related' === wc_get_loop_prop( 'name' ) ||
'up-sells' === wc_get_loop_prop( 'name' ) ||
'cross-sells' === wc_get_loop_prop( 'name' )
) {
if ( filter_var( jet_woo_builder_settings()->get( 'enable_product_thumb_effect' ), FILTER_VALIDATE_BOOLEAN ) ) {
$classes[] = 'jet-woo-thumb-with-effect';
}
}
return $classes;
}
/**
* Track product views.
*/
public function set_track_product_view() {
if ( ! is_singular( 'product' ) ) {
return;
}
global $post;
if ( empty( $_COOKIE['woocommerce_recently_viewed'] ) ) {
$viewed_products = array();
} else {
$viewed_products = (array) explode( '|', $_COOKIE['woocommerce_recently_viewed'] );
}
if ( ! in_array( $post->ID, $viewed_products ) ) {
$viewed_products[] = $post->ID;
}
if ( sizeof( $viewed_products ) > 30 ) {
array_shift( $viewed_products );
}
// Store for session only
wc_setcookie( 'woocommerce_recently_viewed', implode( '|', $viewed_products ) );
}
/**
* Include integration theme file
*
* @return void
*/
public function include_theme_integration_file() {
$template = get_template();
$int_file = jet_woo_builder()->plugin_path( "includes/integrations/themes/{$template}/functions.php" );
if ( file_exists( $int_file ) ) {
require $int_file;
}
}
/**
* Include plugin integrations file
*
* @return [type] [description]
*/
public function include_plugin_integration_file() {
$plugins = array(
'jet-popup.php' => array(
'cb' => 'class_exists',
'args' => 'Jet_Popup',
),
);
foreach ( $plugins as $file => $condition ) {
if ( true === call_user_func( $condition['cb'], $condition['args'] ) ) {
require jet_woo_builder()->plugin_path( 'includes/integrations/plugins/' . $file );
}
}
}
/**
* Open wrapper for canvas page template for product templates
*
* @return [type] [description]
*/
public function open_canvas_wrap() {
if ( ! is_singular( jet_woo_builder_post_type()->slug() ) ) {
return;
}
echo '<div class="product">';
}
/**
* Close wrapper for canvas page template for product templates
*
* @return [type] [description]
*/
public function close_canvas_wrap() {
if ( ! is_singular( jet_woo_builder_post_type()->slug() ) ) {
return;
}
echo '</div>';
}
/**
* 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-builder/in-elementor', $result );
}
/**
* Register plugin widgets
*
* @param object $widgets_manager Elementor widgets manager instance.
*
* @return void
*/
public function register_widgets( $widgets_manager ) {
$global_available_widgets = jet_woo_builder_settings()->get( 'global_available_widgets' );
$single_available_widgets = jet_woo_builder_settings()->get( 'single_product_available_widgets' );
$archive_available_widgets = jet_woo_builder_settings()->get( 'archive_product_available_widgets' );
$archive_category_available_widgets = jet_woo_builder_settings()->get( 'archive_category_available_widgets' );
$shop_available_widgets = jet_woo_builder_settings()->get( 'shop_product_available_widgets' );
require_once jet_woo_builder()->plugin_path( 'includes/base/class-jet-woo-builder-base.php' );
foreach ( glob( jet_woo_builder()->plugin_path( 'includes/widgets/global/' ) . '*.php' ) as $file ) {
$slug = basename( $file, '.php' );
$enabled = isset( $global_available_widgets[ $slug ] ) ? $global_available_widgets[ $slug ] : '';
if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $global_available_widgets ) {
$this->register_widget( $file, $widgets_manager );
}
}
$doc_type = jet_woo_builder()->documents->get_current_type();
if ( ! $doc_type ) {
if ( get_post_type() === jet_woo_builder_post_type()->slug() ) {
$doc_type = get_post_meta( get_the_ID(), '_elementor_template_type', true );
}
}
$doc_type = apply_filters( 'jet-woo-builder/integration/doc-type', $doc_type );
$doc_types = jet_woo_builder()->documents->get_document_types();
if ( $this->is_setting_enabled( 'custom_single_page' ) || $doc_types['single']['slug'] === $doc_type ) {
foreach ( glob( jet_woo_builder()->plugin_path( 'includes/widgets/single-product/' ) . '*.php' ) as $file ) {
$slug = basename( $file, '.php' );
$enabled = isset( $single_available_widgets[ $slug ] ) ? $single_available_widgets[ $slug ] : '';
if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $single_available_widgets ) {
$this->register_widget( $file, $widgets_manager );
}
}
}
if ( $this->is_setting_enabled( 'custom_shop_page' ) || $doc_types['shop']['slug'] === $doc_type ) {
foreach ( glob( jet_woo_builder()->plugin_path( 'includes/widgets/shop/' ) . '*.php' ) as $file ) {
$slug = basename( $file, '.php' );
$enabled = isset( $shop_available_widgets[ $slug ] ) ? $shop_available_widgets[ $slug ] : '';
if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $shop_available_widgets ) {
$this->register_widget( $file, $widgets_manager );
}
}
}
if ( $this->is_setting_enabled( 'custom_archive_page' ) || $doc_types['archive']['slug'] === $doc_type ) {
foreach ( glob( jet_woo_builder()->plugin_path( 'includes/widgets/archive-product/' ) . '*.php' ) as $file ) {
$slug = basename( $file, '.php' );
$enabled = isset( $archive_available_widgets[ $slug ] ) ? $archive_available_widgets[ $slug ] : '';
if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $archive_available_widgets ) {
$this->register_widget( $file, $widgets_manager );
}
}
}
if ( $this->is_setting_enabled( 'custom_archive_category_page' ) || $doc_types['category']['slug'] === $doc_type ) {
foreach ( glob( jet_woo_builder()->plugin_path( 'includes/widgets/archive-category/' ) . '*.php' ) as $file ) {
$slug = basename( $file, '.php' );
$enabled = isset( $archive_category_available_widgets[ $slug ] ) ? $archive_category_available_widgets[ $slug ] : '';
if ( filter_var( $enabled, FILTER_VALIDATE_BOOLEAN ) || ! $archive_category_available_widgets ) {
$this->register_widget( $file, $widgets_manager );
}
}
}
}
/**
* Return true if certain option is enabled
*
* @return bool
*/
public function is_setting_enabled( $type = 'custom_single_page' ) {
return filter_var( jet_woo_builder_shop_settings()->get( $type ), FILTER_VALIDATE_BOOLEAN );
}
/**
* 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_once $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_builder_cat = 'jet-woo-builder';
$elements_manager->add_category(
$jet_woo_builder_cat,
array(
'title' => esc_html__( 'Jet Woo Builder', 'jet-woo-builder' ),
'icon' => 'font',
),
1
);
}
/**
* Add new controls.
*
* @param object $controls_manager Controls manager instance.
*
* @return void
*/
public function add_controls( $controls_manager ) {
$grouped = array(
'jet-woo-box-style' => 'Jet_Woo_Group_Control_Box_Style',
);
foreach ( $grouped as $control_id => $class_name ) {
if ( $this->include_control( $class_name, true ) ) {
$controls_manager->add_group_control( $control_id, new $class_name() );
}
}
}
/**
* Include control file by class name.
*
* @param [type] $class_name [description]
*
* @return [type] [description]
*/
public function include_control( $class_name, $grouped = false ) {
$filename = sprintf(
'includes/controls/%2$sclass-%1$s.php',
str_replace( '_', '-', strtolower( $class_name ) ),
( true === $grouped ? 'groups/' : '' )
);
if ( ! file_exists( jet_woo_builder()->plugin_path( $filename ) ) ) {
return false;
}
require jet_woo_builder()->plugin_path( $filename );
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_Builder_Integration
*
* @return object
*/
function jet_woo_builder_integration() {
return Jet_Woo_Builder_Integration::get_instance();
}

View File

@@ -0,0 +1,803 @@
<?php
/**
* Popup compatibility package
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Builder_Popup_Package' ) ) {
/**
* Define Jet_Woo_Builder_Popup_Package class
*/
class Jet_Woo_Builder_Popup_Package {
private $jet_woo_builder_qw_templates;
/**
* Contains a string of photoswipe styles registered by WC.
*
* @var array
*/
private $photoswipe_styles = '';
/**
* Contains a string of woocommerce default styles registered by WC.
*
* @var array
*/
private $woocommerce_styles = '';
/**
* Jet_Woo_Builder_Popup_Package constructor.
*/
public function __construct() {
add_filter( 'jet-popup/widget-extension/widget-before-render-settings', array( $this, 'define_popups' ), 10, 2 );
add_filter( 'jet-popup/popup-generator/before-define-popup-assets/popup-id', array( $this, 'define_popup_assets' ), 10, 2 );
add_action( 'jet-popup/editor/widget-extension/after-base-controls', array( $this, 'register_controls' ), 10, 2 );
add_filter( 'jet-popup/widget-extension/widget-before-render-settings', array( $this, 'pass_woo_builder_trigger' ), 10, 2 );
add_filter( 'jet-popup/ajax-request/get-elementor-content', array( $this, 'get_popup_content' ), 10, 2 );
add_action( 'jet-woo-builder/popup-generator/after-added-to-cart/cart-popup', array( $this, 'get_cart_popup_data_attrs' ), 10, 2 );
// Add Quick View buttons controls to Products Grid widget
add_action( 'elementor/element/jet-woo-products/section_dots_style/after_section_end', array( $this, 'register_quickview_button_content_controls' ) , 10, 2 );
add_action( 'elementor/element/jet-woo-products/section_dots_style/after_section_end', array( $this, 'register_quickview_button_style_controls' ) , 10, 2 );
add_action( 'elementor/element/jet-woo-products/section_general/before_section_end', array( $this, 'register_quickview_button_show_control' ) , 10, 2 );
add_action( 'jet-woo-builder/templates/jet-woo-products/quickview-button', array( $this, 'get_quickview_button_content' ) );
// Add Quick View buttons controls to Products List widget
add_action( 'elementor/element/jet-woo-products-list/section_button_style/after_section_end', array( $this, 'register_quickview_button_content_controls' ) , 10, 2 );
add_action( 'elementor/element/jet-woo-products-list/section_button_style/after_section_end', array( $this, 'register_quickview_button_style_controls' ) , 10, 2 );
add_action( 'elementor/element/jet-woo-products-list/section_general/before_section_end', array( $this, 'register_quickview_button_show_control' ) , 10, 2 );
add_action( 'jet-woo-builder/templates/jet-woo-products-list/quickview-button', array( $this, 'get_quickview_button_content' ) );
// Add Quick View buttons new icon settings
add_filter( 'jet-woo-builder/jet-woo-products-grid/settings', array( $this, 'quick_view_button_icon' ), 10, 2 );
add_filter( 'jet-woo-builder/jet-woo-products-list/settings', array( $this, 'quick_view_button_icon' ), 10, 2 );
}
/**
* Add Quick View buttons new icon settings.
*
* @param $settings
* @param $widget
* @return mixed
*/
public function quick_view_button_icon( $settings, $widget ) {
if ( isset( $settings['selected_quickview_button_icon_normal'] ) || isset( $settings['quickview_button_icon_normal'] ) ) {
$settings['selected_quickview_button_icon_normal'] = htmlspecialchars( $widget->__render_icon('quickview_button_icon_normal', '%s', '', false ) );
}
return $settings;
}
/**
* Define Jet Woo Builder quick view popups
*
* @param $widget_settings
* @param $settings
*
* @return mixed
*/
public function define_popups( $widget_settings, $settings ) {
if( ! isset( $settings['jet_woo_builder_qv'] ) ){
return $widget_settings;
}
$popup_id = $settings['jet_attached_popup'];
$jet_woo_builder_qw_enabled = filter_var( $settings['jet_woo_builder_qv'], FILTER_VALIDATE_BOOLEAN );
if ( $jet_woo_builder_qw_enabled && ! empty( $settings['jet_woo_builder_qv_template'] ) ) {
$this->jet_woo_builder_qw_templates[ $popup_id ] = $settings['jet_woo_builder_qv_template'];
}
$this->enqueue_popup_styles( $settings['jet_attached_popup'] );
return $widget_settings;
}
/**
* Enqueue current popup styles
*
* @param $popup_id
*/
public function enqueue_popup_styles( $popup_id ){
if ( $popup_id ) {
if ( class_exists( 'Elementor\Core\Files\CSS\Post' ) ) {
$css_file = new Elementor\Core\Files\CSS\Post( $popup_id );
} else {
$css_file = new Elementor\Post_CSS_File( $popup_id );
}
$css_file->enqueue();
}
}
/**
* Define Jet Woo Builder quick view content assets
*
* @param $popup_id
* @param $settings
*
* @return mixed
*/
public function define_popup_assets( $popup_id, $settings ) {
if( empty( $this->jet_woo_builder_qw_templates ) ){
return $popup_id;
}
if ( isset( $this->jet_woo_builder_qw_templates[ $popup_id ] ) ) {
$popup_id = $this->jet_woo_builder_qw_templates[ $popup_id ];
}
return $popup_id;
}
/**
* Register Jet Woo Builder trigger
* @return [type] [description]
*/
public function register_controls( $manager ) {
$templates = jet_woo_builder_post_type()->get_templates_list_for_options( 'single' );
$avaliable_popups = Jet_Popup_Utils::get_avaliable_popups();
$manager->add_control(
'jet_woo_builder_qv',
array(
'label' => __( 'Jet Woo Builder Quick View', 'jet-woo-builder' ),
'description' => __( 'For Products Grid and Product List widgets use Click On Custom Selector Trigger Type with .jet-quickview-button selector', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::SWITCHER,
'label_on' => __( 'Yes', 'jet-woo-builder' ),
'label_off' => __( 'No', 'jet-woo-builder' ),
'return_value' => 'yes',
'default' => '',
)
);
$manager->add_control(
'jet_woo_builder_qv_template',
array(
'type' => Elementor\Controls_Manager::SELECT,
'label' => esc_html__( 'Template', 'jet-woo-builder' ),
'default' => '',
'options' => $templates,
'condition' => array(
'jet_woo_builder_qv' => 'yes',
),
)
);
$manager->add_control(
'jet_woo_builder_cart_popup',
array(
'label' => esc_html__( 'Jet Woo Builder Cart PopUp', 'jet-woo-builder' ),
'description' => esc_html__( 'This option works with widgets that add products to the cart using an ajax request and open popup after it.', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'jet-woo-builder' ),
'label_off' => esc_html__( 'No', 'jet-woo-builder' ),
'return_value' => 'yes',
'default' => '',
)
);
$manager->add_control(
'jet_woo_builder_cart_popup_template',
array(
'type' => Elementor\Controls_Manager::SELECT,
'label' => esc_html__( 'Template', 'jet-woo-builder' ),
'default' => '',
'options' => $avaliable_popups,
'condition' => array(
'jet_woo_builder_cart_popup' => 'yes',
),
)
);
}
/**
* If cart popup option enable - set appropriate key and popup id in data attribute.
*
* @param $popup_enable
* @param $popup_id
* @return bool|int
*/
public function get_cart_popup_data_attrs( $popup_enable, $popup_id) {
if ( ! $popup_enable ) {
return false;
}
return printf( 'data-cart-popup-enable=%1s data-cart-popup-id=%2s', json_encode( $popup_enable ), $popup_id );
}
/**
* If jet_woo_builder_qv enabled - set appropriate key in localized popup data
*
* @param [type] $data [description]
* @param [type] $settings [description]
*
* @return [type] [description]
*/
public function pass_woo_builder_trigger( $data, $settings ) {
$popup_trigger = ! empty( $settings['jet_woo_builder_qv'] ) ? true : false;
$popup_template = ! empty( $settings['jet_woo_builder_qv_template'] ) ? $settings['jet_woo_builder_qv_template'] : '';
if ( $popup_trigger ) {
$data['is-jet-woo-builder'] = $popup_trigger;
$data['jet-woo-builder-qv-template'] = $popup_template;
}
return $data;
}
/**
* Get dynamic content related to passed post ID
*
* @param [type] $content [description]
* @param [type] $popup_data [description]
*
* @return [type] [description]
*/
public function get_popup_content( $content, $popup_data ) {
if ( empty( $popup_data['isJetWooBuilder'] ) || empty( $popup_data['productId'] ) || empty( $popup_data['templateId'] ) ) {
return $content;
}
$template_id = $popup_data['templateId'];
if ( empty( $template_id ) ) {
return $content;
}
$plugin = Elementor\Plugin::instance();
global $post, $woocommerce;
$post = get_post( $popup_data['productId'] );
if ( empty( $post ) ) {
return;
}
$this->photoswipe_styles = apply_filters( 'jet-popup/widgets/photoswipe-styles', $this->photoswipe_styles );
$this->woocommerce_styles = apply_filters( 'jet-popup/widgets/woocommerce-styles', $this->woocommerce_styles );
setup_postdata( $post, null, false );
$content = $this->photoswipe_styles;
$content .= $this->woocommerce_styles;
$content .= $plugin->frontend->get_builder_content( $template_id, true );
$content .= sprintf( '<script> jQuery.getScript("%s/assets/js/frontend/add-to-cart-variation.min.js"); </script>', $woocommerce->plugin_url() );
wp_reset_postdata( $post );
return $content;
}
/**
* Get quick view button html
*
* @param $display_settings
*/
public function get_quickview_button_content( $display_settings ){
$button_classes = array(
'jet-quickview-button',
'jet-quickview-button__link',
'jet-quickview-button__link--icon-' . $display_settings['quickview_button_icon_position'],
);
?>
<div class="jet-quickview-button__container"><a href="#" class="<?php echo implode( ' ', $button_classes ); ?>">
<div class="jet-quickview-button__plane jet-quickview-button__plane-normal"></div>
<div class="jet-quickview-button__state jet-quickview-button__state-normal">
<?php
if ( filter_var( $display_settings['quickview_use_button_icon'], FILTER_VALIDATE_BOOLEAN ) ) {
printf( '<span class="jet-quickview-button__icon jet-woo-builder-icon">%s</span>', htmlspecialchars_decode( $display_settings['selected_quickview_button_icon_normal'] ) );
}
printf( '<span class="jet-quickview-button__label">%s</span>', $display_settings['quickview_button_label_normal'] );
?>
</div>
</a></div>
<?php
}
/**
* Register content controls
*
* @param $obj
* @param array $args
*/
public function register_quickview_button_content_controls( $obj, $args = array() ){
$obj->start_controls_section(
'section_quickview_content',
array(
'label' => esc_html__( 'Quick View', 'jet-woo-builder' ),
)
);
$obj->__add_advanced_icon_control(
'quickview_button_icon_normal',
array(
'label' => esc_html__( 'Button Icon', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::ICON,
'label_block' => true,
'file' => '',
'default' => 'fa fa-eye',
'fa5_default' => array(
'value' => 'fas fa-eye',
'library' => 'fa-solid',
),
)
);
$obj->add_control(
'quickview_button_label_normal',
array(
'label' => esc_html__( 'Button Label Text', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::TEXT,
'default' => esc_html__( 'Quick View', 'jet-woo-builder' ),
)
);
$obj->add_control(
'quickview_button_icon_settings_heading',
array(
'label' => esc_html__( 'Icon', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::HEADING,
'separator' => 'before',
)
);
$obj->add_control(
'quickview_use_button_icon',
array(
'label' => esc_html__( 'Use Icon?', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'jet-woo-builder' ),
'label_off' => esc_html__( 'No', 'jet-woo-builder' ),
'return_value' => 'yes',
'default' => 'yes',
)
);
$obj->add_control(
'quickview_button_icon_position',
array(
'label' => esc_html__( 'Icon Position', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::SELECT,
'options' => array(
'left' => esc_html__( 'Left', 'jet-woo-builder' ),
'top' => esc_html__( 'Top', 'jet-woo-builder' ),
'right' => esc_html__( 'Right', 'jet-woo-builder' ),
'bottom' => esc_html__( 'Bottom', 'jet-woo-builder' ),
),
'default' => 'left',
'render_type' => 'template',
'condition' => array(
'quickview_use_button_icon' => 'yes',
),
)
);
$obj->end_controls_section();
}
/**
* Register style controls
*
* @param $obj
* @param array $args
*/
public function register_quickview_button_style_controls( $obj, $args = array() ){
$css_scheme = apply_filters(
'jet-quickview-button/quickview-button/css-scheme',
array(
'container' => '.jet-quickview-button__container',
'button' => '.jet-quickview-button__link',
'plane_normal' => '.jet-quickview-button__plane-normal',
'state_normal' => '.jet-quickview-button__state-normal',
'icon_normal' => '.jet-quickview-button__state-normal .jet-quickview-button__icon',
'label_normal' => '.jet-quickview-button__state-normal .jet-quickview-button__label',
)
);
/**
* General Style Section
*/
$obj->start_controls_section(
'section_button_quickview_general_style',
array(
'label' => esc_html__( 'Quick View', 'jet-woo-builder' ),
'tab' => Elementor\Controls_Manager::TAB_STYLE,
'show_label' => false,
)
);
$obj->add_group_control(
Elementor\Group_Control_Typography::get_type(),
array(
'name' => 'quickview_button_typography',
'scheme' => Elementor\Scheme_Typography::TYPOGRAPHY_1,
'selector' => '{{WRAPPER}} ' . $css_scheme['button'] . ',{{WRAPPER}} ' . $css_scheme['label_normal'],
)
);
$obj->add_control(
'quickview_custom_size',
array(
'label' => esc_html__( 'Custom Size', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'jet-woo-builder' ),
'label_off' => esc_html__( 'No', 'jet-woo-builder' ),
'return_value' => 'yes',
'default' => 'false',
)
);
$obj->add_responsive_control(
'quickview_button_custom_width',
array(
'label' => esc_html__( 'Custom Width', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::SLIDER,
'size_units' => array(
'px',
'em',
'%',
),
'range' => array(
'px' => array(
'min' => 40,
'max' => 1000,
),
'%' => array(
'min' => 0,
'max' => 100,
),
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['button'] => 'width: {{SIZE}}{{UNIT}};',
),
'condition' => array(
'quickview_custom_size' => 'yes',
),
)
);
$obj->add_responsive_control(
'quickview_button_custom_height',
array(
'label' => esc_html__( 'Custom Height', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::SLIDER,
'size_units' => array(
'px',
'em',
'%',
),
'range' => array(
'px' => array(
'min' => 10,
'max' => 1000,
),
'%' => array(
'min' => 0,
'max' => 100,
),
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['button'] => 'height: {{SIZE}}{{UNIT}};',
),
'condition' => array(
'quickview_custom_size' => 'yes',
),
)
);
$obj->start_controls_tabs( 'quickview_button_style_tabs' );
$obj->start_controls_tab(
'quickview_button_normal_styles',
array(
'label' => esc_html__( 'Normal', 'jet-woo-builder' ),
)
);
$obj->add_control(
'quickview_button_normal_color',
array(
'label' => esc_html__( 'Color', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['label_normal'] => 'color: {{VALUE}}',
'{{WRAPPER}} ' . $css_scheme['icon_normal'] => 'color: {{VALUE}}',
),
)
);
$obj->add_control(
'quickview_button_normal_background',
array(
'label' => esc_html__( 'Background Color', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::COLOR,
'scheme' => array(
'type' => Elementor\Scheme_Color::get_type(),
'value' => Elementor\Scheme_Color::COLOR_1,
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['button'] . ' ' . $css_scheme['plane_normal'] => 'background-color: {{VALUE}}',
),
)
);
$obj->end_controls_tab();
$obj->start_controls_tab(
'quickview_button_hover_styles',
array(
'label' => esc_html__( 'Hover', 'jet-woo-builder' ),
)
);
$obj->add_control(
'quickview_button_hover_color',
array(
'label' => esc_html__( 'Color', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['button'] . ':hover ' . $css_scheme['label_normal'] => 'color: {{VALUE}}',
'{{WRAPPER}} ' . $css_scheme['button'] . ':hover ' . $css_scheme['icon_normal'] => 'color: {{VALUE}}',
),
)
);
$obj->add_control(
'quickview_button_hover_background',
array(
'label' => esc_html__( 'Background Color', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::COLOR,
'scheme' => array(
'type' => Elementor\Scheme_Color::get_type(),
'value' => Elementor\Scheme_Color::COLOR_4,
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['button'] . ':hover ' . $css_scheme['plane_normal'] => 'background-color: {{VALUE}}',
),
)
);
$obj->add_control(
'quickview_button_border_hover_color',
array(
'label' => esc_html__( 'Border Color', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['button'] . ':hover ' . $css_scheme['plane_normal'] => 'border-color: {{VALUE}}',
),
'condition' => array(
'quickview_button_border_border!' => ''
)
)
);
$obj->end_controls_tab();
$obj->end_controls_tabs();
$obj->add_control(
'quickview_button_border_radius',
array(
'label' => esc_html__( 'Border Radius', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['button'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} ' . $css_scheme['plane_normal'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$obj->add_responsive_control(
'quickview_button_alignment',
array(
'label' => esc_html__( 'Alignment', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::CHOOSE,
'default' => 'center',
'options' => array(
'flex-start' => array(
'title' => esc_html__( 'Left', 'jet-woo-builder' ),
'icon' => 'fa fa-align-left',
),
'center' => array(
'title' => esc_html__( 'Center', 'jet-woo-builder' ),
'icon' => 'fa fa-align-center',
),
'flex-end' => array(
'title' => esc_html__( 'Right', 'jet-woo-builder' ),
'icon' => 'fa fa-align-right',
),
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['container'] => 'justify-content: {{VALUE}};',
),
'separator' => 'before'
)
);
$obj->add_responsive_control(
'quickview_button_padding',
array(
'label' => __( 'Padding', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['button'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$obj->add_responsive_control(
'quickview_button_margin',
array(
'label' => __( 'Margin', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['button'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$obj->add_control(
'quickview_button_icon_heading',
array(
'label' => esc_html__( 'Icon', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::HEADING,
'separator' => 'before',
)
);
$obj->start_controls_tabs( 'tabs_quickview_icon_styles' );
$obj->start_controls_tab(
'tab_quickview_icon_normal',
array(
'label' => esc_html__( 'Normal', 'jet-woo-builder' ),
)
);
$obj->add_control(
'normal_quickview_icon_color',
array(
'label' => esc_html__( 'Color', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['icon_normal'] . ' i' => 'color: {{VALUE}}',
),
)
);
$obj->add_responsive_control(
'normal_quickview_icon_font_size',
array(
'label' => esc_html__( 'Font Size', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::SLIDER,
'size_units' => array(
'px',
'em',
'rem',
),
'range' => array(
'px' => array(
'min' => 1,
'max' => 100,
),
),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['icon_normal'] => 'font-size: {{SIZE}}{{UNIT}}',
),
)
);
$obj->add_responsive_control(
'normal_quickview_icon_margin',
array(
'label' => __( 'Margin', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::DIMENSIONS,
'size_units' => array( 'px', '%' ),
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['icon_normal'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
),
)
);
$obj->end_controls_tab();
$obj->start_controls_tab(
'tab_quickview_icon_hover',
array(
'label' => esc_html__( 'Hover', 'jet-woo-builder' ),
)
);
$obj->add_control(
'quickview_icon_color_hover',
array(
'label' => esc_html__( 'Color', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} ' . $css_scheme['button'] . ':hover ' . $css_scheme['icon_normal'] . ' i' => 'color: {{VALUE}}',
),
)
);
$obj->end_controls_tab();
$obj->end_controls_tabs();
$obj->end_controls_section();
}
/**
* Register displaying controls
*
* @param $obj
* @param array $args
*/
public function register_quickview_button_show_control( $obj, $args = array() ){
$obj->add_control(
'show_quickview',
array(
'label' => esc_html__( 'Show Quick View', 'jet-woo-builder' ),
'type' => Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'jet-woo-builder' ),
'label_off' => esc_html__( 'No', 'jet-woo-builder' ),
'return_value' => 'yes',
'default' => '',
)
);
$obj->add_responsive_control(
'quickview_button_order',
array(
'type' => Elementor\Controls_Manager::NUMBER,
'label' => esc_html__( 'Quick View Button Order', 'jet-woo-builder' ),
'default' => 1,
'min' => 1,
'max' => 10,
'step' => 1,
'selectors' => array(
'{{WRAPPER}} ' . '.jet-quickview-button__container' => 'order: {{VALUE}}',
),
)
);
}
}
}
new Jet_Woo_Builder_Popup_Package();

View File

@@ -0,0 +1,23 @@
<?php
/**
* Avada integration
*/
add_action( 'jet-smart-filters/providers/woocommerce-archive/before-ajax-content', 'jet_woo_astra_compatibility', 1 );
function jet_woo_astra_compatibility(){
if( class_exists( 'Astra_Woocommerce' ) ){
$astra = new Astra_Woocommerce();
if ( ! apply_filters( 'astra_woo_shop_product_structure_override', false ) ) {
$astra->shop_customization();
}
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
}
}

View File

@@ -0,0 +1,14 @@
/**
* Avada integration styles
*/
.jet-woo-builder .onsale {
display: inline-block;
}
.jet-woo-builder .price > .amount {
color: inherit;
}
.jet-woo-builder .woocommerce-tabs .panel {
margin: 0;
}

View File

@@ -0,0 +1,17 @@
/**
* Avada integration styles
*/
.jet-woo-builder{
.onsale{
display: inline-block;
}
.price > .amount{
color: inherit;
}
.woocommerce-tabs .panel{
margin: 0;
}
}

View File

@@ -0,0 +1,70 @@
<?php
/**
* Avada integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_avada_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_avada_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_avada_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_avada_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_avada_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_avada_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_avada_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_avada_close_site_main_wrap', 999 );
add_action( 'wp_enqueue_scripts', 'jet_woo_avada_enqueue_styles' );
add_action( 'elementor/widgets/widgets_registered', 'jet_woo_avada_fix_wc_hooks' );
/**
* Fix WooCommerce hooks for avada
*
* @return [type] [description]
*/
function jet_woo_avada_fix_wc_hooks() {
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_avada_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_avada_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}
/**
* Enqueue Avada integration stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
function jet_woo_avada_enqueue_styles() {
wp_enqueue_style(
'jet-woo-builder-avada',
jet_woo_builder()->plugin_url( 'includes/integrations/themes/avada/assets/css/style.css' ),
false,
jet_woo_builder()->get_version()
);
}

View File

@@ -0,0 +1,31 @@
/**
* GeneratePress integration styles
*/
.site-main .jet-woo-builder .product_meta > span,
.entry-content .jet-woo-builder .product_meta > span {
display: block;
}
.site-main .jet-woo-builder .tabs:after, .site-main .jet-woo-builder .tabs:before,
.entry-content .jet-woo-builder .tabs:after,
.entry-content .jet-woo-builder .tabs:before {
display: none !important;
}
.site-main .jet-woo-builder .tabs > li,
.entry-content .jet-woo-builder .tabs > li {
border: none !important;
background: transparent !important;
}
.site-main .jet-woo-builder .tabs > li:after, .site-main .jet-woo-builder .tabs > li:before,
.entry-content .jet-woo-builder .tabs > li:after,
.entry-content .jet-woo-builder .tabs > li:before {
display: none;
}
.site-main .jet-woo-builder .tabs > li a,
.entry-content .jet-woo-builder .tabs > li a {
width: 100%;
display: block;
}

View File

@@ -0,0 +1,34 @@
/**
* GeneratePress integration styles
*/
.site-main .jet-woo-builder,
.entry-content .jet-woo-builder {
.product_meta {
> span {
display: block;
}
}
.tabs{
&:after,
&:before{
display: none!important;
}
> li {
border: none!important;
background: transparent!important;
&:after,
&:before {
display: none;
}
a {
width: 100%;
display: block;
}
}
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* GeneratePress integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_generatepress_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_generatepress_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_generatepress_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_generatepress_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_generatepress_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_generatepress_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_generatepress_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_generatepress_close_site_main_wrap', 999 );
add_action( 'wp_enqueue_scripts', 'jet_woo_generatepress_enqueue_styles' );
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_generatepress_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_generatepress_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}
/**
* Enqueue GeneratePress integration stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
function jet_woo_generatepress_enqueue_styles() {
wp_enqueue_style(
'jet-woo-builder-generatepress',
jet_woo_builder()->plugin_url( 'includes/integrations/themes/generatepress/assets/css/style.css' ),
false,
jet_woo_builder()->get_version()
);
}

View File

@@ -0,0 +1,44 @@
/**
* Hestia integration styles
*/
.site-main .jet-woo-builder .product_meta > span,
.main .jet-woo-builder .product_meta > span,
.entry-content .jet-woo-builder .product_meta > span {
display: block;
}
.site-main .jet-woo-builder .woocommerce-tabs li,
.main .jet-woo-builder .woocommerce-tabs li,
.entry-content .jet-woo-builder .woocommerce-tabs li {
margin: 0;
}
.site-main .jet-woo-builder .tabs:after, .site-main .jet-woo-builder .tabs:before,
.main .jet-woo-builder .tabs:after,
.main .jet-woo-builder .tabs:before,
.entry-content .jet-woo-builder .tabs:after,
.entry-content .jet-woo-builder .tabs:before {
display: none !important;
}
.site-main .jet-woo-builder .tabs > li,
.main .jet-woo-builder .tabs > li,
.entry-content .jet-woo-builder .tabs > li {
border: none !important;
background: transparent !important;
}
.site-main .jet-woo-builder .tabs > li:after, .site-main .jet-woo-builder .tabs > li:before,
.main .jet-woo-builder .tabs > li:after,
.main .jet-woo-builder .tabs > li:before,
.entry-content .jet-woo-builder .tabs > li:after,
.entry-content .jet-woo-builder .tabs > li:before {
display: none;
}
.site-main .jet-woo-builder .tabs > li a,
.main .jet-woo-builder .tabs > li a,
.entry-content .jet-woo-builder .tabs > li a {
width: 100%;
display: block;
}

View File

@@ -0,0 +1,39 @@
/**
* Hestia integration styles
*/
.site-main .jet-woo-builder,
.main .jet-woo-builder,
.entry-content .jet-woo-builder {
.product_meta {
> span {
display: block;
}
}
.woocommerce-tabs li {
margin: 0;
}
.tabs{
&:after,
&:before{
display: none!important;
}
> li {
border: none!important;
background: transparent!important;
&:after,
&:before {
display: none;
}
a {
width: 100%;
display: block;
}
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Hestia integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_hestia_open_site_main_wrap', -999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_hestia_open_site_main_wrap', -999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_hestia_open_site_main_wrap', -999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_hestia_open_site_main_wrap', -999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_hestia_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_hestia_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_hestia_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_hestia_close_site_main_wrap', 999 );
add_action( 'elementor/widgets/widgets_registered', 'jet_woo_hestia_fix_wc_hooks' );
add_action( 'wp_enqueue_scripts', 'jet_woo_hestia_enqueue_styles' );
/**
* Fix WooCommerce hooks for hestia
*
* @return [type] [description]
*/
function jet_woo_hestia_fix_wc_hooks() {
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_hestia_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_hestia_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}
/**
* Enqueue Hestia integration stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
function jet_woo_hestia_enqueue_styles() {
wp_enqueue_style(
'jet-woo-builder-hestia',
jet_woo_builder()->plugin_url( 'includes/integrations/themes/hestia/assets/css/style.css' ),
false,
jet_woo_builder()->get_version()
);
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* Kava integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_kava_open_site_main_wrap', -999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_kava_open_site_main_wrap', -999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_kava_open_site_main_wrap', -999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_kava_open_site_main_wrap', -999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_kava_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_kava_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_kava_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_kava_close_site_main_wrap', 999 );
add_action( 'elementor/widgets/widgets_registered', 'jet_woo_kava_fix_wc_hooks' );
/**
* Fix WooCommerce hooks for kava
*
* @return [type] [description]
*/
function jet_woo_kava_fix_wc_hooks() {
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 10 );
}
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_kava_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_kava_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}

View File

@@ -0,0 +1,56 @@
/**
* Ocean WP integration styles
*/
/* Product Button styles */
.add_to_cart_button.button {
float: none;
display: inline-block;
background-color: transparent;
color: #848494;
padding: 5px 12px;
border: 3px double #e4e4e4;
font-size: 12px;
line-height: 1.5;
border-radius: 0;
text-transform: none; }
.add_to_cart_button.button:hover {
background-color: transparent;
color: #13aff0;
border-color: #13aff0; }
.entry-content .jet-woo-builder .product_meta > span {
display: block; }
.entry-content .jet-woo-builder .woocommerce-tabs li {
margin: 0; }
.entry-content .jet-woo-builder .tabs > li:after, .entry-content .jet-woo-builder .tabs > li:before {
display: none; }
.entry-content .jet-woo-builder .tabs > li a {
width: 100%;
display: block; }
.entry-content .jet-woo-builder .woocommerce-tabs ul.tabs.wc-tabs,
.entry-content .jet-woo-builder .woocommerce-tabs ul.tabs.wc-tabs li a {
border: none; }
.entry-content .jet-woo-builder .woocommerce-variation-price .price {
display: block; }
.entry-content .jet-woo-builder .woocommerce-tabs .panel.wc-tab {
margin: 0; }
.entry-content .jet-woo-builder .price .amount {
color: inherit; }
.entry-content .jet-woo-builder .single_add_to_cart_button {
vertical-align: top; }
.entry-content .jet-woo-builder form .input-text.qty {
max-width: calc( 100% - 74px); }
.woocommerce div.product .jet-single-images__wrap .woocommerce-product-gallery .flex-control-thumbs li {
clear: unset !important; }
/*# sourceMappingURL=style.css.map */

View File

@@ -0,0 +1,75 @@
/**
* Ocean WP integration styles
*/
@import "woocommerce";
.entry-content .jet-woo-builder {
.product_meta {
> span {
display: block;
}
}
.woocommerce-tabs li {
margin: 0;
}
.tabs > li {
&:after,
&:before {
display: none;
}
a {
width: 100%;
display: block;
}
}
.woocommerce-tabs ul.tabs.wc-tabs,
.woocommerce-tabs ul.tabs.wc-tabs li a {
border: none;
}
.woocommerce-variation-price .price {
display: block;
}
.woocommerce-tabs .panel.wc-tab {
margin: 0;
}
.price .amount{
color: inherit;
}
.single_add_to_cart_button{
vertical-align: top;
}
form .input-text.qty{
max-width: calc( 100% - 74px );
}
}
.woocommerce div.product .jet-single-images__wrap .woocommerce-product-gallery .flex-control-thumbs li{
clear: unset!important;
}
// TODO: Do this when will work on OceanWP compatibility
//.elementor-jet-woo-builder-products-ordering {
// .woocommerce-ordering {
// select{
// -webkit-appearance: inherit!important;
// width: 100%!important;
// position: relative!important;
// opacity: 1!important;
// height: auto!important;
// }
//
// .theme-select.orderby.theme-selectOpen{
// display: none!important;
// }
// }
//}

View File

@@ -0,0 +1,21 @@
/* Product Button styles */
.add_to_cart_button {
&.button {
float: none;
display: inline-block;
background-color: transparent;
color: #848494;
padding: 5px 12px;
border: 3px double #e4e4e4;
font-size: 12px;
line-height: 1.5;
border-radius: 0;
text-transform: none;
&:hover {
background-color: transparent;
color: #13aff0;
border-color: #13aff0;
}
}
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* Ocean WP integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_oceanwp_open_site_main_wrap', -999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_oceanwp_open_site_main_wrap', -999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_oceanwp_open_site_main_wrap', -999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_oceanwp_open_site_main_wrap', -999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_oceanwp_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_oceanwp_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_oceanwp_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_oceanwp_close_site_main_wrap', 999 );
add_action( 'elementor/widgets/widgets_registered', 'jet_woo_oceanwp_fix_wc_hooks' );
add_action( 'wp_enqueue_scripts', 'jet_woo_oceanwp_enqueue_styles' );
add_filter( 'ocean_post_layout_class', 'jet_woo_oceanwp_display_sidebar' );
function jet_woo_oceanwp_display_sidebar( $class ){
if ( get_post_type() === 'jet-woo-builder' ){
$class = 'full-width';
}
return $class;
}
/**
* Fix WooCommerce hooks for oceanwp
*
* @return [type] [description]
*/
function jet_woo_oceanwp_fix_wc_hooks() {
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_oceanwp_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_oceanwp_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}
/**
* Enqueue Ocean WP integration stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
function jet_woo_oceanwp_enqueue_styles() {
wp_enqueue_style(
'jet-woo-builder-oceanwp',
jet_woo_builder()->plugin_url( 'includes/integrations/themes/oceanwp/assets/css/style.css' ),
false,
jet_woo_builder()->get_version()
);
}

View File

@@ -0,0 +1,33 @@
/**
* Storefront integration styles
*/
div.product .jet-woo-builder .woocommerce-product-gallery .flex-control-thumbs li {
display: inline-block;
}
.single-product div.product .jet-woo-builder .product_meta {
padding: 0;
font-size: inherit;
border: none;
}
.jet-woo-builder .woocommerce-tabs ul.tabs li:after {
display: none;
}
.single-product div.product .jet-woo-builder .woocommerce-product-rating {
margin-top: 0;
margin-bottom: 0;
}
@media (min-width: 768px) {
.jet-woo-builder.elementor-jet-woo-builder-products-ordering .woocommerce-ordering,
.jet-woo-builder.elementor-jet-woo-builder-products-ordering .woocommerce-result-count,
.jet-woo-builder.elementor-jet-woo-builder-products-result-count .woocommerce-ordering,
.jet-woo-builder.elementor-jet-woo-builder-products-result-count .woocommerce-result-count {
float: none;
margin-bottom: 0;
margin-right: 0;
padding: 0;
}
}

View File

@@ -0,0 +1,34 @@
/**
* Storefront integration styles
*/
div.product .jet-woo-builder .woocommerce-product-gallery .flex-control-thumbs li {
display: inline-block;
}
.single-product div.product .jet-woo-builder .product_meta {
padding: 0;
font-size: inherit;
border: none;
}
.jet-woo-builder .woocommerce-tabs ul.tabs li:after{
display: none;
}
.single-product div.product .jet-woo-builder .woocommerce-product-rating{
margin-top: 0;
margin-bottom: 0;
}
.jet-woo-builder.elementor-jet-woo-builder-products-ordering,
.jet-woo-builder.elementor-jet-woo-builder-products-result-count{
@media (min-width: 768px){
.woocommerce-ordering,
.woocommerce-result-count {
float: none;
margin-bottom: 0;
margin-right: 0;
padding: 0;
}
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* Storefront integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_storefront_open_site_main_wrap', -999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_storefront_open_site_main_wrap', -999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_storefront_open_site_main_wrap', -999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_storefront_open_site_main_wrap', -999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_storefront_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_storefront_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_storefront_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_storefront_close_site_main_wrap', 999 );
add_action( 'elementor/widgets/widgets_registered', 'jet_woo_storefront_fix_wc_hooks' );
add_action( 'wp_enqueue_scripts', 'jet_woo_storefront_enqueue_styles' );
/**
* Fix WooCommerce hooks for storefront
*
* @return [type] [description]
*/
function jet_woo_storefront_fix_wc_hooks() {
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
add_filter( 'storefront_product_thumbnail_columns', 'jet_woo_storefront_thumbnails_columns' );
}
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_storefront_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_storefront_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}
function jet_woo_storefront_thumbnails_columns( $columns ){
$columns = 6;
return $columns;
}
/**
* Enqueue Storefront integration stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
function jet_woo_storefront_enqueue_styles() {
wp_enqueue_style(
'jet-woo-builder-storefront',
jet_woo_builder()->plugin_url( 'includes/integrations/themes/storefront/assets/css/style.css' ),
false,
jet_woo_builder()->get_version()
);
}

View File

@@ -0,0 +1,19 @@
/**
* Twenty Fifteen integration styles
*/
.jet-woo-builder-template-elementor_canvas:before {
display: none;
}
.jet-woo-builder .woocommerce-review-link {
border: none;
}
.jet-woo-builder .product_meta > span {
display: block;
}
.jet-woo-builder .tagged_as a,
.jet-woo-builder .posted_in a {
border: none;
}

View File

@@ -0,0 +1,28 @@
/**
* Twenty Fifteen integration styles
*/
.jet-woo-builder-template-elementor_canvas {
&:before {
display: none;
}
}
.jet-woo-builder {
.woocommerce-review-link {
border: none;
}
.product_meta{
> span{
display: block;
}
}
.tagged_as,
.posted_in{
a{
border: none;
}
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Twenty Fifteen integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_twenty_fifteen_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_twenty_fifteen_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_twenty_fifteen_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_twenty_fifteen_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_twenty_fifteen_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_twenty_fifteen_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_twenty_fifteen_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_twenty_fifteen_close_site_main_wrap', 999 );
add_action( 'wp_enqueue_scripts', 'jet_woo_twenty_fifteen_enqueue_styles' );
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_twenty_fifteen_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_twenty_fifteen_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}
/**
* Enqueue Twenty Fifteen integration stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
function jet_woo_twenty_fifteen_enqueue_styles() {
wp_enqueue_style(
'jet-woo-builder-twentyfifteen',
jet_woo_builder()->plugin_url( 'includes/integrations/themes/twentyfifteen/assets/css/style.css' ),
false,
jet_woo_builder()->get_version()
);
}

View File

@@ -0,0 +1,27 @@
/**
* Twenty Seventeen integration styles
*/
.entry-content .jet-woo-builder .product_meta > span {
display: block;
}
.entry-content .jet-woo-builder a:hover {
box-shadow: none;
}
.entry-content .jet-woo-builder .woocommerce-tabs li {
margin: 0;
}
.entry-content .jet-woo-builder .tabs > li.active a {
box-shadow: none;
}
.entry-content .jet-woo-builder .tabs > li a {
width: 100%;
display: block;
}
.entry-content .jet-woo-builder .woocommerce-variation-price .price {
display: block;
}

View File

@@ -0,0 +1,38 @@
/**
* Twenty Seventeen integration styles
*/
.entry-content .jet-woo-builder {
.product_meta{
> span{
display: block;
}
}
a:hover {
box-shadow: none;
}
.woocommerce-tabs li {
margin: 0;
}
.tabs > li{
&.active{
a{
box-shadow: none;
}
}
a {
width: 100%;
display: block;
}
}
.woocommerce-variation-price .price{
display: block;
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Twenty Seventeen integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_twenty_seventeen_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_twenty_seventeen_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_twenty_seventeen_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_twenty_seventeen_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_twenty_seventeen_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_twenty_seventeen_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_twenty_seventeen_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_twenty_seventeen_close_site_main_wrap', 999 );
add_action( 'wp_enqueue_scripts', 'jet_woo_twenty_seventeen_enqueue_styles' );
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_twenty_seventeen_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_twenty_seventeen_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}
/**
* Enqueue Twenty Fifteen integration stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
function jet_woo_twenty_seventeen_enqueue_styles() {
wp_enqueue_style(
'jet-woo-builder-twentyseventeen',
jet_woo_builder()->plugin_url( 'includes/integrations/themes/twentyseventeen/assets/css/style.css' ),
false,
jet_woo_builder()->get_version()
);
}

View File

@@ -0,0 +1,31 @@
/**
* Twenty Sixteen integration styles
*/
.entry-content .jet-woo-builder .product_meta > span {
display: block;
}
.entry-content .jet-woo-builder .woocommerce-tabs li {
margin: 0;
}
.entry-content .jet-woo-builder .tabs > li {
border: none !important;
background-color: transparent !important;
border-radius: 0 !important;
margin: 0 !important;
padding: 0 !important;
}
.entry-content .jet-woo-builder .tabs > li:after, .entry-content .jet-woo-builder .tabs > li:before {
display: none;
}
.entry-content .jet-woo-builder .tabs > li a {
width: 100%;
display: block;
}
.entry-content .jet-woo-builder .woocommerce-variation-price .price {
display: block;
}

View File

@@ -0,0 +1,38 @@
/**
* Twenty Sixteen integration styles
*/
.entry-content .jet-woo-builder {
.product_meta{
> span{
display: block;
}
}
.woocommerce-tabs li {
margin: 0;
}
.tabs > li{
border: none!important;
background-color: transparent!important;
border-radius: 0!important;
margin: 0!important;
padding: 0!important;
&:after,
&:before{
display: none;
}
a {
width: 100%;
display: block;
}
}
.woocommerce-variation-price .price{
display: block;
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Twenty Sixteen integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_twenty_sixteen_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_twenty_sixteen_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_twenty_sixteen_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_twenty_sixteen_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_twenty_sixteen_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_twenty_sixteen_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_twenty_sixteen_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_twenty_sixteen_close_site_main_wrap', 999 );
add_action( 'wp_enqueue_scripts', 'jet_woo_twenty_sixteen_enqueue_styles' );
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_twenty_sixteen_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_twenty_sixteen_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}
/**
* Enqueue Twenty Fifteen integration stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
function jet_woo_twenty_sixteen_enqueue_styles() {
wp_enqueue_style(
'jet-woo-builder-twentysixteen',
jet_woo_builder()->plugin_url( 'includes/integrations/themes/twentysixteen/assets/css/style.css' ),
false,
jet_woo_builder()->get_version()
);
}

View File

@@ -0,0 +1,45 @@
/**
* Zerif Lite integration styles
*/
.site-main .jet-woo-builder .product_meta > span,
.entry-content .jet-woo-builder .product_meta > span {
display: block;
}
.site-main .jet-woo-builder p,
.entry-content .jet-woo-builder p {
text-align: inherit;
}
.site-main .jet-woo-builder button.button,
.entry-content .jet-woo-builder button.button {
width: auto;
}
.site-main .jet-woo-builder .tabs,
.entry-content .jet-woo-builder .tabs {
padding-left: inherit;
}
.site-main .jet-woo-builder .tabs:before,
.entry-content .jet-woo-builder .tabs:before {
display: none !important;
}
.site-main .jet-woo-builder .tabs > li,
.entry-content .jet-woo-builder .tabs > li {
background: transparent !important;
border: none !important;
}
.site-main .jet-woo-builder .tabs > li:after, .site-main .jet-woo-builder .tabs > li:before,
.entry-content .jet-woo-builder .tabs > li:after,
.entry-content .jet-woo-builder .tabs > li:before {
display: none;
}
.site-main .jet-woo-builder .tabs > li a,
.entry-content .jet-woo-builder .tabs > li a {
width: 100%;
display: block;
}

View File

@@ -0,0 +1,43 @@
/**
* Zerif Lite integration styles
*/
.site-main .jet-woo-builder,
.entry-content .jet-woo-builder {
.product_meta {
> span {
display: block;
}
}
p {
text-align: inherit;
}
button.button {
width: auto;
}
.tabs {
padding-left: inherit;
&:before{
display: none!important;
}
> li {
background: transparent!important;
border: none!important;
&:after,
&:before {
display: none;
}
a {
width: 100%;
display: block;
}
}
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Zerif Lite integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_zeriflite_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_zeriflite_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_zeriflite_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_zeriflite_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_zeriflite_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_zeriflite_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_zeriflite_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_zeriflite_close_site_main_wrap', 999 );
add_action( 'wp_enqueue_scripts', 'jet_woo_zeriflite_enqueue_styles' );
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_zeriflite_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_zeriflite_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}
/**
* Enqueue Zerif Lite integration stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
function jet_woo_zeriflite_enqueue_styles() {
wp_enqueue_style(
'jet-woo-builder-zeriflite',
jet_woo_builder()->plugin_url( 'includes/integrations/themes/zerif-lite/assets/css/style.css' ),
false,
jet_woo_builder()->get_version()
);
}

View File

@@ -0,0 +1,45 @@
/**
* Zerif integration styles
*/
.site-main .jet-woo-builder .product_meta > span,
.entry-content .jet-woo-builder .product_meta > span {
display: block;
}
.site-main .jet-woo-builder p,
.entry-content .jet-woo-builder p {
text-align: inherit;
}
.site-main .jet-woo-builder button.button,
.entry-content .jet-woo-builder button.button {
width: auto;
}
.site-main .jet-woo-builder .tabs,
.entry-content .jet-woo-builder .tabs {
padding-left: inherit;
}
.site-main .jet-woo-builder .tabs:before,
.entry-content .jet-woo-builder .tabs:before {
display: none !important;
}
.site-main .jet-woo-builder .tabs > li,
.entry-content .jet-woo-builder .tabs > li {
background: transparent !important;
border: none !important;
}
.site-main .jet-woo-builder .tabs > li:after, .site-main .jet-woo-builder .tabs > li:before,
.entry-content .jet-woo-builder .tabs > li:after,
.entry-content .jet-woo-builder .tabs > li:before {
display: none;
}
.site-main .jet-woo-builder .tabs > li a,
.entry-content .jet-woo-builder .tabs > li a {
width: 100%;
display: block;
}

View File

@@ -0,0 +1,43 @@
/**
* Zerif integration styles
*/
.site-main .jet-woo-builder,
.entry-content .jet-woo-builder {
.product_meta {
> span {
display: block;
}
}
p {
text-align: inherit;
}
button.button {
width: auto;
}
.tabs {
padding-left: inherit;
&:before{
display: none!important;
}
> li {
background: transparent!important;
border: none!important;
&:after,
&:before {
display: none;
}
a {
width: 100%;
display: block;
}
}
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Zerif integration
*/
add_action( 'elementor/page_templates/canvas/before_content', 'jet_woo_zerif_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/blank-page/before-content', 'jet_woo_zerif_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/header-footer/before_content', 'jet_woo_zerif_open_site_main_wrap', - 999 );
add_action( 'jet-woo-builder/full-width-page/before-content', 'jet_woo_zerif_open_site_main_wrap', - 999 );
add_action( 'elementor/page_templates/canvas/after_content', 'jet_woo_zerif_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/blank-page/after_content', 'jet_woo_zerif_close_site_main_wrap', 999 );
add_action( 'elementor/page_templates/header-footer/after_content', 'jet_woo_zerif_close_site_main_wrap', 999 );
add_action( 'jet-woo-builder/full-width-page/after_content', 'jet_woo_zerif_close_site_main_wrap', 999 );
add_action( 'wp_enqueue_scripts', 'jet_woo_zerif_enqueue_styles' );
/**
* Open .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_zerif_open_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '<div class="site-main">';
}
/**
* Close .site-main wrapper for products
* @return [type] [description]
*/
function jet_woo_zerif_close_site_main_wrap() {
if ( ! is_singular( array( jet_woo_builder_post_type()->slug(), 'product' ) ) ) {
return;
}
echo '</div>';
}
/**
* Enqueue Zerif integration stylesheets.
*
* @since 1.0.0
* @access public
* @return void
*/
function jet_woo_zerif_enqueue_styles() {
wp_enqueue_style(
'jet-woo-builder-zerif',
jet_woo_builder()->plugin_url( 'includes/integrations/themes/zerif/assets/css/style.css' ),
false,
jet_woo_builder()->get_version()
);
}

View File

@@ -0,0 +1,219 @@
<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Woo_Builder_Compatibility' ) ) {
/**
* Define Jet_Woo_Builder_Compatibility class
*/
class Jet_Woo_Builder_Compatibility {
/**
* 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() {
// WPML String Translation plugin exist check
if ( defined( 'WPML_ST_VERSION' ) ) {
add_filter( 'wpml_elementor_widgets_to_translate', array( $this, 'add_translatable_nodes' ) );
add_filter( 'jet-woo-builder/current-template/template-id', array( $this, 'jet_woo_builder_modify_template_id' ) );
}
}
function jet_woo_builder_modify_template_id( $template_id ) {
// WPML String Translation plugin exist check
return apply_filters( 'wpml_object_id', $template_id, jet_woo_builder_post_type()->slug(), true );
}
/**
* Load required files.
*
* @return void
*/
public function load_files() {
}
/**
* Add jet elements translation nodes
*
* @param array
*/
public function add_translatable_nodes( $nodes_to_translate ) {
$nodes_to_translate[ 'jet-woo-products' ] = array(
'conditions' => array( 'widgetType' => 'jet-woo-products' ),
'fields' => array(
array(
'field' => 'sale_badge_text',
'type' => esc_html__( 'Jet Woo Products Grid: Set sale badge text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
$nodes_to_translate[ 'jet-woo-categories' ] = array(
'conditions' => array( 'widgetType' => 'jet-woo-categories' ),
'fields' => array(
array(
'field' => 'count_before_text',
'type' => esc_html__( 'Jet Woo Categories Grid: Count Before Text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
array(
'field' => 'count_after_text',
'type' => esc_html__( 'Jet Woo Categories Grid: Count After Text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
array(
'field' => 'desc_after_text',
'type' => esc_html__( 'Jet Woo Categories Grid: Trimmed After Text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
$nodes_to_translate[ 'jet-woo-taxonomy-tiles' ] = array(
'conditions' => array( 'widgetType' => 'jet-woo-taxonomy-tiles' ),
'fields' => array(
array(
'field' => 'count_before_text',
'type' => esc_html__( 'Jet Woo Taxonomy Tiles: Count Before Text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
array(
'field' => 'count_after_text',
'type' => esc_html__( 'Jet Woo Taxonomy Tiles: Count After Text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
$nodes_to_translate[ 'jet-single-attributes' ] = array(
'conditions' => array( 'widgetType' => 'jet-single-attributes' ),
'fields' => array(
array(
'field' => 'block_title',
'type' => esc_html__( 'Jet Woo Single Attributes: Title Text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
$nodes_to_translate[ 'jet-woo-builder-archive-sale-badge' ] = array(
'conditions' => array( 'widgetType' => 'jet-woo-builder-archive-sale-badge' ),
'fields' => array(
array(
'field' => 'block_title',
'type' => esc_html__( 'Jet Woo Archive Sale Badge: Sale Badge Text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
$nodes_to_translate[ 'jet-woo-builder-archive-category-count' ] = array(
'conditions' => array( 'widgetType' => 'jet-woo-builder-archive-category-count' ),
'fields' => array(
array(
'field' => 'archive_category_count_before_text',
'type' => esc_html__( 'Jet Woo Archive Category Count: Count Before Text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
$nodes_to_translate[ 'jet-woo-builder-archive-category-count' ] = array(
'conditions' => array( 'widgetType' => 'jet-woo-builder-archive-category-count' ),
'fields' => array(
array(
'field' => 'archive_category_count_after_text',
'type' => esc_html__( 'Jet Woo Archive Category Count: Count After Text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
$nodes_to_translate[ 'jet-woo-builder-products-navigation' ] = array(
'conditions' => array( 'widgetType' => 'jet-woo-builder-products-navigation' ),
'fields' => array(
array(
'field' => 'prev_text',
'type' => esc_html__( 'Jet Woo Shop Products Navigation: The previous page link text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
$nodes_to_translate[ 'jet-woo-builder-products-navigation' ] = array(
'conditions' => array( 'widgetType' => 'jet-woo-builder-products-navigation' ),
'fields' => array(
array(
'field' => 'next_text',
'type' => esc_html__( 'Jet Woo Shop Products Navigation: The next page link text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
$nodes_to_translate[ 'jet-woo-builder-products-pagination' ] = array(
'conditions' => array( 'widgetType' => 'jet-woo-builder-products-pagination' ),
'fields' => array(
array(
'field' => 'prev_text',
'type' => esc_html__( 'Jet Woo Shop Products Pagination: The previous page link text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
$nodes_to_translate[ 'jet-woo-builder-products-pagination' ] = array(
'conditions' => array( 'widgetType' => 'jet-woo-builder-products-pagination' ),
'fields' => array(
array(
'field' => 'next_text',
'type' => esc_html__( 'Jet Woo Shop Products Pagination: The next page link text', 'jet-woo-builder' ),
'editor_type' => 'LINE',
),
),
);
return $nodes_to_translate;
}
/**
* 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_Builder_Compatibility
*
* @return object
*/
function jet_woo_builder_compatibility() {
return Jet_Woo_Builder_Compatibility::get_instance();
}

View File

@@ -0,0 +1,330 @@
<?php
/**
* DB Updater module
*
* Version: 1.0.0
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Db_Updater' ) ) {
/**
* Class Cherry Db Updater.
*
* @since 1.0.0
*/
class CX_Db_Updater {
/**
* Module arguments.
*
* @since 1.0.0
* @var array
*/
private $args = array(
'callbacks' => array(),
'slug' => null,
'version' => null,
);
/**
* Option key for DB version.
*
* @since 1.0.0
* @var string
*/
protected $version_key = '%s-db-version';
/**
* Nonce format.
*
* @since 1.0.0
* @var string
*/
protected $nonce = '_%s-db-update-nonce';
/**
* Messages array.
*
* @since 1.0.0
* @var array
*/
protected $messages = array();
/**
* Update done trigger.
*
* @since 1.0.0
* @var bool
*/
protected $updated = false;
/**
* CX_Db_Updater constructor.
*
* @since 1.0.0
* @return void
*/
public function __construct( $args = array() ) {
$this->args = wp_parse_args( $args, $this->args );
if ( ! is_admin() || ! current_user_can( 'update_plugins' ) ) {
return;
}
add_action( 'admin_notices', array( $this, 'init_notices' ) );
add_action( 'admin_init', array( $this, 'do_update' ) );
$this->messages = array(
'error' => esc_html__( 'Module DB Updater init error in %s - version and slug is required arguments', 'cherry-x-framework' ),
'update' => esc_html__( 'We need to update your database to the latest version.', 'cherry-x-framework' ),
'updated' => esc_html__( 'Update complete, thank you for updating to the latest version!', 'cherry-x-framework' ),
);
}
/**
* Process DB update.
*
* @since 1.0.0
*/
public function do_update() {
if ( ! $this->is_current_update() ) {
return;
}
$callbacks = $this->prepare_callbacks();
if ( ! empty( $callbacks ) ) {
foreach ( $callbacks as $callback ) {
if ( is_callable( $callback ) ) {
call_user_func( $callback );
}
}
}
$this->set_updated();
}
/**
* Finalize update.
*
* @since 1.0.0
*/
public function set_updated() {
$this->updated = true;
$option = sprintf( $this->version_key, esc_attr( $this->args['slug'] ) );
update_option( $option, esc_attr( $this->args['version'] ) );
}
/**
* Prepare callbacks array.
*
* @since 1.0.0
* @return array
*/
private function prepare_callbacks() {
$callbacks = array();
if ( empty( $this->args['callbacks'] ) ) {
return $callbacks;
}
ksort( $this->args['callbacks'] );
foreach ( $this->args['callbacks'] as $ver => $ver_cb ) {
if ( version_compare( $this->get_current_version(), $ver, '<' ) ) {
$callbacks = array_merge( $callbacks, $ver_cb );
}
}
return $callbacks;
}
/**
* Check if we processed update for plugin passed in arguments.
*
* @since 1.0.0
* @return bool
*/
private function is_current_update() {
if ( empty( $_GET['cherry_x_db_update'] ) || empty( $_GET['slug'] ) || empty( $_GET['_nonce'] ) ) {
return false;
}
if ( $_GET['slug'] !== $this->args['slug'] ) {
return false;
}
$nonce_action = sprintf( $this->nonce, esc_attr( $this->args['slug'] ) );
if ( ! wp_verify_nonce( $_GET['_nonce'], $nonce_action ) ) {
return false;
}
return true;
}
/**
* Init admin notices.
*
* @since 1.0.0
* @return void
*/
public function init_notices() {
$slug = esc_attr( $this->args['slug'] );
if ( $this->is_update_required() ) {
$this->show_notice( $slug );
}
if ( $this->is_updated() ) {
$this->show_updated_notice( $slug );
}
}
/**
* Returns current DB version.
*
* @since 1.0.0
* @return string
*/
private function get_current_version() {
$option = sprintf( $this->version_key, esc_attr( $this->args['slug'] ) );
return get_option( $option, '1.0.0' );
}
/**
* Check if database requires update.
*
* @since 1.0.0
* @return bool
*/
private function is_update_required() {
$current = $this->get_current_version();
return version_compare( $current, esc_attr( $this->args['version'] ), '<' );
}
/**
* Check if update was succesfully done.
*
* @since 1.0.0
* @return bool
*/
private function is_updated() {
if ( ! $this->is_current_update() ) {
return false;
}
return (bool) $this->updated;
}
/**
* Show notice.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return void
*/
private function show_notice( $slug ) {
echo '<div class="notice notice-info">';
echo '<p>';
$this->notice_title( $slug );
echo $this->messages['update'];
echo '</p>';
echo '<p>';
$this->notice_submit( $slug );
echo '</p>';
echo '</div>';
}
/**
* Show update notice.
*
* @since 1.0.0
* @return void
*/
private function show_updated_notice() {
$slug = esc_attr( $this->args['slug'] );
echo '<div class="notice notice-success is-dismissible">';
echo '<p>';
$this->notice_title( $slug );
echo $this->messages['updated'];
echo '</p>';
echo '</div>';
}
/**
* Show plugin notice submit button.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return void
*/
private function notice_submit( $slug = '' ) {
$format = '<a href="%1s" class="button button-primary">%2$s</a>';
$label = esc_html__( 'Start Update', 'cherry-x-framework' );
$url = add_query_arg(
array(
'cherry_x_db_update' => true,
'slug' => $slug,
'_nonce' => $this->create_nonce( $slug ),
),
esc_url( admin_url( 'index.php' ) )
);
printf( $format, $url, $label );
}
/**
* Create DB update nonce.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return string
*/
private function create_nonce( $slug ) {
return wp_create_nonce( sprintf( $this->nonce, $slug ) );
}
/**
* Show plugin notice title.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return void
*/
private function notice_title( $slug ) {
$name = str_replace( '-', ' ', $slug );
$name = ucwords( $name );
printf( '<strong>%1$s %2$s</strong> &#8211; ', $name, esc_html__( 'Data Update', 'cherry-x-framework' ) );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core = null, $args = array() ) {
return new self( $args );
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,212 @@
@mixin button_base() {
position: relative;
display: inline-block;
font-size: 11px;
line-height: 18px;
text-decoration: none;
padding: 4px 22px;
color: $dark_color;
text-transform: uppercase;
border-radius: $border_radius_small;
border-width: 1px;
border-style: solid;
outline: none;
cursor: pointer;
transition: all 200ms linear;
&:before {
position: absolute;
display: block;
width: 100%;
height: 100%;
top: 0;
left: 0;
border-radius: $border_radius_small;
background-image: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);
content: '';
}
&:hover {
&:before {
background-image: linear-gradient(0deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);
}
}
&:active {
&:before {
opacity: 0;
}
}
}
@mixin button_normal() {
background: $dark_color_2;
&:hover {
background: $dark_color_2_h;
}
}
@mixin button_primary() {
background: $blue_color;
&:hover {
background: $blue_color_h;
}
}
@mixin button_success() {
background: $green_color;
&:hover {
background: $green_color_h;
}
}
@mixin button_danger() {
background: $red_color;
&:hover {
background: $red_color_h;
}
}
@mixin button_warning() {
background: $orange_color;
&:hover {
background: $orange_color_h;
}
}
@mixin secondary_button() {
color: $light_color;
border-color: $secondary_outset_1 $secondary_outset_2 $secondary_outset_2 $secondary_outset_1;
background-color: $secondary_gradint_2;
&:active {
background-color: $secondary_bg_color;
border-color: darken( $secondary_outset_2, 10%) $secondary_outset_1 $secondary_outset_1 darken( $secondary_outset_2, 10%);
}
}
@mixin input() {
font-size: 12px;
line-height: 16px;
color: $dark_color;
background-color: $bg_color;
border-radius: $border_radius_extra_small;
padding: 5px;
min-height: 28px;
border: 1px solid $border_color;
box-shadow: none;
&:focus{
border-color: darken( $border_color, 20% );
box-shadow: none;
}
}
@mixin button_icon( $icon ) {
content: $icon;
display: inline-block;
font-family: dashicons;
font-size: 16px;
font-style: normal;
font-weight: 400;
height: 18px;
line-height: 18px;
text-align: center;
text-decoration: inherit;
transition: all 200ms linear;
vertical-align: middle;
}
@mixin button_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
}
}
@mixin button_icon_after( $icon ) {
&:after {
@include button_icon( $icon );
padding: 0 0 0 5px;
}
}
@mixin button_icon_middle( $icon ) {
&:before {
@include button_icon( $icon );
margin: 0 -5px;
}
}
@mixin link() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
color: $blue_color;
text-transform: uppercase;
transition: all 200ms linear;
&:hover {
color: $dark_color_1;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: $blue_color;
}
}
@mixin link_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
color: $grey_color_4;
}
&:hover {
&:before {
color: $blue_color;
}
}
}
@mixin container() {
padding: 30px;
border: 2px solid $grey_color_2;
background: $grey_color_3;
border-radius: $border_radius_large;
}
@mixin container_heading() {
margin: -30px -30px 30px -30px;
border-radius: $border_radius_large $border_radius_large 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
text-align: center;
background: #fff;
}
@mixin box() {
margin: 0 0 30px;
padding: 20px;
background: #fff;
box-shadow: $box_shadow_box;
border-radius: $border_radius_small;
}
@mixin box_heading() {
margin: -20px -20px 20px -20px;
border-radius: $border_radius_small $border_radius_small 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
background: #fff;
}

View File

@@ -0,0 +1,17 @@
.cx-ui-kit{
button{
*{
pointer-events: none;
}
}
}
.cx-component{
&__content{
.cx-settings__content{
display: none;
&.show{
display: inherit;
}
}
}
}

View File

@@ -0,0 +1,86 @@
$bg_color: #f1f1f1;
$border_color: #dcdcdc;
$bg_color_2: #e5e5e5;
$primary_color: #2a90fc;
$blue_color: #298ffc;
$remove_color: #e54343;
$light_color: #ffffff;
$dark_color: #23282d;
$normal_bg_color: #e1e1e1;
$normal_gradint_1: #ffffff;
$normal_gradint_2: #f0f0f0;
$normal_outset_1: #d7d7d7;
$normal_outset_2: #b7b7b7;
$primary_bg_color: #206ff4;
$primary_gradint_1: #5fadff;
$primary_gradint_2: #2a90fc;
$primary_outset_1: #5b9add;
$primary_outset_2: #3e6a99;
$secondary_bg_color: #495159;
$secondary_gradint_1: #4c5054;
$secondary_gradint_2: #495159;
$secondary_outset_1: #777879;
$secondary_outset_2: #41464d;
$success_bg_color: #3ba956;
$success_gradint_1: #71e18f;
$success_gradint_2: #49c66a;
$success_outset_1: #49c56a;
$success_outset_2: #3a9e54;
$danger_bg_color: #c73434;
$danger_gradint_1: #f98888;
$danger_gradint_2: #e64545;
$danger_outset_1: #e54444;
$danger_outset_2: #b83636;
$warning_bg_color: #ee8425;
$warning_gradint_1: #ffcb81;
$warning_gradint_2: #faa832;
$warning_outset_1: #faa832;
$warning_outset_2: #c98627;
$dark_color_1: #23282d;
$dark_color_2: #495159;
$dark_color_2_h: #393f45;
$grey_color_1: #96989a;
$grey_color_2: #e5e5e5;
$grey_color_3: #f1f1f1;
$grey_color_4: #b4b7ba;
$blue_color: #298ffc;
$blue_color_h: #206ff4;
$green_color: #48c569;
$green_color_h: #3ba956;
$red_color: #e54343;
$red_color_h: #c73434;
$orange_color: #faa730;
$orange_color_h: #ee8425;
$border_radius_extra_small: 2px;
$border_radius_small: 4px;
$border_radius_medium: 6px;
$border_radius_large: 8px;
$box_shadow: 0 5px 13px rgba(0,0,0,.18);
$box_shadow_box: 0 8px 21px rgba(0,0,0,.1);
$light_color: #ffffff;
$dark_color: #23282d;
$switcher_bg_color: #f1f1f1;
$switcher_border_color: #dcdcdc;
$true_state_gradint_1: #71e18f;
$true_state_gradint_2: #49c66a;
$true_state_outset_1: #43b05f;
$true_state_outset_2: #3b9b54;
$false_state_gradint_1: #f98888;
$false_state_gradint_2: #e64545;
$false_state_outset_1: #e54545;
$false_state_outset_2: #c13b3b;

View File

@@ -0,0 +1,63 @@
.cx-button{
@include button_base();
&.cx-button-normal-style {
color: $dark_color;
border-color: $normal_outset_1 $normal_outset_2 $normal_outset_2 $normal_outset_1;
background-color: $normal_gradint_2;
&:active {
background-color: $normal_bg_color;
border-color: darken( $normal_outset_2, 10%) $normal_outset_1 $normal_outset_1 darken( $normal_outset_2, 10%);
}
}
&.cx-button-success-style {
color: $light_color;
border-color: $success_outset_1 $success_outset_2 $success_outset_2 $success_outset_1;
background-color: $success_gradint_2;
&:active {
background-color: $success_bg_color;
border-color: darken( $success_outset_2, 10%) $success_outset_1 $success_outset_1 darken( $success_outset_2, 10%);
}
}
&.cx-button-primary-style {
color: $light_color;
border-color: $primary_outset_1 $primary_outset_2 $primary_outset_2 $primary_outset_1;
background-color: $primary_gradint_2;
&:active {
background-color: $primary_bg_color;
border-color: darken( $primary_outset_2, 10%) $primary_outset_1 $primary_outset_1 darken( $primary_outset_2, 10%);
}
}
&.cx-button-secondary-style {
color: $light_color;
border-color: $secondary_outset_1 $secondary_outset_2 $secondary_outset_2 $secondary_outset_1;
background-color: $secondary_gradint_2;
&:active {
background-color: $secondary_bg_color;
border-color: darken( $secondary_outset_2, 10%) $secondary_outset_1 $secondary_outset_1 darken( $secondary_outset_2, 10%);
}
}
&.cx-button-danger-style{
color: $light_color;
border-color: $danger_outset_1 $danger_outset_2 $danger_outset_2 $danger_outset_1;
background-color: $danger_gradint_2;
&:active {
background-color: $danger_bg_color;
border-color: darken( $danger_outset_2, 10%) $danger_outset_1 $danger_outset_1 darken( $danger_outset_2, 10%);
}
}
&.cx-button-warning-style{
color: $light_color;
border-color: $warning_outset_1 $warning_outset_2 $warning_outset_2 $warning_outset_1;
background-color: $warning_gradint_2;
&:active {
background-color: $warning_bg_color;
border-color: darken( $warning_outset_2, 10%) $warning_outset_1 $warning_outset_1 darken( $warning_outset_2, 10%);
}
}
}

View File

@@ -0,0 +1,55 @@
.cx-checkbox-item{
width: 20px;
height: 20px;
display: inline-block;
border-radius: $border_radius_extra_small;
margin-right: 10px;
margin-bottom: 10px;
cursor: pointer;
position: relative;
background-color: $grey_color_3;
user-select: none;
transition: all 0.4s cubic-bezier(0.77, 0, 0.175, 1);
.marker{
position: absolute;
width: 20px;
height: 20px;
top: 0px;
left: 0px;
color: #fff;
font-size: 20px;
transition:inherit;
transform: scale(0);
&:before{
transition:inherit;
position: relative;
left: -1px;
}
}
}
.cx-label-content {
display: flex;
}
.cx-checkbox-input{
&[checked]{
&+.cx-checkbox-item{
background-color: $green_color;
.marker{
transform: scale(1);
}
}
}
}
.cx-checkbox-label{
font-size: 12px;
line-height: 20px;
color: $dark_color_1;
user-select: none;
&:focus{
outline: 1px solid rgba(41, 143, 252, .6);
box-shadow: 0px 0px 2px rgba(41,143,252,0.6);
}
}

View File

@@ -0,0 +1,50 @@
$font_size: 14px;
.cx-ui-colorpicker-wrapper {
.wp-picker-container {
padding: 3px;
border-radius: 3px;
.wp-color-result-text {
line-height: 18px;
text-align: right;
display: none;
}
.wp-color-result {
width: 60px;
height: 26px;
padding: 0;
border: none;
margin: 0;
box-shadow: inset 0 0 0 3px white;
border: 1px solid #d5dadf;
&:focus {
border: 1px solid #9ba7b3;
outline: none;
}
&:after {
display: none;
}
}
.wp-picker-input-wrap {
margin: 1px 0;
}
&.wp-picker-active {
.wp-color-result {
margin-right: 6px;
}
}
.iris-picker {
position: absolute;
z-index: 999;
}
}
}

View File

@@ -0,0 +1,105 @@
.cx-ui-container{
margin: 10px 0 20px 0;
}
label.cx-label{
margin: 0 0 5px 0;
display: block;
}
.cx-ui-dimensions {
max-width: 300px;
&__units {
margin-right: 20%;
display: flex;
justify-content: flex-end;
}
&__unit {
color: #c2cbd2;
cursor: pointer;
font-size: 9px;
text-transform: uppercase;
margin: 0 2px;
&.is-active {
color: #6d7882;
text-decoration: underline;
}
}
&__values {
display: flex;
border: 1px solid #a4afb7;
border-radius: 3px;
}
&__value-item {
position: relative;
width: 20%;
input {
width: 100%;
margin: 0;
border: none;
box-shadow: none;
border-right: 1px solid #a4afb7;
font-size: 12px;
&:first-child {
border-radius: 3px 0 0 3px;
}
&:focus {
border-color: none;
}
}
}
&__value-label {
width: 100%;
display: block;
position: absolute;
bottom: -18px;
font-size: 9px;
text-transform: uppercase;
text-align: center;
color: #d5dadf;
}
&__is-linked {
width: 20%;
height: 28px;
background-color: white;
text-align: center;
color: #a4afb7;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
border-radius: 0 3px 3px 0;
.link-icon {
display: none;
}
.unlink-icon {
display: block;
}
&.is-linked {
color: white;
background-color: #a4afb7;
.link-icon {
display: block;
}
.unlink-icon {
display: none;
}
}
}
}

View File

@@ -0,0 +1,325 @@
.cx-ui-iconpicker-group {
position: relative;
.full &{
max-width: 100%;
}
.fixed &{
max-width: 150px;
}
.input-group-addon {
position: absolute;
width: 20px;
height: 20px;
left: 0px;
top: 0px;
background: $grey_color_3;
font-size: 14px;
line-height: 20px;
text-align: center;
border-radius: 3px 0 0 3px;
border-right: 1px solid #dddcdc;
margin: 3px;
.fa {
line-height: 20px;
}
}
.cx-ui-text{
@include input();
padding: 0px 0px 0px 30px;
}
}
.iconpicker-popover.popover {
position: absolute;
top: 0;
left: 0;
display: none;
max-width: none;
padding: 1px;
text-align: left;
width: 242px;
background: #f0f0f0;
z-index: 999;
}
.iconpicker-popover.popover.top,
.iconpicker-popover.popover.topLeftCorner,
.iconpicker-popover.popover.topLeft,
.iconpicker-popover.popover.topRight,
.iconpicker-popover.popover.topRightCorner {
margin-top: -10px;
}
.iconpicker-popover.popover.right,
.iconpicker-popover.popover.rightTop,
.iconpicker-popover.popover.rightBottom {
margin-left: 10px;
}
.iconpicker-popover.popover.bottom,
.iconpicker-popover.popover.bottomRightCorner,
.iconpicker-popover.popover.bottomRight,
.iconpicker-popover.popover.bottomLeft,
.iconpicker-popover.popover.bottomLeftCorner {
margin-top: 10px;
}
.iconpicker-popover.popover.left,
.iconpicker-popover.popover.leftBottom,
.iconpicker-popover.popover.leftTop {
margin-left: -10px;
}
.iconpicker-popover.popover.inline {
margin: 0 0 14px 0;
position: relative;
display: inline-block;
opacity: 1;
top: auto;
left: auto;
bottom: auto;
right: auto;
max-width: 100%;
box-shadow: none;
z-index: auto;
vertical-align: top;
}
.iconpicker-popover.popover.inline > .arrow {
display: none;
}
.dropdown-menu .iconpicker-popover.inline {
margin: 0;
border: none;
}
.dropdown-menu.iconpicker-container {
padding: 0;
}
.iconpicker-popover.popover .popover-title {
padding: 14px;
font-size: 14px;
line-height: 16px;
border-bottom: 1px solid #ebebeb;
background-color: #f0f0f0;
}
.iconpicker-popover.popover .popover-title input[type=search].iconpicker-search {
margin: 0 0 2px 0;
}
.iconpicker-popover.popover .popover-title-text ~ input[type=search].iconpicker-search {
margin-top: 14px;
}
.iconpicker-popover.popover .popover-content {
padding: 0px;
text-align: center;
}
.iconpicker-popover .popover-footer {
float: none;
clear: both;
padding: 14px;
text-align: right;
margin: 0;
border-top: 1px solid #ebebeb;
background-color: #f0f0f0;
}
.iconpicker-popover .popover-footer:before,
.iconpicker-popover .popover-footer:after {
content: " ";
display: table;
}
.iconpicker-popover .popover-footer:after {
clear: both;
}
.iconpicker-popover .popover-footer .iconpicker-btn {
margin-left: 10px;
}
.iconpicker-popover .popover-footer input[type=search].iconpicker-search {
margin-bottom: 14px;
}
.iconpicker-popover.popover > .arrow,
.iconpicker-popover.popover > .arrow:after {
position: absolute;
display: block;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
}
.iconpicker-popover.popover > .arrow {
border-width: 11px;
}
.iconpicker-popover.popover > .arrow:after {
border-width: 10px;
content: "";
}
.iconpicker-popover.popover.top > .arrow,
.iconpicker-popover.popover.topLeft > .arrow,
.iconpicker-popover.popover.topRight > .arrow {
left: 50%;
margin-left: -11px;
border-bottom-width: 0;
border-top-color: #f0f0f0;
bottom: -11px;
}
.iconpicker-popover.popover.top > .arrow:after,
.iconpicker-popover.popover.topLeft > .arrow:after,
.iconpicker-popover.popover.topRight > .arrow:after {
content: " ";
bottom: 1px;
margin-left: -10px;
border-bottom-width: 0;
border-top-color: #ffffff;
}
.iconpicker-popover.popover.topLeft > .arrow {
left: 14px;
margin-left: 0;
}
.iconpicker-popover.popover.topRight > .arrow {
left: auto;
right: 14px;
margin-left: 0;
}
.iconpicker-popover.popover.right > .arrow,
.iconpicker-popover.popover.rightTop > .arrow,
.iconpicker-popover.popover.rightBottom > .arrow {
top: 50%;
left: -11px;
margin-top: -11px;
border-left-width: 0;
border-right-color: #f0f0f0;
}
.iconpicker-popover.popover.right > .arrow:after,
.iconpicker-popover.popover.rightTop > .arrow:after,
.iconpicker-popover.popover.rightBottom > .arrow:after {
content: " ";
left: 1px;
bottom: -10px;
border-left-width: 0;
border-right-color: #ffffff;
}
.iconpicker-popover.popover.rightTop > .arrow {
top: auto;
bottom: 14px;
margin-top: 0;
}
.iconpicker-popover.popover.rightBottom > .arrow {
top: 14px;
margin-top: 0;
}
.iconpicker-popover.popover.bottom > .arrow,
.iconpicker-popover.popover.bottomRight > .arrow,
.iconpicker-popover.popover.bottomLeft > .arrow {
left: 50%;
margin-left: -11px;
border-top-width: 0;
border-bottom-color: #f0f0f0;
top: -11px;
}
.iconpicker-popover.popover.bottom > .arrow:after,
.iconpicker-popover.popover.bottomRight > .arrow:after,
.iconpicker-popover.popover.bottomLeft > .arrow:after {
content: " ";
top: 1px;
margin-left: -10px;
border-top-width: 0;
border-bottom-color: #f0f0f0;
}
.iconpicker-popover.popover.bottomLeft > .arrow {
left: 14px;
margin-left: 0;
}
.iconpicker-popover.popover.bottomRight > .arrow {
left: auto;
right: 14px;
margin-left: 0;
}
.iconpicker-popover.popover.left > .arrow,
.iconpicker-popover.popover.leftBottom > .arrow,
.iconpicker-popover.popover.leftTop > .arrow {
top: 50%;
right: -11px;
margin-top: -11px;
border-right-width: 0;
border-left-color: #f0f0f0;
}
.iconpicker-popover.popover.left > .arrow:after,
.iconpicker-popover.popover.leftBottom > .arrow:after,
.iconpicker-popover.popover.leftTop > .arrow:after {
content: " ";
right: 1px;
border-right-width: 0;
border-left-color: #ffffff;
bottom: -10px;
}
.iconpicker-popover.popover.leftBottom > .arrow {
top: 14px;
margin-top: 0;
}
.iconpicker-popover.popover.leftTop > .arrow {
top: auto;
bottom: 14px;
margin-top: 0;
}
.iconpicker {
position: relative;
text-align: left;
text-shadow: none;
line-height: 0;
display: block;
margin: 0;
overflow: hidden;
}
.iconpicker * {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
position: relative;
}
.iconpicker:before,
.iconpicker:after {
content: " ";
display: table;
}
.iconpicker:after {
clear: both;
}
.iconpicker .iconpicker-items {
position: relative;
clear: both;
float: none;
padding: 10px 0 0 10px;
background: #fff;
margin: 0;
overflow: hidden;
overflow-y: auto;
min-height: 55px;
max-height: 275px;
}
.iconpicker .iconpicker-items:before,
.iconpicker .iconpicker-items:after {
content: " ";
display: table;
}
.iconpicker .iconpicker-items:after {
clear: both;
}
.iconpicker .iconpicker-item {
float: left;
width: 28px;
height: 28px;
line-height: 28px;
margin: 0 7px 7px 0;
text-align: center;
cursor: pointer;
border-radius: 3px;
font-size: 18px;
color: #444;
box-shadow: 0 0 0 1px #dddddd;
.fa {
line-height: 28px;
}
}
.iconpicker .iconpicker-item:hover:not(.iconpicker-selected) {
background-color: #eeeeee;
}
.iconpicker .iconpicker-item.iconpicker-selected {
box-shadow: none;
background: #ddd;
}
.iconpicker-component {
cursor: pointer;
}

View File

@@ -0,0 +1,141 @@
.cx-ui-media-wrap {
.cx-upload-preview {
display: block;
margin: 0 0 5px 0;
.cx-image-wrap {
position: relative;
display: inline-block;
vertical-align: top;
width: 128px;
height: 128px;
.inner {
width: 110px;
height: 110px;
margin: 3px;
position: relative;
border: 1px solid #d5dadf;
padding: 5px;
overflow: hidden;
.preview-holder {
width: 100%;
height: 100%;
position: relative;
background: $bg_color;
box-sizing: border-box;
.centered {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
transform: translate(50%,50%);
}
img {
max-width: 100%;
height: auto;
transform: translate(-50%,-50%);
}
span {
width: auto;
height: auto;
font-size: 60px;
transform: translate(-50%,-50%);
}
}
.title {
position: absolute;
display: none;
width: 100px;
padding: 5px;
margin: 5px;
bottom: 0;
left: 0;
color: #fff;
background: #a4afb7;
text-align: center;
font-size: 11px;
overflow: hidden;
}
}
&:hover {
.inner {
border-color: #d5dadf;
}
.title {
display: block;
}
.cx-remove-image {
display: block;
}
}
}
.cx-media-thumb-sortable-placeholder {
width: 120px;
height: 120px;
margin: 3px;
vertical-align: top;
border: 1px dashed $border_color;
display: inline-block;
background-color: $bg_color;
}
}
.upload-button {
float: left;
}
.cx-remove-image {
width: 25px;
height: 25px;
color: $remove_color;
display: block;
position: absolute;
top: 5px;
right: 5px;
cursor: pointer;
text-decoration: none;
outline: 0;
display: none;
i {
width: 25px;
height: 25px;
font-size: 25px;
}
&:hover {
color: darken( $remove_color, 10% );
}
}
.cx-bgsetting {
float: left;
width: 32%;
margin-right: 1%;
&:nth-child(3n+1) {
width: 34%;
margin-right: 0;
}
select {
margin-bottom: 10px;
}
}
}
.button-default_ {
@include button_base();
@include secondary_button();
}

View File

@@ -0,0 +1,91 @@
input.cx-radio-input{
display: none;
}
.cx-radio-item{
margin-bottom: 10px;
&:last-child{
margin-bottom: 0;
}
label {
display: inline-block;
font-size: 12px;
line-height: 14px;
color: $dark_color_1;
}
span.cx-radio-item {
width: 16px;
height: 16px;
border-radius: 25px;
margin-right: 10px;
cursor: pointer;
position: relative;
background-color: white;
display: inline-block;
float: left;
box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.2);
i {
width: 8px;
height: 8px;
background-color: #495159;
margin: 4px;
border-radius: 20px;
display: inline-block;
transform: scale(0);
transition: all 0.4s cubic-bezier(0.77, 0, 0.175, 1);
}
}
}
.cx-radio-item {
.cx-radio-input:checked{
& + label{
span{
i{
transform: scale(1);
}
}
}
}
}
.cx-radio-img {
float: left;
margin: 10px 5px 0 5px;
text-align: center;
max-width: 60px;
font-size: 12px;
position: relative;
.cx-lable-content {
display: flex;
flex-flow: column;
}
label{
display: inline-block;
}
img {
width: 100%;
height: auto;
margin: 0 0 5px 0;
pointer-events: none;
}
}
.cx-radio-img{
.cx-radio-input:checked{
& + label{
font-weight: bold;
.check{
display: block;
}
img{
box-shadow: 0 0 0 2px rgba(255, 254, 255, 1), 0 0 0 5px #49c66a;
}
}
}
}

View File

@@ -0,0 +1,140 @@
.cx-ui-repeater-container {
label.cx-label{
margin: 0 0 5px 0;
display: block;
}
}
.cx-ui-repeater {
&-add {
@include link();
@include link_icon_before( '\f132' );
}
&-item {
padding: 10px 10px 10px 30px;
position: relative;
}
&-remove {
position: absolute;
width: 20px;
height: 20px;
right: 18px;
top: 13px;
border-radius: 50%;
border: 1px solid currentColor;
color: red;
font-size: 18px;
line-height: 20px;
text-align: center;
cursor: pointer;
&:before {
content: "\00D7";
}
&:hover {
color: black;
}
}
}
.cx-ui-kit {
&.cx-ui-repeater-container {
@include container();
}
> label.cx-label {
@include container_heading();
}
.cx-ui-repeater {
&-item {
@include box();
}
&-actions-box {
@include box_heading();
padding: 15px 20px;
cursor: move;
position: relative;
text-align: center;
min-height: 18px;
}
&-toggle {
position: absolute;
color: $grey_color_4;
width: 20px;
height: 20px;
font-size: 22px;
line-height: 20px;
text-align: center;
vertical-align: middle;
cursor: pointer;
text-decoration: none;
box-shadow: none;
outline: none;
top: 13px;
left: 18px;
&:before {
content: "\f142";
transition: all 200ms linear;
font-family: dashicons;
vertical-align: middle;
}
&:hover {
color: $dark_color_1;
}
}
&-remove {
position: absolute;
border: none;
color: $grey_color_4;
font-size: 20px;
line-height: 20px;
width: 20px;
height: 20px;
text-align: center;
vertical-align: middle;
text-decoration: none;
box-shadow: none;
outline: none;
top: 13px;
right: 18px;
&:before {
content: "\f158";
transition: all 200ms linear;
font-family: dashicons;
vertical-align: middle;
}
&:hover {
color: $dark_color_1;
}
}
&-title{
width: 70%;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
font-size: 14px;
}
&-add {
&:focus {
outline: none;
box-shadow: none;
}
}
}
.cx-ui-repeater-min {
padding-bottom: 0;
> .cheryr-ui-repeater-content-box {
display: none;
}
> .cx-ui-repeater-actions-box {
margin-bottom: 0;
border-bottom: none;
background: none;
.cx-ui-repeater-toggle {
&:before {
content: "\f140";
}
}
}
}
}

View File

@@ -0,0 +1,134 @@
select.cx-ui-select{
width: 100%;
outline: 0 none;
@include input();
&:focus{
box-shadow: none;
}
}
select.select2-hidden-accessible{
display: none;
}
.cx-ui-select-wrapper {
.select2{
color: $dark_color;
background-color: white;
border-radius: $border_radius_extra_small;
border: 1px solid $border_color;
.selection{
.select2-selection{
&.select2-selection--single{
background-color: transparent;
border: none;
border-radius: $border_radius_extra_small;
height: 28px;
.select2-selection__rendered{
padding: 5px;
font-size: 12px;
line-height: 18px;
}
.select2-selection__arrow{
height: 24px;
}
}
&.select2-selection--multiple{
background-color: transparent;
border: none;
border-radius: $border_radius_extra_small;
min-height: 25px;
.select2-selection__rendered{
font-size: 12px;
line-height: 14px;
padding: 0;
display: block;
&:focus {
outline: none;
}
.select2-selection__choice{
line-height: 14px;
margin: 2px;
border: none;
background-color: #e4e4e4;
border-radius: $border_radius_extra_small;
color: darken( $dark_color, 50% );
padding: 4px;
.select2-selection__choice__remove{
color: $remove_color;
margin-right: 5px;
font-size: 14px;
}
}
.select2-selection__clear{
}
.select2-search{
margin: 0;
.select2-search__field{
padding: 0;
border: none;
box-shadow: none;
line-height: 19px;
}
}
}
}
}
}
}
.select2-container{
.select2-dropdown{
background-color: white;
border: 1px solid $border_color;
border-radius: $border_radius_extra_small;
box-shadow: 0px 5px 21px rgba(0,0,0,0.1);
margin-top: 1px;
z-index: 500001;
.select2-search__field{
border: 1px solid $border_color;
box-shadow: none;
border-radius: $border_radius_extra_small;
margin: 0;
height: 25px;
&:focus{
outline: none;
}
}
.select2-results {
.select2-results__options{
.select2-results__option{
&[aria-selected=true]{
color: darken( $dark_color, 50% );
background-color: $dark_color;
}
&--highlighted{
color: #fff;
background-color: $primary_color;
}
}
.li[aria-disabled=true]{
display: none;
}
}
}
}
}
}

View File

@@ -0,0 +1,106 @@
.cx-slider-wrap{
display: flex;
flex-wrap: wrap;
.cx-slider-input{
flex: 0 1 10%;
min-width: 100px;
max-width: 200px;
}
.cx-slider-holder{
flex: 0 1 90%;
min-width: 200px;
max-width: 300px;
margin-right: 10px;
input[type=range] {
-webkit-appearance: none;
width: 100%;
margin: 10px 0;
}
input[type=range]:focus {
outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 5px;
cursor: pointer;
box-shadow: none;
background: #a4afb7;
border-radius: 25px;
border: none;
}
input[type=range]::-webkit-slider-thumb {
box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.3);
height: 16px;
width: 16px;
margin-top: -6px;
border-radius: 15px;
background: white;
cursor: pointer;
-webkit-appearance: none;
transition: all 250ms cubic-bezier(0.645, 0.045, 0.355, 1);
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #a4afb7;
}
input[type=range]::-moz-range-track {
width: 100%;
height: 5px;
cursor: pointer;
box-shadow: none;
background: #a4afb7;
border-radius: 25px;
border: none;
}
input[type=range]::-moz-range-thumb {
box-shadow: none;
border: none;
height: 16px;
width: 16px;
border-radius: 15px;
background: #a4afb7;
cursor: pointer;
}
input[type=range]::-ms-track {
width: 100%;
height: 10px;
cursor: pointer;
background: $grey_color_3;
border-color: transparent;
color: transparent;
}
input[type=range]::-ms-fill-lower {
background: $grey_color_3;
border: none;
border-radius: 50px;
box-shadow: none;
}
input[type=range]::-ms-fill-upper {
background: $green_color;
border: none;
border-radius: 50px;
box-shadow: none;
}
input[type=range]::-ms-thumb {
box-shadow: none;
border: none;
height: 10px;
width: 10px;
border-radius: 15px;
background: #495159;
cursor: pointer;
}
input[type=range]:focus::-ms-fill-lower {
background: $grey_color_3;
}
input[type=range]:focus::-ms-fill-upper {
background: $green_color;
}
}
.cx-input{
margin: 0;
width: 100%;
}
}

View File

@@ -0,0 +1,13 @@
.cx-ui-stepper{
position: relative;
max-width: 100px;
input[type=number]{
@include input();
}
}
.cx-ui-stepper-input{
min-width: 70px;
max-width: 70px;
text-align: left;
}

View File

@@ -0,0 +1,110 @@
.cx-switcher-wrap {
width: 54px;
height: 20px;
position: relative;
cursor: pointer;
user-select: none;
background-color: white;
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
transform: translateZ(0);
.bg-cover {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #eceeef;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 0 2px rgba(0, 0, 0, 0.15);
pointer-events: none;
border-radius: 25px;
content: '';
z-index: 1;
transition: all 0.4s ease;
transform: translateZ(0);
}
label {
display: block;
z-index: 2;
span {
font-size: 7px;
line-height: 12px;
text-transform: uppercase;
color: #a4afb7;
text-align: center;
display: block;
opacity: 1;
transition: all 0.4s ease;
}
}
.sw-enable {
padding: 4px 4px 5px 12px;
span {
opacity: 0;
}
}
.sw-disable {
padding: 4px 12px 5px 4px;
span {
opacity: 1;
}
}
.state-marker {
background-color: white;
display: block;
position: absolute;
width: 18px;
height: 18px;
margin: 1px;
top: 0;
left: 0;
border-radius: 50%;
transition: all 0.4s cubic-bezier(0.77, 0, 0.175, 1);
box-sizing: border-box;
z-index: 3;
}
.cx-input-switcher {
display: none;
}
.cx-input-switcher-true:checked {
~ .sw-enable{
span{
opacity: 1;
color: white;
text-shadow: 0 1px rgba(0, 0, 0, 0.2);
}
}
~ .sw-disable{
span{
opacity: 0;
}
}
~ .state-marker {
left: 100%;
margin-left: -19px;
}
~ .bg-cover {
background-color: #49c66a;
}
}
}

View File

@@ -0,0 +1,3 @@
input.cx-ui-text{
@include input();
}

View File

@@ -0,0 +1,5 @@
textarea.cx-ui-textarea{
width: 100%;
@include input();
height: 100px;
}

View File

@@ -0,0 +1,548 @@
$color-1: #fff; // Background color.
$widget-bg: #495159; // Background color in widgets.
$color-2: #efefef; // Background color.
$color-3: #96989a; // Description color and tabs button text color.
$color-4: #b4b7ba; //
$color-5: #f1f1f1; // Scrollbar background
$color-6: #e5e5e5; // Hover scrollbar background
$color-7: #206ff4; // Scrollbar track background
$link-color: #298ffc; // link color.
$link-hover-color: #23282d; // link hover color.
$shadow: 0px 5px 21px rgba(0, 0, 0, 0.1); //Shadow.
$border: 1px solid rgba(0, 0, 0, 0.1) ;
$br-radius: 5px; // Border radius.
$padding: 5px;
$margin: 10px;
$max-height: 700px;
@import "components/use-in-js";
@import "components/variables";
@import "components/mixins";
@import "controls/button";
@import "controls/checkbox";
@import "controls/colorpicker";
@import "controls/iconpicker";
@import "controls/media";
@import "controls/radio";
@import "controls/repeater";
@import "controls/select";
@import "controls/slider";
@import "controls/stepper";
@import "controls/switcher";
@import "controls/text";
@import "controls/textarea";
@import "controls/dimensions";
.cherry-ui-container{
margin: 10px 0 20px 0
}
label.cherry-label{
margin: 0 0 5px 0;
display: block;
}
.hide{
display: none !important;
}
.cx-ui-kit{
font-size: 13px;
h1{
font-weight: 700;
line-height: 1.2em;
margin: 0;
.dashicons{
font-size: 3em;
line-height: inherit;
width: 20px;
margin: 0 $margin * 2 0 $margin * -0.5;
}
}
h2{
font-weight: 600;
font-size: 1.538em;
line-height: 1.538em;
.dashicons{
font-size: 2em;
line-height: inherit;
width: 20px;
margin-right: $margin * 2;
}
}
h3{
font-weight: 600;
font-size: 1.231em;
line-height: 1.231em;
.dashicons{
font-size: 1.7em;
line-height: inherit;
margin-right: $margin * 0.5;
}
}
h4{
font-weight: 500;
font-size: 1.077em;
line-height: 1.077em;
}
h5{
font-weight: 500;
font-size: 1.077em;
line-height: 1.077em;
}
h6{
font-weight: 400;
font-size: 1em;
line-height: 1em;
}
a{
color: $link-color;
text-decoration: none;
&:hover{
color: $link-hover-color;
}
&:focus{
outline: 1px solid rgba(41, 143, 252, .6);
box-shadow: 0px 0px 2px rgba(41,143,252,0.6);
}
}
&__description{
font-size: 0.9em;
color: $color-3;
margin: $margin 0;
}
&__title{
margin: $margin*2 0;
}
&.hide{
display: none;
}
}
.cx-control + .cx-control, .cx-settings + .cx-control{
border-top: $border;
}
.cx-section{
padding: $padding;
background-color: $color-1;
margin-left: -10px;
&__title, &__description{
margin: $margin 0 0 0;
}
& + .cx-ui-kit {
border-top: $border;
}
@media ( min-width: 783px ) {
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
padding: $padding * 1.5;
margin: $margin * 1.5 $margin * 1.5 0 0;
&__holder{
background-color: $color-2;
border-radius: $br-radius;
padding: $padding * 1.5;
}
&__inner{
}
&__info{
background-color: $color-1;
border-radius: $br-radius;
padding: $padding * 1.5;
box-shadow: $shadow;
margin-bottom: $padding * 1.5;
}
.cx-settings{
box-shadow: $shadow;
border-radius: $br-radius;
border: $border;
background-color: $color-1;
margin-top: $padding * 1.5;
&:first-child{
margin-top: 0;
}
}
}
@media ( min-width: 961px ) {
padding: $padding * 3;
margin: $margin * 2 $margin * 2 0 0;
&__info{
padding: $padding * 3;
margin-bottom: $padding * 3;
}
&__holder{
padding: $padding * 3;
}
.cx-settings{
margin-top: $padding * 3;
}
}
}
.cx-component{
padding: $padding * 2 0;
@media ( min-width: 783px ) {
padding: $padding * 1.5;
}
@media ( min-width: 961px ) {
padding: $padding * 3;
}
& + * {
border-top: $border;
}
&__title{
margin-top: 0;
}
& &__content{
.cx-settings{
padding: 0;
border-top: none;
}
}
&__button{
display: block;
min-height: 45px;
.cx-ui-kit__title {
color: inherit;
}
&.active, &:hover{
color: $link-color;
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
&:focus{
outline: none;
box-shadow: inset 0px 0px 10px rgba(41,143,252,0.5);
transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
transition: all 300ms cubic-bezier(0.55, 0.055, 0.675, 0.19);
}
&.cx-accordion, &.cx-toggle{
.cx-component__button{
width: 100%;
padding: $padding * 1.5 $padding * 2;
border:0;
background: none;
cursor: pointer;
position: relative;
.widget &{
background-color: $widget-bg;
color: $color-1;
}
.cx-toggle__title {
font-weight: 700;
font-size: 14px;
float: left;
margin: 0;
}
>span[class*="icon"]{
position: absolute;
top: 50%;
right: 5px;
margin-top: -10px;
font-size: 25px;
color: $color-4;
padding: 5px 5px;
width: 10px;
height: 9px;
text-align: left;
overflow: hidden;
.widget &{
color: $color-1;
}
&.hide-icon{
&:before{
position: relative;
top: -8px;
left: -9px;
}
transform:scaleX(1);
transition: all 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
&.show-icon{
&:before{
position: relative;
top: -7px;
left: -9px;
}
transform:scaleX(0);
transition: all 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
}
&.active{
>span[class*="icon"]{
&.show-icon{
transform:scaleX(1);
transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
&.hide-icon{
transform:scaleX(0);
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
}
}
}
.cx-component__button + .cx-settings__content{
border-top: $border;
}
> .cx-ui-kit__content{
& > .cx-settings + .cx-settings{
margin-top: $margin;
}
> .cx-settings{
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
.widget &{
box-shadow:none;
border-radius: 0;
border-left: 0;
border-right: 0;
}
}
}
}
&.cx-tab{
.cx-tab__tabs{
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
align-items: flex-start;
align-content: flex-start;
border-bottom: $border;
.cx-component__button{
order: 0;
flex: 0 1 100%;
align-self: auto;
padding: $padding * 1.5 $padding * 2;
border: 0;
background: none;
cursor: pointer;
&.active{
-ms-box-shadow: inset 0px -3px 0px 0px $link-color;
box-shadow: inset 0px -3px 0px 0px $link-color;
}
.cx-tab__title {
font-weight: 700;
font-size: 14px;
float: left;
margin: 0;
}
& + button{
border-top: $border;
}
}
}
.cx-tab__body{
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
background-color: $color-1;
.cx-settings{
box-shadow: none;
border-radius: 0;
border: none;
background-color: inherit;
margin: 0;
}
}
@media ( min-width: 783px ) {
.cx-tab__tabs{
border: solid 1px rgba(0,0,0,0.1);
.cx-component__button{
& + button{
border-top: none;
}
}
}
.cx-tab__body{
border: none;
.cx-tab__content{
border: $border;
}
}
&--horizontal{
>.cx-tab__body{
border-radius: none;
>.cx-tab__tabs{
flex-wrap: nowrap;
flex-direction: row;
border-radius:$br-radius $br-radius 0 0;
border-bottom: none;
.cx-component__button{
flex: 0 1 auto;
}
}
>.cx-tab__content{
border-radius: 0 0 $br-radius $br-radius;
}
}
}
&--vertical{
>.cx-tab__body{
display: flex;
border-radius: none;
>.cx-tab__tabs{
flex-direction: row;
-webkit-box-flex: 0;
flex: 0 1 20%;
border-radius:$br-radius 0 0 $br-radius;
border-right: none;
.cx-component__button{
text-align: right;
.cx-tab__title {
width: 100%;
}
&.active{
box-shadow: inset -3px 0px 0px $link-color;
}
}
}
>.cx-tab__content{
-webkit-box-flex: 0;
flex: 0 1 80%;
border-radius: 0 $br-radius $br-radius 0;
}
}
}
}
@media ( min-width: 1200px ) {
&--vertical{
.cx-tab__tabs{
flex: 0 1 20%;
}
.cx-tab__content{
flex: 0 1 80%;
}
}
}
}
.widget &{
padding: 0;
&__content{
margin: 0 $margin * -1.5 $margin * 2;
.cx-control{
padding: $padding * 1.5 $padding * 2;
}
}
}
}
.cx-settings{
& + & {
border-top: $border;
}
& &__title{
margin-bottom: $margin;
}
&__description, & &__title{
margin-left: $margin;
@media ( min-width: 783px ) {
margin-left: $margin * 1.5;
}
@media ( min-width: 961px ) {
margin-left: $margin * 3;
}
}
}
.cx-control {
padding: $padding * 1.5 $padding * 2;
&__title{
margin: 0 0 $margin 0 ;
}
&__description{
margin-top: 0;
}
.cx-ui-container {
margin: 0;
}
@media (min-width: 783px) {
padding: $padding * 1.5;
display: flex;
flex-flow: row nowrap;
&__info{
-webkit-box-flex: 0;
flex: 0 1 30%;
padding-right: $padding * 1.5;
}
&__content{
-webkit-box-flex: 0;
flex: 0 1 70%;
}
}
@media ( min-width: 961px ) {
padding: $padding * 3;
}
.widget & {
padding: $padding * 1.5 0;
flex-direction: column;
&__content{
-webkit-box-flex: 0;
flex: 0 1 100%;
}
&__info{
-webkit-box-flex: 0;
flex: 0 1 100%;
padding-right: 0;
}
}
&-hidden {
display: none;
}
}
.cx-section.cx-scroll > .cx-section__holder > .cx-section__inner,
.cx-tab__content > .cx-scroll,
.cx-accordion__content > .cx-scroll > .cx-settings__content,
.cx-toggle__content > .cx-scroll > .cx-settings__content {
@media ( min-width: 783px ) {
max-height: $max-height;
overflow-y: auto;
position: relative;
&::-webkit-scrollbar {
width: 10px;
height: 10px;
&-button {
width: 0px;
height: 0px;
}
&-thumb {
background-color: $link-color;
border: none;
border-radius: $br-radius;
&:hover, &:active {
background: $color-7;
}
}
&-track {
background-color: $color-1;
border: none;
border-radius: $br-radius;
}
&-corner {
background: transparent;
}
}
}
}

View File

@@ -0,0 +1,589 @@
<?php
/**
* Interface Builder module
*
* Version: 1.1.1
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Interface_Builder' ) ) {
/**
* Class Cherry Interface Builder.
*
* @since 1.0.0
*/
class CX_Interface_Builder {
/**
* Module directory path.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
protected $path;
/**
* Module directory URL.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
protected $url;
/**
* Module version
*
* @var string
*/
protected $version = '1.1.1';
/**
* Conditions
*
* @var array
*/
public $conditions = array();
/**
* [$conditions description]
* @var array
*/
public $fields_value = array();
/**
* Module settings.
*
* @since 1.0.0
* @access private
* @var array
*/
private $args = array(
'path' => '',
'url' => '',
'views' => array(
'section' => 'views/section.php',
'component-tab-vertical' => 'views/component-tab-vertical.php',
'component-tab-horizontal' => 'views/component-tab-horizontal.php',
'component-toggle' => 'views/component-toggle.php',
'component-accordion' => 'views/component-accordion.php',
'component-repeater' => 'views/component-repeater.php',
'settings' => 'views/settings.php',
'control' => 'views/control.php',
'settings-children-title' => 'views/settings-children-title.php',
'tab-children-title' => 'views/tab-children-title.php',
'toggle-children-title' => 'views/toggle-children-title.php',
'form' => 'views/form.php',
'html' => 'views/html.php',
),
'views_args' => array(
'parent' => '',
'type' => '',
'view' => '',
'view_wrapping' => true,
'html' => '',
'scroll' => false,
'title' => '',
'description' => '',
'condition' => array(),
),
);
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @access private
* @var object
*/
private static $instance = null;
/**
* UI element instance.
*
* @since 1.0.0
* @access public
* @var object
*/
public $controls = null;
/**
* The structure of the interface elements.
*
* @since 1.0.0
* @access private
* @var array
*/
private $structure = array();
/**
* Dependencies array
* @var array
*/
private $deps = array(
'css' => array(),
'js' => array( 'jquery' ),
);
/**
* Cherry_Interface_Builder constructor.
*
* @since 1.0.0
* @access public
* @return void
*/
public function __construct( array $args = array() ) {
$this->path = $args['path'];
$this->url = $args['url'];
$this->args = array_merge(
$this->args,
$args
);
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
require trailingslashit( $this->path ) . 'inc/class-cx-controls-manager.php';
$this->controls = new CX_Controls_Manager( $this->path, $this->url );
}
/**
* Register element type section.
*
* @since 1.0.0
* @access public
* @param array $args Options section.
* @return void
*/
public function register_section( array $args = array() ) {
$this->add_new_element( $args, 'section' );
}
/**
* Register element type component.
*
* @since 1.0.0
* @access public
* @param array $args Options component.
* @return void
*/
public function register_component( array $args = array() ) {
$this->add_new_element( $args, 'component' );
}
/**
* Register element type settings.
*
* @since 1.0.0
* @access public
* @param array $args Options settings.
* @return void
*/
public function register_settings( array $args = array() ) {
$this->add_new_element( $args, 'settings' );
}
/**
* Register element type control.
*
* @since 1.0.0
* @access public
* @param array $args Options control.
* @return void
*/
public function register_control( array $args = array() ) {
$this->add_new_element( $args, 'control' );
}
/**
* Register element type form.
*
* @since 1.0.0
* @access public
* @param array $args Options form.
* @return void
*/
public function register_form( array $args = array() ) {
$this->add_new_element( $args, 'form' );
}
/**
* Register element type html.
*
* @since 1.0.0
* @access public
* @param array $args Options control.
* @return void
*/
public function register_html( array $args = array() ) {
$this->add_new_element( $args, 'html' );
}
/**
* This function adds a new element to the structure.
*
* @since 1.0.0
* @access protected
* @param array $args Options new element.
* @param string $type Type new element.
* @return void
*/
protected function add_new_element( array $args = array(), $type = 'section' ) {
if ( ! isset( $args[0] ) && ! is_array( current( $args ) ) ) {
if ( 'control' !== $type && 'component' !== $type ) {
$args['type'] = $type;
}
if ( ! isset( $args['name'] ) && isset( $args['id'] ) ) {
$args['name'] = $args['id'];
}
if ( 'control' === $type ) {
$instance = $this->controls->register_control( $args['type'], $args );
$args['instance'] = $instance;
$this->add_dependencies( $instance );
}
if ( array_key_exists( 'conditions', $args ) ) {
$this->conditions[ $args['id'] ] = $args['conditions'];
}
if ( array_key_exists( 'value', $args ) ) {
$this->fields_value[ $args['id'] ] = $args['value'];
}
$this->structure[ $args['id'] ] = $args;
} else {
foreach ( $args as $key => $value ) {
if ( 'control' !== $type && 'component' !== $type ) {
$value['type'] = $type;
}
if ( ! isset( $value['id'] ) ) {
$value['id'] = $key;
}
if ( ! isset( $value['name'] ) ) {
$value['name'] = $key;
}
if ( 'control' === $type ) {
$instance = $this->controls->register_control( $value['type'], $value );
$value['instance'] = $instance;
$this->add_dependencies( $instance );
}
if ( array_key_exists( 'conditions', $value ) ) {
$this->conditions[ $key ] = $value['conditions'];
}
if ( array_key_exists( 'value', $value ) ) {
$this->fields_value[ $key ] = $value['value'];
}
$this->structure[ $key ] = $value;
}
}
}
/**
* Add control dependencies to global builder deps
*
* @param [type] $control [description]
*/
protected function add_dependencies( $control ) {
if ( ! $control instanceof CX_Controls_Base ) {
return;
}
$this->deps['js'] = array_merge( $this->deps['js'], $control->get_script_depends() );
$this->deps['css'] = array_merge( $this->deps['css'], $control->get_style_depends() );
$constrol_settings = $control->get_settings();
if ( 'repeater' === $constrol_settings['type'] && ! empty( $constrol_settings['fields'] ) ) {
foreach ( $constrol_settings['fields'] as $field ) {
$child_instance = $this->controls->register_control( $field['type'], $field );
if ( $child_instance ) {
$this->deps['js'] = array_merge( $this->deps['js'], $child_instance->get_script_depends() );
$this->deps['css'] = array_merge( $this->deps['css'], $child_instance->get_style_depends() );
}
}
}
}
/**
* Sorts the elements of the structure, adding child items to the parent.
*
* @since 1.0.0
* @access protected
* @param array $structure The original structure of the elements.
* @param string $parent_key The key of the parent element.
* @return array
*/
protected function sort_structure( array $structure = array(), $parent_key = null ) {
$new_array = array();
foreach ( $structure as $key => $value ) {
if (
( null === $parent_key && ! isset( $value['parent'] ) )
|| null === $parent_key && ! isset( $structure[ $value['parent'] ] )
|| ( isset( $value['parent'] ) && $value['parent'] === $parent_key )
) {
$new_array[ $key ] = $value;
$children = $this->sort_structure( $structure, $key );
if ( ! empty( $children ) ) {
$new_array[ $key ]['children'] = $children;
}
}
}
return $new_array;
}
/**
* Reset structure array.
* Call this method only after render.
*
* @since 1.0.1
* @return void
*/
public function reset_structure() {
$this->structure = array();
}
/**
* Get view for interface elements.
*
* @since 1.0.0
* @access protected
* @param string $type View type.
* @param array $args Input data.
* @return string
*/
protected function get_view( $type = 'control', array $args = array() ) {
if ( empty( $args['view'] ) ) {
$path = ( array_key_exists( $type, $this->args['views'] ) ) ? $this->args['views'][ $type ] : $this->args['views']['control'];
$path = is_array( $path ) ? $path[0] : $path;
$path = file_exists( $path ) ? $path : $this->path . $path;
} else {
$path = $args['view'];
}
ob_start();
include $path;
return ob_get_clean();
}
/**
* Render HTML elements.
*
* @since 1.0.0
* @access public
* @param bool $echo Input data.
* @param array $args The original structure of the elements.
* @return string
*/
public function render( $echo = true, array $args = array() ) {
if ( empty( $args ) ) {
$args = $this->structure;
}
if ( empty( $args ) ) {
return false;
}
$sorted_structure = $this->sort_structure( $args );
$output = $this->build( $sorted_structure );
$output = str_replace( array( "\r\n", "\r", "\n", "\t" ), '', $output );
$this->reset_structure();
return $this->output_method( $output, $echo );
}
/**
* Render HTML elements.
*
* @since 1.0.0
* @access protected
* @param array $args Input data.
* @return string
*/
protected function build( array $args = array() ) {
$output = '';
$views = $this->args['views'];
foreach ( $args as $key => $value ) {
$value = wp_parse_args(
$value,
$this->args['views_args']
);
$value['class'] = isset( $value['class'] ) ? $value['class'] . ' ' : '';
$value['class'] .= $value['id'] . ' ';
if ( $value['scroll'] ) {
$value['class'] .= 'cx-scroll ';
}
$type = array_key_exists( $value['type'], $views ) ? $value['type'] : 'field';
$has_child = isset( $value['children'] ) && is_array( $value['children'] ) && ! empty( $value['children'] );
switch ( $type ) {
case 'component-tab-vertical':
case 'component-tab-horizontal':
if ( $has_child ) {
$value['tabs'] = '';
foreach ( $value['children'] as $key_children => $value_children ) {
$value['tabs'] .= $this->get_view( 'tab-children-title', $value_children );
unset( $value['children'][ $key_children ]['title'] );
}
}
break;
case 'component-toggle':
case 'component-accordion':
if ( $has_child ) {
foreach ( $value['children'] as $key_children => $value_children ) {
$value['children'][ $key_children ]['title_in_view'] = $this->get_view( 'toggle-children-title', $value_children );
}
}
break;
case 'settings':
if ( isset( $value['title'] ) && $value['title'] ) {
$value['title'] = isset( $value['title_in_view'] ) ? $value['title_in_view'] : $this->get_view( 'settings-children-title', $value );
}
break;
case 'html':
$value['children'] = $value['html'];
break;
case 'form':
$value['accept-charset'] = isset( $value['accept-charset'] ) ? $value['accept-charset'] : 'utf-8';
$value['action'] = isset( $value['action'] ) ? $value['action'] : '' ;
$value['autocomplete'] = isset( $value['autocomplete'] ) ? $value['autocomplete'] : 'on';
$value['enctype'] = isset( $value['enctype'] ) ? $value['enctype'] : 'application/x-www-form-urlencoded';
$value['method'] = isset( $value['method'] ) ? $value['method'] : 'post';
$value['novalidate'] = ( isset( $value['novalidate'] ) && $value['novalidate'] ) ? 'novalidate' : '';
$value['target'] = isset( $value['target'] ) ? $value['target'] : '';
break;
case 'field':
$ui_args = $value;
$ui_args['class'] = isset( $ui_args['child_class'] ) ? $ui_args['child_class'] : '' ;
$control = isset( $ui_args['instance'] ) ? $ui_args['instance'] : false;
if ( $control ) {
$value['children'] = $control->render();
} else {
$value['children'] = 'Control not found';
}
break;
}
if ( $has_child ) {
$value['children'] = $this->build( $value['children'] );
}
$output .= ( $value['view_wrapping'] ) ? $this->get_view( $type, $value ) : $value['children'];
}
return $output;
}
/**
* Output HTML.
*
* @since 1.0.0
* @access protected
* @param string $output Output HTML.
* @param boolean $echo Output type.
* @return string
*/
protected function output_method( $output = '', $echo = true ) {
if ( ! filter_var( $echo, FILTER_VALIDATE_BOOLEAN ) ) {
return $output;
} else {
echo $output;
}
}
/**
* Enqueue javascript and stylesheet interface builder.
*
* @since 4.0.0
* @access public
* @return void
*/
public function enqueue_assets() {
$suffix = '';
if ( defined( 'SCRIPT_DEBUG' ) && false === SCRIPT_DEBUG ) {
$suffix = '.min';
}
$js_deps = array_unique( $this->deps['js'] );
$css_deps = array_unique( $this->deps['css'] );
wp_enqueue_script(
'cx-interface-builder',
$this->url . 'assets/js/cx-interface-builder' . $suffix . '.js',
$js_deps,
$this->version,
true
);
wp_localize_script( 'cx-interface-builder', 'cxInterfaceBuilder',
array(
'conditions' => $this->conditions,
'fields' => $this->fields_value,
)
);
wp_enqueue_style(
'cx-interface-builder',
$this->url . 'assets/css/cx-interface-builder.css',
$css_deps,
$this->version,
'all'
);
}
}
}

View File

@@ -0,0 +1,180 @@
<?php
/**
* Control base class
*/
/**
* CX_Controls_Base abstract class
*/
if ( ! class_exists( 'CX_Controls_Base' ) ) {
/**
* CX_Controls_Base Abstract Class
*
* @since 1.0.0
*/
abstract class CX_Controls_Base {
/**
* Base URL
*
* @var null
*/
public $base_url = null;
/**
* Settings list
*
* @since 1.0.0
* @var array
*/
protected $settings = array();
/**
* Default settings array
*
* @var array
*/
public $defaults_settings = array();
/**
* Constructor method for the CX_Controls_Base class.
*
* @since 1.0.0
*/
public function __construct( $args = array() ) {
$this->defaults_settings['id'] = 'cx-control-' . uniqid();
$this->settings = wp_parse_args( $args, $this->defaults_settings );
$this->init();
add_action( 'wp_enqueue_scripts', array( $this, 'register_depends' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'register_depends' ) );
}
/**
* Returns control settings
*
* @return array
*/
public function get_settings() {
return $this->settings;
}
/**
* Render methos. Each UI element must implement own method
* @return [type] [description]
*/
abstract public function render();
/**
* Optional additional initializtion for control. Can be overriden from child class if needed.
* @return [type] [description]
*/
public function init() {}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array();
}
/**
* Register required dependencies
*
* @return void
*/
public function register_depends() {}
/**
* Retrun styles dependencies list for current control.
*
* @return array
*/
public function get_style_depends() {
return array();
}
/**
* Set up base URL for next usage
*
* @param string $url array
*/
public function set_base_url( $url = '' ) {
$this->base_url = $url;
}
/**
* Get control value
*
* @since 1.0.0
* @return string control value.
*/
public function get_value() {
return $this->settings['value'];
}
/**
* Set control value
*
* @since 1.0.0
* @param [type] $value new.
*/
public function set_value( $value ) {
$this->settings['value'] = $value;
}
/**
* Get control name
*
* @since 1.0.0
* @return string control name.
*/
public function get_name() {
return $this->settings['name'];
}
/**
* Set control name
*
* @since 1.0.0
* @param [type] $name new control name.
* @throws Exception Invalid control name.
*/
public function set_name( $name ) {
$name = (string) $name;
if ( '' !== $name ) {
$this->settings['name'] = $name;
} else {
throw new Exception( "Invalid control name '" . $name . "'. Name can't be empty." );
}
}
/**
* Returns attributes string from attributes array
*
* @return string
*/
public function get_attr_string( $attr = array() ) {
$result = array();
foreach ( $attr as $key => $value ) {
if ( $key === $value ) {
$result[] = $key;
} else {
$result[] = sprintf( '%1$s="%2$s"', $key, $value );
}
}
return implode( ' ', $result );
}
}
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* UI controls manager class
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Controls_Manager' ) ) {
/**
* Define CX_Controls_Manager class
*/
class CX_Controls_Manager {
/**
* Path to controls folder for current Inteface Builder instance
*
* @var string
*/
private $base_path = '';
/**
* Path to controls folder for current Inteface Builder instance
*
* @var string
*/
private $base_url = '';
/**
* Constructor for the class
*/
public function __construct( $base_path = null, $base_url = null ) {
$this->base_path = trailingslashit( $base_path );
$this->base_url = trailingslashit( $base_url );
require $this->base_path . 'inc/class-cx-controls-base.php';
$this->load_controls();
}
/**
* Automatically load found conrols
*
* @return void
*/
public function load_controls() {
foreach ( glob( $this->base_path . 'inc/controls/*.php' ) as $file ) {
require $file;
}
}
/**
* Register new control instance
*
* @return object
*/
public function register_control( $type = 'text', $args = array() ) {
$prefix = 'CX_Control_';
$classname = $prefix . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $type ) ) );
if ( ! class_exists( $classname ) ) {
return false;
}
$instance = new $classname( $args );
$instance->set_base_url( $this->base_url );
return $instance;
}
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* Class for the building ui-button elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Button' ) ) {
/**
* Class for the building ui-button elements.
*/
class CX_Control_Button extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cherry-ui-button-id',
'name' => 'cherry-ui-button-name',
'value' => 'button',
'disabled' => false,
'form' => '',
'formaction' => '',
'button_type' => 'button',
'style' => 'normal',
'content' => 'Button',
'class' => '',
);
/**
* Render html UI_Button.
*
* @since 1.0.0
*/
public function render() {
$classes = array(
'cx-button',
'cx-button-' . $this->settings['style'] . '-style',
$this->settings['class'],
);
$classes = array_filter( $classes );
$class = trim( implode( ' ', $classes ) );
$attrs = array(
'type' => esc_attr( $this->settings['button_type'] ),
'id' => esc_attr( $this->settings['id'] ),
'name' => esc_attr( $this->settings['name'] ),
'class' => esc_attr( $class ),
'form' => esc_attr( $this->settings['form'] ),
'formaction' => esc_attr( $this->settings['formaction'] ),
);
if ( filter_var( $this->settings['disabled'], FILTER_VALIDATE_BOOLEAN ) ) {
$attrs['disabled'] = 'disabled';
}
$html = sprintf(
'<button %1$s>%2$s</button>',
$this->get_attr_string( $attrs ),
$this->settings['content']
);
return $html;
}
}
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Class for the building checkbox elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Checkbox' ) ) {
/**
* Class for the building CX_Control_Checkbox elements.
*/
class CX_Control_Checkbox extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-checkbox-id',
'name' => 'cx-checkbox-name',
'value' => array(
'checkbox-1' => 'true',
'checkbox-2' => 'true',
'checkbox-3' => 'true',
),
'options' => array(
'checkbox-1' => 'checkbox 1',
'checkbox-2' => 'checkbox 2',
'checkbox-3' => 'checkbox 3',
),
'label' => '',
'class' => '',
);
/**
* Render html UI_Checkbox.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-control-container ' . esc_attr( $class ) . '">';
$counter = 0;
if ( isset( $this->settings['options_callback'] ) ) {
$this->settings['options'] = call_user_func( $this->settings['options_callback'] );
}
if ( ! empty( $this->settings['options'] ) && is_array( $this->settings['options'] ) ) {
if ( ! is_array( $this->settings['value'] ) ) {
$this->settings['value'] = array( $this->settings['value'] );
}
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
foreach ( $this->settings['options'] as $option => $option_value ) {
if ( ! empty( $this->settings['value'] ) ) {
$option_checked = array_key_exists( $option, $this->settings['value'] ) ? $option : '';
$item_value = ! empty( $option_checked ) ? $this->settings['value'][ $option ] : 'false';
} else {
$option_checked = '';
$item_value = 'false';
}
$checked = ( ! empty( $option_checked ) && filter_var( $item_value, FILTER_VALIDATE_BOOLEAN ) ) ? 'checked' : '';
$item_value = filter_var( $item_value, FILTER_VALIDATE_BOOLEAN ) ? 'true' : 'false';
$option_label = isset( $option_value ) && is_array( $option_value ) ? $option_value['label'] : $option_value;
$html .= '<div class="cx-checkbox-item-wrap">';
$html .= '<span class="cx-label-content">';
$html .= '<input type="hidden" id="' . esc_attr( $this->settings['id'] ) . '-' . $counter . '" class="cx-checkbox-input" name="' . esc_attr( $this->settings['name'] ) . '[' . $option . ']" ' . $checked . ' value="' . $item_value . '">';
$html .= '<span class="cx-checkbox-item"><span class="marker dashicons dashicons-yes"></span></span>';
$html .= '<label class="cx-checkbox-label" for="' . esc_attr( $this->settings['id'] ) . '-' . $counter . '"><span class="cx-label-content">' . esc_html( $option_label ) . '</span></label> ';
$html .= '</span>';
$html .= '</div>';
$counter++;
}
}
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* Class for the building colorpicker elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Colorpicker' ) ) {
/**
* Class for the building CX_Control_Colorpicker elements.
*/
class CX_Control_Colorpicker extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-colorpicker-id',
'name' => 'cx-colorpicker-name',
'value' => '',
'label' => '',
'class' => '',
);
/**
* Register control dependencies
*
* @return [type] [description]
*/
public function register_depends() {
wp_register_script(
'cx-colorpicker-alpha',
$this->base_url . 'assets/lib/colorpicker/wp-color-picker-alpha.min.js',
array( 'wp-color-picker' ),
'1.0.0',
true
);
}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array( 'cx-colorpicker-alpha' );
}
/**
* Retrun styles dependencies list for current control.
*
* @return array
*/
public function get_style_depends() {
return array( 'wp-color-picker' );
}
/**
* Render html UI_Colorpicker.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<div class="cx-ui-colorpicker-wrapper">';
$html .= '<input type="text" id="' . esc_attr( $this->settings['id'] ) . '" class="cx-ui-colorpicker" name="' . esc_attr( $this->settings['name'] ) . '" value="' . esc_html( $this->settings['value'] ) . '"/>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,200 @@
<?php
/**
* Class for the building dimensions elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Dimensions' ) ) {
/**
* Class for the building ui-dimensions elements.
*/
class CX_Control_Dimensions extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-dimensions-id',
'name' => 'cx-dimensions-name',
'value' => array(),
'range' => array(
'px' => array(
'min' => 0,
'max' => 100,
'step' => 1,
),
),
'dimension_labels' => array(
'top' => 'Top',
'right' => 'Right',
'bottom' => 'Bottom',
'left' => 'Left',
),
'label' => '',
'class' => '',
'required' => false,
);
protected $default_value = array(
'units' => 'px',
'is_linked' => true,
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
);
/**
* Get required attribute.
*
* @since 1.0.0
* @return string
*/
public function get_required() {
if ( $this->settings['required'] ) {
return 'required="required"';
}
return '';
}
/**
* Render html UI_Dimension.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
if ( empty( $this->settings['value'] ) ) {
$this->settings['value'] = $this->default_value;
} else {
$this->settings['value'] = array_merge( $this->default_value, $this->settings['value'] );
}
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= $this->get_fields();
$html .= '</div>';
return $html;
}
/**
* Return UI fileds
* @return [type] [description]
*/
public function get_fields() {
$hidden = '<input type="hidden" name="%1$s" id="%3$s" value="%2$s">';
$number = '<div class="cx-ui-dimensions__value-item"><input type="number" name="%1$s" id="%3$s" value="%2$s" min="%4$s" max="%5$s" step="%6$s" class="cx-ui-dimensions__val%7$s"><span class="cx-ui-dimensions__value-label">%8$s</span></div>';
$value = $this->settings['value'];
$value = array_merge( $this->default_value, $value );
$result = sprintf(
'<div class="cx-ui-dimensions" data-range=\'%s\'>',
json_encode( $this->settings['range'] )
);
foreach ( array( 'units', 'is_linked' ) as $field ) {
$result .= sprintf(
$hidden,
$this->get_name_attr( $field ), $value[ $field ], $this->get_id_attr( $field )
);
}
$result .= $this->get_units();
$result .= '<div class="cx-ui-dimensions__values">';
$value['is_linked'] = filter_var( $value['is_linked'], FILTER_VALIDATE_BOOLEAN );
foreach ( array( 'top', 'right', 'bottom', 'left' ) as $field ) {
$result .= sprintf(
$number,
$this->get_name_attr( $field ),
$value[ $field ],
$this->get_id_attr( $field ),
$this->settings['range'][ $value['units'] ]['min'],
$this->settings['range'][ $value['units'] ]['max'],
$this->settings['range'][ $value['units'] ]['step'],
( true === $value['is_linked'] ? ' is-linked' : '' ),
$this->settings['dimension_labels'][ $field ]
);
}
$result .= sprintf(
'<div class="cx-ui-dimensions__is-linked%s"><span class="dashicons dashicons-admin-links link-icon"></span><span class="dashicons dashicons-editor-unlink unlink-icon"></span></div>',
( true === $value['is_linked'] ? ' is-linked' : '' )
);
$result .= '</div>';
$result .= '</div>';
return $result;
}
/**
* Returns units selector
*
* @return string
*/
public function get_units() {
$units = array_keys( $this->settings['range'] );
$switcher = 'can-switch';
if ( 1 === count( $units ) ) {
$switcher = '';
}
$item = '<span class="cx-ui-dimensions__unit%2$s" data-unit="%1$s">%1$s</span>';
$result = '';
foreach ( $units as $unit ) {
$result .= sprintf(
$item,
$unit,
( $this->settings['value']['units'] === $unit ? ' is-active' : '' )
);
}
return sprintf( '<div class="cx-ui-dimensions__units">%s</div>', $result );
}
/**
* Retrurn full name attibute by name
*
* @param [type] $name [description]
* @return [type] [description]
*/
public function get_name_attr( $name = '' ) {
return sprintf( '%s[%s]', esc_attr( $this->settings['name'] ), esc_attr( $name ) );
}
/**
* Retrurn full ID attibute by name
*
* @param [type] $name [description]
* @return [type] [description]
*/
public function get_id_attr( $name = '' ) {
return sprintf( '%s_%s', esc_attr( $this->settings['name'] ), esc_attr( $name ) );
}
}
}

View File

@@ -0,0 +1,352 @@
<?php
/**
* Class for the building iconpicker elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Iconpicker' ) ) {
/**
* Class for the building ui-iconpicker elements.
*/
class CX_Control_Iconpicker extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'type' => 'iconpicker',
'id' => 'cx-iconpicker-id',
'name' => 'cx-iconpicker-name',
'value' => '',
'placeholder' => '',
'icon_data' => array(),
'auto_parse' => false,
'label' => '',
'class' => '',
'master' => '',
'width' => 'fixed',
'required' => false,
);
/**
* Default icon data settings.
*
* @var array
*/
private $default_icon_data = array(
'icon_set' => '',
'icon_css' => '',
'icon_base' => 'icon',
'icon_prefix' => '',
'icons' => '',
);
/**
* Icons sets
*
* @var array
*/
public static $sets = array();
/**
* Check if sets already printed
*
* @var boolean
*/
public static $printed = false;
/**
* Array of already printed sets to check it before printing current
*
* @var array
*/
public static $printed_sets = array();
/**
* Temporary icons holder
*
* @var null
*/
public $temp_icons = null;
/**
* Init
* @return [type] [description]
*/
public function init() {
add_action( 'admin_footer', array( $this, 'print_icon_set' ), 1 );
add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_icon_set' ), 9999 );
add_filter( 'cx_handler_response_data', array( $this, 'send_icon_set' ), 10, 1 );
}
/**
* Register control dependencies
*
* @return [type] [description]
*/
public function register_depends() {
wp_register_script(
'cx-iconpicker',
$this->base_url . 'assets/lib/iconpicker/jquery-iconpicker.js',
array( 'jquery' ),
'1.0.0',
true
);
}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array( 'cx-iconpicker' );
}
/**
* Get required attribute
*
* @return string required attribute
*/
public function get_required() {
if ( $this->settings['required'] ) {
return 'required="required"';
}
return '';
}
/**
* Render html UI_Iconpicker.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
$this->settings['width'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$this->settings['icon_data'] = wp_parse_args(
$this->settings['icon_data'],
$this->default_icon_data
);
$html .= '<div class="cx-ui-iconpicker-group">';
if ( $this->validate_icon_data( $this->settings['icon_data'] ) ) {
$html .= $this->render_picker();
} else {
$html .= 'Incorrect Icon Data Settings';
}
$html .= '</div>';
$html .= '</div>';
/**
* Maybe add js repeater template to response
*
* @var bool
*/
$add_js_to_response = apply_filters( 'cx_control/add_data_to_element', false );
if ( $add_js_to_response ) {
ob_start();
$this->print_icon_set();
$icons = ob_get_clean();
$in_repeater = apply_filters( 'cx_control/is_repeater', false );
if ( $in_repeater ) {
$this->temp_icons = $icons;
add_filter( 'cx_control/add_repeater_data', array( $this, 'store_icons' ) );
} else {
$html .= $icons;
}
}
return $html;
}
public function store_icons( $data = array() ) {
if ( ! is_array( $data ) ) {
$data = array();
}
$data[] = $this->temp_icons;
return $data;
}
/**
* Returns iconpicker html markup
*
* @return string
*/
private function render_picker() {
$format = '<span class="input-group-addon"></span><input type="text" name="%1$s" id="%2$s" value="%3$s" class="widefat cx-ui-text cx-ui-iconpicker %4$s" data-set="%5$s">';
$this->prepare_icon_set();
return sprintf(
$format,
$this->settings['name'],
$this->settings['id'],
$this->settings['value'],
$this->settings['class'],
$this->settings['icon_data']['icon_set']
);
}
/**
* Return JS markup for icon set variable.
*
* @return void
*/
public function prepare_icon_set() {
if ( empty( $this->settings['icon_data']['icons'] ) ) {
$this->maybe_parse_set_from_css();
}
if ( ! array_key_exists( $this->settings['icon_data']['icon_set'], self::$sets ) ) {
self::$sets[ $this->settings['icon_data']['icon_set'] ] = array(
'iconCSS' => $this->settings['icon_data']['icon_css'],
'iconBase' => $this->settings['icon_data']['icon_base'],
'iconPrefix' => $this->settings['icon_data']['icon_prefix'],
'icons' => $this->settings['icon_data']['icons'],
);
}
}
/**
* Check if 'parse_set' is true and try to get icons set from CSS file
*
* @return void
*/
private function maybe_parse_set_from_css() {
if ( true !== $this->settings['auto_parse'] || empty( $this->settings['icon_data']['icon_css'] ) ) {
return;
}
ob_start();
$path = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $this->settings['icon_data']['icon_css'] );
if ( file_exists( $path ) ) {
include $path;
}
$result = ob_get_clean();
preg_match_all( '/\.([-_a-zA-Z0-9]+):before[, {]/', $result, $matches );
if ( ! is_array( $matches ) || empty( $matches[1] ) ) {
return;
}
if ( is_array( $this->settings['icon_data']['icons'] ) ) {
$this->settings['icon_data']['icons'] = array_merge(
$this->settings['icon_data']['icons'],
$matches[1]
);
} else {
$this->settings['icon_data']['icons'] = $matches[1];
}
}
/**
* Checks if all required icon data fields are passed
*
* @param array $data Icon data.
* @return bool
*/
private function validate_icon_data( $data ) {
$validate = array_diff( $this->default_icon_data, array( 'icon_base', 'icon_prefix' ) );
foreach ( $validate as $key => $field ) {
if ( empty( $data[ $key ] ) ) {
return false;
}
return true;
}
}
/**
* Function sends the icons into ajax response.
*
* @param array $data Icon data.
* @return array
*/
public function send_icon_set( $data ) {
if ( empty( $data['CxIconSets'] ) ) {
$data['CxIconSets'] = array();
}
foreach ( self::$sets as $key => $value ) {
$data['CxIconSets'][ $key ] = $value;
}
return $data;
}
/**
* Print icon sets
*
* @return void
*/
public function print_icon_set() {
if ( empty( self::$sets ) || true === self::$printed ) {
return;
}
self::$printed = true;
foreach ( self::$sets as $set => $data ) {
if ( in_array( $set, self::$printed_sets ) ) {
continue;
}
self::$printed_sets[] = $set;
$json = json_encode( $data );
printf(
'<script> if ( ! window.CxIconSets ) { window.CxIconSets = {} } window.CxIconSets.%1$s = %2$s</script>',
$set,
$json
);
}
}
}
}

View File

@@ -0,0 +1,154 @@
<?php
/**
* Class for the building ui-media elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Media' ) ) {
/**
* Class for the building CX_Control_Media elements.
*/
class CX_Control_Media extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-media-id',
'name' => 'cx-ui-media-name',
'value' => '',
'multi_upload' => true,
'library_type' => '', // image, video, sound
'upload_button_text' => 'Choose Media',
'label' => '',
'class' => '',
);
/**
* Register control dependencies
*
* @return [type] [description]
*/
public function register_depends() {
wp_enqueue_media();
}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array( 'jquery-ui-sortable' );
}
/**
* Render html CX_Control_Media.
*
* @since 1.0.0
*/
public function render() {
$html = '';
if ( ! current_user_can( 'upload_files' ) ) {
return $html;
}
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' != $this->settings['value'] ) {
$this->settings['value'] = str_replace( ' ', '', $this->settings['value'] );
$medias = explode( ',', $this->settings['value'] );
} else {
$this->settings['value'] = '';
$medias = array();
}
$img_style = ! $this->settings['value'] ? 'style="display:none;"' : '' ;
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<div class="cx-ui-media-wrap">';
$html .= '<div class="cx-upload-preview" >';
$html .= '<div class="cx-all-images-wrap">';
if ( is_array( $medias ) && ! empty( $medias ) ) {
foreach ( $medias as $medias_key => $medias_value ) {
$media_title = get_the_title( $medias_value );
$mime_type = get_post_mime_type( $medias_value );
$tmp = wp_get_attachment_metadata( $medias_value );
$img_src = '';
$thumb = '';
switch ( $mime_type ) {
case 'image/jpeg':
case 'image/png':
case 'image/gif':
$img_src = wp_get_attachment_image_src( $medias_value, 'thumbnail' );
$img_src = $img_src[0];
$thumb = '<img src="' . esc_html( $img_src ) . '" alt="">';
break;
case 'image/x-icon':
$thumb = '<span class="dashicons dashicons-format-image"></span>';
break;
case 'video/mpeg':
case 'video/mp4':
case 'video/quicktime':
case 'video/webm':
case 'video/ogg':
$thumb = '<span class="dashicons dashicons-format-video"></span>';
break;
case 'audio/mpeg':
case 'audio/wav':
case 'audio/ogg':
$thumb = '<span class="dashicons dashicons-format-audio"></span>';
break;
}
$html .= '<div class="cx-image-wrap">';
$html .= '<div class="inner">';
$html .= '<div class="preview-holder" data-id-attr="' . esc_attr( $medias_value ) . '">';
$html .= '<div class="centered">';
$html .= $thumb;
$html .= '</div>';
$html .= '</div>';
$html .= '<span class="title">' . $media_title . '</span>';
$html .= '<a class="cx-remove-image" href="#" title=""><i class="dashicons dashicons-no"></i></a>';
$html .= '</div>';
$html .= '</div>';
}
}
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="cx-element-wrap">';
$html .= '<input type="hidden" id="' . esc_attr( $this->settings['id'] ) . '" class="cx-upload-input" name="' . esc_attr( $this->settings['name'] ) . '" value="' . esc_html( $this->settings['value'] ) . '">';
$html .= '<button type="button" class="upload-button cx-upload-button button-default_" value="' . esc_attr( $this->settings['upload_button_text'] ) . '" data-title="' . esc_attr( $this->settings['upload_button_text'] ) . '" data-multi-upload="' . esc_attr( $this->settings['multi_upload'] ) . '" data-library-type="' . esc_attr( $this->settings['library_type'] ) . '">' . esc_attr( $this->settings['upload_button_text'] ) . '</button>';
$html .= '<div class="clear"></div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,121 @@
<?php
/**
* Class for the building ui-radio elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cxframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cxframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Radio' ) ) {
/**
* Class for the building CX_Control_Radio elements.
*/
class CX_Control_Radio extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-radio-id',
'name' => 'cx-ui-radio-name',
'value' => 'radio-2',
'options' => array(
'radio-1' => array(
'label' => 'Radio 1',
'img_src' => '',
),
'radio-2' => array(
'label' => 'Radio 2',
'img_src' => '',
),
'radio-3' => array(
'label' => 'Radio 3',
'img_src' => '',
),
),
'label' => '',
'class' => '',
);
/**
* Render html UI_Radio.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
if ( isset( $this->settings['options_callback'] ) ) {
$this->settings['options'] = call_user_func( $this->settings['options_callback'] );
}
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '" >';
if ( $this->settings['options'] && ! empty( $this->settings['options'] ) && is_array( $this->settings['options'] ) ) {
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . $this->settings['label'] . '</label> ';
}
$html .= '<div class="cx-radio-group">';
foreach ( $this->settings['options'] as $option => $option_value ) {
$checked = $option == $this->settings['value'] ? ' checked' : '';
$radio_id = $this->settings['id'] . '-' . $option;
$img = isset( $option_value['img_src'] ) && ! empty( $option_value['img_src'] ) ? '<img src="' . esc_url( $option_value['img_src'] ) . '" alt="' . esc_html( $option_value['label'] ) . '">' : '<span class="cx-radio-item"><i></i></span>';
$class_box = isset( $option_value['img_src'] ) && ! empty( $option_value['img_src'] ) ? 'cx-radio-img' : 'cx-radio-item' ;
$html .= '<div class="' . $class_box . '">';
$html .= '<input type="radio" id="' . esc_attr( $radio_id ) . '" class="cx-radio-input" name="' . esc_attr( $this->settings['name'] ) . '" ' . checked( $option, $this->settings['value'], false ) . ' value="' . esc_attr( $option ) . '"/>';
$label_content = $img . $option_value['label'];
$html .= '<label for="' . esc_attr( $radio_id ) . '"><span class="cx-lable-content">' . $label_content . '</span></label> ';
$html .= '</div>';
}
$html .= '<div class="clear"></div>';
$html .= '</div>';
}
$html .= '</div>';
return $html;
}
/**
* Enqueue javascript and stylesheet UI_Radio.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_style(
'ui-radio',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-radio/assets/min/ui-radio.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
wp_enqueue_script(
'ui-radio-min',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-radio/assets/min/ui-radio.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery' ),
Cherry_UI_Elements::$core_version,
true
);
}
}
}

View File

@@ -0,0 +1,372 @@
<?php
/**
* Class for the building ui-repeater elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Repeater' ) ) {
/**
* Class for the building ui-repeater elements.
*/
class CX_Control_Repeater extends CX_Controls_Base {
/**
* Default settings
*
* @var array
*/
public $defaults_settings = array(
'type' => 'repeater',
'id' => 'cx-ui-repeater-id',
'name' => 'cx-ui-repeater-name',
'value' => array(),
'fields' => array(),
'label' => '',
'add_label' => 'Add Item',
'class' => '',
'ui_kit' => true,
'required' => false,
'title_field' => '',
);
/**
* Stored data to process it while renderinr row
*
* @var array
*/
public $data = array();
/**
* Repeater instances counter
*
* @var integer
*/
public static $instance_id = 0;
/**
* Current onstance TMPL name
*
* @var string
*/
public $tmpl_name = '';
/**
* Holder for templates to print it in bottom of customizer page
*
* @var string
*/
public static $customizer_tmpl_to_print = null;
/**
* Is tmpl scripts already printed in customizer
*
* @var boolean
*/
public static $customizer_tmpl_printed = false;
/**
* Child repeater instances
*
* @var array
*/
private $_childs = array();
/**
* Check if we render template for JS
*
* @var boolean
*/
private $_is_js_row = false;
/**
* Init.
*
* @since 1.0.0
*/
public function init() {
$this->set_tmpl_data();
add_action( 'admin_footer', array( $this, 'print_js_template' ), 0 );
add_action( 'customize_controls_print_footer_scripts', array( $this, 'fix_customizer_tmpl' ), 9999 );
}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array( 'jquery-ui-sortable', 'wp-util' );
}
/**
* Get required attribute.
*
* @return string required attribute
*/
public function get_required() {
if ( $this->settings['required'] ) {
return 'required="required"';
}
return '';
}
/**
* Render html UI_Repeater.
*
* @since 1.0.1
*/
public function render() {
$html = '';
$class = $this->settings['class'];
$ui_kit = ! empty( $this->settings['ui_kit'] ) ? 'cx-ui-kit' : '';
$value = ! empty( $this->settings['value'] ) ? count( $this->settings['value'] ) : 0 ;
$title_field = ! empty( $this->settings['title_field'] ) ? 'data-title-field="' . $this->settings['title_field'] . '"' : '' ;
add_filter( 'cx_control/is_repeater', '__return_true' );
$html .= sprintf( '<div class="cx-ui-repeater-container cx-ui-container %1$s %2$s">',
$ui_kit,
esc_attr( $class )
);
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= sprintf(
'<div class="cx-ui-repeater-list" data-name="%1$s" data-index="%2$s" data-widget-id="__i__" %3$s id="%4$s">',
$this->get_tmpl_name(),
$value,
$title_field,
esc_attr( $this->settings['id'] )
);
if ( is_array( $this->settings['value'] ) ) {
$index = 0;
foreach ( $this->settings['value'] as $data ) {
$this->_is_js_row = false;
$html .= $this->render_row( $index, false, $data );
$index++;
}
}
$html .= '</div>';
$html .= sprintf(
'<a href="#" class="cx-ui-repeater-add">%1$s</a>',
esc_html( $this->settings['add_label'] )
);
$html .= '</div>';
/**
* Maybe add js repeater template to response
*
* @var bool
*/
$add_js_to_response = apply_filters( 'cx_control/add_data_to_element', false );
if ( $add_js_to_response ) {
$html .= $this->get_js_template();
}
$html .= $this->get_additional_data();
remove_all_filters( 'cx_control/is_repeater' );
return $html;
}
/**
* Get additional data to return
* @return [type] [description]
*/
public function get_additional_data() {
$data = apply_filters( 'cx_control/add_repeater_data', array() );
if ( ! empty( $data ) ) {
return implode( ' ', $data );
}
}
/**
* Render single row for repeater
*
* @param string $index Current row index.
* @param number $widget_index It contains widget index.
* @param array $data Values to paste.
* @since 1.0.1
*/
public function render_row( $index, $widget_index, $data ) {
$this->data = $data;
$html = '<div class="cx-ui-repeater-item" >';
$html .= '<div class="cx-ui-repeater-actions-box">';
$html .= '<a href="#" class="cx-ui-repeater-remove"></a>';
$html .= '<span class="cx-ui-repeater-title">' . $this->get_row_title() . '</span>';
$html .= '<a href="#" class="cx-ui-repeater-toggle"></a>';
$html .= '</div>';
$html .= '<div class="cheryr-ui-repeater-content-box">';
foreach ( $this->settings['fields'] as $field ) {
$field_classes = array(
$field['id'] . '-wrap',
);
if ( ! empty( $field['class'] ) ) {
$field_classes[] = $field['class'];
}
$field_classes = implode( ' ', $field_classes );
$html .= '<div class="' . $field_classes . '">';
$html .= $this->render_field( $index, $widget_index, $field );
$html .= '</div>';
}
$html .= '</div>';
$html .= '</div>';
$this->data = array();
return $html;
}
/**
* Get repeater item title
*
* @return string
* @since 1.0.1
*/
public function get_row_title() {
if ( empty( $this->settings['title_field'] ) ) {
return '';
}
if ( ! empty( $this->data[ $this->settings['title_field'] ] ) ) {
return $this->data[ $this->settings['title_field'] ];
}
return '';
}
/**
* Render single repeater field
*
* @param string $index Current row index.
* @param number $widget_index It contains widget index.
* @param array $field Values to paste.
* @return string
*/
public function render_field( $index, $widget_index, $field ) {
if ( empty( $field['type'] ) || empty( $field['name'] ) ) {
return '"type" and "name" are required fields for UI_Repeater items';
}
$field = wp_parse_args( $field, array(
'value' => '',
) );
$parent_name = str_replace( '__i__', $widget_index, $this->settings['name'] );
$parent_name = str_replace( '{{{data.index}}}', '{{{data.parentIndex}}}', $parent_name );
$field['id'] = sprintf( '%s-%s', $field['id'], $index );
$field['value'] = isset( $this->data[ $field['name'] ] ) ? $this->data[ $field['name'] ] : $field['value'];
$field['name'] = sprintf( '%1$s[item-%2$s][%3$s]', $parent_name, $index, $field['name'] );
$ui_class_name = 'CX_Control_' . ucwords( $field['type'] );
if ( ! class_exists( $ui_class_name ) ) {
return '<p>Class <b>' . $ui_class_name . '</b> not exist!</p>';
}
$ui_item = new $ui_class_name( $field );
if ( 'repeater' === $ui_item->settings['type'] && true === $this->_is_js_row ) {
$this->_childs[] = $ui_item;
}
return $ui_item->render();
}
/**
* Get TMPL name for current repeater instance.
*
* @return string
*/
public function get_tmpl_name() {
return $this->tmpl_name;
}
/**
* Set current repeater instance ID
*
* @return void
*/
public function set_tmpl_data() {
self::$instance_id++;
$this->tmpl_name = sprintf( 'repeater-template-%s', self::$instance_id );
global $wp_customize;
if ( isset( $wp_customize ) ) {
self::$customizer_tmpl_to_print .= $this->get_js_template();
}
}
/**
* Print JS template for current repeater instance
*
* @return void
*/
public function print_js_template() {
echo $this->get_js_template();
if ( ! empty( $this->_childs ) ) {
foreach ( $this->_childs as $child ) {
echo $child->get_js_template();
}
}
}
/**
* Get JS template to print
*
* @return string
*/
public function get_js_template() {
$this->_is_js_row = true;
return sprintf(
'<script type="text/html" id="tmpl-%1$s">%2$s</script>',
$this->get_tmpl_name(),
$this->render_row( '{{{data.index}}}', '{{{data.widgetId}}}', array() )
);
}
/**
* Outputs JS templates on customizer page
*
* @return void
*/
public function fix_customizer_tmpl() {
if ( true === self::$customizer_tmpl_printed ) {
return;
}
self::$customizer_tmpl_printed = true;
echo self::$customizer_tmpl_to_print;
}
}
}

View File

@@ -0,0 +1,185 @@
<?php
/**
* Class for the building ui-select elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Select' ) ) {
/**
* Class for the building CX_Control_Select elements.
*/
class CX_Control_Select extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-select-id',
'name' => 'cx-ui-select-name',
'multiple' => false,
'filter' => false,
'size' => 1,
'inline_style' => 'width: 100%',
'value' => 'select-8',
'placeholder' => null,
'options' => array(
'select-1' => 'select 1',
'select-2' => 'select 2',
'select-3' => 'select 3',
'select-4' => 'select 4',
'select-5' => array(
'label' => 'Group 1',
),
'optgroup-1' => array(
'label' => 'Group 1',
'group_options' => array(
'select-6' => 'select 6',
'select-7' => 'select 7',
'select-8' => 'select 8',
),
),
'optgroup-2' => array(
'label' => 'Group 2',
'group_options' => array(
'select-9' => 'select 9',
'select-10' => 'select 10',
'select-11' => 'select 11',
),
),
),
'label' => '',
'class' => '',
);
/**
* Register control dependencies
*
* @return [type] [description]
*/
public function register_depends() {
wp_register_script(
'cx-select2',
$this->base_url . 'assets/lib/select2/select2.min.js',
array( 'jquery' ),
'4.0.5',
true
);
wp_register_style(
'cx-select2',
$this->base_url . 'assets/lib/select2/select2.min.css',
array(),
'4.0.5',
'all'
);
}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array( 'cx-select2' );
}
/**
* Retrun styles dependencies list for current control.
*
* @return array
*/
public function get_style_depends() {
return array( 'cx-select2' );
}
/**
* Render html UI_Select.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
if ( isset( $this->settings['options_callback'] ) ) {
$this->settings['options'] = call_user_func( $this->settings['options_callback'] );
}
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
$html .= '<div class="cx-ui-select-wrapper">';
( $this->settings['filter'] ) ? $filter_state = 'data-filter="true"' : $filter_state = 'data-filter="false"' ;
( $this->settings['multiple'] ) ? $multi_state = 'multiple="multiple"' : $multi_state = '' ;
( $this->settings['multiple'] ) ? $name = $this->settings['name'] . '[]' : $name = $this->settings['name'] ;
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . $this->settings['label'] . '</label> ';
}
$inline_style = $this->settings['inline_style'] ? 'style="' . esc_attr( $this->settings['inline_style'] ) . '"' : '' ;
$html .= '<select id="' . esc_attr( $this->settings['id'] ) . '" class="cx-ui-select" name="' . esc_attr( $name ) . '" size="' . esc_attr( $this->settings['size'] ) . '" ' . $multi_state . ' ' . $filter_state . ' data-placeholder="' . esc_attr( $this->settings['placeholder'] ) . '" ' . $inline_style . '>';
if ( $this->settings['options'] && ! empty( $this->settings['options'] ) && is_array( $this->settings['options'] ) ) {
foreach ( $this->settings['options'] as $option => $option_value ) {
if ( ! is_array( $this->settings['value'] ) ) {
$this->settings['value'] = array( $this->settings['value'] );
}
if ( false === strpos( $option, 'optgroup' ) ) {
$selected_state = '';
if ( $this->settings['value'] && ! empty( $this->settings['value'] ) ) {
foreach ( $this->settings['value'] as $key => $value ) {
$selected_state = selected( $value, $option, false );
if ( " selected='selected'" == $selected_state ) {
break;
}
}
}
if ( is_array( $option_value ) ) {
$label = $option_value['label'];
} else {
$label = $option_value;
}
$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected_state . '>' . esc_html( $label ) . '</option>';
} else {
$html .= '<optgroup label="' . esc_attr( $option_value['label'] ) . '">';
$selected_state = '';
foreach ( $option_value['group_options'] as $group_item => $group_value ) {
foreach ( $this->settings['value'] as $key => $value ) {
$selected_state = selected( $value, $group_item, false );
if ( " selected='selected'" == $selected_state ) {
break;
}
}
$html .= '<option value="' . esc_attr( $group_item ) . '" ' . $selected_state . '>' . esc_html( $group_value ) . '</option>';
}
$html .= '</optgroup>';
}
}
}
$html .= '</select>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,104 @@
<?php
/**
* Class for the building ui slider elements .
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Slider' ) ) {
/**
* Class for the building UI_Slider elements.
*/
class CX_Control_Slider extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-slider-id',
'name' => 'cx-ui-slider-name',
'max_value' => 100,
'min_value' => 0,
'value' => 50,
'step_value' => 1,
'label' => '',
'class' => '',
);
/**
* Render html UI_Slider.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
$ui_stepper = new CX_Control_Stepper(
array(
'id' => $this->settings['id'] . '-stepper',
'name' => $this->settings['name'],
'max_value' => $this->settings['max_value'],
'min_value' => $this->settings['min_value'],
'value' => $this->settings['value'],
'step_value' => $this->settings['step_value'],
)
);
$ui_stepper_html = $ui_stepper->render();
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<div class="cx-slider-wrap">';
$html .= '<div class="cx-slider-holder">';
$html .= '<input type="range" class="cx-slider-unit" step="' . esc_attr( $this->settings['step_value'] ) . '" min="' . esc_attr( $this->settings['min_value'] ) . '" max="' . esc_attr( $this->settings['max_value'] ) . '" value="' . esc_attr( $this->settings['value'] ) . '">';
$html .= '</div>';
$html .= '<div class="cx-slider-input">';
$html .= $ui_stepper_html;
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
/**
* Enqueue javascript and stylesheet UI_Slider.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_script(
'ui-slider',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-slider/assets/min/ui-slider.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery' ),
Cherry_UI_Elements::$core_version,
true
);
wp_enqueue_style(
'ui-slider',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-slider/assets/min/ui-slider.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Class for the building ui stepper elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cxframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cxframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Stepper' ) ) {
/**
* Class for the building CX_Control_Stepper elements.
*/
class CX_Control_Stepper extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-stepper-id',
'name' => 'cx-ui-stepper-name',
'value' => '0',
'max_value' => '100',
'min_value' => '0',
'step_value' => '1',
'label' => '',
'class' => '',
'placeholder' => '',
);
/**
* Render html UI_Stepper.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<div class="cx-ui-stepper">';
$html .= '<input type="number" id="' . esc_attr( $this->settings['id'] ) . '" class="cx-ui-stepper-input" pattern="[0-5]+([\.,][0-5]+)?" name="' . esc_attr( $this->settings['name'] ) . '" value="' . esc_html( $this->settings['value'] ) . '" min="' . esc_html( $this->settings['min_value'] ) . '" max="' . esc_html( $this->settings['max_value'] ) . '" step="' . esc_html( $this->settings['step_value'] ) . '" placeholder="' . esc_attr( $this->settings['placeholder'] ) . '">';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Class for the building ui swither elements .
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Switcher' ) ) {
/**
* Class for the building CX_Control_Switcher elements.
*/
class CX_Control_Switcher extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-swither-id',
'name' => 'cx-ui-swither-name',
'value' => true,
'toggle' => array(
'true_toggle' => 'On',
'false_toggle' => 'Off',
),
'label' => '',
'class' => '',
);
/**
* Render html UI_Switcher.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$value = filter_var( $this->settings['value'], FILTER_VALIDATE_BOOLEAN );
$html .= '<div class="cx-switcher-wrap">';
$html .= '<input type="radio" id="' . esc_attr( $this->settings['id'] ) . '-true" class="cx-input-switcher cx-input-switcher-true" name="' . esc_attr( $this->settings['name'] ) . '" ' . checked( true, $value, false ) . ' value="true">';
$html .= '<input type="radio" id="' . esc_attr( $this->settings['id'] ) . '-false" class="cx-input-switcher cx-input-switcher-false" name="' . esc_attr( $this->settings['name'] ) . '" ' . checked( false, $value, false ) . ' value="false">';
$html .= '<span class="bg-cover"></span>';
$html .= '<label class="sw-enable"><span>' . esc_html( $this->settings['toggle']['true_toggle'] ) . '</span></label>';
$html .= '<label class="sw-disable"><span>' . esc_html( $this->settings['toggle']['false_toggle'] ) . '</span></label>';
$html .= '<span class="state-marker"></span>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Class for the building ui-text elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Text' ) ) {
/**
* Class for the building ui-text elements.
*/
class CX_Control_Text extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'type' => 'text',
'id' => 'cx-ui-input-id',
'name' => 'cx-ui-input-name',
'value' => '',
'placeholder' => '',
'label' => '',
'class' => '',
'required' => false,
);
/**
* Get required attribute.
*
* @since 1.0.0
* @return string
*/
public function get_required() {
if ( $this->settings['required'] ) {
return 'required="required"';
}
return '';
}
/**
* Render html UI_Text.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<input type="' . esc_attr( $this->settings['type'] ) . '" id="' . esc_attr( $this->settings['id'] ) . '" class="widefat cx-ui-text" name="' . esc_attr( $this->settings['name'] ) . '" value="' . esc_html( $this->settings['value'] ) . '" placeholder="' . esc_attr( $this->settings['placeholder'] ) . '" ' . $this->get_required() . '>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Class for the building ui-textarea elements
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Textarea' ) ) {
/**
* Class for the building CX_Control_Textarea elements.
*/
class CX_Control_Textarea extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-textarea-id',
'name' => 'cx-ui-textarea-name',
'value' => '',
'placeholder' => '',
'rows' => '10',
'cols' => '20',
'label' => '',
'class' => '',
);
/**
* Render html UI_Textarea.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . $this->settings['label'] . '</label> ';
}
$html .= '<textarea id="' . esc_attr( $this->settings['id'] ) . '" class="cx-ui-textarea" name="' . esc_attr( $this->settings['name'] ) . '" rows="' . esc_attr( $this->settings['rows'] ) . '" cols="' . esc_attr( $this->settings['cols'] ) . '" placeholder="' . esc_attr( $this->settings['placeholder'] ) . '">' . esc_html( $this->settings['value'] ) . '</textarea>';
$html .= '</div>';
return $html;
}
}
}

Some files were not shown because too many files have changed in this diff Show More