Add initial files and structure for Essential Addons for Elementor Lite plugin

This commit is contained in:
2025-01-17 00:40:58 +01:00
parent ae5052c407
commit d2ed11bf1b
524 changed files with 258494 additions and 2310 deletions

View File

@@ -0,0 +1,512 @@
<?php
namespace Essential_Addons_Elementor\Classes;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
use Elementor\Core\Files\CSS\Post as Post_CSS;
use Elementor\Plugin;
use Essential_Addons_Elementor\Classes\Elements_Manager;
use Essential_Addons_Elementor\Traits\Library;
class Asset_Builder {
/**
* @theTraitAnnotation Library
*/
use Library;
/**
* Post ID
* @var int
*/
protected $post_id;
/**
* @var string
*/
protected $custom_js = '';
/**
* @var string
*/
protected $css_strings = '';
/**
* @var \Essential_Addons_Elementor\Classes\Elements_Manager
*/
protected $elements_manager;
/**
* @var false|mixed|string|void
*/
protected $css_print_method = '';
/**
* @var false|mixed|string|void
*/
protected $js_print_method = '';
/**
* @var array
*/
protected $registered_elements;
/**
* @var array
*/
protected $registered_extensions;
/**
* @var object
*/
protected $localize_objects;
/**
* @var int|int[]|mixed|string[]
*/
protected $custom_js_enable;
/**
* @var bool
*/
protected $main_page;
/**
* construct
*
* @param array $registered_elements
* @param array $registered_extensions
*/
public function __construct( $registered_elements, $registered_extensions ) {
$this->registered_elements = $registered_elements;
$this->registered_extensions = $registered_extensions;
$this->elements_manager = new Elements_Manager( $this->registered_elements, $this->registered_extensions );
$this->elements_manager->css_print_method = $this->css_print_method = get_option( 'elementor_css_print_method' );
$this->elements_manager->js_print_method = $this->js_print_method = get_option( 'eael_js_print_method' );
$this->init_hook();
$this->custom_js_enable = $this->get_settings( 'custom-js' );
}
/**
* init_hook
* Load Hook
*/
protected function init_hook() {
add_action( 'wp_footer', [ $this, 'add_inline_js' ], 100 );
add_action( 'wp_footer', [ $this, 'add_inline_css' ], 15 );
add_action( 'after_delete_post', [ $this, 'delete_cache_data' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'frontend_asset_load' ], 100 );
add_action( 'elementor/frontend/before_enqueue_styles', [ $this, 'ea_before_enqueue_styles' ] );
add_action( 'elementor/theme/register_locations', [ $this, 'load_asset_per_location' ], 20 );
add_filter( 'elementor/files/file_name', [ $this, 'load_asset_per_file' ] );
}
/**
* frontend_asset_load
* Load asset as per condition
* @return false|void
*/
public function frontend_asset_load() {
$handle = 'eael-general';
$this->post_id = get_the_ID();
$this->elements_manager->get_element_list( $this->post_id );
$this->load_commnon_asset();
$this->register_script();
if ( ! $this->is_edit() ) {
wp_enqueue_script( 'eael-general' );
wp_enqueue_style( 'eael-general' );
$this->load_custom_js( $this->post_id );
} else {
$elements = $this->get_settings();
if ( empty( $elements ) ) {
return false;
}
if ( $this->js_print_method == 'internal' ) {
wp_enqueue_script( 'eael-general' );
}
if ( $this->css_print_method == 'internal' ) {
wp_enqueue_style( 'eael-general' );
}
do_action( 'eael/before_enqueue_styles', $elements );
do_action( 'eael/before_enqueue_scripts', $elements );
$this->enqueue_asset( null, $elements, 'edit' );
$this->load_custom_js( $this->post_id );
}
wp_localize_script( $handle, 'localize', $this->localize_objects );
}
/**
* ea_before_enqueue_styles
* @return false|void
*/
public function ea_before_enqueue_styles() {
if ( $this->is_edit() ) {
return false;
}
$this->post_id = get_the_ID();
$this->set_main_page( $this->post_id );
$this->elements_manager->get_element_list( $this->post_id );
$elements = get_post_meta( $this->post_id, '_eael_widget_elements', true );
if ( ! empty( $elements ) ) {
$this->enqueue_asset( $this->post_id, $elements );
}
if ( ! $this->main_page ) {
$this->load_custom_js( $this->post_id );
}
}
/**
* load_asset_per_location
*
* @param $instance
*
* @return false|void
*/
public function load_asset_per_location( $instance ) {
if ( is_admin() || ! ( class_exists( 'ElementorPro\Modules\ThemeBuilder\Module' ) ) ) {
return false;
}
$locations = $instance->get_locations();
foreach ( $locations as $location => $settings ) {
$documents = \ElementorPro\Modules\ThemeBuilder\Module::instance()->get_conditions_manager()->get_documents_for_location( $location );
foreach ( $documents as $document ) {
$post_id = $document->get_post()->ID;
$this->post_id = $post_id;
$this->set_main_page( $this->post_id );
$this->elements_manager->get_element_list( $this->post_id );
$elements = get_post_meta( $this->post_id, '_eael_widget_elements', true );
if ( ! empty( $elements ) ) {
do_action( 'eael/before_enqueue_styles', $elements );
do_action( 'eael/before_enqueue_scripts', $elements );
$this->enqueue_asset( $this->post_id, $elements );
}
if ( ! $this->main_page ) {
$this->load_custom_js( $this->post_id );
}
}
}
}
/**
* load_asset_per_file
* @param $file_name
*
* @return mixed
*/
public function load_asset_per_file( $file_name ) {
if( empty( $file_name ) ){
return $file_name;
}
$post_id = preg_replace( '/[^0-9]/', '', $file_name );
if ( $post_id < 1 ) {
return $file_name;
}
$this->post_id = $post_id;
$type = get_post_meta( $this->post_id, '_elementor_template_type', true );
$template_list = ['popup'];
$this->set_main_page( $this->post_id );
$this->elements_manager->get_element_list( $this->post_id );
$elements = get_post_meta( $this->post_id, '_eael_widget_elements', true );
if ( ! empty( $elements ) ) {
do_action( 'eael/before_enqueue_styles', $elements );
do_action( 'eael/before_enqueue_scripts', $elements );
$this->enqueue_asset( $this->post_id, $elements );
}
if ( ! $this->main_page ) {
$this->load_custom_js( $this->post_id );
}
return $file_name;
}
/**
* add_inline_js
* Load inline js data
*/
public function add_inline_js() {
if ( $this->is_edit_mode() || $this->is_preview_mode() ) {
if ( $this->custom_js ) {
printf( '<script>%1$s</script>', 'var localize =' . wp_json_encode( $this->localize_objects ) );
printf( '<script id="eael-inline-js">%s</script>', $this->custom_js );
}
}
}
/**
* add_inline_css
* Load inline css file
*/
public function add_inline_css() {
if ( $this->is_edit_mode() || $this->is_preview_mode() ) {
if ( $this->css_strings ) {
printf( '<style id="eael-inline-css">%s</style>', $this->css_strings );
}
}
}
public function register_script() {
$css_deps = [ 'elementor-frontend' ];
$js_deps = [ 'jquery' ];
$theme = wp_get_theme(); // gets the current theme
$theme_data = $theme->parent() ? $theme->parent() : $theme;
if ( 'Hello Elementor' === $theme_data->name && version_compare( $theme_data->Version, '2.1.0', '>=' ) && wp_style_is( 'hello-elementor-theme-style', 'registered' ) ) {
array_unshift( $css_deps, 'hello-elementor-theme-style' );
} elseif ( in_array( 'Astra', [ $theme->name, $theme->parent_theme ] ) && wp_style_is( 'astra-theme-css', 'registered' ) ) {
array_unshift( $css_deps, 'astra-theme-css' );
} elseif ( in_array( 'XStore', [ $theme->name, $theme->parent_theme ] ) ) {
$js_deps[] = 'etheme';
}
if ( class_exists( 'Cartflows_Loader' ) && wcf()->utils->is_step_post_type() ) {
$css_deps = [ 'elementor-frontend' ];
}
wp_register_script( 'eael-general', EAEL_PLUGIN_URL . 'assets/front-end/js/view/general.min.js', $js_deps, EAEL_PLUGIN_VERSION, true );
wp_register_style( 'eael-general', EAEL_PLUGIN_URL . "assets/front-end/css/view/general.min.css", $css_deps, EAEL_PLUGIN_VERSION );
}
/**
* load_common_asset
* Load common asset file
*/
public function load_commnon_asset() {
wp_register_style(
'font-awesome-5-all',
ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/all.min.css',
false,
EAEL_PLUGIN_VERSION
);
wp_register_style(
'font-awesome-4-shim',
ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/v4-shims.min.css',
false,
EAEL_PLUGIN_VERSION
);
wp_register_script(
'font-awesome-4-shim',
ELEMENTOR_ASSETS_URL . 'lib/font-awesome/js/v4-shims.min.js',
false,
EAEL_PLUGIN_VERSION
);
// register reading progress assets
wp_register_style(
'eael-reading-progress',
EAEL_PLUGIN_URL . 'assets/front-end/css/view/reading-progress.min.css',
false,
EAEL_PLUGIN_VERSION
);
wp_register_script(
'eael-reading-progress',
EAEL_PLUGIN_URL . 'assets/front-end/js/view/reading-progress.min.js',
[ 'jquery' ],
EAEL_PLUGIN_VERSION
);
// register Table of contents assets
wp_register_style(
'eael-table-of-content',
EAEL_PLUGIN_URL . 'assets/front-end/css/view/table-of-content.min.css',
false,
EAEL_PLUGIN_VERSION
);
wp_register_script(
'eael-table-of-content',
EAEL_PLUGIN_URL . 'assets/front-end/js/view/table-of-content.min.js',
[ 'jquery' ],
EAEL_PLUGIN_VERSION
);
// register scroll to top assets
wp_register_style(
'eael-scroll-to-top',
EAEL_PLUGIN_URL . 'assets/front-end/css/view/scroll-to-top.min.css',
false,
EAEL_PLUGIN_VERSION
);
wp_register_script(
'eael-scroll-to-top',
EAEL_PLUGIN_URL . 'assets/front-end/js/view/scroll-to-top.min.js',
[ 'jquery' ],
EAEL_PLUGIN_VERSION
);
// localize object
$this->localize_objects = apply_filters( 'eael/localize_objects', [
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'essential-addons-elementor' ),
'i18n' => [
'added' => __( 'Added ', 'essential-addons-for-elementor-lite' ),
'compare' => __( 'Compare', 'essential-addons-for-elementor-lite' ),
'loading' => esc_html__( 'Loading...', 'essential-addons-for-elementor-lite' )
],
'eael_translate_text' => [
'required_text' => esc_html__( 'is a required field', 'essential-addons-for-elementor-lite' ),
'invalid_text' => esc_html__( 'Invalid', 'essential-addons-for-elementor-lite' ),
'billing_text' => esc_html__( 'Billing', 'essential-addons-for-elementor-lite' ),
'shipping_text' => esc_html__( 'Shipping', 'essential-addons-for-elementor-lite' ),
'fg_mfp_counter_text' => apply_filters( 'eael/filterble-gallery/mfp-counter-text', __( 'of', 'essential-addons-for-elementor-lite' ) ),
],
'page_permalink' => get_the_permalink(),
'cart_redirectition' => get_option( 'woocommerce_cart_redirect_after_add' ),
'cart_page_url' => function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : '',
'el_breakpoints' => method_exists( Plugin::$instance->breakpoints, 'get_breakpoints_config' ) ? Plugin::$instance->breakpoints->get_breakpoints_config() : '',
] );
}
/**
* enqueue_asset
*
* @param int $post_id
* @param array $elements
* @param string $context
*/
public function enqueue_asset( $post_id = null, $elements = [], $context = 'view' ) {
$dynamic_asset_id = ( $post_id ? '-' . $post_id : '' );
if ( $this->css_print_method == 'internal' ) {
$this->css_strings .= $this->elements_manager->generate_strings( $elements, $context, 'css' );
} else {
if ( ! $this->has_asset( $post_id, 'css' ) ) {
$this->elements_manager->generate_script( $post_id, $elements, $context, 'css' );
}
wp_enqueue_style(
'eael' . $dynamic_asset_id,
$this->safe_url( EAEL_ASSET_URL . '/' . 'eael' . $dynamic_asset_id . '.css' ),
[ 'eael-general' ],
get_post_modified_time()
);
}
if ( $this->js_print_method == 'internal' ) {
$this->custom_js .= $this->elements_manager->generate_strings( $elements, $context, 'js' );
} else {
if ( ! $this->has_asset( $post_id, 'js' ) ) {
$this->elements_manager->generate_script( $post_id, $elements, $context, 'js' );
}
wp_enqueue_script(
'eael' . $dynamic_asset_id,
$this->safe_url( EAEL_ASSET_URL . '/' . 'eael' . $dynamic_asset_id . '.js' ),
[ 'eael-general' ],
get_post_modified_time(),
true
);
}
}
/**
* delete_cache_data
*
* @param int $post_id
*/
public function delete_cache_data( $post_id ) {
$this->elements_manager->remove_files( $post_id );
delete_post_meta( $post_id, '_eael_custom_js' );
delete_post_meta( $post_id, '_eael_widget_elements' );
}
/**
* has_asset
*
* @param int $post_id
* @param string $file
*
* @return bool
*/
public function has_asset( $post_id, $file = 'css' ) {
if ( file_exists( $this->safe_path( EAEL_ASSET_PATH . '/' . 'eael' . ( $post_id ? '-' . $post_id : '' ) . '.' . $file ) ) ) {
return true;
}
return false;
}
public function load_custom_js( $post_id ) {
static $post_ids_array = [];
if ( in_array( $post_id, $post_ids_array ) ) {
return false;
}
$post_ids_array[] = $post_id;
if ( ! $this->custom_js_enable ) {
return false;
}
$custom_js = get_post_meta( $post_id, '_eael_custom_js', true );
if ( $custom_js ) {
// add semicolon if someone misses adding this in custom js code .
$this->custom_js .= $custom_js.';';
}
}
/**
* is_edit
* check is edit page
* @return bool
*/
public function is_edit() {
return (
Plugin::instance()->editor->is_edit_mode() ||
Plugin::instance()->preview->is_preview_mode() ||
is_preview()
);
}
/**
* set_main_page
*
* @param $post_id
*/
protected function set_main_page( $post_id ) {
$this->main_page = get_post_meta( $post_id, '_elementor_template_type', true ) == 'wp-page';
}
}

View File

@@ -0,0 +1,343 @@
<?php
namespace Essential_Addons_Elementor\Classes;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
use Elementor\Plugin;
use Essential_Addons_Elementor\Traits\Admin;
use Essential_Addons_Elementor\Traits\Core;
use Essential_Addons_Elementor\Traits\Elements;
use Essential_Addons_Elementor\Traits\Enqueue;
use Essential_Addons_Elementor\Traits\Helper;
use Essential_Addons_Elementor\Traits\Library;
use Essential_Addons_Elementor\Traits\Login_Registration;
use Essential_Addons_Elementor\Traits\Woo_Product_Comparable;
use Essential_Addons_Elementor\Traits\Controls;
use Essential_Addons_Elementor\Traits\Facebook_Feed;
use Essential_Addons_Elementor\Classes\Asset_Builder;
use Essential_Addons_Elementor\Traits\Ajax_Handler;
class Bootstrap
{
use Library;
use Core;
use Helper;
use Enqueue;
use Admin;
use Elements;
use Login_Registration;
use Woo_Product_Comparable;
use Controls;
use Facebook_Feed;
use Ajax_Handler;
// instance container
private static $instance = null;
// request unique id container
protected $uid = null;
// registered elements container
protected $registered_elements;
// registered extensions container
protected $registered_extensions;
// identify whether pro is enabled
protected $pro_enabled;
// localize objects
public $localize_objects = [];
// request data container
protected $request_requires_update;
// loaded templates in a request
protected $loaded_templates = [];
// loaded elements in a request
protected $loaded_elements = [];
// used for internal css
protected $css_strings;
// used for internal js
protected $js_strings;
// used to store custom js
protected $custom_js_strings;
// modules
protected $installer;
const EAEL_PROMOTION_FLAG = 11;
const EAEL_ADMIN_MENU_FLAG = 11;
/**
* Singleton instance
*
* @since 3.0.0
*/
public static function instance()
{
if (self::$instance == null) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Constructor of plugin class
*
* @since 3.0.0
*/
private function __construct()
{
// init modules
$this->installer = new WPDeveloper_Plugin_Installer();
// before init hook
do_action('eael/before_init');
// search for pro version
$this->pro_enabled = apply_filters('eael/pro_enabled', false);
// elements classmap
$this->registered_elements = apply_filters('eael/registered_elements', $GLOBALS['eael_config']['elements']);
// extensions classmap
$this->registered_extensions = apply_filters('eael/registered_extensions', $GLOBALS['eael_config']['extensions']);
// start plugin tracking
if ( ! $this->pro_enabled ) {
$this->start_plugin_tracking();
}
// register extensions
$this->register_extensions();
// register hooks
$this->register_hooks();
if ( $this->is_activate_elementor() ) {
new Asset_Builder( $this->registered_elements, $this->registered_extensions );
}
}
protected function register_hooks()
{
// Core
add_action('init', [$this, 'i18n']);
// TODO::RM
add_filter('eael/active_plugins', [$this, 'is_plugin_active'], 10, 1);
add_filter('eael/is_plugin_active', [$this, 'is_plugin_active'], 10, 1);
add_action('elementor/editor/after_save', array($this, 'save_global_values'), 10, 2);
add_action('trashed_post', array($this, 'save_global_values_trashed_post'), 10, 1);
// Enqueue
add_action('eael/before_enqueue_styles', [$this, 'before_enqueue_styles']);
add_action('elementor/editor/before_enqueue_scripts', [$this, 'editor_enqueue_scripts']);
add_action('elementor/frontend/before_register_scripts', [$this, 'frontend_enqueue_scripts']);
// Generator
$this->init_ajax_hooks();
// Ajax
add_action('wp_ajax_facebook_feed_load_more', [$this, 'facebook_feed_render_items']);
add_action('wp_ajax_nopriv_facebook_feed_load_more', [$this, 'facebook_feed_render_items']);
// Compare table
add_action( 'wp_ajax_nopriv_eael_product_grid', [$this, 'get_compare_table']);
add_action( 'wp_ajax_eael_product_grid', [$this, 'get_compare_table']);
add_action( 'wp_ajax_eael_clear_widget_cache_data', [ $this, 'eael_clear_widget_cache_data' ] );
if ( defined( 'ELEMENTOR_VERSION' ) ) {
if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
add_action( 'elementor/controls/register', array( $this, 'register_controls' ) );
add_action('elementor/widgets/register', array($this, 'register_elements'));
} else {
add_action( 'elementor/controls/controls_registered', array( $this, 'register_controls' ) );
add_action('elementor/widgets/widgets_registered', array($this, 'register_elements'));
}
}
// Elements
add_action('elementor/elements/categories_registered', array($this, 'register_widget_categories'));
add_filter('elementor/editor/localize_settings', [$this, 'promote_pro_elements']);
add_action('wp_footer', [$this, 'render_global_html']);
add_action('wp_footer', [$this, 'render_advanced_accordion_global_faq']);
// Controls
add_action('eael/controls/query', [$this, 'query'], 10, 1);
add_action('eael/controls/betterdocs/query', [$this, 'betterdocs_query'], 10, 1);
add_action('eael/controls/layout', [$this, 'layout'], 10, 1);
add_action('eael/controls/terms_style', [$this, 'terms_style'], 10, 1);
add_action('eael/controls/read_more_button_style', [$this, 'read_more_button_style'], 10, 1);
add_action('eael/controls/load_more_button_style', [$this, 'load_more_button_style'], 10, 1);
add_action('eael/controls/custom_positioning', [$this, 'custom_positioning'], 10, 5);
add_action('eael/controls/nothing_found_style', [$this, 'nothing_found_style'], 10, 1);
add_filter('eael/controls/event-calendar/source', [$this, 'event_calendar_source']);
add_action('eael/controls/advanced-data-table/source', [$this, 'advanced_data_table_source']);
// Login | Register
add_action('init', [$this, 'login_or_register_user']);
add_filter('wp_new_user_notification_email', array($this, 'new_user_notification_email'), 10, 3);
add_filter('wp_new_user_notification_email_admin', array($this, 'new_user_notification_email_admin'), 10, 3);
add_action( 'login_init', [$this, 'eael_redirect_to_reset_password'] );
if( 'on' === get_option( 'eael_custom_profile_fields' ) ){
add_action( 'show_user_profile', [ $this, 'eael_extra_user_profile_fields' ] );
add_action( 'edit_user_profile', [ $this, 'eael_extra_user_profile_fields' ] );
add_action( 'personal_options_update', [ $this, 'eael_save_extra_user_profile_fields' ] );
add_action( 'edit_user_profile_update', [ $this, 'eael_save_extra_user_profile_fields' ] );
}
//rank math support
add_filter('rank_math/researches/toc_plugins', [$this, 'toc_rank_math_support']);
// if(defined('WPML_TM_VERSION')){
// add_filter( 'elementor/documents/get/post_id',[$this, 'eael_wpml_template_translation']);
// }
//templately plugin support
if( !class_exists('Templately\Plugin') && !get_option('eael_templately_promo_hide') ) {
add_action( 'elementor/editor/before_enqueue_scripts', [$this, 'templately_promo_enqueue_scripts'] );
add_action( 'eael/before_enqueue_styles', [$this, 'templately_promo_enqueue_style'] );
add_action( 'elementor/editor/footer', [ $this, 'print_template_views' ] );
add_action( 'wp_ajax_templately_promo_status', array($this, 'templately_promo_status'));
}
//Essential Blocks Promo
if ( ! class_exists( 'Classic_Editor' ) && ! class_exists( 'EssentialBlocks' ) && ( ! get_option( 'eael_eb_optin_hide' ) || ! get_option( 'eael_gb_eb_popup_hide' ) ) ) {
add_action( 'enqueue_block_editor_assets', [ $this, 'essential_blocks_promo_enqueue_scripts' ] );
add_action( 'admin_notices', [ $this, 'essential_block_optin' ] );
add_action( 'eael_admin_notices', [ $this, 'essential_block_special_optin' ], 100 );
add_action( 'wp_ajax_eael_eb_optin_notice_dismiss', [ $this, 'eael_eb_optin_notice_dismiss' ] );
add_action( 'wp_ajax_eael_gb_eb_popup_dismiss', [ $this, 'eael_gb_eb_popup_dismiss' ] );
}
if( class_exists( 'woocommerce' ) ) {
// quick view
add_action( 'eael_woo_single_product_image', 'woocommerce_show_product_images', 20 );
add_action( 'eael_woo_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'eael_woo_single_product_summary', 'woocommerce_template_single_rating', 10 );
add_action( 'eael_woo_single_product_summary', 'woocommerce_template_single_price', 15 );
add_action( 'eael_woo_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'eael_woo_single_product_summary', 'woocommerce_template_single_add_to_cart', 25 );
add_action( 'eael_woo_single_product_summary', 'woocommerce_template_single_meta', 30 );
add_filter( 'woocommerce_product_get_rating_html', [ $this, 'eael_rating_markup' ], 10, 3 );
add_filter( 'eael_product_wrapper_class', [ $this, 'eael_product_wrapper_class' ], 10, 3 );
add_action('wp_ajax_eael_checkout_cart_qty_update', [$this, 'eael_checkout_cart_qty_update'] );
add_action('wp_ajax_nopriv_eael_checkout_cart_qty_update', [$this, 'eael_checkout_cart_qty_update'] );
add_action( 'wp_loaded', [ $this, 'eael_woo_cart_empty_action' ], 20 );
add_filter( 'woocommerce_checkout_fields', [ $this, 'eael_customize_woo_checkout_fields' ] );
add_action( 'eael_woo_before_product_loop', function ( $layout ) {
if ( $layout === 'eael-product-default' ) {
return;
}
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open' );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close' );
remove_action( 'woocommerce_after_shop_loop_item', 'astra_woo_woocommerce_shop_product_content' );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
} );
add_action( 'eael_woo_after_product_loop', function ( $layout ) {
if ( $layout === 'eael-product-default' ) {
return;
}
add_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open' );
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close' );
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
if( function_exists( 'astra_woo_woocommerce_shop_product_content' ) ){
add_action( 'woocommerce_after_shop_loop_item', 'astra_woo_woocommerce_shop_product_content' );
}
} );
}
// Admin
if ( is_admin() ) {
// Admin
if (!$this->pro_enabled) {
$this->admin_notice();
} else {
new WPDeveloper_Core_Installer( basename( EAEL_PLUGIN_BASENAME, '.php' ) );
}
add_action('admin_menu', array($this, 'admin_menu'));
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
// Core
add_filter('plugin_action_links_' . EAEL_PLUGIN_BASENAME, array($this, 'insert_plugin_links'));
add_filter('plugin_row_meta', array($this, 'insert_plugin_row_meta'), 10, 2);
// removed activation redirection temporarily
// add_action('admin_init', array($this, 'redirect_on_activation'));
if ( ! did_action( 'elementor/loaded' ) ) {
add_action( 'admin_notices', array( $this, 'elementor_not_loaded' ) );
add_action( 'eael_admin_notices', array( $this, 'elementor_not_loaded' ) );
}
add_action( 'in_admin_header', [ $this, 'remove_admin_notice' ], 99 );
//handle typeform auth token
add_action('admin_init', [$this, 'typeform_auth_handle']);
// On Editor - Register WooCommerce frontend hooks before the Editor init.
// Priority = 5, in order to allow plugins remove/add their wc hooks on init.
if ( ! empty( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] ) {
add_action( 'init', [ $this, 'register_wc_hooks' ], 5 );
}
// update admin menu notice flag once visit EA settings page
add_action( 'eael_admin_page_setting', [ $this, 'eael_show_admin_menu_notice' ] );
// Black Friday Optin
// add_action( 'admin_notices', [ $this, 'eael_black_friday_optin' ] );
// add_action( 'eael_admin_notices', [ $this, 'eael_black_friday_optin' ] );
// add_action( 'wp_ajax_eael_black_friday_optin_dismiss', [ $this, 'eael_black_friday_optin_dismiss' ] );
if ( ! current_user_can( 'administrator' ) ) {
add_filter( 'elementor/document/save/data', function ( $data ) {
if ( empty( $data['elements'] ) ) {
return $data;
}
$data['elements'] = Plugin::$instance->db->iterate_data( $data['elements'], function ( $element ) {
if ( isset( $element['widgetType'] ) && $element['widgetType'] === 'eael-login-register' ) {
if ( ! empty( $element['settings']['register_user_role'] ) ) {
$element['settings']['register_user_role'] = '';
}
}
return $element;
} );
return $data;
} );
}
} else {
add_action( 'wp', [ $this, 'eael_post_view_count' ] );
}
// beehive theme compatibility
add_filter( 'beehive_scripts', array( $this, 'beehive_theme_swiper_slider_compatibility' ), 999 );
}
}

View File

@@ -0,0 +1,386 @@
<?php
namespace Essential_Addons_Elementor\Classes;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
use Elementor\Plugin;
use Essential_Addons_Elementor\Traits\Library;
class Elements_Manager {
use Library;
/**
* custom key name which are used for store widget list in option table
*/
const ELEMENT_KEY = '_eael_widget_elements';
/**
* This is hold custom js data in option table
*/
const JS_KEY = '_eael_custom_js';
public $css_print_method;
public $js_print_method;
/**
* Post id
* @var string
*/
protected $post_id;
/**
* registered element list from essential addons settings
* @var array
*/
protected $registered_elements;
/**
* registered extensions list from essential addons settings
* @var array
*/
protected $registered_extensions;
/**
* __construct
* @param array $registered_elements
* @param array $registered_extensions
*/
public function __construct( $registered_elements, $registered_extensions ) {
$this->registered_elements = $registered_elements;
$this->registered_extensions = $registered_extensions;
add_action( 'elementor/editor/after_save', array( $this, 'eael_elements_cache' ), 10, 2 );
}
/**
* eael_elements_cache
* Save widget name list in option table for improve performance.
* @param int $post_id
* @param array $data
*/
public function eael_elements_cache( $post_id, $data ) {
$widget_list = $this->get_widget_list( $data );
$page_setting = get_post_meta( $post_id, '_elementor_page_settings', true );
$custom_js = isset( $page_setting['eael_custom_js'] ) ? trim( $page_setting['eael_custom_js'] ) : '';
$this->save_widgets_list( $post_id, $widget_list, $custom_js );
}
/**
* get_widget_list
* get widget names
* @param array $data
*
* @return array
*/
public function get_widget_list( $data ) {
$widget_list = [];
$replace = $this->replace_widget_name();
if ( is_object( Plugin::$instance->db ) ) {
Plugin::$instance->db->iterate_data( $data, function ( $element ) use ( &$widget_list, $replace ) {
if ( empty( $element['widgetType'] ) ) {
$type = $element['elType'];
} else {
$type = $element['widgetType'];
}
if ( ! empty( $element['widgetType'] ) && $element['widgetType'] === 'global' ) {
$document = Plugin::$instance->documents->get( $element['templateID'] );
$type = is_object( $document ) ? current( $this->get_widget_list( $document->get_elements_data() ) ) : $type;
if ( ! empty( $type ) ) {
$type = 'eael-' . $type;
}
}
if ( ! empty( $type ) && ! is_array( $type ) ) {
if ( isset( $replace[ $type ] ) ) {
$type = $replace[ $type ];
}
if ( strpos( $type, 'eael-' ) !== false ) {
$type = str_replace( 'eael-', '', $type );
if ( ! isset( $widget_list[ $type ] ) ) {
$widget_list[ $type ] = $type;
}
}
$widget_list += $this->get_extension_list( $element );
}
} );
}
return $widget_list;
}
/**
* get_element_list
* get cached widget list
* @param $post_id
*
* @return bool
*/
public function get_element_list( $post_id ) {
if ( is_object( Plugin::instance()->editor ) && Plugin::instance()->editor->is_edit_mode() ) {
return false;
}
if ( $this->has_exist( $post_id ) ) {
return false;
}
$document = is_object( Plugin::$instance->documents ) ? Plugin::$instance->documents->get( $post_id ) : [];
$data = is_object( $document ) ? $document->get_elements_data() : [];
$data = $this->get_widget_list( $data );
$this->save_widgets_list( $post_id, $data, false );
return true;
}
/**
* get_extension_list
* get extension name those name had been changed for some reason.
* @param array $element
*
* @return array
*/
public function get_extension_list( $element ) {
$list = [];
if ( isset( $element['elType'] ) && ( $element['elType'] == 'section' || $element['elType'] == 'container' ) ) {
if ( ! empty( $element['settings']['eael_particle_switch'] ) ) {
$list['section-particles'] = 'section-particles';
}
if ( ! empty( $element['settings']['eael_parallax_switcher'] ) ) {
$list['section-parallax'] = 'section-parallax';
}
} else {
if ( ! empty( $element['settings']['eael_tooltip_section_enable'] ) ) {
$list['tooltip-section'] = 'tooltip-section';
}
if ( ! empty( $element['settings']['eael_ext_content_protection'] ) ) {
$list['content-protection'] = 'content-protection';
}
}
if ( ! empty( $element['settings']['eael_wrapper_link_switch'] ) ) {
$list['wrapper-link'] = 'wrapper-link';
}
return $list;
}
/*
* replace_widget_name
* Added backward compatibility
*/
public static function replace_widget_name() {
return [
'eicon-woocommerce' => 'eael-product-grid',
'eael-countdown' => 'eael-count-down',
'eael-creative-button' => 'eael-creative-btn',
'eael-team-member' => 'eael-team-members',
'eael-testimonial' => 'eael-testimonials',
'eael-weform' => 'eael-weforms',
'eael-cta-box' => 'eael-call-to-action',
'eael-dual-color-header' => 'eael-dual-header',
'eael-pricing-table' => 'eael-price-table',
'eael-filterable-gallery' => 'eael-filter-gallery',
'eael-one-page-nav' => 'eael-one-page-navigation',
'eael-interactive-card' => 'eael-interactive-cards',
'eael-image-comparison' => 'eael-img-comparison',
'eael-dynamic-filterable-gallery' => 'eael-dynamic-filter-gallery',
'eael-google-map' => 'eael-adv-google-map',
'eael-instafeed' => 'eael-instagram-gallery',
'eael-ninja' => 'eael-ninja-form',
];
}
/**
* save_widgets_list
* save widget list and custom js data in option table
* @param int $post_id
* @param array $list
* @param string $custom_js
*
* @return bool|mixed
*/
public function save_widgets_list( $post_id, $list, $custom_js = '' ) {
if ( \defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return $post_id;
}
$documents = is_object( Plugin::$instance->documents ) ? Plugin::$instance->documents->get( $post_id ) : [];
if ( ! in_array( get_post_status( $post_id ), [ 'publish', 'private' ] ) || ( is_object( $documents ) && ! $documents->is_built_with_elementor() ) ) {
return false;
}
if ( in_array( get_post_meta( $post_id, '_elementor_template_type', true ), $this->excluded_template_type() ) ) {
return false;
}
if ( $custom_js !== false ) {
update_post_meta( $post_id, '_eael_custom_js', $custom_js );
}
if ( md5( implode( '', (array) $list ) ) == md5( implode( '', (array) get_post_meta( $post_id, self::ELEMENT_KEY, true ) ) ) ) {
return false;
}
try {
update_post_meta( $post_id, self::ELEMENT_KEY, $list );
$this->remove_files( $post_id );
if ( $this->has_exist( $post_id ) ) {
$this->update_asset( $post_id, $list );
}
return true;
} catch ( \Exception $e ) {
return false;
}
}
/**
* generate_script
* create js/css file as per widget loaded in page
* @param int $post_id
* @param array $elements
* @param string $context
* @param string $ext
*/
public function generate_script( $post_id, $elements, $context, $ext ) {
// if folder not exists, create new folder
if ( ! file_exists( EAEL_ASSET_PATH ) ) {
wp_mkdir_p( EAEL_ASSET_PATH );
}
// naming asset file
$file_name = 'eael' . ( $post_id ? '-' . $post_id : '' ) . '.' . $ext;
// output asset string
$output = $this->generate_strings( $elements, $context, $ext );
// write to file
$file_path = $this->safe_path( EAEL_ASSET_PATH . DIRECTORY_SEPARATOR . $file_name );
file_put_contents( $file_path, $output );
}
/**
* generate_strings
* Load assets for inline loading
* @param string $elements
* @param string $context
* @param string $ext
*
* @return string
*/
public function generate_strings( $elements, $context, $ext ) {
$output = '';
$paths = $this->generate_dependency( $elements, $context, $ext );
if ( ! empty( $paths ) ) {
foreach ( $paths as $path ) {
$output .= file_get_contents( $this->safe_path( $path ) );
}
}
return $output;
}
/**
* generate_dependency
* Load core library for widget list which are defined on config.php file
* @param array $elements
* @param string $context
* @param string $type
*
* @return array
*/
public function generate_dependency( $elements, $context, $type ) {
$lib = [ 'view' => [], 'edit' => [] ];
$self = [ 'general' => [], 'view' => [], 'edit' => [] ];
if ( $type == 'js' ) {
$self['general'][] = EAEL_PLUGIN_PATH . 'assets/front-end/js/view/general.min.js';
$self['edit'][] = EAEL_PLUGIN_PATH . 'assets/front-end/js/edit/promotion.min.js';
} else if ( $type == 'css' && ! $this->is_edit_mode() ) {
$self['view'][] = EAEL_PLUGIN_PATH . "assets/front-end/css/view/general.min.css";
}
foreach ( $elements as $element ) {
if ( isset( $this->registered_elements[ $element ] ) ) {
if ( ! empty( $this->registered_elements[ $element ]['dependency'][ $type ] ) ) {
foreach ( $this->registered_elements[ $element ]['dependency'][ $type ] as $file ) {
if ( ! empty( $file['type'] ) && ! empty( $file['context'] ) && ! empty( $file['file'] ) ) {
${$file['type']}[ $file['context'] ][] = $file['file'];
}
}
}
} elseif ( isset( $this->registered_extensions[ $element ] ) ) {
if ( ! empty( $this->registered_extensions[ $element ]['dependency'][ $type ] ) ) {
foreach ( $this->registered_extensions[ $element ]['dependency'][ $type ] as $file ) {
if ( ! empty( $file['type'] ) && ! empty( $file['context'] ) && ! empty( $file['file'] ) ) {
${$file['type']}[ $file['context'] ][] = $file['file'];
}
}
}
}
}
if ( $context == 'view' ) {
return array_unique( array_merge( $lib['view'], $self['view'] ) );
}
return array_unique( array_merge( $lib['view'], $lib['edit'], $self['edit'], $self['view'] ) );
}
/**
* has_exist
* @param $post_id
* check widget list already saved in option table weather load or not
* @return bool
*/
public function has_exist( $post_id ) {
$status = get_post_meta( $post_id, self::ELEMENT_KEY, true );
return ! empty( $status );
}
/**
* update_asset
* @param int $post_id
* @param $elements
*/
public function update_asset( $post_id, $elements ) {
if ( $this->css_print_method != 'internal' ) {
$this->generate_script( $post_id, $elements, 'view', 'css' );
}
if ( $this->js_print_method != 'internal' ) {
$this->generate_script( $post_id, $elements, 'view', 'js' );
}
}
/**
* excluded_template_type
* @return string[]
*/
public function excluded_template_type() {
return [
'kit',
];
}
}

View File

@@ -0,0 +1,108 @@
<?php
namespace Essential_Addons_Elementor\Classes;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
class Migration
{
use \Essential_Addons_Elementor\Traits\Core;
use \Essential_Addons_Elementor\Traits\Library;
/**
* Plugin activation hook
*
* @since 3.0.0
*/
public function plugin_activation_hook()
{
// remove old cache files
$this->empty_dir(EAEL_ASSET_PATH);
//check setup wizard condition
$this->enable_setup_wizard();
// save default values
$this->set_default_values();
}
/**
* Plugin deactivation hook
*
* @since 3.0.0
*/
public function plugin_deactivation_hook()
{
$this->empty_dir(EAEL_ASSET_PATH);
}
/**
* Plugin upgrade hook
*
* @since 3.0.0
*/
public function plugin_upgrade_hook( $upgrader_object, $options ) {
if ( isset( $options['action'], $options['type'] ) && $options['action'] === 'update' && $options['type'] === 'plugin' ) {
if ( ( isset( $options['plugins'] ) &&
( in_array( EAEL_PLUGIN_BASENAME, $options['plugins'] ) ||
in_array( 'essential-addons-elementor/essential_adons_elementor.php', $options['plugins'] )
)
) || ( isset( $options['plugin'] ) &&
in_array( $options['plugin'], [ EAEL_PLUGIN_BASENAME, 'essential-addons-elementor/essential_adons_elementor.php' ] )
)
) {
// remove old cache files
$this->empty_dir( EAEL_ASSET_PATH );
}
}
}
/**
* Plugin migrator
*
* @since 3.0.0
*/
public function migrator() {
// set current version to db
if ( get_option( 'eael_version' ) != EAEL_PLUGIN_VERSION ) {
// update plugin version
update_option( 'eael_version', EAEL_PLUGIN_VERSION );
}
add_action( 'eael_after_clear_cache_files', [ $this, 'reduce_options_data' ] );
}
public function reduce_options_data() {
$status = get_transient( 'eael_reduce_op_table_data' );
if ( $status ) {
return false;
}
global $wpdb;
$sql = "from {$wpdb->options} as options_tb
inner join (SELECT option_id FROM {$wpdb->options}
WHERE ((option_name like '%\_eael_elements' and LENGTH(option_name) = 23 )
or (option_name like '%\_eael_custom_js' and LENGTH(option_name) = 24)
or (option_name like '%\_eael_updated_at' and LENGTH(option_name) = 25)
or (option_name = 'eael_reduce_op_table_data')
or (option_name = 'eael_remove_old_cache')
or (option_name = 'eael_editor_updated_at')
or (option_name like 'eael_login_error_%'))
) AS options_tb2
ON options_tb2.option_id = options_tb.option_id";
$selection_sql = "select count(options_tb.option_id) as total " . $sql;
$results = $wpdb->get_var( $selection_sql );
if ( $results > 0 ) {
$deletiation_sql = "delete options_tb " . $sql;
$wpdb->query( $deletiation_sql );
}
set_transient( 'eael_reduce_op_table_data', 1, DAY_IN_SECONDS );
wp_clear_scheduled_hook( 'eael_remove_unused_options_data' );
}
}

View File

@@ -0,0 +1,982 @@
<?php
/**
* Plugin_Usage_Tracker
* This class is responsible for data sending to insights.
* @version 3.0.0
*/
namespace Essential_Addons_Elementor\Classes;
/**
* Exit if accessed directly
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Main SDK for Plugin_Usage_Tracker.
*/
class Plugin_Usage_Tracker {
/**
* WP Insights Version
*/
const WPINS_VERSION = '3.0.3';
/**
* API URL
*/
const API_URL = 'https://send.wpinsight.com/process-plugin-data';
/**
* Installed Plugin File
*
* @var string
*/
private $plugin_file = null;
/**
* Installed Plugin Name
*
* @var string
*/
private $plugin_name = null;
/**
* How often the event should subsequently
* @var string
*/
public $recurrence = 'daily';
private $event_hook = null;
/**
* Instace of Plugin_Usage_Tracker
* @var Plugin_Usage_Tracker
*/
private static $_instance = null;
private $disabled_wp_cron;
private $enable_self_cron;
private $require_optin;
private $include_goodbye_form;
private $marketing;
private $options;
private $item_id;
private $notice_options;
/**
* Get Instance of Plugin_Usage_Tracker
* @return Plugin_Usage_Tracker
*/
public static function get_instance( $plugin_file, $args = [] ){
if( is_null( static::$_instance ) ) {
static::$_instance = new static( $plugin_file, $args );
}
return static::$_instance;
}
/**
* Automatically Invoked when initialized.
*
* @param array $args
*/
public function __construct( $plugin_file, $args = [] ){
$this->plugin_file = $plugin_file;
$this->plugin_name = basename( $this->plugin_file, '.php' );
$this->disabled_wp_cron = defined('DISABLE_WP_CRON') && DISABLE_WP_CRON == true;
$this->enable_self_cron = $this->disabled_wp_cron == true ? true : false;
$this->event_hook = 'put_do_weekly_action';
$this->require_optin = isset( $args['opt_in'] ) ? $args['opt_in'] : true;
$this->include_goodbye_form = isset( $args['goodbye_form'] ) ? $args['goodbye_form'] : true;
$this->marketing = isset( $args['email_marketing'] ) ? $args['email_marketing'] : true;
$this->options = isset( $args['options'] ) ? $args['options'] : [];
$this->item_id = isset( $args['item_id'] ) ? $args['item_id'] : false;
/**
* Activation Hook
*/
register_activation_hook( $this->plugin_file, array( $this, 'activate_this_plugin' ) );
/**
* Deactivation Hook
*/
register_deactivation_hook( $this->plugin_file, array( $this, 'deactivate_this_plugin' ) );
}
/**
* When user agreed to opt-in tracking schedule is enabled.
* @since 3.0.0
*/
public function schedule_tracking() {
if( $this->disabled_wp_cron ) {
return;
}
if ( ! wp_next_scheduled( $this->event_hook ) ) {
wp_schedule_event( time(), $this->recurrence, $this->event_hook );
}
}
/**
* Add the schedule event if the plugin is tracked.
*
* @return void
*/
public function activate_this_plugin(){
$allow_tracking = $this->is_tracking_allowed();
if( ! $allow_tracking ) {
return;
}
$this->schedule_tracking();
}
/**
* Remove the schedule event when plugin is deactivated and send the deactivated reason to inishghts if user submitted.
* @since 3.0.0
*/
public function deactivate_this_plugin() {
/**
* Check tracking is allowed or not.
*/
$allow_tracking = $this->is_tracking_allowed();
if( ! $allow_tracking ) {
return;
}
$body = $this->get_data();
$body['status'] = 'Deactivated';
$body['deactivated_date'] = time();
// Check deactivation reason and add for insights data.
if( false !== get_option( 'wpins_deactivation_reason_' . $this->plugin_name ) ) {
$body['deactivation_reason'] = get_option( 'wpins_deactivation_reason_' . $this->plugin_name );
}
if( false !== get_option( 'wpins_deactivation_details_' . $this->plugin_name ) ) {
$body['deactivation_details'] = get_option( 'wpins_deactivation_details_' . $this->plugin_name );
}
$this->send_data( $body );
delete_option( 'wpins_deactivation_reason_' . $this->plugin_name );
delete_option( 'wpins_deactivation_details_' . $this->plugin_name );
/**
* Clear the event schedule.
*/
if( ! $this->disabled_wp_cron ) {
wp_clear_scheduled_hook( $this->event_hook );
}
}
/**
* Initial Method to Hook Everything.
* @return void
*/
public function init(){
// $this->clicked();
add_action('wpdeveloper_notice_clicked_for_' . $this->plugin_name, array($this, 'clicked'));
add_action( $this->event_hook, array( $this, 'do_tracking' ) );
// For Test
// add_action( 'admin_init', array( $this, 'force_tracking' ) );
// add_action( 'admin_notices', array( $this, 'notice' ) );
add_action('wpdeveloper_optin_notice_for_' . $this->plugin_name, array($this, 'notice'));
/**
* Deactivation Reason Form and Submit Data to Insights.
*/
add_filter( 'plugin_action_links_' . plugin_basename( $this->plugin_file ), array( $this, 'deactivate_action_links' ) );
add_action( 'admin_footer-plugins.php', array( $this, 'deactivate_reasons_form' ) );
add_action( 'wp_ajax_deactivation_form_' . esc_attr( $this->plugin_name ), array( $this, 'deactivate_reasons_form_submit' ) );
}
/**
* For Redirecting Current Page without Arguments!
*
* @return void
*/
private function redirect_to(){
$request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
$query_string = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY );
parse_str( $query_string, $current_url );
$unset_array = array( 'dismiss', 'plugin', '_wpnonce', 'later', 'plugin_action', 'marketing_optin' );
foreach( $unset_array as $value ) {
if( isset( $current_url[ $value ] ) ) {
unset( $current_url[ $value ] );
}
}
$current_url = http_build_query($current_url);
$redirect_url = $request_uri . '?' . $current_url;
return $redirect_url;
}
/**
* This method forcing the do_tracking method to execute instant.
* @return void
*/
public function force_tracking(){
$this->do_tracking( true );
}
/**
* This method is responsible for all the magic from the front of the plugin.
* @since 3.0.0
* @param $force Force tracking if it's not the correct time to track/
*/
public function do_tracking( $force = false ) {
/**
* Check URL is set or not.
*/
if ( empty( self::API_URL ) ) {
return;
}
/**
* Check is tracking allowed or not.
*/
if( ! $this->is_tracking_allowed() ) {
return;
}
/**
* Check is this the correct time to track or not.
* or Force to track.
*/
if( ! $this->is_time_to_track() && ! $force ) {
return;
}
/**
* Get All Data.
*/
$body = $this->get_data();
/**
* Send all data.
*/
return $this->send_data( $body );
}
/**
* Is tracking allowed?
* @since 1.0.0
*/
private function is_tracking_allowed() {
// First, check if the user has changed their mind and opted out of tracking
if( $this->has_user_opted_out() ) {
$this->set_is_tracking_allowed( false, $this->plugin_name );
return false;
}
// The wpins_allow_tracking option is an array of plugins that are being tracked
$allow_tracking = get_option( 'wpins_allow_tracking' );
// If this plugin is in the array, then tracking is allowed
if( isset( $allow_tracking[$this->plugin_name] ) ) {
return true;
}
return false;
}
/**
* Set a flag in DB If tracking is allowed.
*
* @since 3.0.0
* @param $is_allowed Boolean true if is allowed.
*/
public function set_is_tracking_allowed( $is_allowed, $plugin = null ) {
if( empty( $plugin ) ) {
$plugin = $this->plugin_name;
}
/**
* Get All Tracked Plugin List using this Tracker.
*/
$allow_tracking = get_option( 'wpins_allow_tracking' );
/**
* Check user is opted out for tracking or not.
*/
if( $this->has_user_opted_out() ) {
if( isset( $allow_tracking[$plugin] ) ) {
unset( $allow_tracking[$plugin] );
}
} else if( $is_allowed || ! $this->require_optin ) {
/**
* If user has agreed to allow tracking
*/
if( empty( $allow_tracking ) || ! is_array( $allow_tracking ) ) {
$allow_tracking = array( $plugin => $plugin );
} else {
$allow_tracking[$plugin] = $plugin;
}
} else {
if( isset( $allow_tracking[$plugin] ) ) {
unset( $allow_tracking[$plugin] );
}
}
update_option( 'wpins_allow_tracking', $allow_tracking );
}
/**
* Check the user has opted out or not.
*
* @since 3.0.0
* @return Boolean
*/
protected function has_user_opted_out() {
if( ! empty( $this->options ) ) {
foreach( $this->options as $option_name ) {
$options = get_option( $option_name );
if( ! empty( $options['wpins_opt_out'] ) ) {
return true;
}
}
}
return false;
}
/**
* Check if it's time to track
*
* @since 3.0.0
*/
public function is_time_to_track() {
$track_times = get_option( 'wpins_last_track_time', array() );
return ! isset( $track_times[$this->plugin_name] ) ? true :
( ( isset( $track_times[$this->plugin_name] ) && $track_times[$this->plugin_name] ) < strtotime( '-1 day' ) ? true : false );
}
/**
* Set tracking time.
*
* @since 3.0.0
*/
public function set_track_time() {
$track_times = get_option( 'wpins_last_track_time', array() );
$track_times[ $this->plugin_name ] = time();
update_option( 'wpins_last_track_time', $track_times );
}
/**
* This method is responsible for collecting all data.
*
* @since 3.0.0
*/
public function get_data() {
$body = array(
'plugin_slug' => sanitize_text_field( $this->plugin_name ),
'url' => get_bloginfo( 'url' ),
'site_name' => get_bloginfo( 'name' ),
'site_version' => get_bloginfo( 'version' ),
'site_language' => get_bloginfo( 'language' ),
'charset' => get_bloginfo( 'charset' ),
'wpins_version' => self::WPINS_VERSION,
'php_version' => phpversion(),
'multisite' => is_multisite(),
'file_location' => __FILE__
);
// Collect the email if the correct option has been set
if( $this->marketing ) {
if( ! function_exists( 'wp_get_current_user' ) ) {
include ABSPATH . 'wp-includes/pluggable.php';
}
$current_user = wp_get_current_user();
$email = $current_user->user_email;
if( is_email( $email ) ) {
$body['email'] = $email;
} else {
$email = get_option( 'admin_email' );
if( is_email($email) ) {
$body['email'] = $email;
}
}
}
$body['marketing_method'] = $this->marketing;
$body['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '';
/**
* Collect all active and inactive plugins
*/
if( ! function_exists( 'get_plugins' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugins = array_keys( get_plugins() );
$active_plugins = is_network_admin() ? array_keys( get_site_option( 'active_sitewide_plugins', array() ) ) : get_option( 'active_plugins', array() );
foreach ( $plugins as $key => $plugin ) {
if ( in_array( $plugin, $active_plugins ) ) {
unset( $plugins[$key] );
}
}
$body['active_plugins'] = $active_plugins;
$body['inactive_plugins'] = $plugins;
/**
* Text Direction.
*/
$body['text_direction'] = ( function_exists( 'is_rtl' ) ? ( is_rtl() ? 'RTL' : 'LTR' ) : 'NOT SET' );
/**
* Get Our Plugin Data.
* @since 3.0.0
*/
$plugin = $this->plugin_data();
if( empty( $plugin ) ) {
$body['message'] .= __( 'We can\'t detect any plugin information. This is most probably because you have not included the code in the plugin main file.', 'disable-comments' );
$body['status'] = 'NOT FOUND';
} else {
if( isset( $plugin['Name'] ) ) {
$body['plugin'] = sanitize_text_field( $plugin['Name'] );
}
if( isset( $plugin['Version'] ) ) {
$body['version'] = sanitize_text_field( $plugin['Version'] );
}
$body['status'] = 'Active';
}
/**
* Get active theme name and version
* @since 3.0.0
*/
$theme = wp_get_theme();
if( $theme->Name ) {
$body['theme'] = sanitize_text_field( $theme->Name );
}
if( $theme->Version ) {
$body['theme_version'] = sanitize_text_field( $theme->Version );
}
if ( ! empty( $this->get_used_elements_count() ) ) {
$body['optional_data'] = $this->get_used_elements_count();
}
return $body;
}
/**
* Collect plugin data,
* Retrieve current plugin information
*
* @since 3.0.0
*/
public function plugin_data() {
if( ! function_exists( 'get_plugin_data' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugin = get_plugin_data( $this->plugin_file );
return $plugin;
}
/**
* Send the data to insights.
* @since 3.0.0
*/
public function send_data( $body ) {
/**
* Get SITE ID
*/
$site_id_key = "wpins_{$this->plugin_name}_site_id";
$site_id = get_option( $site_id_key, false );
$failed_data = [];
$site_url = get_bloginfo( 'url' );
$original_site_url = get_option( "wpins_{$this->plugin_name}_original_url", false );
if( ( $original_site_url === false || $original_site_url != $site_url ) && version_compare( $body['wpins_version'], '3.0.1', '>=' ) ) {
$site_id = false;
}
/**
* Send Initial Data to API
*/
if( $site_id == false && $this->item_id !== false ) {
if( isset( $_SERVER['REMOTE_ADDR'] ) && ! empty( $_SERVER['REMOTE_ADDR'] && $_SERVER['REMOTE_ADDR'] != '127.0.0.1' ) ) {
$country_request = wp_remote_get( 'http://ip-api.com/json/'. $_SERVER['REMOTE_ADDR'] .'?fields=country');
if( ! is_wp_error( $country_request ) && $country_request['response']['code'] == 200 ) {
$ip_data = json_decode( $country_request["body"] );
$body['country'] = isset( $ip_data->country ) ? $ip_data->country : 'NOT SET';
}
}
$body['plugin_slug'] = $this->plugin_name;
$body['url'] = $site_url;
$body['item_id'] = $this->item_id;
$request = $this->remote_post( $body );
if( ! is_wp_error( $request ) && $request['response']['code'] == 200 ) {
$retrieved_body = json_decode( wp_remote_retrieve_body( $request ), true );
if( is_array( $retrieved_body ) && isset( $retrieved_body['siteId'] ) ) {
update_option( $site_id_key, $retrieved_body['siteId'] );
update_option( "wpins_{$this->plugin_name}_original_url", $site_url );
update_option( "wpins_{$this->plugin_name}_{$retrieved_body['siteId']}", $body );
}
} else {
$failed_data = $body;
}
}
$site_id_data_key = "wpins_{$this->plugin_name}_{$site_id}";
$site_id_data_failed_key = "wpins_{$this->plugin_name}_{$site_id}_send_failed";
if( $site_id != false ) {
$old_sent_data = get_option( $site_id_data_key, [] );
$diff_data = $this->diff( $body, $old_sent_data );
$failed_data = get_option( $site_id_data_failed_key, [] );
if( ! empty( $failed_data ) && $diff_data != $failed_data ) {
$failed_data = array_merge( $failed_data, $diff_data );
}
}
if( ! empty( $failed_data ) && $site_id != false ) {
$failed_data['plugin_slug'] = $this->plugin_name;
$failed_data['url'] = $site_url;
$failed_data['site_id'] = $site_id;
if( $original_site_url != false ) {
$failed_data['original_url'] = $original_site_url;
}
$request = $this->remote_post( $failed_data );
if( ! is_wp_error( $request ) ) {
delete_option( $site_id_data_failed_key );
$replaced_data = array_merge( $old_sent_data, $failed_data );
update_option( $site_id_data_key, $replaced_data );
}
}
if( ! empty( $diff_data ) && $site_id != false && empty( $failed_data ) ) {
$diff_data['plugin_slug'] = $this->plugin_name;
$diff_data['url'] = $site_url;
$diff_data['site_id'] = $site_id;
if( $original_site_url != false ) {
$diff_data['original_url'] = $original_site_url;
}
$request = $this->remote_post( $diff_data );
if( is_wp_error( $request ) ) {
update_option( $site_id_data_failed_key, $diff_data );
} else {
$replaced_data = array_merge( $old_sent_data, $diff_data );
update_option( $site_id_data_key, $replaced_data );
}
}
$this->set_track_time();
if( isset( $request ) && is_wp_error( $request ) ) {
return $request;
}
if( isset( $request ) ) {
return true;
}
return false;
}
/**
* WP_REMOTE_POST method responsible for send data to the API_URL
*
* @param array $data
* @param array $args
* @return void
*/
protected function remote_post( $data = array(), $args = array() ){
if( empty( $data ) ) {
return;
}
$args = wp_parse_args( $args, array(
'method' => 'POST',
'timeout' => 30,
'redirection' => 5,
'httpversion' => '1.1',
'blocking' => true,
'body' => $data,
'user-agent' => 'PUT/1.0.0; ' . get_bloginfo( 'url' )
));
$request = wp_remote_post( esc_url( self::API_URL ), $args );
if( is_wp_error( $request ) || ( isset( $request['response'], $request['response']['code'] ) && $request['response']['code'] != 200 ) ) {
return new \WP_Error( 500, 'Something went wrong.' );
}
return $request;
}
/**
* Difference between old and new data
*
* @param array $new_data
* @param array $old_data
* @return void
*/
protected function diff( $new_data, $old_data ){
$data = [];
if( ! empty( $new_data ) ) {
foreach( $new_data as $key => $value ) {
if( isset( $old_data[ $key ] ) ) {
if( $old_data[ $key ] == $value ) {
continue;
}
}
$data[ $key ] = $value;
}
}
return $data;
}
/**
* Display the admin notice to users to allow them to opt in
*
* @since 3.0.0
*/
public function notice() {
/**
* Return if notice is not set.
*/
if( ! isset( $this->notice_options['notice'] ) ) {
return;
}
/**
* Check is allowed or blocked for notice.
*/
$block_notice = get_option( 'wpins_block_notice' );
if( isset( $block_notice[$this->plugin_name] ) ) {
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$url_yes = add_query_arg( [
'plugin' => $this->plugin_name,
'plugin_action' => 'yes',
] );
$url_no = add_query_arg( array(
'plugin' => $this->plugin_name,
'plugin_action' => 'no'
) );
$url_yes = wp_nonce_url( $url_yes, '_wpnonce_optin_' . $this->plugin_name );
$url_no = wp_nonce_url( $url_no, '_wpnonce_optin_' . $this->plugin_name );
// Decide on notice text
$notice_text = $this->notice_options['notice'] . ' <a href="#" class="wpinsights-'. esc_attr( $this->plugin_name ) .'-collect">'. $this->notice_options['consent_button_text'] .'</a>';
$extra_notice_text = $this->notice_options['extra_notice'];
$output = '';
$output .= '<div class="notice notice-info updated put-dismiss-notice">';
$output .= '<p>'. $notice_text .'</p>';
$output .= '<div class="wpinsights-data" style="display: none;">';
$output .= '<p>'. $extra_notice_text .'</p>';
$output .= '</div>';
$output .= '<p>';
$output .= '<a href="'. esc_url( $url_yes ) .'" class="button-primary">'. $this->notice_options['yes'] .'</a>&nbsp;';
$output .= '<a href="'. esc_url( $url_no ) .'" class="button-secondary">'. $this->notice_options['no'] .'</a>';
$output .= '</p>';
$output .= "<script type='text/javascript'>jQuery('.wpinsights-". esc_attr( $this->plugin_name ) ."-collect').on('click', function(e) {e.preventDefault();jQuery('.wpinsights-data').slideToggle('fast');});</script>";
$output .= '</div>';
printf( '%1$s', $output );
}
/**
* Set all notice options to customized notice.
*
* @since 3.0.0
* @param array $options
* @return void
*/
public function set_notice_options( $options = [] ){
$default_options = [
'consent_button_text' => __( 'What we collect.', 'disable-comments' ),
'yes' => __( 'Sure, I\'d like to help', 'disable-comments' ),
'no' => __( 'No Thanks.', 'disable-comments' ),
];
$options = wp_parse_args( $options, $default_options );
$this->notice_options = $options;
}
/**
* Responsible for track the click from Notice.
* @return void
*/
public function clicked(){
if ( isset( $_GET['_wpnonce'] ) && isset( $_GET['plugin'] ) && trim( $_GET['plugin'] ) === $this->plugin_name && isset( $_GET['plugin_action'] ) ) {
if ( ! wp_verify_nonce( $_GET['_wpnonce'], '_wpnonce_optin_' . $this->plugin_name ) ) {
return;
}
if( isset( $_GET['tab'] ) && $_GET['tab'] === 'plugin-information' ) {
return;
}
$plugin = sanitize_text_field( $_GET['plugin'] );
$action = sanitize_text_field( $_GET['plugin_action'] );
if( $action == 'yes' ) {
$this->schedule_tracking();
$this->set_is_tracking_allowed( true, $plugin );
if( $this->do_tracking( true ) ) {
$this->update_block_notice( $plugin );
}
/**
* Redirect User To the Current URL, but without set query arguments.
*/
wp_safe_redirect( $this->redirect_to() );
} else {
$this->set_is_tracking_allowed( false, $plugin );
$this->update_block_notice( $plugin );
}
}
}
/**
* Set if we should block the opt-in notice for this plugin
*
* @since 3.0.0
*/
public function update_block_notice( $plugin = null ) {
if( empty( $plugin ) ) {
$plugin = $this->plugin_name;
}
$block_notice = get_option( 'wpins_block_notice' );
if( empty( $block_notice ) || ! is_array( $block_notice ) ) {
$block_notice = array( $plugin => $plugin );
} else {
$block_notice[$plugin] = $plugin;
}
update_option( 'wpins_block_notice', $block_notice );
}
/**
* AJAX callback when the deactivated form is submitted.
* @since 3.0.0
*/
public function deactivate_reasons_form_submit() {
check_ajax_referer( 'wpins_deactivation_nonce', 'security' );
if( isset( $_POST['values'] ) ) {
$values = sanitize_text_field( $_POST['values'] );
update_option( 'wpins_deactivation_reason_' . $this->plugin_name, $values );
}
if( isset( $_POST['details'] ) ) {
$details = sanitize_text_field( $_POST['details'] );
update_option( 'wpins_deactivation_details_' . $this->plugin_name, $details );
}
echo 'success';
wp_die();
}
/**
* Filter the deactivation link to allow us to present a form when the user deactivates the plugin
* @since 3.0.0
*/
public function deactivate_action_links( $links ) {
/**
* Check is tracking allowed or not.
*/
if( ! $this->is_tracking_allowed() ) {
return $links;
}
if( isset( $links['deactivate'] ) && $this->include_goodbye_form ) {
$deactivation_link = $links['deactivate'];
/**
* Change the default deactivate button link.
*/
$deactivation_link = str_replace( '<a ', '<div class="wpinsights-goodbye-form-wrapper-'. esc_attr( $this->plugin_name ) .'"><div class="wpinsights-goodbye-form-bg"></div><span class="wpinsights-goodbye-form" id="wpinsights-goodbye-form"></span></div><a onclick="javascript:event.preventDefault();" id="wpinsights-goodbye-link-' . esc_attr( $this->plugin_name ) . '" ', $deactivation_link );
$links['deactivate'] = $deactivation_link;
}
return $links;
}
/**
* ALL Deactivate Reasons.
* @since 3.0.0
*/
public function deactivation_reasons() {
$form = array();
$form['heading'] = __( 'Sorry to see you go', 'disable-comments' );
$form['body'] = __( 'Before you deactivate the plugin, would you quickly give us your reason for doing so?', 'disable-comments' );
$form['options'] = array(
__( 'I no longer need the plugin', 'disable-comments' ),
[
'label' => __( 'I found a better plugin', 'disable-comments' ),
'extra_field' => __( 'Please share which plugin', 'disable-comments' )
],
__( "I couldn't get the plugin to work", 'disable-comments' ),
__( 'It\'s a temporary deactivation', 'disable-comments' ),
[
'label' => __( 'Other', 'disable-comments' ),
'extra_field' => __( 'Please share the reason', 'disable-comments' ),
'type' => 'textarea'
]
);
return apply_filters( 'wpins_form_text_' . $this->plugin_name, $form );
}
/**
* Deactivate Reasons Form.
* This form will appears when user wants to deactivate the plugin to send you deactivated reasons.
*
* @since 3.0.0
*/
public function deactivate_reasons_form() {
$form = $this->deactivation_reasons();
$class_plugin_name = esc_attr( $this->plugin_name );
$html = '<div class="wpinsights-goodbye-form-head"><strong>' . esc_html( $form['heading'] ) . '</strong></div>';
$html .= '<div class="wpinsights-goodbye-form-body"><p class="wpinsights-goodbye-form-caption">' . esc_html( $form['body'] ) . '</p>';
if( is_array( $form['options'] ) ) {
$html .= '<div id="wpinsights-goodbye-options" class="wpinsights-goodbye-options"><ul>';
foreach( $form['options'] as $option ) {
if( is_array( $option ) ) {
$id = strtolower( str_replace( " ", "_", esc_attr( $option['label'] ) ) );
$id = $id . '_' . $class_plugin_name;
$html .= '<li class="has-goodbye-extra">';
$html .= '<input type="radio" name="wpinsights-'. esc_attr( $class_plugin_name ) .'-goodbye-options" id="' . esc_attr( $id ) . '" value="' . esc_attr( $option['label'] ) . '">';
$html .= '<div><label for="' . $id . '">' . esc_attr( $option['label'] ) . '</label>';
if( isset( $option[ 'extra_field' ] ) && ! isset( $option['type'] )) {
$html .= '<input type="text" style="display: none" name="'. esc_attr( $id ) .'" id="' . str_replace( " ", "", esc_attr( $option['extra_field'] ) ) . '" placeholder="' . esc_attr( $option['extra_field'] ) . '">';
}
if( isset( $option[ 'extra_field' ] ) && isset( $option['type'] )) {
$html .= '<'. $option['type'] .' style="display: none" type="text" name="'. esc_attr( $id ) .'" id="' . str_replace( " ", "", esc_attr( $option['extra_field'] ) ) . '" placeholder="' . esc_attr( $option['extra_field'] ) . '"></' . $option['type'] . '>';
}
$html .= '</div></li>';
} else {
$id = strtolower( str_replace( " ", "_", esc_attr( $option ) ) );
$id = $id . '_' . $class_plugin_name;
$html .= '<li><input type="radio" name="wpinsights-'. $class_plugin_name .'-goodbye-options" id="' . esc_attr( $id ) . '" value="' . esc_attr( $option ) . '"> <label for="' . $id . '">' . esc_attr( $option ) . '</label></li>';
}
}
$html .= '</ul></div><!-- .wpinsights-'. $class_plugin_name .'-goodbye-options -->';
}
$html .= '</div><!-- .wpinsights-goodbye-form-body -->';
$html .= '<p class="deactivating-spinner"><span class="spinner"></span> ' . __( 'Submitting form', 'disable-comments' ) . '</p>';
$wrapper_class = '.wpinsights-goodbye-form-wrapper-'. $class_plugin_name;
$styles = '';
$styles .= '<style type="text/css">';
$styles .= '.wpinsights-form-active-' . $class_plugin_name . ' .wpinsights-goodbye-form-bg {';
$styles .= 'background: rgba( 0, 0, 0, .8 );position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 9;';
$styles .= '}';
$styles .= $wrapper_class . '{';
$styles .= 'position: relative; display: none;';
$styles .= '}';
$styles .= '.wpinsights-form-active-' . $class_plugin_name . ' ' . $wrapper_class . '{';
$styles .= 'display: flex !important; position: fixed;top: 0;left: 0;width: 100%;height: 100%; justify-content: center; align-items: center;';
$styles .= '}';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form { display: none; }';
$styles .= '.wpinsights-form-active-' . $class_plugin_name . ' .wpinsights-goodbye-form {';
$styles .= 'position: relative !important; width: 550px; max-width: 80%; background: #fff; box-shadow: 2px 8px 23px 3px rgba(0,0,0,.2); border-radius: 3px; white-space: normal; overflow: hidden; display: block; z-index: 999999;';
$styles .= '}';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-head {';
$styles .= 'background: #fff; color: #495157; padding: 18px; box-shadow: 0 0 8px rgba(0,0,0,.1); font-size: 15px;';
$styles .= '}';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form .wpinsights-goodbye-form-head strong { font-size: 15px; }';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-body { padding: 8px 18px; color: #333; }';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-body label { padding-left: 5px; color: #6d7882; }';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-body .wpinsights-goodbye-form-caption {';
$styles .= 'font-weight: 500; font-size: 15px; color: #495157; line-height: 1.4;';
$styles .= '}';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-body #wpinsights-goodbye-options { padding-top: 5px; }';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-body #wpinsights-goodbye-options ul > li { margin-bottom: 15px; }';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-body #wpinsights-goodbye-options ul > li > div { display: inline; padding-left: 3px; }';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-body #wpinsights-goodbye-options ul > li > div > input, '. $wrapper_class .' .wpinsights-goodbye-form-body #wpinsights-goodbye-options ul > li > div > textarea {';
$styles .= 'margin: 10px 18px; padding: 8px; width: 80%;';
$styles .= '}';
$styles .= $wrapper_class . ' .deactivating-spinner { display: none; padding-bottom: 20px !important; }';
$styles .= $wrapper_class . ' .deactivating-spinner .spinner { float: none; margin: 4px 4px 0 18px; vertical-align: bottom; visibility: visible; }';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-footer { padding: 8px 18px; margin-bottom: 15px; }';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-footer > .wpinsights-goodbye-form-buttons { display: flex; align-items: center; justify-content: space-between; }';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-footer .wpinsights-submit-btn {';
$styles .= 'background-color: #f3bafd; -webkit-border-radius: 3px; border-radius: 3px; color: #0c0d0e; line-height: 1; padding: 10px 20px; font-size: 13px; font-weight: 500; text-transform: uppercase; transition: .3s;';
$styles .= '}';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-footer .wpinsights-submit-btn:hover {';
$styles .= 'background-color: #f5d0fe;';
$styles .= '}';
$styles .= $wrapper_class . ' .wpinsights-goodbye-form-footer .wpinsights-deactivate-btn {';
$styles .= 'font-size: 13px; color: #a4afb7; background: none; float: right; padding-right: 10px; width: auto; text-decoration: underline;';
$styles .= '}';
$styles .= $wrapper_class . ' .test {';
$styles .= '}';
$styles .= '</style>';
$styles .= '';
echo $styles;
?>
<script type="text/javascript">
jQuery(document).ready(function($){
$("#wpinsights-goodbye-link-<?php echo $class_plugin_name; ?>").on("click",function(){
// We'll send the user to this deactivation link when they've completed or dismissed the form
var url = document.getElementById("wpinsights-goodbye-link-<?php echo $class_plugin_name; ?>");
$('body').toggleClass('wpinsights-form-active-<?php echo $class_plugin_name; ?>');
$(".wpinsights-goodbye-form-wrapper-<?php echo $class_plugin_name; ?> #wpinsights-goodbye-form").fadeIn();
$(".wpinsights-goodbye-form-wrapper-<?php echo $class_plugin_name; ?> #wpinsights-goodbye-form").html( '<?php echo $html; ?>' + '<div class="wpinsights-goodbye-form-footer"><div class="wpinsights-goodbye-form-buttons"><a id="wpinsights-submit-form-<?php echo $class_plugin_name; ?>" class="wpinsights-submit-btn" href="#"><?php _e( 'Submit and Deactivate', 'disable-comments' ); ?></a>&nbsp;<a class="wpsp-put-deactivate-btn" href="'+url+'"><?php _e( 'Just Deactivate', 'disable-comments' ); ?></a></div></div>');
$('#wpinsights-submit-form-<?php echo $class_plugin_name; ?>').on('click', function(e){
// As soon as we click, the body of the form should disappear
$("#wpinsights-goodbye-form-<?php echo $class_plugin_name; ?> .wpinsights-goodbye-form-body").fadeOut();
$("#wpinsights-goodbye-form-<?php echo $class_plugin_name; ?> .wpinsights-goodbye-form-footer").fadeOut();
// Fade in spinner
$("#wpinsights-goodbye-form-<?php echo $class_plugin_name; ?> .deactivating-spinner").fadeIn();
e.preventDefault();
var checkedInput = $("input[name='wpinsights-<?php echo esc_attr( $class_plugin_name ); ?>-goodbye-options']:checked"),
checkedInputVal, details;
if( checkedInput.length > 0 ) {
checkedInputVal = checkedInput.val();
details = $('input[name="'+ checkedInput[0].id +'"], textarea[name="'+ checkedInput[0].id +'"]').val();
}
if( typeof details === 'undefined' ) {
details = '';
}
if( typeof checkedInputVal === 'undefined' ) {
checkedInputVal = 'No Reason';
}
var data = {
'action': 'deactivation_form_<?php echo esc_attr( $class_plugin_name ); ?>',
'values': checkedInputVal,
'details': details,
'security': "<?php echo wp_create_nonce ( 'wpins_deactivation_nonce' ); ?>",
'dataType': "json"
}
$.post(
ajaxurl,
data,
function(response){
// Redirect to original deactivation URL
window.location.href = url;
}
);
});
$('#wpinsights-goodbye-options > ul ').on('click', 'li label, li > input', function( e ){
var parent = $(this).parents('li');
parent.siblings().find('label').next('input, textarea').css('display', 'none');
parent.find('label').next('input, textarea').css('display', 'block');
});
// If we click outside the form, the form will close
$('.wpinsights-goodbye-form-bg').on('click',function(){
$("#wpinsights-goodbye-form").fadeOut();
$('body').removeClass('wpinsights-form-active-<?php echo esc_attr( $class_plugin_name ); ?>');
});
});
});
</script>
<?php }
/**
* Get Used Elements Count
* Get eael all used elements from all pages
* @return array
*
* @since 3.7.0
*/
public static function get_used_elements_count() {
global $wpdb;
$sql = "SELECT `post_id`
FROM $wpdb->postmeta
WHERE `meta_key` = '_eael_widget_elements'";
$post_ids = $wpdb->get_col( $sql );
$used_elements = [];
foreach ( $post_ids as $post_id ) {
$ea_elements = get_post_meta( (int) $post_id, '_eael_widget_elements', true );
$el_controls = get_post_meta( (int) $post_id, '_elementor_controls_usage', true );
if ( empty( $ea_elements ) || empty( $el_controls ) || ! is_array( $ea_elements ) || ! is_array( $el_controls ) ) {
continue;
}
foreach ( $ea_elements as $element ) {
$element_name = "eael-{$element}";
$replace_widget_name = array_flip( Elements_Manager::replace_widget_name() );
$count = 0;
if ( isset( $replace_widget_name[ $element_name ] ) ) {
$element_name = $replace_widget_name[ $element_name ];
}
if ( ! empty( $el_controls[ $element_name ] ) && is_array( $el_controls[ $element_name ] ) ) {
$count = $el_controls[ $element_name ]['count'];
}
$used_elements[ $element_name ] = isset( $used_elements[ $element_name ] ) ? $used_elements[ $element_name ] + $count : $count;
}
array_walk_recursive( $el_controls, function ( $value, $key ) use ( &$used_elements ) {
$element_name = '';
if ( $key === 'eael_particle_switch' ) {
$element_name = 'eael-section-particles';
} elseif ( $key === 'eael_parallax_switcher' ) {
$element_name = 'eael-section-parallax';
} elseif ( $key === 'eael_tooltip_section_enable' ) {
$element_name = 'eael-tooltip-section';
} elseif ( $key === 'eael_ext_content_protection' ) {
$element_name = 'eael-content-protection';
} elseif ( $key === 'eael_cl_enable' ) {
$element_name = 'eael-conditional-display';
}
if ( ! empty( $element_name ) ) {
$used_elements[ $element_name ] = isset( $used_elements[ $element_name ] ) ? $used_elements[ $element_name ] + $value : $value;
}
} );
}
return $used_elements;
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace Essential_Addons_Elementor\Classes;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly.
/**
* WPDeveloper Core Install
*/
class WPDeveloper_Core_Installer {
/**
* Plugin Base Name
*
* @var string
*/
private $plugin_basename;
/**
* Instantiate the class
*
* @param string $affiliate
*/
function __construct( $plugin_basename = '' ) {
$this->plugin_basename = $plugin_basename;
add_action( 'init', array( $this, 'init_hooks' ) );
}
/**
* Initialize the hooks
*
* @return void
*/
public function init_hooks() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
add_action( 'wp_ajax_wpdeveloper_upsale_core_install_' . $this->plugin_basename, array( $this, 'core_install' ) );
}
/**
* Fail if plugin installtion/activation fails
*
* @param Object $thing
*
* @return void
*/
public function fail_on_error( $thing ) {
if ( is_wp_error( $thing ) ) {
wp_send_json_error( $thing->get_error_message() );
}
}
/**
* Install Upsale Plugin
*
* @return void
*/
public function core_install() {
check_ajax_referer( 'wpdeveloper_upsale_core_install_' . $this->plugin_basename );
if ( ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( __( 'You don\'t have permission to install the plugins', 'essential-addons-for-elementor-lite' ) );
}
$plugin_slug = ( isset( $_POST['slug'] ) ) ? sanitize_text_field( $_POST['slug'] ) : '';
$plugin_file = ( isset( $_POST['file'] ) ) ? sanitize_text_field( $_POST['file'] ) : '';
if( empty( $plugin_file ) || empty( $plugin_slug ) ) {
wp_send_json_error( __( 'You don\'t have set any slug and file name to install the plugins', 'essential-addons-for-elementor-lite' ) );
}
$plugin_status = $this->install_plugin( $plugin_slug, $plugin_file );
$this->fail_on_error( $plugin_status );
wp_send_json_success();
}
/**
* Install and activate a plugin
*
* @param string $slug
* @param string $file
*
* @return WP_Error|null
*/
public function install_plugin( $slug, $file ) {
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$plugin_basename = $slug . '/' . $file;
// if exists and not activated
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_basename ) ) {
return activate_plugin( $plugin_basename );
}
// seems like the plugin doesn't exists. Download and activate it
$upgrader = new \Plugin_Upgrader( new \WP_Ajax_Upgrader_Skin() );
$api = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) );
$result = $upgrader->install( $api->download_link );
if ( is_wp_error( $result ) ) {
return $result;
}
return activate_plugin( $plugin_basename );
}
}

View File

@@ -0,0 +1,934 @@
<?php
namespace Essential_Addons_Elementor\Classes;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly.
use Essential_Addons_Elementor\Classes\Helper;
use Essential_Addons_Elementor\Classes\WPDeveloper_Core_Installer;
class WPDeveloper_Notice {
/**
* Admin Notice Key
*
* @var array
*/
const ADMIN_UPDATE_NOTICE_KEY = 'wpdeveloper_notices_seen';
/**
* All Data
* @var array
*/
private $data = array();
private $properties = array(
'links', 'message', 'thumbnail',
);
private $methods = array(
'message', 'thumbnail', 'classes'
);
/**
* cne_day == current_notice_end_day
*
* @var integer
*/
public $cne_time = '2 day';
public $maybe_later_time = '7 day';
public $finish_time = [];
/**
* Plugin Name
*
* @var string
*/
private $plugin_name;
/**
* Plugin File Name
* @var string
*/
private $plugin_file;
/**
* First Install Version Of The Plugin
*
* @var string
*/
private $version;
/**
* Saved Data in DB
* @var array
*/
private $options_data;
/**
* Current Timestamp
* @var integer
*/
public $timestamp;
/**
* Primary Notice Action
*
* @var string
*/
private $do_notice_action;
/**
* Default Options Set
*
* @var array
*/
public $options_args = array(
);
/**
* Notice ID for users.
* @var string
*/
private $notice_id;
/**
* Upsale Notice Arguments
* @var array
*/
public $upsale_args;
/**
* Revoke this function when the object is created.
*
* @param string $plugin_name
* @param string $version
*/
public function __construct( $plugin_file = '', $version = '' ) {
$this->plugin_file = $plugin_file;
$this->plugin_name = basename( $plugin_file, '.php' );
$this->version = $version;
$this->timestamp = intval( current_time( 'timestamp' ) );
$this->notice_id = 'wpdeveloper_notice_' . str_replace( '.', '_', $this->version );
$this->do_notice_action = 'wpdeveloper_notices_for_' . $this->plugin_name;
new WPDeveloper_Core_Installer( $this->plugin_name );
}
/**
* Initiate The Plugin
* @return void
*/
public function init(){
$this->migration();
add_action( 'init', array( $this, 'first_install_track') );
add_action( 'deactivate_' . $this->plugin_file, array( $this, 'first_install_end' ) );
add_action( 'init', array( $this, 'hooks' ) );
}
public function migration(){
$user_notices = $this->get_user_notices();
if( \version_compare( get_option( 'eael_version', false ), '3.7.2', '==' ) && ! get_option( 'eael_notice_migration', false ) ) {
if( is_array( $user_notices ) ) {
array_walk( $user_notices, function( $value, $key ){
array_walk( $value, function( $v, $k ){
array_walk( $v, function( $vv, $kk ){
update_user_meta( get_current_user_id(), $this->plugin_name . '_' . $vv, true );
} );
} );
} );
}
update_option( 'eael_notice_migration', true );
}
}
/**
* All Hooks
* @return void
*/
public function hooks(){
add_action( 'wpdeveloper_notice_clicked_for_' . $this->plugin_name, array( $this, 'clicked' ) );
add_action( 'wp_ajax_wpdeveloper_upsale_notice_dissmiss_for_' . $this->plugin_name, array( $this, 'upsale_notice_dissmiss' ) );
add_action( 'wp_ajax_wpdeveloper_notice_dissmiss_for_' . $this->plugin_name, array( $this, 'notice_dissmiss' ) );
add_action( 'wpdeveloper_before_notice_for_' . $this->plugin_name, array( $this, 'before' ) );
add_action( 'wpdeveloper_after_notice_for_' . $this->plugin_name, array( $this, 'after' ) );
add_action( 'wpdeveloper_before_upsale_notice_for_' . $this->plugin_name, array( $this, 'before_upsale' ) );
add_action( 'wpdeveloper_after_upsale_notice_for_' . $this->plugin_name, array( $this, 'after' ) );
add_action( $this->do_notice_action, array( $this, 'content' ) );
// if( current_user_can( 'install_plugins' ) ) {
if( isset( $_GET['plugin'] ) && $_GET['plugin'] == $this->plugin_name ) {
do_action( 'wpdeveloper_notice_clicked_for_' . $this->plugin_name );
/**
* Redirect User To the Current URL, but without set query arguments.
*/
wp_safe_redirect( $this->redirect_to() );
}
$return_notice = $this->next_notice();
$current_notice = current( $return_notice );
$next_notice = next( $return_notice );
$deserve_notice = $this->deserve_notice( $current_notice );
$options_data = $this->get_options_data();
$user_notices = $this->get_user_notices();
$notice_time = isset( $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] )
? $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] : $this->timestamp;
$next_notice_time = $next_notice ? $options_data[ $this->plugin_name ]['notice_will_show'][ $next_notice ] : $this->timestamp;
$current_notice_end = $this->makeTime( $notice_time, $this->cne_time );
if( ! $deserve_notice ) {
unset( $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] );
$this->update_options_data( $options_data[ $this->plugin_name ] );
}
if( $deserve_notice ) {
/**
* TODO: automatic maybe later setup with time.
*/
if( ( $this->timestamp >= $current_notice_end ) || ( $this->timestamp > $next_notice_time ) ) {
$this->maybe_later( $current_notice );
$notice_time = false;
}
if( isset( $this->finish_time[ $current_notice ] ) ) {
if( $this->timestamp >= strtotime( $this->finish_time[ $current_notice ] ) ) {
unset( $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] );
$this->update_options_data( $options_data[ $this->plugin_name ] );
$notice_time = false;
}
}
if( $notice_time != false ) {
if( $notice_time <= $this->timestamp ) {
if( $current_notice === 'upsale' ) {
$upsale_args = $this->get_upsale_args();
if( empty( $upsale_args ) ) {
unset( $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] );
$this->update_options_data( $options_data[ $this->plugin_name ] );
} else {
/**
* For Upsale Remove
* if the plugin is activated.
*/
if( isset( $upsale_args['condition'], $upsale_args['condition']['by'] ) ) {
switch( $upsale_args['condition']['by'] ) {
case 'class' :
if( isset( $upsale_args['condition']['class'] ) && class_exists( $upsale_args['condition']['class'] ) ) {
unset( $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] );
$this->update_options_data( $options_data[ $this->plugin_name ] );
return;
}
break;
case 'function' :
if( isset( $upsale_args['condition']['function'] ) && function_exists( $upsale_args['condition']['function'] ) ) {
unset( $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] );
$this->update_options_data( $options_data[ $this->plugin_name ] );
return;
}
break;
}
}
if ( ! function_exists( 'get_plugins' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
$pkey = $upsale_args['slug'] . '/' . $upsale_args['file'];
if( isset( $plugins[ $pkey ] ) ) {
$this->update( $current_notice );
return;
}
add_action( 'admin_notices', array( $this, 'upsale_notice' ) );
add_action( 'eael_admin_notices', array( $this, 'upsale_notice' ) );
}
} else {
if( $this->is_ok( 'message', $current_notice ) || $current_notice === 'opt_in' ) {
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
add_action( 'eael_admin_notices', array( $this, 'admin_notices' ) );
}
}
}
}
}
// }
}
/**
* Make time using timestamp and a string like 2 Hour, 2 Day, 30 Minutes, 1 Week, 1 year
* @param integer $current
* @param string $time
* @return integer
*/
public function makeTime( $current, $time ) {
return intval( strtotime( date( 'Y-m-d h:i:s', intval( $current ) ) . " +$time" ) );
}
/**
* Automatice Maybe Later.
* @param string $notice
* @return void
*/
private function maybe_later( $notice ){
if( empty( $notice ) ) {
return;
}
$options_data = $this->get_options_data();
$options_data[ $this->plugin_name ]['notice_will_show'][ $notice ] = $this->makeTime( $this->timestamp, $this->maybe_later_time );
$this->update_options_data( $options_data[ $this->plugin_name ] );
}
/**
* When links are clicked, this function will invoked.
* @return void
*/
public function clicked(){
if( isset( $_GET['plugin'] ) ) {
$plugin = sanitize_text_field( $_GET['plugin'] );
if( $plugin === $this->plugin_name ) {
$options_data = $this->get_options_data();
$clicked_from = current( $this->next_notice() );
if( isset( $_GET['plugin_action'] ) ) {
$plugin_action = sanitize_text_field( $_GET['plugin_action'] );
}
if( isset( $_GET['dismiss'] ) ) {
$dismiss = sanitize_text_field( $_GET['dismiss'] );
}
if( isset( $_GET['later'] ) ) {
$later = sanitize_text_field( $_GET['later'] );
}
$later_time = '';
switch( $clicked_from ) {
case 'opt_in' :
$dismiss = ( isset( $plugin_action ) ) ? $plugin_action : false ;
$later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
break;
case 'first_install' :
$later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
break;
case 'update' :
$dismiss = ( isset( $plugin_action ) ) ? $plugin_action : false ;
$later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
break;
// case 'update_400k' :
// $dismiss = ( isset( $plugin_action ) ) ? $plugin_action : false ;
// $later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
// break;
case 'review' :
$later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
break;
case 'upsale' :
$later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
break;
}
if( isset( $later ) && $later == true ) {
$options_data[ $this->plugin_name ]['notice_will_show'][ $clicked_from ] = $later_time;
}
if( isset( $dismiss ) && $dismiss == true ) {
update_user_meta( get_current_user_id(), $this->plugin_name . '_' . $clicked_from, true );
$this->update( $clicked_from );
}
$this->update_options_data( $options_data[ $this->plugin_name ] );
}
}
}
/**
* For Redirecting Current Page without Arguments!
*
* @return void
*/
private function redirect_to(){
$request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
$query_string = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY );
wp_parse_str( $query_string, $current_url );
$unset_array = array( 'dismiss', 'plugin', '_wpnonce', 'later', 'plugin_action', 'marketing_optin' );
foreach( $unset_array as $value ) {
if( isset( $current_url[ $value ] ) ) {
unset( $current_url[ $value ] );
}
}
$current_url = http_build_query($current_url);
$redirect_url = $request_uri . '?' . $current_url;
return $redirect_url;
}
/**
* Before Notice
* @return void
*/
public function before(){
$current_notice = current( $this->next_notice() );
$classes = 'notice notice-info put-dismiss-notice';
if( isset( $this->data['classes'] ) ) {
if( isset( $this->data['classes'][ $current_notice ] ) ) {
$classes = $this->data['classes'][ $current_notice ];
}
}
if( $this->has_thumbnail( $current_notice ) ) {
$classes .= 'notice-has-thumbnail';
}
echo '<div class="'. $classes .' wpdeveloper-'. $current_notice .'-notice" data-notice="'. $current_notice .'">';
}
/**
* After Notice
* @return void
*/
public function after(){
echo '</div>';
}
/**
* Content generation & Hooks Funciton.
* @return void
*/
public function content(){
$options_data = $this->get_options_data();
$notice = current( $this->next_notice() );
switch( $notice ) {
case 'opt_in' :
do_action('wpdeveloper_optin_notice_for_' . $this->plugin_name );
break;
case 'first_install' :
if( $options_data[ $this->plugin_name ]['first_install'] !== 'deactivated' ) {
do_action( 'wpdeveloper_first_install_notice_for_' . $this->plugin_name );
$this->get_thumbnail( 'first_install' );
$this->get_message( 'first_install' );
}
break;
case 'update' :
do_action( 'wpdeveloper_update_notice_for_' . $this->plugin_name );
$this->dismiss_button_scripts();
$this->get_thumbnail( 'update' );
$this->get_message( 'update' );
break;
// case 'update_400k' :
// do_action( 'wpdeveloper_update_notice_for_' . $this->plugin_name );
// $this->dismiss_button_scripts();
// $this->get_thumbnail( 'update_400k' );
// $this->get_message( 'update_400k' );
// break;
case 'review' :
do_action( 'wpdeveloper_review_notice_for_' . $this->plugin_name );
$this->get_thumbnail( 'review' );
$this->get_message( 'review' );
break;
}
}
/**
* Before Upsale Notice
* @return void
*/
public function before_upsale(){
$classes = '';
if( $this->has_thumbnail('upsale') ) {
$classes = 'notice-has-thumbnail';
}
echo '<div class="error notice is-dismissible wpdeveloper-upsale-notice '. $classes .'">';
}
/**
* Upsale Notice
*/
public function upsale_notice(){
do_action( 'wpdeveloper_before_upsale_notice_for_' . $this->plugin_name );
do_action('wpdeveloper_upsale_notice_for_' . $this->plugin_name);
$this->get_thumbnail( 'upsale' );
$this->get_message( 'upsale' );
do_action( 'wpdeveloper_after_upsale_notice_for_' . $this->plugin_name );
$this->upsale_button_script();
}
/**
* Get upsale arguments.
* @return void
*/
private function get_upsale_args(){
return ( empty( $this->upsale_args ) ) ? array() : $this->upsale_args;
}
/**
* This function is responsible for making the button visible to the upsale notice.
*/
private function upsale_button(){
$upsale_args = $this->get_upsale_args();
$plugin_slug = ( isset( $upsale_args['slug'] )) ? $upsale_args['slug'] : '' ;
$btn_text = ( isset( $upsale_args['btn_text'] )) ? $upsale_args['btn_text'] : __( 'Install Now!', 'essential-addons-for-elementor-lite' ) ;
if( empty( $plugin_slug ) ) {
return;
}
echo '<button data-slug="'. esc_attr( $plugin_slug ) .'" id="plugin-install-core-'. $this->plugin_name .'" class="button button-primary">'. Helper::eael_wp_kses( $btn_text ) .'</button>';
}
/**
* This methods is responsible for get notice image.
*
* @param string $msg_for
* @return void
*/
protected function get_thumbnail( $msg_for ){
$output = '';
if( isset( $this->data['thumbnail'] ) && isset( $this->data['thumbnail'][ $msg_for ] ) ) {
$output = '<div class="wpdeveloper-notice-thumbnail">';
$output .= '<img src="'. esc_url( $this->data['thumbnail'][ $msg_for ] ) .'" alt="">';
$output .= '</div>';
}
echo wp_kses_post( $output );
}
/**
* Has Thumbnail Check
*
* @param string $msg_for
* @return boolean
*/
protected function has_thumbnail( $msg_for = '' ){
if( empty( $msg_for ) ) {
return false;
}
if( isset( $this->data['thumbnail'] ) && isset( $this->data['thumbnail'][ $msg_for ] ) ) {
return true;
}
return false;
}
/**
* This method is responsible for get messages.
*
* @param string $msg_for
* @return void
*/
protected function get_message( $msg_for ){
if( isset( $this->data['message'] ) && isset( $this->data['message'][ $msg_for ] ) ) {
echo '<div class="wpdeveloper-notice-message">';
echo Helper::eael_wp_kses( $this->data['message'][ $msg_for ] );
if( $msg_for === 'upsale' ) {
$this->upsale_button();
}
$this->dismissible_notice( $msg_for );
echo '</div>';
}
}
/**
* Detect which notice will show @ next.
* @return array
*/
protected function next_notice() {
$options_data = $this->get_options_data();
if ( ! $options_data ) {
$args = $this->get_args();
$return_notice = $args['notice_will_show'];
} else {
$return_notice = $options_data[ $this->plugin_name ]['notice_will_show'];
}
if ( is_array( $return_notice ) ) {
$return_notice = array_flip( $return_notice );
ksort( $return_notice );
}
return (array) $return_notice;
}
/**
* Which notice is deserve to show in next slot.
* @param string $notice
* @return boolean
*/
private function deserve_notice( $notice ) {
$notices = $this->get_user_notices();
if( $notice === false ) {
return false;
}
if( empty( $notices ) ) {
return true;
} else {
if( isset( $notices[ $this->notice_id ] ) && isset( $notices[ $this->notice_id ][ $this->plugin_name ] ) ) {
if( in_array( $notice, $notices[ $this->notice_id ][ $this->plugin_name ] ) ) {
return false;
} else {
return true;
}
} else {
return true;
}
}
}
/**
* This is the main methods for generate the notice.
* @return void
*/
public function admin_notices(){
$current_notice = current( $this->next_notice() );
if( get_user_meta( get_current_user_id(), $this->plugin_name . '_' . $current_notice, true ) ) {
return;
}
if( $current_notice == 'opt_in' ) {
do_action( $this->do_notice_action );
return;
}
do_action( 'wpdeveloper_before_notice_for_' . $this->plugin_name );
do_action( $this->do_notice_action );
do_action( 'wpdeveloper_after_notice_for_' . $this->plugin_name );
}
/**
* This method is responsible for all dismissible links generation.
* @param string $links_for
* @return void
*/
public function dismissible_notice( $links_for = '' ){
if( empty( $links_for ) ) {
return;
}
$links = isset( $this->data['links'][ $links_for ] ) ? $this->data['links'][ $links_for ] : false;
if( $links ) :
$output = '<ul class="wpdeveloper-notice-link">';
foreach( $links as $key => $link_value ) {
if( ! empty( $link_value['label'] ) ) {
$output .= '<li>';
if( isset( $link_value['link'] ) ) {
$link = $link_value['link'];
$target = isset( $link_value['target'] ) ? 'target="'. esc_attr( $link_value['target'] ) .'"' : '';
if( isset( $link_value['data_args'] ) && is_array( $link_value['data_args'] ) ) {
$data_args = [];
foreach( $link_value['data_args'] as $key => $args_value ) {
$data_args[ $key ] = $args_value;
}
$data_args[ 'plugin' ] = $this->plugin_name;
$normal_link = add_query_arg( $data_args, $link );
$link = wp_nonce_url( $normal_link, 'wpdeveloper-nonce' );
}
$class = '';
if( isset( $link_value['link_class'] ) ) {
$class = 'class="' . sanitize_html_class( implode( ' ', $link_value['link_class'] ) ) . '"';
}
$output .= '<a '. $class .' href="'. esc_url( $link ) .'" '. $target .'>';
}
if( isset( $link_value['icon_class'] ) ) {
$output .= '<span class="'. esc_attr( $link_value['icon_class'] ) .'"></span>';
}
if( isset( $link_value['icon_img'] ) ) {
$output .= '<img src="'. esc_url( $link_value['icon_img'] ) .'" alt="" />';
}
$output .= $link_value['label'];
if( isset( $link_value['link'] ) ) {
$output .= '</a>';
}
$output .= '</li>';
}
}
$output .= '</ul>';
printf( '%1$s', $output );
endif;
}
/**
* First Installation Track
* @return void
*/
public function first_install_track( $args = array() ){
if( ! current_user_can( 'manage_options' ) ) {
return;
}
if( empty( $args ) ) {
$args = array(
'time' => $this->timestamp,
'version' => $this->version,
);
}
$options_data = $this->get_options_data();
$args = wp_parse_args( $args, $this->get_args() );
if( ! isset( $options_data[ $this->plugin_name ] )
|| ( isset( $options_data[ $this->plugin_name ]['version'] ) && version_compare( $options_data[ $this->plugin_name ]['version'], $this->version, '!=' ) ) ) {
$this->update_options_data( $args );
}
}
/**
* First Installation Deactive Track
*
* @return void
*/
public function first_install_end(){
// $args = array(
// 'first_install' => 'deactivated'
// );
// $options_data = $this->get_options_data();
// if( isset( $options_data[ $this->plugin_name ] ) ) {
// $args = wp_parse_args( $args, $options_data[ $this->plugin_name ] );
// $this->update_options_data( $args );
// }
delete_option( 'wpdeveloper_plugins_data' );
}
/**
* Get all options from database!
* @return void
*/
protected function get_options_data( $key = '' ) {
$options_data = get_option( 'wpdeveloper_plugins_data', [] );
if ( empty( $key ) ) {
return $options_data;
}
if ( isset( $options_data[ $this->plugin_name ][ $key ] ) ) {
return $options_data[ $this->plugin_name ][ $key ];
}
return [];
}
/**
* This will update the options table for plugins.
*
* @param mixed $new_data
* @param array $args
* @return void
*/
protected function update_options_data( $args = array() ){
$options_data = $this->get_options_data();
$options_data[ $this->plugin_name ] = $args;
update_option( 'wpdeveloper_plugins_data', $options_data );
}
/**
* Set properties data, for some selected properties.
*
* @param string $name
* @param mixed $value
*/
public function __set( $name, $value ){
if( in_array( $name, $this->properties ) ) {
$this->data[ $name ] = $value;
}
}
/**
* Invoked when some selected methods are called
*
* @param string $name
* @param array $values
* @return void
*/
public function __call( $name, $values ){
if( in_array( $name, $this->methods ) ) {
$this->data[ $name ][ $values[0] ] = $values[1];
}
}
protected function is_ok( $name, $notice ){
if( isset( $this->data[ $name ], $this->data[ $name ][ $notice ] ) ) {
return true;
}
return false;
}
/**
* Get all option arguments.
* @param string $key
* @return array
*/
private function get_args( $key = '' ){
if( empty( $key ) ) {
return $this->options_args;
}
if( isset( $this->options_args[ $key ] ) ) {
return $this->options_args[ $key ];
}
return false;
}
/**
* Resetting data on update.
* @return void
*/
private function set_args_on_update(){
$args = $this->get_args();
$options_data = $this->get_options_data();
$set_data = $options_data[ $this->plugin_name ];
$args = wp_parse_args( $set_data, $args );
$this->update_options_data( $args );
}
/**
* When upgrade is complete. it will fired.
* @param WP_Upgrader $upgrader_object
* @param array $options
* @return void
*/
public function upgrade_completed( $upgrader_object, $options ) {
// If an update has taken place and the updated type is plugins and the plugins element exists
if( isset( $options['action'] ) && $options['action'] == 'update' && $options['type'] == 'plugin' ) {
if( ! isset( $options['plugin'] ) && isset( $options['plugins'] ) ) {
foreach( $options['plugins'] as $plugin ) {
if( $plugin == $this->plugin_name ) {
$this->set_args_on_update();
}
}
}
if( isset( $options['plugin'] ) && $options['plugin'] == $this->plugin_name ) {
$this->set_args_on_update();
}
}
}
/**
* This function is responsible for get_user_notices
* @return void
*/
private function get_user_notices() {
$notices = get_user_meta( get_current_user_id(), self::ADMIN_UPDATE_NOTICE_KEY, true );
return ! $notices ? array() : $notices;
}
/**
* This function is responsible for update meta information.
*
* @param string $notice
* @return void
*/
private function update( $notice ){
if( empty( $notice ) ) {
return;
}
$options_data = $this->get_options_data();
$user_notices = $this->get_user_notices();
$user_notices[ $this->notice_id ][ $this->plugin_name ][] = $notice;
// Remove the upsale from notice_will_show field in options DB.
unset( $options_data[ $this->plugin_name ]['notice_will_show'][ $notice ] );
$this->update_options_data( $options_data[ $this->plugin_name ] );
// Set users meta, not to show again current_version notice.
update_user_meta( get_current_user_id(), self::ADMIN_UPDATE_NOTICE_KEY, $user_notices);
}
public function notice_dissmiss(){
if( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'wpdeveloper_notice_dissmiss' ) ) {
return;
}
if( ! isset( $_POST['action'] ) || ( $_POST['action'] !== 'wpdeveloper_notice_dissmiss_for_' . $this->plugin_name ) ) {
return;
}
$dismiss = isset( $_POST['dismiss'] ) ? sanitize_text_field( $_POST['dismiss'] ) : false;
$notice = isset( $_POST['notice'] ) ? sanitize_text_field( $_POST['notice'] ) : false;
if( $dismiss ) {
$this->update( $notice );
update_user_meta( get_current_user_id(), $this->plugin_name . '_' . $notice, true );
echo 'success';
} else {
echo 'failed';
}
die();
}
/**
* This function is responsible for do action when
* the dismiss button clicked in upsale notice.
*/
public function upsale_notice_dissmiss(){
if( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'wpdeveloper_upsale_notice_dissmiss' ) ) {
return;
}
if( ! isset( $_POST['action'] ) || ( $_POST['action'] !== 'wpdeveloper_upsale_notice_dissmiss_for_' . $this->plugin_name ) ) {
return;
}
$dismiss = isset( $_POST['dismiss'] ) ? sanitize_text_field( $_POST['dismiss'] ) : false;
if( $dismiss ) {
$this->update( 'upsale' );
echo 'success';
} else {
echo 'failed';
}
die();
}
public function dismiss_button_scripts(){
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
var wpdevNotice = $('.notice.is-dismissible');
if( wpdevNotice.length > 0 ) {
$('body').on('click', 'button.notice-dismiss', function (e) {
e.preventDefault();
$.ajax({
url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
type: 'post',
data: {
action: 'wpdeveloper_notice_dissmiss_for_<?php echo esc_html( $this->plugin_name ); ?>',
_wpnonce: '<?php echo wp_create_nonce('wpdeveloper_notice_dissmiss'); ?>',
dismiss: true,
notice: wpdevNotice.data('notice'),
},
success: function(response) {
$('.notice').hide();
console.log('Successfully saved!');
},
error: function(error) {
console.log('Something went wrong!');
},
complete: function() {
console.log('Its Complete.');
}
});
});
}
} );
</script>
<?php
}
/**
* Upsale Button Script.
* When install button is clicked, it will do its own things.
* also for dismiss button JS.
* @return void
*/
public function upsale_button_script(){
$upsale_args = $this->get_upsale_args();
$plugin_slug = ( isset( $upsale_args['slug'] ) ) ? $upsale_args['slug'] : '';
$plugin_file = ( isset( $upsale_args['file'] ) ) ? $upsale_args['file'] : '';
$page_slug = ( isset( $upsale_args['page_slug'] ) ) ? $upsale_args['page_slug'] : '';
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
<?php if( ! empty( $plugin_slug ) && ! empty( $plugin_file ) ) : ?>
$('#plugin-install-core-<?php echo esc_html( $this->plugin_name ); ?>').on('click', function (e) {
var self = $(this);
e.preventDefault();
self.addClass('install-now updating-message');
self.text('<?php echo esc_js( 'Installing...' ); ?>');
$.ajax({
url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
type: 'POST',
data: {
action: 'wpdeveloper_upsale_core_install_<?php echo esc_html( $this->plugin_name ); ?>',
_wpnonce: '<?php echo wp_create_nonce('wpdeveloper_upsale_core_install_' . esc_html( $this->plugin_name )); ?>',
slug : '<?php echo esc_html( $plugin_slug ); ?>',
file : '<?php echo esc_html( $plugin_file ); ?>'
},
success: function(response) {
self.text('<?php echo esc_js( 'Installed' ); ?>');
<?php if( ! empty( $page_slug ) ) : ?>
window.location.href = '<?php echo esc_url( admin_url( "admin.php?page={$page_slug}" ) ); ?>';
<?php endif; ?>
},
error: function(error) {
self.removeClass('install-now updating-message');
},
complete: function() {
self.attr('disabled', 'disabled');
self.removeClass('install-now updating-message');
}
});
});
<?php endif; ?>
$('.wpdeveloper-upsale-notice').on('click', 'button.notice-dismiss', function (e) {
e.preventDefault();
$.ajax({
url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
type: 'post',
data: {
action: 'wpdeveloper_upsale_notice_dissmiss_for_<?php echo esc_html( $this->plugin_name ); ?>',
_wpnonce: '<?php echo wp_create_nonce('wpdeveloper_upsale_notice_dissmiss'); ?>',
dismiss: true
},
success: function(response) {
console.log('Successfully saved!');
},
error: function(error) {
console.log('Something went wrong!');
},
complete: function() {
console.log('Its Complete.');
}
});
});
} );
</script>
<?php
}
}

View File

@@ -0,0 +1,203 @@
<?php
namespace Essential_Addons_Elementor\Classes;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly.
use \WP_Error;
class WPDeveloper_Plugin_Installer
{
public function __construct()
{
add_action('wp_ajax_wpdeveloper_install_plugin', [$this, 'ajax_install_plugin']);
add_action('wp_ajax_wpdeveloper_upgrade_plugin', [$this, 'ajax_upgrade_plugin']);
add_action('wp_ajax_wpdeveloper_activate_plugin', [$this, 'ajax_activate_plugin']);
}
/**
* get_local_plugin_data
*
* @param mixed $basename
* @return array|false
*/
public function get_local_plugin_data($basename = '')
{
if (empty($basename)) {
return false;
}
if (!function_exists('get_plugins')) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
if (!isset($plugins[$basename])) {
return false;
}
return $plugins[$basename];
}
/**
* get_remote_plugin_data
*
* @param mixed $slug
* @return mixed array|WP_Error
*/
public function get_remote_plugin_data($slug = '')
{
if (empty($slug)) {
return new WP_Error('empty_arg', __('Argument should not be empty.'));
}
$response = wp_remote_post(
'http://api.wordpress.org/plugins/info/1.0/',
[
'body' => [
'action' => 'plugin_information',
'request' => serialize((object) [
'slug' => $slug,
'fields' => [
'version' => false,
],
]),
],
]
);
if (is_wp_error($response)) {
return $response;
}
return unserialize(wp_remote_retrieve_body($response));
}
/**
* install_plugin
*
* @param mixed $slug
* @param bool $active
* @return mixed bool|WP_Error
*/
public function install_plugin($slug = '', $active = true)
{
if (empty($slug)) {
return new WP_Error('empty_arg', __('Argument should not be empty.'));
}
include_once ABSPATH . 'wp-admin/includes/file.php';
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . 'wp-admin/includes/class-automatic-upgrader-skin.php';
$plugin_data = $this->get_remote_plugin_data($slug);
if (is_wp_error($plugin_data)) {
return $plugin_data;
}
$upgrader = new \Plugin_Upgrader(new \Automatic_Upgrader_Skin());
// install plugin
$install = $upgrader->install($plugin_data->download_link);
if (is_wp_error($install)) {
return $install;
}
// activate plugin
if ($install === true && $active) {
$active = activate_plugin($upgrader->plugin_info(), '', false, true);
if (is_wp_error($active)) {
return $active;
}
return $active === null;
}
return $install;
}
/**
* upgrade_plugin
*
* @param mixed $basename
* @return mixed bool|WP_Error
*/
public function upgrade_plugin($basename = '')
{
if (empty($slug)) {
return new WP_Error('empty_arg', __('Argument should not be empty.'));
}
include_once ABSPATH . 'wp-admin/includes/file.php';
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . 'wp-admin/includes/class-automatic-upgrader-skin.php';
$upgrader = new \Plugin_Upgrader(new \Automatic_Upgrader_Skin());
// upgrade plugin
return $upgrader->upgrade($basename);
}
public function ajax_install_plugin()
{
check_ajax_referer('essential-addons-elementor', 'security');
if(!current_user_can( 'install_plugins' )) {
wp_send_json_error(__('you are not allowed to do this action', 'essential-addons-for-elementor-lite'));
}
$slug = isset( $_POST['slug'] ) ? sanitize_text_field( $_POST['slug'] ) : '';
$result = $this->install_plugin( $slug );
if ( is_wp_error( $result ) ) {
wp_send_json_error( $result->get_error_message() );
}
wp_send_json_success(__('Plugin is installed successfully!', 'essential-addons-for-elementor-lite'));
}
public function ajax_upgrade_plugin()
{
check_ajax_referer('essential-addons-elementor', 'security');
//check user capabilities
if(!current_user_can( 'update_plugins' )) {
wp_send_json_error(__('you are not allowed to do this action', 'essential-addons-for-elementor-lite'));
}
$basename = isset( $_POST['basename'] ) ? sanitize_text_field( $_POST['basename'] ) : '';
$result = $this->upgrade_plugin( $basename );
if (is_wp_error($result)) {
wp_send_json_error($result->get_error_message());
}
wp_send_json_success(__('Plugin is updated successfully!', 'essential-addons-for-elementor-lite'));
}
public function ajax_activate_plugin()
{
check_ajax_referer('essential-addons-elementor', 'security');
//check user capabilities
if(!current_user_can( 'activate_plugins' )) {
wp_send_json_error(__('you are not allowed to do this action', 'essential-addons-for-elementor-lite'));
}
$basename = isset( $_POST['basename'] ) ? sanitize_text_field( $_POST['basename'] ) : '';
$result = activate_plugin( $basename, '', false, true );
if ( is_wp_error( $result ) ) {
wp_send_json_error( $result->get_error_message() );
}
if ($result === false) {
wp_send_json_error(__('Plugin couldn\'t be activated.', 'essential-addons-for-elementor-lite'));
}
wp_send_json_success(__('Plugin is activated successfully!', 'essential-addons-for-elementor-lite'));
}
}

View File

@@ -0,0 +1 @@
<?php // Silence is golden

View File

@@ -0,0 +1,665 @@
<?php
namespace Essential_Addons_Elementor\Controls;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Background;
use Elementor\Modules\DynamicTags\Module as TagsModule;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* EAEL background control.
*
* A base control for creating background control. Displays input fields to define
* the background color, background image, background gradient or background video.
*
* @since 1.2.2
*/
class EAEL_Background extends Group_Control_Background {
/**
* Fields.
*
* Holds all the background control fields.
*
* @since 1.2.2
* @access protected
* @static
*
* @var array Background control fields.
*/
protected static $fields;
/**
* Get background control type.
*
* Retrieve the control type, in this case `background`.
*
* @return string Control type.
* @since 1.0.0
* @access public
* @static
*
*/
public static function get_type() {
return 'eael-background';
}
/**
* Init fields.
*
* Initialize background control fields.
*
* @return array Control fields.
* @since 1.2.2
* @access public
*
*/
public function init_fields() {
$fields = [];
$fields['background'] = [
'label' => esc_html_x( 'Background Type', 'Background Control', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'render_type' => 'ui',
];
$fields['color'] = [
'label' => esc_html_x( 'Color', 'Background Control', 'elementor' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'title' => esc_html_x( 'Background Color', 'Background Control', 'elementor' ),
'selectors' => [
'{{SELECTOR}}' => 'background: {{VALUE}};',
],
'condition' => [
'background' => [ 'classic', 'gradient', 'video' ],
],
];
$fields['color_stop'] = [
'label' => esc_html_x( 'Location', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ '%', 'custom' ],
'default' => [
'unit' => '%',
'size' => 0,
],
'render_type' => 'ui',
'condition' => [
'background' => [ 'gradient' ],
],
'of_type' => 'gradient',
];
$fields['color_b'] = [
'label' => esc_html_x( 'Second Color', 'Background Control', 'elementor' ),
'type' => Controls_Manager::COLOR,
'default' => '#f2295b',
'render_type' => 'ui',
'condition' => [
'background' => [ 'gradient' ],
],
'of_type' => 'gradient',
];
$fields['color_b_stop'] = [
'label' => esc_html_x( 'Location', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ '%', 'custom' ],
'default' => [
'unit' => '%',
'size' => 100,
],
'render_type' => 'ui',
'condition' => [
'background' => [ 'gradient' ],
],
'of_type' => 'gradient',
];
$fields['gradient_type'] = [
'label' => esc_html_x( 'Type', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SELECT,
'options' => [
'linear' => esc_html_x( 'Linear', 'Background Control', 'elementor' ),
'radial' => esc_html_x( 'Radial', 'Background Control', 'elementor' ),
],
'default' => 'linear',
'render_type' => 'ui',
'condition' => [
'background' => [ 'gradient' ],
],
'of_type' => 'gradient',
];
$fields['gradient_angle'] = [
'label' => esc_html_x( 'Angle', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'deg', 'grad', 'rad', 'turn', 'custom' ],
'default' => [
'unit' => 'deg',
'size' => 180,
],
'selectors' => [
'{{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' => [
'background' => [ 'gradient' ],
'gradient_type' => 'linear',
],
'of_type' => 'gradient',
];
$fields['gradient_position'] = [
'label' => esc_html_x( 'Position', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SELECT,
'options' => [
'center center' => esc_html_x( 'Center Center', 'Background Control', 'elementor' ),
'center left' => esc_html_x( 'Center Left', 'Background Control', 'elementor' ),
'center right' => esc_html_x( 'Center Right', 'Background Control', 'elementor' ),
'top center' => esc_html_x( 'Top Center', 'Background Control', 'elementor' ),
'top left' => esc_html_x( 'Top Left', 'Background Control', 'elementor' ),
'top right' => esc_html_x( 'Top Right', 'Background Control', 'elementor' ),
'bottom center' => esc_html_x( 'Bottom Center', 'Background Control', 'elementor' ),
'bottom left' => esc_html_x( 'Bottom Left', 'Background Control', 'elementor' ),
'bottom right' => esc_html_x( 'Bottom Right', 'Background Control', 'elementor' ),
],
'default' => 'center center',
'selectors' => [
'{{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' => [
'background' => [ 'gradient' ],
'gradient_type' => 'radial',
],
'of_type' => 'gradient',
];
$fields['image'] = [
'label' => esc_html_x( 'Image', 'Background Control', 'elementor' ),
'type' => Controls_Manager::MEDIA,
'ai' => [
'category' => 'background',
],
'dynamic' => [
'active' => true,
],
'responsive' => true,
'title' => esc_html_x( 'Background Image', 'Background Control', 'elementor' ),
'selectors' => [
'{{SELECTOR}}' => 'background-image: url("{{URL}}");',
],
'has_sizes' => true,
'render_type' => 'template',
'condition' => [
'background' => [ 'classic' ],
],
];
$fields['position'] = [
'label' => esc_html_x( 'Position', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SELECT,
'default' => '',
'separator' => 'before',
'responsive' => true,
'options' => [
'' => esc_html_x( 'Default', 'Background Control', 'elementor' ),
'center center' => esc_html_x( 'Center Center', 'Background Control', 'elementor' ),
'center left' => esc_html_x( 'Center Left', 'Background Control', 'elementor' ),
'center right' => esc_html_x( 'Center Right', 'Background Control', 'elementor' ),
'top center' => esc_html_x( 'Top Center', 'Background Control', 'elementor' ),
'top left' => esc_html_x( 'Top Left', 'Background Control', 'elementor' ),
'top right' => esc_html_x( 'Top Right', 'Background Control', 'elementor' ),
'bottom center' => esc_html_x( 'Bottom Center', 'Background Control', 'elementor' ),
'bottom left' => esc_html_x( 'Bottom Left', 'Background Control', 'elementor' ),
'bottom right' => esc_html_x( 'Bottom Right', 'Background Control', 'elementor' ),
'initial' => esc_html_x( 'Custom', 'Background Control', 'elementor' ),
],
'selectors' => [
'{{SELECTOR}}' => 'background-position: {{VALUE}};',
],
'condition' => [
'background' => [ 'classic' ],
'image[url]!' => '',
],
];
$fields['xpos'] = [
'label' => esc_html_x( 'X Position', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'responsive' => true,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'default' => [
'size' => 0,
],
'tablet_default' => [
'size' => 0,
],
'mobile_default' => [
'size' => 0,
],
'range' => [
'px' => [
'min' => - 800,
'max' => 800,
],
'em' => [
'min' => - 100,
'max' => 100,
],
'%' => [
'min' => - 100,
'max' => 100,
],
'vw' => [
'min' => - 100,
'max' => 100,
],
],
'selectors' => [
'{{SELECTOR}}' => 'background-position: {{SIZE}}{{UNIT}} {{ypos.SIZE}}{{ypos.UNIT}}',
],
'condition' => [
'background' => [ 'classic' ],
'position' => [ 'initial' ],
'image[url]!' => '',
],
'required' => true,
];
$fields['ypos'] = [
'label' => esc_html_x( 'Y Position', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'responsive' => true,
'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ],
'default' => [
'size' => 0,
],
'tablet_default' => [
'size' => 0,
],
'mobile_default' => [
'size' => 0,
],
'range' => [
'px' => [
'min' => - 800,
'max' => 800,
],
'em' => [
'min' => - 100,
'max' => 100,
],
'%' => [
'min' => - 100,
'max' => 100,
],
'vh' => [
'min' => - 100,
'max' => 100,
],
],
'selectors' => [
'{{SELECTOR}}' => 'background-position: {{xpos.SIZE}}{{xpos.UNIT}} {{SIZE}}{{UNIT}}',
],
'condition' => [
'background' => [ 'classic' ],
'position' => [ 'initial' ],
'image[url]!' => '',
],
'required' => true,
];
$fields['attachment'] = [
'label' => esc_html_x( 'Attachment', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SELECT,
'default' => '',
'options' => [
'' => esc_html_x( 'Default', 'Background Control', 'elementor' ),
'scroll' => esc_html_x( 'Scroll', 'Background Control', 'elementor' ),
'fixed' => esc_html_x( 'Fixed', 'Background Control', 'elementor' ),
],
'selectors' => [
'(desktop+){{SELECTOR}}' => 'background-attachment: {{VALUE}};',
],
'condition' => [
'background' => [ 'classic' ],
'image[url]!' => '',
],
];
$fields['attachment_alert'] = [
'type' => Controls_Manager::RAW_HTML,
'content_classes' => 'elementor-control-field-description',
'raw' => esc_html__( 'Note: Attachment Fixed works only on desktop.', 'elementor' ),
'separator' => 'none',
'condition' => [
'background' => [ 'classic' ],
'image[url]!' => '',
'attachment' => 'fixed',
],
];
$fields['repeat'] = [
'label' => esc_html_x( 'Repeat', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SELECT,
'default' => '',
'responsive' => true,
'options' => [
'' => esc_html_x( 'Default', 'Background Control', 'elementor' ),
'no-repeat' => esc_html_x( 'No-repeat', 'Background Control', 'elementor' ),
'repeat' => esc_html_x( 'Repeat', 'Background Control', 'elementor' ),
'repeat-x' => esc_html_x( 'Repeat-x', 'Background Control', 'elementor' ),
'repeat-y' => esc_html_x( 'Repeat-y', 'Background Control', 'elementor' ),
],
'selectors' => [
'{{SELECTOR}}' => 'background-repeat: {{VALUE}};',
],
'condition' => [
'background' => [ 'classic' ],
'image[url]!' => '',
],
];
$fields['size'] = [
'label' => esc_html_x( 'Display Size', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SELECT,
'responsive' => true,
'default' => '',
'options' => [
'' => esc_html_x( 'Default', 'Background Control', 'elementor' ),
'auto' => esc_html_x( 'Auto', 'Background Control', 'elementor' ),
'cover' => esc_html_x( 'Cover', 'Background Control', 'elementor' ),
'contain' => esc_html_x( 'Contain', 'Background Control', 'elementor' ),
'initial' => esc_html_x( 'Custom', 'Background Control', 'elementor' ),
],
'selectors' => [
'{{SELECTOR}}' => 'background-size: {{VALUE}};',
],
'condition' => [
'background' => [ 'classic' ],
'image[url]!' => '',
],
];
$fields['bg_width'] = [
'label' => esc_html_x( 'Width', 'Background Control', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'responsive' => true,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
],
'%' => [
'min' => 0,
'max' => 100,
],
'vw' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'size' => 100,
'unit' => '%',
],
'required' => true,
'selectors' => [
'{{SELECTOR}}' => 'background-size: {{SIZE}}{{UNIT}} auto',
],
'condition' => [
'background' => [ 'classic' ],
'size' => [ 'initial' ],
'image[url]!' => '',
],
];
$fields['video_link'] = [
'label' => esc_html_x( 'Video Link', 'Background Control', 'elementor' ),
'type' => Controls_Manager::TEXT,
'placeholder' => 'https://www.youtube.com/watch?v=XHOmBV4js_E',
'description' => esc_html__( 'YouTube/Vimeo link, or link to video file (mp4 is recommended).', 'elementor' ),
'label_block' => true,
'default' => '',
'dynamic' => [
'active' => true,
'categories' => [
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
],
],
'condition' => [
'background' => [ 'video' ],
],
'of_type' => 'video',
'frontend_available' => true,
];
$fields['video_start'] = [
'label' => esc_html__( 'Start Time', 'elementor' ),
'type' => Controls_Manager::NUMBER,
'description' => esc_html__( 'Specify a start time (in seconds)', 'elementor' ),
'placeholder' => 10,
'condition' => [
'background' => [ 'video' ],
],
'of_type' => 'video',
'frontend_available' => true,
];
$fields['video_end'] = [
'label' => esc_html__( 'End Time', 'elementor' ),
'type' => Controls_Manager::NUMBER,
'description' => esc_html__( 'Specify an end time (in seconds)', 'elementor' ),
'placeholder' => 70,
'condition' => [
'background' => [ 'video' ],
],
'of_type' => 'video',
'frontend_available' => true,
];
$fields['play_once'] = [
'label' => esc_html__( 'Play Once', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'background' => [ 'video' ],
],
'of_type' => 'video',
'frontend_available' => true,
];
$fields['play_on_mobile'] = [
'label' => esc_html__( 'Play On Mobile', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'background' => [ 'video' ],
],
'of_type' => 'video',
'frontend_available' => true,
];
// This control was added to handle a bug with the Youtube Embed API. The bug: If there is a video with Privacy
// Mode on, and at the same time the page contains another video WITHOUT privacy mode on, one of the videos
// will not run properly. This added control allows users to align all their videos to one host (either
// youtube.com or youtube-nocookie.com, depending on whether the user wants privacy mode on or not).
$fields['privacy_mode'] = [
'label' => esc_html__( 'Privacy Mode', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'background' => [ 'video' ],
],
'of_type' => 'video',
'frontend_available' => true,
];
$fields['video_fallback'] = [
'label' => esc_html_x( 'Background Fallback', 'Background Control', 'elementor' ),
'description' => esc_html__( 'This cover image will replace the background video in case that the video could not be loaded.', 'elementor' ),
'type' => Controls_Manager::MEDIA,
'dynamic' => [
'active' => true,
],
'condition' => [
'background' => [ 'video' ],
],
'selectors' => [
'{{SELECTOR}}' => 'background: url("{{URL}}") 50% 50%; background-size: cover;',
],
'of_type' => 'video',
];
$fields['slideshow_gallery'] = [
'label' => esc_html_x( 'Images', 'Background Control', 'elementor' ),
'type' => Controls_Manager::GALLERY,
'condition' => [
'background' => [ 'slideshow' ],
],
'show_label' => false,
'of_type' => 'slideshow',
'frontend_available' => true,
];
$fields['slideshow_loop'] = [
'label' => esc_html__( 'Infinite Loop', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'condition' => [
'background' => [ 'slideshow' ],
],
'of_type' => 'slideshow',
'frontend_available' => true,
];
$fields['slideshow_slide_duration'] = [
'label' => esc_html__( 'Duration', 'elementor' ) . ' (ms)',
'type' => Controls_Manager::NUMBER,
'default' => 5000,
'condition' => [
'background' => [ 'slideshow' ],
],
'frontend_available' => true,
];
$fields['slideshow_slide_transition'] = [
'label' => esc_html__( 'Transition', 'elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'fade',
'options' => [
'fade' => 'Fade',
'slide_right' => 'Slide Right',
'slide_left' => 'Slide Left',
'slide_up' => 'Slide Up',
'slide_down' => 'Slide Down',
],
'condition' => [
'background' => [ 'slideshow' ],
],
'of_type' => 'slideshow',
'frontend_available' => true,
];
$fields['slideshow_transition_duration'] = [
'label' => esc_html__( 'Transition Duration', 'elementor' ) . ' (ms)',
'type' => Controls_Manager::NUMBER,
'default' => 500,
'condition' => [
'background' => [ 'slideshow' ],
],
'frontend_available' => true,
];
$fields['slideshow_background_size'] = [
'label' => esc_html__( 'Background Size', 'elementor' ),
'type' => Controls_Manager::SELECT,
'responsive' => true,
'default' => '',
'options' => [
'' => esc_html__( 'Default', 'elementor' ),
'auto' => esc_html__( 'Auto', 'elementor' ),
'cover' => esc_html__( 'Cover', 'elementor' ),
'contain' => esc_html__( 'Contain', 'elementor' ),
],
'selectors' => [
'{{WRAPPER}} .elementor-background-slideshow__slide__image' => 'background-size: {{VALUE}};',
],
'condition' => [
'background' => [ 'slideshow' ],
],
];
$fields['slideshow_background_position'] = [
'label' => esc_html__( 'Background Position', 'elementor' ),
'type' => Controls_Manager::SELECT,
'default' => '',
'responsive' => true,
'options' => [
'' => esc_html__( 'Default', 'elementor' ),
'center center' => esc_html_x( 'Center Center', 'Background Control', 'elementor' ),
'center left' => esc_html_x( 'Center Left', 'Background Control', 'elementor' ),
'center right' => esc_html_x( 'Center Right', 'Background Control', 'elementor' ),
'top center' => esc_html_x( 'Top Center', 'Background Control', 'elementor' ),
'top left' => esc_html_x( 'Top Left', 'Background Control', 'elementor' ),
'top right' => esc_html_x( 'Top Right', 'Background Control', 'elementor' ),
'bottom center' => esc_html_x( 'Bottom Center', 'Background Control', 'elementor' ),
'bottom left' => esc_html_x( 'Bottom Left', 'Background Control', 'elementor' ),
'bottom right' => esc_html_x( 'Bottom Right', 'Background Control', 'elementor' ),
],
'selectors' => [
'{{WRAPPER}} .elementor-background-slideshow__slide__image' => 'background-position: {{VALUE}};',
],
'condition' => [
'background' => [ 'slideshow' ],
],
];
$fields['slideshow_lazyload'] = [
'label' => esc_html__( 'Lazyload', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'separator' => 'before',
'condition' => [
'background' => [ 'slideshow' ],
],
'of_type' => 'slideshow',
'frontend_available' => true,
];
$fields['slideshow_ken_burns'] = [
'label' => esc_html__( 'Ken Burns Effect', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'separator' => 'before',
'condition' => [
'background' => [ 'slideshow' ],
],
'of_type' => 'slideshow',
'frontend_available' => true,
];
$fields['slideshow_ken_burns_zoom_direction'] = [
'label' => esc_html__( 'Direction', 'elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'in',
'options' => [
'in' => esc_html__( 'In', 'elementor' ),
'out' => esc_html__( 'Out', 'elementor' ),
],
'condition' => [
'background' => [ 'slideshow' ],
'slideshow_ken_burns!' => '',
],
'of_type' => 'slideshow',
'frontend_available' => true,
];
return $fields;
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace Essential_Addons_Elementor\Controls;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Base_Data_Control;
class Select2 extends Base_Data_Control
{
public function get_type()
{
return 'eael-select2';
}
public function enqueue() {
wp_register_script( 'eael-select2', EAEL_PLUGIN_URL . 'assets/front-end/js/edit/ea-select2.js',
[ 'jquery-elementor-select2' ], EAEL_PLUGIN_VERSION, true );
wp_localize_script(
'eael-select2',
'eael_select2_localize',
[
'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
'search_text' => esc_html__( 'Search', 'essential-addons-for-elementor-lite' ),
'remove' => __( 'Remove', 'essential-addons-for-elementor-lite' ),
'thumbnail' => __( 'Image', 'essential-addons-for-elementor-lite' ),
'name' => __( 'Title', 'essential-addons-for-elementor-lite' ),
'price' => __( 'Price', 'essential-addons-for-elementor-lite' ),
'quantity' => __( 'Quantity', 'essential-addons-for-elementor-lite' ),
'subtotal' => __( 'Subtotal', 'essential-addons-for-elementor-lite' ),
'cl_login_status' => __( 'User Status', 'essential-addons-for-elementor-lite' ),
'cl_post_type' => __( 'Post Type', 'essential-addons-for-elementor-lite' ),
'cl_browser' => __( 'Browser', 'essential-addons-for-elementor-lite' ),
'cl_date_time' => __( 'Date & Time', 'essential-addons-for-elementor-lite' ),
'cl_recurring_day'=> __( 'Recurring Day', 'essential-addons-for-elementor-lite' ),
'cl_dynamic' => __( 'Dynamic Field', 'essential-addons-for-elementor-lite' ),
'cl_query_string' => __( 'Query String', 'essential-addons-for-elementor-lite' ),
'cl_visit_count' => __( 'Visit Count', 'essential-addons-for-elementor-lite' ),
]
);
wp_enqueue_script( 'eael-select2' );
}
protected function get_default_settings()
{
return [
'multiple' => false,
'source_name' => 'post_type',
'source_type' => 'post',
];
}
public function content_template()
{
$control_uid = $this->get_control_uid();
?>
<# var controlUID = '<?php echo esc_html( $control_uid ); ?>'; #>
<# var currentID = elementor.panel.currentView.currentPageView.model.attributes.settings.attributes[data.name]; #>
<div class="elementor-control-field">
<# if ( data.label ) { #>
<label for="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-title">{{{data.label }}}</label>
<# } #>
<div class="elementor-control-input-wrapper elementor-control-unit-5">
<# var multiple = ( data.multiple ) ? 'multiple' : ''; #>
<select id="<?php echo esc_attr( $control_uid ); ?>" {{ multiple }} class="ea-select2" data-setting="{{ data.name }}"></select>
</div>
</div>
<#
( function( $ ) {
$( document.body ).trigger( 'eael_select2_init',{currentID:data.controlValue,data:data,controlUID:controlUID,multiple:data.multiple} );
}( jQuery ) );
#>
<?php
}
}

View File

@@ -0,0 +1 @@
<?php // Silence is golden

View File

@@ -0,0 +1,65 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Widget_Base;
class Better_Payment extends Widget_Base {
public function get_name() {
return 'eael-better-payment';
}
public function get_title() {
return esc_html__( 'Better Payment', 'essential-addons-for-elementor-lite');
}
public function get_icon() {
return 'eaicon-better-payment';
}
public function get_categories() {
return [ 'essential-addons-elementor' ];
}
public function get_keywords() {
return [
'payment', 'better-payment' ,'paypal', 'stripe', 'sell', 'donate', 'transaction', 'online-transaction', 'better payment', 'online transaction', 'ea better payment', 'ea', 'essential addons'
];
}
public function get_custom_help_url() {
return '#';
}
protected function register_controls() {
$this->start_controls_section(
'eael_global_warning',
[
'label' => __('Warning!', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_global_warning_text',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('<strong>Better Payment</strong> is not installed/activated on your site. Please install and activate <a href="plugin-install.php?s=better-payment&tab=search&type=tag" target="_blank">Better Payment</a> first.',
'essential-addons-for-elementor-lite'),
'content_classes' => 'eael-warning',
]
);
$this->end_controls_section();
}
protected function render() {
return;
}
}

View File

@@ -0,0 +1,591 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Typography;
use \Elementor\Group_Control_Background;
use \Elementor\Widget_Base;
class Betterdocs_Search_Form extends Widget_Base
{
public function get_name()
{
return 'eael-betterdocs-search-form';
}
public function get_title()
{
return __('BetterDocs Search Form', 'essential-addons-for-elementor-lite');
}
public function get_categories()
{
return ['essential-addons-elementor'];
}
public function get_icon()
{
return 'eaicon-betterdocs-search-form';
}
/**
* Get widget keywords.
*
* Retrieve the list of keywords the widget belongs to.
*
* @since 3.5.2
* @access public
*
* @return array Widget keywords.
*/
public function get_keywords()
{
return [
'knowledgebase',
'knowledge Base',
'documentation',
'doc',
'kb',
'betterdocs',
'ea betterdocs',
'search',
'search form',
'ea',
'essential addons'
];
}
public function get_custom_help_url()
{
return 'https://essential-addons.com/elementor/docs/betterdocs-search-form/';
}
protected function register_controls()
{
/*-----------------------------------------------------------------------------------*/
/* Content Tab
/*-----------------------------------------------------------------------------------*/
if (!defined('BETTERDOCS_URL')) {
$this->start_controls_section(
'eael_global_warning',
[
'label' => __('Warning!', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_global_warning_text',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('<strong>BetterDocs</strong> is not installed/activated on your site. Please install and activate <a href="plugin-install.php?s=BetterDocs&tab=search&type=term" target="_blank">BetterDocs</a> first.', 'essential-addons-for-elementor-lite'),
'content_classes' => 'eael-warning',
]
);
$this->end_controls_section();
} else {
/**
* ----------------------------------------------------------
* Section: Search Box
* ----------------------------------------------------------
*/
$this->start_controls_section(
'section_search_box_settings',
[
'label' => __('Search Box', 'essential-addons-for-elementor-lite'),
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'search_box_bg',
'types' => ['classic', 'gradient'],
'selector' => '{{WRAPPER}} .betterdocs-live-search'
]
);
$this->add_responsive_control(
'search_box_padding',
[
'label' => esc_html__('Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'default' => [
'top' => 50,
'right' => 50,
'bottom' => 50,
'left' => 50
],
'selectors' => [
'{{WRAPPER}} .betterdocs-live-search' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
],
]
);
$this->end_controls_section(); # end of 'Search Box'
/**
* ----------------------------------------------------------
* Section: Search Field
* ----------------------------------------------------------
*/
$this->start_controls_section(
'section_search_field_settings',
[
'label' => __('Search Field', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'section_search_field_placeholder',
[
'label' => __('Placeholder', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'default' => esc_html__('Search', 'essential-addons-for-elementor-lite'),
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'search_field_bg',
[
'label' => esc_html__('Field Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .betterdocs-searchform' => 'background: {{VALUE}};',
],
]
);
$this->add_control(
'search_field_text_color',
[
'label' => esc_html__('Field Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .betterdocs-searchform .betterdocs-search-field' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'search_field_text_typography',
'selector' => '{{WRAPPER}} .betterdocs-searchform .betterdocs-search-field'
]
);
$this->add_responsive_control(
'search_field_padding',
[
'label' => __('Field Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .betterdocs-searchform .betterdocs-search-field' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'search_field_padding_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .betterdocs-searchform' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Border::get_type(),
[
'name' => 'search_field_border',
'label' => __('Border', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} .betterdocs-searchform',
]
);
$this->add_group_control(
\Elementor\Group_Control_Box_Shadow::get_type(),
[
'name' => 'search_field_shadow',
'label' => __('Shadow', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} .betterdocs-searchform',
]
);
$this->add_control(
'field_search_icon_heading',
[
'label' => esc_html__('Search Icon', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'field_search_icon_color',
[
'label' => esc_html__('Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .betterdocs-searchform svg.docs-search-icon' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'field_search_icon_size',
[
'label' => esc_html__('Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%', 'em'],
'range' => [
'px' => [
'max' => 500,
],
],
'selectors' => [
'{{WRAPPER}} .betterdocs-searchform svg.docs-search-icon' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'field_close_icon_heading',
[
'label' => esc_html__('Close Icon', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'search_field_close_icon_color',
[
'label' => esc_html__('Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .docs-search-close .close-line' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'search_field_close_icon_border_color',
[
'label' => esc_html__('Border Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .docs-search-loader, {{WRAPPER}} .docs-search-close .close-border' => 'stroke: {{VALUE}};',
],
]
);
$this->end_controls_section(); # end of 'Search Field'
/**
* ----------------------------------------------------------
* Section: Search Result Box
* ----------------------------------------------------------
*/
$this->start_controls_section(
'section_search_result_settings',
[
'label' => __('Search Result Box', 'essential-addons-for-elementor-lite'),
]
);
$this->add_responsive_control(
'result_box_width',
[
'label' => __('Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 100,
'unit' => '%',
],
'size_units' => ['%', 'px', 'em'],
'range' => [
'%' => [
'max' => 100,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .betterdocs-live-search .docs-search-result' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'result_box_max_width',
[
'label' => __('Max Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 1600,
'unit' => 'px',
],
'size_units' => ['px', 'em'],
'range' => [
'px' => [
'max' => 1600,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .betterdocs-live-search .docs-search-result' => 'max-width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'result_box_bg',
'types' => ['classic', 'gradient'],
'selector' => '{{WRAPPER}} .betterdocs-live-search .docs-search-result'
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'result_box_border',
'label' => esc_html__('Border', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} .betterdocs-live-search .docs-search-result',
]
);
$this->end_controls_section(); # end of 'Search Result Box'
/**
* ----------------------------------------------------------
* Section: Search Result Item
* ----------------------------------------------------------
*/
$this->start_controls_section(
'section_search_result_item_settings',
[
'label' => __('Search Result List', 'essential-addons-for-elementor-lite'),
]
);
$this->start_controls_tabs('item_settings_tab');
// Normal State Tab
$this->start_controls_tab(
'item_normal',
['label' => esc_html__('Normal', 'essential-addons-for-elementor-lite')]
);
$this->add_control(
'result_box_item',
[
'label' => esc_html__('Item', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'result_box_item_typography',
'selector' => '{{WRAPPER}} .betterdocs-live-search .docs-search-result li a'
]
);
$this->add_control(
'result_box_item_color',
[
'label' => esc_html__('Item Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .betterdocs-live-search .docs-search-result li a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'result_item_border',
'label' => esc_html__('Border', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} .betterdocs-live-search .docs-search-result li'
]
);
$this->add_responsive_control(
'result_box_item_padding',
[
'label' => __('Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .betterdocs-live-search .docs-search-result li a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'search_result_box_item_count',
[
'label' => esc_html__('Count', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'result_box_item_count_typography',
'selector' => '{{WRAPPER}} .betterdocs-live-search .docs-search-result li span'
]
);
$this->add_control(
'result_box_item_count_color',
[
'label' => esc_html__('Item Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .betterdocs-live-search .docs-search-result li span' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
// Hover State Tab
$this->start_controls_tab(
'item_hover',
['label' => esc_html__('Hover', 'essential-addons-for-elementor-lite')]
);
$this->add_responsive_control(
'result_item_transition',
[
'label' => __('Transition', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 300,
'unit' => '%',
],
'size_units' => ['%'],
'range' => [
'%' => [
'max' => 2500,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .betterdocs-live-search .docs-search-result li, {{WRAPPER}} .betterdocs-live-search .docs-search-result li a, {{WRAPPER}} .betterdocs-live-search .docs-search-result li span, {{WRAPPER}} .betterdocs-live-search .docs-search-result' => 'transition: {{SIZE}}ms;',
],
]
);
$this->add_control(
'result_box_item_hover_heading',
[
'label' => esc_html__('Item', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'result_box_item_hover_bg',
'types' => ['classic', 'gradient'],
'selector' => '{{WRAPPER}} .betterdocs-live-search .docs-search-result li:hover',
'exclude' => [
'image'
]
]
);
$this->add_control(
'result_box_item_hover_color',
[
'label' => esc_html__('Item Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .betterdocs-live-search .docs-search-result li:hover a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'result_item_hover_border',
'label' => esc_html__('Border', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} .betterdocs-live-search .docs-search-result li:hover'
]
);
$this->add_control(
'result_box_item_hover_count_heading',
[
'label' => esc_html__('Count', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'result_box_item_hover_count_color',
[
'label' => esc_html__('Item Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .betterdocs-live-search .docs-search-result li:hover span' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section(); # end of 'Search Result Item'
}
}
protected function render()
{
if (!defined('BETTERDOCS_URL')) return;
$settings = $this->get_settings_for_display();
$shortcode = sprintf('[betterdocs_search_form placeholder="'.$settings['section_search_field_placeholder'].'"]', apply_filters('eael_betterdocs_search_form_params', []));
echo do_shortcode(shortcode_unautop($shortcode));
}
public function render_plain_content()
{
$settings = $this->get_settings_for_display();
// In plain mode, render without shortcode
echo '[betterdocs_search_form placeholder="'.$settings['section_search_field_placeholder'].'"]';
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Widget_Base;
class Career_Page extends Widget_Base {
public function get_name() {
return 'eael-career-page';
}
public function get_title() {
return esc_html__( 'EasyJobs Career Page', 'essential-addons-for-elementor-lite');
}
public function get_icon() {
return 'eaicon-easyjobs';
}
public function get_categories() {
return [ 'essential-addons-elementor' ];
}
public function get_keywords() {
return [
'easyjobs',
'addons',
'ea',
'career',
'job',
'career page',
'essential addons',
];
}
public function get_custom_help_url() {
return 'https://easy.jobs/docs/';
}
protected function register_controls() {
$this->start_controls_section(
'eael_global_warning',
[
'label' => __('Warning!', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_global_warning_text',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('<strong>EasyJobs</strong> is not installed/activated on your site. Please install and activate <a href="plugin-install.php?s=easyjobs&tab=search&type=term" target="_blank">EasyJobs</a> first.',
'essential-addons-for-elementor-lite'),
'content_classes' => 'eael-warning',
]
);
$this->end_controls_section();
}
protected function render() {
return;
}
}

View File

@@ -0,0 +1,841 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Typography;
use Elementor\Modules\DynamicTags\Module as TagsModule;
use \Elementor\Widget_Base;
use \Essential_Addons_Elementor\Classes\Helper;
use \Essential_Addons_Elementor\Classes\Controls;
class Content_Ticker extends Widget_Base
{
use \Essential_Addons_Elementor\Traits\Template_Query;
public function get_name()
{
return 'eael-content-ticker';
}
public function get_title()
{
return esc_html__('Content Ticker', 'essential-addons-for-elementor-lite');
}
public function get_icon()
{
return 'eaicon-content-ticker';
}
public function get_categories()
{
return ['essential-addons-elementor'];
}
public function get_keywords()
{
return [
'ticker',
'ea ticker',
'ea content ticker',
'news headline',
'news ticker',
'text rotate',
'text animation',
'text swing',
'text slide',
'ea',
'essential addons',
];
}
public function get_custom_help_url()
{
return 'https://essential-addons.com/elementor/docs/content-ticker/';
}
protected function register_controls()
{
/**
* Content Ticker Content Settings
*/
$this->start_controls_section(
'eael_section_content_ticker_settings',
[
'label' => esc_html__('Ticker Settings', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_dynamic_template_Layout',
[
'label' => esc_html__('Template Layout', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'default',
'options' => $this->get_template_list_for_dropdown(),
]
);
$ticker_options = apply_filters(
'eael_ticker_options',
[
'options' => [
'dynamic' => esc_html__('Dynamic', 'essential-addons-for-elementor-lite'),
'custom' => esc_html__('Custom', 'essential-addons-for-elementor-lite'),
],
'conditions' => [
'custom',
],
]
);
$this->add_control(
'eael_ticker_type',
[
'label' => esc_html__('Ticker Type', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'dynamic',
'label_block' => false,
'options' => $ticker_options['options'],
]
);
$this->add_control(
'eael_ticker_type_pro_alert',
[
'label' => esc_html__('Custom Content available in pro version only!', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'condition' => [
'eael_ticker_type' => $ticker_options['conditions'],
],
]
);
$this->add_control(
'eael_ticker_tag_text',
[
'label' => esc_html__('Tag Text', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'label_block' => false,
'default' => esc_html__('Trending Today', 'essential-addons-for-elementor-lite'),
'ai' => [
'active' => false,
],
]
);
$this->end_controls_section();
/**
* Query Controls
* @source includes/helper.php
*/
do_action('eael/controls/query', $this);
do_action('eael_ticker_custom_content_controls', $this);
/**
* Content Tab: Carousel Settings
*/
$this->start_controls_section(
'section_additional_options',
[
'label' => __('Animation Settings', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'carousel_effect',
[
'label' => __('Effect', 'essential-addons-for-elementor-lite'),
'description' => __('Sets transition effect', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'slide',
'options' => [
'slide' => __('Slide', 'essential-addons-for-elementor-lite'),
'fade' => __('Fade', 'essential-addons-for-elementor-lite'),
],
]
);
$this->add_control(
'slider_speed',
[
'label' => __('Slider Speed', 'essential-addons-for-elementor-lite'),
'description' => __('Duration of transition between slides (in ms)', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => ['size' => 400],
'range' => [
'px' => [
'min' => 100,
'max' => 3000,
'step' => 1,
],
],
'size_units' => '',
'separator' => 'before',
]
);
$this->add_control(
'autoplay',
[
'label' => __('Autoplay', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'label_on' => __('Yes', 'essential-addons-for-elementor-lite'),
'label_off' => __('No', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
'separator' => 'before',
]
);
$this->add_control(
'autoplay_speed',
[
'label' => __('Autoplay Speed', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => ['size' => 2000],
'range' => [
'px' => [
'min' => 500,
'max' => 5000,
'step' => 1,
],
],
'size_units' => '',
'condition' => [
'autoplay' => 'yes',
],
]
);
$this->add_control(
'pause_on_hover',
[
'label' => __('Pause On Hover', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => '',
'label_on' => __('Yes', 'essential-addons-for-elementor-lite'),
'label_off' => __('No', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
'condition' => [
'autoplay' => 'yes',
],
]
);
$this->add_control(
'infinite_loop',
[
'label' => __('Infinite Loop', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'label_on' => __('Yes', 'essential-addons-for-elementor-lite'),
'label_off' => __('No', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
]
);
$this->add_control(
'grab_cursor',
[
'label' => __('Grab Cursor', 'essential-addons-for-elementor-lite'),
'description' => __('Shows grab cursor when you hover over the slider', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => '',
'label_on' => __('Show', 'essential-addons-for-elementor-lite'),
'label_off' => __('Hide', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
'separator' => 'before',
]
);
$this->add_control(
'navigation_heading',
[
'label' => __('Navigation', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'arrows',
[
'label' => __('Arrows', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'label_on' => __('Yes', 'essential-addons-for-elementor-lite'),
'label_off' => __('No', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
]
);
$this->add_control(
'direction',
[
'label' => __('Direction', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'left',
'options' => [
'left' => __('Left', 'essential-addons-for-elementor-lite'),
'right' => __('Right', 'essential-addons-for-elementor-lite'),
],
'separator' => 'before',
'condition' => [
'carousel_effect' => 'slide',
],
]
);
$this->end_controls_section();
if (!apply_filters('eael/pro_enabled', false)) {
$this->start_controls_section(
'eael_section_pro',
[
'label' => __('Go Premium for More Features', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_control_get_pro',
[
'label' => __('Unlock more possibilities', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'1' => [
'title' => '',
'icon' => 'fa fa-unlock-alt',
],
],
'default' => '1',
'description' => '<span class="pro-feature"> Get the <a href="https://wpdeveloper.com/upgrade/ea-pro" target="_blank">Pro version</a> for more stunning elements and customization options.</span>',
]
);
$this->end_controls_section();
}
/**
* -------------------------------------------
* Tab Style (Ticker Content Style)
* -------------------------------------------
*/
$this->start_controls_section(
'eael_section_ticker_typography_settings',
[
'label' => esc_html__('Ticker Content', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_ticker_content_bg',
[
'label' => esc_html__('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-ticker-wrap .eael-ticker' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_ticker_content_color',
[
'label' => esc_html__('Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#222222',
'selectors' => [
'{{WRAPPER}} .eael-ticker-wrap .eael-ticker .ticker-content a' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_ticker_hover_content_color',
[
'label' => esc_html__('Text Hover Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#f44336',
'selectors' => [
'{{WRAPPER}} .eael-ticker-wrap .eael-ticker .ticker-content a:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_ticker_content_typography',
'selector' => '{{WRAPPER}} .eael-ticker-wrap .eael-ticker .ticker-content a',
]
);
$this->add_responsive_control(
'eael_ticker_content_padding',
[
'label' => esc_html__('Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-ticker-wrap .eael-ticker .ticker-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_ticker_content_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-ticker-wrap .eael-ticker' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_ticker_tag_style_settings',
[
'label' => esc_html__('Tag Style', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_ticker_tag_bg_color',
[
'label' => esc_html__('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#222222',
'selectors' => [
'{{WRAPPER}} .eael-ticker-wrap .ticker-badge' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_ticker_tag_color',
[
'label' => esc_html__('Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .eael-ticker-wrap .ticker-badge span' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_ticker_tag_typography',
'selector' => '{{WRAPPER}} .eael-ticker-wrap .ticker-badge span',
]
);
$this->add_responsive_control(
'eael_ticker_tag_padding',
[
'label' => esc_html__('Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-ticker-wrap .ticker-badge' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_ticker_tag_margin',
[
'label' => esc_html__('Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-ticker-wrap .ticker-badge' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_ticker_tag_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-ticker-wrap .ticker-badge' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
/**
* Style Tab: Arrows
*/
$this->start_controls_section(
'section_arrows_style',
[
'label' => __('Arrows', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'arrows' => 'yes',
],
]
);
$this->add_control(
'prev_arrow',
[
'label' => __('Choose Prev Arrow', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::ICONS,
'label_block' => true,
'default' => [
'value' => 'fas fa-angle-left',
'library' => 'fa-solid',
],
]
);
$this->add_control(
'arrow_new',
[
'label' => __('Choose Next Arrow', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'arrow',
'label_block' => true,
'default' => [
'value' => 'fas fa-angle-right',
'library' => 'fa-solid',
],
]
);
$this->add_responsive_control(
'arrows_size',
[
'label' => __('Arrows Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => ['size' => '22'],
'range' => [
'px' => [
'min' => 5,
'max' => 100,
'step' => 1,
],
],
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev' => 'font-size: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next img, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev img' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next svg, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'left_arrow_position',
[
'label' => __('Align Left Arrow', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => -100,
'max' => 100,
'step' => 1,
],
],
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .swiper-container-wrap .swiper-button-prev' => 'right: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'right_arrow_position',
[
'label' => __('Align Right Arrow', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => -100,
'max' => 100,
'step' => 1,
],
],
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next' => 'right: {{SIZE}}{{UNIT}};',
],
]
);
$this->start_controls_tabs('tabs_arrows_style');
$this->start_controls_tab(
'tab_arrows_normal',
[
'label' => __('Normal', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'arrows_bg_color_normal',
[
'label' => __('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'arrows_color_normal',
[
'label' => __('Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev' => 'color: {{VALUE}};',
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next svg, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev svg' => 'fill: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'arrows_border_normal',
'label' => __('Border', 'essential-addons-for-elementor-lite'),
'placeholder' => '1px',
'default' => '1px',
'selector' => '{{WRAPPER}} .swiper-container-wrap .swiper-button-next, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev',
]
);
$this->add_control(
'arrows_border_radius_normal',
[
'label' => __('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'tab_arrows_hover',
[
'label' => __('Hover', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'arrows_bg_color_hover',
[
'label' => __('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next:hover, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev:hover' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'arrows_color_hover',
[
'label' => __('Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next:hover, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev:hover' => 'color: {{VALUE}};',
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next:hover svg, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev:hover svg' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'arrows_border_color_hover',
[
'label' => __('Border Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next:hover, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev:hover' => 'border-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_responsive_control(
'arrows_padding',
[
'label' => __('Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .swiper-container-wrap .swiper-button-next, {{WRAPPER}} .swiper-container-wrap .swiper-button-prev' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'separator' => 'before',
]
);
$this->end_controls_section();
}
protected function render()
{
$settings = $this->get_settings_for_display();
$settings = Helper::fix_old_query($settings);
$args = Helper::get_query_args($settings);
$this->add_render_attribute('content-ticker-wrap', 'class', 'swiper-container-wrap eael-ticker');
$this->add_render_attribute('content-ticker', 'class', 'swiper-container eael-content-ticker');
$this->add_render_attribute('content-ticker', 'class', 'swiper-container-' . esc_attr($this->get_id()));
$this->add_render_attribute('content-ticker', 'data-pagination', '.swiper-pagination-' . esc_attr($this->get_id()));
$this->add_render_attribute('content-ticker', 'data-arrow-next', '.swiper-button-next-' . esc_attr($this->get_id()));
$this->add_render_attribute('content-ticker', 'data-arrow-prev', '.swiper-button-prev-' . esc_attr($this->get_id()));
if ($settings['direction'] == 'right') {
$this->add_render_attribute('content-ticker', 'dir', 'rtl');
}
if (!empty($settings['margin_tablet']['size'])) {
$this->add_render_attribute('content-ticker', 'data-margin-tablet', $settings['margin_tablet']['size']);
}
if (!empty($settings['margin_mobile']['size'])) {
$this->add_render_attribute('content-ticker', 'data-margin-mobile', $settings['margin_mobile']['size']);
}
if ($settings['carousel_effect']) {
$this->add_render_attribute('content-ticker', 'data-effect', $settings['carousel_effect']);
}
if (!empty($settings['slider_speed']['size'])) {
$this->add_render_attribute('content-ticker', 'data-speed', $settings['slider_speed']['size']);
}
if ($settings['autoplay'] == 'yes' && !empty($settings['autoplay_speed']['size'])) {
$this->add_render_attribute('content-ticker', 'data-autoplay', $settings['autoplay_speed']['size']);
} else {
$this->add_render_attribute('content-ticker', 'data-autoplay', '999999');
}
if ($settings['pause_on_hover'] == 'yes') {
$this->add_render_attribute('content-ticker', 'data-pause-on-hover', 'true');
}
if ($settings['infinite_loop'] == 'yes') {
$this->add_render_attribute('content-ticker', 'data-loop', true);
}
if ($settings['grab_cursor'] == 'yes') {
$this->add_render_attribute('content-ticker', 'data-grab-cursor', true);
}
if ($settings['arrows'] == 'yes') {
$this->add_render_attribute('content-ticker', 'data-arrows', '1');
}
echo '<div class="eael-ticker-wrap" id="eael-ticker-wrap-' . $this->get_id() . '">';
if (!empty($settings['eael_ticker_tag_text'])) {
echo '<div class="ticker-badge">
<span>' . Helper::eael_wp_kses($settings['eael_ticker_tag_text']) . '</span>
</div>';
}
echo '<div ' . $this->get_render_attribute_string('content-ticker-wrap') . '>
<div ' . $this->get_render_attribute_string('content-ticker') . '>
<div class="swiper-wrapper">';
if ('dynamic' === $settings['eael_ticker_type']) {
if (\file_exists($this->get_template($settings['eael_dynamic_template_Layout']))) {
$query = new \WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
include $this->get_template($settings['eael_dynamic_template_Layout']);
}
wp_reset_postdata();
}
} else {
echo '<div class="swiper-slide"><a href="#" class="ticker-content">' . __('No content found!', 'essential-addons-for-elementor-lite') . '</a></div>';
}
} elseif ('custom' === $settings['eael_ticker_type'] && apply_filters('eael/is_plugin_active', 'essential-addons-elementor/essential_adons_elementor.php')) {
if (\file_exists($this->get_template($settings['eael_dynamic_template_Layout']))) {
foreach ($settings['eael_ticker_custom_contents'] as $content) {
echo Helper::include_with_variable($this->get_template($settings['eael_dynamic_template_Layout']), ['content' => Helper::eael_wp_kses($content['eael_ticker_custom_content']), 'link' => $content['eael_ticker_custom_content_link']]);
}
}
}
echo '</div>
</div>
' . $this->render_arrows() . '
</div>
</div>';
}
/**
* Render Content Ticker arrows output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @access protected
*/
protected function render_arrows()
{
$settings = $this->get_settings_for_display();
if ($settings['arrows'] == 'yes') {
if (isset($settings['__fa4_migrated']['arrow_new']) || empty($settings['arrow'])) {
$arrow = Helper::get_render_icon( $settings['arrow_new'] );
} else {
$arrow = '<i class="' . esc_attr( $settings['arrow'] ) . '"></i>';
}
$html = '<div class="content-ticker-pagination">';
$html .= '<div class="swiper-button-next swiper-button-next-' . $this->get_id() . '">';
if (isset($arrow['url'])) {
$html .= '<img src="' . esc_url($arrow['url']) . '" alt="' . esc_attr(get_post_meta($arrow['id'], '_wp_attachment_image_alt', true)) . '" />';
} else {
$html .= $arrow;
}
$html .= '</div>';
$html .= '<div class="swiper-button-prev swiper-button-prev-' . $this->get_id() . '">';
if (isset($settings['prev_arrow']['value']['url'])) {
$html .= '<img src="' . esc_url($settings['prev_arrow']['value']['url']) . '" alt="' . esc_attr(get_post_meta($settings['prev_arrow']['value']['id'], '_wp_attachment_image_alt', true)) . '" />';
} else {
$html .= Helper::get_render_icon( $settings['prev_arrow'] );
}
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,630 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Background;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Typography;
use Elementor\Icons_Manager;
use Elementor\Modules\DynamicTags\Module as TagsModule;
use \Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use \Elementor\Widget_Base;
use Essential_Addons_Elementor\Classes\Helper;
class Creative_Button extends Widget_Base
{
public function get_name()
{
return 'eael-creative-button';
}
public function get_title()
{
return esc_html__('Creative Button', 'essential-addons-for-elementor-lite');
}
public function get_icon()
{
return 'eaicon-creative-button';
}
public function get_categories()
{
return ['essential-addons-elementor'];
}
public function get_keywords()
{
return [
'button',
'ea button',
'creative button',
'ea creative button',
'cta',
'call to action',
'ea',
'marketing button',
'essential addons',
];
}
public function get_custom_help_url()
{
return 'https://essential-addons.com/elementor/docs/creative-buttons/';
}
protected function register_controls()
{
if ( !apply_filters( 'eael/pro_enabled', false ) ) {
// Content Controls
$this->start_controls_section(
'eael_section_creative_button_content',
[
'label' => esc_html__('Button Content', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'creative_button_text',
[
'label' => __('Button Text', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'label_block' => true,
'default' => 'Click Me!',
'placeholder' => __('Enter button text', 'essential-addons-for-elementor-lite'),
'title' => __('Enter button text here', 'essential-addons-for-elementor-lite'),
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'creative_button_secondary_text',
[
'label' => __('Button Secondary Text', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'label_block' => true,
'default' => 'Go!',
'placeholder' => __('Enter button secondary text', 'essential-addons-for-elementor-lite'),
'title' => __('Enter button secondary text here', 'essential-addons-for-elementor-lite'),
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'creative_button_link_url',
[
'label' => esc_html__('Link URL', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::URL,
'dynamic' => [
'active' => true,
'categories' => [
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
],
],
'label_block' => true,
'default' => [
'url' => '#',
'is_external' => '',
],
'show_external' => true,
]
);
$this->add_control(
'eael_creative_button_icon_new',
[
'label' => esc_html__('Icon', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'eael_creative_button_icon',
'condition' => [
'creative_button_effect!' => ['eael-creative-button--tamaya'],
],
]
);
$this->add_control(
'eael_creative_button_icon_alignment',
[
'label' => esc_html__('Icon Position', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'left',
'options' => [
'left' => esc_html__('Before', 'essential-addons-for-elementor-lite'),
'right' => esc_html__('After', 'essential-addons-for-elementor-lite'),
],
'condition' => [
'eael_creative_button_icon_new!' => '',
'creative_button_effect!' => ['eael-creative-button--tamaya'],
],
]
);
$this->add_responsive_control(
'eael_creative_button_icon_indent',
[
'label' => esc_html__('Icon Spacing', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 60,
],
],
'condition' => [
'eael_creative_button_icon_new!' => '',
'creative_button_effect!' => ['eael-creative-button--tamaya'],
],
'selectors' => [
'{{WRAPPER}} .eael-creative-button-icon-right' => 'margin-left: {{SIZE}}px;',
'{{WRAPPER}} .eael-creative-button-icon-left' => 'margin-right: {{SIZE}}px;',
'{{WRAPPER}} .eael-creative-button--shikoba i' => 'left: {{SIZE}}%;',
],
]
);
$this->end_controls_section();
} else {
do_action('eael_creative_button_pro_controls', $this);
}
if ( !apply_filters( 'eael/pro_enabled', false ) ) {
$this->start_controls_section(
'eael_section_pro',
[
'label' => __('Go Premium for More Features', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_control_get_pro',
[
'label' => __('Unlock more possibilities', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'1' => [
'title' => '',
'icon' => 'fa fa-unlock-alt',
],
],
'default' => '1',
'description' => '<span class="pro-feature"> Get the <a href="https://wpdeveloper.com/upgrade/ea-pro" target="_blank">Pro version</a> for more stunning elements and customization options.</span>',
]
);
$this->end_controls_section();
}
// Style Controls
$this->start_controls_section(
'eael_section_creative_button_settings',
[
'label' => esc_html__('Button Effects &amp; Styles', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
if (!apply_filters('eael/pro_enabled', false)) {
$this->add_control(
'creative_button_effect',
[
'label' => esc_html__('Set Button Effect', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'eael-creative-button--default',
'options' => [
'eael-creative-button--default' => esc_html__('Default', 'essential-addons-for-elementor-lite'),
'eael-creative-button--winona' => esc_html__('Winona', 'essential-addons-for-elementor-lite'),
'eael-creative-button--ujarak' => esc_html__('Ujarak', 'essential-addons-for-elementor-lite'),
'eael-creative-button--wayra' => esc_html__('Wayra', 'essential-addons-for-elementor-lite'),
'eael-creative-button--tamaya' => esc_html__('Tamaya', 'essential-addons-for-elementor-lite'),
'eael-creative-button--rayen' => esc_html__('Rayen', 'essential-addons-for-elementor-lite'),
'eael-creative-button--pipaluk' => esc_html__('Pipaluk (Pro)', 'essential-addons-for-elementor-lite'),
'eael-creative-button--moema' => esc_html__('Moema (Pro)', 'essential-addons-for-elementor-lite'),
'eael-creative-button--wave' => esc_html__('Wave (Pro)', 'essential-addons-for-elementor-lite'),
'eael-creative-button--aylen' => esc_html__('Aylen (Pro)', 'essential-addons-for-elementor-lite'),
'eael-creative-button--saqui' => esc_html__('Saqui (Pro)', 'essential-addons-for-elementor-lite'),
'eael-creative-button--wapasha' => esc_html__('Wapasha (Pro)', 'essential-addons-for-elementor-lite'),
'eael-creative-button--nuka' => esc_html__('Nuka (Pro)', 'essential-addons-for-elementor-lite'),
'eael-creative-button--antiman' => esc_html__('Antiman (Pro)', 'essential-addons-for-elementor-lite'),
'eael-creative-button--quidel' => esc_html__('Quidel (Pro)', 'essential-addons-for-elementor-lite'),
'eael-creative-button--shikoba' => esc_html__('Shikoba (Pro)', 'essential-addons-for-elementor-lite'),
],
'description' => '10 more effects on <a href="https://wpdeveloper.com/in/upgrade-essential-addons-elementor">Pro version</a>',
]
);
$this->add_control(
'use_gradient_background',
[
'label' => __('Use Gradient Background', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'essential-addons-for-elementor-lite'),
'label_off' => __('Hide', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
'default' => '',
]
);
$this->start_controls_tabs('eael_creative_button_tabs');
$this->start_controls_tab('normal', ['label' => esc_html__('Normal', 'essential-addons-for-elementor-lite')]);
$this->add_control('eael_creative_button_icon_color',
[
'label' => esc_html__('Icon Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#ffffff',
'selectors' => [
'{{WRAPPER}} .eael-creative-button i' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button .creative-button-inner svg' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'eael_creative_button_text_color',
[
'label' => esc_html__( 'Text Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => '#ffffff',
'selectors' => [
'{{WRAPPER}} .eael-creative-button' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button svg' => 'fill: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button .eael-creative-button--tamaya-secondary' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_creative_button_background_color',
[
'label' => esc_html__('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#f54',
'selectors' => [
'{{WRAPPER}} .eael-creative-button' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--ujarak:hover' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--wayra:hover' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--tamaya::before' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--tamaya::after' => 'background-color: {{VALUE}};',
],
'condition' => [
'use_gradient_background' => '',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'eael_creative_button_gradient_background',
'types' => ['gradient', 'classic'],
'selector' => '
{{WRAPPER}} .eael-creative-button,
{{WRAPPER}} .eael-creative-button.eael-creative-button--ujarak:hover,
{{WRAPPER}} .eael-creative-button.eael-creative-button--wayra:hover,
{{WRAPPER}} .eael-creative-button.eael-creative-button--tamaya::before,
{{WRAPPER}} .eael-creative-button.eael-creative-button--tamaya::after
',
'condition' => [
'use_gradient_background' => 'yes',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_creative_button_border',
'selector' => '{{WRAPPER}} .eael-creative-button',
]
);
$this->add_control(
'eael_creative_button_border_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .eael-creative-button' => 'border-radius: {{SIZE}}px;',
'{{WRAPPER}} .eael-creative-button::before' => 'border-radius: {{SIZE}}px;',
'{{WRAPPER}} .eael-creative-button::after' => 'border-radius: {{SIZE}}px;',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab('eael_creative_button_hover', ['label' => esc_html__('Hover', 'essential-addons-for-elementor-lite')]);
$this->add_control('eael_creative_button_hover_icon_color',
[
'label' => esc_html__('Icon Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#ffffff',
'selectors' => [
'{{WRAPPER}} .eael-creative-button:hover i' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button:hover .creative-button-inner svg' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'eael_creative_button_hover_text_color',
[
'label' => esc_html__('Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#ffffff',
'selectors' => [
'{{WRAPPER}} .eael-creative-button:hover .cretive-button-text' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--winona::after' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--rayen:hover::before' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_creative_button_hover_background_color',
[
'label' => esc_html__('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#f54',
'selectors' => [
'{{WRAPPER}} .eael-creative-button:hover' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--ujarak::before' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--wayra:hover::before' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--tamaya:hover' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--rayen::before' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--rayen:hover::before' => 'background-color: {{VALUE}};',
],
'condition' => [
'use_gradient_background' => '',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'eael_creative_button_hover_gradient_background',
'types' => ['gradient', 'classic'],
'selector' => '
{{WRAPPER}} .eael-creative-button:hover,
{{WRAPPER}} .eael-creative-button.eael-creative-button--ujarak::before,
{{WRAPPER}} .eael-creative-button.eael-creative-button--wayra:hover::before,
{{WRAPPER}} .eael-creative-button.eael-creative-button--tamaya:hover,
{{WRAPPER}} .eael-creative-button.eael-creative-button--rayen::before,
{{WRAPPER}} .eael-creative-button.eael-creative-button--rayen:hover::before
',
'condition' => [
'use_gradient_background' => 'yes',
],
]
);
$this->add_control(
'eael_creative_button_hover_border_color',
[
'label' => esc_html__('Border Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-creative-button:hover' => 'border-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--wapasha::before' => 'border-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--antiman::before' => 'border-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--pipaluk::before' => 'border-color: {{VALUE}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--quidel::before' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_responsive_control(
'eael_creative_button_alignment',
[
'label' => esc_html__('Button Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'label_block' => true,
'options' => [
'flex-start' => [
'title' => esc_html__('Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__('Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-center',
],
'flex-end' => [
'title' => esc_html__('Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-right',
],
],
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-creative-button-wrapper' => 'justify-content: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'eael_creative_button_width',
[
'label' => esc_html__('Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%'],
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .eael-creative-button' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_creative_button_typography',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
],
'selector' => '{{WRAPPER}} .eael-creative-button .cretive-button-text, {{WRAPPER}} .eael-creative-button--winona::after, {{WRAPPER}} .eael-creative-button--rayen::before, {{WRAPPER}} .eael-creative-button--tamaya::after, {{WRAPPER}} .eael-creative-button--tamaya::before',
]
);
$this->add_responsive_control(
'eael_creative_button_icon_size',
[
'label' => esc_html__('Icon Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%'],
'default' => [
'size' => 30,
'unit' => 'px',
],
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .eael-creative-button i' => 'font-size: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .eael-creative-button svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_creative_button_padding',
[
'label' => esc_html__('Button Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-creative-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--winona::after' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--winona > .creative-button-inner' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--tamaya::before' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--rayen::before' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--rayen > .creative-button-inner' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-creative-button.eael-creative-button--saqui::after' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
} else {
do_action('eael_creative_button_style_pro_controls', $this);
}
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'button_box_shadow',
'selector' => '{{WRAPPER}} .eael-creative-button',
]
);
$this->end_controls_section();
}
protected function render()
{
$settings = $this->get_settings_for_display();
$icon_migrated = isset($settings['__fa4_migrated']['eael_creative_button_icon_new']);
$icon_is_new = empty($settings['eael_creative_button_icon']);
$this->add_render_attribute('eael_creative_button', [
'class' => ['eael-creative-button', esc_attr($settings['creative_button_effect'])],
]);
if ( ! empty( $settings['creative_button_link_url']['url'] ) ) {
$this->add_link_attributes( 'eael_creative_button', $settings['creative_button_link_url'] );
}
if ($settings['creative_button_link_url']['is_external']) {
$this->add_render_attribute('eael_creative_button', 'target');
}
if ($settings['creative_button_link_url']['nofollow']) {
$this->add_render_attribute('eael_creative_button', 'rel', 'nofollow');
}
$this->add_render_attribute('eael_creative_button', 'data-text', esc_attr($settings['creative_button_secondary_text']));
?>
<div class="eael-creative-button-wrapper">
<a <?php echo $this->get_render_attribute_string('eael_creative_button'); ?>>
<?php if ($settings['creative_button_effect'] === 'eael-creative-button--tamaya' ) : ?>
<div class="eael-creative-button--tamaya-secondary eael-creative-button--tamaya-before"><span><?php echo Helper::eael_wp_kses($settings['creative_button_secondary_text']); ?></span></div>
<?php endif; ?>
<div class="creative-button-inner">
<?php if ($settings['creative_button_effect'] !== 'eael-creative-button--tamaya' && $settings['eael_creative_button_icon_alignment'] == 'left') : ?>
<?php if ($icon_migrated || $icon_is_new) {
echo '<span class="eael-creative-button-icon-left">';
Icons_Manager::render_icon( $settings['eael_creative_button_icon_new'], [ 'aria-hidden' => 'true' ] );
echo '</span>';
} else { ?>
<i class="<?php echo esc_attr($settings['eael_creative_button_icon']); ?> eael-creative-button-icon-left" aria-hidden="true"></i>
<?php } ?>
<?php endif; ?>
<span class="cretive-button-text"><?php echo Helper::eael_wp_kses($settings['creative_button_text']); ?></span>
<?php if ($settings['creative_button_effect'] !== 'eael-creative-button--tamaya' && $settings['eael_creative_button_icon_alignment'] == 'right') : ?>
<?php if ($icon_migrated || $icon_is_new) {
echo '<span class="eael-creative-button-icon-right">';
Icons_Manager::render_icon( $settings['eael_creative_button_icon_new'], [ 'aria-hidden' => 'true' ] );
echo '</span>';
} else { ?>
<i class="<?php echo esc_attr($settings['eael_creative_button_icon']); ?> eael-creative-button-icon-right" aria-hidden="true"></i>
<?php } ?>
<?php endif; ?>
</div>
<?php if ($settings['creative_button_effect'] === 'eael-creative-button--tamaya' ) : ?>
<div class="eael-creative-button--tamaya-secondary eael-creative-button--tamaya-after"><span><?php echo Helper::eael_wp_kses($settings['creative_button_secondary_text']); ?></span></div>
<?php endif; ?>
</a>
</div>
<?php
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Widget_Base;
class EmbedPress extends Widget_Base {
public function get_name() {
return 'eael-embedpress';
}
public function get_title() {
return esc_html__( 'EmbedPress', 'essential-addons-for-elementor-lite');
}
public function get_icon() {
return 'eaicon-embedpress';
}
public function get_categories() {
return [ 'essential-addons-elementor' ];
}
public function get_keywords() {
return [
'embedpress',
'ea embedpress',
'audio',
'video',
'map',
'youtube',
'vimeo',
'wistia',
'google',
'ea',
'essential addons'
];
}
public function get_custom_help_url() {
return 'https://embedpress.com/documentation';
}
protected function register_controls() {
$this->start_controls_section(
'eael_global_warning',
[
'label' => __('Warning!', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_global_warning_text',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('<strong>EmbedPress</strong> is not installed/activated on your site. Please install and activate <a href="plugin-install.php?s=embedpress&tab=search&type=term" target="_blank">EmbedPress</a> first.',
'essential-addons-for-elementor-lite'),
'content_classes' => 'eael-warning',
]
);
$this->end_controls_section();
}
protected function render() {
return;
}
}

View File

@@ -0,0 +1,654 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Background;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Typography;
use \Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use \Elementor\Widget_Base;
use \Elementor\Repeater;
use Essential_Addons_Elementor\Classes\Helper as HelperClass;
class Fancy_Text extends Widget_Base {
public function get_name() {
return 'eael-fancy-text';
}
public function get_title() {
return esc_html__( 'Fancy Text', 'essential-addons-for-elementor-lite');
}
public function get_icon() {
return 'eaicon-fancy-text';
}
public function get_categories() {
return [ 'essential-addons-elementor' ];
}
public function get_keywords() {
return [
'ea fancy text',
'ea typing text',
'animated headline',
'Headline',
'typewriter',
'text effect',
'text typing effect',
'text animation',
'animated heading',
'ea',
'essential addons'
];
}
public function get_style_depends() {
return [
'e-animations',
];
}
public function get_custom_help_url() {
return 'https://essential-addons.com/elementor/docs/fancy-text/';
}
protected function register_controls() {
// Content Controls
$this->start_controls_section(
'eael_fancy_text_content',
[
'label' => esc_html__( 'Fancy Text', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_fancy_text_prefix',
[
'label' => esc_html__( 'Prefix Text', 'essential-addons-for-elementor-lite'),
'placeholder' => esc_html__( 'Place your prefix text', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'This is the ', 'essential-addons-for-elementor-lite'),
'dynamic' => [ 'active' => true ],
'ai' => [
'active' => false,
],
]
);
$repeater = new Repeater();
$repeater->add_control(
'eael_fancy_text_strings_text_field',
[
'label' => esc_html__( 'Fancy String', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'dynamic' => [ 'active' => true ],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eael_fancy_text_strings',
[
'label' => __( 'Fancy Text Strings', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::REPEATER,
'show_label' => true,
'fields' => $repeater->get_controls(),
'title_field' => '{{ eael_fancy_text_strings_text_field }}',
'default' => [
[
'eael_fancy_text_strings_text_field' => __( 'First string', 'essential-addons-for-elementor-lite'),
],
[
'eael_fancy_text_strings_text_field' => __( 'Second string', 'essential-addons-for-elementor-lite'),
],
[
'eael_fancy_text_strings_text_field' => __( 'Third string', 'essential-addons-for-elementor-lite'),
]
],
]
);
$this->add_control(
'eael_fancy_text_suffix',
[
'label' => esc_html__( 'Suffix Text', 'essential-addons-for-elementor-lite'),
'placeholder' => esc_html__( 'Place your suffix text', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( ' of the sentence.', 'essential-addons-for-elementor-lite'),
'dynamic' => [ 'active' => true ],
'ai' => [
'active' => false,
],
]
);
$this->end_controls_section();
// Settings Control
$this->start_controls_section(
'eael_fancy_text_settings',
[
'label' => esc_html__( 'Fancy Text Settings', 'essential-addons-for-elementor-lite')
]
);
$style_options = apply_filters(
'fancy_text_style_types',
[
'styles' => [
'style-1' => esc_html__( 'Style 1', 'essential-addons-for-elementor-lite'),
'style-2' => esc_html__( 'Style 2 (Pro)', 'essential-addons-for-elementor-lite'),
],
'conditions' => ['style-2']
]
);
$this->add_control(
'eael_fancy_text_style',
[
'label' => esc_html__( 'Style Type', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'style-1',
'options' => $style_options['styles']
]
);
$this->add_control(
'eael_fancy_text_style_pro_alert',
[
'label' => esc_html__( 'Only available in pro version!', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'condition' => [
'eael_fancy_text_style' => $style_options['conditions'],
]
]
);
$this->add_responsive_control(
'eael_fancy_text_alignment',
[
'label' => esc_html__( 'Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'center',
'selectors' => [
'{{WRAPPER}} .eael-fancy-text-container' => 'text-align: {{VALUE}}',
],
]
);
$this->add_control(
'eael_fancy_text_transition_type',
[
'label' => esc_html__( 'Animation Type', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'typing',
'options' => [
'typing' => esc_html__( 'Typing', 'essential-addons-for-elementor-lite'),
'fadeIn' => esc_html__( 'Fade', 'essential-addons-for-elementor-lite'),
'fadeInUp' => esc_html__( 'Fade Up', 'essential-addons-for-elementor-lite'),
'fadeInDown' => esc_html__( 'Fade Down', 'essential-addons-for-elementor-lite'),
'fadeInLeft' => esc_html__( 'Fade Left', 'essential-addons-for-elementor-lite'),
'fadeInRight' => esc_html__( 'Fade Right', 'essential-addons-for-elementor-lite'),
'zoomIn' => esc_html__( 'Zoom', 'essential-addons-for-elementor-lite'),
'bounceIn' => esc_html__( 'Bounce', 'essential-addons-for-elementor-lite'),
'swing' => esc_html__( 'Swing', 'essential-addons-for-elementor-lite'),
],
]
);
$this->add_control(
'eael_fancy_text_speed',
[
'label' => esc_html__( 'Typing Speed', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::NUMBER,
'default' => '50',
'condition' => [
'eael_fancy_text_transition_type' => 'typing',
],
]
);
$this->add_control(
'eael_fancy_text_delay',
[
'label' => esc_html__( 'Delay on Change', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::NUMBER,
'default' => '2500'
]
);
$this->add_control(
'eael_fancy_text_loop',
[
'label' => esc_html__( 'Loop the animation', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'return_value' => 'yes',
'default' => 'yes'
]
);
$this->add_control(
'eael_fancy_text_cursor',
[
'label' => esc_html__( 'Display Type Cursor', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'eael_fancy_text_transition_type' => 'typing',
],
]
);
$this->end_controls_section();
if(!apply_filters('eael/pro_enabled', false)) {
$this->start_controls_section(
'eael_section_pro',
[
'label' => __( 'Go Premium for More Features', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_control_get_pro',
[
'label' => __( 'Unlock more possibilities', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'1' => [
'title' => '',
'icon' => 'fa fa-unlock-alt',
],
],
'default' => '1',
'description' => '<span class="pro-feature"> Get the <a href="https://wpdeveloper.com/upgrade/ea-pro" target="_blank">Pro version</a> for more stunning elements and customization options.</span>'
]
);
$this->end_controls_section();
}
$this->start_controls_section(
'eael_fancy_text_prefix_styles',
[
'label' => esc_html__( 'Prefix Text Styles', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE
]
);
$this->add_control(
'eael_fancy_text_prefix_color',
[
'label' => esc_html__( 'Prefix Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-fancy-text-prefix' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'typography',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_PRIMARY
],
'fields_options' => [
'typography' => ['default' => 'yes'],
'font_size' => ['default' => ['size' => 22]],
'font_weight' => ['default' => 600],
'line_height' => ['default' => ['size' => 1]],
],
'selector' => '{{WRAPPER}} .eael-fancy-text-prefix',
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_fancy_text_strings_styles',
[
'label' => esc_html__( 'Fancy Text Styles', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE
]
);
$this->add_control(
'eael_fancy_text_color_selector',
[
'label' => esc_html__('Choose Background Type', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'solid-color' => [
'title' => __('Color', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-paint-brush',
],
'gradient-color' => [
'title' => __('Gradient', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-barcode',
],
],
'toggle' => true,
'default' => 'solid-color',
'condition' => [
'eael_fancy_text_style' => 'style-1',
]
]
);
$this->add_control(
'eael_fancy_text_strings_background_color',
[
'label' => esc_html__( 'Background', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-fancy-text-strings' => 'background: {{VALUE}};',
],
'conditions' => [
'relation' => 'or',
'terms' => [
[
'terms' => [
[
'name' => 'eael_fancy_text_color_selector',
'operator' => '==',
'value' => 'solid-color',
],
],
],
[
'name' => 'eael_fancy_text_style',
'operator' => '==',
'value' => 'style-2',
],
],
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'eael_fancy_text_color_gradient',
'types' => ['gradient'],
'fields_options' => [
'background' => [
'label' => _x( 'Gradient Color', 'Text Shadow Control', 'elementor' ),
'toggle' => false,
'default' => 'gradient',
],
'color' => [
'default' => '#062ACA',
],
'color_b' => [
'default' => '#9401D9',
]
],
'selector' => '{{WRAPPER}} .eael-fancy-text-strings',
'condition' => [
'eael_fancy_text_color_selector' => 'gradient-color',
'eael_fancy_text_style' => 'style-1',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_fancy_text_strings_typography',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_PRIMARY
],
'fields_options' => [
'typography' => ['default' => 'yes'],
'font_size' => ['default' => ['size' => 22]],
'font_weight' => ['default' => 600],
],
'selector' => '{{WRAPPER}} .eael-fancy-text-strings, {{WRAPPER}} .typed-cursor',
]
);
$this->add_control(
'eael_fancy_text_strings_color',
[
'label' => esc_html__( 'Solid Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-fancy-text-strings' => 'color: {{VALUE}};',
],
'conditions' => [
'relation' => 'or',
'terms' => [
[
'terms' => [
[
'name' => 'eael_fancy_text_style',
'operator' => '==',
'value' => 'style-1',
]
],
],
[
'name' => 'eael_fancy_text_style',
'operator' => '==',
'value' => 'style-2',
],
],
],
]
);
$this->add_control(
'eael_fancy_text_cursor_color',
[
'label' => esc_html__( 'Typing Cursor Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-fancy-text-strings::after' => 'color: {{VALUE}};',
],
'condition' => [
'eael_fancy_text_cursor' => 'yes',
],
]
);
$this->add_responsive_control(
'eael_fancy_text_strings_padding',
[
'label' => esc_html__( 'Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-fancy-text-strings' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_fancy_text_strings_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-fancy-text-strings' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_fancy_text_strings_border',
'selector' => '{{WRAPPER}} .eael-fancy-text-strings',
]
);
$this->add_control(
'eael_fancy_text_strings_border_radius',
[
'label' => esc_html__( 'Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .eael-fancy-text-strings' => 'border-radius: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_fancy_text_suffix_styles',
[
'label' => esc_html__( 'Suffix Text Styles', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE
]
);
$this->add_control(
'eael_fancy_text_suffix_color',
[
'label' => esc_html__( 'Suffix Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-fancy-text-suffix' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'ending_typography',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_PRIMARY
],
'fields_options' => [
'typography' => ['default' => 'yes'],
'font_size' => ['default' => ['size' => 22]],
'font_weight' => ['default' => 600],
'line_height' => ['default' => ['size' => 1]],
],
'selector' => '{{WRAPPER}} .eael-fancy-text-suffix',
]
);
$this->end_controls_section();
}
public function fancy_text($settings) {
$fancy_text = array("");
foreach ( $settings as $item ) {
if ( ! empty( $item['eael_fancy_text_strings_text_field'] ) ) {
$fancy_text[] = HelperClass::eael_wp_kses($item['eael_fancy_text_strings_text_field']) ;
}
}
return implode("|",$fancy_text);
}
protected function render() {
$settings = $this->get_settings_for_display();
$fancy_text = $this->fancy_text($settings['eael_fancy_text_strings']);
if(!apply_filters('eael/pro_enabled', false)) { $settings['eael_fancy_text_style'] = 'style-1'; }
$this->add_render_attribute( 'fancy-text', 'class', 'eael-fancy-text-container' );
$this->add_render_attribute( 'fancy-text', 'class', esc_attr($settings['eael_fancy_text_style']) );
$this->add_render_attribute( 'fancy-text', 'data-fancy-text-id', esc_attr($this->get_id()) );
$this->add_render_attribute( 'fancy-text', 'data-fancy-text', $fancy_text );
$this->add_render_attribute( 'fancy-text', 'data-fancy-text-transition-type', $settings['eael_fancy_text_transition_type'] );
$this->add_render_attribute( 'fancy-text', 'data-fancy-text-speed', $settings['eael_fancy_text_speed'] );
$this->add_render_attribute( 'fancy-text', 'data-fancy-text-delay', $settings['eael_fancy_text_delay'] );
$this->add_render_attribute( 'fancy-text', 'data-fancy-text-cursor', $settings['eael_fancy_text_cursor'] );
$this->add_render_attribute( 'fancy-text', 'data-fancy-text-loop', $settings['eael_fancy_text_loop'] );
?>
<div <?php echo $this->get_render_attribute_string( 'fancy-text' ); ?> >
<?php if ( ! empty( $settings['eael_fancy_text_prefix'] ) ) : ?>
<span class="eael-fancy-text-prefix"><?php echo HelperClass::eael_wp_kses($settings['eael_fancy_text_prefix']); ?> </span>
<?php endif; ?>
<?php if ( $settings['eael_fancy_text_transition_type'] == 'fancy' ) : ?>
<span id="eael-fancy-text-<?php echo esc_attr($this->get_id()); ?>" class="eael-fancy-text-strings
<?php echo esc_attr( $settings['eael_fancy_text_color_selector'] ) ?>"></span>
<?php endif; ?>
<?php if ( $settings['eael_fancy_text_transition_type'] != 'fancy' ) : ?>
<span id="eael-fancy-text-<?php echo esc_attr($this->get_id()); ?>" class="eael-fancy-text-strings <?php echo esc_attr( $settings['eael_fancy_text_color_selector'] ); ?>">
<noscript>
<?php
$eael_fancy_text_strings_list = "";
foreach ( $settings['eael_fancy_text_strings'] as $item ) {
$eael_fancy_text_strings_list .= HelperClass::eael_wp_kses($item['eael_fancy_text_strings_text_field']) . ', ';
}
echo rtrim($eael_fancy_text_strings_list, ", ");
?>
</noscript>
</span>
<?php endif; ?>
<?php if ( ! empty( $settings['eael_fancy_text_suffix'] ) ) : ?>
<span class="eael-fancy-text-suffix"> <?php echo HelperClass::eael_wp_kses($settings['eael_fancy_text_suffix']); ?></span>
<?php endif; ?>
</div><!-- close .eael-fancy-text-container -->
<div class="clearfix"></div>
<?php
}
protected function content_template() {}
}

View File

@@ -0,0 +1,983 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if ( !defined( 'ABSPATH' ) ) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Background;
use \Elementor\Group_Control_Typography;
use \Elementor\Icons_Manager;
use \Elementor\Repeater;
use \Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use \Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use \Elementor\Utils;
use \Elementor\Widget_Base;
use \Essential_Addons_Elementor\Classes\Helper;
class Feature_List extends Widget_Base {
public function get_name() {
return 'eael-feature-list';
}
public function get_title() {
return esc_html__( 'Feature List', 'essential-addons-for-elementor-lite' );
}
public function get_icon() {
return 'eaicon-feature-list';
}
public function get_categories() {
return ['essential-addons-elementor'];
}
public function get_keywords() {
return [
'list',
'ea list',
'ea feature list',
'feature',
'icon',
'connector',
'featured content',
'highlights',
'ea',
'essential addons',
];
}
public function get_custom_help_url() {
return 'https://essential-addons.com/elementor/docs/ea-feature-list/';
}
protected function register_controls() {
/**
* Feature List Settings
*/
$this->start_controls_section(
'eael_section_feature_list_content_settings',
[
'label' => esc_html__( 'Content Settings', 'essential-addons-for-elementor-lite' ),
]
);
$repeater = new Repeater();
$repeater->add_control(
'eael_feature_list_icon_type',
[
'label' => esc_html__( 'Icon Type', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'icon' => [
'title' => esc_html__( 'Icon', 'essential-addons-for-elementor-lite' ),
'icon' => 'fa fa-star',
],
'image' => [
'title' => esc_html__( 'Image', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-image-bold',
],
],
'default' => 'icon',
'label_block' => false,
]
);
$repeater->add_control(
'eael_feature_list_icon_new',
[
'label' => esc_html__( 'Icon', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'eael_feature_list_icon',
'condition' => [
'eael_feature_list_icon_type' => 'icon',
],
]
);
// start icon color option
$repeater->add_control(
'eael_feature_list_icon_is_individual_style',
[
'label' => esc_html__( 'Icon Style', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'ON', 'essential-addons-for-elementor-lite' ),
'label_off' => __( 'OFF', 'essential-addons-for-elementor-lite' ),
'return_value' => 'on',
'default' => '',
'fa4compatibility' => 'eael_feature_list_icon',
'condition' => [
'eael_feature_list_icon_type' => 'icon',
],
]
);
$repeater->add_control(
'eael_feature_list_icon_individual_color',
[
'label' => esc_html__( 'Icon Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
"{{WRAPPER}} {{CURRENT_ITEM}} .eael-feature-list-icon i" => 'color: {{VALUE}};',
"{{WRAPPER}} {{CURRENT_ITEM}} .eael-feature-list-icon svg" => 'color: {{VALUE}} !important; fill: {{VALUE}} !important;',
],
'fa4compatibility' => 'eael_feature_list_icon',
'condition' => [
'eael_feature_list_icon_is_individual_style' => 'on',
],
]
);
$repeater->add_control(
'eael_feature_list_icon_individual_bg_color',
[
'label' => esc_html__( 'Icon Background', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
"{{WRAPPER}} {{CURRENT_ITEM}} .eael-feature-list-icon" => 'background-color: {{VALUE}}',
],
'fa4compatibility' => 'eael_feature_list_icon',
'condition' => [
'eael_feature_list_icon_is_individual_style' => 'on',
],
]
);
$repeater->add_control(
'eael_feature_list_icon_individual_box_bg_color',
[
'label' => esc_html__( 'Icon Box Background', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
"{{WRAPPER}} {{CURRENT_ITEM}} .eael-feature-list-icon-inner" => 'background-color: {{VALUE}}',
],
'fa4compatibility' => 'eael_feature_list_icon',
'condition' => [
'eael_feature_list_icon_is_individual_style' => 'on',
],
]
);
// end icon color option
$repeater->add_control(
'eael_feature_list_img',
[
'label' => esc_html__( 'Image', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'eael_feature_list_icon_type' => 'image',
],
'ai' => [
'active' => false,
],
]
);
$repeater->add_control(
'eael_feature_list_title',
[
'label' => esc_html__( 'Title', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Title', 'essential-addons-for-elementor-lite' ),
'dynamic' => ['active' => true],
'ai' => [
'active' => false,
],
]
);
$repeater->add_control(
'eael_feature_list_content',
[
'label' => esc_html__( 'Content', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Optio, neque qui velit. Magni dolorum quidem ipsam eligendi, totam, facilis laudantium cum accusamus ullam voluptatibus commodi numquam, error, est. Ea, consequatur.', 'essential-addons-for-elementor-lite' ),
'dynamic' => ['active' => true],
]
);
$repeater->add_control(
'eael_feature_list_link',
[
'label' => esc_html__( 'Link', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::URL,
'dynamic' => ['active' => true],
'placeholder' => esc_html__( 'https://your-link.com', 'essential-addons-for-elementor-lite' ),
'separator' => 'before',
]
);
$this->add_control(
'eael_feature_list',
[
'label' => esc_html__( 'Feature Item', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::REPEATER,
'seperator' => 'before',
'default' => [
[
'eael_feature_list_icon_new' => [
'value' => 'fas fa-check',
'library' => 'fa-solid',
],
'eael_feature_list_title' => esc_html__( 'Feature Item 1', 'essential-addons-for-elementor-lite' ),
'eael_feature_list_content' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipisi cing elit, sed do eiusmod tempor incididunt ut abore et dolore magna', 'essential-addons-for-elementor-lite' ),
],
[
'eael_feature_list_icon_new' => [
'value' => 'fas fa-times',
'library' => 'fa-solid',
],
'eael_feature_list_title' => esc_html__( 'Feature Item 2', 'essential-addons-for-elementor-lite' ),
'eael_feature_list_content' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipisi cing elit, sed do eiusmod tempor incididunt ut abore et dolore magna', 'essential-addons-for-elementor-lite' ),
],
[
'eael_feature_list_icon_new' => [
'value' => 'fas fa-anchor',
'library' => 'fa-solid',
],
'eael_feature_list_title' => esc_html__( 'Feature Item 3', 'essential-addons-for-elementor-lite' ),
'eael_feature_list_content' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipisi cing elit, sed do eiusmod tempor incididunt ut abore et dolore magna', 'essential-addons-for-elementor-lite' ),
],
],
'fields' => $repeater->get_controls(),
'title_field' => '{{{ elementor.helpers.renderIcon( this, eael_feature_list_icon_new, {}, "i", "panel" ) || \'<i class="{{ eael_feature_list_icon_new.value }}" aria-hidden="true"></i>\' }}} {{ eael_feature_list_title }}',
]
);
$this->add_control(
'eael_feature_list_title_size',
[
'label' => esc_html__( 'Title HTML Tag', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => 'H1',
'h2' => 'H2',
'h3' => 'H3',
'h4' => 'H4',
'h5' => 'H5',
'h6' => 'H6',
'div' => 'div',
'span' => 'span',
'p' => 'p',
],
'default' => 'h2',
'separator' => 'before',
]
);
$this->add_control(
'eael_feature_list_icon_shape',
[
'label' => esc_html__( 'Icon Shape', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'circle',
'label_block' => false,
'options' => [
'circle' => esc_html__( 'Circle', 'essential-addons-for-elementor-lite' ),
'square' => esc_html__( 'Square', 'essential-addons-for-elementor-lite' ),
'rhombus' => esc_html__( 'Rhombus', 'essential-addons-for-elementor-lite' ),
],
]
);
$this->add_control(
'eael_feature_list_icon_shape_view',
[
'label' => esc_html__( 'Shape View', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'stacked',
'label_block' => false,
'options' => [
'framed' => esc_html__( 'Framed', 'essential-addons-for-elementor-lite' ),
'stacked' => esc_html__( 'Stacked', 'essential-addons-for-elementor-lite' ),
],
]
);
$this->add_responsive_control(
'eael_feature_list_icon_position',
[
'label' => esc_html__( 'Icon Position', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-text-align-left',
],
'top' => [
'title' => esc_html__( 'Top', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'left',
'devices' => ['desktop', 'tablet', 'mobile'],
'desktop_default' => 'left',
'tablet_default' => 'left',
'mobile_default' => 'left',
'toggle' => false,
]
);
$this->add_responsive_control(
'eael_feature_list_icon_right_indicator_position',
[
'label' => __( 'Arrow Indicator Position', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%'],
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 5,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'unit' => 'px',
'size' => 35,
],
'selectors' => [
'{{WRAPPER}} .eael-feature-list-items.connector-type-modern .eael-feature-list-item:after' => 'top: {{SIZE}}{{UNIT}} !important;',
],
'condition' => [
'eael_feature_list_icon_position' => 'top',
],
]
);
$this->add_control(
'eael_feature_list_connector',
[
'label' => esc_html__( 'Show Connector', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'label_on' => esc_html__( 'Show', 'essential-addons-for-elementor-lite' ),
'label_off' => esc_html__( 'No', 'essential-addons-for-elementor-lite' ),
'return_value' => 'yes',
]
);
$this->end_controls_section();
/**
* -------------------------------------------
* Feature List Style
* -------------------------------------------
*/
$this->start_controls_section(
'eael_section_feature_list_style',
[
'label' => esc_html__( 'List', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'eael_feature_list_space_between',
[
'label' => esc_html__( 'Space Between', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 15,
],
'range' => [
'px' => [
'max' => 50,
],
],
'selectors' => [
'{{WRAPPER}} .eael-feature-list-items .eael-feature-list-item:not(:last-child)' => 'padding-bottom: calc({{SIZE}}{{UNIT}}/2)',
'{{WRAPPER}} .eael-feature-list-items .eael-feature-list-item:not(:first-child)' => 'padding-top: calc({{SIZE}}{{UNIT}}/2)',
'{{WRAPPER}} .eael-feature-list-items.connector-type-modern .eael-feature-list-item:not(:last-child):before' => 'height: calc(100% + {{SIZE}}{{UNIT}})',
'body.rtl {{WRAPPER}} .eael-feature-list-items .eael-feature-list-item:after' => 'left: calc(-{{SIZE}}{{UNIT}}/2)',
],
]
);
$this->add_control(
'eael_feature_list_connector_type',
[
'label' => esc_html__( 'Connector Type', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'connector-type-classic',
'label_block' => false,
'options' => [
'connector-type-classic' => esc_html__( 'Classic', 'essential-addons-for-elementor-lite' ),
'connector-type-modern' => esc_html__( 'Modern', 'essential-addons-for-elementor-lite' ),
],
'condition' => [
'eael_feature_list_connector' => 'yes',
'eael_feature_list_icon_position!' => 'top',
],
'separator' => 'before',
]
);
$this->add_control(
'eael_feature_list_connector_styles',
[
'label' => esc_html__( 'Connector Styles', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'solid',
'label_block' => false,
'options' => [
'solid' => esc_html__( 'Solid', 'essential-addons-for-elementor-lite' ),
'dashed' => esc_html__( 'Dashed', 'essential-addons-for-elementor-lite' ),
'dotted' => esc_html__( 'Dotted', 'essential-addons-for-elementor-lite' ),
],
'condition' => [
'eael_feature_list_connector' => 'yes',
],
'selectors' => [
'{{WRAPPER}} .connector-type-classic .connector' => 'border-style: {{VALUE}};',
'{{WRAPPER}} .connector-type-modern .eael-feature-list-item:before, {{WRAPPER}} .connector-type-modern .eael-feature-list-item:after' => 'border-style: {{VALUE}};',
],
]
);
$this->add_control(
'eael_feature_list_connector_color',
[
'label' => esc_html__( 'Connector Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'global' => [
'default' => Global_Colors::COLOR_PRIMARY
],
'default' => '#37368e',
'selectors' => [
'{{WRAPPER}} .connector-type-classic .connector' => 'border-color: {{VALUE}};',
'{{WRAPPER}} .connector-type-modern .eael-feature-list-item:before, {{WRAPPER}} .connector-type-modern .eael-feature-list-item:after' => 'border-color: {{VALUE}};',
],
'condition' => [
'eael_feature_list_connector' => 'yes',
],
]
);
$this->add_control(
'eael_feature_list_connector_width',
[
'label' => esc_html__( 'Connector Width', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'unit' => 'px',
'size' => 1,
],
'range' => [
'px' => [
'min' => 1,
'max' => 5,
],
],
'selectors' => [
'{{WRAPPER}} .connector-type-classic .connector' => 'border-width: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .eael-feature-list-items.connector-type-modern .eael-feature-list-item:before, {{WRAPPER}} .eael-feature-list-items.connector-type-modern .eael-feature-list-item:after' => 'border-width: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .-icon-position-left .connector-type-modern .eael-feature-list-item:before, {{WRAPPER}} .-icon-position-left .connector-type-modern .eael-feature-list-item:after' => 'border-width: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .-icon-position-right .connector-type-modern .eael-feature-list-item:before, {{WRAPPER}} .-icon-position-right .connector-type-modern .eael-feature-list-item:after' => 'border-width: {{SIZE}}{{UNIT}};',
],
'condition' => [
'eael_feature_list_connector' => 'yes',
],
]
);
$this->end_controls_section();
/**
* -------------------------------------------
* Feature List Icon Style
* -------------------------------------------
*/
$this->start_controls_section(
'eael_section_feature_list_style_icon',
[
'label' => esc_html__( 'Icon', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'eael_feature_list_icon_background',
'types' => ['classic', 'gradient'],
'exclude' => [
'image',
],
'color' => [
'default' => '#3858f4',
],
'selector' => '{{WRAPPER}} .eael-feature-list-items .eael-feature-list-icon-box .eael-feature-list-icon-inner',
]
);
$this->add_control(
'eael_feature_list_secondary_color',
[
'label' => esc_html__( 'Secondary Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => '#ffffff',
'selectors' => [
'{{WRAPPER}} .eael-feature-list-items.framed .eael-feature-list-icon' => 'background-color: {{VALUE}};',
],
'condition' => [
'eael_feature_list_icon_shape_view' => 'framed',
],
'separator' => 'before',
]
);
$this->add_control(
'eael_feature_list_icon_color',
[
'label' => esc_html__( 'Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .eael-feature-list-items .eael-feature-list-icon' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-feature-list-items .eael-feature-list-icon svg' => 'fill: {{VALUE}};',
],
'separator' => 'before',
]
);
$this->add_responsive_control(
'eael_feature_list_icon_circle_size',
[
'label' => esc_html__( 'Size', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 70,
],
'range' => [
'px' => [
'min' => 6,
'max' => 300,
],
],
'selectors' => [
'{{WRAPPER}} .eael-feature-list-icon-box .eael-feature-list-icon' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .eael-feature-list-items.connector-type-classic .connector' => 'right: calc(100% - {{SIZE}}{{UNIT}});',
],
]
);
$this->add_responsive_control(
'eael_feature_list_icon_size',
[
'label' => esc_html__( 'Icon Size', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 21,
],
'range' => [
'px' => [
'min' => 6,
'max' => 150,
],
],
'selectors' => [
'{{WRAPPER}} .eael-feature-list-icon-box .eael-feature-list-icon' => 'font-size: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .eael-feature-list-icon-box .eael-feature-list-icon img' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .eael-feature-list-img' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_feature_list_icon_padding',
[
'label' => esc_html__( 'Padding', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%', 'em'],
'default' => [
'top' => 15,
'right' => 15,
'bottom' => 15,
'left' => 15,
'isLinked' => true,
],
'selectors' => [
'{{WRAPPER}} .eael-feature-list-icon-box .eael-feature-list-icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_feature_list_icon_border_width',
[
'label' => esc_html__( 'Border Width', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 1,
],
'range' => [
'px' => [
'min' => 1,
'max' => 50,
],
],
'selectors' => [
'{{WRAPPER}} .eael-feature-list-icon-box .eael-feature-list-icon-inner' => 'padding: {{SIZE}}{{UNIT}};',
],
'condition' => [
'eael_feature_list_icon_shape_view' => 'framed',
],
]
);
$this->add_control(
'eael_feature_list_icon_border_radius',
[
'label' => esc_html__( 'Border Radius', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .eael-feature-list-icon-box .eael-feature-list-icon-inner' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-feature-list-icon-box .eael-feature-list-icon-inner .eael-feature-list-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'condition' => [
'eael_feature_list_icon_shape_view' => 'framed',
],
]
);
$this->add_responsive_control(
'eael_feature_list_icon_space',
[
'label' => esc_html__( 'Spacing', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'devices' => ['desktop', 'tablet', 'mobile'],
'desktop_default' => [
'size' => 30,
'unit' => 'px',
],
'tablet_default' => [
'size' => 20,
'unit' => 'px',
],
'mobile_default' => [
'size' => 10,
'unit' => 'px',
],
'selectors' => [
'{{WRAPPER}} .-icon-position-left .eael-feature-list-content-box, {{WRAPPER}} .-icon-position-right .eael-feature-list-content-box, {{WRAPPER}} .-icon-position-top .eael-feature-list-content-box' => 'margin: {{SIZE}}{{UNIT}};',
'(mobile){{WRAPPER}} .-mobile-icon-position-left .eael-feature-list-content-box' => 'margin: 0 0 0 {{SIZE}}{{UNIT}} !important;',
'(mobile){{WRAPPER}} .-mobile-icon-position-right .eael-feature-list-content-box' => 'margin: 0 {{SIZE}}{{UNIT}} 0 0 !important;',
],
]
);
$this->end_controls_section();
/**
* -------------------------------------------
* Feature List Content Style
* -------------------------------------------
*/
$this->start_controls_section(
'eael_section_feature_list_style_content',
[
'label' => esc_html__( 'Content', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'eael_feature_list_text_align',
[
'label' => __( 'Alignment', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', 'elementor' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => __( 'Center', 'elementor' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => __( 'Right', 'elementor' ),
'icon' => 'eicon-text-align-right',
],
'justify' => [
'title' => __( 'Justified', 'elementor' ),
'icon' => 'eicon-text-align-justify',
],
],
'condition' => [
'eael_feature_list_icon_position' => 'top',
],
'selectors' => [
'{{WRAPPER}} .eael-feature-list-item' => 'text-align: {{VALUE}};',
],
]
);
$this->add_control(
'eael_feature_list_heading_title',
[
'label' => esc_html__( 'Title', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::HEADING,
]
);
$this->add_responsive_control(
'eael_feature_list_title_bottom_space',
[
'label' => esc_html__( 'Title Bottom Space', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 10,
],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .eael-feature-list-item .eael-feature-list-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_feature_list_title_color',
[
'label' => esc_html__( 'Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => '#414247',
'selectors' => [
'{{WRAPPER}} .eael-feature-list-content-box .eael-feature-list-title, {{WRAPPER}} .eael-feature-list-content-box .eael-feature-list-title > a, {{WRAPPER}} .eael-feature-list-content-box .eael-feature-list-title:visited' => 'color: {{VALUE}};',
],
'global' => [
'default' => Global_Colors::COLOR_PRIMARY
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_feature_list_title_typography',
'selector' => '{{WRAPPER}} .eael-feature-list-content-box .eael-feature-list-title, {{WRAPPER}} .eael-feature-list-content-box .eael-feature-list-title a',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_PRIMARY
],
]
);
$this->add_control(
'eael_feature_list_description',
[
'label' => esc_html__( 'Description', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'eael_feature_list_description_color',
[
'label' => esc_html__( 'Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-feature-list-content-box .eael-feature-list-content' => 'color: {{VALUE}};',
],
'global' => [
'default' => Global_Colors::COLOR_TEXT
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_feature_list_description_typography',
'selector' => '{{WRAPPER}} .eael-feature-list-content-box .eael-feature-list-content',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_TEXT
],
'fields_options' => [
'font_size' => ['default' => ['unit' => 'px', 'size' => 14]],
],
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$css_id = 'eael-feature-list-' . esc_attr( $this->get_id() );
$this->add_render_attribute( 'eael_feature_list', [
'id' => $css_id,
'class' => [
'eael-feature-list-items',
$settings['eael_feature_list_icon_shape'],
$settings['eael_feature_list_icon_shape_view'],
$settings['eael_feature_list_connector_type'],
],
] );
// connector class change by connector type
if ( $settings['eael_feature_list_icon_position'] == 'top' && $settings['eael_feature_list_connector'] == 'yes' ) {
$this->add_render_attribute( 'eael_feature_list', 'class', 'connector-type-modern' );
}
$this->add_render_attribute( 'eael_feature_list_item', 'class', 'eael-feature-list-item' );
// $padding = $settings['eael_feature_list_icon_padding']['size'];
$circle_size = intval( $settings['eael_feature_list_icon_circle_size']['size'] );
$font = $settings['eael_feature_list_icon_size']['size'];
if ( isset( $settings['eael_feature_list_icon_border_width']['right'] ) && isset( $settings['eael_feature_list_icon_border_width']['left'] ) ) {
$border = $settings['eael_feature_list_icon_border_width']['right'] + $settings['eael_feature_list_icon_border_width']['left'];
}
if ( !empty($settings['eael_feature_list_icon_shape']) && $settings['eael_feature_list_icon_shape'] == 'rhombus' ) {
$margin = 30;
$connector_width = intval( $circle_size + $margin + ( !empty( $settings['eael_feature_list_connector_width']['size'] ) ? $settings['eael_feature_list_connector_width']['size'] : 0 ) );
} else {
$connector_width = intval( $circle_size + ( !empty( $settings['eael_feature_list_connector_width']['size'] ) ? $settings['eael_feature_list_connector_width']['size'] : 0 ) );
}
// connector
if ( !empty($settings['eael_feature_list_icon_position']) && $settings['eael_feature_list_icon_position'] == 'right' ) {
$connector = 'left: calc(100% - ' . $connector_width . 'px); right: 0;';
} else {
$connector = 'right: calc(100% - ' . $connector_width . 'px); left: 0;';
}
// mobile
if ( !empty($settings['eael_feature_list_icon_position_tablet']) && $settings['eael_feature_list_icon_position_tablet'] == 'right' ) {
$connector_tablet = 'left: calc(100% - ' . $connector_width . 'px); right: 0;';
} else {
$connector_tablet = 'right: calc(100% - ' . $connector_width . 'px); left: 0;';
}
// mobile
if ( !empty($settings['eael_feature_list_icon_position_mobile']) && $settings['eael_feature_list_icon_position_mobile'] == 'right' ) {
$connector_mobile = 'left: calc(100% - ' . $connector_width . 'px); right: 0;';
} else {
$connector_mobile = 'right: calc(100% - ' . $connector_width . 'px); left: 0;';
}
// icon position for all mode
$eael_feature_list_icon_position_setting = ( !empty($settings['eael_feature_list_icon_position']) && $settings['eael_feature_list_icon_position'] ) ? $settings['eael_feature_list_icon_position'] : 'left';
$eael_feature_list_icon_position_tablet_setting = ( !empty($settings['eael_feature_list_icon_position_tablet']) && $settings['eael_feature_list_icon_position_tablet'] ) ? $settings['eael_feature_list_icon_position_tablet'] : 'left';
$eael_feature_list_icon_position_mobile_setting = ( !empty($settings['eael_feature_list_icon_position_mobile']) && $settings['eael_feature_list_icon_position_mobile'] ) ? $settings['eael_feature_list_icon_position_mobile'] : 'left';
$this->add_render_attribute(
'eael_feature_list_wrapper',
[
'class' => [
'-icon-position-' . $eael_feature_list_icon_position_setting,
'-tablet-icon-position-' . $eael_feature_list_icon_position_tablet_setting,
'-mobile-icon-position-' . $eael_feature_list_icon_position_mobile_setting,
],
]
);
?>
<div <?php echo $this->get_render_attribute_string( 'eael_feature_list_wrapper' ); ?>>
<ul <?php echo $this->get_render_attribute_string( 'eael_feature_list' ); ?>>
<?php
$individual_icon_color_css = '';
foreach ( $settings['eael_feature_list'] as $index => $item ):
$this->add_render_attribute( 'eael_feature_list_icon' . $index, 'class', 'eael-feature-list-icon fl-icon-'.$index );
$this->add_render_attribute( 'eael_feature_list_title' . $index, 'class', 'eael-feature-list-title' );
$this->add_render_attribute( 'eael_feature_list_content' . $index, 'class', 'eael-feature-list-content' );
// icon color
$icon_color = ( $item['eael_feature_list_icon_is_individual_style'] == 'on' && isset($item['eael_feature_list_icon_individual_color']) ) ? esc_attr( $item['eael_feature_list_icon_individual_color'] ) : '' ;
$icon_bg = ( ( $item['eael_feature_list_icon_is_individual_style'] == 'on' ) ? ' style="background-color:' . esc_attr( $item['eael_feature_list_icon_individual_bg_color'] ) . '"' : '' );
$icon_box_bg = ( ( $item['eael_feature_list_icon_is_individual_style'] == 'on' ) ? ' style="background-color:' . esc_attr( $item['eael_feature_list_icon_individual_box_bg_color'] ) . '"' : '' );
$feat_title_tag = Helper::eael_validate_html_tag($settings['eael_feature_list_title_size']);
if ( $item['eael_feature_list_link']['url'] ) {
$this->add_link_attributes( 'eael_feature_list_title_anchor' . $index, $item['eael_feature_list_link'] );
}
$feature_icon_tag = 'span';
$feature_has_icon = ( !empty( $item['eael_feature_list_icon'] ) || !empty( $item['eael_feature_list_icon_new'] ) );
if ( $item['eael_feature_list_link']['url'] ) {
$this->add_link_attributes( 'eael_feature_list_link' . $index, $item['eael_feature_list_link'] );
$feature_icon_tag = 'a';
}
?>
<li class="eael-feature-list-item <?php echo 'elementor-repeater-item-' . esc_attr( $item['_id'] ); ?>">
<?php if ( 'yes' == $settings['eael_feature_list_connector'] ): ?>
<span class="connector" style="<?php echo $connector; ?>"></span>
<span class="connector connector-tablet" style="<?php echo $connector_tablet; ?>"></span>
<span class="connector connector-mobile" style="<?php echo $connector_mobile; ?>"></span>
<?php endif;?>
<div class="eael-feature-list-icon-box">
<div class="eael-feature-list-icon-inner">
<<?php echo $feature_icon_tag . ' ' . $this->get_render_attribute_string( 'eael_feature_list_icon' . $index) . $this->get_render_attribute_string( 'eael_feature_list_link' . $index); ?>>
<?php
if ( $item['eael_feature_list_icon_type'] == 'icon' && $feature_has_icon ) {
if ( empty( $item['eael_feature_list_icon'] ) || isset( $item['__fa4_migrated']['eael_feature_list_icon_new'] ) ) {
Icons_Manager::render_icon( $item['eael_feature_list_icon_new'], [ 'aria-hidden' => 'true' ] );
} else {
echo '<i class="' . esc_attr( $item['eael_feature_list_icon'] ) . '" aria-hidden="true"></i>';
}
}
if ( $item['eael_feature_list_icon_type'] == 'image' ) {
$this->add_render_attribute( 'feature_list_image' . $index, [
'src' => esc_url( $item['eael_feature_list_img']['url'] ),
'class' => 'eael-feature-list-img',
'alt' => esc_attr( get_post_meta( $item['eael_feature_list_img']['id'], '_wp_attachment_image_alt', true ) ),
] );
echo '<img ' . $this->get_render_attribute_string( 'feature_list_image' . $index) . '>';
}?>
</<?php echo $feature_icon_tag; ?>>
</div>
</div>
<div class="eael-feature-list-content-box">
<<?php echo implode( ' ', [ $feat_title_tag, $this->get_render_attribute_string( 'eael_feature_list_title' . $index), ] ); ?>
><?php echo !empty( $item['eael_feature_list_link']['url'] ) ? "<a {$this->get_render_attribute_string( 'eael_feature_list_title_anchor' . $index)}>" : ''; ?><?php echo Helper::eael_wp_kses($item['eael_feature_list_title']); ?><?php echo !empty( $item['eael_feature_list_link']['url'] ) ? "</a>" : ''; ?></<?php echo $feat_title_tag; ?>
>
<p <?php echo $this->get_render_attribute_string( 'eael_feature_list_content' . $index); ?>><?php echo Helper::eael_wp_kses($item['eael_feature_list_content']); ?></p>
</div>
</li>
<?php
endforeach;?>
</ul>
</div>
<?php
}
protected function content_template() {}
}

View File

@@ -0,0 +1,640 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if ( !defined( 'ABSPATH' ) ) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Typography;
use \Elementor\Widget_Base;
use \Elementor\Repeater;
use \Essential_Addons_Elementor\Classes\Helper;
class Image_Accordion extends Widget_Base {
public function get_name() {
return 'eael-image-accordion';
}
public function get_title() {
return esc_html__( 'Image Accordion', 'essential-addons-for-elementor-lite' );
}
public function get_icon() {
return 'eaicon-image-accrodion';
}
public function get_categories() {
return [ 'essential-addons-elementor' ];
}
public function get_keywords() {
return [
'image',
'ea image accordion',
'image effect',
'hover effect',
'creative image',
'gallery',
'ea',
'essential addons',
];
}
public function get_custom_help_url() {
return 'https://essential-addons.com/elementor/docs/image-accordion/';
}
protected function register_controls() {
/**
* Image accordion Content Settings
*/
$this->start_controls_section(
'eael_section_img_accordion_settings',
[
'label' => esc_html__( 'General', 'essential-addons-for-elementor-lite' ),
]
);
$this->add_control(
'eael_img_accordion_type',
[
'label' => esc_html__( 'Accordion Style', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'on-hover',
'label_block' => false,
'options' => [
'on-hover' => esc_html__( 'On Hover', 'essential-addons-for-elementor-lite' ),
'on-click' => esc_html__( 'On Click', 'essential-addons-for-elementor-lite' ),
],
]
);
$this->add_control(
'eael_img_accordion_direction',
[
'label' => esc_html__( 'Direction', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'on-hover',
'label_block' => false,
'options' => [
'accordion-direction-horizontal' => esc_html__( 'Horizontal', 'essential-addons-for-elementor-lite' ),
'accordion-direction-vertical' => esc_html__( 'Vertical', 'essential-addons-for-elementor-lite' ),
],
'default' => 'accordion-direction-horizontal',
]
);
$this->add_control(
'eael_img_accordion_content_heading',
[
'label' => __( 'Content', 'essential-addons-for-elementor-lite' ),
'type' => \Elementor\Controls_Manager::HEADING,
]
);
$this->add_control(
'eael_img_accordion_content_horizontal_align',
[
'label' => __( 'Horizontal Alignment', 'essential-addons-for-elementor-lite' ),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => __( 'Center', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => __( 'Right', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'center',
'toggle' => true,
]
);
$this->add_control(
'eael_img_accordion_content_vertical_align',
[
'label' => __( 'Vertical Alignment', 'essential-addons-for-elementor-lite' ),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'top' => [
'title' => __( 'Top', 'essential-addons-for-elementor-lite' ),
'icon' => 'fa fa-arrow-circle-up',
],
'center' => [
'title' => __( 'Center', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-text-align-center',
],
'bottom' => [
'title' => __( 'Bottom', 'essential-addons-for-elementor-lite' ),
'icon' => 'fa fa-arrow-circle-down',
],
],
'default' => 'center',
'toggle' => true,
]
);
$this->add_control(
'title_tag',
[
'label' => __( 'Select Tag', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'h2',
'options' => [
'h1' => __( 'H1', 'essential-addons-for-elementor-lite' ),
'h2' => __( 'H2', 'essential-addons-for-elementor-lite' ),
'h3' => __( 'H3', 'essential-addons-for-elementor-lite' ),
'h4' => __( 'H4', 'essential-addons-for-elementor-lite' ),
'h5' => __( 'H5', 'essential-addons-for-elementor-lite' ),
'h6' => __( 'H6', 'essential-addons-for-elementor-lite' ),
'span' => __( 'Span', 'essential-addons-for-elementor-lite' ),
'p' => __( 'P', 'essential-addons-for-elementor-lite' ),
'div' => __( 'Div', 'essential-addons-for-elementor-lite' ),
],
]
);
$repeater = new Repeater();
$repeater->add_control(
'eael_accordion_is_active',
[
'label' => __( 'Make it active?', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Yes', 'essential-addons-for-elementor-lite' ),
'label_off' => __( 'No', 'essential-addons-for-elementor-lite' ),
'return_value' => 'yes',
]
);
$repeater->add_control(
'eael_accordion_bg',
[
'label' => esc_html__( 'Background Image', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::MEDIA,
'label_block' => true,
'default' => [
'url' => EAEL_PLUGIN_URL . '/assets/front-end/img/accordion.png',
],
'ai' => [
'active' => false,
],
]
);
$repeater->add_control(
'eael_accordion_tittle',
[
'label' => esc_html__( 'Title', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__( 'Accordion item title', 'essential-addons-for-elementor-lite' ),
'dynamic' => [ 'active' => true ],
'ai' => [
'active' => false,
],
]
);
$repeater->add_control(
'eael_accordion_content',
[
'label' => esc_html__( 'Content', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::WYSIWYG,
'label_block' => true,
'default' => esc_html__( 'Accordion content goes here!', 'essential-addons-for-elementor-lite' ),
]
);
$repeater->add_control(
'eael_accordion_enable_title_link',
[
'label' => esc_html__( 'Enable Title Link', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'your-plugin' ),
'label_off' => __( 'Hide', 'your-plugin' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$repeater->add_control(
'eael_accordion_title_link',
[
'name' => 'eael_accordion_title_link',
'label' => esc_html__( 'Title Link', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::URL,
'dynamic' => [ 'active' => true ],
'label_block' => true,
'default' => [
'url' => '#',
'is_external' => '',
],
'show_external' => true,
'condition' => [
'eael_accordion_enable_title_link' => 'yes',
],
]
);
$this->add_control(
'eael_img_accordions',
[
'type' => Controls_Manager::REPEATER,
'seperator' => 'before',
'default' => [
[
'eael_accordion_tittle' => esc_html__( 'Image Accordion #1', 'essential-addons-for-elementor-lite' ),
'eael_accordion_content' => esc_html__( 'Image Accordion Content Goes Here! Click edit button to change this text.', 'essential-addons-for-elementor-lite' ),
'eael_accordion_bg' => [
'url' => EAEL_PLUGIN_URL . '/assets/front-end/img/accordion.png',
]
],
[
'eael_accordion_tittle' => esc_html__( 'Image Accordion #2', 'essential-addons-for-elementor-lite' ),
'eael_accordion_content' => esc_html__( 'Image Accordion Content Goes Here! Click edit button to change this text.', 'essential-addons-for-elementor-lite' ),
'eael_accordion_bg' => [
'url' => EAEL_PLUGIN_URL . '/assets/front-end/img/accordion.png',
]
],
[
'eael_accordion_tittle' => esc_html__( 'Image Accordion #3', 'essential-addons-for-elementor-lite' ),
'eael_accordion_content' => esc_html__( 'Image Accordion Content Goes Here! Click edit button to change this text.', 'essential-addons-for-elementor-lite' ),
'eael_accordion_bg' => [
'url' => EAEL_PLUGIN_URL . '/assets/front-end/img/accordion.png',
]
],
[
'eael_accordion_tittle' => esc_html__( 'Image Accordion #4', 'essential-addons-for-elementor-lite' ),
'eael_accordion_content' => esc_html__( 'Image Accordion Content Goes Here! Click edit button to change this text.', 'essential-addons-for-elementor-lite' ),
'eael_accordion_bg' => [
'url' => EAEL_PLUGIN_URL . '/assets/front-end/img/accordion.png',
]
],
],
'fields' => $repeater->get_controls(),
'title_field' => '{{eael_accordion_tittle}}',
]
);
$this->end_controls_section();
/**
* -------------------------------------------
* Tab Style (Image accordion)
* -------------------------------------------
*/
$this->start_controls_section(
'eael_section_img_accordion_style_settings',
[
'label' => esc_html__( 'General', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_accordion_height',
[
'label' => esc_html__( 'Height', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::TEXT,
'default' => '400',
'description' => 'Unit in px',
'selectors' => [
'{{WRAPPER}} .eael-img-accordion ' => 'height: {{VALUE}}px;',
],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eael_accordion_bg_color',
[
'label' => esc_html__( 'Background Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-img-accordion' => 'background-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'eael_accordion_container_padding',
[
'label' => esc_html__( 'Padding', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-img-accordion' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_accordion_container_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-img-accordion' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_accordion_border',
'label' => esc_html__( 'Border', 'essential-addons-for-elementor-lite' ),
'selector' => '{{WRAPPER}} .eael-img-accordion',
]
);
$this->add_control(
'eael_accordion_border_radius',
[
'label' => esc_html__( 'Border Radius', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 4,
],
'range' => [
'px' => [
'max' => 500,
],
],
'selectors' => [
'{{WRAPPER}} .eael-img-accordion' => 'border-radius: {{SIZE}}px;',
'{{WRAPPER}} .eael-img-accordion a:first-child' => 'border-radius: {{SIZE}}px 0 0 {{SIZE}}px;',
'{{WRAPPER}} .eael-img-accordion a:last-child' => 'border-radius: 0 {{SIZE}}px {{SIZE}}px 0;',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'eael_accordion_shadow',
'selector' => '{{WRAPPER}} .eael-img-accordion',
]
);
$this->add_control(
'eael_accordion_img_overlay_color',
[
'label' => esc_html__( 'Overlay Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => 'rgba(0, 0, 0, .3)',
'selectors' => [
'{{WRAPPER}} .eael-img-accordion .eael-image-accordion-hover:before' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_accordion_img_hover_color',
[
'label' => esc_html__( 'Hover Overlay Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => 'rgba(0, 0, 0, .5)',
'selectors' => [
'{{WRAPPER}} .eael-img-accordion .eael-image-accordion-hover:hover::before' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-img-accordion .eael-image-accordion-hover.overlay-active:hover::before' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-img-accordion .eael-image-accordion-hover.overlay-active:before' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_section();
/**
* -------------------------------------------
* Tab Style (Thumbnail Style)
* -------------------------------------------
*/
$this->start_controls_section(
'eael_section_img_accordion_thumbnail_style_settings',
[
'label' => esc_html__( 'Thumbnail', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_image_accordion_thumbnail_margin',
[
'label' => __( 'Margin', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-img-accordion .eael-image-accordion-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_image_accordion_thumbnail_padding',
[
'label' => __( 'Padding', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-img-accordion .eael-image-accordion-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_image_accordion_thumbnail_radius',
[
'label' => __( 'Border Radius', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-img-accordion .eael-image-accordion-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}!important;',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Border::get_type(),
[
'name' => 'eael_image_accordion_thumbnail_border',
'label' => __( 'Border', 'essential-addons-for-elementor-lite' ),
'selector' => '{{WRAPPER}} .eael-img-accordion .eael-image-accordion-item',
]
);
$this->end_controls_section();
/**
* -------------------------------------------
* Tab Style (Image accordion Content Style)
* -------------------------------------------
*/
$this->start_controls_section(
'eael_section_img_accordion_typography_settings',
[
'label' => esc_html__( 'Color &amp; Typography', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_accordion_title_text',
[
'label' => esc_html__( 'Title', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'eael_accordion_title_color',
[
'label' => esc_html__( 'Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .eael-img-accordion .overlay .img-accordion-title' => 'color: {{VALUE}} !important;',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_accordion_title_typography',
'selector' => '{{WRAPPER}} .eael-img-accordion .overlay .img-accordion-title',
]
);
$this->add_control(
'eael_accordion_content_text',
[
'label' => esc_html__( 'Content', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'eael_accordion_content_color',
[
'label' => esc_html__( 'Color', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .eael-img-accordion .overlay p' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_accordion_content_typography',
'selector' => '{{WRAPPER}} .eael-img-accordion .overlay p',
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$horizontal_alignment = 'eael-img-accordion-horizontal-align-' . $settings[ 'eael_img_accordion_content_horizontal_align' ];
$vertical_alignment = 'eael-img-accordion-vertical-align-' . $settings[ 'eael_img_accordion_content_vertical_align' ];
$this->add_render_attribute(
'eael-image-accordion',
[
'class' => [
'eael-img-accordion',
$settings[ 'eael_img_accordion_direction' ],
$horizontal_alignment,
$vertical_alignment,
],
'id' => 'eael-img-accordion-' . $this->get_id(),
]
);
$this->add_render_attribute( 'eael-image-accordion', 'data-img-accordion-id', esc_attr( $this->get_id() ) );
$this->add_render_attribute( 'eael-image-accordion', 'data-img-accordion-type', $settings[ 'eael_img_accordion_type' ] );
if ( empty( $settings[ 'eael_img_accordions' ] ) ) {
return;
}
?>
<div <?php echo $this->get_render_attribute_string( 'eael-image-accordion' ); ?>>
<?php foreach ( $settings[ 'eael_img_accordions' ] as $key => $img_accordion ): ?>
<?php
$active = $img_accordion['eael_accordion_is_active'];
$activeCSS = ( $active === 'yes' ? ' flex: 3 1 0%;' : '' );
$this->add_render_attribute(
'eael-image-accordion-item-wrapper-' . $key,
[
'class' => 'eael-image-accordion-hover eael-image-accordion-item',
'style' => "background-image: url(" . esc_url( $img_accordion['eael_accordion_bg']['url'] ) . ");" . $activeCSS,
]
);
if ( $active === 'yes' ) {
$this->add_render_attribute( 'eael-image-accordion-item-wrapper-' . $key, 'class', 'overlay-active' );
}
?>
<div <?php echo $this->get_render_attribute_string( 'eael-image-accordion-item-wrapper-' . $key ); ?> tabindex="0">
<div class="overlay">
<div class="overlay-inner <?php echo( $active === 'yes' ? ' overlay-inner-show' : '' ); ?>">
<?php
$title_linked = false;
if ( $img_accordion['eael_accordion_enable_title_link'] == 'yes' && $img_accordion['eael_accordion_title_link']['url'] !== '#' && $img_accordion['eael_accordion_title_link']['url'] ) {
$this->add_link_attributes( 'eael-image-accordion-link-' . $key, $img_accordion['eael_accordion_title_link'] );
$title_linked = true;
echo "<a ". $this->get_render_attribute_string( 'eael-image-accordion-link-' . $key ) .">";
}
if ( !empty( $img_accordion[ 'eael_accordion_tittle' ] ) ):
printf( '<%1$s class="img-accordion-title">%2$s</%1$s>', Helper::eael_validate_html_tag($settings[ 'title_tag' ]), Helper::eael_wp_kses($img_accordion[ 'eael_accordion_tittle' ]) );
endif;
echo $title_linked ? '</a>' : '';
if ( !empty( $img_accordion[ 'eael_accordion_content' ] ) ):
?>
<p><?php echo sprintf( "%s", $this->parse_text_editor( $img_accordion[ 'eael_accordion_content' ] ) ); ?></p>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php
if ( !empty( $settings[ 'eael_img_accordions' ] ) ) {
if ( 'on-hover' === $settings[ 'eael_img_accordion_type' ] ) {
echo '<style typr="text/css">
#eael-img-accordion-' . $this->get_id() . ' .eael-image-accordion-hover:hover {
flex: 3 1 0% !important;
}
#eael-img-accordion-' . $this->get_id() . ' .eael-image-accordion-hover:hover:hover .overlay-inner * {
opacity: 1;
visibility: visible;
transform: none;
transition: all .3s .3s;
}
</style>';
}
}
}
}

View File

@@ -0,0 +1,801 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Typography;
use \Elementor\Widget_Base;
use \Essential_Addons_Elementor\Classes\Helper as HelperClass;
use Essential_Addons_Elementor\Traits\Helper;
class Post_Timeline extends Widget_Base
{
use Helper;
protected $page_id;
public function get_name()
{
return 'eael-post-timeline';
}
public function get_title()
{
return __('Post Timeline', 'essential-addons-for-elementor-lite');
}
public function get_icon()
{
return 'eaicon-post-timeline';
}
public function get_categories()
{
return ['essential-addons-for-elementor-lite'];
}
public function get_keywords()
{
return [
'post',
'posts',
'timeline',
'ea post timeline',
'ea posts timeline',
'blog posts',
'content marketing',
'blogger',
'ea',
'essential addons',
];
}
public function get_custom_help_url()
{
return 'https://essential-addons.com/elementor/docs/post-timeline/';
}
protected function register_controls()
{
/**
* Query And Layout Controls!
* @source includes/elementor-helper.php
*/
do_action('eael/controls/query', $this);
do_action('eael/controls/layout', $this);
$this->start_controls_section(
'section_post_timeline_links',
[
'label' => __('Links', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'timeline_link_nofollow',
[
'label' => __('No Follow', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Yes', 'essential-addons-for-elementor-lite'),
'label_off' => __('No', 'essential-addons-for-elementor-lite'),
'return_value' => 'true',
]
);
$this->add_control(
'timeline_link_target_blank',
[
'label' => __('Target Blank', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Yes', 'essential-addons-for-elementor-lite'),
'label_off' => __('No', 'essential-addons-for-elementor-lite'),
'return_value' => 'true',
]
);
$this->end_controls_section();
if (!apply_filters('eael/pro_enabled', false)) {
HelperClass::go_premium($this);
}
$this->start_controls_section(
'eael_section_post_timeline_style',
[
'label' => __('Timeline Style', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_timeline_display_overlay',
[
'label' => __('Show Overlay', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'essential-addons-for-elementor-lite'),
'label_off' => __('Hide', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
'default' => 'yes',
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-image' => 'opacity: .6',
],
'condition'=> [
'eael_dynamic_template_Layout!' => 'card',
]
]
);
$this->add_control(
'eael_timeline_overlay_color',
[
'label' => __('Overlay Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'description' => __('Leave blank or Clear to use default gradient overlay', 'essential-addons-for-elementor-lite'),
'default' => 'linear-gradient(45deg, #3f3f46 0%, #05abe0 100%) repeat scroll 0 0 rgba(0, 0, 0, 0)',
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-inner' => 'background: {{VALUE}}',
],
'condition' => [
'eael_timeline_display_overlay' => 'yes',
'eael_dynamic_template_Layout!' => 'card',
],
]
);
$this->add_control(
'eael_timeline_bg_color',
[
'label' => __('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#3DB1C0',
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-inner' => 'background: {{VALUE}}',
],
'condition' => [
'eael_dynamic_template_Layout' => 'card',
],
]
);
$this->add_responsive_control(
'eael_post_grid_spacing',
[
'label' => esc_html__('Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%', 'em'],
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-inner' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'condition' => [
'eael_dynamic_template_Layout' => 'card',
],
]
);
$this->add_control(
'eael_post_timeline_border_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-inner' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
],
'condition' => [
'eael_dynamic_template_Layout' => 'card',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'eael_post_timeline_box_shadow',
'selector' => '{{WRAPPER}} .eael-timeline-post-inner',
'condition' => [
'eael_dynamic_template_Layout' => 'card',
],
]
);
$this->add_control(
'eael_post_timeline_content_heading',
[
'label' => esc_html__('Content', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'condition' => [
'eael_dynamic_template_Layout' => 'card',
],
'separator' => 'before',
]
);
$this->add_responsive_control(
'eael_post_timeline_content_spacing',
[
'label' => esc_html__('Spacing', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%', 'em'],
'selectors' => [
'{{WRAPPER}} .eael-timeline-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'condition' => [
'eael_dynamic_template_Layout' => 'card',
],
]
);
$this->add_control(
'eael_post_timeline_image_heading',
[
'label' => esc_html__('Image', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => [
'eael_dynamic_template_Layout!' => 'default',
],
]
);
$this->add_responsive_control(
'eael_timeline_image_height',
[
'label' => esc_html__('Height', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 500,
],
],
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-image' => 'height: {{SIZE}}PX;',
],
'condition' => [
'eael_dynamic_template_Layout!' => 'default',
],
]
);
$this->add_control(
'eael_timeline_img_border_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-image' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'condition' => [
'eael_dynamic_template_Layout!' => 'default',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_typography',
[
'label' => __('Typography', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_timeline_title_style',
[
'label' => __('Title Style', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'eael_timeline_title_color',
[
'label' => __('Title Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-title .eael-timeline-post-title-text' => 'color: {{VALUE}};',
'{{WRAPPER}} .timeline-layout-card .eael-timeline-post-title .eael-timeline-post-title-text-card' => 'color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'eael_timeline_title_alignment',
[
'label' => __('Title Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => __('Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => __('Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-right',
],
],
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-title .eael-timeline-post-title-text' => 'text-align: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_timeline_title_typography',
'label' => __('Title Typography', 'essential-addons-for-elementor-lite'),
'global' => [
'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
],
'selector' => '{{WRAPPER}} .eael-timeline-post-title .eael-timeline-post-title-text',
]
);
$this->add_control(
'eael_timeline_excerpt_style',
[
'label' => __('Excerpt Style', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'eael_timeline_excerpt_color',
[
'label' => __('Excerpt Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#ffffff',
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-excerpt p' => 'color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'eael_timeline_excerpt_alignment',
[
'label' => __('Excerpt Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => __('Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => __('Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-right',
],
'justify' => [
'title' => __('Justified', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-justify',
],
],
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-excerpt p' => 'text-align: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_timeline_excerpt_typography',
'label' => __('Excerpt Typography', 'essential-addons-for-elementor-lite'),
'global' => [
'default' => Global_Typography::TYPOGRAPHY_TEXT,
],
'selector' => '{{WRAPPER}} .eael-timeline-post-excerpt p',
]
);
$this->end_controls_section();
// Start Arrow Styling
$this->start_controls_section(
'eael_section_arrow',
[
'label' => __('Arrow', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_timeline_border_color',
[
'label' => __('Border & Arrow Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#e5eaed',
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-inner' => 'border-color: {{VALUE}};',
'{{WRAPPER}} .eael-timeline-post-inner::after' => 'border-left-color: {{VALUE}};',
'{{WRAPPER}} .eael-timeline-post:nth-child(2n) .eael-timeline-post-inner::after' => 'border-right-color: {{VALUE}};',
],
'condition' => [
'eael_dynamic_template_Layout' => 'default',
],
]
);
$this->add_control(
'eael_timeline_arrow_color',
[
'label' => __('Arrow Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#3DB1C0',
'selectors' => [
'{{WRAPPER}} .eael-timeline-post-inner' => 'border-color: {{VALUE}};',
'{{WRAPPER}} .eael-timeline-post-inner::after' => 'border-left-color: {{VALUE}}; border-right-color: {{VALUE}}',
// '{{WRAPPER}} .eael-timeline-post:nth-child(2n) .eael-timeline-post-inner::after' => 'border-right-color: {{VALUE}};',
],
'condition' => [
'eael_dynamic_template_Layout!' => 'default',
],
]
);
$this->add_responsive_control(
'eael_timeline_arrow_size',
[
'label' => esc_html__('Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 20,
],
],
'selectors' => [
'{{WRAPPER}} .eael-post-timeline.timeline-layout-card .eael-timeline-post-inner:after' => 'border-width: {{SIZE}}px; right: -{{SIZE}}px; left: -{{SIZE}}px',
'{{WRAPPER}} .eael-post-timeline.timeline-layout-card .eael-timeline-post:nth-child(2n) .eael-timeline-post-inner:after' => 'left: -{{SIZE}}px;',
],
'condition' => [
'eael_dynamic_template_Layout!' => 'default',
],
]
);
$this->add_control(
'eael_timeline_arrow_alignment',
[
'label' => __('Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'top' => [
'title' => __( 'Top', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-v-align-top',
],
'middle' => [
'title' => __( 'Middle', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-v-align-middle',
],
'bottom' => [
'title' => __( 'Bottom', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-v-align-bottom',
],
],
'default' => 'top',
'condition' => [
'eael_dynamic_template_Layout!' => 'default',
],
]
);
$this->end_controls_section();
// Start Time Styling
$this->start_controls_section(
'eael_section_time',
[
'label' => __('Time', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_timeline_date_background_color',
[
'label' => __('Date Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => 'rgba(0, 0, 0, 0.7)',
'selectors' => [
'{{WRAPPER}} .eael-timeline-post time' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-timeline-post time::before' => 'border-bottom-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_timeline_date_color',
[
'label' => __('Date Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .eael-timeline-post time' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_timeline_time_typography',
'label' => __('Typography', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} time',
]
);
$this->add_control(
'eael_timeline_time_padding',
[
'label' => esc_html__('Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} time' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_timeline_time_border_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} time' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_line',
[
'label' => __('Line & Bullet', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_section_post_timeline_line_heading',
[
'label' => __('Line', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'eael_section_post_timeline_line_size',
[
'label' => __('Line Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%'],
'range' => [
'px' => [
'min' => 0,
'max' => 20,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .eael-timeline-post:after' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_section_post_timeline_line_position_from_right',
[
'label' => __('Line Position From Right', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 20,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .eael-timeline-post:after' => 'right: -{{SIZE}}{{UNIT}};',
],
'condition'=> [
'eael_dynamic_template_Layout!' => 'card',
]
]
);
$this->add_control(
'eael_section_post_timeline_bullet_size',
[
'label' => __('Bullet Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%'],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .eael-timeline-bullet' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_section_post_timeline_bullet_position_from_left',
[
'label' => __('Left-sided Bullet Positon', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 50,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .eael-timeline-bullet' => 'right: -{{SIZE}}{{UNIT}};',
],
'condition'=> [
'eael_dynamic_template_Layout!' => 'card',
]
]
);
$this->add_control(
'eael_section_post_timeline_bullet_position_from_right',
[
'label' => __('Right-sided Bullet Position', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 50,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .eael-timeline-post:nth-child(2n) .eael-timeline-bullet' => 'left: -{{SIZE}}{{UNIT}};',
],
'condition'=> [
'eael_dynamic_template_Layout!' => 'card',
]
]
);
$this->add_control(
'eael_timeline_bullet_color',
[
'label' => __('Timeline Bullet Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#9fa9af',
'selectors' => [
'{{WRAPPER}} .eael-timeline-bullet' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_timeline_bullet_border_color',
[
'label' => __('Timeline Bullet Border Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .eael-timeline-bullet' => 'border-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_timeline_vertical_line_color',
[
'label' => __('Timeline Vertical Line Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => 'rgba(83, 85, 86, .2)',
'selectors' => [
'{{WRAPPER}} .eael-timeline-post:after' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_section();
do_action('eael/controls/load_more_button_style', $this);
}
protected function render()
{
$settings = $this->get_settings_for_display();
$settings = HelperClass::fix_old_query($settings);
$args = HelperClass::get_query_args($settings);
$args = HelperClass::get_dynamic_args($settings, $args);
$settings ['expanison_indicator'] = $settings['excerpt_expanison_indicator'];
$this->add_render_attribute(
'eael_post_timeline_wrapper',
[
'id' => "eael-post-timeline-{$this->get_id()}",
'class' => ["eael-post-timeline", "timeline-layout-{$settings['eael_dynamic_template_Layout']}", "eael-post-timeline-arrow-{$settings['eael_timeline_arrow_alignment']}"],
]
);
$this->add_render_attribute(
'eael_post_timeline',
[
'class' => ['eael-post-timeline', 'eael-post-appender', "eael-post-appender-{$this->get_id()}"],
]
);
echo '<div ' . $this->get_render_attribute_string('eael_post_timeline_wrapper') . '>
<div ' . $this->get_render_attribute_string('eael_post_timeline') . '>';
$template = $this->get_template($this->get_settings('eael_dynamic_template_Layout'));
$settings['loadable_file_name'] = $this->get_filename_only($template);
$dir_name = $this->get_temp_dir_name($settings['loadable_file_name']);
$found_posts = 0;
if(file_exists($template)){
$query = new \WP_Query($args);
if ($query->have_posts()) {
$found_posts = $query->found_posts;
$ppp = empty( $args['posts_per_page'] ) ? get_option( 'posts_per_page' ) : $args['posts_per_page'];
$max_page = ceil( $found_posts / absint( $ppp ) );
$args['max_page'] = $max_page;
while ($query->have_posts()) {
$query->the_post();
include($template);
}
} else {
_e('<p class="no-posts-found">No posts found!</p>', 'essential-addons-for-elementor-lite');
}
wp_reset_postdata();
} else {
_e('<p class="no-posts-found">No layout found!</p>', 'essential-addons-for-elementor-lite');
}
echo '</div>
</div>';
if ( $found_posts > $args['posts_per_page'] ) {
$this->print_load_more_button( $settings, $args, $dir_name );
}
}
}

View File

@@ -0,0 +1,543 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Background;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use Elementor\Icons_Manager;
use \Elementor\Widget_Base;
use \Essential_Addons_Elementor\Classes\Helper;
class SVG_Draw extends Widget_Base {
public function get_name() {
return 'eael-svg-draw';
}
public function get_title() {
return esc_html__( 'SVG Draw', 'essential-addons-for-elementor-lite' );
}
public function get_icon() {
return 'eaicon-svg-draw';
}
public function get_categories() {
return [ 'essential-addons-elementor' ];
}
public function get_keywords() {
return [
'svg',
'draq',
'ea svg',
'ea svg draw',
'animation',
'icon',
'icon animation',
'svg animation',
'ea',
'essential addons',
];
}
public function get_custom_help_url() {
return 'https://essential-addons.com/elementor/docs/ea-svg-draw/';
}
protected function default_custom_svg() {
return '<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" id="Icons" viewBox="0 0 74 74" width="512" height="512">
<path d="M65,72H9a3,3,0,0,1-3-3V30a1,1,0,0,1,2,0V69a1,1,0,0,0,1,1H65a1,1,0,0,0,1-1V30a1,1,0,0,1,2,0V69A3,3,0,0,1,65,72Z"/>
<path d="M70,31H52.31a1,1,0,0,1,0-2H70V19H4V29H21.69a1,1,0,1,1,0,2H4a2,2,0,0,1-2-2V19a2,2,0,0,1,2-2H70a2,2,0,0,1,2,2V29A2,2,0,0,1,70,31Z"/>
<path d="M37,19a1,1,0,0,1-.86-1.509c2.193-3.712,7.618-12.538,10.615-14.326a8.2,8.2,0,1,1,8.4,14.078c-1.222.73-3.7,1.319-7.369,1.75a1,1,0,1,1-.233-1.986c4.439-.522,6.025-1.151,6.576-1.48A6.179,6.179,0,0,0,56.971,11.7a6.194,6.194,0,0,0-9.191-6.818c-2.126,1.269-6.517,7.871-9.918,13.626A1,1,0,0,1,37,19Z"/>
<path d="M37,19a1,1,0,0,1-.862-.491c-3.4-5.756-7.792-12.358-9.917-13.626a6.2,6.2,0,1,0-6.347,10.644c.55.329,2.136.958,6.576,1.48a1,1,0,1,1-.233,1.986c-3.667-.431-6.147-1.02-7.369-1.75a8.2,8.2,0,1,1,8.4-14.078c3,1.788,8.42,10.614,10.614,14.326A1,1,0,0,1,37,19Z"/>
<path d="M42,72H32a1,1,0,0,1-1-1V29.12a1,1,0,0,1,2,0V70h8V29.12a1,1,0,0,1,2,0V71A1,1,0,0,1,42,72Z"/>
<path d="M41.94,30H32.06a1,1,0,1,1,0-2h9.88a1,1,0,0,1,0,2Z"/>
<path d="M46.692,40.563a1,1,0,0,1-.912-.59L36.088,18.41a1,1,0,0,1,1.824-.82l8.613,19.162,1.29-4.114a1,1,0,0,1,1.365-.613l3.77,1.7-7.163-15.3a1,1,0,1,1,1.812-.848L55.906,35.32a1,1,0,0,1-1.316,1.335l-5.2-2.344-1.74,5.55a1,1,0,0,1-.895.7Z"/>
<path d="M27.308,40.563l-.06,0a1,1,0,0,1-.895-.7l-1.74-5.55-5.2,2.344a1,1,0,0,1-1.316-1.335L26.4,17.576a1,1,0,1,1,1.812.848l-7.163,15.3,3.77-1.7a1,1,0,0,1,1.365.613l1.29,4.114L36.088,17.59a1,1,0,0,1,1.824.82L28.22,39.973A1,1,0,0,1,27.308,40.563Z"/>
</svg>
';
}
protected function register_controls() {
$this->start_controls_section(
'eael_section_svg_content_settings',
[
'label' => esc_html__( 'General', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'eael_svg_src',
[
'label' => esc_html__( 'Source', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'icon',
'options' => [
'icon' => esc_html__( 'Icon', 'essential-addons-for-elementor-lite' ),
'custom' => esc_html__( 'Custom SVG', 'essential-addons-for-elementor-lite' ),
],
]
);
$this->add_control(
'eael_svg_icon',
[
'label' => esc_html__( 'Icon', 'essential-addons-for-elementor-lite' ),
'type' => \Elementor\Controls_Manager::ICONS,
'default' => [
'value' => [
'url' => EAEL_PLUGIN_URL . 'assets/admin/images/svg-draw.svg',
],
'library' => 'svg',
],
'condition' => [
'eael_svg_src' => 'icon'
]
]
);
$this->add_control(
'svg_html',
[
'label' => esc_html__( 'SVG Code', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::TEXTAREA,
'condition' => [
'eael_svg_src' => 'custom'
],
'default' => $this->default_custom_svg(),
'description' => esc_html__( 'SVG draw works best on path elements.', 'essential-addons-for-elementor-lite' ),
]
);
$this->add_control(
'eael_svg_exclude_style',
[
'label' => esc_html__( 'Exclude Style', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'essential-addons-for-elementor-lite' ),
'label_off' => esc_html__( 'No', 'essential-addons-for-elementor-lite' ),
'default' => 'no',
'description' => esc_html__( 'Exclude style from SVG Source (If any).', 'essential-addons-for-elementor-lite' )
]
);
$this->add_responsive_control(
'eael_svg_width',
[
'label' => esc_html__( 'Width', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%' ],
'range' => [
'px' => [
'min' => 1,
'max' => 500,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 200,
],
'separator' => 'before',
'selectors' => [
'{{WRAPPER}} svg' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_svg_height',
[
'label' => esc_html__( 'Height', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 500,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 200,
],
'selectors' => [
'{{WRAPPER}} svg' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_svg_alignment',
[
'label' => esc_html__( 'Alignment', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'essential-addons-for-elementor-lite' ),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'center',
'selectors' => [
'{{WRAPPER}} .eael-svg-draw-container' => 'text-align: {{VALUE}};',
],
]
);
$this->add_control(
'eael_svg_link',
[
'label' => esc_html__( 'Link', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::URL,
'placeholder' => esc_html__( 'https://your-link.com', 'essential-addons-for-elementor-lite' ),
'options' => [ 'url' ],
'label_block' => true,
'separator' => 'before'
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_svg_appearance',
[
'label' => esc_html__( 'Appearance', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'eael_svg_fill',
[
'label' => esc_html__( 'SVG Fill Type', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'none',
'options' => [
'none' => esc_html__( 'None', 'essential-addons-for-elementor-lite' ),
'after' => esc_html__( 'Fill After Draw', 'essential-addons-for-elementor-lite' ),
'before' => esc_html__( 'Fill Before Draw', 'essential-addons-for-elementor-lite' ),
],
]
);
$this->add_control(
'eael_svg_fill_transition',
[
'label' => esc_html__( 'Fill Transition', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::NUMBER,
'default' => 1,
'min' => 0,
'selectors' => [
'{{WRAPPER}} .fill-svg svg path' => 'animation-duration: {{SIZE}}s;',
],
'description' => esc_html__( 'Duration on SVG fills (in seconds)', 'essential-addons-for-elementor-lite' )
]
);
$this->add_control(
'eael_svg_animation_on',
[
'label' => esc_html__( 'Animation', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'page-load',
'options' => [
'none' => esc_html__( 'None', 'essential-addons-for-elementor-lite' ),
'page-load' => esc_html__( 'On Page Load', 'essential-addons-for-elementor-lite' ),
'page-scroll' => esc_html__( 'On Page Scroll', 'essential-addons-for-elementor-lite' ),
'hover' => esc_html__( 'Mouse Hover', 'essential-addons-for-elementor-lite' ),
],
'separator' => 'before'
]
);
$this->add_control(
'eael_svg_draw_offset',
[
'label' => esc_html__( 'Drawing Start Point', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::NUMBER,
'min' => 1,
'max' => 1000,
'step' => 1,
'default' => 50,
'condition' => [
'eael_svg_animation_on' => [ 'page-scroll' ],
],
'description' => esc_html__( 'The point at which the drawing begins to animate as scrolls down (in pixels).', 'essential-addons-for-elementor-lite' )
]
);
$this->add_control(
'eael_svg_pause_on_hover',
[
'label' => esc_html__( 'Pause on Hover Off', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'essential-addons-for-elementor-lite' ),
'label_off' => esc_html__( 'No', 'essential-addons-for-elementor-lite' ),
'default' => 'yes',
'condition' => [
'eael_svg_animation_on' => 'hover',
],
'description' => esc_html__( 'Pause SVG drawing on mouse leave', 'essential-addons-for-elementor-lite' )
]
);
$this->add_control(
'eael_svg_loop',
[
'label' => esc_html__( 'Repeat Drawing', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'essential-addons-for-elementor-lite' ),
'label_off' => esc_html__( 'No', 'essential-addons-for-elementor-lite' ),
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'eael_svg_animation_on!' => [ 'page-scroll', 'none' ],
]
]
);
$this->add_control(
'eael_svg_animation_direction',
[
'label' => esc_html__( 'Direction', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SELECT,
'default' => 'reverse',
'options' => [
'reverse' => esc_html__( 'Reverse', 'essential-addons-for-elementor-lite' ),
'restart' => esc_html__( 'Restart', 'essential-addons-for-elementor-lite' ),
],
'condition' => [
'eael_svg_animation_on!' => [ 'page-scroll', 'none' ],
'eael_svg_loop' => 'yes'
]
]
);
$this->add_control(
'eael_svg_draw_speed',
[
'label' => esc_html__( 'Speed', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::NUMBER,
'min' => 1,
'max' => 300,
'step' => 1,
'default' => 20,
'condition' => [
'eael_svg_animation_on!' => [ 'page-scroll' ],
],
'description' => esc_html__( 'Duration on SVG draws (in ms)', 'essential-addons-for-elementor-lite' )
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_svg_style_settings',
[
'label' => esc_html__( 'Style', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_svg_path_thickness',
[
'label' => esc_html__( 'Path Thickness', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 50,
'step' => .1,
],
],
'default' => [
'unit' => 'px',
'size' => 1.2,
],
'selectors' => [
'{{WRAPPER}} svg path' => 'stroke-width: {{SIZE}};',
'{{WRAPPER}} svg circle' => 'stroke-width: {{SIZE}};',
'{{WRAPPER}} svg rect' => 'stroke-width: {{SIZE}};',
'{{WRAPPER}} svg polygon' => 'stroke-width: {{SIZE}};',
],
]
);
$this->add_control(
'eael_svg_color',
[
'type' => Controls_Manager::COLOR,
'label' => esc_html__( 'Color', 'essential-addons-for-elementor-lite' ),
'selectors' => [
'{{WRAPPER}} svg path' => 'stroke:{{VALUE}};',
'{{WRAPPER}} svg circle' => 'stroke:{{VALUE}};',
'{{WRAPPER}} svg rect' => 'stroke:{{VALUE}};',
'{{WRAPPER}} svg polygon' => 'stroke:{{VALUE}};',
],
'default' => '#974CF3'
]
);
$this->add_control(
'eael_svg_fill_color',
[
'type' => Controls_Manager::COLOR,
'label' => esc_html__( 'Fill Color', 'essential-addons-for-elementor-lite' ),
'selectors' => [
'{{WRAPPER}} .elementor-widget-container .fill-svg svg path' => 'fill:{{VALUE}};',
'{{WRAPPER}} .elementor-widget-container .eael-svg-draw-container.fill-svg svg path' => 'fill:{{VALUE}};',
'{{WRAPPER}} .elementor-widget-container .eael-svg-draw-container.fill-svg svg circle' => 'fill:{{VALUE}};',
'{{WRAPPER}} .elementor-widget-container .eael-svg-draw-container.fill-svg svg rect' => 'fill:{{VALUE}};',
'{{WRAPPER}} .elementor-widget-container .eael-svg-draw-container.fill-svg svg polygon' => 'fill:{{VALUE}};'
],
'default' => '#D8C2F3',
'condition' => [
'eael_svg_fill!' => 'none'
]
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'eael_svg_background',
'types' => [ 'classic', 'gradient' ],
'selector' => '{{WRAPPER}} .eael-svg-draw-container svg',
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_svg_border',
'selector' => '{{WRAPPER}} .eael-svg-draw-container svg',
'separator' => 'before'
]
);
$this->add_control(
'eael_svg_border_radius',
[
'label' => esc_html__( 'Border Radius', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-svg-draw-container svg' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_svg_padding',
[
'label' => esc_html__( 'Padding', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-svg-draw-container svg' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_svg_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-svg-draw-container svg' => 'Margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'box_shadow',
'selector' => '{{WRAPPER}} .eael-svg-draw-container svg',
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$svg_html = isset( $settings['svg_html'] ) ? preg_replace( '#<script(.*?)>(.*?)</script>#is', '', $settings['svg_html'] ) : '';
$this->add_render_attribute( 'eael-svg-drow-wrapper', [
'class' => [
'eael-svg-draw-container',
esc_attr( $settings['eael_svg_animation_on'] ),
$settings['eael_svg_fill'] === 'before' ? 'fill-svg' : ''
],
] );
$svg_options = [
'fill' => $settings['eael_svg_fill'] === 'after' ? 'fill-svg' : '',
'speed' => esc_attr( $settings['eael_svg_draw_speed'] ),
'offset' => esc_attr( $settings['eael_svg_draw_offset'] ),
'loop' => $settings['eael_svg_loop'] ? esc_attr( $settings['eael_svg_loop'] ) : 'no',
'pause' => $settings['eael_svg_pause_on_hover'] ? esc_attr( $settings['eael_svg_pause_on_hover'] ) : 'no',
'direction' => esc_attr( $settings['eael_svg_animation_direction'] ),
'excludeStyle' => esc_attr( $settings['eael_svg_exclude_style'] )
];
$this->add_render_attribute( 'eael-svg-drow-wrapper', [
'data-settings' => wp_json_encode( $svg_options )
] );
if ( ! empty( $settings['eael_svg_link']['url'] ) ) {
$this->add_link_attributes( 'eael_svg_link', $settings['eael_svg_link'] );
echo '<a ' . $this->get_render_attribute_string( 'eael_svg_link' ) . '>';
}
echo '<div ' . $this->get_render_attribute_string( 'eael-svg-drow-wrapper' ) . '>';
if ( $settings['eael_svg_src'] === 'icon' ):
if ( $settings['eael_svg_icon']['library'] === 'svg' ) {
if ( empty( $settings['eael_svg_icon']['value']['id'] ) ) {
echo $this->default_custom_svg();
}
Icons_Manager::render_icon( $settings['eael_svg_icon'], [ 'aria-hidden' => 'true', 'class' => [ 'eael-svg-drow-wrapper' ] ] );
} else {
echo Helper::get_svg_by_icon( $settings['eael_svg_icon'] );
}
else:
printf( '%s', $svg_html );
endif;
echo ' </div>';
if ( ! empty( $settings['eael_svg_link']['url'] ) ) {
echo "</a>";
}
}
}

View File

@@ -0,0 +1,925 @@
<?php
namespace Essential_Addons_Elementor\Elements;
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Modules\DynamicTags\Module as TagsModule;
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Widget_Base;
class Sticky_Video extends Widget_Base
{
protected $eaelRElem = 1;
public function get_name()
{
return 'eael-sticky-video';
}
public function get_title()
{
return esc_html__('Sticky Video', 'essential-addons-for-elementor-lite');
}
public function get_icon()
{
return 'eaicon-sticky-video';
}
public function get_categories()
{
return ['essential-addons-elementor'];
}
public function get_keywords()
{
return [
'video',
'sticky',
'ea sticky video',
'ea video player',
'youtube',
'vimeo',
'mp4',
'mpg',
'ogg',
'webm',
'mov',
'avi',
'scrollable video',
'sticky control',
'video player',
'youtube content',
'ea',
'essential addons'
];
}
public function get_custom_help_url()
{
return 'https://essential-addons.com/elementor/docs/sticky-video/';
}
public function get_style_depends()
{
return [
'font-awesome-5-all',
'font-awesome-4-shim',
];
}
public function get_script_depends()
{
return [
'font-awesome-4-shim'
];
}
protected function register_controls()
{
/**
* General
*/
$this->start_controls_section(
'eaelsv_sticky_option_section',
[
'label' => __('Sticky Options', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'eaelsv_is_sticky',
[
'label' => __('Sticky', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_block' => false,
'label_on' => __('On', 'essential-addons-for-elementor-lite'),
'label_off' => __('Off', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
'default' => 'yes',
'selectors' => [
'{{WRAPPER}} div.eaelsv-sticky-player' => 'display: block',
],
]
);
$this->add_control(
'eaelsv_sticky_position',
[
'label' => __('Position', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'options' => [
'top-left' => __('Top Left', 'essential-addons-for-elementor-lite'),
'top-right' => __('Top Right', 'essential-addons-for-elementor-lite'),
'bottom-left' => __('Bottom Left', 'essential-addons-for-elementor-lite'),
'bottom-right' => __('Bottom Right', 'essential-addons-for-elementor-lite'),
],
'default' => 'bottom-right',
'condition' => [
'eaelsv_is_sticky' => 'yes',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_video_settings',
[
'label' => esc_html__('Video', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'eael_video_source',
[
'label' => __('Source', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'youtube',
'options' => [
'youtube' => __('YouTube', 'essential-addons-for-elementor-lite'),
'vimeo' => __('Vimeo', 'essential-addons-for-elementor-lite'),
'self_hosted' => __('Self Hosted', 'essential-addons-for-elementor-lite'),
],
]
);
$this->add_control(
'eaelsv_link_youtube',
[
'label' => __('Link', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'dynamic' => ['active' => true],
'placeholder' => __('Enter your URL (YouTube)', 'essential-addons-for-elementor-lite'),
'label_block' => true,
'default' => 'https://www.youtube.com/watch?v=uuyXfUDqRZM',
'condition' => [
'eael_video_source' => 'youtube',
],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eaelsv_link_vimeo',
[
'label' => __('Link', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'dynamic' => [ 'active' => true ],
'placeholder' => __('Enter your URL (Vimeo)', 'essential-addons-for-elementor-lite'),
'label_block' => true,
'default' => 'https://vimeo.com/235215203',
'condition' => [
'eael_video_source' => 'vimeo',
],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eaelsv_link_dailymotion',
[
'label' => __('Link', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'dynamic' => [ 'active' => true ],
'placeholder' => __('Enter your URL (Dailymotion)', 'essential-addons-for-elementor-lite'),
'label_block' => true,
'condition' => [
'eael_video_source' => 'dailymotion',
],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eaelsv_link_external',
[
'label' => __('External URL', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_block' => false,
'condition' => [
'eael_video_source' => 'self_hosted',
],
]
);
$this->add_control(
'eaelsv_hosted_url',
[
'label' => __('Choose File', 'elementor'),
'type' => Controls_Manager::MEDIA,
'dynamic' => [
'active' => true,
'categories' => [
TagsModule::MEDIA_CATEGORY,
],
],
'media_type' => 'video',
'condition' => [
'eael_video_source' => 'self_hosted',
'eaelsv_link_external' => '',
],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eaelsv_external_url',
[
'label' => __('Link', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'dynamic' => [ 'active' => true ],
'placeholder' => __('Enter your URL', 'essential-addons-for-elementor-lite'),
'label_block' => true,
'show_label' => false,
'condition' => [
'eael_video_source' => 'self_hosted',
'eaelsv_link_external' => 'yes',
],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eael_video_self_hosted_link',
[
'label' => __('Choose File', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::MEDIA,
'label_block' => true,
'condition' => [
'eael_video_source' => 'self_hosted',
'eael_video_source_external' => '',
],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eaelsv_start_time',
[
'label' => __('Start Time', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::NUMBER,
'min' => 0,
'max' => 10000,
'step' => 1,
'default' => '',
'description' => 'Specify a start time (in seconds)',
'condition' => [
'eael_video_source' => 'self_hosted',
],
]
);
$this->add_control(
'eaelsv_end_time',
[
'label' => __('End Time', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::NUMBER,
'min' => 0,
'max' => 10000,
'step' => 1,
'default' => '',
'description' => 'Specify an end time (in seconds)',
'condition' => [
'eael_video_source' => 'self_hosted',
],
]
);
$this->add_control(
'eael_video_video_options',
[
'label' => __('Video Options', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'eaelsv_autopaly',
[
'label' => __('Autoplay', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_block' => false,
'return_value' => 'yes',
'default' => '',
]
);
$this->add_control(
'eaelsv_autopaly_description',
[
'raw' => __('Autoplay requires mute volume.', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::RAW_HTML,
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
'condition' => [
'eaelsv_autopaly' => 'yes',
],
]
);
$this->add_control(
'eaelsv_mute',
[
'label' => __('Mute', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_block' => false,
'return_value' => 'yes',
'default' => '',
'condition' => [
'eaelsv_autopaly!' => 'yes',
],
]
);
$this->add_control(
'eaelsv_loop',
[
'label' => __('Loop', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_block' => false,
'return_value' => 'yes',
'default' => '',
]
);
$this->add_control(
'eaelsv_sh_show_bar',
[
'label' => __('Show Bar', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_block' => false,
'default' => 'yes',
'selectors' => [
'{{WRAPPER}} .plyr__controls' => 'display: flex!important;',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_video_image_overlay_section',
[
'label' => __('Image Overlay', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'eaelsv_overlay_options',
[
'label' => __('Image Overlay', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'options' => [
'' => __('Default', 'essential-addons-for-elementor-lite'),
'yes' => __('Custom', 'essential-addons-for-elementor-lite'),
'transparent' => __('Transparent', 'essential-addons-for-elementor-lite'),
],
'default' => '',
]
);
$this->add_control(
'eaelsv_overlay_image',
[
'label' => __('Choose Image', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::MEDIA,
'label_block' => true,
'condition' => [
'eaelsv_overlay_options' => 'yes',
],
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
'ai' => [
'active' => false,
],
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'default' => 'full',
'name' => 'eaelsv_overlay_image_size',
'condition' => [
'eaelsv_overlay_options' => 'yes',
],
]
);
$this->add_control(
'eaelsv_overlay_play_icon',
[
'label' => __('Play Icon', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_block' => false,
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'eaelsv_overlay_options' => 'yes',
],
]
);
$this->add_control(
'eaelsv_icon_new',
[
'label' => esc_html__('Choose Icon', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'eaelsv_icon',
'condition' => [
'eaelsv_overlay_options' => 'yes',
'eaelsv_overlay_play_icon' => 'yes',
],
]
);
$this->add_control( 'eaelsv_icon_new_notice', [
'type' => Controls_Manager::RAW_HTML,
'raw' => __( 'Play icon appears on top of overlay image.', 'essential-addons-for-elementor-lite' ),
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
'condition' => [
'eaelsv_overlay_options' => 'yes',
],
] );
$this->end_controls_section();
/**
* Style Tab Started
*/
$this->start_controls_section(
'eaelsv_sticky_video_interface',
[
'label' => __('Sticky Video Interface', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'eaelsv_is_sticky' => 'yes',
],
]
);
$this->add_control(
'eaelsv_sticky_width',
[
'label' => __('Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::NUMBER,
'min' => 100,
'max' => 500,
'step' => 1,
'default' => 300,
'condition' => [
'eaelsv_is_sticky' => 'yes',
],
'selectors' => [
'{{WRAPPER}} .eael-sticky-video-player2.out' => 'width: {{VALUE}}px!important;',
],
]
);
$this->add_control(
'eaelsv_sticky_height',
[
'label' => __('Height', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::NUMBER,
'min' => 55,
'max' => 280,
'step' => 1,
'default' => 169,
'condition' => [
'eaelsv_is_sticky' => 'yes',
],
'selectors' => [
'{{WRAPPER}} .eael-sticky-video-player2.out' => 'height: {{VALUE}}px!important;',
],
]
);
$this->add_control(
'eaelsv_scroll_height_display_sticky',
[
'label' => __('Scroll Height To Display Sticky (%)', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 50,
'max' => 200,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 70,
],
'condition' => [
'eaelsv_is_sticky' => 'yes',
],
]
);
$this->add_control(
'eaelsv_sticky_close_button_color',
[
'label' => __('Close Button Color', 'essential-addons-for-elementor-lite'),
'type' => \Elementor\Controls_Manager::COLOR,
'condition' => [
'eaelsv_is_sticky' => 'yes',
],
'selectors' => [
'{{WRAPPER}} .eaelsv-sticky-player-close' => 'color: {{VALUE}}!important',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eaelsv_sh_player_section',
[
'label' => __('Player', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'eaelsv_sh_video_width',
[
'label' => esc_html__('Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%'],
'range' => [
'px' => [
'min' => 0,
'max' => 1200,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .eael-sticky-video-wrapper' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'eaelsv_sh_video_border_type',
[
'label' => __('Border Type', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'none',
'options' => [
'none' => __('None', 'essential-addons-for-elementor-lite'),
'solid' => __('Solid', 'essential-addons-for-elementor-lite'),
'double' => __('Double', 'essential-addons-for-elementor-lite'),
'dotted' => __('Dotted', 'essential-addons-for-elementor-lite'),
'dashed' => __('Dashed', 'essential-addons-for-elementor-lite'),
],
'selectors' => [
'{{WRAPPER}} .eael-sticky-video-wrapper' => 'border-style: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'eaelsv_sh_video_border_width',
[
'label' => esc_html__('Border Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .eael-sticky-video-wrapper' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eaelsv_sh_video_border_color',
[
'label' => esc_html__('Border Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-sticky-video-wrapper' => 'border-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'eaelsv_sh_video_border_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .eael-sticky-video-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eaelsv-overlay' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-sticky-video-player2' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eaelsv_sh_player_interface_section',
[
'label' => __('Interface', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eaelsv_sh_video_interface_color',
[
'label' => esc_html__('Interface Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#ADD8E6',
'selectors' => [
'{{WRAPPER}} .plyr__control.plyr__tab-focus' => 'box-shadow: 0 0 0 5px {{VALUE}}!important',
'{{WRAPPER}} .plyr__control--overlaid' => 'background: {{VALUE}}!important',
'{{WRAPPER}} .plyr--video .plyr__control.plyr__tab-focus' => 'background: {{VALUE}}!important',
'{{WRAPPER}} .plyr__control--overlaid' => 'background: {{VALUE}}!important',
'{{WRAPPER}} .plyr--video .plyr__control:hover' => 'background: {{VALUE}}!important',
],
]
);
$this->add_responsive_control(
'eaelsv_sh_play_button_size',
[
'label' => __('Play Button Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 15,
'unit' => 'px',
],
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 15,
'max' => 55,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .plyr__control--overlaid' => 'padding: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eaelsv_sh_player_bar_section',
[
'label' => __('Bar', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'eaelsv_sh_player_bar_padding',
[
'label' => __('Bar Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 10,
'unit' => 'px',
],
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 10,
'max' => 50,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .plyr--video .plyr__controls' => 'padding: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eaelsv_sh_bar_margin',
[
'label' => esc_html__('Bar Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .plyr--video .plyr__controls' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
}
protected function render()
{
$settings = $this->get_settings_for_display();
$iconNew = $settings['eaelsv_icon_new'];
$sticky = $settings['eaelsv_is_sticky'];
$autoplay = ($settings['eaelsv_autopaly'] == 'yes') ? $settings['eaelsv_autopaly'] : 'no';
$eaelsvPlayer = '';
$eaelsv_overlay_visibility = $settings['eaelsv_overlay_options'];
if ('youtube' == $settings['eael_video_source']) {
$eaelsvPlayer = $this->eaelsv_load_player_youtube();
}
if ('vimeo' == $settings['eael_video_source']) {
$eaelsvPlayer = $this->eaelsv_load_player_vimeo();
}
if ('self_hosted' == $settings['eael_video_source']) {
$eaelsvPlayer = $this->eaelsv_load_player_self_hosted();
}
echo '<div class="eael-sticky-video-wrapper eaelsv-overlay-visibility-' . esc_attr( $eaelsv_overlay_visibility ) . '">';
if ('yes' === $settings['eaelsv_overlay_options']) {
// $autoplay = 'yes';
$icon = '';
if ('yes' === $settings['eaelsv_overlay_play_icon']) {
if ($iconNew['value'] != '') {
if (is_array($iconNew['value'])) {
$icon = '<img src="' . esc_url( $iconNew['value']['url'] ) . '" width="100">';
} else {
$icon = '<i class="' . esc_attr( $iconNew['value'] ) . '"></i>';
}
} else {
$icon = '<i class="eicon-play"></i>';
}
}
$overlay_class = 'eaelsv-overlay';
if( 'yes' === $settings['eaelsv_overlay_options'] && empty( $settings['eaelsv_overlay_image']['url'] ) ){
$icon = '';
$overlay_class = 'eaelsv-overlay-ignore';
}
$this->add_render_attribute(
'esvp_overlay_wrapper',
[
'class' => esc_attr( $overlay_class ),
'style' => "background-image:url('" . $settings['eaelsv_overlay_image']['url'] . "');",
]
);
echo '<div ' . $this->get_render_attribute_string('esvp_overlay_wrapper') . '>
<div class="eaelsv-overlay-icon">' . $icon . '</div>
</div>';
}
$this->add_render_attribute(
'esvp_overlay_wrapper2',
[
'class' => 'eael-sticky-video-player2',
'data-sticky' => $sticky,
'data-position' => $settings['eaelsv_sticky_position'],
'data-sheight' => $settings['eaelsv_sticky_height'],
'data-swidth' => $settings['eaelsv_sticky_width'],
'data-scroll_height' => !empty($settings['eaelsv_scroll_height_display_sticky']['size']) ? $settings['eaelsv_scroll_height_display_sticky']['size'] : '',
'data-autoplay' => $autoplay,
'data-overlay' => ($settings['eaelsv_overlay_options'] == 'yes') ? $settings['eaelsv_overlay_options'] : 'no',
]
);
echo '<div ' . $this->get_render_attribute_string('esvp_overlay_wrapper2') . '>
' . $eaelsvPlayer . '
<span class="eaelsv-sticky-player-close"><i class="fas fa-times-circle"></i></span>
</div>
</div>';
}
protected function eaelsv_load_player_youtube()
{
$settings = $this->get_settings_for_display();
$id = $this->eaelsv_get_url_id();
$autoplay = $settings['eaelsv_autopaly'];
$mute = $autoplay == 'yes' ? 'yes' : $settings['eaelsv_mute'];
$loop = $settings['eaelsv_loop'];
$am = '"storage": {"enabled": false, "key": "plyr"}';
$am .= ( $autoplay == 'yes' ? ', "autoplay":1' : ', "autoplay":0' );
$am .= ( $mute == 'yes' ? ', "muted":1, "volume":0' : ', "muted":0' );
if ('yes' == $loop) {
$lp = '"loop": {"active": true}';
} else {
$lp = '"loop": {"active": false}';
}
return '<div
id="eaelsv-player-' . $this->get_id() . '"
data-plyr-provider="youtube"
data-plyr-embed-id="' . esc_attr($id) . '"
data-plyr-config="{' . esc_attr($am) . ', ' . esc_attr($lp) . '}"
></div>';
}
protected function eaelsv_load_player_vimeo()
{
$settings = $this->get_settings_for_display();
$id = $this->eaelsv_get_url_id();
$autoplay = $settings['eaelsv_autopaly'];
$mute = $autoplay == 'yes' ? 'yes' : $settings['eaelsv_mute'];
$loop = $settings['eaelsv_loop'];
$am = '"storage": {"enabled": false, "key": "plyr"}';
$am .= ( $autoplay == 'yes' ? ', "autoplay":1' : ', "autoplay":0' );
$am .= ( $mute == 'yes' ? ', "muted":1, "volume":0' : ', "muted":0' );
if ('yes' == $loop) {
$lp = '"loop": {"active": true}';
} else {
$lp = '"loop": {"active": false}';
}
return '<div
id="eaelsv-player-' . $this->get_id() . '"
data-plyr-provider="vimeo"
data-plyr-embed-id="' . esc_attr($id) . '"
data-plyr-config="{' . esc_attr($am) . ', ' . esc_attr($lp) . '}"
></div>';
}
protected function eaelsv_load_player_self_hosted()
{
$settings = $this->get_settings_for_display();
$video = ($settings['eaelsv_external_url'] != '') ? $settings['eaelsv_external_url'] : $settings['eaelsv_hosted_url']['url'];
$controlBars = $settings['eaelsv_sh_show_bar'];
$autoplay = $settings['eaelsv_autopaly'];
$mute = $settings['eaelsv_mute'];
$loop = $settings['eaelsv_loop'];
$interfaceColor = $settings['eaelsv_sh_video_interface_color'];
$startTime = $settings['eaelsv_start_time'];
$endTime = $settings['eaelsv_end_time'];
$am = '';
$am .= ($autoplay == 'yes' ? '"autoplay":1' : '"autoplay":0');
$am .= ($mute == 'yes' ? ', "muted":1' : ', "muted":0');
if ('yes' == $loop) {
$lp = '"loop": {"active": true}';
} else {
$lp = '"loop": {"active": false}';
}
return '<video class="eaelsv-player" id="eaelsv-player-' . $this->get_id() . '" playsinline controls data-plyr-config="{' . esc_attr($am) . ', ' . esc_attr($lp) . '}">
<source src="' . esc_attr($video) . '#t=' . esc_attr($startTime) . ',' . esc_attr($endTime) . '" type="video/mp4" />
</video>';
}
protected function eaelsv_get_url_id()
{
$settings = $this->get_settings_for_display();
if ( 'youtube' === $settings['eael_video_source'] ) {
$url = $settings['eaelsv_link_youtube'];
$link = explode( '=', parse_url( $url, PHP_URL_QUERY ) );
$short_link = explode( '/', $url );
$id = isset( $link[1] ) ? $link[1] : ( isset( $short_link[3] ) ? $short_link[3] : '' );
}
if ('vimeo' === $settings['eael_video_source']) {
$url = $settings['eaelsv_link_vimeo'];
$link = explode('/', $url);
$id = isset( $link[3] ) ? $link[3] : '';
}
if ('self_hosted' === $settings['eael_video_source']) {
$externalUrl = $settings['eaelsv_link_external'];
if ('yes' == $externalUrl) {
$id = $settings['eaelsv_external_url'];
} else {
$id = $settings['eaelsv_hosted_url']['url'];
}
}
return $id;
}
}

View File

@@ -0,0 +1,966 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Group_Control_Typography;
use \Elementor\Group_Control_Background;
use Elementor\Repeater;
use \Elementor\Utils;
use \Elementor\Widget_Base;
use \Essential_Addons_Elementor\Classes\Helper as HelperClass;
class Team_Member extends Widget_Base {
public function get_name() {
return 'eael-team-member';
}
public function get_title() {
return esc_html__( 'Team Member', 'essential-addons-for-elementor-lite');
}
public function get_icon() {
return 'eaicon-team-mamber';
}
public function get_categories() {
return [ 'essential-addons-elementor' ];
}
public function get_keywords()
{
return [
'team',
'member',
'team member',
'ea team member',
'ea team members',
'person',
'card',
'meet the team',
'team builder',
'our team',
'ea',
'essential addons'
];
}
public function get_custom_help_url()
{
return 'https://essential-addons.com/elementor/docs/team-members/';
}
protected function register_controls() {
$this->start_controls_section(
'eael_section_team_member_image',
[
'label' => esc_html__( 'Team Member Image', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_team_member_image',
[
'label' => __( 'Team Member Avatar', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'ai' => [
'active' => false,
],
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'thumbnail',
'default' => 'full',
'condition' => [
'eael_team_member_image[url]!' => '',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_team_member_content',
[
'label' => esc_html__( 'Team Member Content', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_team_member_name',
[
'label' => esc_html__( 'Name', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'default' => esc_html__( 'John Doe', 'essential-addons-for-elementor-lite'),
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eael_team_member_job_title',
[
'label' => esc_html__( 'Job Position', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'default' => esc_html__( 'Software Engineer', 'essential-addons-for-elementor-lite'),
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eael_team_member_description',
[
'label' => esc_html__( 'Description', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXTAREA,
'dynamic' => [
'active' => true,
],
'default' => esc_html__( 'Add team member description here. Remove the text if not necessary.', 'essential-addons-for-elementor-lite'),
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_team_member_social_profiles',
[
'label' => esc_html__( 'Social Profiles', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_team_member_enable_social_profiles',
[
'label' => esc_html__( 'Display Social Profiles?', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
]
);
$repeater = new Repeater();
$repeater->add_control(
'social_new',
[
'label' => esc_html__( 'Icon', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'social',
'default' => [
'value' => 'fab fa-wordpress',
'library' => 'fa-brands',
],
]
);
$repeater->add_control(
'link',
[
'name' => 'link',
'label' => esc_html__( 'Link', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::URL,
'dynamic' => ['active' => true],
'label_block' => true,
'default' => [
'url' => '',
'is_external' => 'true',
],
'placeholder' => esc_html__( 'Place URL here', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_team_member_social_profile_links',
[
'type' => Controls_Manager::REPEATER,
'condition' => [
'eael_team_member_enable_social_profiles!' => '',
],
'default' => [
[
'social_new' => [
'value' => 'fab fa-facebook',
'library' => 'fa-brands'
]
],
[
'social_new' => [
'value' => 'fab fa-twitter',
'library' => 'fa-brands'
]
],
[
'social_new' => [
'value' => 'fab fa-google-plus',
'library' => 'fa-brands'
]
],
[
'social_new' => [
'value' => 'fab fa-linkedin',
'library' => 'fa-brands'
]
],
],
'fields' => $repeater->get_controls(),
'title_field' => '<i class="{{ social_new.value }}"></i>',
]
);
$this->end_controls_section();
if(!apply_filters('eael/pro_enabled', false)) {
$this->start_controls_section(
'eael_section_pro',
[
'label' => __( 'Go Premium for More Features', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_control_get_pro',
[
'label' => __( 'Unlock more possibilities', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'1' => [
'title' => '',
'icon' => 'fa fa-unlock-alt',
],
],
'default' => '1',
'description' => '<span class="pro-feature"> Get the <a href="https://wpdeveloper.com/upgrade/ea-pro" target="_blank">Pro version</a> for more stunning elements and customization options.</span>'
]
);
$this->end_controls_section();
}
$this->start_controls_section(
'eael_section_team_members_styles_general',
[
'label' => esc_html__( 'Team Member Styles', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE
]
);
$team_member_style_presets_options = apply_filters('eael_team_member_style_presets_options', [
'eael-team-members-simple' => esc_html__( 'Simple Style', 'essential-addons-for-elementor-lite' ),
'eael-team-members-overlay' => esc_html__( 'Overlay Style', 'essential-addons-for-elementor-lite' ),
'eael-team-members-centered' => esc_html__( 'Centered Style', 'essential-addons-for-elementor-lite' ),
'eael-team-members-circle' => esc_html__( 'Circle Style', 'essential-addons-for-elementor-lite' ),
'eael-team-members-social-bottom' => esc_html__( 'Social on Bottom', 'essential-addons-for-elementor-lite' ),
'eael-team-members-social-right' => esc_html__( 'Social on Right', 'essential-addons-for-elementor-lite' ),
]);
$this->add_control(
'eael_team_members_preset',
[
'label' => esc_html__( 'Style Preset', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'eael-team-members-simple',
'options' => $team_member_style_presets_options
]
);
$team_member_style_presets_condition = apply_filters('eael_team_member_style_presets_condition', [
'eael-team-members-centered',
'eael-team-members-circle',
'eael-team-members-social-bottom',
'eael-team-members-social-right'
]);
$this->add_control(
'eael_team_members_preset_pro_alert',
[
'label' => esc_html__( 'Only available in pro version!', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'condition' => [
'eael_team_members_preset' => $team_member_style_presets_condition
]
]
);
$this->add_control(
'content_card_style',
[
'label' => __( 'Content Card', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'content_card_height',
[
'label' => esc_html__( 'Height', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', 'em' ],
'range' => [
'px' => [
'min' => 0,
'max' => 500,
],
'em' => [
'min' => 0,
'max' => 200
]
],
'selectors' => [
'{{WRAPPER}} .eael-team-item .eael-team-content' => 'min-height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_team_members_enable_text_overlay',
[
'label' => esc_html__( 'Enable Description Overlay', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'return_value' => 'yes',
'condition' => [
'eael_team_members_preset' => 'eael-team-members-simple'
]
]
);
$this->add_control(
'eael_team_members_overlay_background',
[
'label' => esc_html__( 'Overlay Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => 'rgba(255,255,255,0.8)',
'selectors' => [
'{{WRAPPER}} .eael-team-members-overlay .eael-team-content' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-team-image .eael-team-text-overlay' => 'background-color: {{VALUE}};',
],
'conditions' => [
'relation' => 'or',
'terms' => [
[
'name' => 'eael_team_members_preset',
'operator' => '=',
'value' => 'eael-team-members-overlay'
],
[
'name' => 'eael_team_members_enable_text_overlay',
'operator' => '=',
'value' => 'yes'
]
]
],
]
);
$this->add_control(
'eael_team_members_background',
[
'label' => esc_html__( 'Content Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-team-item .eael-team-content' => 'background-color: {{VALUE}};',
'{{WRAPPER}} .eael-team-item .eael-team-image .eael-team-text-overlay' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_team_members_alignment',
[
'label' => esc_html__( 'Set Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'label_block' => true,
'options' => [
'default' => [
'title' => __( 'Default', 'essential-addons-for-elementor-lite'),
'icon' => 'fa fa-ban',
],
'left' => [
'title' => esc_html__( 'Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-left',
],
'centered' => [
'title' => esc_html__( 'Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'eael-team-align-default',
'prefix_class' => 'eael-team-align-',
]
);
$this->add_responsive_control(
'eael_team_members_padding',
[
'label' => esc_html__( 'Content Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-team-item .eael-team-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_team_members_border',
'label' => esc_html__( 'Border', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} .eael-team-item',
]
);
$this->add_control(
'eael_team_members_border_radius',
[
'label' => esc_html__( 'Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'selectors' => [
'{{WRAPPER}} .eael-team-item' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_team_members_image_styles',
[
'label' => esc_html__( 'Team Member Image Style', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE
]
);
$this->add_responsive_control(
'eael_team_members_image_width',
[
'label' => esc_html__( 'Image Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 100,
'unit' => '%',
],
'range' => [
'%' => [
'min' => 0,
'max' => 100,
],
'px' => [
'min' => 0,
'max' => 1000,
],
],
'size_units' => [ '%', 'px' ],
'selectors' => [
'{{WRAPPER}} .eael-team-item figure img' => 'width:{{SIZE}}{{UNIT}};',
],
'condition' => [
'eael_team_members_preset!' => 'eael-team-members-circle'
]
]
);
do_action('eael/team_member_circle_controls', $this);
$this->add_responsive_control(
'eael_team_members_image_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-team-item figure img' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_team_members_image_padding',
[
'label' => esc_html__( 'Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-team-item figure img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_team_members_image_border',
'label' => esc_html__( 'Border', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} .eael-team-item figure img',
]
);
$this->add_control(
'eael_team_members_image_rounded',
[
'label' => esc_html__( 'Rounded Avatar?', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'return_value' => 'team-avatar-rounded',
'default' => '',
]
);
$this->add_control(
'eael_team_members_image_border_radius',
[
'label' => esc_html__( 'Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'selectors' => [
'{{WRAPPER}} .eael-team-item figure img' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
],
'condition' => [
'eael_team_members_image_rounded!' => 'team-avatar-rounded',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_team_members_typography',
[
'label' => esc_html__( 'Color &amp; Typography', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE
]
);
$this->add_control(
'eael_team_members_name_heading',
[
'label' => __( 'Member Name', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'eael_team_members_name_color',
[
'label' => esc_html__( 'Member Name Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#272727',
'selectors' => [
'{{WRAPPER}} .eael-team-item .eael-team-member-name' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_team_members_name_typography',
'selector' => '{{WRAPPER}} .eael-team-item .eael-team-member-name',
]
);
$this->add_control(
'eael_team_members_position_heading',
[
'label' => __( 'Member Job Position', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'eael_team_members_position_color',
[
'label' => esc_html__( 'Job Position Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#272727',
'selectors' => [
'{{WRAPPER}} .eael-team-item .eael-team-member-position' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_team_members_position_typography',
'selector' => '{{WRAPPER}} .eael-team-item .eael-team-member-position',
]
);
$this->add_control(
'eael_team_members_description_heading',
[
'label' => __( 'Member Description', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'eael_team_members_description_color',
[
'label' => esc_html__( 'Description Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#272727',
'selectors' => [
'{{WRAPPER}} .eael-team-item .eael-team-content .eael-team-text' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-team-item .eael-team-image .eael-team-text.eael-team-text-overlay' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_team_members_description_typography',
'selector' => '{{WRAPPER}} .eael-team-item .eael-team-content .eael-team-text,
{{WRAPPER}} .eael-team-item .eael-team-image .eael-team-text.eael-team-text-overlay',
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_team_members_social_profiles_styles',
[
'label' => esc_html__( 'Social Profiles Style', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE
]
);
$this->add_control(
'eael_team_members_social_icon_size',
[
'label' => esc_html__( 'Icon Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 200,
],
],
'default' => [
'size' => 35,
'unit' => 'px'
],
'selectors' => [
// '{{WRAPPER}} .eael-team-member-social-link > a' => 'width: {{SIZE}}px; height: {{SIZE}}px; line-height: {{SIZE}}px;',
'{{WRAPPER}} .eael-team-member-social-link > a i' => 'font-size: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .eael-team-member-social-link > a img' => 'width: {{SIZE}}px; height: {{SIZE}}px; line-height: {{SIZE}}px;',
'{{WRAPPER}} .eael-team-member-social-link > a svg' => 'width: {{SIZE}}px; height: {{SIZE}}px; line-height: {{SIZE}}px;',
],
]
);
$this->add_responsive_control(
'eael_team_members_social_profiles_padding',
[
'label' => esc_html__( 'Social Profiles Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-team-content > .eael-team-member-social-profiles' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-team-image > .eael-team-member-social-profiles' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_team_members_social_icons_padding',
[
'label' => esc_html__( 'Social Icon Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-team-content > .eael-team-member-social-profiles li.eael-team-member-social-link > a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-team-image > .eael-team-member-social-profiles li.eael-team-member-social-link > a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_team_members_social_icons_spacing',
[
'label' => esc_html__( 'Social Icon Distance', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-team-content > .eael-team-member-social-profiles li.eael-team-member-social-link' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .eael-team-image > .eael-team-member-social-profiles li.eael-team-member-social-link' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_team_members_social_icons_used_gradient_bg',
[
'label' => __( 'Use Gradient Background', 'essential-addons-for-elementor-lite' ),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => __( 'Yes', 'essential-addons-for-elementor-lite' ),
'label_off' => __( 'No', 'essential-addons-for-elementor-lite' ),
'return_value' => 'yes',
]
);
$this->start_controls_tabs( 'eael_team_members_social_icons_style_tabs' );
$this->start_controls_tab( 'normal', [ 'label' => esc_html__( 'Normal', 'essential-addons-for-elementor-lite') ] );
$this->add_control(
'eael_team_members_social_icon_color',
[
'label' => esc_html__( 'Icon Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#f1ba63',
'selectors' => [
'{{WRAPPER}} .eael-team-member-social-link > a' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-team-member-social-link > a svg' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'eael_team_members_social_icon_background',
[
'label' => esc_html__( 'Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-team-member-social-link > a' => 'background-color: {{VALUE}};',
],
'condition' => [
'eael_team_members_social_icons_used_gradient_bg' => ''
]
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'eael_team_members_social_icon_gradient_background',
'label' => __( 'Background', 'essential-addons-for-elementor-lite' ),
'types' => [ 'classic', 'gradient' ],
'selector' => '{{WRAPPER}} .eael-team-member-social-link > a',
'condition' => [
'eael_team_members_social_icons_used_gradient_bg' => 'yes'
]
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_team_members_social_icon_border',
'selector' => '{{WRAPPER}} .eael-team-member-social-link > a',
]
);
$this->add_control(
'eael_team_members_social_icon_border_radius',
[
'label' => esc_html__( 'Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .eael-team-member-social-link > a' => 'border-radius: {{SIZE}}px;',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_team_members_social_icon_typography',
'selector' => '{{WRAPPER}} .eael-team-member-social-link > a',
]
);
$this->end_controls_tab();
$this->start_controls_tab( 'eael_team_members_social_icon_hover', [ 'label' => esc_html__( 'Hover', 'essential-addons-for-elementor-lite') ] );
$this->add_control(
'eael_team_members_social_icon_hover_color',
[
'label' => esc_html__( 'Icon Hover Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#ad8647',
'selectors' => [
'{{WRAPPER}} .eael-team-member-social-link > a:hover' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-team-member-social-link > a:hover svg' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'eael_team_members_social_icon_hover_background',
[
'label' => esc_html__( 'Hover Background', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-team-member-social-link > a:hover' => 'background-color: {{VALUE}};',
],
'condition' => [
'eael_team_members_social_icons_used_gradient_bg' => ''
]
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'eael_team_members_social_icon_hover_gradient_background',
'label' => __( 'Background', 'essential-addons-for-elementor-lite' ),
'types' => [ 'classic', 'gradient' ],
'selector' => '{{WRAPPER}} .eael-team-member-social-link > a:hover',
'condition' => [
'eael_team_members_social_icons_used_gradient_bg' => 'yes'
]
]
);
$this->add_control(
'eael_team_members_social_icon_hover_border_color',
[
'label' => esc_html__( 'Hover Border Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-team-member-social-link > a:hover' => 'border-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function render( ) {
$settings = $this->get_settings_for_display();
$team_member_image = $this->get_settings( 'eael_team_member_image' );
$team_member_image_url = Group_Control_Image_Size::get_attachment_image_src( $team_member_image['id'], 'thumbnail', $settings );
if( empty( $team_member_image_url ) ) : $team_member_image_url = $team_member_image['url']; else: $team_member_image_url = $team_member_image_url; endif;
$team_member_classes = $this->get_settings('eael_team_members_preset') . " " . $this->get_settings('eael_team_members_image_rounded');
$this->add_render_attribute( 'eael_team_text', 'class', 'eael-team-text' );
if ( isset( $settings['eael_team_members_enable_text_overlay'] ) && $settings['eael_team_members_enable_text_overlay'] == 'yes' ) {
$this->add_render_attribute( 'eael_team_text', 'class', 'eael-team-text-overlay' );
}
?>
<div id="eael-team-member-<?php echo esc_attr($this->get_id()); ?>" class="eael-team-item <?php echo $team_member_classes; ?>">
<div class="eael-team-item-inner">
<div class="eael-team-image">
<figure>
<img src="<?php echo esc_url($team_member_image_url);?>" alt="<?php echo esc_attr( get_post_meta($team_member_image['id'], '_wp_attachment_image_alt', true) ); ?>">
</figure>
<?php if( 'eael-team-members-social-right' === $settings['eael_team_members_preset'] ) : ?>
<?php do_action( 'eael/team_member_social_right_markup', $settings, $this ); ?>
<?php endif; ?>
<?php
if ( isset( $settings['eael_team_members_enable_text_overlay'] ) && $settings['eael_team_members_enable_text_overlay'] == 'yes' ) {
?>
<p <?php echo $this->get_render_attribute_string('eael_team_text'); ?>><?php echo HelperClass::eael_wp_kses($settings['eael_team_member_description']); ?></p>
<?php
}
?>
</div>
<div class="eael-team-content">
<h2 class="eael-team-member-name"><?php echo HelperClass::eael_wp_kses($settings['eael_team_member_name']); ?></h2>
<h3 class="eael-team-member-position"><?php echo HelperClass::eael_wp_kses($settings['eael_team_member_job_title']); ?></h3>
<?php if( 'eael-team-members-social-bottom' === $settings['eael_team_members_preset'] ) : ?>
<?php do_action( 'eael/team_member_social_botton_markup', $settings, $this ); ?>
<?php else: ?>
<?php if ( ! empty( $settings['eael_team_member_enable_social_profiles'] ) && 'eael-team-members-social-right' !== $settings['eael_team_members_preset'] ): ?>
<ul class="eael-team-member-social-profiles">
<?php foreach ( $settings['eael_team_member_social_profile_links'] as $index => $item ) : ?>
<?php $icon_migrated = isset($item['__fa4_migrated']['social_new']);
$icon_is_new = empty($item['social']); ?>
<?php if ( ! empty( $item['social'] ) || !empty($item['social_new'])) : ?>
<?php $this->add_link_attributes( 'social_link_' . $index, $item['link'] ); ?>
<li class="eael-team-member-social-link">
<a <?php $this->print_render_attribute_string( 'social_link_' . $index ); ?>>
<?php if ($icon_is_new || $icon_migrated) { ?>
<?php if( isset( $item['social_new']['value']['url'] ) ) : ?>
<img src="<?php echo esc_url( $item['social_new']['value']['url'] ); ?>" alt="<?php echo esc_attr(get_post_meta($item['social_new']['value']['id'], '_wp_attachment_image_alt', true)); ?>" />
<?php else :
\Elementor\Icons_Manager::render_icon( $item['social_new'], [ 'aria-hidden' => 'true' ] );
endif; ?>
<?php } else { ?>
<i class="<?php echo esc_attr($item['social'] ); ?>"></i>
<?php } ?>
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<p <?php echo $this->get_render_attribute_string('eael_team_text'); ?>><?php echo HelperClass::eael_wp_kses($settings['eael_team_member_description']); ?></p>
<?php endif; ?>
</div>
</div>
</div>
<?php
}
}

View File

@@ -0,0 +1,924 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Group_Control_Typography;
use \Elementor\Utils;
use \Elementor\Widget_Base;
use Essential_Addons_Elementor\Classes\Helper as HelperClass;
class Testimonial extends Widget_Base {
public function get_name() {
return 'eael-testimonial';
}
public function get_title() {
return esc_html__( 'Testimonial', 'essential-addons-for-elementor-lite');
}
public function get_icon() {
return 'eaicon-testimonial';
}
public function get_categories() {
return [ 'essential-addons-elementor' ];
}
public function get_keywords()
{
return [
'testimonial',
'ea testimonial',
'ea testimonials',
'testimony',
'review',
'endorsement',
'recommendation',
'reference',
'appreciation',
'feedback',
'star rating',
'social proof',
'ea',
'essential addons'
];
}
public function get_custom_help_url()
{
return 'https://essential-addons.com/elementor/docs/testimonials/';
}
public function get_style_depends()
{
return [
'font-awesome-5-all',
'font-awesome-4-shim',
];
}
public function get_script_depends()
{
return [
'font-awesome-4-shim'
];
}
protected function register_controls() {
$this->start_controls_section(
'eael_section_testimonial_image',
[
'label' => esc_html__( 'Testimonial Image', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_testimonial_enable_avatar',
[
'label' => esc_html__( 'Display Avatar?', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
]
);
$this->add_control(
'image',
[
'label' => __( 'Testimonial Avatar', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'eael_testimonial_enable_avatar' => 'yes',
],
'ai' => [
'active' => false,
],
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'image',
'default' => 'thumbnail',
'condition' => [
'image[url]!' => '',
'eael_testimonial_enable_avatar' => 'yes',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_testimonial_content',
[
'label' => esc_html__( 'Testimonial Content', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_testimonial_name',
[
'label' => esc_html__( 'User Name', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'John Doe', 'essential-addons-for-elementor-lite'),
'dynamic' => [ 'active' => true ],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eael_testimonial_company_title',
[
'label' => esc_html__( 'Company Name', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Codetic', 'essential-addons-for-elementor-lite'),
'dynamic' => [ 'active' => true ],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eael_testimonial_description',
[
'label' => esc_html__( 'Testimonial Description', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::WYSIWYG,
'default' => esc_html__( 'Add testimonial description here. Edit and place your own text.', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'content_height',
[
'label' => esc_html__( 'Description Height', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', '%', 'em'],
'range' => [
'px' => [ 'max' => 300 ],
'%' => [ 'max' => 100 ]
],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_testimonial_enable_rating',
[
'label' => esc_html__( 'Display Rating?', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
]
);
$this->add_control(
'eael_testimonial_rating_number',
[
'label' => __( 'Rating Number', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'rating-five',
'options' => [
'rating-one' => __( '1', 'essential-addons-for-elementor-lite'),
'rating-two' => __( '2', 'essential-addons-for-elementor-lite'),
'rating-three' => __( '3', 'essential-addons-for-elementor-lite'),
'rating-four' => __( '4', 'essential-addons-for-elementor-lite'),
'rating-five' => __( '5', 'essential-addons-for-elementor-lite'),
],
'condition' => [
'eael_testimonial_enable_rating' => 'yes',
],
]
);
$this->end_controls_section();
if(!apply_filters('eael/pro_enabled', false)) {
$this->start_controls_section(
'eael_section_pro',
[
'label' => __( 'Go Premium for More Features', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_control_get_pro',
[
'label' => __( 'Unlock more possibilities', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'1' => [
'title' => '',
'icon' => 'fa fa-unlock-alt',
],
],
'default' => '1',
'description' => '<span class="pro-feature"> Get the <a href="https://wpdeveloper.com/upgrade/ea-pro" target="_blank">Pro version</a> for more stunning elements and customization options.</span>'
]
);
$this->end_controls_section();
}
$this->start_controls_section(
'eael_section_testimonial_styles_general',
[
'label' => esc_html__( 'Testimonial Styles', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE
]
);
$this->add_control(
'eael_testimonial_style',
[
'label' => __( 'Select Style', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'default-style',
'options' => [
'default-style' => __( 'Default', 'essential-addons-for-elementor-lite'),
'classic-style' => __( 'Classic', 'essential-addons-for-elementor-lite'),
'middle-style' => __( 'Content | Icon/Image | Bio', 'essential-addons-for-elementor-lite'),
'icon-img-left-content' => __( 'Icon/Image | Content', 'essential-addons-for-elementor-lite'),
'icon-img-right-content' => __( 'Content | Icon/Image', 'essential-addons-for-elementor-lite'),
'content-top-icon-title-inline' => __( 'Content Top | Icon Title Inline', 'essential-addons-for-elementor-lite'),
'content-bottom-icon-title-inline' => __( 'Content Bottom | Icon Title Inline', 'essential-addons-for-elementor-lite')
]
]
);
$this->add_control(
'eael_testimonial_is_gradient_background',
[
'label' => __('Use Gradient Background', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'essential-addons-for-elementor-lite'),
'label_off' => __('Hide', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
]
);
$this->add_control(
'eael_testimonial_background',
[
'label' => esc_html__('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-testimonial-item' => 'background-color: {{VALUE}};',
],
'condition' => [
'eael_testimonial_is_gradient_background' => ''
]
]
);
$this->add_group_control(
\Elementor\Group_Control_Background::get_type(),
[
'name' => 'eael_testimonial_gradient_background',
'label' => __('Gradient Background', 'essential-addons-for-elementor-lite'),
'types' => ['classic', 'gradient'],
'selector' => '{{WRAPPER}} .eael-testimonial-item',
'condition' => [
'eael_testimonial_is_gradient_background' => 'yes'
]
]
);
$this->add_control(
'eael_testimonial_alignment',
[
'label' => esc_html__( 'Layout Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'label_block' => true,
'options' => [
'default' => [
'title' => __( 'Default', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-ban',
],
'left' => [
'title' => esc_html__( 'Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'default',
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content' => 'text-align: {{VALUE}};',
'{{WRAPPER}} .eael-testimonial-image' => 'text-align: {{VALUE}};',
],
]
);
$this->add_control(
'eael_testimonial_user_display_block',
[
'label' => esc_html__( 'Display User & Company Block?', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'return_value' => 'yes',
'default' => '',
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_testimonial_image_styles',
[
'label' => esc_html__( 'Testimonial Image Style', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'eael_testimonial_enable_avatar' => 'yes'
]
]
);
$this->add_responsive_control(
'eael_testimonial_image_width',
[
'label' => esc_html__( 'Image Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 150,
'unit' => 'px',
],
'range' => [
'%' => [
'min' => 0,
'max' => 100,
],
'px' => [
'min' => 0,
'max' => 1000,
],
],
'size_units' => [ '%', 'px' ],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-image figure > img' => 'width:{{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_testimonial_max_image_width',
[
'label' => esc_html__( 'Image Max Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 100,
'unit' => '%',
],
'range' => [
'%' => [
'min' => 0,
'max' => 100,
],
],
'size_units' => [ '%' ],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-image' => 'max-width:{{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_testimonial_image_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-image img' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_testimonial_image_padding',
[
'label' => esc_html__( 'Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-image img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_testimonial_image_border',
'label' => esc_html__( 'Border', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} .eael-testimonial-image img',
]
);
$this->add_control(
'eael_testimonial_image_rounded',
[
'label' => esc_html__( 'Rounded Avatar?', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'return_value' => 'testimonial-avatar-rounded',
'default' => '',
]
);
$this->add_control(
'eael_testimonial_image_border_radius',
[
'label' => esc_html__( 'Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'selectors' => [
'{{WRAPPER}} .eael-testimonial-image img' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
],
'condition' => [
'eael_testimonial_image_rounded!' => 'testimonial-avatar-rounded',
],
]
);
$this->end_controls_section();
// color, Typography & Spacing
$this->start_controls_section(
'eael_section_testimonial_typography',
[
'label' => esc_html__( 'Color, Typography &amp; Spacing', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE
]
);
$this->add_control(
'eael_testimonial_name_heading',
[
'label' => __( 'User Name', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
]
);
$this->add_control(
'eael_testimonial_name_color',
[
'label' => esc_html__( 'User Name Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#272727',
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content .eael-testimonial-user' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_testimonial_name_typography',
'selector' => '{{WRAPPER}} .eael-testimonial-content .eael-testimonial-user',
]
);
$this->add_control(
'eael_testimonial_name_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content .eael-testimonial-user' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_testimonial_company_heading',
[
'label' => __( 'Company Name', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'eael_testimonial_company_color',
[
'label' => esc_html__( 'Company Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#272727',
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content .eael-testimonial-user-company' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_testimonial_position_typography',
'selector' => '{{WRAPPER}} .eael-testimonial-content .eael-testimonial-user-company',
]
);
$this->add_control(
'eael_testimonial_company_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content .eael-testimonial-user-company' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_testimonial_description_heading',
[
'label' => __( 'Testimonial Text', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'eael_testimonial_description_color',
[
'label' => esc_html__( 'Testimonial Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#292929',
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content .eael-testimonial-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_testimonial_description_typography',
'selector' => '{{WRAPPER}} .eael-testimonial-content .eael-testimonial-text',
]
);
$this->add_control(
'eael_testimonial_description_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content .eael-testimonial-text' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_testimonial_rating_heading',
[
'label' => __( 'Rating', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'eael_testimonial_rating_item_color',
[
'label' => esc_html__( 'Rating Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#f2b01e',
'selectors' => [
'{{WRAPPER}} .rating-five .testimonial-star-rating li i' => 'color: {{VALUE}};',
'{{WRAPPER}} .rating-one .testimonial-star-rating li:first-child i' => 'color: {{VALUE}};',
'{{WRAPPER}} .rating-two .testimonial-star-rating li:nth-child(1) i, {{WRAPPER}} .rating-two .testimonial-star-rating li:nth-child(2) i' => 'color: {{VALUE}};',
'{{WRAPPER}} .rating-three .testimonial-star-rating li:nth-child(1) i, {{WRAPPER}} .rating-three .testimonial-star-rating li:nth-child(2) i, {{WRAPPER}} .rating-three .testimonial-star-rating li:nth-child(3) i' => 'color: {{VALUE}};',
'{{WRAPPER}} .rating-four .testimonial-star-rating li:nth-child(1) i, {{WRAPPER}} .rating-four .testimonial-star-rating li:nth-child(2) i, {{WRAPPER}} .rating-four .testimonial-star-rating li:nth-child(3) i, {{WRAPPER}} .rating-four .testimonial-star-rating li:nth-child(4) i' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_testimonial_rating_item_size',
[
'label' => esc_html__( 'Rating Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content .testimonial-star-rating li i' => 'font-size: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_testimonial_rating_item_distance',
[
'label' => esc_html__( 'Distance Between Rating Item', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content .testimonial-star-rating li' => 'margin-right: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_testimonial_rating_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .eael-testimonial-content .testimonial-star-rating' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_testimonial_quotation_typography',
[
'label' => esc_html__( 'Quotation Style', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE
]
);
$this->add_control(
'eael_testimonial_quotation_color',
[
'label' => esc_html__( 'Quotation Mark Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => 'rgba(0,0,0,0.15)',
'selectors' => [
'{{WRAPPER}} .eael-testimonial-quote' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_testimonial_quotation_typography',
'selector' => '{{WRAPPER}} .eael-testimonial-quote',
]
);
$this->add_responsive_control(
'eael_testimonial_quotation_top',
[
'label' => esc_html__( 'Quotation Postion From Top', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 5,
'unit' => '%',
],
'range' => [
'%' => [
'min' => 0,
'max' => 100,
]
],
'size_units' => [ '%' ],
'selectors' => [
'{{WRAPPER}} span.eael-testimonial-quote' => 'top:{{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_testimonial_quotation_right',
[
'label' => esc_html__( 'Quotation Postion From Right', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 5,
'unit' => '%',
],
'range' => [
'%' => [
'min' => 0,
'max' => 100,
]
],
'size_units' => [ '%' ],
'selectors' => [
'{{WRAPPER}} span.eael-testimonial-quote' => 'right:{{SIZE}}{{UNIT}};',
],
]
);
$this->end_controls_section();
}
protected function render_testimonial_image() {
$settings = $this->get_settings();
$image = Group_Control_Image_Size::get_attachment_image_html( $settings );
if( ! empty($image) && ! empty($settings['eael_testimonial_enable_avatar']) ) {
ob_start();
?>
<div class="eael-testimonial-image">
<?php if( 'yes' == $settings['eael_testimonial_enable_avatar'] ) : ?>
<figure><?php echo Group_Control_Image_Size::get_attachment_image_html( $settings ); ?></figure>
<?php endif; ?>
</div>
<?php
echo ob_get_clean();
}
}
protected function render_testimonial_rating() {
$settings = $this->get_settings_for_display('eael_testimonial_enable_rating');
if ( $settings == 'yes' ) :
ob_start();
?>
<ul class="testimonial-star-rating">
<li><i class="fas fa-star" aria-hidden="true"></i></li>
<li><i class="fas fa-star" aria-hidden="true"></i></li>
<li><i class="fas fa-star" aria-hidden="true"></i></li>
<li><i class="fas fa-star" aria-hidden="true"></i></li>
<li><i class="fas fa-star" aria-hidden="true"></i></li>
</ul>
<?php
echo ob_get_clean();
endif;
}
protected function render_user_name_and_company() {
$settings = $this->get_settings_for_display();
if( ! empty($settings['eael_testimonial_name']) ) : ?><p <?php echo $this->get_render_attribute_string('eael_testimonial_user'); ?>><?php echo HelperClass::eael_wp_kses($settings['eael_testimonial_name']); ?></p><?php endif;
if( ! empty($settings['eael_testimonial_company_title']) ) : ?><p class="eael-testimonial-user-company"><?php echo HelperClass::eael_wp_kses($settings['eael_testimonial_company_title']); ?></p><?php endif;
}
protected function testimonial_quote() {
echo '<span class="eael-testimonial-quote"></span>';
}
protected function testimonial_desc() {
$settings = $this->get_settings_for_display();
echo '<div class="eael-testimonial-text">'.wpautop($settings['eael_testimonial_description']).'</div>';
}
protected function render() {
$settings = $this->get_settings_for_display();
$rating = $this->get_settings_for_display('eael_testimonial_enable_rating');
$this->add_render_attribute(
'eael_testimonial_wrap',
[
'id' => 'eael-testimonial-'.esc_attr($this->get_id()),
'class' => [
'eael-testimonial-item',
'clearfix',
$this->get_settings('eael_testimonial_image_rounded'),
esc_attr($settings['eael_testimonial_style']),
]
]
);
if ( $rating == 'yes' )
$this->add_render_attribute('eael_testimonial_wrap', 'class', $this->get_settings('eael_testimonial_rating_number'));
$this->add_render_attribute('eael_testimonial_user', 'class', 'eael-testimonial-user');
if ( ! empty( $settings['eael_testimonial_user_display_block'] ) )
$this->add_render_attribute('eael_testimonial_user', 'style', 'display: block; float: none;');
?>
<div <?php echo $this->get_render_attribute_string('eael_testimonial_wrap'); ?>>
<?php if('classic-style' == $settings['eael_testimonial_style']) { ?>
<div class="eael-testimonial-content">
<?php
// $this->testimonial_quote();
$this->testimonial_desc();
?>
<div class="clearfix">
<?php $this->render_user_name_and_company(); ?>
</div>
<?php $this->render_testimonial_rating( $settings ); ?>
</div>
<?php $this->render_testimonial_image(); ?>
<?php } ?>
<?php if('middle-style' == $settings['eael_testimonial_style']) { ?>
<div class="eael-testimonial-content">
<?php
// $this->testimonial_quote();
$this->testimonial_desc();
?>
<?php $this->render_testimonial_image(); ?>
<div class="clearfix">
<?php $this->render_user_name_and_company(); ?>
</div>
<?php $this->render_testimonial_rating( $settings ); ?>
</div>
<?php } ?>
<?php if('default-style' == $settings['eael_testimonial_style']) { ?>
<?php $this->render_testimonial_image(); ?>
<div class="eael-testimonial-content">
<?php
// $this->testimonial_quote();
$this->testimonial_desc();
$this->render_testimonial_rating( $settings );
$this->render_user_name_and_company();
?>
</div>
<?php } ?>
<?php if('icon-img-left-content' == $settings['eael_testimonial_style']) { ?>
<?php
// $this->testimonial_quote();
$this->render_testimonial_image();
?>
<div class="eael-testimonial-content">
<?php
$this->testimonial_desc();
$this->render_testimonial_rating( $settings );
?>
<div class="bio-text clearfix">
<?php $this->render_user_name_and_company(); ?>
</div>
</div>
<?php } ?>
<?php if('icon-img-right-content' == $settings['eael_testimonial_style']) { ?>
<?php
// $this->testimonial_quote();
$this->render_testimonial_image();
?>
<div class="eael-testimonial-content">
<?php
$this->testimonial_desc();
$this->render_testimonial_rating( $settings );
?>
<div class="bio-text-right"><?php $this->render_user_name_and_company(); ?></div>
</div>
<?php } ?>
<?php if('content-top-icon-title-inline' == $settings['eael_testimonial_style']) { ?>
<div class="eael-testimonial-content eael-testimonial-inline-bio">
<?php $this->render_testimonial_image(); ?>
<div class="bio-text"><?php $this->render_user_name_and_company(); ?></div>
<?php $this->render_testimonial_rating( $settings ); ?>
</div>
<div class="eael-testimonial-content">
<?php $this->testimonial_desc(); ?>
</div>
<?php } ?>
<?php if('content-bottom-icon-title-inline' == $settings['eael_testimonial_style']) { ?>
<div class="eael-testimonial-content">
<?php $this->testimonial_desc(); ?>
</div>
<div class="eael-testimonial-content eael-testimonial-inline-bio">
<?php $this->render_testimonial_image(); ?>
<div class="bio-text"><?php $this->render_user_name_and_company(); ?></div>
<?php $this->render_testimonial_rating( $settings ); ?>
</div>
<?php } ?>
<?php $this->testimonial_quote(); ?>
</div>
<?php }
protected function content_template() {}
}

View File

@@ -0,0 +1,752 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Typography;
use \Elementor\Utils;
use \Elementor\Widget_Base;
use \Elementor\Icons_Manager;
use \Essential_Addons_Elementor\Classes\Helper;
class Tooltip extends Widget_Base {
public function get_name() {
return 'eael-tooltip';
}
public function get_title() {
return esc_html__( 'Tooltip', 'essential-addons-for-elementor-lite');
}
public function get_icon() {
return 'eaicon-tooltip';
}
public function get_categories() {
return [ 'essential-addons-elementor' ];
}
public function get_keywords()
{
return [
'tooltip',
'ea tooltip',
'popover',
'hover',
'hint',
'floating text',
'glossary',
'ea',
'essential addons'
];
}
public function get_custom_help_url()
{
return 'https://essential-addons.com/elementor/docs/tooltip/';
}
protected function register_controls() {
/**
* Tooltip Settings
*/
$this->start_controls_section(
'eael_section_tooltip_settings',
[
'label' => esc_html__( 'Content Settings', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_tooltip_type',
[
'label' => esc_html__( 'Content Type', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'label_block' => true,
'options' => [
'icon' => [
'title' => esc_html__( 'Icon', 'essential-addons-for-elementor-lite'),
'icon' => 'fa fa-info',
],
'text' => [
'title' => esc_html__( 'Text', 'essential-addons-for-elementor-lite'),
'icon' => 'fa fa-text-width',
],
'image' => [
'title' => esc_html__( 'Image', 'essential-addons-for-elementor-lite'),
'icon' => 'fa fa-image',
],
'shortcode' => [
'title' => esc_html__( 'Shortcode', 'essential-addons-for-elementor-lite'),
'icon' => 'fa fa-code',
],
],
'default' => 'icon',
]
);
$this->add_control(
'eael_tooltip_icon_content_new',
[
'label' => esc_html__( 'Icon', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'eael_tooltip_icon_content',
'default' => [
'value' => 'fas fa-home',
'library' => 'fa-solid',
],
'condition' => [
'eael_tooltip_type' => [ 'icon' ]
]
]
);
$this->add_responsive_control(
'eael_tooltip_icon_size',
[
'label' => esc_html__( 'Icon Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => [ '%', 'px' ],
'default' => [
'size' => 60,
],
'range' => [
'px' => [
'max' => 150,
],
'%' => [
'max' => 100
]
],
'selectors' => [
'{{WRAPPER}} .eael-tooltip .eael-tooltip-content i' => 'font-size: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .eael-tooltip .eael-tooltip-content svg' => 'height: {{SIZE}}{{UNIT}};width: {{SIZE}}{{UNIT}};line-height: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .eael-tooltip .eael-tooltip-content .ea-tooltip-svg-trigger' => 'height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};',
],
'condition' => [
'eael_tooltip_type' => 'icon'
]
]
);
$this->add_control(
'eael_tooltip_content',
[
'label' => esc_html__( 'Content', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::WYSIWYG,
'label_block' => true,
'default' => esc_html__( 'Hover Me!', 'essential-addons-for-elementor-lite'),
'condition' => [
'eael_tooltip_type' => [ 'text' ]
],
'dynamic' => [ 'active' => true ]
]
);
$this->add_control(
'eael_tooltip_content_tag',
[
'label' => esc_html__( 'Content Tag', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'span',
'label_block' => false,
'options' => [
'h1' => esc_html__( 'H1', 'essential-addons-for-elementor-lite'),
'h2' => esc_html__( 'H2', 'essential-addons-for-elementor-lite'),
'h3' => esc_html__( 'H3', 'essential-addons-for-elementor-lite'),
'h4' => esc_html__( 'H4', 'essential-addons-for-elementor-lite'),
'h5' => esc_html__( 'H5', 'essential-addons-for-elementor-lite'),
'h6' => esc_html__( 'H6', 'essential-addons-for-elementor-lite'),
'div' => esc_html__( 'DIV', 'essential-addons-for-elementor-lite'),
'span' => esc_html__( 'SPAN', 'essential-addons-for-elementor-lite'),
'p' => esc_html__( 'P', 'essential-addons-for-elementor-lite'),
],
'condition' => [
'eael_tooltip_type' => 'text'
]
]
);
$this->add_control(
'eael_tooltip_img_content',
[
'label' => esc_html__( 'Image', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'eael_tooltip_type' => [ 'image' ]
],
'ai' => [
'active' => false,
],
]
);
$this->add_control(
'eael_tooltip_shortcode_content',
[
'label' => esc_html__( 'Shortcode', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
'default' => esc_html__( '[shortcode-here]', 'essential-addons-for-elementor-lite'),
'condition' => [
'eael_tooltip_type' => [ 'shortcode' ]
]
]
);
$this->add_responsive_control(
'eael_tooltip_content_alignment',
[
'label' => esc_html__( 'Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'label_block' => true,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-right',
],
'justify' => [
'title' => __( 'Justified', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-justify',
],
],
'default' => 'left',
'prefix_class' => 'eael-tooltip-align%s-',
]
);
$this->add_control(
'eael_tooltip_enable_link',
[
'label' => esc_html__( 'Enable Link', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'false',
'return_value' => 'yes',
'condition' => [
'eael_tooltip_type!' => ['shortcode']
]
]
);
$this->add_control(
'eael_tooltip_link',
[
'label' => esc_html__( 'Button Link', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::URL,
'dynamic' => ['active' => true],
'label_block' => true,
'default' => [
'url' => '#',
'is_external' => '',
],
'show_external' => true,
'condition' => [
'eael_tooltip_enable_link' => 'yes'
]
]
);
$this->end_controls_section();
/**
* Tooltip Hover Content Settings
*/
$this->start_controls_section(
'eael_section_tooltip_hover_content_settings',
[
'label' => esc_html__( 'Tooltip Settings', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_tooltip_hover_content',
[
'label' => esc_html__( 'Content', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::WYSIWYG,
'label_block' => true,
'default' => esc_html__( 'Tooltip content', 'essential-addons-for-elementor-lite'),
'dynamic' => [ 'active' => true ]
]
);
$this->add_control(
'eael_tooltip_hover_dir',
[
'label' => esc_html__( 'Hover Direction', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'right',
'label_block' => false,
'options' => [
'left' => esc_html__( 'Left', 'essential-addons-for-elementor-lite'),
'right' => esc_html__( 'Right', 'essential-addons-for-elementor-lite'),
'top' => esc_html__( 'Top', 'essential-addons-for-elementor-lite'),
'bottom' => esc_html__( 'Bottom', 'essential-addons-for-elementor-lite'),
],
]
);
$this->add_control(
'eael_tooltip_hover_speed',
[
'label' => esc_html__( 'Hover Speed', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::TEXT,
'label_block' => false,
'default' => esc_html__( '300', 'essential-addons-for-elementor-lite'),
'selectors' => [
'{{WRAPPER}} .eael-tooltip:hover .eael-tooltip-text.eael-tooltip-top' => 'animation-duration: {{SIZE}}ms;',
'{{WRAPPER}} .eael-tooltip:hover .eael-tooltip-text.eael-tooltip-left' => 'animation-duration: {{SIZE}}ms;',
'{{WRAPPER}} .eael-tooltip:hover .eael-tooltip-text.eael-tooltip-bottom' => 'animation-duration: {{SIZE}}ms;',
'{{WRAPPER}} .eael-tooltip:hover .eael-tooltip-text.eael-tooltip-right' => 'animation-duration: {{SIZE}}ms;',
],
'ai' => [
'active' => false,
],
]
);
$this->end_controls_section();
/**
* -------------------------------------------
* Tab Style Tooltip Content
* -------------------------------------------
*/
$this->start_controls_section(
'eael_section_tooltip_style_settings',
[
'label' => esc_html__( 'Content Style', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'eael_tooltip_max_width',
[
'label' => __( 'Content Max Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'size_units' => [ 'px', '%' ],
'default' => [
'unit' => 'px',
'size' => 100,
],
'selectors' => [
'{{WRAPPER}} .eael-tooltip' => 'width: {{SIZE}}{{UNIT}};',
]
]
);
$this->add_responsive_control(
'eael_tooltip_content_padding',
[
'label' => esc_html__( 'Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-tooltip' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_tooltip_content_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-tooltip' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_tooltip_text_alignment',
[
'label' => esc_html__( 'Content Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'label_block' => true,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-right',
],
'justify' => [
'title' => __( 'Justified', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-justify',
],
],
'condition' => [
'eael_tooltip_type' => 'text'
],
'default' => 'left',
'prefix_class' => 'eael-tooltip-text-align-',
]
);
$this->start_controls_tabs( 'eael_tooltip_content_style_tabs' );
// Normal State Tab
$this->start_controls_tab( 'eael_tooltip_content_normal', [ 'label' => esc_html__( 'Normal', 'essential-addons-for-elementor-lite') ] );
$this->add_control(
'eael_tooltip_content_bg_color',
[
'label' => esc_html__( 'Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-tooltip' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_tooltip_content_color',
[
'label' => esc_html__( 'Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-tooltip' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-tooltip a' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-tooltip svg' => 'fill: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'eael_tooltip_shadow',
'selector' => '{{WRAPPER}} .eael-tooltip',
'separator' => 'before'
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_tooltip_border',
'label' => esc_html__( 'Border', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} .eael-tooltip',
]
);
$this->end_controls_tab();
// Hover State Tab
$this->start_controls_tab( 'eael_tooltip_content_hover', [ 'label' => esc_html__( 'Hover', 'essential-addons-for-elementor-lite') ] );
$this->add_control(
'eael_tooltip_content_hover_bg_color',
[
'label' => esc_html__( 'Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .eael-tooltip:hover' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_tooltip_content_hover_color',
[
'label' => esc_html__( 'Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#212121',
'selectors' => [
'{{WRAPPER}} .eael-tooltip:hover' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-tooltip:hover a' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-tooltip:hover svg' => 'fill: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'eael_tooltip_hover_shadow',
'selector' => '{{WRAPPER}} .eael-tooltip:hover',
'separator' => 'before'
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_tooltip_hover_border',
'label' => esc_html__( 'Border', 'essential-addons-for-elementor-lite'),
'selector' => '{{WRAPPER}} .eael-tooltip:hover',
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_tooltip_content_typography',
'selector' => '{{WRAPPER}} .eael-tooltip',
]
);
$this->add_responsive_control(
'eael_tooltip_content_radius',
[
'label' => esc_html__( 'Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-tooltip' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
if(!apply_filters('eael/pro_enabled', false)) {
$this->start_controls_section(
'eael_section_pro',
[
'label' => __( 'Go Premium for More Features', 'essential-addons-for-elementor-lite')
]
);
$this->add_control(
'eael_control_get_pro',
[
'label' => __( 'Unlock more possibilities', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'1' => [
'title' => '',
'icon' => 'fa fa-unlock-alt',
],
],
'default' => '1',
'description' => '<span class="pro-feature"> Get the <a href="https://wpdeveloper.com/upgrade/ea-pro" target="_blank">Pro version</a> for more stunning elements and customization options.</span>'
]
);
$this->end_controls_section();
}
/**
* -------------------------------------------
* Tab Style Tooltip Hover Content
* -------------------------------------------
*/
$this->start_controls_section(
'eael_section_tooltip_hover_style_settings',
[
'label' => esc_html__( 'Tooltip Style', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'eael_tooltip_hover_width',
[
'label' => __( 'Tooltip Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => '150'
],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 5,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text' => 'width: {{SIZE}}{{UNIT}};',
]
]
);
$this->add_responsive_control(
'eael_tooltip_hover_max_width',
[
'label' => __( 'Tooltip Max Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => '150'
],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 5,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text' => 'max-width: {{SIZE}}{{UNIT}};',
]
]
);
$this->add_responsive_control(
'eael_tooltip_hover_content_padding',
[
'label' => esc_html__( 'Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_tooltip_hover_content_margin',
[
'label' => esc_html__( 'Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_tooltip_hover_content_bg_color',
[
'label' => esc_html__( 'Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#555',
'selectors' => [
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_tooltip_hover_content_color',
[
'label' => esc_html__( 'Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#fff',
'selectors' => [
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_tooltip_hover_content_typography',
'selector' => '{{WRAPPER}} .eael-tooltip .eael-tooltip-text',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'eael_tooltip_box_shadow',
'selector' => '{{WRAPPER}} .eael-tooltip .eael-tooltip-text',
]
);
$this->add_responsive_control(
'eael_tooltip_arrow_size',
[
'label' => __( 'Arrow Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 5,
'unit' => 'px',
],
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text:after' => 'border-width: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text.eael-tooltip-left::after' => 'top: calc( 50% - {{SIZE}}{{UNIT}} );',
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text.eael-tooltip-right::after' => 'top: calc( 50% - {{SIZE}}{{UNIT}} );',
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text.eael-tooltip-top::after' => 'left: calc( 50% - {{SIZE}}{{UNIT}} );',
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text.eael-tooltip-bottom::after' => 'left: calc( 50% - {{SIZE}}{{UNIT}} );',
],
]
);
$this->add_control(
'eael_tooltip_arrow_color',
[
'label' => esc_html__( 'Arrow Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#555',
'selectors' => [
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text.eael-tooltip-top:after' => 'border-top-color: {{VALUE}};',
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text.eael-tooltip-bottom:after' => 'border-bottom-color: {{VALUE}};',
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text.eael-tooltip-left:after' => 'border-left-color: {{VALUE}};',
'{{WRAPPER}} .eael-tooltip .eael-tooltip-text.eael-tooltip-right:after' => 'border-right-color: {{VALUE}};',
],
]
);
$this->end_controls_section();
}
protected function render( ) {
$settings = $this->get_settings_for_display();
$icon_migrated = isset($settings['__fa4_migrated']['eael_tooltip_icon_content_new']);
$icon_is_new = empty($settings['eael_tooltip_icon_content']);
$this->add_link_attributes( 'eael_tooltip_link', (array) $settings['eael_tooltip_link'] );
?>
<div class="eael-tooltip">
<?php if( $settings['eael_tooltip_type'] === 'text' ) : ?>
<<?php echo esc_attr( Helper::eael_validate_html_tag($settings['eael_tooltip_content_tag']) ); ?> class="eael-tooltip-content" tabindex="0" aria-describedby="tooltip-text-<?php echo esc_attr( $this->get_id() ); ?>"><?php if( $settings['eael_tooltip_enable_link'] === 'yes' ) : ?><a <?php $this->print_render_attribute_string( 'eael_tooltip_link' ); ?>><?php endif; ?><?php echo wp_kses_post($settings['eael_tooltip_content']); ?><?php if( $settings['eael_tooltip_enable_link'] === 'yes' ) : ?></a><?php endif; ?></<?php echo esc_attr( Helper::eael_validate_html_tag($settings['eael_tooltip_content_tag']) ); ?>>
<span id="tooltip-text-<?php echo esc_attr( $this->get_id() ); ?>" class="eael-tooltip-text eael-tooltip-<?php echo esc_attr( $settings['eael_tooltip_hover_dir'] ) ?>" role="tooltip"><?php echo __( $settings['eael_tooltip_hover_content'] ); ?></span>
<?php elseif( $settings['eael_tooltip_type'] === 'icon' ) : ?>
<span class="eael-tooltip-content" tabindex="0" aria-describedby="tooltip-text-<?php echo esc_attr( $this->get_id() ); ?>"><?php if( $settings['eael_tooltip_enable_link'] === 'yes' ) : ?><a <?php $this->print_render_attribute_string( 'eael_tooltip_link' ); ?>><?php endif; ?>
<?php if ($icon_is_new || $icon_migrated) { ?>
<?php if( isset($settings['eael_tooltip_icon_content_new']['value']['url']) ) : ?>
<img class="ea-tooltip-svg-trigger" src="<?php echo esc_url( $settings['eael_tooltip_icon_content_new']['value']['url'] ); ?>" alt="<?php echo esc_attr(get_post_meta($settings['eael_tooltip_icon_content_new']['value']['id'], '_wp_attachment_image_alt', true)); ?>" />
<?php else :
Icons_Manager::render_icon( $settings['eael_tooltip_icon_content_new'], [ 'aria-hidden' => 'true' ] );
endif;
} else {
Icons_Manager::render_icon( $settings['eael_tooltip_icon_content'], [ 'aria-hidden' => 'true' ] );
} ?>
<?php if( $settings['eael_tooltip_enable_link'] === 'yes' ) : ?></a><?php endif; ?></span>
<span id="tooltip-text-<?php echo esc_attr( $this->get_id() ); ?>" class="eael-tooltip-text eael-tooltip-<?php echo esc_attr( $settings['eael_tooltip_hover_dir'] ) ?>" role="tooltip"><?php echo __( $settings['eael_tooltip_hover_content'] ); ?></span>
<?php elseif( $settings['eael_tooltip_type'] === 'image' ) : ?>
<span class="eael-tooltip-content" tabindex="0" aria-describedby="tooltip-text-<?php echo esc_attr( $this->get_id() ); ?>"><?php if( $settings['eael_tooltip_enable_link'] === 'yes' ) : ?><a <?php $this->print_render_attribute_string( 'eael_tooltip_link' ); ?>><?php endif; ?><img src="<?php echo esc_url( $settings['eael_tooltip_img_content']['url'] ); ?>" alt="<?php echo esc_attr( get_post_meta($settings['eael_tooltip_img_content']['id'], '_wp_attachment_image_alt', true) ); ?>"><?php if( $settings['eael_tooltip_enable_link'] === 'yes' ) : ?></a><?php endif; ?></span>
<span id="tooltip-text-<?php echo esc_attr( $this->get_id() ); ?>" class="eael-tooltip-text eael-tooltip-<?php echo esc_attr( $settings['eael_tooltip_hover_dir'] ) ?>" role="tooltip"><?php echo __( $settings['eael_tooltip_hover_content'] ); ?></span>
<?php elseif( $settings['eael_tooltip_type'] === 'shortcode' ) : ?>
<div class="eael-tooltip-content" tabindex="0" aria-describedby="tooltip-text-<?php echo esc_attr( $this->get_id() ); ?>"><?php echo do_shortcode( $settings['eael_tooltip_shortcode_content'] ); ?></div>
<span id="tooltip-text-<?php echo esc_attr( $this->get_id() ); ?>" class="eael-tooltip-text eael-tooltip-<?php echo esc_attr( $settings['eael_tooltip_hover_dir'] ) ?>" role="tooltip"><?php echo __( $settings['eael_tooltip_hover_content'] ); ?></span>
<?php endif; ?>
</div>
<?php
}
protected function content_template() {}
}

View File

@@ -0,0 +1,372 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Widget_Base;
class TypeForm extends Widget_Base {
private $form_list = [];
public function get_name () {
return 'eael-typeform';
}
public function get_title () {
return __('Typeform', 'essential-addons-for-elementor-lite');
}
public function get_categories () {
return ['essential-addons-elementor'];
}
public function get_icon () {
return 'eaicon-typeform';
}
public function get_keywords () {
return [
'ea contact form',
'ea typeform',
'ea type form',
'ea type forms',
'contact form',
'form styler',
'elementor form',
'feedback',
'typeform',
'ea',
'essential addons'
];
}
public function get_custom_help_url () {
return 'https://essential-addons.com/elementor/docs/typeform/';
}
private function get_personal_token () {
return get_option('eael_save_typeform_personal_token');
}
public function get_form_list () {
$token = $this->get_personal_token();
$key = 'eael_typeform_'.md5(implode('', ['eael_type_form_data', $token]));
$form_arr = get_transient($key);
if (empty($form_arr)) {
$response = wp_remote_get(
'https://api.typeform.com/forms?page_size=200',
[
'headers' => [
'Authorization' => "Bearer $token",
]
]
);
if (is_wp_error($response)) {
return $this->form_list;
}
if (isset($response['response']['code']) && $response['response']['code'] == 200) {
$data = json_decode(wp_remote_retrieve_body($response));
if (isset($data->items)) {
$form_arr = $data->items;
set_transient($key, $form_arr, 1 * HOUR_IN_SECONDS);
}
}
}
$this->form_list[''] = __('Select Form', 'essential-addons-for-elementor-lite');
if (!empty($form_arr)) {
foreach ($form_arr as $item) {
$this->form_list[$item->_links->display] = $item->title;
}
}
return $this->form_list;
}
private function no_token_set () {
$this->start_controls_section(
'eael_global_warning',
[
'label' => __('Warning!', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_global_warning_text',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('Whoops! It seems like you haven\'t connected your Typeform account. To do this, navigate to <b>WordPress Dashboard -> Essential Addons -> Elements -> Typeform</b> (<a target="_blank" href="'.esc_url(admin_url( 'admin.php?page=eael-settings')).'">Get Access</a>).',
'essential-addons-for-elementor-lite'),
'content_classes' => 'eael-warning',
]
);
$this->end_controls_section();
}
protected function register_controls () {
if ($this->get_personal_token() == '') {
$this->no_token_set();
return;
}
$this->start_controls_section(
'section_info_box',
[
'label' => __('Typeform', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_typeform_list',
[
'label' => __('Typeform', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => '',
'label_block' => true,
'options' => $this->get_form_list()
]
);
$this->add_control(
'eael_typeform_hideheaders',
[
'label' => __('Hide Header', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'return_value' => 'yes',
]
);
$this->add_control(
'eael_typeform_hidefooter',
[
'label' => __('Hide Footer', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'return_value' => 'yes',
]
);
$this->end_controls_section();
/*-----------------------------------------------------------------------------------*/
/* Style Tab
/*-----------------------------------------------------------------------------------*/
/**
* Style Tab: Form Container
* -------------------------------------------------
*/
$this->start_controls_section(
'section_container_style',
[
'label' => __('Form Container', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_typeform_background',
[
'label' => esc_html__('Form Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-typeform' => 'background: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'eael_typeform_alignment',
[
'label' => esc_html__('Form Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'label_block' => true,
'options' => [
'default' => [
'title' => __('Default', 'essential-addons-for-elementor-lite'),
'icon' => 'fa fa-ban',
],
'left' => [
'title' => esc_html__('Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => esc_html__('Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-h-align-center',
],
'right' => [
'title' => esc_html__('Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-h-align-right',
],
],
'default' => 'default',
]
);
$this->add_responsive_control(
'eael_typeform_max_width',
[
'label' => esc_html__('Form Max Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'em', '%'],
'range' => [
'px' => [
'min' => 10,
'max' => 1500,
],
'em' => [
'min' => 1,
'max' => 80,
],
],
'selectors' => [
'{{WRAPPER}} .eael-typeform' => 'width: {{SIZE}}{{UNIT}};'
],
]
);
$this->add_responsive_control(
'eael_typeform_max_height',
[
'label' => esc_html__('Form Height', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'em', '%'],
'range' => [
'px' => [
'min' => 10,
'max' => 1500,
],
'em' => [
'min' => 1,
'max' => 80,
],
],
'default' => [
'size' => '700',
'unit' => 'px',
],
'selectors' => [
'{{WRAPPER}} .eael-typeform' => 'height: {{SIZE}}{{UNIT}};'
],
]
);
$this->add_control(
'eael_typeform_opacity',
[
'label' => __('Opacity', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 100
]
],
'default' => [
'unit' => 'px',
'size' => 50,
],
]
);
$this->add_responsive_control(
'eael_typeform_margin',
[
'label' => esc_html__('Form Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-typeform' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_typeform_padding',
[
'label' => esc_html__('Form Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-typeform' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_type_border_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'separator' => 'before',
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .eael-typeform' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_type_border',
'selector' => '{{WRAPPER}} .eael-typeform',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'eael_typeform_box_shadow',
'selector' => '{{WRAPPER}} .eael-typeform',
]
);
$this->end_controls_section();
}
protected function render () {
$settings = $this->get_settings_for_display();
if ($this->get_settings('eael_typeform_list') == '') {
return;
}
$id = 'eael-type-form-'.$this->get_id();
$this->add_render_attribute(
'eael_typeform_wrapper',
[
'id' => $id,
'class' => [
'eael-typeform',
'clearfix',
'fs_wp_sidebar',
'fsBody',
'eael-contact-form'
]
]
);
$alignment = $settings['eael_typeform_alignment'];
$this->add_render_attribute('eael_typeform_wrapper', 'class', 'eael-typeform-align-'.$alignment);
$data = [
'url' => esc_url($settings['eael_typeform_list']),
'hideFooter' => ($this->get_settings('eael_typeform_hidefooter') == 'yes'),
'hideHeaders' => ($this->get_settings('eael_typeform_hideheaders') == 'yes'),
'opacity' => $this->get_settings('eael_typeform_opacity')['size']
];
echo '<div data-typeform="'.htmlspecialchars(json_encode($data), ENT_QUOTES,
'UTF-8').'" '.$this->get_render_attribute_string('eael_typeform_wrapper').'></div>';
}
}

View File

@@ -0,0 +1,803 @@
<?php
namespace Essential_Addons_Elementor\Elements;
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Typography;
use \Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use \Elementor\Widget_Base;
use \Essential_Addons_Elementor\Classes\Helper;
class WeForms extends Widget_Base
{
public function get_name()
{
return 'eael-weform';
}
public function get_title()
{
return esc_html__('weForm', 'essential-addons-for-elementor-lite');
}
public function get_icon()
{
return 'eaicon-weforms';
}
public function get_categories()
{
return ['essential-addons-elementor'];
}
public function get_keywords()
{
return [
'contact form',
'ea contact form',
'ea we form',
'ea weform',
'ea weforms',
'form styler',
'ea form styler',
'elementor form',
'feedback',
'ea',
'essential addons'
];
}
public function get_custom_help_url()
{
return 'https://essential-addons.com/elementor/docs/weforms/';
}
protected function register_controls()
{
if (!function_exists('WeForms')) {
$this->start_controls_section(
'eael_global_warning',
[
'label' => __('Warning!', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_global_warning_text',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('<strong>WeForms</strong> is not installed/activated on your site. Please install and activate <strong>WeForms</strong> first.', 'essential-addons-for-elementor-lite'),
'content_classes' => 'eael-warning',
]
);
$this->end_controls_section();
} else {
$this->start_controls_section(
'eael_section_weform',
[
'label' => esc_html__('Select Form', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'wpuf_contact_form',
[
'label' => esc_html__('Select weForm', 'essential-addons-for-elementor-lite'),
'description' => esc_html__('Please save and refresh the page after selecting the form', 'essential-addons-for-elementor-lite'),
'label_block' => true,
'type' => Controls_Manager::SELECT,
'options' => Helper::get_weform_list(),
'default' => '0',
]
);
$this->end_controls_section();
if (!apply_filters('eael/pro_enabled', false)) {
$this->start_controls_section(
'eael_section_pro',
[
'label' => __('Go Premium for More Features', 'essential-addons-for-elementor-lite'),
]
);
$this->add_control(
'eael_control_get_pro',
[
'label' => __('Unlock more possibilities', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'1' => [
'title' => '',
'icon' => 'fa fa-unlock-alt',
],
],
'default' => '1',
'description' => '<span class="pro-feature"> Get the <a href="https://wpdeveloper.com/upgrade/ea-pro" target="_blank">Pro version</a> for more stunning elements and customization options.</span>',
]
);
$this->end_controls_section();
}
}
$this->start_controls_section(
'eael_section_weform_styles',
[
'label' => esc_html__('Form Container Styles', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_weform_background',
[
'label' => esc_html__('Form Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container' => 'background-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'eael_weform_alignment',
[
'label' => esc_html__('Form Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'label_block' => true,
'options' => [
'default' => [
'title' => __('Default', 'essential-addons-for-elementor-lite'),
'icon' => 'fa fa-ban',
],
'left' => [
'title' => esc_html__('Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__('Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__('Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'default',
'prefix_class' => 'eael-contact-form-align-',
]
);
$this->add_responsive_control(
'eael_weform_width',
[
'label' => esc_html__('Form Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'em', '%'],
'range' => [
'px' => [
'min' => 10,
'max' => 1500,
],
'em' => [
'min' => 1,
'max' => 80,
],
],
'selectors' => [
'{{WRAPPER}} .eael-weform-container' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_weform_max_width',
[
'label' => esc_html__('Form Max Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'em', '%'],
'range' => [
'px' => [
'min' => 10,
'max' => 1500,
],
'em' => [
'min' => 1,
'max' => 80,
],
],
'selectors' => [
'{{WRAPPER}} .eael-weform-container' => 'max-width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_weform_margin',
[
'label' => esc_html__('Form Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-weform-container' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_weform_padding',
[
'label' => esc_html__('Form Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-weform-container' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_weform_border_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'separator' => 'before',
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .eael-weform-container' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_weform_border',
'selector' => '{{WRAPPER}} .eael-weform-container',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'eael_weform_box_shadow',
'selector' => '{{WRAPPER}} .eael-weform-container',
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_weform_field_styles',
[
'label' => esc_html__('Form Fields Styles', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_weform_input_background',
[
'label' => esc_html__('Input Field Background', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea' => 'background-color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'eael_weform_input_width',
[
'label' => esc_html__('Input Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'em', '%'],
'range' => [
'px' => [
'min' => 10,
'max' => 1500,
],
'em' => [
'min' => 1,
'max' => 80,
],
],
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"]' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_weform_textarea_width',
[
'label' => esc_html__('Textarea Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'em', '%'],
'range' => [
'px' => [
'min' => 10,
'max' => 1500,
],
'em' => [
'min' => 1,
'max' => 80,
],
],
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_weform_input_padding',
[
'label' => esc_html__('Fields Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_weform_input_margin',
[
'label' => esc_html__('Fields Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'eael_weform_input_border_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'separator' => 'before',
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_weform_input_border',
'selector' => '{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'eael_weform_input_box_shadow',
'selector' => '{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea',
]
);
$this->add_control(
'eael_weform_focus_heading',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__('Focus State Style', 'essential-addons-for-elementor-lite'),
'separator' => 'before',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'eael_weform_input_focus_box_shadow',
'selector' => '{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea:focus',
]
);
$this->add_control(
'eael_weform_input_focus_border',
[
'label' => esc_html__('Border Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"]:focus,
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea:focus' => 'border-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_weform_label_style_heading',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__('Label Style', 'essential-addons-for-elementor-lite'),
'separator' => 'before',
]
);
$this->add_control(
'eael_weform_label_margin',
[
'label' => __('Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%', 'em'],
'selectors' => [
'{{WRAPPER}} .eael-weform-container .wpuf-label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_weform_typography',
[
'label' => esc_html__('Color & Typography', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'eael_weform_label_color',
[
'label' => esc_html__('Label Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container, {{WRAPPER}} .eael-weform-container .wpuf-label label' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_weform_field_color',
[
'label' => esc_html__('Field Font Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_weform_placeholder_color',
[
'label' => esc_html__('Placeholder Font Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container ::-webkit-input-placeholder' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-weform-container ::-moz-placeholder' => 'color: {{VALUE}};',
'{{WRAPPER}} .eael-weform-container ::-ms-input-placeholder' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_weform_label_heading',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__('Label Typography', 'essential-addons-for-elementor-lite'),
'separator' => 'before',
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_weform_label_typography',
'selector' => '{{WRAPPER}} .eael-weform-container, {{WRAPPER}} .eael-weform-container .wpuf-label label',
]
);
$this->add_control(
'eael_weform_heading_input_field',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__('Input Fields Typography', 'essential-addons-for-elementor-lite'),
'separator' => 'before',
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_weform_input_field_typography',
'selector' => '{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="text"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="password"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="email"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="url"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields input[type="number"],
{{WRAPPER}} .eael-weform-container ul.wpuf-form li .wpuf-fields textarea',
]
);
$this->end_controls_section();
$this->start_controls_section(
'eael_section_weform_submit_button_styles',
[
'label' => esc_html__('Submit Button Styles', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'eael_weform_submit_btn_width',
[
'label' => esc_html__('Button Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'em', '%'],
'range' => [
'px' => [
'min' => 10,
'max' => 1500,
],
'em' => [
'min' => 1,
'max' => 80,
],
],
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_weform_submit_btn_alignment',
[
'label' => esc_html__('Button Alignment', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::CHOOSE,
'label_block' => true,
'options' => [
'default' => [
'title' => __('Default', 'essential-addons-for-elementor-lite'),
'icon' => 'fa fa-ban',
],
'left' => [
'title' => esc_html__('Left', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__('Center', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__('Right', 'essential-addons-for-elementor-lite'),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'default',
'prefix_class' => 'eael-contact-form-btn-align-',
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'eael_weform_submit_btn_typography',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_PRIMARY
],
'selector' => '{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]',
]
);
$this->add_responsive_control(
'eael_weform_submit_btn_margin',
[
'label' => esc_html__('Margin', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'eael_weform_submit_btn_padding',
[
'label' => esc_html__('Padding', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->start_controls_tabs('eael_weform_submit_button_tabs');
$this->start_controls_tab('normal', ['label' => esc_html__('Normal', 'essential-addons-for-elementor-lite')]);
$this->add_control(
'eael_weform_submit_btn_text_color',
[
'label' => esc_html__('Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_weform_submit_btn_background_color',
[
'label' => esc_html__('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]' => 'background-color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'eael_weform_submit_btn_border',
'selector' => '{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]',
]
);
$this->add_control(
'eael_weform_submit_btn_border_radius',
[
'label' => esc_html__('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]' => 'border-radius: {{SIZE}}px;',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab('eael_weform_submit_btn_hover', ['label' => esc_html__('Hover', 'essential-addons-for-elementor-lite')]);
$this->add_control(
'eael_weform_submit_btn_hover_text_color',
[
'label' => esc_html__('Text Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_weform_submit_btn_hover_background_color',
[
'label' => esc_html__('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]:hover' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'eael_weform_submit_btn_hover_border_color',
[
'label' => esc_html__('Border Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]:hover' => 'border-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'eael_weform_submit_btn_box_shadow',
'selector' => '{{WRAPPER}} .eael-weform-container ul.wpuf-form .wpuf-submit input[type="submit"]',
]
);
$this->end_controls_section();
}
protected function render()
{
if (!function_exists('WeForms')) {
return;
}
$settings = $this->get_settings_for_display();
if (!empty($settings['wpuf_contact_form'])) {
echo '<div class="eael-weform-container">
' . do_shortcode('[weforms id="' . esc_attr( $settings['wpuf_contact_form'] ) . '" ]') . '
</div>';
}
}
}

View File

@@ -0,0 +1,111 @@
<?php
namespace Essential_Addons_Elementor\Elements;
use Elementor\Controls_Manager;
use Elementor\Widget_Base;
use Essential_Addons_Elementor\Traits\Woo_Product_Comparable;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
/**
* Class Woo_Product_Compare
* @package namespace Essential_Addons_Elementor\Pro\Elements;
*/
class Woo_Product_Compare extends Widget_Base {
use Woo_Product_Comparable;
protected $products_list = [];
protected $remove_action = 'eael-wcpc-remove-product';
/**
* @inheritDoc
*/
public function get_name() {
return 'eael-woo-product-compare';
}
/**
* @inheritDoc
*/
public function get_title() {
return esc_html__( 'Woo Product Compare', 'essential-addons-for-elementor-lite' );
}
/**
* @inheritDoc
*/
public function get_icon() {
return 'eaicon-product-compare';
}
/**
* @inheritDoc
*/
public function get_keywords() {
return [
'woocommerce product compare',
'woocommerce product comparison',
'product compare',
'product comparison',
'products compare',
'products comparison',
'wc',
'woocommerce',
'products',
'compare',
'comparison',
'ea',
'essential addons',
];
}
public function get_custom_help_url() {
return 'https://essential-addons.com/elementor/docs/woo-product-compare/';
}
/**
* @inheritDoc
*/
public function get_categories() {
return [ 'essential-addons-elementor', 'woocommerce-elements' ];
}
/**
* @inheritDoc
*/
protected function register_controls() {
$this->init_content_wc_notice_controls();
if ( ! function_exists( 'WC' ) ) {
return;
}
/*----Content Tab----*/
do_action( 'eael/wcpc/before-content-controls', $this );
$this->init_content_product_compare_controls();
$this->init_content_table_settings_controls();
do_action( 'eael/wcpc/after-content-controls', $this );
/*----Style Tab----*/
do_action( 'eael/wcpc/before-style-controls', $this );
$this->init_style_content_controls();
$this->init_style_table_controls();
do_action( 'eael/wcpc/after-style-controls', $this );
}
protected function render() {
if ( ! function_exists( 'WC' ) ) {
return;
}
$ds = $this->get_settings_for_display();
$product_ids = $this->get_settings_for_display( 'product_ids' );
$products = $this->get_products_list( $product_ids );
$fields = $this->fields();
$this->render_compare_table( compact( 'products', 'fields', 'ds' ) );
}
}

View File

@@ -0,0 +1 @@
<?php // Silence is golden

View File

@@ -0,0 +1,64 @@
<?php
namespace Essential_Addons_Elementor\Extensions;
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
class Custom_JS
{
public function __construct()
{
add_action('elementor/documents/register_controls', [$this, 'section_custom_js'], 20);
}
public function section_custom_js($controls)
{
$controls->start_controls_section(
'eael_ext_section_custom_js',
[
'label' => sprintf('<i class="eaicon-logo"></i> %s', __('Custom JS', 'essential-addons-for-elementor-lite')),
'tab' => Controls_Manager::TAB_ADVANCED,
]
);
$controls->add_control(
'eael_custom_js_label',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('Add your own custom JS here', 'essential-addons-for-elementor-lite'),
]
);
$controls->add_control(
'eael_custom_js',
[
'type' => Controls_Manager::CODE,
'show_label' => false,
'language' => 'javascript',
]
);
$controls->add_control(
'eael_custom_js_usage',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('You may use both jQuery selector e.g. $(.selector) or Vanilla JS selector e.g. document.queryselector(.selector)', 'essential-addons-for-elementor-lite'),
'content_classes' => 'elementor-descriptor',
]
);
$controls->add_control(
'eael_custom_js_docs',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('For more information, <a href="https://essential-addons.com/elementor/docs/custom-js/" target="_blank">click here</a>', 'essential-addons-for-elementor-lite'),
'content_classes' => 'elementor-descriptor',
]
);
$controls->end_controls_section();
}
}

View File

@@ -0,0 +1,170 @@
<?php
namespace Essential_Addons_Elementor\Extensions;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Post_Duplicator {
public function __construct() {
add_filter( 'admin_action_eae_duplicate', array( $this, 'duplicate' ) );
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 10000 );
add_filter( 'post_row_actions', array( $this, 'row_actions' ), 10, 2 );
add_filter( 'page_row_actions', array( $this, 'row_actions' ), 10, 2 );
}
public function admin_bar_menu( $wp_admin_bar ) {
global $pagenow;
global $post;
$enabled_on = get_option( 'eael_save_post_duplicator_post_type', 'all' );
if ( ! is_admin() || $pagenow !== 'post.php' || ( $enabled_on != 'all' || $post->post_type != $enabled_on ) ) {
return;
}
$duplicate_url = admin_url( 'admin.php?action=eae_duplicate&post=' . $post->ID );
$duplicate_url = wp_nonce_url( $duplicate_url, 'ea_duplicator' );
$wp_admin_bar->add_menu(
array(
'id' => 'eae-duplicator',
'title' => __( 'EA Duplicator', 'essential-addons-for-elementor-lite' ),
'href' => $duplicate_url
)
);
}
/**
* EA Duplicator Button added in table row
*
* @param array $actions
* @param WP_Post $post
*
* @return array
*/
public function row_actions( $actions, $post ) {
$enabled_on = get_option( 'eael_save_post_duplicator_post_type', 'all' );
if ( current_user_can( 'edit_posts' ) && ( $enabled_on == 'all' || $post->post_type == $enabled_on ) ) {
$duplicate_url = admin_url( 'admin.php?action=eae_duplicate&post=' . $post->ID );
$duplicate_url = wp_nonce_url( $duplicate_url, 'ea_duplicator' );
$actions['eae_duplicate'] = sprintf( '<a href="%s" title="%s">%s</a>', $duplicate_url, __( 'Duplicate ' . esc_attr( $post->post_title ), 'essential-addons-for-elementor-lite' ), __( 'EA Duplicator', 'essential-addons-for-elementor-lite' ) );
}
return $actions;
}
/**
* Duplicate a post
* @return void
*/
public function duplicate() {
$nonce = isset( $_REQUEST['_wpnonce'] ) && ! empty( $_REQUEST['_wpnonce'] ) ? $_REQUEST['_wpnonce'] : null;
$post_id = isset( $_REQUEST['post'] ) && ! empty( $_REQUEST['post'] ) ? intval( $_REQUEST['post'] ) : null;
$action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? trim( sanitize_text_field( $_REQUEST['action'] ) ) : null;
if ( is_null( $nonce ) || is_null( $post_id ) || $action !== 'eae_duplicate' ) {
return; // Return if action is not eae_duplicate
}
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'ea_duplicator' ) ) {
return; // Return if nonce is not valid
}
$post = sanitize_post( get_post( $post_id ), 'db' );
if ( is_null( $post ) ) {
return; // Return if post is not there.
}
$current_user = wp_get_current_user();
$allowed_roles = array('editor', 'administrator', 'author');
$redirect_url = admin_url( 'edit.php?post_type=' . $post->post_type );
if ( ! array_intersect( $allowed_roles, $current_user->roles ) ) {
switch ( $post->post_type ) {
case 'post':
$can_edit_others_posts = current_user_can('edit_others_posts');
break;
case 'page':
$can_edit_others_posts = current_user_can('edit_others_pages');
break;
default :
$can_edit_others_posts = current_user_can('edit_others_posts');
break;
}
if ( $current_user->ID !== $post->post_author && ! $can_edit_others_posts ){
wp_safe_redirect( $redirect_url );
return;
}
}
$duplicate_post_args = array(
'post_author' => $current_user->ID,
'post_title' => $post->post_title . ' - Copy',
'post_content' => $post->post_content,
'post_excerpt' => $post->post_excerpt,
'post_parent' => $post->post_parent,
'post_status' => 'draft',
'ping_status' => $post->ping_status,
'comment_status' => $post->comment_status,
'post_password' => $post->post_password,
'post_type' => $post->post_type,
'to_ping' => $post->to_ping,
'menu_order' => $post->menu_order,
);
$duplicated_id = wp_insert_post( $duplicate_post_args );
if ( ! is_wp_error( $duplicated_id ) ) {
$taxonomies = get_object_taxonomies( $post->post_type );
if ( ! empty( $taxonomies ) && is_array( $taxonomies ) ) {
foreach ( $taxonomies as $taxonomy ) {
$post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'slugs' ) );
wp_set_object_terms( $duplicated_id, $post_terms, $taxonomy, false );
}
}
global $wpdb;
$post_meta = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = %d", $post_id ) );
if ( ! empty( $post_meta ) && is_array( $post_meta ) ) {
$duplicate_insert_query = "INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ";
$insert = '';
foreach ( $post_meta as $meta_info ) {
$meta_key = sanitize_text_field( $meta_info->meta_key );
$meta_value = $meta_info->meta_value;
$exclude_meta_keys = [ '_wc_average_rating', '_wc_review_count', '_wc_rating_count' ];
if( in_array($meta_key, $exclude_meta_keys) ){
continue;
}
if ( $meta_key === '_elementor_template_type' ) {
delete_post_meta( $duplicated_id, '_elementor_template_type' );
}
if ( ! empty( $insert ) ) {
$insert .= ', ';
}
$insert .= $wpdb->prepare( '(%d, %s, %s)', $duplicated_id, $meta_key, $meta_value );
}
$wpdb->query( $duplicate_insert_query . $insert );
}
}
wp_safe_redirect( $redirect_url );
}
}

View File

@@ -0,0 +1,159 @@
<?php
namespace Essential_Addons_Elementor\Extensions;
if (!defined('ABSPATH')) {
exit;
}
use Elementor\Controls_Manager;
class Promotion
{
public function __construct() {
if ( ! apply_filters( 'eael/pro_enabled', false ) ) {
add_action( 'elementor/element/section/section_layout/after_section_end', [ $this, 'section_parallax' ], 10 );
add_action( 'elementor/element/section/section_layout/after_section_end', [ $this, 'section_particles' ], 10 );
add_action( 'elementor/element/common/_section_style/after_section_end', [ $this, 'content_protection' ], 10 );
add_action( 'elementor/element/common/_section_style/after_section_end', [ $this, 'section_tooltip' ], 10 );
add_action( 'elementor/element/common/_section_style/after_section_end', [ $this, 'conditional_display' ] );
add_action( 'elementor/element/column/section_advanced/after_section_end', [ $this, 'conditional_display' ] );
add_action( 'elementor/element/section/section_advanced/after_section_end', [ $this, 'conditional_display' ] );
}
}
public function teaser_template($texts)
{
$html = '<div class="ea-nerd-box">
<div class="ea-nerd-box-icon">
<img src="' . EAEL_PLUGIN_URL . 'assets/admin/images/icon-ea-logo.svg' . '">
</div>
<div class="ea-nerd-box-title">' . $texts['title'] . '</div>
<div class="ea-nerd-box-message">' . $texts['messages'] . '</div>
<a class="ea-nerd-box-link elementor-button elementor-button-default" href="https://wpdeveloper.com/upgrade/ea-pro" target="_blank">
' . __('Upgrade Essential Addons', 'essential-addons-for-elementor-lite') . '
</a>
</div>';
return $html;
}
public function section_parallax($element)
{
$element->start_controls_section(
'eael_ext_section_parallax_section',
[
'label' => __('<i class="eaicon-logo"></i> Parallax', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_LAYOUT,
]
);
$element->add_control(
'eael_ext_section_parallax_pro_required',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => $this->teaser_template([
'title' => __('Meet EA Parallax', 'essential-addons-for-elementor-lite'),
'messages' => __('Create stunning Parallax effects on your site and blow everyone away.', 'essential-addons-for-elementor-lite'),
]),
]
);
$element->end_controls_section();
}
public function section_particles($element)
{
$element->start_controls_section(
'eael_ext_section_particles_section',
[
'label' => __('<i class="eaicon-logo"></i> Particles', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_LAYOUT,
]
);
$element->add_control(
'eael_ext_section_particles_pro_required',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => $this->teaser_template([
'title' => __('Meet EA Particles', 'essential-addons-for-elementor-lite'),
'messages' => __('Create stunning Particles effects on your site and blow everyone away.', 'essential-addons-for-elementor-lite'),
]),
]
);
$element->end_controls_section();
}
public function content_protection($element)
{
$element->start_controls_section(
'eael_ext_content_protection_section',
[
'label' => __('<i class="eaicon-logo"></i> Content Protection', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_ADVANCED,
]
);
$element->add_control(
'eael_ext_content_protection_pro_required',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => $this->teaser_template([
'title' => __('Meet EA Content Protection', 'essential-addons-for-elementor-lite'),
'messages' => __('Put a restriction on any of your content and protect your privacy.', 'essential-addons-for-elementor-lite'),
]),
]
);
$element->end_controls_section();
}
public function section_tooltip($element)
{
$element->start_controls_section(
'eael_ext_section_tooltip_section',
[
'label' => __('<i class="eaicon-logo"></i> Advanced Tooltip', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_ADVANCED,
]
);
$element->add_control(
'eael_ext_section_tooltip_pro_required',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => $this->teaser_template([
'title' => __('Meet EA Advanced Tooltip', 'essential-addons-for-elementor-lite'),
'messages' => __('Highlight any Elementor widgets with a key message when they are hovered.', 'essential-addons-for-elementor-lite'),
]),
]
);
$element->end_controls_section();
}
public function conditional_display( $element ) {
$element->start_controls_section(
'eael_conditional_display_section',
[
'label' => __( '<i class="eaicon-logo"></i> Conditional Display', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_ADVANCED
]
);
$element->add_control(
'eael_conditional_display_section_pro_required',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => $this->teaser_template( [
'title' => __( 'Meet EA Conditional Display', 'essential-addons-for-elementor-lite' ),
'messages' => __( "Control any section, column, container or widgets visibility with your own logic.", 'essential-addons-for-elementor-lite' ),
] ),
]
);
$element->end_controls_section();
}
}

View File

@@ -0,0 +1,214 @@
<?php
namespace Essential_Addons_Elementor\Extensions;
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Essential_Addons_Elementor\Classes\Helper;
class Reading_Progress
{
public function __construct()
{
add_action('elementor/documents/register_controls', [$this, 'register_controls'], 10);
}
public function register_controls($element)
{
if (Helper::prevent_extension_loading(get_the_ID())) {
return;
}
$global_settings = get_option('eael_global_settings');
$element->start_controls_section(
'eael_ext_reading_progress_section',
[
'label' => __('<i class="eaicon-logo"></i> Reading Progress Bar', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_SETTINGS,
]
);
$element->add_control(
'eael_ext_reading_progress',
[
'label' => __('Enable Reading Progress Bar', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'label_on' => __('Yes', 'essential-addons-for-elementor-lite'),
'label_off' => __('No', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
]
);
$element->add_control(
'eael_ext_reading_progress_has_global',
[
'label' => __('Enabled Globally?', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HIDDEN,
'default' => (isset($global_settings['reading_progress']['enabled']) ? $global_settings['reading_progress']['enabled'] : false),
]
);
if (isset($global_settings['reading_progress']['enabled']) && ($global_settings['reading_progress']['enabled'] == true) && get_the_ID() != $global_settings['reading_progress']['post_id'] && get_post_status($global_settings['reading_progress']['post_id']) == 'publish') {
$element->add_control(
'eael_global_warning_text',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('You can modify the Global Reading Progress Bar by <strong><a href="' . get_bloginfo('url') . '/wp-admin/post.php?post=' . $global_settings['reading_progress']['post_id'] . '&action=elementor">Clicking Here</a></strong>', 'essential-addons-for-elementor-lite'),
'content_classes' => 'eael-warning',
'separator' => 'before',
'condition' => [
'eael_ext_reading_progress' => 'yes',
],
]
);
} else {
$element->add_control(
'eael_ext_reading_progress_global',
[
'label' => __('Enable Reading Progress Bar Globally', 'essential-addons-for-elementor-lite'),
'description' => __('Enabling this option will effect on entire site.', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'label_on' => __('Yes', 'essential-addons-for-elementor-lite'),
'label_off' => __('No', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
'separator' => 'before',
'condition' => [
'eael_ext_reading_progress' => 'yes',
],
]
);
$element->add_control(
'eael_ext_reading_progress_global_display_condition',
[
'label' => __('Display On', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'all',
'options' => [
'posts' => __('All Posts', 'essential-addons-for-elementor-lite'),
'pages' => __('All Pages', 'essential-addons-for-elementor-lite'),
'all' => __('All Posts & Pages', 'essential-addons-for-elementor-lite'),
],
'condition' => [
'eael_ext_reading_progress' => 'yes',
'eael_ext_reading_progress_global' => 'yes',
],
'separator' => 'before',
]
);
}
$element->add_control(
'eael_ext_reading_progress_position',
[
'label' => esc_html__('Position', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'top',
'label_block' => false,
'options' => [
'top' => esc_html__('Top', 'essential-addons-for-elementor-lite'),
'bottom' => esc_html__('Bottom', 'essential-addons-for-elementor-lite'),
],
'separator' => 'before',
'condition' => [
'eael_ext_reading_progress' => 'yes',
],
]
);
$element->add_control(
'eael_ext_reading_progress_height',
[
'label' => __('Height', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 5,
],
'selectors' => [
'.eael-reading-progress-wrap .eael-reading-progress' => 'height: {{SIZE}}{{UNIT}} !important',
'.eael-reading-progress-wrap .eael-reading-progress .eael-reading-progress-fill' => 'height: {{SIZE}}{{UNIT}} !important',
],
'separator' => 'before',
'condition' => [
'eael_ext_reading_progress' => 'yes',
],
]
);
$element->add_control(
'eael_ext_reading_progress_bg_color',
[
'label' => __('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'.eael-reading-progress' => 'background-color: {{VALUE}}',
],
'separator' => 'before',
'condition' => [
'eael_ext_reading_progress' => 'yes',
],
]
);
$element->add_control(
'eael_ext_reading_progress_fill_color',
[
'label' => __('Fill Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#1fd18e',
'selectors' => [
'.eael-reading-progress-wrap .eael-reading-progress .eael-reading-progress-fill' => 'background-color: {{VALUE}}',
],
'separator' => 'before',
'condition' => [
'eael_ext_reading_progress' => 'yes',
],
]
);
$element->add_control(
'eael_ext_reading_progress_animation_speed',
[
'label' => __('Animation Speed', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 50,
],
'selectors' => [
'.eael-reading-progress-wrap .eael-reading-progress .eael-reading-progress-fill' => 'transition: width {{SIZE}}ms ease;',
],
'separator' => 'before',
'condition' => [
'eael_ext_reading_progress' => 'yes',
],
]
);
$element->end_controls_section();
}
}

View File

@@ -0,0 +1,443 @@
<?php
namespace Essential_Addons_Elementor\Extensions;
if (!defined('ABSPATH')) {
exit;
}
use \Elementor\Controls_Manager;
use \Essential_Addons_Elementor\Classes\Helper;
class Scroll_to_Top
{
public function __construct()
{
add_action('elementor/documents/register_controls', [$this, 'register_controls'], 10);
}
public function register_controls($element)
{
if (Helper::prevent_extension_loading(get_the_ID())) {
return;
}
$global_settings = get_option('eael_global_settings');
$element->start_controls_section(
'eael_ext_scroll_to_top_section',
[
'label' => __('<i class="eaicon-logo"></i> Scroll to Top', 'essential-addons-for-elementor-lite'),
'tab' => Controls_Manager::TAB_SETTINGS,
]
);
$element->add_control(
'eael_ext_scroll_to_top',
[
'label' => __('Enable Scroll to Top', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'label_on' => __('Yes', 'essential-addons-for-elementor-lite'),
'label_off' => __('No', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
]
);
$element->add_control(
'eael_ext_scroll_to_top_has_global',
[
'label' => __('Enabled Globally?', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::HIDDEN,
'default' => (isset($global_settings['eael_ext_scroll_to_top']['enabled']) ? $global_settings['eael_ext_scroll_to_top']['enabled'] : false),
]
);
if (isset($global_settings['eael_ext_scroll_to_top']['enabled']) && ($global_settings['eael_ext_scroll_to_top']['enabled'] == true) && get_the_ID() != $global_settings['eael_ext_scroll_to_top']['post_id'] && get_post_status($global_settings['eael_ext_scroll_to_top']['post_id']) == 'publish') {
$element->add_control(
'eael_ext_scroll_to_top_global_warning_text',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __('You can modify the Global Scroll to Top by <strong><a href="' . get_bloginfo('url') . '/wp-admin/post.php?post=' . $global_settings['eael_ext_scroll_to_top']['post_id'] . '&action=elementor">Clicking Here</a></strong>', 'essential-addons-for-elementor-lite'),
'content_classes' => 'eael-warning',
'separator' => 'before',
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
} else {
$element->add_control(
'eael_ext_scroll_to_top_global',
[
'label' => __('Enable Scroll to Top Globally', 'essential-addons-for-elementor-lite'),
'description' => __('Enabling this option will effect on entire site.', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'label_on' => __('Yes', 'essential-addons-for-elementor-lite'),
'label_off' => __('No', 'essential-addons-for-elementor-lite'),
'return_value' => 'yes',
'separator' => 'before',
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_global_display_condition',
[
'label' => __('Display On', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'all',
'options' => [
'posts' => __('All Posts', 'essential-addons-for-elementor-lite'),
'pages' => __('All Pages', 'essential-addons-for-elementor-lite'),
'all' => __('All Posts & Pages', 'essential-addons-for-elementor-lite'),
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
'eael_ext_scroll_to_top_global' => 'yes',
],
'separator' => 'before',
]
);
}
$element->add_control(
'eael_ext_scroll_to_top_position_text',
[
'label' => esc_html__('Position', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SELECT,
'default' => 'bottom-right',
'label_block' => false,
'options' => [
'bottom-left' => esc_html__('Bottom Left', 'essential-addons-for-elementor-lite'),
'bottom-right' => esc_html__('Bottom Right', 'essential-addons-for-elementor-lite'),
],
'separator' => 'before',
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_position_bottom',
[
'label' => __('Bottom', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'em', '%'],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 1,
],
'em' => [
'min' => 0,
'max' => 50,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 15,
],
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'bottom: {{SIZE}}{{UNIT}}',
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_position_left',
[
'label' => __('Left', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'em', '%'],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 1,
],
'em' => [
'min' => 0,
'max' => 50,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 15,
],
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'left: {{SIZE}}{{UNIT}}',
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
'eael_ext_scroll_to_top_position_text' => 'bottom-left',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_position_right',
[
'label' => __('Right', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'em', '%'],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 1,
],
'em' => [
'min' => 0,
'max' => 50,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 15,
],
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'right: {{SIZE}}{{UNIT}}',
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
'eael_ext_scroll_to_top_position_text' => 'bottom-right',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_button_width',
[
'label' => __('Width', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 50,
],
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'width: {{SIZE}}{{UNIT}};',
],
'separator' => 'before',
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_button_height',
[
'label' => __('Height', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 1000,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 50,
],
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'height: {{SIZE}}{{UNIT}};',
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_z_index',
[
'label' => __('Z Index', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 9999,
'step' => 10,
],
],
'default' => [
'unit' => 'px',
'size' => 9999,
],
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'z-index: {{SIZE}}',
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_button_opacity',
[
'label' => __('Opacity', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 1,
'step' => 0.01,
],
],
'default' => [
'unit' => 'px',
'size' => 0.7,
],
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'opacity: {{SIZE}};',
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_button_icon_image',
[
'label' => esc_html__('Icon', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::ICONS,
'default' => [
'value' => 'fas fa-chevron-up',
'library' => 'fa-solid',
],
'separator' => 'before',
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_button_icon_size',
[
'label' => __('Icon Size', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 16,
'unit' => 'px',
],
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
],
],
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button i' => 'font-size: {{SIZE}}{{UNIT}};',
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_button_icon_color',
[
'label' => __('Icon Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#ffffff',
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button i' => 'color: {{VALUE}}',
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button svg' => 'fill: {{VALUE}}',
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_button_bg_color',
[
'label' => __('Background Color', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::COLOR,
'default' => '#000000',
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'background-color: {{VALUE}}',
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->add_control(
'eael_ext_scroll_to_top_button_border_radius',
[
'label' => __('Border Radius', 'essential-addons-for-elementor-lite'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 50,
'step' => 1,
],
],
'default' => [
'unit' => 'px',
'size' => 5,
],
'selectors' => [
'.eael-ext-scroll-to-top-wrap .eael-ext-scroll-to-top-button' => 'border-radius: {{SIZE}}{{UNIT}}',
],
'condition' => [
'eael_ext_scroll_to_top' => 'yes',
],
]
);
$element->end_controls_section();
}
}

View File

@@ -0,0 +1,74 @@
<?php
namespace Essential_Addons_Elementor\Extensions;
use Elementor\Controls_Manager;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Wrapper_Link {
/**
* Initialize hooks
*/
public function __construct() {
add_action( 'elementor/element/common/_section_style/after_section_end', [ $this, 'register_controls' ] );
add_action( 'elementor/element/column/section_advanced/after_section_end', [ $this, 'register_controls' ] );
add_action( 'elementor/element/section/section_advanced/after_section_end', [ $this, 'register_controls' ] );
add_action( 'elementor/element/container/section_layout/after_section_end', [ $this, 'register_controls' ] );
add_action( 'elementor/frontend/before_render', [ $this, 'before_render' ], 1 );
}
public function register_controls( $element ) {
$element->start_controls_section(
'eael_wrapper_link_section',
[
'label' => __( '<i class="eaicon-logo"></i> Wrapper Link', 'essential-addons-for-elementor-lite' ),
'tab' => Controls_Manager::TAB_ADVANCED
]
);
$element->add_control(
'eael_wrapper_link_switch',
[
'label' => __( 'Enable Wrapper Link', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::SWITCHER
]
);
$element->add_control(
'eael_wrapper_link',
[
'label' => __( 'Link', 'essential-addons-for-elementor-lite' ),
'type' => Controls_Manager::URL,
'dynamic' => [
'active' => true,
],
'condition' => [
'eael_wrapper_link_switch!' => ''
]
]
);
$element->end_controls_section();
}
public function before_render( $element ) {
$wrapper_link_settings = $element->get_settings_for_display( 'eael_wrapper_link' );
if ( ! empty( $element->get_settings_for_display( 'eael_wrapper_link_switch' ) ) && ! empty( $wrapper_link_settings['url'] ) ) {
$element->add_render_attribute( '_wrapper',
'data-eael-wrapper-link',
wp_json_encode( [
'url' => esc_url( $wrapper_link_settings['url'] ),
'is_external' => esc_attr( $wrapper_link_settings['is_external'] ),
'nofollow' => esc_attr( $wrapper_link_settings['nofollow'] )
] )
);
}
}
}

View File

@@ -0,0 +1 @@
<?php // Silence is golden

View File

@@ -0,0 +1,43 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Layout 2
*
*/
if ($default_multiple_kb) {
if(!empty($settings['selected_knowledge_base'])){
$button_link = str_replace('%knowledge_base%', $settings['selected_knowledge_base'], get_term_link($term->slug, 'doc_category'));
}else{
$button_link = str_replace('%knowledge_base%', 'non-knowledgebase', get_term_link($term->slug, 'doc_category'));
}
} else {
$button_link = get_term_link($term->slug, 'doc_category');
}
echo '<a href="' . esc_url( $button_link ) . '" class="eael-better-docs-category-box-post layout__2">';
echo '<div class="eael-bd-cb-inner">';
if ($settings['show_icon']) {
$cat_icon_id = get_term_meta($term->term_id, 'doc_category_image-id', true);
if ($cat_icon_id) {
$cat_icon = wp_get_attachment_image($cat_icon_id, 'thumbnail', ['alt' => esc_attr(get_post_meta($cat_icon_id, '_wp_attachment_image_alt', true))]);
} else {
$cat_icon = '<img src="' . EAEL_PLUGIN_URL . 'assets/front-end/img/betterdocs-cat-icon.svg" alt="betterdocs-category-box-icon">';
}
echo '<div class="eael-bd-cb-cat-icon__layout-2">' . $cat_icon . '</div>';
}
if ($settings['show_title']) {
echo '<' . Helper::eael_validate_html_tag($settings['title_tag']) . ' class="eael-bd-cb-cat-title__layout-2"><span>' . $term->name . '</span></' . Helper::eael_validate_html_tag($settings['title_tag']) . '>';
}
if ($settings['show_count']) {
printf('<div class="eael-bd-cb-cat-count__layout-2"><span class="count-inner__layout-2">%s</span></div>', Helper::get_doc_post_count($term->count, $term->term_id));
}
echo '</div>';
echo '</a>';

View File

@@ -0,0 +1,43 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Default
*
*/
if ($default_multiple_kb) {
if(!empty($settings['selected_knowledge_base'])){
$button_link = str_replace('%knowledge_base%', $settings['selected_knowledge_base'], get_term_link($term->slug, 'doc_category'));
}else{
$button_link = str_replace('%knowledge_base%', 'non-knowledgebase', get_term_link($term->slug, 'doc_category'));
}
} else {
$button_link = get_term_link($term->slug, 'doc_category');
}
echo '<a href="' . esc_url( $button_link ) . '" class="eael-better-docs-category-box-post">
<div class="eael-bd-cb-inner">';
if ($settings['show_icon']) {
$cat_icon_id = get_term_meta($term->term_id, 'doc_category_image-id', true);
if ($cat_icon_id) {
$cat_icon = wp_get_attachment_image($cat_icon_id, 'thumbnail', ['alt' => esc_attr(get_post_meta($cat_icon_id, '_wp_attachment_image_alt', true))]);
} else {
$cat_icon = '<img src="' . EAEL_PLUGIN_URL . 'assets/front-end/img/betterdocs-cat-icon.svg" alt="betterdocs-category-box-icon">';
}
echo '<div class="eael-bd-cb-cat-icon">' . $cat_icon . '</div>';
}
if ($settings['show_title']) {
echo '<' . Helper::eael_validate_html_tag($settings['title_tag'] ). ' class="eael-bd-cb-cat-title">' . $term->name . '</' . Helper::eael_validate_html_tag($settings['title_tag']) . '>';
}
if ($settings['show_count']) {
printf('<div class="eael-bd-cb-cat-count"><span class="count-prefix">%s</span>%s<span class="count-suffix">%s</span></div>', Helper::eael_wp_kses($settings['count_prefix']) , Helper::get_doc_post_count($term->count, $term->term_id), Helper::eael_wp_kses($settings['count_suffix']));
}
echo '</div>
</a>';

View File

@@ -0,0 +1,170 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Layout 2
*
*/
echo '<article class="eael-better-docs-category-grid-post layout-2" data-id="' . get_the_ID() . '">
<div class="eael-bd-cg-inner">';
if ($settings['show_header'] === 'true') {
echo '<div class="eael-bd-cg-header">';
if ($settings['show_count']) {
echo '<div class="eael-docs-item-count" data-content="' . Helper::get_doc_post_count($term->count, $term->term_id) . '"></div>';
}
if ($settings['show_title']) {
echo '<' . Helper::eael_validate_html_tag($settings['title_tag']) . ' class="eael-docs-cat-title">' . $term->name . '</' . Helper::eael_validate_html_tag($settings['title_tag']) . '>';
}
echo '</div>';
}
if ($settings['show_list'] === 'true') {
echo '<div class="eael-bd-cg-body">';
$args = array(
'post_type' => 'docs',
'post_status' => 'publish',
'posts_per_page' => $settings['post_per_page'],
'orderby' => $settings['post_orderby'],
'order' => $settings['post_order'],
'tax_query' => array(
array(
'taxonomy' => 'doc_category',
'field' => 'slug',
'terms' => $term->slug,
'operator' => 'AND',
'include_children' => false,
),
),
);
$query = new \WP_Query($args);
if ($query->have_posts()) {
echo '<ul>';
while ($query->have_posts()) {
$query->the_post();
$attr = ['href="' . get_the_permalink() . '"'];
echo '<li>';
if (isset($settings['list_icon']['value']['url']) && !empty($settings['list_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-post-list-icon" src="' . esc_url( $settings['list_icon']['value']['url'] ). '" />';
} else {
echo '<i class="' . esc_attr( $settings['list_icon']['value'] ) . ' eael-bd-cg-post-list-icon"></i>';
}
echo '<a ' . implode(' ', $attr) . '>' . get_the_title() . '</a>
</li>';
}
echo '</ul>';
}
wp_reset_query();
// Nested category query
if ($settings['nested_subcategory'] === 'true') {
$args = array(
'child_of' => $term->term_id,
'order' => $settings['order'],
'orderby' => $settings['orderby'],
);
$sub_categories = get_terms('doc_category', $args);
if ($sub_categories) {
foreach ($sub_categories as $sub_category) {
echo '<span class="eael-bd-grid-sub-cat-title">';
if (isset($settings['nested_list_title_closed_icon']['value']['url']) && !empty($settings['nested_list_title_closed_icon']['value']['url'])) {
echo '<img class="toggle-arrow arrow-right" src="' . esc_url( $settings['nested_list_title_closed_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['nested_list_title_closed_icon']['value'] ) . ' toggle-arrow arrow-right"></i>';
}
if (isset($settings['nested_list_title_open_icon']['value']['url']) && !empty($settings['nested_list_title_open_icon']['value']['url'])) {
echo '<img class="toggle-arrow arrow-down" src="' . esc_url( $settings['nested_list_title_open_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['nested_list_title_open_icon']['value'] ) . ' toggle-arrow arrow-down"></i>';
}
echo '<a href="#">' . $sub_category->name . '</a></span>';
echo '<ul class="docs-sub-cat-list">';
$sub_args = array(
'post_type' => 'docs',
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'doc_category',
'field' => 'slug',
'terms' => $sub_category->slug,
'operator' => 'AND',
'include_children' => false,
),
),
);
$sub_args['posts_per_page'] = -1;
$sub_post_query = new \WP_Query($sub_args);
if ($sub_post_query->have_posts()):
while ($sub_post_query->have_posts()): $sub_post_query->the_post();
$sub_attr = ['href="' . get_the_permalink() . '"'];
echo '<li class="sub-list">';
if (isset($settings['list_icon']['value']['url']) && !empty($settings['list_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-post-list-icon" src="' . esc_url( $settings['list_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['list_icon']['value'] ) . ' eael-bd-cg-post-list-icon"></i>';
}
echo '<a ' . implode(' ', $sub_attr) . '>' . get_the_title() . '</a></li>';
endwhile;
endif;
wp_reset_query();
echo '</ul>';
}
}
}
echo '</div>';
}
echo '<div class="eael-bd-cg-footer">';
if ($settings['show_button']) {
if ($default_multiple_kb) {
if(!empty($settings['selected_knowledge_base'])){
if(!empty($settings['selected_knowledge_base'])){
$button_link = str_replace('%knowledge_base%', $settings['selected_knowledge_base'], get_term_link($term->slug, 'doc_category'));
}else{
$button_link = str_replace('%knowledge_base%', 'non-knowledgebase', get_term_link($term->slug, 'doc_category'));
}
}else{
$button_link = str_replace('%knowledge_base%', 'non-knowledgebase', get_term_link($term->slug, 'doc_category'));
}
} else {
$button_link = get_term_link($term->slug, 'doc_category');
}
echo '<a class="eael-bd-cg-button" href="' . esc_url( $button_link ) . '">';
if ($settings['icon_position'] === 'before') {
if (isset($settings['button_icon']['value']['url']) && !empty($settings['button_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-button-icon eael-bd-cg-button-icon-left" src="' . esc_url( $settings['button_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['button_icon']['value'] ) . ' eael-bd-cg-button-icon eael-bd-cg-button-icon-left"></i>';
}
}
echo Helper::eael_wp_kses($settings['button_text']);
if ($settings['icon_position'] === 'after') {
if (isset($settings['button_icon']['value']['url']) && !empty($settings['button_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-button-icon eael-bd-cg-button-icon-right" src="' . esc_url( $settings['button_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['button_icon']['value'] ) . ' eael-bd-cg-button-icon eael-bd-cg-button-icon-right"></i>';
}
}
echo '</a>';
}
echo '</div>
</div>
</article>';

View File

@@ -0,0 +1,223 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Default
*
*/
echo '<article class="eael-better-docs-category-grid-post" data-id="' . get_the_ID() . '">
<div class="eael-bd-cg-inner">';
if ($settings['show_header'] === 'true') {
echo '<div class="eael-bd-cg-header">
<div class="eael-bd-cg-header-inner">';
if ($settings['show_icon']) {
$cat_icon_id = get_term_meta($term->term_id, 'doc_category_image-id', true);
if ($cat_icon_id) {
$cat_icon = wp_get_attachment_image($cat_icon_id, 'thumbnail', ['alt' => esc_attr(get_post_meta($cat_icon_id, '_wp_attachment_image_alt', true))]);
} else {
$cat_icon = '<img src="' . EAEL_PLUGIN_URL . 'assets/front-end/img/betterdocs-cat-icon.svg" alt="betterdocs-category-grid-icon">';
}
echo '<div class="eael-docs-cat-icon">' . $cat_icon . '</div>';
}
if ($settings['show_title']) {
echo '<' . Helper::eael_validate_html_tag($settings['title_tag']) . ' class="eael-docs-cat-title">' . $term->name . '</' . Helper::eael_validate_html_tag($settings['title_tag']) . '>';
}
if ($settings['show_count']) {
echo '<div class="eael-docs-item-count">' . Helper::get_doc_post_count($term->count, $term->term_id) . '</div>';
}
echo '</div>
</div>';
}
if ($settings['show_list'] === 'true') {
echo '<div class="eael-bd-cg-body">';
$multiple_kb = Helper::get_betterdocs_multiple_kb_status();
if ($multiple_kb == true) {
$taxes = array('knowledge_base', 'doc_category');
foreach ($taxes as $tax) {
$kterms = get_terms($tax);
if (!is_wp_error($kterms)) {
foreach ($kterms as $kterm) {
$tax_map[$tax][$kterm->slug] = $kterm->term_taxonomy_id;
}
}
}
$args = array(
'post_type' => 'docs',
'post_status' => 'publish',
'posts_per_page' => $settings['post_per_page'],
'orderby' => $settings['post_orderby'],
'order' => $settings['post_order'],
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'doc_category',
'field' => 'term_taxonomy_id',
'operator' => 'IN',
'terms' => array($tax_map['doc_category'][$term->slug]),
'include_children' => false,
),
),
);
if(!empty($settings['selected_knowledge_base'])){
$args['tax_query'][] = array(
'taxonomy' => 'knowledge_base',
'field' => 'term_taxonomy_id',
'terms' => array($tax_map['knowledge_base'][$settings['selected_knowledge_base']]),
'operator' => 'IN',
'include_children' => false,
);
}
} else {
$args = array(
'post_type' => 'docs',
'post_status' => 'publish',
'posts_per_page' => $settings['post_per_page'],
'orderby' => $settings['post_orderby'],
'order' => $settings['post_order'],
'tax_query' => array(
array(
'taxonomy' => 'doc_category',
'field' => 'slug',
'terms' => $term->slug,
'operator' => 'AND',
'include_children' => false,
),
),
);
}
$query = new \WP_Query($args);
if ($query->have_posts()) {
echo '<ul>';
while ($query->have_posts()) {
$query->the_post();
$attr = ['href="' . get_the_permalink() . '"'];
echo '<li>';
if (isset($settings['list_icon']['value']['url']) && !empty($settings['list_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-post-list-icon" src="' . esc_url( $settings['list_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['list_icon']['value'] ) . ' eael-bd-cg-post-list-icon"></i>';
}
echo '<a ' . implode(' ', $attr) . '>' . get_the_title() . '</a>
</li>';
}
echo '</ul>';
}
wp_reset_query();
// Nested category query
if ($settings['nested_subcategory'] === 'true') {
$args = array(
'child_of' => $term->term_id,
'order' => $settings['order'],
'orderby' => $settings['orderby'],
);
$sub_categories = get_terms('doc_category', $args);
if ($sub_categories) {
foreach ($sub_categories as $sub_category) {
echo '<span class="eael-bd-grid-sub-cat-title">';
if (isset($settings['nested_list_title_closed_icon']['value']['url']) && !empty($settings['nested_list_title_closed_icon']['value']['url'])) {
echo '<img class="toggle-arrow arrow-right" src="' . esc_url( $settings['nested_list_title_closed_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['nested_list_title_closed_icon']['value'] ) . ' toggle-arrow arrow-right"></i>';
}
if (isset($settings['nested_list_title_open_icon']['value']['url']) && !empty($settings['nested_list_title_open_icon']['value']['url'])) {
echo '<img class="toggle-arrow arrow-down" src="' . esc_url( $settings['nested_list_title_open_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['nested_list_title_open_icon']['value'] ) . ' toggle-arrow arrow-down"></i>';
}
echo '<a href="#">' . $sub_category->name . '</a></span>';
echo '<ul class="docs-sub-cat-list">';
$sub_args = array(
'post_type' => 'docs',
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'doc_category',
'field' => 'slug',
'terms' => $sub_category->slug,
'operator' => 'AND',
'include_children' => false,
),
),
);
$sub_args['posts_per_page'] = -1;
$sub_post_query = new \WP_Query($sub_args);
if ($sub_post_query->have_posts()):
while ($sub_post_query->have_posts()): $sub_post_query->the_post();
$sub_attr = ['href="' . get_the_permalink() . '"'];
echo '<li class="sub-list">';
if (isset($settings['list_icon']['value']['url']) && !empty($settings['list_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-post-list-icon" src="' . esc_url( $settings['list_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['list_icon']['value'] ) . ' eael-bd-cg-post-list-icon"></i>';
}
echo '<a ' . implode(' ', $sub_attr) . '>' . get_the_title() . '</a></li>';
endwhile;
endif;
wp_reset_query();
echo '</ul>';
}
}
}
echo '</div>';
}
echo '<div class="eael-bd-cg-footer">';
if ($settings['show_button']) {
if ($default_multiple_kb) {
if(!empty($settings['selected_knowledge_base'])){
$button_link = str_replace('%knowledge_base%', $settings['selected_knowledge_base'], get_term_link($term->slug, 'doc_category'));
}else{
$button_link = str_replace('%knowledge_base%', 'non-knowledgebase', get_term_link($term->slug, 'doc_category'));
}
} else {
$button_link = get_term_link($term->slug, 'doc_category');
}
echo '<a class="eael-bd-cg-button" href="' . esc_url( $button_link ) . '">';
if ($settings['icon_position'] === 'before') {
if (isset($settings['button_icon']['value']['url']) && !empty($settings['button_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-button-icon eael-bd-cg-button-icon-left" src="' . esc_url( $settings['button_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['button_icon']['value'] ) . ' eael-bd-cg-button-icon eael-bd-cg-button-icon-left"></i>';
}
}
echo Helper::eael_wp_kses($settings['button_text']);
if ($settings['icon_position'] === 'after') {
if (isset($settings['button_icon']['value']['url']) && !empty($settings['button_icon']['value']['url'])) {
echo '<img class="eael-bd-cg-button-icon eael-bd-cg-button-icon-right" src="' . esc_url( $settings['button_icon']['value']['url'] ) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['button_icon']['value'] ) . ' eael-bd-cg-button-icon eael-bd-cg-button-icon-right"></i>';
}
}
echo '</a>';
}
echo '</div>';
echo '</div>';
echo '</article>';

View File

@@ -0,0 +1,41 @@
<?php
/**
* Template Name: Default
*/
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
if (isset($content) && isset($link)) {
echo '<div class="swiper-slide">
<div class="ticker-content">';
if (!empty($link['url'])) {
echo '<a href="' . esc_url( $link['url'] ) . '" ';
if ($link['is_external'] == 'on') {
echo 'target="_blank" ';
}
if ($link['nofollow'] == 'on') {
echo 'rel="nofollow"';
}
echo '>';
}
echo $content;
if (!empty($link['url'])) {
echo '</a>';
}
echo '</div>
</div>';
} else {
echo '<div class="swiper-slide">
<div class="ticker-content">
<a href="' . get_the_permalink() . '" class="ticker-content-link">' . get_the_title() . '</a>
</div>
</div>';
}

View File

@@ -0,0 +1,91 @@
<?php
namespace Essential_Addons_Elementor\Template\Content;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
trait Product_Grid {
public static function render_template_( $args, $settings ) {
$query = new \WP_Query( $args );
ob_start();
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$product = wc_get_product( get_the_ID() );
if ( $settings['eael_product_grid_style_preset'] == 'eael-product-simple' || $settings['eael_product_grid_style_preset'] == 'eael-product-reveal' ) { ?>
<li class="product">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">
<?php echo wp_kses_post( $product->get_image( 'woocommerce_thumbnail' )); ?>
<h2 class="woocommerce-loop-product__title"> <?php echo esc_html( $product->get_title()); ?> </h2>
<?php
if ( $settings['eael_product_grid_rating'] == 'yes' ) {
echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ));
}
if ( ! $product->managing_stock() && ! $product->is_in_stock() ) {
printf( '<span class="outofstock-badge">%s</span>', __( 'Stock <br/> Out', 'essential-addons-for-elementor-lite' ) );
} elseif ( $product->is_on_sale() ) {
printf( '<span class="onsale">%s</span>', __( 'Sale!', 'essential-addons-for-elementor-lite' ) );
}
?>
<span class="price"><?php echo wp_kses_post( $product->get_price_html()); ?></span>
</a>
<?php
woocommerce_template_loop_add_to_cart();
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
self::print_compare_button( $product->get_id() );
}
?>
</li>
<?php
} else if ( $settings['eael_product_grid_style_preset'] == 'eael-product-overlay' ) {
?>
<li class="product">
<div class="overlay">
<?php echo $product->get_image( 'woocommerce_thumbnail' ); ?>
<div class="button-wrap clearfix">
<a href="<?php echo esc_url( $product->get_permalink()); ?>" class="product-link"><span class="fas fa-link"></span></a>
<?php
woocommerce_template_loop_add_to_cart();
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
self::print_compare_button( $product->get_id(), 'icon' );
}
?>
</div>
</div>
<h2 class="woocommerce-loop-product__title"><?php echo esc_html( $product->get_title()); ?></h2>
<?php
if ($settings['eael_product_grid_rating'] === 'yes') {
echo wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() );
}
if ($product->is_on_sale()){
printf( '<span class="onsale">%s</span>', __( 'Sale!', 'essential-addons-for-elementor-lite' ));
}
?>
<span class="price"> <?php echo $product->get_price_html(); ?> </span>
</li>
<?php
} else {
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
add_action( 'woocommerce_after_shop_loop_item', function (){
global $product;
if (!$product) return;
self::print_compare_button( $product->get_id() );
});
}
wc_get_template_part( 'content', 'product' );
}
}
} else {
printf( '<p class="no-posts-found">%</p>', __( 'No products found!', 'essential-addons-for-elementor-lite' ) );
}
wp_reset_postdata();
?>
<?php
return ob_get_clean();
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace Essential_Addons_Elementor\Template\Content;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
trait Woo_Product_List {
public static function render_template_( $args, $settings ) {
$query = new \WP_Query( $args );
ob_start();
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$product = wc_get_product( get_the_ID() );
if ( $settings['eael_woo_product_list_style_preset'] == 'eael-product-simple' || $settings['eael_woo_product_list_style_preset'] == 'eael-product-reveal' ) { ?>
<li class="product">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">
<?php echo wp_kses_post( $product->get_image( 'woocommerce_thumbnail' )); ?>
<h2 class="woocommerce-loop-product__title"> <?php echo esc_html( $product->get_title()); ?> </h2>
<?php
if ( $settings['eael_woo_product_list_rating'] == 'yes' ) {
echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ));
}
if ( ! $product->managing_stock() && ! $product->is_in_stock() ) {
printf( '<span class="outofstock-badge">%s</span>', __( 'Stock <br/> Out', 'essential-addons-for-elementor-lite' ) );
} elseif ( $product->is_on_sale() ) {
printf( '<span class="onsale">%s</span>', __( 'Sale!', 'essential-addons-for-elementor-lite' ) );
}
?>
<span class="price"><?php echo wp_kses_post( $product->get_price_html()); ?></span>
</a>
<?php
woocommerce_template_loop_add_to_cart();
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
self::print_compare_button( $product->get_id() );
}
?>
</li>
<?php
} else if ( $settings['eael_woo_product_list_style_preset'] == 'eael-product-overlay' ) {
?>
<li class="product">
<div class="overlay">
<?php echo $product->get_image( 'woocommerce_thumbnail' ); ?>
<div class="button-wrap clearfix">
<a href="<?php echo esc_url( $product->get_permalink()); ?>" class="product-link"><span class="fas fa-link"></span></a>
<?php
woocommerce_template_loop_add_to_cart();
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
self::print_compare_button( $product->get_id(), 'icon' );
}
?>
</div>
</div>
<h2 class="woocommerce-loop-product__title"><?php echo esc_html( $product->get_title()); ?></h2>
<?php
if ($settings['eael_woo_product_list_rating'] === 'yes') {
echo wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() );
}
if ($product->is_on_sale()){
printf( '<span class="onsale">%s</span>', __( 'Sale!', 'essential-addons-for-elementor-lite' ));
}
?>
<span class="price"> <?php echo $product->get_price_html(); ?> </span>
</li>
<?php
} else {
if ( isset( $settings['show_compare']) && 'yes' === $settings['show_compare'] ) {
add_action( 'woocommerce_after_shop_loop_item', function (){
global $product;
if (!$product) return;
self::print_compare_button( $product->get_id() );
});
}
wc_get_template_part( 'content', 'product' );
}
}
} else {
printf( '<p class="no-posts-found">%</p>', __( 'No products found!', 'essential-addons-for-elementor-lite' ) );
}
wp_reset_postdata();
?>
<?php
return ob_get_clean();
}
}

View File

@@ -0,0 +1,623 @@
<?php
/**
* Template Name: Default
*/
use \Essential_Addons_Elementor\Classes\Helper;
use Essential_Addons_Elementor\Elements\Product_Grid;
use \Elementor\Group_Control_Image_Size;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
if ( has_post_thumbnail() ) {
$settings[ 'eael_image_size_customize' ] = [
'id' => get_post_thumbnail_id(),
];
$settings['eael_image_size_customize_size'] = $settings['eael_product_grid_image_size_size'];
$thumbnail_html = Group_Control_Image_Size::get_attachment_image_html( $settings,'eael_image_size_customize' );
}
$title_tag = isset( $settings['eael_product_grid_title_html_tag'] ) ? Helper::eael_validate_html_tag($settings['eael_product_grid_title_html_tag']) : 'h2';
$should_print_compare_btn = isset( $settings['show_compare'] ) && 'yes' === $settings['show_compare'];
if ( function_exists( 'YITH_WCWL' ) ) {
$should_print_wishlist_btn = isset( $settings['eael_product_grid_wishlist'] ) && 'yes' === $settings['eael_product_grid_wishlist'];
}
// Improvement
$grid_style_preset = isset($settings['eael_product_grid_style_preset']) ? $settings['eael_product_grid_style_preset'] : '';
$list_style_preset = isset($settings['eael_product_list_style_preset']) ? $settings['eael_product_list_style_preset'] : '';
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? esc_attr( $settings['eael_product_sale_badge_alignment'] ) : '';
$sale_badge_preset = isset( $settings['eael_product_sale_badge_preset'] ) ? esc_attr( $settings['eael_product_sale_badge_preset'] ) : '';
// should print vars
$should_print_rating = isset( $settings['eael_product_grid_rating'] ) && 'yes' === $settings['eael_product_grid_rating'];
$should_print_quick_view = isset( $settings['eael_product_grid_quick_view'] ) && 'yes' === $settings['eael_product_grid_quick_view'];
$should_print_image_clickable = isset( $settings['eael_product_grid_image_clickable'] ) && 'yes' === $settings['eael_product_grid_image_clickable'];
$should_print_price = isset( $settings['eael_product_grid_price'] ) && 'yes' === $settings['eael_product_grid_price'];
$should_print_excerpt = isset( $settings['eael_product_grid_excerpt'] ) && ('yes' === $settings['eael_product_grid_excerpt'] && has_excerpt());
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$sale_badge_text = !empty($settings['eael_product_sale_text']) ? $settings['eael_product_sale_text'] : __( 'Sale!', 'essential-addons-for-elementor-lite' );
$stock_out_badge_text = !empty($settings['eael_product_stockout_text']) ?$settings['eael_product_stockout_text'] : __( 'Stock <br/> Out', 'essential-addons-for-elementor-lite' );
$is_show_badge = $settings['eael_show_product_sale_badge'];
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$product_wrapper_classes = implode( " ", apply_filters( 'eael_product_wrapper_class', [], $product->get_id(), 'eicon-woocommerce' ) );
if ( $grid_style_preset == 'eael-product-simple' || $grid_style_preset == 'eael-product-reveal' ) { ?>
<li class="product <?php echo esc_attr( $product_wrapper_classes ); ?>">
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
?>
<div class="eael-product-wrap">
<?php
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo wp_kses_post( $product->get_image( $settings['eael_product_grid_image_size_size'], [ 'loading' => 'eager', 'class'=> 'attachment-woocommerce_thumbnail size-woocommerce_thumbnail wvs-archive-product-image' ] ) );
if ( $should_print_image_clickable ) {
echo '</a>';
}
// printf('<%1$s class="woocommerce-loop-product__title"><a href="%3$s" class="woocommerce-LoopProduct-link woocommerce-loop-product__link woocommerce-loop-product__title_link woocommerce-loop-product__title_link_simple woocommerce-loop-product__title_link_reveal">%2$s</a></%1$s>', $title_tag, $product->get_title(), $product->get_permalink());
echo '<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s class="woocommerce-loop-product__title">%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_rating ) {
echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) );
}
if ( $is_show_badge ){
if ( ! $product->is_in_stock() ) {
printf( '<span class="outofstock-badge ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">%s</span>', $stock_out_badge_text );
} elseif ( $product->is_on_sale() ) {
printf( '<span class="onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">%s</span>', $sale_badge_text );
}
}
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
?>
<?php
woocommerce_template_loop_add_to_cart();
if ( $should_print_compare_btn ) {
Product_Grid::print_compare_button( $product->get_id() );
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<div class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</div>';
}
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</div>
</li>
<?php
} else if ( $grid_style_preset == 'eael-product-overlay' ) {
?>
<li <?php post_class( "product {$product_wrapper_classes}" ); ?>>
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
?>
<div class="overlay">
<?php
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo $product->get_image( $settings['eael_product_grid_image_size_size'], [ 'loading' => 'eager' ] );
if ( $should_print_image_clickable ) {
echo '</a>';
}
?>
<div class="button-wrap clearfix">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="product-link"><span class="fas fa-link"></span></a>
<?php
woocommerce_template_loop_add_to_cart();
if ( $should_print_compare_btn ) {
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<div class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</div>';
}
?>
</div>
</div>
<?php
// printf('<%1$s class="woocommerce-loop-product__title"><a href="%3$s" class="woocommerce-LoopProduct-link woocommerce-loop-product__link woocommerce-loop-product__title_link woocommerce-loop-product__title_link_overlay">%2$s</a></%1$s>', $title_tag, $product->get_title(), $product->get_permalink());
echo '<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s class="woocommerce-loop-product__title">%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_rating ) {
echo wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() );
}
if ( $is_show_badge ) {
if ( ! $product->is_in_stock() ) {
printf( '<span class="outofstock-badge ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">%s</span>', $stock_out_badge_text );
} elseif ( $product->is_on_sale() ) {
printf( '<span class="onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">%s</span>', $sale_badge_text );
}
}
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</li>
<?php
} else if (($grid_style_preset == 'eael-product-preset-5') || ($grid_style_preset == 'eael-product-preset-6') || ($grid_style_preset == 'eael-product-preset-7')) {
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( "product {$product_wrapper_classes}" ); ?>>
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
?>
<div class="eael-product-wrap">
<div class="product-image-wrap">
<div class="image-wrap">
<?php
if ( $is_show_badge ) {
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $stock_out_badge_text . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $sale_badge_text . '</span>' : '' ) );
}
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo wp_kses_post( $product->get_image( $settings['eael_product_grid_image_size_size'], [ 'loading' => 'eager' ] ) );
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
<div class="image-hover-wrap">
<?php if($grid_style_preset == 'eael-product-preset-5'){ ?>
<ul class="icons-wrap block-style">
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-grid-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<?php
if ( $should_print_compare_btn ) {
echo '<li class="add-to-compare">';
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
echo '</li>';
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<li class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</li>';
}
?>
<li class="view-details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
</ul>
<?php } elseif ($grid_style_preset == 'eael-product-preset-7') { ?>
<ul class="icons-wrap block-box-style">
<li class="add-to-cart"><?php
woocommerce_template_loop_add_to_cart(); ?></li>
<?php
if ( $should_print_compare_btn ) {
echo '<li class="add-to-compare">';
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
echo '</li>';
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<li class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</li>';
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-grid-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details"><?php echo '<a href="' . $product->get_permalink
() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
<?php } else { ?>
<ul class="icons-wrap box-style">
<li class="add-to-cart"><?php
woocommerce_template_loop_add_to_cart();
?></li>
<?php
if ( $should_print_compare_btn ) {
echo '<li class="add-to-compare">';
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
echo '</li>';
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<li class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</li>';
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-grid-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details" title="Details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
<?php }
?>
</div>
</div>
<div class="product-details-wrap">
<?php
if(($grid_style_preset == 'eael-product-preset-7') && $should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
?>
<div class="eael-product-title">
<?php
echo '<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>';
?>
<?php //printf('<%1$s><a href="%3$s" class="woocommerce-LoopProduct-link woocommerce-loop-product__link woocommerce-loop-product__title_link woocommerce-loop-product__title_link_simple woocommerce-loop-product__title_link_reveal">%2$s</a></%1$s>', $title_tag, $product->get_title(), $product->get_permalink()); ?>
</div>
<?php if(($grid_style_preset != 'eael-product-preset-7') && $should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}?>
</div>
</div>
<?php
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</li>
<?php
}
} else if ($grid_style_preset == 'eael-product-preset-8') {
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( "product {$product_wrapper_classes}" ); ?>>
<div class="eael-product-wrap">
<div class="product-image-wrap">
<div class="image-wrap">
<?php
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
if ( $is_show_badge ) {
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $stock_out_badge_text . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $sale_badge_text . '</span>' : '' ) );
}
echo $product->get_image($settings['eael_product_grid_image_size_size'], ['loading' => 'eager']);
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
<div class="image-hover-wrap">
<ul class="icons-wrap over-box-style">
<li class="add-to-cart"><?php
woocommerce_template_loop_add_to_cart(); ?>
</li>
<?php
if ( $should_print_compare_btn ) {
echo '<li class="add-to-compare">';
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
echo '</li>';
}
?>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<li class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</li>';
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-grid-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
</ul>
</div>
</div>
<div class="product-details-wrap">
<?php
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
?>
<div class="eael-product-title">
<?php
echo '<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>';
?>
</div>
</div>
</div>
</li>
<?php
}
} else if(($list_style_preset == 'eael-product-list-preset-1') ||
($list_style_preset == 'eael-product-list-preset-2') ||
($list_style_preset == 'eael-product-list-preset-3') ||
($list_style_preset == 'eael-product-list-preset-4')) {
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li class="product <?php echo esc_attr( "{$product_wrapper_classes} {$list_style_preset}" ) ?>">
<div class="eael-product-wrap">
<div class="product-image-wrap">
<div class="image-wrap">
<?php
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
if ( $is_show_badge ) {
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $stock_out_badge_text . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . $sale_badge_text . '</span>' : '' ) );
}
echo wp_kses_post( $product->get_image( $settings['eael_product_grid_image_size_size'], [ 'loading' => 'eager' ] ) );
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
</div>
<div class="product-details-wrap">
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
if ($list_style_preset == 'eael-product-list-preset-2') {
echo '<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words(strip_shortcodes(get_the_excerpt()), $settings['eael_product_grid_excerpt_length'], $settings['eael_product_grid_excerpt_expanison_indicator']) . '</p>';
echo '</div>';
}
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
} elseif ($list_style_preset == 'eael-product-list-preset-3') {
echo '<div class="price-wrap">';
if ($should_print_price) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
echo '</div>
<div class="title-wrap">
<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words(strip_shortcodes(get_the_excerpt() ? get_the_excerpt() :
get_the_content()), $settings['eael_product_grid_excerpt_length'], $settings['eael_product_grid_excerpt_expanison_indicator']) . '</p>';
echo '</div>';
}
echo '</div>';
} elseif ($list_style_preset == 'eael-product-list-preset-4') {
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
echo '<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words(strip_shortcodes(get_the_excerpt() ? get_the_excerpt() :
get_the_content()), $settings['eael_product_grid_excerpt_length'], $settings['eael_product_grid_excerpt_expanison_indicator']) . '</p>';
echo '</div>';
}
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
} else {
echo '<div class="eael-product-title">
<a href="' . esc_url( $product->get_permalink() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ));
echo '</a>
</div>';
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words(strip_shortcodes(get_the_excerpt() ? get_the_excerpt() :
get_the_content()), $settings['eael_product_grid_excerpt_length'], $settings['eael_product_grid_excerpt_expanison_indicator']) . '</p>';
echo '</div>';
};
}
?>
<ul class="icons-wrap <?php echo esc_attr( $settings['eael_product_action_buttons_preset'] ); ?>">
<?php
if ( $should_print_compare_btn ) {
echo '<li class="add-to-compare">';
Product_Grid::print_compare_button( $product->get_id(), 'icon' );
echo '</li>';
}
?>
<li class="add-to-cart"><?php
woocommerce_template_loop_add_to_cart(); ?></li>
<?php
if ( ! empty( $should_print_wishlist_btn ) ) {
echo '<li class="add-to-whishlist">';
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</li>';
}
?>
<?php
if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-grid-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
</ul>
<?php
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</div>
</div>
</li>
<?php
}
}else {
if($settings['eael_product_grid_rating']!='yes'){
remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop_rating',5);
}
add_action('woocommerce_before_shop_loop_item_title',function(){
global $product;
if ( ! $product->is_in_stock() ) {
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
echo '<span class="outofstock-badge">'.__('Stock ', 'essential-addons-for-elementor-lite'). '<br />' . __('Out', 'essential-addons-for-elementor-lite').'</span>';
}
},9);
if ( $should_print_compare_btn ) {
add_action( 'woocommerce_after_shop_loop_item', [
'\Essential_Addons_Elementor\Elements\Product_Grid',
'print_compare_button',
] );
}
$thumb_size = isset($settings['eael_product_grid_image_size_size']) ? $settings['eael_product_grid_image_size_size'] : '';
global $eael_thumb_default;
add_filter( 'single_product_archive_thumbnail_size', function($size)use($thumb_size){
global $eael_thumb_default;
$eael_thumb_default = $size;
return $thumb_size != '' ? $thumb_size : $size ;
});
wc_get_template_part( 'content', 'product' );
add_filter( 'single_product_archive_thumbnail_size', function($size){
global $eael_thumb_default;
return !empty($eael_thumb_default) ? $eael_thumb_default : $size;
});
if ( $should_print_compare_btn ) {
remove_action( 'woocommerce_after_shop_loop_item', [
'\Essential_Addons_Elementor\Elements\Product_Grid',
'print_compare_button',
] );
}
}

View File

@@ -0,0 +1,383 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
use \Elementor\Group_Control_Image_Size;
/**
* Template Name: Default
*/
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
if (has_post_thumbnail() && $settings['eael_show_image'] == 'yes') {
$settings[ 'eael_image_size_customize' ] = [
'id' => get_post_thumbnail_id(),
];
$settings['eael_image_size_customize_size'] = $settings['image_size'];
$thumbnail_html = Group_Control_Image_Size::get_attachment_image_html( $settings,'eael_image_size_customize' );
}
$enable_ratio = $settings['enable_postgrid_image_ratio'] == 'yes' ? 'eael-image-ratio':'';
$title_tag = isset($settings['title_tag']) ? Helper::eael_validate_html_tag($settings['title_tag']) : 'h2';
if ($settings['eael_post_grid_preset_style'] === 'two') {
echo '<article class="eael-grid-post eael-post-grid-column" data-id="' . get_the_ID() . '">
<div class="eael-grid-post-holder">
<div class="eael-grid-post-holder-inner">';
if (has_post_thumbnail() && $settings['eael_show_image'] == 'yes') {
echo '<div class="eael-entry-media">';
if ( 'yes' === $settings['eael_show_post_terms'] && 'yes' === $settings['eael_post_terms_on_image_hover'] ) {
echo Helper::get_terms_as_list($settings['eael_post_terms'], $settings['eael_post_terms_max_length']);
}
echo '<div class="eael-entry-overlay ' . esc_attr( $settings['eael_post_grid_hover_animation'] ) . '">';
if (isset($settings['eael_post_grid_bg_hover_icon_new']['url'])) {
echo '<img src="' . esc_url($settings['eael_post_grid_bg_hover_icon_new']['url']) . '" alt="' . esc_attr(get_post_meta($settings['eael_post_grid_bg_hover_icon_new']['id'], '_wp_attachment_image_alt', true)) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['eael_post_grid_bg_hover_icon_new']['value'] ) . '" aria-hidden="true"></i>';
}
echo '<a href="' . get_the_permalink() . '"' . $link_settings['image_link_nofollow'] . '' . $link_settings['image_link_target_blank'] . '></a>';
echo '</div>';
echo '<div class="eael-entry-thumbnail '.$enable_ratio.'">
'.$thumbnail_html.'
</div>
</div>';
}
if ($settings['eael_show_title'] || $settings['eael_show_meta'] || $settings['eael_show_excerpt']) {
echo '<div class="eael-entry-wrapper">';
if ($settings['eael_show_title']) {
echo '<header class="eael-entry-header"><' . $title_tag . ' class="eael-entry-title">';
echo '<a
class="eael-grid-post-link"
href="' . get_the_permalink() . '"
title="' . get_the_title() . '"' . $link_settings['title_link_nofollow'] . '' . $link_settings['title_link_target_blank'] . '>';
if (empty($settings['eael_title_length'])) {
echo get_the_title();
} else {
echo implode(" ", array_slice(explode(" ", get_the_title()), 0, $settings['eael_title_length']));
}
echo '</a>';
echo '</' . $title_tag . '></header>';
}
if ($settings['meta_position'] == 'meta-entry-header') {
echo '<div class="eael-entry-header-after style-two">';
if ( isset( $settings['eael_show_avatar_two'] ) && 'yes' === $settings['eael_show_avatar_two'] ) {
echo '<div class="eael-author-avatar"><a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_avatar(get_the_author_meta('ID'), 96, '', get_the_author_meta( 'display_name' ) ) . '</a></div>';
}
if ($settings['eael_show_meta']) {
echo '<div class="eael-entry-meta">';
if ( isset( $settings['eael_show_author_two'] ) && 'yes' === $settings['eael_show_author_two'] ) {
echo '<span class="eael-posted-by">' . get_the_author_posts_link() . '</span>';
}
if ($settings['eael_show_date'] === 'yes') {
echo '<span class="eael-posted-on eael-meta-posted-on"><i class="far fa-clock"></i><time datetime="' . get_the_date() . '">' . get_the_date() . '</time></span>';
}
echo '</div>';
}
echo '</div>';
}
if ($settings['eael_show_excerpt'] || $settings['eael_show_read_more_button']) {
echo '<div class="eael-entry-content">
<div class="eael-grid-post-excerpt">';
if ($settings['eael_show_excerpt']) {
if (empty($settings['eael_excerpt_length'])) {
echo '<p>' . strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()) . '</p>';
} else {
echo '<p>' . wp_trim_words( strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()), $settings['eael_excerpt_length'], $settings['excerpt_expanison_indicator'] ) . '</p>';
}
}
if ($settings['eael_show_read_more_button']) {
echo '<a
href="' . get_the_permalink() . '"
class="eael-post-elements-readmore-btn"' . $link_settings['read_more_link_nofollow'] . '' . $link_settings['read_more_link_target_blank'] . '>' . Helper::eael_wp_kses($settings['read_more_button_text']) . '</a>';
}
echo '</div>
</div>';
}
if ($settings['meta_position'] == 'meta-entry-footer') {
echo '<div class="eael-entry-header-after style-two">';
if ( isset( $settings['eael_show_avatar_two'] ) && 'yes' === $settings['eael_show_avatar_two'] ) {
echo '<div class="eael-author-avatar"><a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_avatar(get_the_author_meta('ID'), 96, '', get_the_author_meta( 'display_name' ) ) . '</a></div>';
}
echo '<div class="eael-entry-meta">';
if ( isset( $settings['eael_show_author_two'] ) && 'yes' === $settings['eael_show_author_two'] ) {
echo '<span class="eael-posted-by style-two-footer">' . get_the_author_posts_link() . '</span>';
}
if ( 'yes' === $settings['eael_show_date'] ) {
echo '<span class="eael-meta-posted-on"><i class="far fa-clock"></i><time datetime="' . get_the_date() . '">' . get_the_date() . '</time></span>';
}
if ( 'yes' === $settings['eael_show_post_terms'] ) {
if ($settings['eael_post_terms'] === 'category') {
$terms = get_the_category();
}
if ($settings['eael_post_terms'] === 'tags') {
$terms = get_the_tags();
}
//For custom post type
$get_custom_post_type = get_post_type( get_the_ID() ); //post
$get_custom_taxonomy = $settings["eael_{$get_custom_post_type}_terms"]; //tags
if( 'post' !== $get_custom_post_type && $settings[ 'eael_post_terms' ] === $get_custom_taxonomy ) {
$terms = wp_get_post_terms( get_the_ID(), $get_custom_taxonomy );
}
if (!empty($terms)) {
$html = '<ul class="post-meta-categories">';
$count = 0;
foreach ($terms as $term) {
if ($count === intval($settings['eael_post_terms_max_length'])) {
break;
}
if ($count === 0) {
$html .= '<li class="meta-cat-icon"><i class="far fa-folder-open"></i></li>';
}
$is_last_item = $count + 1 === intval($settings['eael_post_terms_max_length']) || $count + 1 === count( (array) $terms);
if ( ! empty( $term->name ) ) {
$eael_post_terms_separator = ! empty( $settings['eael_post_terms_separator'] ) ? wp_strip_all_tags( $settings['eael_post_terms_separator'] ) : '';
$eael_post_terms_separator = $is_last_item ? '' : $eael_post_terms_separator;
}
$link = ($settings['eael_post_terms'] === 'category') ? get_category_link($term->term_id) : get_tag_link($term->term_id);
$html .= '<li>';
$html .= '<a href="' . esc_url($link) . '">';
$html .= $term->name . " " . esc_html( $eael_post_terms_separator );
$html .= '</a>';
$html .= '</li>';
$count++;
}
$html .= '</ul>';
echo $html;
}
}
echo '</div>';
echo '</div>';
}
echo '</div>';
}
echo '</div>
</div>
</article>';
} else if ($settings['eael_post_grid_preset_style'] === 'three') {
echo '<article class="eael-grid-post eael-post-grid-column" data-id="' . get_the_ID() . '">
<div class="eael-grid-post-holder">
<div class="eael-grid-post-holder-inner">';
if (has_post_thumbnail() && $settings['eael_show_image'] == 'yes') {
echo '<div class="eael-entry-media">';
if ( 'yes' === $settings['eael_show_post_terms'] && 'yes' === $settings['eael_post_terms_on_image_hover'] ) {
echo Helper::get_terms_as_list($settings['eael_post_terms'], $settings['eael_post_terms_max_length']);
}
echo '<div class="eael-entry-overlay ' . esc_attr( $settings['eael_post_grid_hover_animation'] ) . '">';
if (isset($settings['eael_post_grid_bg_hover_icon_new']['url'])) {
echo '<img src="' . esc_url($settings['eael_post_grid_bg_hover_icon_new']['url']) . '" alt="' . esc_attr(get_post_meta($settings['eael_post_grid_bg_hover_icon_new']['id'], '_wp_attachment_image_alt', true)) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['eael_post_grid_bg_hover_icon_new']['value'] ) . '" aria-hidden="true"></i>';
}
echo '<a href="' . get_the_permalink() . '"' . $link_settings['image_link_nofollow'] . '' . $link_settings['image_link_target_blank'] . '></a>';
echo '</div>';
echo '<div class="eael-entry-thumbnail '.$enable_ratio.'">
'.$thumbnail_html.'
</div>
</div>';
if ($settings['meta_position'] == 'meta-entry-header' && $settings['eael_show_date'] === 'yes') {
echo '<span class="eael-meta-posted-on"><time datetime="' . get_the_date() . '"><span>' . get_the_date('d') . '</span>' . get_the_date('F') . '</time></span>';
}
}
if ($settings['eael_show_title'] || $settings['eael_show_meta'] || $settings['eael_show_excerpt']) {
echo '<div class="eael-entry-wrapper">';
if ($settings['eael_show_title']) {
echo '<header class="eael-entry-header"><' . $title_tag . ' class="eael-entry-title">';
echo '<a
class="eael-grid-post-link"
href="' . get_the_permalink() . '"
title="' . get_the_title() . '"' . $link_settings['title_link_nofollow'] . '' . $link_settings['title_link_target_blank'] . '>';
if (empty($settings['eael_title_length'])) {
echo get_the_title();
} else {
echo implode(" ", array_slice(explode(" ", get_the_title()), 0, $settings['eael_title_length']));
}
echo '</a>';
/*
* used Helper::eael_validate_html_tag() method to validate $title_tag
*/
echo '</' . $title_tag . '></header>';
}
if ($settings['meta_position'] == 'meta-entry-footer') {
if ($settings['eael_show_meta']) {
echo '<div class="eael-entry-meta">';
if ( isset( $settings['eael_show_author_three'] ) && 'yes' === $settings['eael_show_author_three'] ) {
echo '<span class="eael-posted-by">' . get_the_author_posts_link() . '</span>';
}
if ($settings['eael_show_date'] === 'yes') {
echo '<span class="eael-posted-on"><time datetime="' . get_the_date() . '">' . get_the_date() . '</time></span>';
}
echo '</div>';
}
}
if ($settings['eael_show_excerpt'] || $settings['eael_show_read_more_button']) {
echo '<div class="eael-entry-content">
<div class="eael-grid-post-excerpt">';
if ($settings['eael_show_excerpt']) {
if (empty($settings['eael_excerpt_length'])) {
echo '<p>' . strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()) . '</p>';
} else {
echo '<p>' . wp_trim_words( strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()), $settings['eael_excerpt_length'], $settings['excerpt_expanison_indicator']) . '</p>';
}
}
if ($settings['eael_show_read_more_button']) {
echo '<a
href="' . get_the_permalink() . '"
class="eael-post-elements-readmore-btn"' . $link_settings['read_more_link_nofollow'] . '' . $link_settings['read_more_link_target_blank'] . '>' . Helper::eael_wp_kses($settings['read_more_button_text']) . '</a>';
}
echo '</div>
</div>';
}
echo '</div>';
}
echo '</div>
</div>
</article>';
} else {
echo '<article class="eael-grid-post eael-post-grid-column" data-id="' . esc_attr( get_the_ID() ) . '">
<div class="eael-grid-post-holder">
<div class="eael-grid-post-holder-inner">';
if (has_post_thumbnail() && $settings['eael_show_image'] == 'yes') {
echo '<div class="eael-entry-media">';
if ( 'yes' === $settings['eael_show_post_terms'] && 'yes' === $settings['eael_post_terms_on_image_hover'] ) {
echo Helper::get_terms_as_list($settings['eael_post_terms'], $settings['eael_post_terms_max_length']);
}
echo '<div class="eael-entry-overlay ' . esc_attr( $settings['eael_post_grid_hover_animation'] ) . '">';
if (isset($settings['eael_post_grid_bg_hover_icon_new']['url'])) {
echo '<img src="' . esc_url($settings['eael_post_grid_bg_hover_icon_new']['url']) . '" alt="' . esc_attr(get_post_meta($settings['eael_post_grid_bg_hover_icon_new']['id'], '_wp_attachment_image_alt', true)) . '" />';
} else {
if (($settings['eael_post_grid_bg_hover_icon_new']['library']) == 'svg') {
echo '<img src="' . esc_url($settings['eael_post_grid_bg_hover_icon_new']['value']['url']) . '" alt="' . esc_attr(get_post_meta($settings['eael_post_grid_bg_hover_icon_new']['value']['id'], '_wp_attachment_image_alt', true)) . '" />';
} else {
echo '<i class="' . esc_attr( $settings['eael_post_grid_bg_hover_icon_new']['value'] ) . '" aria-hidden="true"></i>';
}
}
echo '<a href="' . get_the_permalink() . '"' . $link_settings['image_link_nofollow'] . '' . $link_settings['image_link_target_blank'] . '></a>';
echo '</div>';
echo '<div class="eael-entry-thumbnail '.$enable_ratio.'">
'.$thumbnail_html.'
</div>
</div>';
}
if ($settings['eael_show_title'] || $settings['eael_show_meta'] || $settings['eael_show_excerpt']) {
echo '<div class="eael-entry-wrapper">';
if ($settings['eael_show_title']) {
echo '<header class="eael-entry-header"><' . $title_tag . ' class="eael-entry-title">';
echo '<a
class="eael-grid-post-link"
href="' . get_the_permalink() . '"
title="' . get_the_title() . '"' . $link_settings['title_link_nofollow'] . '' . $link_settings['title_link_target_blank'] . '>';
if (empty($settings['eael_title_length'])) {
echo get_the_title();
} else {
echo implode(" ", array_slice(explode(" ", get_the_title()), 0, $settings['eael_title_length']));
}
echo '</a>';
echo '</' . $title_tag . '></header>';
}
if ($settings['meta_position'] == 'meta-entry-header') {
echo '<div class="eael-entry-header-after">';
if ( isset( $settings['eael_show_avatar'] ) && 'yes' === $settings['eael_show_avatar'] ) {
echo '<div class="eael-author-avatar"><a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_avatar(get_the_author_meta('ID'), 96, '', get_the_author_meta( 'display_name' ) ) . '</a></div>';
}
if ($settings['eael_show_meta']) {
echo '<div class="eael-entry-meta">';
if ( isset( $settings['eael_show_author'] ) && 'yes' === $settings['eael_show_author'] ) {
echo '<span class="eael-posted-by">' . get_the_author_posts_link() . '</span>';
}
if ($settings['eael_show_date'] === 'yes') {
echo '<span class="eael-posted-on"><time datetime="' . get_the_date() . '">' . get_the_date() . '</time></span>';
}
echo '</div>';
}
echo '</div>';
}
if ($settings['eael_show_excerpt'] || $settings['eael_show_read_more_button']) {
echo '<div class="eael-entry-content">
<div class="eael-grid-post-excerpt">';
if ($settings['eael_show_excerpt']) {
if (empty($settings['eael_excerpt_length'])) {
echo '<p>' . strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()) . '</p>';
} else {
echo '<p>' . wp_trim_words( strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()), $settings['eael_excerpt_length'], $settings['excerpt_expanison_indicator']) . '</p>';
}
}
if ($settings['eael_show_read_more_button']) {
echo '<a
href="' . get_the_permalink() . '"
class="eael-post-elements-readmore-btn"' . $link_settings['read_more_link_nofollow'] . '' . $link_settings['read_more_link_target_blank'] . '>' . Helper::eael_wp_kses($settings['read_more_button_text']) . '</a>';
}
echo '</div>
</div>';
}
if ($settings['eael_show_meta'] && $settings['meta_position'] == 'meta-entry-footer') {
echo '<div class="eael-entry-footer">';
if ( isset( $settings['eael_show_avatar'] ) && 'yes' === $settings['eael_show_avatar'] ) {
echo '<div class="eael-author-avatar"><a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_avatar(get_the_author_meta('ID'), 96, '', get_the_author_meta( 'display_name' ) ) . '</a></div>';
}
if ($settings['eael_show_meta']) {
echo '<div class="eael-entry-meta">';
if ( isset( $settings['eael_show_author'] ) && 'yes' === $settings['eael_show_author'] ) {
echo '<span class="eael-posted-by">' . get_the_author_posts_link() . '</span>';
}
if ($settings['eael_show_date'] === 'yes') {
echo '<span class="eael-posted-on"><time datetime="' . get_the_date() . '">' . get_the_date() . '</time></span>';
}
echo '</div>';
}
echo '</div>';
}
echo '</div>';
}
echo '</div>
</div>
</article>';
}

View File

@@ -0,0 +1,52 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Card
*/
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
$image = '';
if ($settings['eael_show_image'] == 'yes' && has_post_thumbnail()) {
$image = '<div class="eael-timeline-post-image" style="background-image: url('. wp_get_attachment_image_url
(get_post_thumbnail_id(),
$settings['image_size']) .')"></div>';
}
$title_tag = isset($settings['title_tag']) ? Helper::eael_validate_html_tag($settings['title_tag']) : 'h2';
echo '<article class="eael-timeline-post">
<div class="eael-timeline-bullet"></div>
<div class="eael-timeline-post-inner">
<a class="eael-timeline-post-link" href="' . get_the_permalink() . '" title="' . esc_html(get_the_title()) . '"' . ($settings['timeline_link_nofollow'] ? 'rel="nofollow"' : '') .'' . ($settings['timeline_link_target_blank'] ? 'target="_blank"' : '') . '>
<time datetime="' . get_the_date() . '">' . get_the_date() . '</time>
'. $image;
if( $settings['eael_show_title'] || $settings['eael_show_excerpt'] ) {
echo '<div class="eael-timeline-content">';
if ( $settings['eael_show_title'] ) {
echo '<div class="eael-timeline-post-title">
<' . $title_tag . ' class="' . esc_attr( 'eael-timeline-post-title-text-card' ) . '" >' . get_the_title() . '</'.$title_tag.'>
</div>';
}
if ( $settings['eael_show_excerpt'] ) {
echo '<div class="eael-timeline-post-excerpt">';
if ( empty( $settings['eael_excerpt_length'] ) ) {
echo '<p>' . strip_shortcodes( get_the_excerpt() ? get_the_excerpt() : get_the_content() ) . '</p>';
} else {
echo '<p>' . wp_trim_words( strip_shortcodes( get_the_excerpt() ? get_the_excerpt() : get_the_content() ), $settings['eael_excerpt_length'], $settings['expanison_indicator'] ) . '</p>';
}
echo '</div>';
}
echo '</div>';
}
echo '</a>
</div>
<div class="eael-timeline-clear"></div>
</article>';

View File

@@ -0,0 +1,46 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Default
*/
use Elementor\Group_Control_Image_Size;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
$post_timeline_image_url = Group_Control_Image_Size::get_attachment_image_src( get_post_thumbnail_id(),
'image', $settings );
$image_size = sanitize_html_class( $settings['image_size'] );
$image_class = " attachment-$image_size size-$image_size";
$title_tag = isset($settings['title_tag']) ? Helper::eael_validate_html_tag($settings['title_tag']) : 'h2';
echo '<article class="eael-timeline-post eael-timeline-column">
<div class="eael-timeline-bullet"></div>
<div class="eael-timeline-post-inner">
<a class="eael-timeline-post-link" href="' . get_the_permalink() . '" title="' . esc_attr(get_the_title()) . '"' . ($settings['timeline_link_nofollow'] ? 'rel="nofollow"' : '') .'' . ($settings['timeline_link_target_blank'] ? 'target="_blank"' : '') . '>
<time datetime="' . get_the_date() . '">' . get_the_date() . '</time>
<div class="eael-timeline-post-image'.$image_class.'" ' . ($settings['eael_show_image'] == 'yes' ? 'style="background-image: url('.esc_url( $post_timeline_image_url ).');"' : null) . '></div>';
if ($settings['eael_show_excerpt']) {
echo '<div class="eael-timeline-post-excerpt">';
if(empty($settings['eael_excerpt_length'])) {
echo '<p>'.strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()).'</p>';
}else {
echo '<p>' . wp_trim_words(strip_shortcodes(get_the_excerpt() ? get_the_excerpt() : get_the_content()), intval( $settings['eael_excerpt_length'] ), sanitize_text_field( $settings['expanison_indicator'] )) . '</p>';
}
echo '</div>';
}
if ($settings['eael_show_title']) {
echo '<div class="eael-timeline-post-title">
<' . Helper::eael_validate_html_tag( $settings['title_tag'] ) . ' class="eael-timeline-post-title-text">' . get_the_title() . '</' . Helper::eael_validate_html_tag( $settings['title_tag'] ) . '>
</div>';
}
echo '</a>
</div>
</article>';

View File

@@ -0,0 +1,125 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Preset 1
*/
use Essential_Addons_Elementor\Elements\Woo_Product_carousel;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
// Improvement
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
$sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
$sale_text = !empty($settings['eael_product_carousel_sale_text']) ? $settings['eael_product_carousel_sale_text'] : 'Sale!';
$stockout_text = !empty($settings['eael_product_carousel_stockout_text']) ? $settings['eael_product_carousel_stockout_text'] : 'Stock Out';
// should print vars
$should_print_rating = isset( $settings['eael_product_carousel_rating'] ) && 'yes' === $settings['eael_product_carousel_rating'];
$should_print_quick_view = isset( $settings['eael_product_carousel_quick_view'] ) && 'yes' === $settings['eael_product_carousel_quick_view'];
$should_print_image_clickable = isset( $settings['eael_product_carousel_image_clickable'] ) && 'yes' === $settings['eael_product_carousel_image_clickable'];
$should_print_title_clickable = isset( $settings['eael_product_carousel_title_clickable'] ) && 'yes' === $settings['eael_product_carousel_title_clickable'];
$should_print_price = isset( $settings['eael_product_carousel_price'] ) && 'yes' === $settings['eael_product_carousel_price'];
$should_print_excerpt = isset( $settings['eael_product_carousel_excerpt'] ) && ('yes' === $settings['eael_product_carousel_excerpt'] && has_excerpt());
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$product_details_wrap_show = ! empty( $settings['eael_product_carousel_show_title'] ) || $should_print_price || $should_print_rating || $should_print_excerpt;
$product_details_none_class = $product_details_wrap_show ? '' : 'product-details-none';
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( ['product', 'swiper-slide'] ); ?>>
<div class="eael-product-carousel <?php echo esc_attr( $product_details_none_class ); ?>">
<div class="product-image-wrap">
<div class="image-wrap">
<?php
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $stockout_text ) . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $sale_text ) . '</span>' : '' ) );
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo $product->get_image($settings['eael_product_carousel_image_size_size'], ['loading' => 'eager']);
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
<div class="image-hover-wrap">
<ul class="icons-wrap box-style">
<?php if( $settings[ 'eael_product_carousel_show_add_to_cart' ] ) { ?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details" title="Details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
<?php
?>
</div>
</div>
<div class="product-details-wrap">
<div class="product-details">
<?php
if ( $settings['eael_product_carousel_show_title'] ) {
echo '<div class="eael-product-title">';
if( $should_print_title_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo '<' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if ( empty( $settings['eael_product_carousel_title_length'] ) ) {
echo Helper::eael_wp_kses( $product->get_title() );
} else {
echo implode( " ", array_slice( explode( " ", Helper::eael_wp_kses($product->get_title()) ), 0, $settings['eael_product_carousel_title_length'] ) );
}
echo '</' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if( $should_print_title_clickable ) {
echo '</a>';
}
echo '</div>';
}
?>
<?php if ($should_print_rating) {
echo wc_get_rating_html($product->get_average_rating(), $product->get_rating_count());
}
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words( strip_shortcodes( get_the_excerpt() ), $settings['eael_product_carousel_excerpt_length'],
esc_html( $settings['eael_product_carousel_excerpt_expanison_indicator'] ) ) . '</p>';
echo '</div>';
}
?>
</div>
<?php if($should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}?>
</div>
</div>
</li>
<?php
}

View File

@@ -0,0 +1,126 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Preset 2
*/
use Essential_Addons_Elementor\Elements\Woo_Product_Carousel;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
// Improvement
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
$sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
$sale_text = !empty($settings['eael_product_carousel_sale_text']) ? $settings['eael_product_carousel_sale_text'] : 'Sale!';
$stockout_text = !empty($settings['eael_product_carousel_stockout_text']) ? $settings['eael_product_carousel_stockout_text'] : 'Stock Out';
// should print vars
$should_print_rating = isset( $settings['eael_product_carousel_rating'] ) && 'yes' === $settings['eael_product_carousel_rating'];
$should_print_quick_view = isset( $settings['eael_product_carousel_quick_view'] ) && 'yes' === $settings['eael_product_carousel_quick_view'];
$should_print_image_clickable = isset( $settings['eael_product_carousel_image_clickable'] ) && 'yes' === $settings['eael_product_carousel_image_clickable'];
$should_print_title_clickable = isset( $settings['eael_product_carousel_title_clickable'] ) && 'yes' === $settings['eael_product_carousel_title_clickable'];
$should_print_price = isset( $settings['eael_product_carousel_price'] ) && 'yes' === $settings['eael_product_carousel_price'];
$should_print_excerpt = isset( $settings['eael_product_carousel_excerpt'] ) && ('yes' === $settings['eael_product_carousel_excerpt'] && has_excerpt());
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$product_details_wrap_show = ! empty( $settings['eael_product_carousel_show_title'] ) || $should_print_price || $should_print_rating || $should_print_excerpt;
$product_details_none_class = $product_details_wrap_show ? '' : 'product-details-none-overlay';
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( ['product', 'swiper-slide'] ); ?>>
<div class="eael-product-carousel <?php echo esc_attr( $product_details_none_class ); ?>">
<div class="carousel-overlay <?php echo $should_print_image_clickable ? 'eael-img-clickable' : ''; ?>"></div>
<div class="product-image-wrap">
<div class="image-wrap">
<?php
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $stockout_text ) . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $sale_text ) . '</span>' : '' ) );
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo $product->get_image($settings['eael_product_carousel_image_size_size'], ['loading' => 'eager']);
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
<div class="image-hover-wrap">
<ul class="icons-wrap box-style-list">
<?php if( $settings[ 'eael_product_carousel_show_add_to_cart' ] ) { ?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details" title="Details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
</div>
</div>
<div class="product-overlay-content">
<div class="product-details-wrap">
<div class="eael-product-title-wrap">
<?php
if ( $settings['eael_product_carousel_show_title'] ) {
echo '<div class="eael-product-title">';
if( $should_print_title_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo '<' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if ( empty( $settings['eael_product_carousel_title_length'] ) ) {
echo Helper::eael_wp_kses( $product->get_title() );
} else {
echo implode( " ", array_slice( explode( " ", Helper::eael_wp_kses($product->get_title()) ), 0, $settings['eael_product_carousel_title_length'] ) );
}
echo '</' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if( $should_print_title_clickable ) {
echo '</a>';
}
echo '</div>';
}
?>
<?php if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
} ?>
</div>
<?php if($should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words( strip_shortcodes( get_the_excerpt() ), $settings['eael_product_carousel_excerpt_length'],
esc_html( $settings['eael_product_carousel_excerpt_expanison_indicator'] ) ) . '</p>';
echo '</div>';
}
?>
</div>
</div>
</div>
</li>
<?php
}

View File

@@ -0,0 +1,122 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Preset 3
*/
use Essential_Addons_Elementor\Elements\Woo_Product_carousel;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
// Improvement
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
$sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
$sale_text = !empty($settings['eael_product_carousel_sale_text']) ? $settings['eael_product_carousel_sale_text'] : 'Sale!';
$stockout_text = !empty($settings['eael_product_carousel_stockout_text']) ? $settings['eael_product_carousel_stockout_text'] : 'Stock Out';
// should print vars
$should_print_rating = isset( $settings['eael_product_carousel_rating'] ) && 'yes' === $settings['eael_product_carousel_rating'];
$should_print_quick_view = isset( $settings['eael_product_carousel_quick_view'] ) && 'yes' === $settings['eael_product_carousel_quick_view'];
$should_print_image_clickable = isset( $settings['eael_product_carousel_image_clickable'] ) && 'yes' === $settings['eael_product_carousel_image_clickable'];
$should_print_title_clickable = isset( $settings['eael_product_carousel_title_clickable'] ) && 'yes' === $settings['eael_product_carousel_title_clickable'];
$should_print_price = isset( $settings['eael_product_carousel_price'] ) && 'yes' === $settings['eael_product_carousel_price'];
$should_print_excerpt = isset( $settings['eael_product_carousel_excerpt'] ) && ('yes' === $settings['eael_product_carousel_excerpt'] && has_excerpt());
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$product_details_wrap_show = ! empty( $settings['eael_product_carousel_show_title'] ) || $should_print_price || $should_print_rating || $should_print_excerpt;
$product_details_none_class = $product_details_wrap_show ? '' : 'product-details-none';
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( ['product', 'swiper-slide'] ); ?>>
<div class="eael-product-carousel <?php echo esc_attr( $product_details_none_class ); ?>">
<div class="product-image-wrap">
<div class="image-wrap">
<?php
echo ( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $stockout_text ) . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $sale_text ) . '</span>' : '' ) );
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo $product->get_image($settings['eael_product_carousel_image_size_size'], ['loading' => 'eager']);
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
<div class="image-hover-wrap">
<ul class="icons-wrap block-style">
<?php if( $settings[ 'eael_product_carousel_show_add_to_cart' ] ) { ?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
<?php
?>
</div>
</div>
<div class="product-details-wrap">
<?php
if ( $settings['eael_product_carousel_show_title'] ) {
echo '<div class="eael-product-title">';
if( $should_print_title_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo '<' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if ( empty( $settings['eael_product_carousel_title_length'] ) ) {
echo Helper::eael_wp_kses( $product->get_title() );
} else {
echo implode( " ", array_slice( explode( " ", Helper::eael_wp_kses($product->get_title()) ), 0, $settings['eael_product_carousel_title_length'] ) );
}
echo '</' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if( $should_print_title_clickable ) {
echo '</a>';
}
echo '</div>';
}
?>
<?php if($should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}?>
<?php if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words( strip_shortcodes( get_the_excerpt() ), $settings['eael_product_carousel_excerpt_length'],
esc_html( $settings['eael_product_carousel_excerpt_expanison_indicator'] ) ) . '</p>';
echo '</div>';
}
?>
</div>
</div>
</li>
<?php
}

View File

@@ -0,0 +1,129 @@
<?php
use \Essential_Addons_Elementor\Classes\Helper;
/**
* Template Name: Preset 4
*/
use Essential_Addons_Elementor\Elements\Woo_Product_carousel;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
// Improvement
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
$sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
$sale_text = !empty($settings['eael_product_carousel_sale_text']) ? $settings['eael_product_carousel_sale_text'] : 'Sale!';
$stockout_text = !empty($settings['eael_product_carousel_stockout_text']) ? $settings['eael_product_carousel_stockout_text'] : 'Stock Out';
// should print vars
$should_print_rating = isset( $settings['eael_product_carousel_rating'] ) && 'yes' === $settings['eael_product_carousel_rating'];
$should_print_quick_view = isset( $settings['eael_product_carousel_quick_view'] ) && 'yes' === $settings['eael_product_carousel_quick_view'];
$should_print_image_clickable = isset( $settings['eael_product_carousel_image_clickable'] ) && 'yes' === $settings['eael_product_carousel_image_clickable'];
$should_print_title_clickable = isset( $settings['eael_product_carousel_title_clickable'] ) && 'yes' === $settings['eael_product_carousel_title_clickable'];
$should_print_price = isset( $settings['eael_product_carousel_price'] ) && 'yes' === $settings['eael_product_carousel_price'];
$should_print_excerpt = isset( $settings['eael_product_carousel_excerpt'] ) && ('yes' === $settings['eael_product_carousel_excerpt'] && has_excerpt());
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$product_details_wrap_show = ! empty( $settings['eael_product_carousel_show_title'] ) || $should_print_price || $should_print_rating || $should_print_excerpt;
$product_details_none_class = $product_details_wrap_show ? '' : 'product-details-none-overlay';
if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
?>
<li <?php post_class( ['product', 'swiper-slide'] ); ?>>
<div class="eael-product-carousel <?php echo esc_attr( $product_details_none_class ); ?>">
<div class="carousel-overlay <?php echo $should_print_image_clickable ? 'eael-img-clickable' : ''; ?>"></div>
<div class="product-image-wrap">
<div class="image-wrap">
<?php
echo ( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $stockout_text ) . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . esc_html( $sale_text ) . '</span>' : '' ) );
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo $product->get_image($settings['eael_product_carousel_image_size_size'], ['loading' => 'eager']);
if( $should_print_image_clickable ) {
echo '</a>';
}
?>
</div>
</div>
<div class="product-overlay-content">
<div class="product-details-wrap">
<div class="product-details">
<div class="eael-product-title-wrap">
<?php
if ( $settings['eael_product_carousel_show_title'] ) {
echo '<div class="eael-product-title">';
if( $should_print_title_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo '<' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if ( empty( $settings['eael_product_carousel_title_length'] ) ) {
echo Helper::eael_wp_kses( $product->get_title() );
} else {
echo implode( " ", array_slice( explode( " ", Helper::eael_wp_kses($product->get_title()) ), 0, $settings['eael_product_carousel_title_length'] ) );
}
echo '</' . Helper::eael_validate_html_tag( $settings['eael_product_carousel_title_tag'] ) . '>';
if( $should_print_title_clickable ) {
echo '</a>';
}
echo '</div>';
}
?>
<?php if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
} ?>
</div>
<?php if($should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
} ?>
</div>
<?php if ( $should_print_excerpt ) {
echo '<div class="eael-product-excerpt">';
echo '<p>' . wp_trim_words( strip_shortcodes( get_the_excerpt() ), $settings['eael_product_carousel_excerpt_length'],
esc_html( $settings['eael_product_carousel_excerpt_expanison_indicator'] ) ) . '</p>';
echo '</div>';
}
?>
<div class="buttons-wrap">
<ul class="icons-wrap box-style">
<?php if( $settings[ 'eael_product_carousel_show_add_to_cart' ] ) { ?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php
}
?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<li class="view-details" title="Details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
</ul>
</div>
</div>
</div>
</div>
</li>
<?php
}

View File

@@ -0,0 +1,276 @@
<?php
/**
* Template Name: Default
*/
use \Essential_Addons_Elementor\Classes\Helper;
use Essential_Addons_Elementor\Elements\Woo_Product_Gallery;
use \Elementor\Group_Control_Image_Size;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
if ( has_post_thumbnail() ) {
$settings[ 'eael_image_size_customize' ] = [
'id' => get_post_thumbnail_id(),
];
$settings['eael_image_size_customize_size'] = $settings['eael_product_gallery_image_size_size'];
$thumbnail_html = Group_Control_Image_Size::get_attachment_image_html( $settings,'eael_image_size_customize' );
}
$title_tag = isset( $settings['eael_product_gallery_title_html_tag'] ) ? Helper::eael_validate_html_tag($settings['eael_product_gallery_title_html_tag']) : 'h2';
// Improvement
$gallery_style_preset = isset($settings['eael_product_gallery_style_preset']) ? $settings['eael_product_gallery_style_preset'] : '';
$sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
$sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
// should print vars
$sale_text = !empty($settings['eael_product_gallery_sale_text']) ? $settings['eael_product_gallery_sale_text'] : 'Sale!';
$stockout_text = !empty($settings['eael_product_gallery_stockout_text']) ? $settings['eael_product_gallery_stockout_text'] : 'Stock <br/> Out';
$should_print_rating = isset( $settings['eael_product_gallery_rating'] ) && 'yes' === $settings['eael_product_gallery_rating'];
$should_print_quick_view = isset( $settings['eael_product_gallery_quick_view'] ) && 'yes' === $settings['eael_product_gallery_quick_view'];
$should_print_addtocart = isset( $settings['eael_product_gallery_addtocart_show'] ) && 'yes' === $settings['eael_product_gallery_addtocart_show'];
$should_print_link = isset( $settings['eael_product_gallery_link_show'] ) && 'yes' === $settings['eael_product_gallery_link_show'];
$should_print_image_clickable = isset( $settings['eael_product_gallery_image_clickable'] ) && 'yes' === $settings['eael_product_gallery_image_clickable'];
$should_print_price = isset( $settings['eael_product_gallery_price'] ) && 'yes' === $settings['eael_product_gallery_price'];
$widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
$quick_view_setting = [
'widget_id' => $widget_id,
'product_id' => $product->get_id(),
'page_id' => $settings['eael_page_id'],
];
$show_secondary_image = isset( $settings['eael_product_gallery_show_secondary_image'] ) && 'yes' === $settings['eael_product_gallery_show_secondary_image'];
$image_sources = [
'src' => '',
'src_hover' => ''
];
//if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
$product_wrapper_classes = implode( " ", apply_filters( 'eael_product_wrapper_class', [], $product->get_id(), 'eael-woo-product-gallery' ) );
if ( $gallery_style_preset == 'eael-product-preset-4' ) { ?>
<li class="product <?php echo esc_attr( $product_wrapper_classes ) ?>">
<?php
if($show_secondary_image){
$image_sources = Helper::eael_get_woo_product_gallery_image_srcs( $product, $settings['eael_product_gallery_image_size_size'] );
}
?>
<div class="eael-product-wrap" data-src="<?php echo esc_url( $image_sources['src'] ); ?>" data-src-hover="<?php echo esc_url( $image_sources['src_hover'] ) ?>" >
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ){
do_action( 'woocommerce_before_shop_loop_item' );
}
echo ( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock '. esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) .'">'. Helper::eael_wp_kses($stockout_text) .'</span>' : ($product->is_on_sale() ? '<span class="eael-onsale '. esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) .'">' . Helper::eael_wp_kses($sale_text) . '</span>' : '') );
if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}?>
<?php
echo $product->get_image( $settings['eael_product_gallery_image_size_size'], ['loading' => 'eager', 'alt' => esc_attr( $product->get_title() ) ] );
if ( $should_print_image_clickable ) {
echo '</a>';
}
printf('<%1$s class="woocommerce-loop-product__title">%2$s</%1$s>', $title_tag, Helper::eael_wp_kses($product->get_title()));
if ( $should_print_rating ) {
echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) );
}
if ( $should_print_price ) {
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
?>
<?php
if ( $should_print_addtocart ) {
woocommerce_template_loop_add_to_cart();
}
if ( $settings['eael_wc_loop_hooks'] === 'yes' ){
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</div>
</li>
<?php
} else if (($gallery_style_preset == 'eael-product-preset-3') || ($gallery_style_preset == 'eael-product-preset-2')) {
?>
<li <?php post_class( "product {$product_wrapper_classes}" ); ?>>
<?php
if( $show_secondary_image ){
$image_sources = Helper::eael_get_woo_product_gallery_image_srcs( $product, $settings['eael_product_gallery_image_size_size'] );
}
?>
<div class="eael-product-wrap" data-src="<?php echo esc_url( $image_sources['src'] ); ?>" data-src-hover="<?php echo esc_url( $image_sources['src_hover'] ); ?>" >
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
?>
<div class="product-image-wrap">
<div class="image-wrap">
<?php if( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo ( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock '. esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) .'">'. Helper::eael_wp_kses( $stockout_text ) .'</span>' : ($product->is_on_sale() ? '<span class="eael-onsale '. esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) .'">' . Helper::eael_wp_kses($sale_text) . '</span>' : '') );
echo $product->get_image( $settings['eael_product_gallery_image_size_size'], ['loading' => 'eager', 'alt' => esc_attr( $product->get_title() ) ] );
if( $should_print_image_clickable ) {
echo '</a>';
}?>
</div>
<div class="image-hover-wrap">
<?php if ($gallery_style_preset == 'eael-product-preset-2') { ?>
<ul class="icons-wrap block-box-style">
<?php if( $should_print_addtocart ){?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php } ?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-gallery-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<?php if( $should_print_link ){?>
<li class="view-details"><?php echo '<a href="' . $product->get_permalink() . '" aria-label="View Details about ' . esc_attr( $product->get_title() ) . '"><i class="fas fa-link"></i></a>'; ?></li>
<?php } ?>
</ul>
<?php } else { ?>
<ul class="icons-wrap box-style">
<?php if( $should_print_addtocart ){?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php } ?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-gallery-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<?php if( $should_print_link ){?>
<li class="view-details" title="Details" aria-label="View Details about <?php echo esc_attr( $product->get_title() ); ?>"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
<?php } ?>
</ul>
<?php }
?>
</div>
</div>
<div class="product-details-wrap">
<?php
if(($gallery_style_preset == 'eael-product-preset-2') && $should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}
if ($should_print_rating) {
echo wc_get_rating_html
($product->get_average_rating(), $product->get_rating_count());
}
?>
<div class="eael-product-title">
<?php printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ) ); ?>
</div>
<?php if(($gallery_style_preset != 'eael-product-preset-2') && $should_print_price ){
echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
}?>
</div>
<?php
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</div>
</li>
<?php
} else if ($gallery_style_preset == 'eael-product-preset-1') {
?>
<li <?php post_class( "product {$product_wrapper_classes}" ); ?>>
<?php
if( $show_secondary_image ){
$image_sources = Helper::eael_get_woo_product_gallery_image_srcs( $product, $settings['eael_product_gallery_image_size_size'] );
}
?>
<div class="eael-product-wrap" data-src="<?php echo esc_url( $image_sources['src'] ); ?>" data-src-hover="<?php echo esc_url( $image_sources['src_hover'] ); ?>" >
<?php
do_action( 'eael_woocommerce_before_shop_loop_item' );
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_before_shop_loop_item' );
}
?>
<div class="product-image-wrap">
<div class="image-wrap">
<?php if ( $should_print_image_clickable ) {
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
echo( ! $product->is_in_stock() ? '<span class="eael-onsale outofstock ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . Helper::eael_wp_kses( $stockout_text ) . '</span>' : ( $product->is_on_sale() ? '<span class="eael-onsale ' . esc_attr( $sale_badge_preset . ' ' . $sale_badge_align ) . '">' . Helper::eael_wp_kses( $sale_text ) . '</span>' : '' ) );
echo $product->get_image( $settings['eael_product_gallery_image_size_size'], ['loading' => 'eager', 'alt' => esc_attr( $product->get_title() )] );
if ( $should_print_image_clickable ) {
echo '</a>';
} ?>
</div>
<div class="image-hover-wrap">
<ul class="icons-wrap over-box-style">
<?php if( $should_print_addtocart ){?>
<li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
<?php } ?>
<?php if( $should_print_quick_view ){?>
<li class="eael-product-quick-view">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
class="eael-product-gallery-open-popup open-popup-link">
<i class="fas fa-eye"></i>
</a>
</li>
<?php } ?>
<?php if( $should_print_link ){?>
<li class="view-details"><?php echo '<a href="' . $product->get_permalink() . '" aria-label="View Details about ' . esc_attr( $product->get_title() ) . '" ><i class="fas fa-link"></i></a>'; ?></li>
<?php } ?>
</ul>
</div>
</div>
<div class="product-details-wrap">
<?php
if ( $should_print_price ) {
echo '<div class="eael-product-price">' . $product->get_price_html() . '</div>';
}
?>
<div class="eael-product-title">
<?php
echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
printf('<%1$s>%2$s</%1$s>', $title_tag, Helper::eael_wp_kses( $product->get_title() ) );
echo '</a>';
?>
</div>
</div>
<?php
if ( $settings['eael_wc_loop_hooks'] === 'yes' ) {
do_action( 'woocommerce_after_shop_loop_item' );
}
do_action( 'eael_woocommerce_after_shop_loop_item' );
?>
</div>
</li>
<?php
}
//}

View File

@@ -0,0 +1,147 @@
<?php
/**
* Template Name: Preset 1
*/
use Essential_Addons_Elementor\Elements\Woo_Product_List;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( empty( $woo_product_list ) ) {
$woo_product_list = Woo_Product_List::get_woo_product_list_settings( $settings );
}
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
$woo_product_list_loop = Woo_Product_List::get_woo_product_list_loop_settings( $product, $settings, $woo_product_list ); // static method as the template is used by read more feature too
?>
<div <?php post_class( 'product' ); ?>>
<div class="eael-product-list-item <?php echo esc_attr( $woo_product_list['image_alignment'] ); ?>">
<?php if( 'badge-preset-2' === $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<div class="eael-product-list-image-wrap">
<?php if( 'badge-preset-2' !== $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link" >
<?php endif; ?>
<?php echo wp_kses_post( $product->get_image( $woo_product_list['image_size'], ['loading' => 'eager'] ) ); ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
</a>
<?php endif; ?>
<?php if ( $woo_product_list['button_position_on_hover'] ) : ?>
<ul class="eael-product-list-buttons-on-hover">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<li class="eael-product-list-add-to-cart-button eael-m-0">
<?php woocommerce_template_loop_add_to_cart(); ?>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['quick_view_button_show'] ) : ?>
<li class="eael-product-list-quick-view-button eael-m-0">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ); ?>" class="open-popup-link"><i class="fas fa-eye"></i></a>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['link_button_show'] ) : ?>
<li class="eael-product-list-link-button eael-m-0">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>"><i class="fas fa-link"></i></a>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
</div>
<div class="eael-product-list-content-wrap">
<?php
if ( 'after-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<div class="eael-product-list-content-header <?php echo esc_attr( $woo_product_list_loop['direction_rtl_class'] ) ?>" >
<?php if ( $woo_product_list['rating_show'] ) : ?>
<div class="eael-product-list-rating">
<?php echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) ); ?>
<?php if ( $woo_product_list['review_count_show'] && $woo_product_list_loop['review_count'] > 0 ) : ?>
<a href="<?php echo esc_url( get_permalink() ) ?>#reviews" class="woocommerce-review-link eael-product-list-review-count" rel="nofollow">(<?php printf( '%s', __( $woo_product_list_loop['review_count'], 'essential-addons-for-elementor-lite' ) ); ?>)</a>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="eael-product-list-notice eael-product-list-notice-shiping-free">
<?php if ( $woo_product_list['category_show'] && $woo_product_list_loop['has_terms'] ) : ?>
<p>
<i class="fas fa-box"></i>
<?php echo esc_html( Woo_Product_List::eael_get_product_category_name( $woo_product_list_loop['terms'] ) ); ?>
</p>
<?php endif; ?>
</div>
</div>
<div class="eael-product-list-content-body">
<?php
if ( 'before-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<?php if ( $woo_product_list['excerpt_show'] ) : ?>
<div class="eael-product-list-excerpt">
<?php echo wp_trim_words( strip_shortcodes( get_the_excerpt() ), $woo_product_list['excerpt_words_count'], $woo_product_list['excerpt_expanison_indicator'] ); ?>
</div>
<?php endif; ?>
<?php if ( $woo_product_list['price_show'] ) : ?>
<h3 class="eael-product-list-price">
<?php echo wp_kses_post( $product->get_price_html() ); ?>
</h3>
<?php endif; ?>
</div>
<div class="eael-product-list-content-footer">
<?php if ( $woo_product_list['total_sold_show'] ) : ?>
<div class="eael-product-list-progress">
<div class="eael-product-list-progress-info">
<h4 class="eael-product-list-progress-count"><?php esc_html_e( $woo_product_list['total_sold_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['total_sales_count'] ); ?></span></h4>
<?php if( $product->managing_stock() && $woo_product_list['total_sold_remaining_show'] ) : ?>
<h4 class="eael-product-list-progress-remaining"><?php esc_html_e( $woo_product_list['total_sold_remaining_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['stock_quantity_count'] ); ?></span></h4>
<?php endif; ?>
</div>
<div class="eael-product-list-progress-bar-outer">
<div style="width: <?php echo esc_attr( $woo_product_list_loop['total_sold_progress_percentage'] ); ?>%;" class="eael-product-list-progress-bar-inner"></div>
</div>
</div>
<?php endif; ?>
<?php if ( $woo_product_list['button_position_static'] ) : ?>
<div class="eael-product-list-buttons">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<p class="eael-product-list-add-to-cart-button eael-m-0"><?php woocommerce_template_loop_add_to_cart(); ?></p>
<?php endif; ?>
<?php if ( $woo_product_list['quick_view_button_show'] ) : ?>
<p class="eael-product-list-quick-view-button eael-m-0">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ); ?>" class="open-popup-link">
<?php esc_html_e( $woo_product_list['quick_view_text'], 'essential-addons-for-elementor-lite' ); ?>
</a>
</p>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,148 @@
<?php
/**
* Template Name: Preset 2
*/
use Essential_Addons_Elementor\Elements\Woo_Product_List;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( empty( $woo_product_list ) ) {
$woo_product_list = Woo_Product_List::get_woo_product_list_settings( $settings );
}
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
$woo_product_list_loop = Woo_Product_List::get_woo_product_list_loop_settings( $product, $settings, $woo_product_list ); // static method as the template is used by read more feature too
?>
<div <?php post_class( 'product' ); ?>>
<div class="eael-product-list-item <?php echo esc_attr( $woo_product_list['image_alignment'] ); ?>">
<?php if( 'badge-preset-2' === $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<div class="eael-product-list-image-wrap">
<?php if( 'badge-preset-2' !== $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link" >
<?php endif; ?>
<?php echo wp_kses_post( $product->get_image( $woo_product_list['image_size'], ['loading' => 'eager'] ) ); ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
</a>
<?php endif; ?>
<?php if ( $woo_product_list['button_position_on_hover'] ) : ?>
<ul class="eael-product-list-buttons-on-hover">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<li class="eael-product-list-add-to-cart-button eael-m-0">
<?php woocommerce_template_loop_add_to_cart(); ?>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['quick_view_button_show'] ) : ?>
<li class="eael-product-list-quick-view-button eael-m-0">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ); ?>" class="open-popup-link"><i class="fas fa-eye"></i></a>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['link_button_show'] ) : ?>
<li class="eael-product-list-link-button eael-m-0">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>"><i class="fas fa-link"></i></a>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
</div>
<div class="eael-product-list-content-wrap">
<?php
if ( 'after-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<div class="eael-product-list-content-header <?php echo esc_attr( $woo_product_list_loop['direction_rtl_class'] ) ?>" >
<?php if ( $woo_product_list['rating_show'] ) : ?>
<div class="eael-product-list-rating">
<?php echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) ); ?>
<?php if ( $woo_product_list['review_count_show'] && $woo_product_list_loop['review_count'] > 0 ) : ?>
<a href="<?php echo esc_url( get_permalink() ) ?>#reviews" class="woocommerce-review-link eael-product-list-review-count" rel="nofollow">(<?php printf( '%s', __( $woo_product_list_loop['review_count'], 'essential-addons-for-elementor-lite' ) ); ?>)</a>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="eael-product-list-notice eael-product-list-notice-category">
<?php if ( $woo_product_list['category_show'] && $woo_product_list_loop['has_terms'] ) : ?>
<p>
<i class="fas fa-box"></i>
<?php echo esc_html( Woo_Product_List::eael_get_product_category_name( $woo_product_list_loop['terms'] ) ); ?>
</p>
<?php endif; ?>
</div>
</div>
<div class="eael-product-list-content-body">
<?php
if ( 'before-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<?php if ( $woo_product_list['excerpt_show'] ) : ?>
<div class="eael-product-list-excerpt">
<?php echo wp_trim_words( strip_shortcodes( get_the_excerpt() ), $woo_product_list['excerpt_words_count'], $woo_product_list['excerpt_expanison_indicator'] ); ?>
</div>
<?php endif; ?>
<?php if ( $woo_product_list['price_show'] ) : ?>
<h3 class="eael-product-list-price">
<?php echo wp_kses_post( $product->get_price_html() ); ?>
</h3>
<?php endif; ?>
</div>
<div class="eael-product-list-content-footer">
<?php if ( $woo_product_list['total_sold_show'] ) : ?>
<div class="eael-product-list-progress">
<div class="eael-product-list-progress-info">
<h4 class="eael-product-list-progress-count"><?php esc_html_e( $woo_product_list['total_sold_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['total_sales_count'] ); ?></span></h4>
<?php if( $product->managing_stock() && $woo_product_list['total_sold_remaining_show'] ) : ?>
<h4 class="eael-product-list-progress-remaining"><?php esc_html_e( $woo_product_list['total_sold_remaining_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['stock_quantity_count'] ); ?></span></h4>
<?php endif; ?>
</div>
<div class="eael-product-list-progress-bar-outer">
<div style="width: <?php echo esc_attr( $woo_product_list_loop['total_sold_progress_percentage'] ); ?>%;" class="eael-product-list-progress-bar-inner"></div>
</div>
</div>
<?php endif; ?>
<?php if ( $woo_product_list['button_position_static'] ) : ?>
<div class="eael-product-list-buttons">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<p class="eael-product-list-add-to-cart-button eael-m-0"><?php woocommerce_template_loop_add_to_cart(); ?></p>
<?php endif; ?>
<?php if ( $woo_product_list['quick_view_button_show'] ) : ?>
<p class="eael-product-list-quick-view-button eael-m-0">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ); ?>" class="open-popup-link">
<?php esc_html_e( $woo_product_list['quick_view_text'], 'essential-addons-for-elementor-lite' ); ?>
</a>
</p>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,136 @@
<?php
/**
* Template Name: Preset 3
*/
use Essential_Addons_Elementor\Elements\Woo_Product_List;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( empty( $woo_product_list ) ) {
$woo_product_list = Woo_Product_List::get_woo_product_list_settings( $settings );
}
$product = wc_get_product( get_the_ID() );
if ( ! $product ) {
error_log( '$product not found in ' . __FILE__ );
return;
}
$woo_product_list_loop = Woo_Product_List::get_woo_product_list_loop_settings( $product, $settings, $woo_product_list ); // static method as the template is used by read more feature too
?>
<div <?php post_class( 'product' ); ?>>
<div class="eael-product-list-item <?php echo esc_attr( $woo_product_list['image_alignment'] ); ?>">
<?php if( 'badge-preset-2' === $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<div class="eael-product-list-image-wrap">
<?php if( 'badge-preset-2' !== $woo_product_list['badge_preset'] ) : ?>
<?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?>
<?php endif; ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
<a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link" >
<?php endif; ?>
<?php echo wp_kses_post( $product->get_image( $woo_product_list['image_size'], ['loading' => 'eager'] ) ); ?>
<?php if ( $woo_product_list['image_clickable'] ) : ?>
</a>
<?php endif; ?>
<?php if ( $woo_product_list['button_position_on_hover'] ) : ?>
<ul class="eael-product-list-buttons-on-hover">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<li class="eael-product-list-add-to-cart-button eael-m-0">
<?php woocommerce_template_loop_add_to_cart(); ?>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['quick_view_button_show'] ) : ?>
<li class="eael-product-list-quick-view-button eael-m-0">
<a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ); ?>" class="open-popup-link"><i class="fas fa-eye"></i></a>
</li>
<?php endif; ?>
<?php if ( $woo_product_list['link_button_show'] ) : ?>
<li class="eael-product-list-link-button eael-m-0">
<a href="<?php echo esc_url( $product->get_permalink() ); ?>"><i class="fas fa-link"></i></a>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
</div>
<div class="eael-product-list-content-wrap">
<?php
if ( 'after-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<div class="eael-product-list-content-header <?php echo esc_attr( $woo_product_list_loop['direction_rtl_class'] ) ?>" >
<?php if ( $woo_product_list['rating_show'] ) : ?>
<div class="eael-product-list-rating">
<?php echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) ); ?>
<?php if ( $woo_product_list['review_count_show'] && $woo_product_list_loop['review_count'] > 0 ) : ?>
<a href="<?php echo esc_url( get_permalink() ) ?>#reviews" class="woocommerce-review-link eael-product-list-review-count" rel="nofollow">(<?php printf( '%s', __( $woo_product_list_loop['review_count'], 'essential-addons-for-elementor-lite' ) ); ?>)</a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div class="eael-product-list-content-body">
<?php
if ( 'before-title' === $woo_product_list['content_header_position'] ) :
Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product );
endif;
?>
<?php if ( $woo_product_list['excerpt_show'] ) : ?>
<div class="eael-product-list-excerpt">
<?php echo wp_trim_words( strip_shortcodes( get_the_excerpt() ), $woo_product_list['excerpt_words_count'], $woo_product_list['excerpt_expanison_indicator'] ); ?>
</div>
<?php endif; ?>
<?php if ( $woo_product_list['price_show'] ) : ?>
<h3 class="eael-product-list-price">
<?php echo wp_kses_post( $product->get_price_html() ); ?>
</h3>
<?php endif; ?>
</div>
<div class="eael-product-list-content-footer">
<?php if ( $woo_product_list['button_position_static'] ) : ?>
<div class="eael-product-list-buttons">
<?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?>
<p class="eael-product-list-add-to-cart-button eael-m-0"><?php woocommerce_template_loop_add_to_cart(); ?></p>
<?php endif; ?>
<?php if ( $woo_product_list['total_sold_show'] ) : ?>
<div class="eael-product-list-progress">
<div class="eael-product-list-progress-info">
<h4 class="eael-product-list-progress-count"><?php esc_html_e( $woo_product_list['total_sold_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['total_sales_count'] ); ?></span> <?php _e('Item', 'essential-addons-for-elementor-lite'); ?></h4>
</div>
<div class="eael-product-list-progress-bar-outer">
<div style="width: <?php echo esc_attr( $woo_product_list_loop['total_sold_progress_percentage'] ); ?>%;" class="eael-product-list-progress-bar-inner"></div>
</div>
</div>
<?php endif; ?>
<div class="eael-product-list-notice eael-product-list-notice-shiping-free">
<?php if ( $woo_product_list['category_show'] && $woo_product_list_loop['has_terms'] ) : ?>
<p>
<i class="fas fa-box"></i>
<?php echo esc_html( Woo_Product_List::eael_get_product_category_name( $woo_product_list_loop['terms'] ) ); ?>
</p>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,712 @@
<?php
namespace Essential_Addons_Elementor\Template\Woocommerce\Cart;
use Elementor\Icons_Manager;
use \Essential_Addons_Elementor\Classes\Helper;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
trait Woo_Cart_Helper {
public static $setting_data = [];
public static function ea_get_woo_cart_settings() {
return self::$setting_data;
}
public static function ea_set_woo_cart_settings( $settings ) {
self::$setting_data = $settings;
}
/**
* Added all actions
*/
public function ea_woo_cart_add_actions( $settings ) {
// set ea cart controller settings
self::ea_set_woo_cart_settings( $settings );
}
public function ea_cart_render() {
$settings = self::ea_get_woo_cart_settings();
Woo_Cart_Shortcode::output( [], $settings );
}
public static function woo_cart_style_one( $settings ) { ?>
<form class="woocommerce-cart-form eael-woo-cart-form woocommerce" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
<?php do_action( 'woocommerce_before_cart_table' ); ?>
<div class="eael-cart-clear-btn mt10">
<?php if ( ! empty( $settings['eael_woo_cart_components_cart_clear_button'] ) && $settings['eael_woo_cart_components_cart_clear_button'] === 'yes' ) {
$clear_text = apply_filters( 'eael_woo_cart_clear_button_text', $settings['eael_woo_cart_components_cart_clear_button_text'] );
echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" class="button" title="' . esc_attr( $clear_text ) . '">' . esc_html( $clear_text ) . '</a>';
}
?>
</div>
<div class="eael-woo-cart-table-warp">
<table class="shop_table cart woocommerce-cart-form__contents eael-woo-cart-table">
<thead>
<tr>
<?php
if ( ! empty( $settings['table_items'] ) && is_array( $settings['table_items'] ) ) {
foreach ( $settings['table_items'] as $column_data ) {
$item_class = "elementor-repeater-item-{$column_data['_id']}";
?>
<th class="<?php echo esc_attr( "product-{$column_data['column_type']} {$item_class}" ); ?>">
<?php
$title = apply_filters( "eael_woo_cart_table_{$column_data['column_type']}_title", $column_data['column_heading_title'] );
echo esc_html( $title );
?>
</th>
<?php
}
}
?>
</tr>
</thead>
<tbody>
<?php
do_action( 'woocommerce_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0
&& apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key )
) {
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink',
$_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item,
$cart_item_key );
?>
<tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class',
'cart_item', $cart_item, $cart_item_key ) ); ?>">
<?php
if ( ! empty( $settings['table_items'] ) && is_array( $settings['table_items'] ) ) {
foreach ( $settings['table_items'] as $column_data ) {
$item_class = "elementor-repeater-item-{$column_data['_id']}";
switch ( $column_data['column_type'] ) {
case 'remove': ?>
<td class="product-remove <?php echo esc_attr( $item_class ); ?>">
<?php
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'woocommerce_cart_item_remove_link',
sprintf(
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>',
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
esc_html__( 'Remove this item', 'essential-addons-for-elementor-lite' ),
esc_attr( $product_id ),
esc_attr( $_product->get_sku() ),
Helper::get_render_icon( $column_data['item_remove_icon'], [ 'aria-hidden' => 'true' ] )
),
$cart_item_key
);
?>
</td>
<?php
break;
case 'thumbnail': ?>
<td class="product-thumbnail <?php echo esc_attr( $item_class ); ?>">
<?php
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
if ( ! $product_permalink ) {
echo $thumbnail; // PHPCS: XSS ok.
} else {
printf( '<a href="%s">%s</a>', esc_url( $product_permalink ),
$thumbnail ); // PHPCS: XSS ok.
}
?>
</td>
<?php
break;
case 'name': ?>
<td class="product-name <?php echo esc_attr( $item_class ); ?>">
<?php
if ( ! $product_permalink ) {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name',
$_product->get_name(), $cart_item, $cart_item_key )
. '&nbsp;' );
} else {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name',
sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ),
$_product->get_name() ), $cart_item, $cart_item_key ) );
}
do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
// Meta data.
echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.
// Backorder notification.
if ( $_product->backorders_require_notification()
&& $_product->is_on_backorder( $cart_item['quantity'] )
) {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification',
'<p class="backorder_notification">'
. esc_html__( 'Available on backorder', 'essential-addons-for-elementor-lite' )
. '</p>', $product_id ) );
}
?>
</td>
<?php
break;
case 'price': ?>
<td class="product-price <?php echo esc_attr( $item_class ); ?>">
<?php
echo apply_filters( 'woocommerce_cart_item_price',
WC()->cart->get_product_price( $_product ), $cart_item,
$cart_item_key ); // PHPCS: XSS ok.
?>
</td>
<?php
break;
case 'quantity': ?>
<td class="product-quantity <?php echo esc_attr( $item_class ); ?>">
<?php
if ( $_product->is_sold_individually() ) {
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
} else {
$product_quantity = woocommerce_quantity_input(
[
'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'],
'max_value' => $_product->get_max_purchase_quantity(),
'min_value' => '0',
'product_name' => $_product->get_name(),
],
$_product,
false
);
}
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity,
$cart_item_key, $cart_item ); // PHPCS: XSS ok.
?>
</td>
<?php
break;
case 'subtotal': ?>
<td class="product-subtotal <?php echo esc_attr( $item_class ); ?>">
<?php
echo apply_filters( 'woocommerce_cart_item_subtotal',
WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ),
$cart_item,
$cart_item_key ); // PHPCS: XSS ok.
?>
</td>
<?php
break;
}
}
}
?>
</tr>
<?php
}
}
do_action( 'woocommerce_cart_contents' );
do_action( 'woocommerce_after_cart_contents' ); ?>
</tbody>
</table>
</div>
<?php
do_action( 'woocommerce_after_cart_table' );
self::woo_cart_collaterals( $settings );
?>
</form>
<?php
}
public static function eael_woo_cart_totals( $settings ) {
if ( ! empty( $settings['ea_woo_cart_layout'] ) ) {
?>
<div class="cart_totals <?php echo ( WC()->customer->has_calculated_shipping() ) ? 'calculated_shipping' : ''; ?>">
<?php
do_action( 'woocommerce_before_cart_totals' );
if ( $settings['eael_woo_cart_components_cart_totals_subtotal'] === 'yes' || $settings['eael_woo_cart_components_cart_totals_coupon'] === 'yes' ||
$settings['eael_woo_cart_components_cart_totals_shipping'] === 'yes' ||
( ! empty( WC()->cart->get_fees() ) && $settings['eael_woo_cart_components_cart_totals_fees'] === 'yes' ) ||
$settings['eael_woo_cart_components_cart_totals_tax'] === 'yes' || $settings['eael_woo_cart_components_cart_totals_total'] === 'yes' ) {
?>
<table class="shop_table shop_table_responsive">
<?php if ( $settings['eael_woo_cart_components_cart_totals_subtotal'] === 'yes' ) {
$subtotal_label = apply_filters( 'eael_woo_cart_totals_subtotal_label', esc_html__( 'Subtotal', 'essential-addons-for-elementor-lite' ) );
?>
<tr class="cart-subtotal">
<th><?php echo esc_html( $subtotal_label ); ?></th>
<td data-title="<?php echo esc_attr( $subtotal_label ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
<?php } ?>
<?php
if ( $settings['eael_woo_cart_components_cart_totals_coupon'] === 'yes' ) {
foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td data-title="<?php echo esc_attr( wc_cart_totals_coupon_label( $coupon, false ) ); ?>"><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php
endforeach;
}
?>
<?php
if ( $settings['eael_woo_cart_components_cart_totals_shipping'] === 'yes' ) {
if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
<?php do_action( 'woocommerce_cart_totals_before_shipping' ); ?>
<?php wc_cart_totals_shipping_html(); ?>
<?php do_action( 'woocommerce_cart_totals_after_shipping' ); ?>
<?php elseif ( WC()->cart->needs_shipping() && 'yes' === get_option( 'woocommerce_enable_shipping_calc' ) ) :
$shipping_label = apply_filters( 'eael_woo_cart_totals_shipping_label', esc_html__( 'Shipping', 'essential-addons-for-elementor-lite' ) );
?>
<tr class="shipping">
<th><?php echo esc_html( $shipping_label ); ?></th>
<td data-title="<?php echo esc_attr( $shipping_label ); ?>"><?php woocommerce_shipping_calculator(); ?></td>
</tr>
<?php
endif;
} ?>
<?php
if ( $settings['eael_woo_cart_components_cart_totals_fees'] === 'yes' ) {
foreach ( WC()->cart->get_fees() as $fee ) : ?>
<tr class="fee">
<th><?php echo esc_html( $fee->name ); ?></th>
<td data-title="<?php echo esc_attr( $fee->name ); ?>"><?php wc_cart_totals_fee_html( $fee ); ?></td>
</tr>
<?php
endforeach;
} ?>
<?php
if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() && $settings['eael_woo_cart_components_cart_totals_tax'] === 'yes' ) {
$taxable_address = WC()->customer->get_taxable_address();
$estimated_text = '';
if ( WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping() ) {
/* translators: %s location. */
$estimated_text = sprintf( ' <small>' . esc_html__( '(estimated for %s)', 'essential-addons-for-elementor-lite' ) . '</small>', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] );
}
if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) {
foreach ( WC()->cart->get_tax_totals() as $code => $tax ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
?>
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php echo esc_html( $tax->label ) . $estimated_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th>
<td data-title="<?php echo esc_attr( $tax->label ); ?>"><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
<?php
}
} else {
?>
<tr class="tax-total">
<th><?php echo esc_html( WC()->countries->tax_or_vat() ) . $estimated_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th>
<td data-title="<?php echo esc_attr( WC()->countries->tax_or_vat() ); ?>"><?php wc_cart_totals_taxes_total_html(); ?></td>
</tr>
<?php
}
}
?>
<?php
do_action( 'woocommerce_cart_totals_before_order_total' );
if ( $settings['eael_woo_cart_components_cart_totals_total'] === 'yes' ) {
$total_label = apply_filters( 'eael_woo_cart_totals_total_label', esc_html__( 'Total', 'essential-addons-for-elementor-lite' ) );
?>
<tr class="order-total">
<th><?php echo esc_html( $total_label ); ?></th>
<td data-title="<?php echo esc_attr( $total_label ); ?>"><?php wc_cart_totals_order_total_html(); ?></td>
</tr>
<?php
}
do_action( 'woocommerce_cart_totals_after_order_total' );
?>
</table>
<?php
}
?>
<div class="wc-proceed-to-checkout">
<?php do_action( 'woocommerce_proceed_to_checkout', $settings ); ?>
</div>
<?php
do_action( 'woocommerce_after_cart_totals' ); ?>
</div>
<?php
} else {
woocommerce_cart_totals();
}
}
public function remove_woocommerce_cross_sell_display( $settings ) {
// Remove default 'woocommerce_cross_sell_display' callback from 'woocommerce_cart_collaterals'
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
}
public static function eael_cart_button_proceed_to_checkout( $settings ) {
if ( ! empty( $settings['ea_woo_cart_layout'] ) ) {
$button_text = apply_filters( 'eael_woo_cart_checkout_button_text', $settings['eael_woo_cart_components_cart_checkout_button_text'] );
?>
<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="checkout-button button alt wc-forward">
<?php echo esc_html( $button_text ); ?>
</a>
<?php
} else {
woocommerce_button_proceed_to_checkout();
}
}
public static function woo_cart_style_two( $settings ) { ?>
<form class="woocommerce-cart-form eael-woo-cart-form woocommerce" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">
<?php do_action( 'woocommerce_before_cart_table' ); ?>
<div class="eael-cart-clear-btn mt10">
<?php if ( ! empty( $settings['eael_woo_cart_components_cart_clear_button'] ) && $settings['eael_woo_cart_components_cart_clear_button'] === 'yes' ) {
$clear_text = apply_filters( 'eael_woo_cart_clear_button_text', $settings['eael_woo_cart_components_cart_clear_button_text'] );
echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" class="button" title="' . esc_attr( $clear_text ) . '">' . esc_html( $clear_text ) . '</a>';
}
?>
</div>
<div class="shop_table cart woocommerce-cart-form__contents eael-woo-cart-table">
<?php
$has_table_left_components = $settings['eael_woo_cart_table_components_thumbnail'] === 'yes' ? true : false;
$has_table_right_components = in_array( 'yes', [
$settings['eael_woo_cart_table_components_price'],
$settings['eael_woo_cart_table_components_qty'],
$settings['eael_woo_cart_table_components_subtotal'],
$settings['eael_woo_cart_table_components_remove']
] ) ? true : false;
if ( $has_table_left_components || $has_table_right_components ) {
?>
<div class="eael-woo-cart-thead">
<div class="eael-woo-cart-tr">
<?php if ( $has_table_left_components ) { ?>
<div class="eael-woo-cart-tr-left">
<div class="eael-woo-cart-td product-thumbnail">
<?php
$title = apply_filters( "eael_woo_cart_table_thumbnail_title", $settings['eael_woo_cart_table_components_thumbnail_title'] );
echo esc_html( $title );
?>
</div>
</div>
<?php
}
if ( $has_table_right_components ) { ?>
<div class="eael-woo-cart-tr-right">
<?php if ( $settings['eael_woo_cart_table_components_price'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-price">
<?php
$title = apply_filters( "eael_woo_cart_table_price_title", $settings['eael_woo_cart_table_components_price_title'] );
echo esc_html( $title );
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_qty'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-quantity">
<?php
$title = apply_filters( "eael_woo_cart_table_quantity_title", $settings['eael_woo_cart_table_components_qty_title'] );
echo esc_html( $title );
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_subtotal'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-subtotal">
<?php
$title = apply_filters( "eael_woo_cart_table_subtotal_title", $settings['eael_woo_cart_table_components_subtotal_title'] );
echo esc_html( $title );
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_remove'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-remove"></div>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
<div class="eael-woo-cart-tbody">
<?php
do_action( 'woocommerce_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0
&& apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key )
) {
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink',
$_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item,
$cart_item_key );
?>
<div class="eael-woo-cart-tr woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class',
'cart_item', $cart_item, $cart_item_key ) ); ?>">
<?php if ( $has_table_left_components ) { ?>
<div class="eael-woo-cart-tr-left">
<div class="eael-woo-cart-td product-thumbnail">
<?php
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
if ( ! $product_permalink ) {
echo $thumbnail; // PHPCS: XSS ok.
} else {
printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok.
}
if ( $settings['eael_woo_cart_table_components_remove'] === 'yes' ) { ?>
<div class="eael-woo-cart-product-remove">
<?php
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'woocommerce_cart_item_remove_link',
sprintf(
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>',
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
esc_html__( 'Remove this item', 'essential-addons-for-elementor-lite' ),
esc_attr( $product_id ),
esc_attr( $_product->get_sku() ),
Helper::get_render_icon( $settings['eael_woo_cart_table_components_remove_icon'], [ 'aria-hidden' => 'true' ] )
),
$cart_item_key
);
?>
</div>
<?php }
?>
</div>
<?php if ( $settings['eael_woo_cart_table_components_name'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-name">
<?php
if ( ! $product_permalink ) {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;' );
} else {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ),
$_product->get_name() ), $cart_item, $cart_item_key ) );
}
do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
// Product SKU
if ( $settings['eael_woo_cart_table_components_sku'] === 'yes' && ! empty( $_product->get_sku() ) ) {
printf( '<p class="eael-woo-cart-sku">#%s</p>', $_product->get_sku() );
}
// Meta data.
echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok.
// Backorder notification.
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification',
'<p class="backorder_notification">'
. esc_html__( 'Available on backorder', 'essential-addons-for-elementor-lite' )
. '</p>', $product_id ) );
}
?>
</div>
<?php } ?>
</div>
<?php
}
if ( $has_table_right_components ) { ?>
<div class="eael-woo-cart-tr-right">
<?php if ( $settings['eael_woo_cart_table_components_price'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-price">
<?php
echo apply_filters( 'woocommerce_cart_item_price',
WC()->cart->get_product_price( $_product ), $cart_item,
$cart_item_key ); // PHPCS: XSS ok.
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_qty'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-quantity">
<?php
if ( $_product->is_sold_individually() ) {
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
} else {
$product_quantity = woocommerce_quantity_input(
[
'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'],
'max_value' => $_product->get_max_purchase_quantity(),
'min_value' => '0',
'product_name' => $_product->get_name(),
],
$_product,
false
);
}
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity,
$cart_item_key, $cart_item ); // PHPCS: XSS ok.
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_subtotal'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-subtotal" data-title="<?php echo esc_html( $title ); ?>">
<?php
echo apply_filters( 'woocommerce_cart_item_subtotal',
WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ),
$cart_item,
$cart_item_key ); // PHPCS: XSS ok.
?>
</div>
<?php
}
if ( $settings['eael_woo_cart_table_components_remove'] === 'yes' ) { ?>
<div class="eael-woo-cart-td product-remove">
<?php
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'woocommerce_cart_item_remove_link',
sprintf(
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">%s</a>',
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
esc_html__( 'Remove this item', 'essential-addons-for-elementor-lite' ),
esc_attr( $product_id ),
esc_attr( $_product->get_sku() ),
Helper::get_render_icon( $settings['eael_woo_cart_table_components_remove_icon'], [ 'aria-hidden' => 'true' ] )
),
$cart_item_key
);
?>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<?php
}
}
do_action( 'woocommerce_cart_contents' );
do_action( 'woocommerce_after_cart_contents' ); ?>
</div>
<?php } ?>
</div>
<?php
do_action( 'woocommerce_after_cart_table' );
self::woo_cart_collaterals( $settings );
?>
</form>
<?php
}
public static function woo_cart_collaterals( $settings ) { ?>
<div class="eael-cart-coupon-and-collaterals">
<div class="eael-cart-coupon-wrapper">
<?php if ( wc_coupons_enabled() && $settings['eael_woo_cart_components_cart_coupon'] === 'yes' ) {
$button_text = apply_filters( 'eael_woo_cart_coupon_button_text', $settings['eael_woo_cart_components_cart_coupon_button_text'] );
$placeholder = apply_filters( 'eael_woo_cart_coupon_placeholder', $settings['eael_woo_cart_components_cart_coupon_placeholder'] );
$coupon_label = apply_filters( 'eael_woo_cart_coupon_label_text', esc_html__( 'Coupon:', 'essential-addons-for-elementor-lite' ) );
?>
<div class="coupon">
<label for="coupon_code" class="sr-only"><?php echo esc_html( $coupon_label ); ?></label>
<input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php echo esc_attr( $placeholder ); ?>"/>
<button type="submit" class="button" name="apply_coupon"
value="<?php echo esc_attr( $button_text ); ?>"><?php echo esc_html( $button_text ); ?></button>
<?php do_action( 'woocommerce_cart_coupon' ); ?>
</div>
<?php
}
if ( $settings['eael_woo_cart_components_continue_shopping'] === 'yes' ) {
$continue_shopping_text = apply_filters( 'eael_woo_cart_continue_shopping_text', $settings['eael_woo_cart_components_continue_shopping_text'] );
printf( '<a class="eael-woo-cart-back-to-shop" href="%s">%s %s</a>',
get_permalink( wc_get_page_id( 'shop' ) ),
Helper::get_render_icon( $settings['eael_woo_cart_components_continue_shopping_icon'], [ 'aria-hidden' => 'true' ] ),
esc_html( $continue_shopping_text )
);
}
?>
</div>
<?php do_action( 'woocommerce_before_cart_collaterals' ); ?>
<div class="cart-collaterals">
<div class="eael-cart-update-btn">
<?php if ( $settings['eael_woo_cart_components_cart_update_button'] === 'yes' ) {
$update_text = apply_filters( 'eael_woo_cart_update_button_text', $settings['eael_woo_cart_components_cart_update_button_text'] );
?>
<button type="submit" class="button" name="update_cart" value="<?php echo esc_attr( $update_text ); ?>"><?php echo esc_html( $update_text ); ?></button>
<?php
}
else if ( ! $settings['eael_woo_cart_components_cart_update_button'] && $settings['eael_woo_cart_auto_cart_update'] === 'yes' ){
echo '<button type="submit" class="button" name="update_cart" style="display:none;"></button>';
}
do_action( 'woocommerce_cart_actions' );
wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' );
?>
</div>
<?php
/**
* Cart collaterals hook.
*
* @hooked woocommerce_cross_sell_display
* @hooked woocommerce_cart_totals - 10
*/
do_action( 'eael_woocommerce_before_cart_collaterals', $settings );
if ( $settings['eael_woo_cart_components_cart_totals'] === 'yes' ) {
do_action( 'woocommerce_cart_collaterals', $settings );
} else {
?>
<div class="cart_totals">
<div class="wc-proceed-to-checkout">
<?php do_action( 'woocommerce_proceed_to_checkout', $settings ); ?>
</div>
</div>
<?php
}
?>
</div>
</div>
<?php
}
public function wc_empty_cart_message( $message ) {
$settings = self::ea_get_woo_cart_settings();
$empty_text = $settings['eael_woo_cart_components_empty_cart_text'];
return empty( $empty_text ) ? $message : esc_html( $empty_text );
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace Essential_Addons_Elementor\Template\Woocommerce\Cart;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( class_exists( '\WC_Shortcode_Cart' ) ) {
class Woo_Cart_Shortcode extends \WC_Shortcode_Cart {
use Woo_Cart_Helper;
/**
* Output the cart shortcode.
*
* @param array $atts Shortcode attributes.
*/
public static function output( $atts, $settings = [] ) {
if ( ! apply_filters( 'woocommerce_output_cart_shortcode_content', true ) ) {
return;
}
// Constants.
wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
$atts = shortcode_atts( [], $atts, 'woocommerce_cart' );
$nonce_value = wc_get_var( $_REQUEST['woocommerce-shipping-calculator-nonce'],
wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.
// Update Shipping. Nonce check uses new value and old value (woocommerce-cart). @todo remove in 4.0.
if ( ! empty( $_POST['calc_shipping'] )
&& ( wp_verify_nonce( $nonce_value, 'woocommerce-shipping-calculator' )
|| wp_verify_nonce( $nonce_value, 'woocommerce-cart' ) )
) { // WPCS: input var ok.
self::calculate_shipping();
// Also calc totals before we check items so subtotals etc are up to date.
WC()->cart->calculate_totals();
}
// Check cart items are valid.
do_action( 'woocommerce_check_cart_items' );
// Calc totals.
WC()->cart->calculate_totals();
$auto_update = $settings['eael_woo_cart_auto_cart_update'] === 'yes' ? 'eael-auto-update' : '';
if ( WC()->cart->is_empty() ) { ?>
<div class="eael-woo-cart-wrapper eael-woo-cart-empty <?php echo esc_attr( printf( '%s %s', "eael-woo-{$settings['ea_woo_cart_layout']}", $auto_update ) ); ?>">
<?php wc_get_template( 'cart/cart-empty.php' ); ?>
</div>
<?php
} else {
$style_two_wrapper_class = '';
if ( $settings['ea_woo_cart_layout'] === 'style-2' ) {
if ( $settings['eael_woo_cart_table_components_thumbnail'] === 'yes' ) {
$style_two_wrapper_class .= ' has-table-left-content';
}
if ( in_array( 'yes', [
$settings['eael_woo_cart_table_components_price'],
$settings['eael_woo_cart_table_components_qty'],
$settings['eael_woo_cart_table_components_subtotal'],
$settings['eael_woo_cart_table_components_remove']
] ) ) {
$style_two_wrapper_class .= ' has-table-right-content';
}
}
?>
<div class="eael-woo-cart-wrapper <?php echo esc_attr( sprintf( '%s %s %s', "eael-woo-{$settings['ea_woo_cart_layout']}", $auto_update, $style_two_wrapper_class ) ); ?>">
<?php
do_action( 'woocommerce_before_cart' );
switch ( $settings['ea_woo_cart_layout'] ) {
case 'default':
self::woo_cart_style_one( $settings );
break;
case 'style-2':
self::woo_cart_style_two( $settings );
break;
}
do_action( 'woocommerce_after_cart' );
?>
</div>
<?php
}
}
}
}

View File

@@ -0,0 +1,834 @@
<?php
namespace Essential_Addons_Elementor\Template\Woocommerce\Checkout;
use \Elementor\Icons_Manager;
use \Exception;
use \Essential_Addons_Elementor\Classes\Helper as CheckoutHelperCLass;
if (!defined('ABSPATH')) {
exit;
} // Exit if accessed directly
trait Woo_Checkout_Helper {
public static $setting_data = [];
public static function ea_get_woo_checkout_settings(){
return self::$setting_data;
}
public static function ea_set_woo_checkout_settings($setting){
self::$setting_data = $setting;
}
/**
* Show the checkout.
*/
public static function ea_checkout($settings) {
// Show non-cart errors.
do_action( 'woocommerce_before_checkout_form_cart_notices' );
// Check cart has contents.
if ( WC()->cart->is_empty() && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_redirect_empty_cart', true ) ) {
return;
}
// Check cart contents for errors.
do_action( 'woocommerce_check_cart_items' );
// Calc totals.
WC()->cart->calculate_totals();
// Get checkout object.
$checkout = WC()->checkout();
if ( empty( $_POST ) && wc_notice_count( 'error' ) > 0 ) { // WPCS: input var ok, CSRF ok.
wc_get_template( 'checkout/cart-errors.php', array( 'checkout' => $checkout ) );
wc_clear_notices();
} else {
$non_js_checkout = ! empty( $_POST['woocommerce_checkout_update_totals'] ); // WPCS: input var ok, CSRF ok.
if ( wc_notice_count( 'error' ) === 0 && $non_js_checkout ) {
wc_add_notice( __( 'The order totals have been updated. Please confirm your order by pressing the "Place order" button at the bottom of the page.', 'essential-addons-for-elementor-lite' ) );
}
if($settings['ea_woo_checkout_layout'] == 'default'){
echo self::render_default_template_($checkout, $settings);
}else {
do_action('eael_add_woo_checkout_pro_layout', $checkout, $settings);
}
}
}
/**
* Show the Order Received page.
*/
public static function ea_order_received( $order_id = 0 ) {
$order = false;
// Get the order.
$order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $order_id ) );
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( wp_unslash( $_GET['key'] ) ) ); // WPCS: input var ok, CSRF ok.
if ( $order_id > 0 ) {
$order = wc_get_order( $order_id );
if ( ! $order || ! hash_equals( $order->get_order_key(), $order_key ) ) {
$order = false;
}
}
// Empty awaiting payment session.
unset( WC()->session->order_awaiting_payment );
// In case order is created from admin, but paid by the actual customer, store the ip address of the payer
// when they visit the payment confirmation page.
if ( $order && $order->is_created_via( 'admin' ) ) {
$order->set_customer_ip_address( \WC_Geolocation::get_ip_address() );
$order->save();
}
// Empty current cart.
wc_empty_cart();
wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
}
/**
* Show the pay page.
*/
public static function ea_order_pay( $order_id ) {
do_action( 'before_woocommerce_pay' );
$order_id = absint( $order_id );
// Pay for existing order.
if ( isset( $_GET['pay_for_order'], $_GET['key'] ) && $order_id ) { // WPCS: input var ok, CSRF ok.
try {
$order_key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : ''; // WPCS: input var ok, CSRF ok.
$order = wc_get_order( $order_id );
$hold_stock_minutes = (int) get_option( 'woocommerce_hold_stock_minutes', 0 );
// Order or payment link is invalid.
if ( ! $order || $order->get_id() !== $order_id || ! hash_equals( $order->get_order_key(), $order_key ) ) {
throw new Exception( __( 'Sorry, this order is invalid and cannot be paid for.', 'essential-addons-for-elementor-lite' ) );
}
// Logged out customer does not have permission to pay for this order.
if ( ! current_user_can( 'pay_for_order', $order_id ) && ! is_user_logged_in() ) {
echo '<div class="woocommerce-info">' . esc_html__( 'Please log in to your account below to continue to the payment form.', 'essential-addons-for-elementor-lite' ) . '</div>';
woocommerce_login_form(
array(
'redirect' => $order->get_checkout_payment_url(),
)
);
return;
}
// Add notice if logged in customer is trying to pay for guest order.
if ( ! $order->get_user_id() && is_user_logged_in() ) {
// If order has does not have same billing email then current logged in user then show warning.
if ( $order->get_billing_email() !== wp_get_current_user()->user_email ) {
wc_print_notice( __( 'You are paying for a guest order. Please continue with payment only if you recognize this order.', 'essential-addons-for-elementor-lite' ), 'error' );
}
}
// Logged in customer trying to pay for someone else's order.
if ( ! current_user_can( 'pay_for_order', $order_id ) ) {
throw new Exception( __( 'This order cannot be paid for. Please contact us if you need assistance.', 'essential-addons-for-elementor-lite' ) );
}
// Does not need payment.
if ( ! $order->needs_payment() ) {
/* translators: %s: order status */
throw new Exception( sprintf( __( 'This order&rsquo;s status is &ldquo;%s&rdquo;&mdash;it cannot be paid for. Please contact us if you need assistance.', 'essential-addons-for-elementor-lite' ), wc_get_order_status_name( $order->get_status() ) ) );
}
// Ensure order items are still stocked if paying for a failed order. Pending orders do not need this check because stock is held.
if ( ! $order->has_status( wc_get_is_pending_statuses() ) ) {
$quantities = array();
foreach ( $order->get_items() as $item_key => $item ) {
if ( $item && is_callable( array( $item, 'get_product' ) ) ) {
$product = $item->get_product();
if ( ! $product ) {
continue;
}
$quantities[ $product->get_stock_managed_by_id() ] = isset( $quantities[ $product->get_stock_managed_by_id() ] ) ? $quantities[ $product->get_stock_managed_by_id() ] + $item->get_quantity() : $item->get_quantity();
}
}
foreach ( $order->get_items() as $item_key => $item ) {
if ( $item && is_callable( array( $item, 'get_product' ) ) ) {
$product = $item->get_product();
if ( ! $product ) {
continue;
}
if ( ! apply_filters( 'woocommerce_pay_order_product_in_stock', $product->is_in_stock(), $product, $order ) ) {
/* translators: %s: product name */
throw new Exception( sprintf( __( 'Sorry, "%s" is no longer in stock so this order cannot be paid for. We apologize for any inconvenience caused.', 'essential-addons-for-elementor-lite' ), $product->get_name() ) );
}
// We only need to check products managing stock, with a limited stock qty.
if ( ! $product->managing_stock() || $product->backorders_allowed() ) {
continue;
}
// Check stock based on all items in the cart and consider any held stock within pending orders.
$held_stock = ( $hold_stock_minutes > 0 ) ? wc_get_held_stock_quantity( $product, $order->get_id() ) : 0;
$required_stock = $quantities[ $product->get_stock_managed_by_id() ];
if ( ! apply_filters( 'woocommerce_pay_order_product_has_enough_stock', ( $product->get_stock_quantity() >= ( $held_stock + $required_stock ) ), $product, $order ) ) {
/* translators: 1: product name 2: quantity in stock */
throw new Exception( sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s available). We apologize for any inconvenience caused.', 'essential-addons-for-elementor-lite' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity() - $held_stock, $product ) ) );
}
}
}
}
WC()->customer->set_props(
array(
'billing_country' => $order->get_billing_country() ? $order->get_billing_country() : null,
'billing_state' => $order->get_billing_state() ? $order->get_billing_state() : null,
'billing_postcode' => $order->get_billing_postcode() ? $order->get_billing_postcode() : null,
)
);
WC()->customer->save();
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
if ( count( $available_gateways ) ) {
current( $available_gateways )->set_current();
}
wc_get_template(
'checkout/form-pay.php',
array(
'order' => $order,
'available_gateways' => $available_gateways,
'order_button_text' => apply_filters( 'woocommerce_pay_order_button_text', __( 'Pay for order', 'essential-addons-for-elementor-lite' ) ),
)
);
} catch ( Exception $e ) {
wc_print_notice( $e->getMessage(), 'error' );
}
} elseif ( $order_id ) {
// Pay for order after checkout step.
$order_key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : ''; // WPCS: input var ok, CSRF ok.
$order = wc_get_order( $order_id );
if ( $order && $order->get_id() === $order_id && hash_equals( $order->get_order_key(), $order_key ) ) {
if ( $order->needs_payment() ) {
wc_get_template( 'checkout/order-receipt.php', array( 'order' => $order ) );
} else {
/* translators: %s: order status */
wc_print_notice( sprintf( __( 'This order&rsquo;s status is &ldquo;%s&rdquo;&mdash;it cannot be paid for. Please contact us if you need assistance.', 'essential-addons-for-elementor-lite' ), wc_get_order_status_name( $order->get_status() ) ), 'error' );
}
} else {
wc_print_notice( __( 'Sorry, this order is invalid and cannot be paid for.', 'essential-addons-for-elementor-lite' ), 'error' );
}
} else {
wc_print_notice( __( 'Invalid order.', 'essential-addons-for-elementor-lite' ), 'error' );
}
do_action( 'after_woocommerce_pay' );
}
/**
* Show the coupon.
*/
public static function ea_coupon_template() {
$settings = self::ea_get_woo_checkout_settings();
if ( get_option( 'woocommerce_enable_coupons' ) === 'no' || $settings['ea_woo_checkout_coupon_hide'] === 'yes' ) {
return;
}
?>
<div class="woo-checkout-coupon">
<div class="ea-coupon-icon">
<?php Icons_Manager::render_icon( $settings['ea_woo_checkout_coupon_icon'], [ 'aria-hidden' => 'true' ] ); ?>
</div>
<?php if( wc_coupons_enabled() ){ ?>
<div class="woocommerce-form-coupon-toggle">
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_coupon_message', $settings['ea_woo_checkout_coupon_title'] . ' <a href="#" class="showcoupon">' . $settings['ea_woo_checkout_coupon_link_text'] . '</a>' ), 'notice' ); ?>
</div>
<form class="checkout_coupon woocommerce-form-coupon" method="post" style="display:none">
<p><?php esc_html_e( $settings['ea_woo_checkout_coupon_form_content'], 'essential-addons-for-elementor-lite' ); ?></p>
<p class="form-row form-row-first">
<input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( $settings['ea_woo_checkout_coupon_placeholder_text'], 'essential-addons-for-elementor-lite' ); ?>" id="coupon_code" value="" />
</p>
<p class="form-row form-row-last">
<button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( $settings['ea_woo_checkout_coupon_button_text'], 'essential-addons-for-elementor-lite' ); ?>"><?php esc_html_e( $settings['ea_woo_checkout_coupon_button_text'], 'essential-addons-for-elementor-lite' ); ?></button>
</p>
<div class="clear"></div>
</form>
<?php } ?>
</div>
<?php }
/**
* Show the login.
*/
public static function ea_login_template(){
$settings = self::ea_get_woo_checkout_settings();
$class = '';
$status = true;
if('no' === get_option( 'woocommerce_enable_checkout_login_reminder')){
return '';
}elseif(\Elementor\Plugin::$instance->editor->is_edit_mode() && 'yes' === $settings['ea_section_woo_login_show']){
$class = 'woo-checkout-login-editor';
}elseif(!is_user_logged_in()){
$class = 'eael-woo-checkout-login-page';
}else{
return '';
}
ob_start();
?>
<div class="woo-checkout-login <?php echo $class; ?>">
<div class="ea-login-icon">
<?php Icons_Manager::render_icon( $settings['ea_woo_checkout_login_icon'], [ 'aria-hidden' => 'true' ] ); ?>
</div>
<div class="woocommerce-form-login-toggle">
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_login_message', $settings['ea_woo_checkout_login_title'] ) . ' <a href="#" class="showlogin">' . $settings['ea_woo_checkout_login_link_text'] . '</a>', 'notice' ); ?>
</div>
<?php
$message = CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_login_message']);
$redirect = wc_get_checkout_url();
$hidden = true;
?>
<form class="woocommerce-form woocommerce-form-login login" method="post" <?php echo ( $hidden ) ? 'style="display:none;"' : ''; ?>>
<?php do_action( 'woocommerce_login_form_start' ); ?>
<?php echo ( $message ) ? wpautop( wptexturize( $message ) ) : ''; // @codingStandardsIgnoreLine ?>
<p class="form-row form-row-first">
<label for="username"><?php esc_html_e( 'Username or email', 'essential-addons-for-elementor-lite' ); ?>&nbsp;<span class="required">*</span></label>
<input type="text" class="input-text" name="username" id="username" autocomplete="username" />
</p>
<p class="form-row form-row-last">
<label for="password"><?php esc_html_e( 'Password', 'essential-addons-for-elementor-lite' ); ?>&nbsp;<span class="required">*</span></label>
<input class="input-text" type="password" name="password" id="password" autocomplete="current-password" />
</p>
<div class="clear"></div>
<?php do_action( 'woocommerce_login_form' ); ?>
<p class="form-row">
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox woocommerce-form-login__rememberme">
<input class="woocommerce-form__input woocommerce-form__input-checkbox" name="rememberme" type="checkbox" id="rememberme" value="forever" /> <span><?php esc_html_e( 'Remember me', 'essential-addons-for-elementor-lite' ); ?></span>
</label>
<?php wp_nonce_field( 'woocommerce-login', 'woocommerce-login-nonce' ); ?>
<input type="hidden" name="redirect" value="<?php echo esc_url( $redirect ); ?>" />
<button type="submit" class="woocommerce-button button woocommerce-form-login__submit" name="login" value="<?php esc_attr_e( 'Login', 'essential-addons-for-elementor-lite' ); ?>"><?php esc_html_e( 'Login', 'essential-addons-for-elementor-lite' ); ?></button>
</p>
<p class="lost_password">
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php esc_html_e( 'Lost your password?', 'essential-addons-for-elementor-lite' ); ?></a>
</p>
<div class="clear"></div>
<?php do_action( 'woocommerce_login_form_end' ); ?>
</form>
</div>
<?php
$content = ob_get_clean();
if($status){
echo $content;
}
}
/**
* Show the login.
*/
public static function checkout_order_review_template() {
$settings = self::ea_get_woo_checkout_settings();
?>
<?php do_action('woocommerce_checkout_before_order_review_heading'); ?>
<h2 id="order_review_heading" class="woo-checkout-section-title">
<?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_order_details_title']); ?>
</h2>
<?php do_action('woocommerce_checkout_before_order_review'); ?>
<div class="ea-woo-checkout-order-review">
<?php self::checkout_order_review_default($settings); ?>
</div>
<?php do_action('woocommerce_checkout_after_order_review'); ?>
<?php }
public function remove_woocommerce_display_recurring_totals( $settings ){
remove_action('woocommerce_review_order_after_order_total', array( 'WC_Subscriptions_Cart', 'display_recurring_totals' ), 10);
}
/**
* Show the order review.
*/
public static function checkout_order_review_default($settings) {
WC()->cart->calculate_totals();
?>
<div class="ea-checkout-review-order-table">
<ul class="ea-order-review-table">
<?php
if( $settings['ea_woo_checkout_layout'] == 'default' ) { ?>
<li class="table-header">
<div class="table-col-1"><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_product_text']); ?></div>
<div class="table-col-2"><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_quantity_text']); ?></div>
<div class="table-col-3"><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_price_text']); ?></div>
</li>
<?php }
?>
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<li class="table-row <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<div class="table-col-1 product-thum-name">
<div class="product-thumbnail">
<?php
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
echo $thumbnail; // PHPCS: XSS ok.
?>
</div>
<div class="product-name">
<?php $name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo CheckoutHelperCLass::eael_wp_kses( $name );
?>
<?php if( $settings['ea_woo_checkout_layout'] == 'split' || $settings['ea_woo_checkout_layout'] == 'multi-steps' ) {
if( !empty( $settings['ea_woo_checkout_cart_update_enable'] ) && 'yes' === $settings['ea_woo_checkout_cart_update_enable'] ) {
static::eael_checkout_cart_quantity_input_print( $_product, $cart_item_key, $cart_item );
}else {
echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '&times;&nbsp;%s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key );
}
} // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
<?php if( $settings['ea_woo_checkout_layout'] == 'default' ) { ?>
<div class="table-col-2 product-quantity">
<?php
if( !empty( $settings['ea_woo_checkout_cart_update_enable'] ) && 'yes' === $settings['ea_woo_checkout_cart_update_enable'] ) {
static::eael_checkout_cart_quantity_input_print( $_product, $cart_item_key, $cart_item );
} else {
echo apply_filters( 'woocommerce_checkout_cart_item_quantity', $cart_item['quantity'], $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
<?php } ?>
<div class="table-col-3 product-total eael-checkout-cart-item-total">
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</li>
<?php
}
}
do_action( 'woocommerce_review_order_after_cart_contents' );
?>
</ul>
<div class="ea-order-review-table-footer">
<!-- Show default text (from woocommerce) if change label control (ea_woo_checkout_table_header_text) is off -->
<?php $woo_checkout_order_details_change_label_settings = !empty($settings['ea_woo_checkout_table_header_text']) ? CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_header_text']) : ''; ?>
<?php
if($settings['ea_woo_checkout_shop_link'] == 'yes') { ?>
<div class="back-to-shop">
<a class="back-to-shopping" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
<?php //if($woo_checkout_order_details_change_label_settings == 'yes') : ?>
<!-- <i class="fas fa-long-arrow-alt-left"></i>--><?php //echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_shop_link_text']); ?>
<?php //else : ?>
<!-- <i class="fas fa-long-arrow-alt-left"></i>--><?php //esc_html_e( 'Continue Shopping', 'essential-addons-for-elementor-lite' ); ?>
<?php //endif; ?>
<i class="fas fa-long-arrow-alt-left"></i><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_shop_link_text']); ?>
</a>
</div>
<?php } ?>
<div class="footer-content">
<div class="cart-subtotal">
<?php if($woo_checkout_order_details_change_label_settings == 'yes') : ?>
<div><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_subtotal_text']); ?></div>
<?php else : ?>
<?php esc_html_e( 'Subtotal', 'essential-addons-for-elementor-lite' ); ?>
<?php endif; ?>
<div class="eael-checkout-cart-subtotal"><?php wc_cart_totals_subtotal_html(); ?></div>
</div>
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<div class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<div><?php wc_cart_totals_coupon_label( $coupon ); ?></div>
<div><?php wc_cart_totals_coupon_html( $coupon ); ?></div>
</div>
<?php endforeach; ?>
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
<div class="shipping-area">
<?php
wc_cart_totals_shipping_html();
?>
</div>
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
<?php endif; ?>
<?php do_action('eael_woo_checkout_before_cart_get_fees', WC()); ?>
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
<?php apply_filters('eael_woo_checkout_cart_fee', $fee); ?>
<div class="fee">
<div><?php echo esc_html( $fee->name ); ?></div>
<div><?php wc_cart_totals_fee_html( $fee ); ?></div>
</div>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited ?>
<div class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<div><?php echo esc_html( $tax->label ); ?></div>
<div><?php echo wp_kses_post( $tax->formatted_amount ); ?></div>
</div>
<?php endforeach; ?>
<?php else : ?>
<div class="tax-total">
<div><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></div>
<div><?php wc_cart_totals_taxes_total_html(); ?></div>
</div>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
<div class="order-total">
<?php if($woo_checkout_order_details_change_label_settings == 'yes') : ?>
<div><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_table_total_text']); ?></div>
<?php else : ?>
<?php esc_html_e( 'Total', 'essential-addons-for-elementor-lite' ); ?>
<?php endif; ?>
<div class="eael-checkout-cart-total"><?php wc_cart_totals_order_total_html(); ?></div>
</div>
<?php
if( class_exists('WC_Subscriptions_Cart') && (\WC_Subscriptions_Cart::cart_contains_subscription())) {
echo '<table class="recurring-wrapper">';
do_action( 'eael_display_recurring_total_total' );
echo '</table>';
}
?>
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
</div>
</div>
</div>
<?php
}
/**
* Show the default layout.
*/
public static function render_default_template_($checkout, $settings) {
?>
<?php
// If checkout registration is disabled and not logged in, the user cannot checkout.
if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) {
echo esc_html( apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'essential-addons-for-elementor-lite' ) ) );
return;
}
?>
<?php do_action( 'woocommerce_before_checkout_form', $checkout ); ?>
<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
<?php if ( $checkout->get_checkout_fields() ) : ?>
<?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>
<div class="col2-set" id="customer_details">
<div class="col-1">
<?php do_action( 'woocommerce_checkout_billing' ); ?>
</div>
<div class="col-2">
<?php do_action( 'woocommerce_checkout_shipping' ); ?>
</div>
</div>
<?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>
<?php endif; ?>
<?php do_action( 'woocommerce_checkout_order_review' ); ?>
</form>
<?php
do_action('woocommerce_after_checkout_form', $checkout);
}
/**
* Output the billing form.
*/
public function ea_checkout_form_billing() {
// Get checkout object.
$checkout = WC()->checkout();
$settings = self::ea_get_woo_checkout_settings();
?>
<div class="woocommerce-billing-fields">
<?php if ( wc_ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>
<h3><?php esc_html_e( 'Billing &amp; Shipping', 'essential-addons-for-elementor-lite' ); ?></h3>
<?php else : ?>
<h3><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_billing_title']); ?></h3>
<?php endif; ?>
<?php do_action( 'woocommerce_before_checkout_billing_form', $checkout ); ?>
<div class="woocommerce-billing-fields__field-wrapper">
<?php
$fields = $checkout->get_checkout_fields( 'billing' );
foreach ( $fields as $key => $field ) {
woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
}
?>
</div>
<?php do_action( 'woocommerce_after_checkout_billing_form', $checkout ); ?>
</div>
<?php if ( ! is_user_logged_in() && $checkout->is_registration_enabled() ) : ?>
<div class="woocommerce-account-fields">
<?php if ( ! $checkout->is_registration_required() ) : ?>
<p class="form-row form-row-wide create-account">
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
<input class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" id="createaccount" <?php checked( ( true === $checkout->get_value( 'createaccount' ) || ( true === apply_filters( 'woocommerce_create_account_default_checked', false ) ) ), true ); ?> type="checkbox" name="createaccount" value="1" /> <span><?php esc_html_e( 'Create an account?', 'essential-addons-for-elementor-lite' ); ?></span>
</label>
</p>
<?php endif; ?>
<?php do_action( 'woocommerce_before_checkout_registration_form', $checkout ); ?>
<?php if ( $checkout->get_checkout_fields( 'account' ) ) : ?>
<div class="create-account">
<?php foreach ( $checkout->get_checkout_fields( 'account' ) as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
<div class="clear"></div>
</div>
<?php endif; ?>
<?php do_action( 'woocommerce_after_checkout_registration_form', $checkout ); ?>
</div>
<?php endif;
}
/**
* Output the shipping form.
*/
public function ea_checkout_form_shipping() {
// Get checkout object.
$checkout = WC()->checkout();
$settings = self::ea_get_woo_checkout_settings();
?>
<div class="woocommerce-shipping-fields">
<?php if ( true === WC()->cart->needs_shipping_address() ) : ?>
<h3 id="ship-to-different-address">
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
<input id="ship-to-different-address-checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" <?php checked( apply_filters( 'woocommerce_ship_to_different_address_checked', 'shipping' === get_option( 'woocommerce_ship_to_destination' ) ? 1 : 0 ), 1 ); ?> type="checkbox" name="ship_to_different_address" value="1" /> <span><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_shipping_title']); ?></span>
</label>
</h3>
<div class="shipping_address">
<?php do_action( 'woocommerce_before_checkout_shipping_form', $checkout ); ?>
<div class="woocommerce-shipping-fields__field-wrapper">
<?php
$fields = $checkout->get_checkout_fields( 'shipping' );
foreach ( $fields as $key => $field ) {
woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
}
?>
</div>
<?php do_action( 'woocommerce_after_checkout_shipping_form', $checkout ); ?>
</div>
<?php endif; ?>
</div>
<div class="woocommerce-additional-fields">
<?php do_action( 'woocommerce_before_order_notes', $checkout ); ?>
<?php if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' === get_option( 'woocommerce_enable_order_comments', 'yes' ) ) ) : ?>
<?php if ( ! WC()->cart->needs_shipping() || wc_ship_to_billing_address_only() ) : ?>
<h3><?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_additional_info_title']); ?></h3>
<?php endif; ?>
<div class="woocommerce-additional-fields__field-wrapper">
<?php foreach ( $checkout->get_checkout_fields( 'order' ) as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php do_action( 'woocommerce_after_order_notes', $checkout ); ?>
</div>
<?php }
/**
* Output the payment.
*/
public function ea_checkout_payment() {
if ( WC()->cart->needs_payment() ) {
$available_gateways = WC()->payment_gateways()->get_available_payment_gateways();
WC()->payment_gateways()->set_current_gateway( $available_gateways );
} else {
$available_gateways = array();
}
$settings = self::ea_get_woo_checkout_settings();
?>
<div class="woo-checkout-payment">
<?php do_action('eael_wc_multistep_checkout_after_shipping'); ?>
<h3 id="payment-title" class="woo-checkout-section-title">
<?php echo CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_payment_title']); ?>
</h3>
<?php wc_get_template(
'checkout/payment.php',
array(
'checkout' => WC()->checkout(),
'available_gateways' => $available_gateways,
'order_button_text' => apply_filters( 'woocommerce_order_button_text', CheckoutHelperCLass::eael_wp_kses($settings['ea_woo_checkout_place_order_text']) ),
)
); ?>
</div>
<?php }
public function custom_shipping_package_name( $name ) {
if( ! empty( self::$setting_data[ 'ea_woo_checkout_table_shipping_text' ] ) ) {
$name = self::$setting_data['ea_woo_checkout_table_shipping_text'];
}
return $name;
}
/**
* Added all actions
*/
public function ea_woo_checkout_add_actions($settings) {
self::ea_set_woo_checkout_settings($settings);
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
if(!did_action('woocommerce_before_checkout_form')){
add_action( 'woocommerce_before_checkout_form', [ $this, 'ea_login_template' ], 10 );
add_action( 'woocommerce_before_checkout_form', [ $this, 'ea_coupon_template' ], 10 );
}
if( $settings['ea_woo_checkout_layout'] == 'default' ) {
if(!did_action('woocommerce_before_checkout_form')){
add_action( 'woocommerce_before_checkout_form', [ $this, 'checkout_order_review_template' ], 9 );
}
}
$wc_checkout_instance = WC()->checkout();
remove_action( 'woocommerce_checkout_billing', [ $wc_checkout_instance, 'checkout_form_billing' ] );
remove_action( 'woocommerce_checkout_shipping', [ $wc_checkout_instance, 'checkout_form_shipping' ] );
if(!did_action('woocommerce_checkout_billing')){
add_action( 'woocommerce_checkout_billing', [ $this, 'ea_checkout_form_billing' ], 10);
}
if(!did_action('woocommerce_checkout_shipping')){
add_action( 'woocommerce_checkout_shipping', [ $this, 'ea_checkout_form_shipping' ], 10 );
}
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
if(!did_action('woocommerce_checkout_order_review')){
add_action( 'woocommerce_checkout_order_review', [ $this, 'ea_checkout_payment' ], 20 );
}
remove_action('woocommerce_checkout_billing', [ $wc_checkout_instance, 'checkout_form_shipping' ]);
add_filter('woocommerce_shipping_package_name', [ $this, 'custom_shipping_package_name' ], 10, 3);
}
/**
* Print quantity input field
* @return void
*
* @since 5.1.4
*/
public static function eael_checkout_cart_quantity_input_print($_product, $cart_item_key, $cart_item){
if ( $_product->is_sold_individually() ) {
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
} else {
$product_quantity = woocommerce_quantity_input(
[
'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'],
'max_value' => $_product->get_max_purchase_quantity(),
'min_value' => '0',
'product_name' => $_product->get_name(),
'classes' => array('eael-checkout-cart-qty-input', 'input-text', 'qty', 'text'),
],
$_product,
false
);
}
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity,
$cart_item_key, $cart_item ); // PHPCS: XSS ok.
}
}

View File

@@ -0,0 +1 @@
<?php // Silence is golden

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