first commit
This commit is contained in:
@@ -0,0 +1,855 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
|
||||
use Elementor\Modules\DynamicTags\Module as TagsModule;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Elementor 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 Group_Control_Background extends Group_Control_Base {
|
||||
|
||||
/**
|
||||
* Fields.
|
||||
*
|
||||
* Holds all the background control fields.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
* @static
|
||||
*
|
||||
* @var array Background control fields.
|
||||
*/
|
||||
protected static $fields;
|
||||
|
||||
/**
|
||||
* Background Types.
|
||||
*
|
||||
* Holds all the available background types.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access private
|
||||
* @static
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $background_types;
|
||||
|
||||
/**
|
||||
* Get background control type.
|
||||
*
|
||||
* Retrieve the control type, in this case `background`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return string Control type.
|
||||
*/
|
||||
public static function get_type() {
|
||||
return 'background';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get background control types.
|
||||
*
|
||||
* Retrieve available background types.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return array Available background types.
|
||||
*/
|
||||
public static function get_background_types() {
|
||||
if ( null === self::$background_types ) {
|
||||
self::$background_types = self::get_default_background_types();
|
||||
}
|
||||
|
||||
return self::$background_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Default background types.
|
||||
*
|
||||
* Retrieve background control initial types.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @access private
|
||||
* @static
|
||||
*
|
||||
* @return array Default background types.
|
||||
*/
|
||||
private static function get_default_background_types() {
|
||||
return [
|
||||
'classic' => [
|
||||
'title' => esc_html__( 'Classic', 'elementor' ),
|
||||
'icon' => 'eicon-paint-brush',
|
||||
],
|
||||
'gradient' => [
|
||||
'title' => esc_html__( 'Gradient', 'elementor' ),
|
||||
'icon' => 'eicon-barcode',
|
||||
],
|
||||
'video' => [
|
||||
'title' => esc_html__( 'Video', 'elementor' ),
|
||||
'icon' => 'eicon-video-camera',
|
||||
],
|
||||
'slideshow' => [
|
||||
'title' => esc_html__( 'Slideshow', 'elementor' ),
|
||||
'icon' => 'eicon-slideshow',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Init fields.
|
||||
*
|
||||
* Initialize background control fields.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access public
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
public function init_fields() {
|
||||
$active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints();
|
||||
|
||||
$location_device_args = [];
|
||||
$location_device_defaults = [
|
||||
'default' => [
|
||||
'unit' => '%',
|
||||
],
|
||||
];
|
||||
|
||||
$angel_device_args = [];
|
||||
$angel_device_defaults = [
|
||||
'default' => [
|
||||
'unit' => 'deg',
|
||||
],
|
||||
];
|
||||
|
||||
$position_device_args = [];
|
||||
$position_device_defaults = [
|
||||
'default' => 'center center',
|
||||
];
|
||||
|
||||
foreach ( $active_breakpoints as $breakpoint_name => $breakpoint ) {
|
||||
$location_device_args[ $breakpoint_name ] = $location_device_defaults;
|
||||
$angel_device_args[ $breakpoint_name ] = $angel_device_defaults;
|
||||
$position_device_args[ $breakpoint_name ] = $position_device_defaults;
|
||||
}
|
||||
|
||||
$fields = [];
|
||||
|
||||
$fields['background'] = [
|
||||
'label' => esc_html__( 'Background Type', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'render_type' => 'ui',
|
||||
];
|
||||
|
||||
$fields['gradient_notice'] = [
|
||||
'type' => Controls_Manager::ALERT,
|
||||
'alert_type' => 'warning',
|
||||
'content' => esc_html__( 'Set locations and angle for each breakpoint to ensure the gradient adapts to different screen sizes.', 'elementor' ),
|
||||
'render_type' => 'ui',
|
||||
'condition' => [
|
||||
'background' => [ 'gradient' ],
|
||||
],
|
||||
];
|
||||
|
||||
$fields['color'] = [
|
||||
'label' => esc_html__( 'Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'default' => '',
|
||||
'title' => esc_html__( 'Background Color', 'elementor' ),
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'background-color: {{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,
|
||||
],
|
||||
'device_args' => $location_device_args,
|
||||
'responsive' => true,
|
||||
'render_type' => 'ui',
|
||||
'condition' => [
|
||||
'background' => [ 'gradient' ],
|
||||
],
|
||||
'of_type' => 'gradient',
|
||||
];
|
||||
|
||||
$fields['color_b'] = [
|
||||
'label' => esc_html__( 'Second Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'default' => '#f2295b',
|
||||
'render_type' => 'ui',
|
||||
'control_type' => 'content',
|
||||
'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,
|
||||
],
|
||||
'device_args' => $location_device_args,
|
||||
'responsive' => true,
|
||||
'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__( 'Linear', 'elementor' ),
|
||||
'radial' => esc_html__( 'Radial', 'elementor' ),
|
||||
],
|
||||
'default' => 'linear',
|
||||
'render_type' => 'ui',
|
||||
'condition' => [
|
||||
'background' => [ 'gradient' ],
|
||||
],
|
||||
'of_type' => 'gradient',
|
||||
];
|
||||
|
||||
$fields['gradient_angle'] = [
|
||||
'label' => esc_html__( 'Angle', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'size_units' => [ 'deg', 'grad', 'rad', 'turn', 'custom' ],
|
||||
'default' => [
|
||||
'unit' => 'deg',
|
||||
'size' => 180,
|
||||
],
|
||||
'device_args' => $angel_device_args,
|
||||
'responsive' => true,
|
||||
'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__( 'Position', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'options' => [
|
||||
'center center' => esc_html__( 'Center Center', 'elementor' ),
|
||||
'center left' => esc_html__( 'Center Left', 'elementor' ),
|
||||
'center right' => esc_html__( 'Center Right', 'elementor' ),
|
||||
'top center' => esc_html__( 'Top Center', 'elementor' ),
|
||||
'top left' => esc_html__( 'Top Left', 'elementor' ),
|
||||
'top right' => esc_html__( 'Top Right', 'elementor' ),
|
||||
'bottom center' => esc_html__( 'Bottom Center', 'elementor' ),
|
||||
'bottom left' => esc_html__( 'Bottom Left', 'elementor' ),
|
||||
'bottom right' => esc_html__( 'Bottom Right', 'elementor' ),
|
||||
],
|
||||
'default' => 'center center',
|
||||
'device_args' => $position_device_args,
|
||||
'responsive' => true,
|
||||
'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__( 'Image', 'elementor' ),
|
||||
'type' => Controls_Manager::MEDIA,
|
||||
'ai' => [
|
||||
'category' => 'background',
|
||||
],
|
||||
'dynamic' => [
|
||||
'active' => true,
|
||||
],
|
||||
'responsive' => true,
|
||||
'title' => esc_html__( 'Background Image', 'elementor' ),
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'background-image: url("{{URL}}");',
|
||||
],
|
||||
'has_sizes' => true,
|
||||
'render_type' => 'template',
|
||||
'condition' => [
|
||||
'background' => [ 'classic' ],
|
||||
],
|
||||
];
|
||||
|
||||
$fields['position'] = [
|
||||
'label' => esc_html__( 'Position', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => '',
|
||||
'separator' => 'before',
|
||||
'responsive' => true,
|
||||
'options' => [
|
||||
'' => esc_html__( 'Default', 'elementor' ),
|
||||
'center center' => esc_html__( 'Center Center', 'elementor' ),
|
||||
'center left' => esc_html__( 'Center Left', 'elementor' ),
|
||||
'center right' => esc_html__( 'Center Right', 'elementor' ),
|
||||
'top center' => esc_html__( 'Top Center', 'elementor' ),
|
||||
'top left' => esc_html__( 'Top Left', 'elementor' ),
|
||||
'top right' => esc_html__( 'Top Right', 'elementor' ),
|
||||
'bottom center' => esc_html__( 'Bottom Center', 'elementor' ),
|
||||
'bottom left' => esc_html__( 'Bottom Left', 'elementor' ),
|
||||
'bottom right' => esc_html__( 'Bottom Right', 'elementor' ),
|
||||
'initial' => esc_html__( 'Custom', 'elementor' ),
|
||||
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'background-position: {{VALUE}};',
|
||||
],
|
||||
'condition' => [
|
||||
'background' => [ 'classic' ],
|
||||
'image[url]!' => '',
|
||||
],
|
||||
];
|
||||
|
||||
$fields['xpos'] = [
|
||||
'label' => esc_html__( 'X Position', '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__( 'Y Position', '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__( 'Default', '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' ),
|
||||
'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__( 'Default', 'elementor' ),
|
||||
'no-repeat' => esc_html__( 'No-repeat', 'elementor' ),
|
||||
'repeat' => esc_html__( 'Repeat', 'elementor' ),
|
||||
'repeat-x' => esc_html__( 'Repeat-x', 'elementor' ),
|
||||
'repeat-y' => esc_html__( 'Repeat-y', 'elementor' ),
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'background-repeat: {{VALUE}};',
|
||||
],
|
||||
'condition' => [
|
||||
'background' => [ 'classic' ],
|
||||
'image[url]!' => '',
|
||||
],
|
||||
];
|
||||
|
||||
$fields['size'] = [
|
||||
'label' => esc_html__( 'Display 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' ),
|
||||
'initial' => esc_html__( 'Custom', 'elementor' ),
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'background-size: {{VALUE}};',
|
||||
],
|
||||
'condition' => [
|
||||
'background' => [ 'classic' ],
|
||||
'image[url]!' => '',
|
||||
],
|
||||
];
|
||||
|
||||
$fields['bg_width'] = [
|
||||
'label' => esc_html__( 'Width', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'responsive' => true,
|
||||
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'max' => 1000,
|
||||
],
|
||||
],
|
||||
'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__( 'Video Link', '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,
|
||||
],
|
||||
],
|
||||
'ai' => [
|
||||
'active' => false,
|
||||
],
|
||||
'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__( 'Background Fallback', '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__( 'Images', '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__( 'Center Center', 'elementor' ),
|
||||
'center left' => esc_html__( 'Center Left', 'elementor' ),
|
||||
'center right' => esc_html__( 'Center Right', 'elementor' ),
|
||||
'top center' => esc_html__( 'Top Center', 'elementor' ),
|
||||
'top left' => esc_html__( 'Top Left', 'elementor' ),
|
||||
'top right' => esc_html__( 'Top Right', 'elementor' ),
|
||||
'bottom center' => esc_html__( 'Bottom Center', 'elementor' ),
|
||||
'bottom left' => esc_html__( 'Bottom Left', 'elementor' ),
|
||||
'bottom right' => esc_html__( 'Bottom Right', '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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get child default args.
|
||||
*
|
||||
* Retrieve the default arguments for all the child controls for a specific group
|
||||
* control.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default arguments for all the child controls.
|
||||
*/
|
||||
protected function get_child_default_args() {
|
||||
return [
|
||||
'types' => [ 'classic', 'gradient' ],
|
||||
'selector' => '{{WRAPPER}}:not(.elementor-motion-effects-element-type-background), {{WRAPPER}} > .elementor-motion-effects-container > .elementor-motion-effects-layer',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter fields.
|
||||
*
|
||||
* Filter which controls to display, using `include`, `exclude`, `condition`
|
||||
* and `of_type` arguments.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
protected function filter_fields() {
|
||||
$fields = parent::filter_fields();
|
||||
|
||||
$args = $this->get_args();
|
||||
|
||||
foreach ( $fields as &$field ) {
|
||||
if ( isset( $field['of_type'] ) && ! in_array( $field['of_type'], $args['types'] ) ) {
|
||||
unset( $field );
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare fields.
|
||||
*
|
||||
* Process background control fields before adding them to `add_control()`.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @param array $fields Background control fields.
|
||||
*
|
||||
* @return array Processed fields.
|
||||
*/
|
||||
protected function prepare_fields( $fields ) {
|
||||
$args = $this->get_args();
|
||||
|
||||
$background_types = self::get_background_types();
|
||||
|
||||
$choose_types = [];
|
||||
|
||||
foreach ( $args['types'] as $type ) {
|
||||
if ( isset( $background_types[ $type ] ) ) {
|
||||
$choose_types[ $type ] = $background_types[ $type ];
|
||||
}
|
||||
}
|
||||
|
||||
$fields['background']['options'] = $choose_types;
|
||||
|
||||
return parent::prepare_fields( $fields );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default options.
|
||||
*
|
||||
* Retrieve the default options of the background control. Used to return the
|
||||
* default options while initializing the background control.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default background control options.
|
||||
*/
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
592
wp-content/plugins/elementor/includes/controls/groups/base.php
Normal file
592
wp-content/plugins/elementor/includes/controls/groups/base.php
Normal file
@@ -0,0 +1,592 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Elementor group control base.
|
||||
*
|
||||
* An abstract class for creating new group controls in the panel.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @abstract
|
||||
*/
|
||||
abstract class Group_Control_Base implements Group_Control_Interface {
|
||||
|
||||
/**
|
||||
* Arguments.
|
||||
*
|
||||
* Holds all the group control arguments.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @var array Group control arguments.
|
||||
*/
|
||||
private $args = [];
|
||||
|
||||
/**
|
||||
* Options.
|
||||
*
|
||||
* Holds all the group control options.
|
||||
*
|
||||
* Currently supports only the popover options.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @var array Group control options.
|
||||
*/
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* Get options.
|
||||
*
|
||||
* Retrieve group control options. If options are not set, it will initialize default options.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @access public
|
||||
*
|
||||
* @param array $option Optional. Single option.
|
||||
*
|
||||
* @return mixed Group control options. If option parameter was not specified, it will
|
||||
* return an array of all the options. If single option specified, it will
|
||||
* return the option value or `null` if option does not exists.
|
||||
*/
|
||||
final public function get_options( $option = null ) {
|
||||
if ( null === $this->options ) {
|
||||
$this->init_options();
|
||||
}
|
||||
|
||||
if ( $option ) {
|
||||
if ( isset( $this->options[ $option ] ) ) {
|
||||
return $this->options[ $option ];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new controls to stack.
|
||||
*
|
||||
* Register multiple controls to allow the user to set/update data.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param Controls_Stack $element The element stack.
|
||||
* @param array $user_args The control arguments defined by the user.
|
||||
* @param array $options Optional. The element options. Default is
|
||||
* an empty array.
|
||||
*/
|
||||
final public function add_controls( Controls_Stack $element, array $user_args, array $options = [] ) {
|
||||
$this->init_args( $user_args );
|
||||
|
||||
// Filter which controls to display
|
||||
$filtered_fields = $this->filter_fields();
|
||||
$filtered_fields = $this->prepare_fields( $filtered_fields );
|
||||
|
||||
// For php < 7
|
||||
reset( $filtered_fields );
|
||||
|
||||
if ( isset( $this->args['separator'] ) ) {
|
||||
$filtered_fields[ key( $filtered_fields ) ]['separator'] = $this->args['separator'];
|
||||
}
|
||||
|
||||
$has_injection = false;
|
||||
|
||||
if ( ! empty( $options['position'] ) ) {
|
||||
$has_injection = true;
|
||||
|
||||
$element->start_injection( $options['position'] );
|
||||
|
||||
unset( $options['position'] );
|
||||
}
|
||||
|
||||
if ( $this->get_options( 'popover' ) ) {
|
||||
$this->start_popover( $element );
|
||||
}
|
||||
|
||||
foreach ( $filtered_fields as $field_id => $field_args ) {
|
||||
// Add the global group args to the control
|
||||
$field_args = $this->add_group_args_to_field( $field_id, $field_args );
|
||||
|
||||
// Register the control
|
||||
$id = $this->get_controls_prefix() . $field_id;
|
||||
|
||||
if ( ! empty( $field_args['responsive'] ) ) {
|
||||
unset( $field_args['responsive'] );
|
||||
|
||||
$element->add_responsive_control( $id, $field_args, $options );
|
||||
} else {
|
||||
$element->add_control( $id, $field_args, $options );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->get_options( 'popover' ) ) {
|
||||
$element->end_popover();
|
||||
}
|
||||
|
||||
if ( $has_injection ) {
|
||||
$element->end_injection();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arguments.
|
||||
*
|
||||
* Retrieve group control arguments.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*
|
||||
* @return array Group control arguments.
|
||||
*/
|
||||
final public function get_args() {
|
||||
return $this->args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fields.
|
||||
*
|
||||
* Retrieve group control fields.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access public
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
final public function get_fields() {
|
||||
if ( null === static::$fields ) {
|
||||
static::$fields = $this->init_fields();
|
||||
}
|
||||
|
||||
return static::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get controls prefix.
|
||||
*
|
||||
* Retrieve the prefix of the group control, which is `{{ControlName}}_`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*
|
||||
* @return string Control prefix.
|
||||
*/
|
||||
public function get_controls_prefix() {
|
||||
return $this->args['name'] . '_';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get group control classes.
|
||||
*
|
||||
* Retrieve the classes of the group control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*
|
||||
* @return string Group control classes.
|
||||
*/
|
||||
public function get_base_group_classes() {
|
||||
return 'elementor-group-control-' . static::get_type() . ' elementor-group-control';
|
||||
}
|
||||
|
||||
/**
|
||||
* Init fields.
|
||||
*
|
||||
* Initialize group control fields.
|
||||
*
|
||||
* @abstract
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*/
|
||||
abstract protected function init_fields();
|
||||
|
||||
/**
|
||||
* Get default options.
|
||||
*
|
||||
* Retrieve the default options of the group control. Used to return the
|
||||
* default options while initializing the group control.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default group control options.
|
||||
*/
|
||||
protected function get_default_options() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get child default arguments.
|
||||
*
|
||||
* Retrieve the default arguments for all the child controls for a specific group
|
||||
* control.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default arguments for all the child controls.
|
||||
*/
|
||||
protected function get_child_default_args() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter fields.
|
||||
*
|
||||
* Filter which controls to display, using `include`, `exclude` and the
|
||||
* `condition` arguments.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
protected function filter_fields() {
|
||||
$args = $this->get_args();
|
||||
|
||||
$fields = $this->get_fields();
|
||||
|
||||
if ( ! empty( $args['include'] ) ) {
|
||||
$fields = array_intersect_key( $fields, array_flip( $args['include'] ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $args['exclude'] ) ) {
|
||||
$fields = array_diff_key( $fields, array_flip( $args['exclude'] ) );
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add group arguments to field.
|
||||
*
|
||||
* Register field arguments to group control.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @param string $control_id Group control id.
|
||||
* @param array $field_args Group control field arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function add_group_args_to_field( $control_id, $field_args ) {
|
||||
$args = $this->get_args();
|
||||
|
||||
if ( ! empty( $args['tab'] ) ) {
|
||||
$field_args['tab'] = $args['tab'];
|
||||
}
|
||||
|
||||
if ( ! empty( $args['section'] ) ) {
|
||||
$field_args['section'] = $args['section'];
|
||||
}
|
||||
|
||||
$field_args['classes'] = $this->get_base_group_classes() . ' elementor-group-control-' . $control_id;
|
||||
|
||||
foreach ( [ 'condition', 'conditions' ] as $condition_type ) {
|
||||
if ( ! empty( $args[ $condition_type ] ) ) {
|
||||
if ( empty( $field_args[ $condition_type ] ) ) {
|
||||
$field_args[ $condition_type ] = [];
|
||||
}
|
||||
|
||||
$field_args[ $condition_type ] += $args[ $condition_type ];
|
||||
}
|
||||
}
|
||||
|
||||
return $field_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare fields.
|
||||
*
|
||||
* Process group control fields before adding them to `add_control()`.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @param array $fields Group control fields.
|
||||
*
|
||||
* @return array Processed fields.
|
||||
*/
|
||||
protected function prepare_fields( $fields ) {
|
||||
$popover_options = $this->get_options( 'popover' );
|
||||
|
||||
$popover_name = ! $popover_options ? null : $popover_options['starter_name'];
|
||||
|
||||
foreach ( $fields as $field_key => &$field ) {
|
||||
if ( $popover_name ) {
|
||||
$field['condition'][ $popover_name . '!' ] = '';
|
||||
}
|
||||
|
||||
if ( isset( $this->args['fields_options']['__all'] ) ) {
|
||||
$field = array_merge( $field, $this->args['fields_options']['__all'] );
|
||||
}
|
||||
|
||||
if ( isset( $this->args['fields_options'][ $field_key ] ) ) {
|
||||
$field = array_merge( $field, $this->args['fields_options'][ $field_key ] );
|
||||
}
|
||||
|
||||
if ( ! empty( $field['condition'] ) ) {
|
||||
$field = $this->add_condition_prefix( $field );
|
||||
}
|
||||
|
||||
if ( ! empty( $field['conditions'] ) ) {
|
||||
$field['conditions'] = $this->add_conditions_prefix( $field['conditions'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $field['selectors'] ) ) {
|
||||
$field['selectors'] = $this->handle_selectors( $field['selectors'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $field['device_args'] ) ) {
|
||||
foreach ( $field['device_args'] as $device => $device_arg ) {
|
||||
if ( ! empty( $field['device_args'][ $device ]['condition'] ) ) {
|
||||
$field['device_args'][ $device ] = $this->add_condition_prefix( $field['device_args'][ $device ] );
|
||||
}
|
||||
|
||||
if ( ! empty( $field['device_args'][ $device ]['conditions'] ) ) {
|
||||
$field['device_args'][ $device ]['conditions'] = $this->add_conditions_prefix( $field['device_args'][ $device ]['conditions'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $device_arg['selectors'] ) ) {
|
||||
$field['device_args'][ $device ]['selectors'] = $this->handle_selectors( $device_arg['selectors'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init options.
|
||||
*
|
||||
* Initializing group control options.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @access private
|
||||
*/
|
||||
private function init_options() {
|
||||
$default_options = [
|
||||
'popover' => [
|
||||
'starter_name' => 'popover_toggle',
|
||||
'starter_value' => 'custom',
|
||||
'starter_title' => '',
|
||||
],
|
||||
];
|
||||
|
||||
$this->options = array_replace_recursive( $default_options, $this->get_default_options() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init arguments.
|
||||
*
|
||||
* Initializing group control base class.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @param array $args Group control settings value.
|
||||
*/
|
||||
protected function init_args( $args ) {
|
||||
$this->args = array_merge( $this->get_default_args(), $this->get_child_default_args(), $args );
|
||||
|
||||
if ( isset( $this->args['scheme'] ) ) {
|
||||
$this->args['global']['default'] = Plugin::$instance->kits_manager->convert_scheme_to_global( $this->args['scheme'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default arguments.
|
||||
*
|
||||
* Retrieve the default arguments of the group control. Used to return the
|
||||
* default arguments while initializing the group control.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access private
|
||||
*
|
||||
* @return array Control default arguments.
|
||||
*/
|
||||
private function get_default_args() {
|
||||
return [
|
||||
'default' => '',
|
||||
'selector' => '{{WRAPPER}}',
|
||||
'fields_options' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add condition prefix.
|
||||
*
|
||||
* Used to add the group prefix to controls with conditions, to
|
||||
* distinguish them from other controls with the same name.
|
||||
*
|
||||
* This way Elementor can apply condition logic to a specific control in a
|
||||
* group control.
|
||||
*
|
||||
* @since 1.2.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $field Group control field.
|
||||
*
|
||||
* @return array Group control field.
|
||||
*/
|
||||
private function add_condition_prefix( $field ) {
|
||||
$controls_prefix = $this->get_controls_prefix();
|
||||
|
||||
$prefixed_condition_keys = array_map(
|
||||
function( $key ) use ( $controls_prefix ) {
|
||||
return $controls_prefix . $key;
|
||||
},
|
||||
array_keys( $field['condition'] )
|
||||
);
|
||||
|
||||
$field['condition'] = array_combine(
|
||||
$prefixed_condition_keys,
|
||||
$field['condition']
|
||||
);
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
private function add_conditions_prefix( $conditions ) {
|
||||
$controls_prefix = $this->get_controls_prefix();
|
||||
|
||||
foreach ( $conditions['terms'] as & $condition ) {
|
||||
if ( isset( $condition['terms'] ) ) {
|
||||
$condition = $this->add_conditions_prefix( $condition );
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$condition['name'] = $controls_prefix . $condition['name'];
|
||||
}
|
||||
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle selectors.
|
||||
*
|
||||
* Used to process the CSS selector of group control fields. When using
|
||||
* group control, Elementor needs to apply the selector to different fields.
|
||||
* This method handles the process.
|
||||
*
|
||||
* In addition, it handles selector values from other fields and process the
|
||||
* css.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access private
|
||||
*
|
||||
* @param array $selectors An array of selectors to process.
|
||||
*
|
||||
* @return array Processed selectors.
|
||||
*/
|
||||
private function handle_selectors( $selectors ) {
|
||||
$args = $this->get_args();
|
||||
|
||||
$selectors = array_combine(
|
||||
array_map(
|
||||
function( $key ) use ( $args ) {
|
||||
return str_replace( '{{SELECTOR}}', $args['selector'], $key );
|
||||
}, array_keys( $selectors )
|
||||
),
|
||||
$selectors
|
||||
);
|
||||
|
||||
if ( ! $selectors ) {
|
||||
return $selectors;
|
||||
}
|
||||
|
||||
$controls_prefix = $this->get_controls_prefix();
|
||||
|
||||
foreach ( $selectors as &$selector ) {
|
||||
$selector = preg_replace_callback( '/{{\K(.*?)(?=}})/', function( $matches ) use ( $controls_prefix ) {
|
||||
$is_external_reference = false;
|
||||
|
||||
return preg_replace_callback( '/[^ ]+?(?=\.)\./', function( $sub_matches ) use ( $controls_prefix, &$is_external_reference ) {
|
||||
$placeholder = $sub_matches[0];
|
||||
|
||||
if ( 'external.' === $placeholder ) {
|
||||
$is_external_reference = true;
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( $is_external_reference ) {
|
||||
$is_external_reference = false;
|
||||
|
||||
return $placeholder;
|
||||
}
|
||||
|
||||
return $controls_prefix . $placeholder;
|
||||
}, $matches[1] );
|
||||
}, $selector );
|
||||
}
|
||||
|
||||
return $selectors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start popover.
|
||||
*
|
||||
* Starts a group controls popover.
|
||||
*
|
||||
* @since 1.9.1
|
||||
* @access private
|
||||
* @param Controls_Stack $element Element.
|
||||
*/
|
||||
private function start_popover( Controls_Stack $element ) {
|
||||
$popover_options = $this->get_options( 'popover' );
|
||||
|
||||
$settings = $this->get_args();
|
||||
|
||||
if ( isset( $settings['global'] ) ) {
|
||||
if ( ! isset( $popover_options['settings']['global'] ) ) {
|
||||
$popover_options['settings']['global'] = [];
|
||||
}
|
||||
|
||||
$popover_options['settings']['global'] = array_replace_recursive( $popover_options['settings']['global'], $settings['global'] );
|
||||
}
|
||||
|
||||
if ( isset( $settings['label'] ) ) {
|
||||
$label = $settings['label'];
|
||||
} else {
|
||||
$label = $popover_options['starter_title'];
|
||||
}
|
||||
|
||||
$control_params = [
|
||||
'type' => Controls_Manager::POPOVER_TOGGLE,
|
||||
'label' => $label,
|
||||
'return_value' => $popover_options['starter_value'],
|
||||
];
|
||||
|
||||
if ( ! empty( $popover_options['settings'] ) ) {
|
||||
$control_params = array_replace_recursive( $control_params, $popover_options['settings'] );
|
||||
}
|
||||
|
||||
foreach ( [ 'condition', 'conditions' ] as $key ) {
|
||||
if ( ! empty( $settings[ $key ] ) ) {
|
||||
$control_params[ $key ] = $settings[ $key ];
|
||||
}
|
||||
}
|
||||
|
||||
$starter_name = $popover_options['starter_name'];
|
||||
|
||||
if ( isset( $this->args['fields_options'][ $starter_name ] ) ) {
|
||||
$control_params = array_merge( $control_params, $this->args['fields_options'][ $starter_name ] );
|
||||
}
|
||||
|
||||
$control_params['groupPrefix'] = $this->get_controls_prefix();
|
||||
|
||||
$element->add_control( $this->get_controls_prefix() . $starter_name, $control_params );
|
||||
|
||||
$element->start_popover();
|
||||
}
|
||||
}
|
||||
120
wp-content/plugins/elementor/includes/controls/groups/border.php
Normal file
120
wp-content/plugins/elementor/includes/controls/groups/border.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Elementor border control.
|
||||
*
|
||||
* A base control for creating border control. Displays input fields to define
|
||||
* border type, border width and border color.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Group_Control_Border extends Group_Control_Base {
|
||||
|
||||
/**
|
||||
* Fields.
|
||||
*
|
||||
* Holds all the border control fields.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @static
|
||||
*
|
||||
* @var array Border control fields.
|
||||
*/
|
||||
protected static $fields;
|
||||
|
||||
/**
|
||||
* Get border control type.
|
||||
*
|
||||
* Retrieve the control type, in this case `border`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return string Control type.
|
||||
*/
|
||||
public static function get_type() {
|
||||
return 'border';
|
||||
}
|
||||
|
||||
/**
|
||||
* Init fields.
|
||||
*
|
||||
* Initialize border control fields.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
protected function init_fields() {
|
||||
$fields = [];
|
||||
|
||||
$fields['border'] = [
|
||||
'label' => esc_html__( 'Border Type', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'options' => [
|
||||
'' => esc_html__( 'Default', 'elementor' ),
|
||||
'none' => esc_html__( 'None', 'elementor' ),
|
||||
'solid' => esc_html__( 'Solid', 'elementor' ),
|
||||
'double' => esc_html__( 'Double', 'elementor' ),
|
||||
'dotted' => esc_html__( 'Dotted', 'elementor' ),
|
||||
'dashed' => esc_html__( 'Dashed', 'elementor' ),
|
||||
'groove' => esc_html__( 'Groove', 'elementor' ),
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'border-style: {{VALUE}};',
|
||||
],
|
||||
];
|
||||
|
||||
$fields['width'] = [
|
||||
'label' => esc_html__( 'Border Width', 'elementor' ),
|
||||
'type' => Controls_Manager::DIMENSIONS,
|
||||
'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
||||
],
|
||||
'condition' => [
|
||||
'border!' => [ '', 'none' ],
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
$fields['color'] = [
|
||||
'label' => esc_html__( 'Border Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'default' => '',
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'border-color: {{VALUE}};',
|
||||
],
|
||||
'condition' => [
|
||||
'border!' => [ '', 'none' ],
|
||||
],
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default options.
|
||||
*
|
||||
* Retrieve the default options of the border control. Used to return the
|
||||
* default options while initializing the border control.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default border control options.
|
||||
*/
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Elementor box shadow control.
|
||||
*
|
||||
* A base control for creating box shadow control. Displays input fields to define
|
||||
* the box shadow including the horizontal shadow, vertical shadow, shadow blur,
|
||||
* shadow spread, shadow color and the position.
|
||||
*
|
||||
* @since 1.2.2
|
||||
*/
|
||||
class Group_Control_Box_Shadow extends Group_Control_Base {
|
||||
|
||||
/**
|
||||
* Fields.
|
||||
*
|
||||
* Holds all the box shadow control fields.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
* @static
|
||||
*
|
||||
* @var array Box shadow control fields.
|
||||
*/
|
||||
protected static $fields;
|
||||
|
||||
/**
|
||||
* Get box shadow control type.
|
||||
*
|
||||
* Retrieve the control type, in this case `box-shadow`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return string Control type.
|
||||
*/
|
||||
public static function get_type() {
|
||||
return 'box-shadow';
|
||||
}
|
||||
|
||||
/**
|
||||
* Init fields.
|
||||
*
|
||||
* Initialize box shadow control fields.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
protected function init_fields() {
|
||||
$controls = [];
|
||||
|
||||
$controls['box_shadow'] = [
|
||||
'label' => esc_html__( 'Box Shadow', 'elementor' ),
|
||||
'type' => Controls_Manager::BOX_SHADOW,
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'box-shadow: {{HORIZONTAL}}px {{VERTICAL}}px {{BLUR}}px {{SPREAD}}px {{COLOR}} {{box_shadow_position.VALUE}};',
|
||||
],
|
||||
];
|
||||
|
||||
$controls['box_shadow_position'] = [
|
||||
'label' => esc_html__( 'Position', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'options' => [
|
||||
' ' => esc_html_x( 'Outline', 'Box Shadow Control', 'elementor' ),
|
||||
'inset' => esc_html_x( 'Inset', 'Box Shadow Control', 'elementor' ),
|
||||
],
|
||||
'default' => ' ',
|
||||
'render_type' => 'ui',
|
||||
];
|
||||
|
||||
return $controls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default options.
|
||||
*
|
||||
* Retrieve the default options of the box shadow control. Used to return the
|
||||
* default options while initializing the box shadow control.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default box shadow control options.
|
||||
*/
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => [
|
||||
'starter_title' => esc_html__( 'Box Shadow', 'elementor' ),
|
||||
'starter_name' => 'box_shadow_type',
|
||||
'starter_value' => 'yes',
|
||||
'settings' => [
|
||||
'render_type' => 'ui',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Elementor CSS Filter control.
|
||||
*
|
||||
* A base control for applying css filters. Displays sliders to define the
|
||||
* values of different CSS filters including blur, brightens, contrast,
|
||||
* saturation and hue.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
class Group_Control_Css_Filter extends Group_Control_Base {
|
||||
|
||||
/**
|
||||
* Prepare fields.
|
||||
*
|
||||
* Process css_filter control fields before adding them to `add_control()`.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @param array $fields CSS filter control fields.
|
||||
*
|
||||
* @return array Processed fields.
|
||||
*/
|
||||
protected static $fields;
|
||||
|
||||
/**
|
||||
* Get CSS filter control type.
|
||||
*
|
||||
* Retrieve the control type, in this case `css-filter`.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return string Control type.
|
||||
*/
|
||||
public static function get_type() {
|
||||
return 'css-filter';
|
||||
}
|
||||
|
||||
/**
|
||||
* Init fields.
|
||||
*
|
||||
* Initialize CSS filter control fields.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
protected function init_fields() {
|
||||
$controls = [];
|
||||
|
||||
$controls['blur'] = [
|
||||
'label' => esc_html_x( 'Blur', 'Filter Control', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'required' => 'true',
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 0,
|
||||
'max' => 10,
|
||||
'step' => 0.1,
|
||||
],
|
||||
],
|
||||
'default' => [
|
||||
'size' => 0,
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'filter: brightness( {{brightness.SIZE}}% ) contrast( {{contrast.SIZE}}% ) saturate( {{saturate.SIZE}}% ) blur( {{blur.SIZE}}px ) hue-rotate( {{hue.SIZE}}deg )',
|
||||
],
|
||||
];
|
||||
|
||||
$controls['brightness'] = [
|
||||
'label' => esc_html_x( 'Brightness', 'Filter Control', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'render_type' => 'ui',
|
||||
'required' => 'true',
|
||||
'default' => [
|
||||
'size' => 100,
|
||||
],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 0,
|
||||
'max' => 200,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$controls['contrast'] = [
|
||||
'label' => esc_html_x( 'Contrast', 'Filter Control', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'render_type' => 'ui',
|
||||
'required' => 'true',
|
||||
'default' => [
|
||||
'size' => 100,
|
||||
],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 0,
|
||||
'max' => 200,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$controls['saturate'] = [
|
||||
'label' => esc_html_x( 'Saturation', 'Filter Control', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'render_type' => 'ui',
|
||||
'required' => 'true',
|
||||
'default' => [
|
||||
'size' => 100,
|
||||
],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 0,
|
||||
'max' => 200,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$controls['hue'] = [
|
||||
'label' => esc_html_x( 'Hue', 'Filter Control', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'render_type' => 'ui',
|
||||
'required' => 'true',
|
||||
'default' => [
|
||||
'size' => 0,
|
||||
],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 0,
|
||||
'max' => 360,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $controls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default options.
|
||||
*
|
||||
* Retrieve the default options of the CSS filter control. Used to return the
|
||||
* default options while initializing the CSS filter control.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default CSS filter control options.
|
||||
*/
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => [
|
||||
'starter_name' => 'css_filter',
|
||||
'starter_title' => esc_html__( 'CSS Filters', 'elementor' ),
|
||||
'settings' => [
|
||||
'render_type' => 'ui',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Group_Control_Flex_Container extends Group_Control_Base {
|
||||
|
||||
protected static $fields;
|
||||
|
||||
public static function get_type() {
|
||||
return 'flex-container';
|
||||
}
|
||||
|
||||
protected function init_fields() {
|
||||
$start = is_rtl() ? 'right' : 'left';
|
||||
$end = is_rtl() ? 'left' : 'right';
|
||||
|
||||
$fields = [];
|
||||
|
||||
$fields['items'] = [
|
||||
'type' => Controls_Manager::HEADING,
|
||||
'label' => esc_html__( 'Items', 'elementor' ),
|
||||
'separator' => 'before',
|
||||
];
|
||||
|
||||
$fields['direction'] = [
|
||||
'label' => esc_html__( 'Direction', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'options' => [
|
||||
'row' => [
|
||||
'title' => esc_html__( 'Row - horizontal', 'elementor' ),
|
||||
'icon' => 'eicon-arrow-' . $end,
|
||||
],
|
||||
'column' => [
|
||||
'title' => esc_html__( 'Column - vertical', 'elementor' ),
|
||||
'icon' => 'eicon-arrow-down',
|
||||
],
|
||||
'row-reverse' => [
|
||||
'title' => esc_html__( 'Row - reversed', 'elementor' ),
|
||||
'icon' => 'eicon-arrow-' . $start,
|
||||
],
|
||||
'column-reverse' => [
|
||||
'title' => esc_html__( 'Column - reversed', 'elementor' ),
|
||||
'icon' => 'eicon-arrow-up',
|
||||
],
|
||||
],
|
||||
'default' => '',
|
||||
// The `--container-widget-width` CSS variable is used for handling widgets that get an undefined width in column mode.
|
||||
// The `--container-widget-flex-grow` CSS variable is used to give certain widgets a default `flex-grow: 1` value for the `flex row` combination.
|
||||
'selectors_dictionary' => [
|
||||
'row' => '--flex-direction: row; --container-widget-width: initial; --container-widget-height: 100%; --container-widget-flex-grow: 1; --container-widget-align-self: stretch; --flex-wrap-mobile: wrap;',
|
||||
'column' => '--flex-direction: column; --container-widget-width: 100%; --container-widget-height: initial; --container-widget-flex-grow: 0; --container-widget-align-self: initial; --flex-wrap-mobile: wrap;',
|
||||
'row-reverse' => '--flex-direction: row-reverse; --container-widget-width: initial; --container-widget-height: 100%; --container-widget-flex-grow: 1; --container-widget-align-self: stretch; --flex-wrap-mobile: wrap-reverse;',
|
||||
'column-reverse' => '--flex-direction: column-reverse; --container-widget-width: 100%; --container-widget-height: initial; --container-widget-flex-grow: 0; --container-widget-align-self: initial; --flex-wrap-mobile: wrap;',
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '{{VALUE}};',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
// Only use the flex direction prefix class inside the editor.
|
||||
$flex_direction_prefix_class = Plugin::$instance->editor->is_edit_mode() ? [ 'prefix_class' => 'e-con--' ] : [];
|
||||
|
||||
$fields['_is_row'] = array_merge( $flex_direction_prefix_class, [
|
||||
'type' => Controls_Manager::HIDDEN,
|
||||
'default' => 'row',
|
||||
'condition' => [
|
||||
'direction' => [
|
||||
'row',
|
||||
'row-reverse',
|
||||
],
|
||||
],
|
||||
] );
|
||||
|
||||
$fields['_is_column'] = array_merge( $flex_direction_prefix_class, [
|
||||
'type' => Controls_Manager::HIDDEN,
|
||||
'default' => 'column',
|
||||
'condition' => [
|
||||
'direction' => [
|
||||
'',
|
||||
'column',
|
||||
'column-reverse',
|
||||
],
|
||||
],
|
||||
] );
|
||||
|
||||
$fields['justify_content'] = [
|
||||
'label' => esc_html__( 'Justify Content', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'label_block' => true,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'flex-start' => [
|
||||
'title' => esc_html__( 'Start', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-justify-start-h',
|
||||
],
|
||||
'center' => [
|
||||
'title' => esc_html__( 'Center', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-justify-center-h',
|
||||
],
|
||||
'flex-end' => [
|
||||
'title' => esc_html__( 'End', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-justify-end-h',
|
||||
],
|
||||
'space-between' => [
|
||||
'title' => esc_html__( 'Space Between', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-justify-space-between-h',
|
||||
],
|
||||
'space-around' => [
|
||||
'title' => esc_html__( 'Space Around', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-justify-space-around-h',
|
||||
],
|
||||
'space-evenly' => [
|
||||
'title' => esc_html__( 'Space Evenly', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-justify-space-evenly-h',
|
||||
],
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--justify-content: {{VALUE}};',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
$fields['align_items'] = [
|
||||
'label' => esc_html__( 'Align Items', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'flex-start' => [
|
||||
'title' => esc_html__( 'Start', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-align-start-v',
|
||||
],
|
||||
'center' => [
|
||||
'title' => esc_html__( 'Center', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-align-center-v',
|
||||
],
|
||||
'flex-end' => [
|
||||
'title' => esc_html__( 'End', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-align-end-v',
|
||||
],
|
||||
'stretch' => [
|
||||
'title' => esc_html__( 'Stretch', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-align-stretch-v',
|
||||
],
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--align-items: {{VALUE}}; --container-widget-width: calc( ( 1 - var( --container-widget-flex-grow ) ) * 100% );',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
$fields['gap'] = [
|
||||
'label' => esc_html__( 'Gaps', 'elementor' ),
|
||||
'type' => Controls_Manager::GAPS,
|
||||
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
|
||||
'default' => [
|
||||
'unit' => 'px',
|
||||
],
|
||||
'separator' => 'before',
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--gap: {{ROW}}{{UNIT}} {{COLUMN}}{{UNIT}}',
|
||||
],
|
||||
'responsive' => true,
|
||||
'conversion_map' => [
|
||||
'old_key' => 'size',
|
||||
'new_key' => 'column',
|
||||
],
|
||||
'upgrade_conversion_map' => [
|
||||
'old_key' => 'size',
|
||||
'new_keys' => [ 'column', 'row' ],
|
||||
],
|
||||
'validators' => [
|
||||
'Number' => [
|
||||
'min' => 0,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$fields['wrap'] = [
|
||||
'label' => esc_html__( 'Wrap', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'options' => [
|
||||
'nowrap' => [
|
||||
'title' => esc_html__( 'No Wrap', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-nowrap',
|
||||
],
|
||||
'wrap' => [
|
||||
'title' => esc_html__( 'Wrap', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-wrap',
|
||||
],
|
||||
],
|
||||
'description' => esc_html__( 'Items within the container can stay in a single line (No wrap), or break into multiple lines (Wrap).', 'elementor' ),
|
||||
'default' => '',
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--flex-wrap: {{VALUE}};',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
$fields['align_content'] = [
|
||||
'label' => esc_html__( 'Align Content', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'' => esc_html__( 'Default', 'elementor' ),
|
||||
'center' => esc_html__( 'Center', 'elementor' ),
|
||||
'flex-start' => esc_html__( 'Start', 'elementor' ),
|
||||
'flex-end' => esc_html__( 'End', 'elementor' ),
|
||||
'space-between' => esc_html__( 'Space Between', 'elementor' ),
|
||||
'space-around' => esc_html__( 'Space Around', 'elementor' ),
|
||||
'space-evenly' => esc_html__( 'Space Evenly', 'elementor' ),
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--align-content: {{VALUE}};',
|
||||
],
|
||||
'condition' => [
|
||||
'wrap' => 'wrap',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Group_Control_Flex_Item extends Group_Control_Base {
|
||||
|
||||
protected static $fields;
|
||||
|
||||
public static function get_type() {
|
||||
return 'flex-item';
|
||||
}
|
||||
|
||||
protected function init_fields() {
|
||||
$fields = [];
|
||||
|
||||
$fields['basis_type'] = [
|
||||
'label' => esc_html__( 'Flex Basis', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'options' => [
|
||||
'' => esc_html__( 'Default', 'elementor' ),
|
||||
'custom' => esc_html__( 'Custom', 'elementor' ),
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
$fields['basis'] = [
|
||||
'label' => esc_html__( 'Custom Width', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'range' => [
|
||||
'px' => [
|
||||
'max' => 1000,
|
||||
],
|
||||
],
|
||||
'default' => [
|
||||
'unit' => '%',
|
||||
],
|
||||
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--flex-basis: {{SIZE}}{{UNIT}};',
|
||||
],
|
||||
'condition' => [
|
||||
'basis_type' => 'custom',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
$fields['align_self'] = [
|
||||
'label' => esc_html__( 'Align Self', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'options' => [
|
||||
'flex-start' => [
|
||||
'title' => esc_html__( 'Start', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-align-start-v',
|
||||
],
|
||||
'center' => [
|
||||
'title' => esc_html__( 'Center', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-align-center-v',
|
||||
],
|
||||
'flex-end' => [
|
||||
'title' => esc_html__( 'End', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-align-end-v',
|
||||
],
|
||||
'stretch' => [
|
||||
'title' => esc_html__( 'Stretch', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-align-stretch-v',
|
||||
],
|
||||
],
|
||||
'default' => '',
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--align-self: {{VALUE}};',
|
||||
],
|
||||
'responsive' => true,
|
||||
'description' => esc_html__( 'This control will affect contained elements only.', 'elementor' ),
|
||||
];
|
||||
|
||||
$fields['order'] = [
|
||||
'label' => esc_html__( 'Order', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'start' => [
|
||||
'title' => esc_html__( 'Start', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-order-start',
|
||||
],
|
||||
'end' => [
|
||||
'title' => esc_html__( 'End', 'elementor' ),
|
||||
'icon' => 'eicon-flex eicon-order-end',
|
||||
],
|
||||
'custom' => [
|
||||
'title' => esc_html__( 'Custom', 'elementor' ),
|
||||
'icon' => 'eicon-ellipsis-v',
|
||||
],
|
||||
],
|
||||
'selectors_dictionary' => [
|
||||
// Hacks to set the order to start / end.
|
||||
// For example, if the user has 10 widgets, but wants to set the 5th one to be first,
|
||||
// this hack should do the trick while taking in account elements with `order: 0` or less.
|
||||
'start' => '-99999 /* order start hack */',
|
||||
'end' => '99999 /* order end hack */',
|
||||
'custom' => '',
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--order: {{VALUE}};',
|
||||
],
|
||||
'responsive' => true,
|
||||
'description' => esc_html__( 'This control will affect contained elements only.', 'elementor' ),
|
||||
];
|
||||
|
||||
$fields['order_custom'] = [
|
||||
'label' => esc_html__( 'Custom Order', 'elementor' ),
|
||||
'type' => Controls_Manager::NUMBER,
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--order: {{VALUE}};',
|
||||
],
|
||||
'responsive' => true,
|
||||
'condition' => [
|
||||
'order' => 'custom',
|
||||
],
|
||||
];
|
||||
|
||||
$fields['size'] = [
|
||||
'label' => esc_html__( 'Size', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'none' => [
|
||||
'title' => esc_html__( 'None', 'elementor' ),
|
||||
'icon' => 'eicon-ban',
|
||||
],
|
||||
'grow' => [
|
||||
'title' => esc_html__( 'Grow', 'elementor' ),
|
||||
'icon' => 'eicon-grow',
|
||||
],
|
||||
'shrink' => [
|
||||
'title' => esc_html__( 'Shrink', 'elementor' ),
|
||||
'icon' => 'eicon-shrink',
|
||||
],
|
||||
'custom' => [
|
||||
'title' => esc_html__( 'Custom', 'elementor' ),
|
||||
'icon' => 'eicon-ellipsis-v',
|
||||
],
|
||||
],
|
||||
'selectors_dictionary' => [
|
||||
'grow' => '--flex-grow: 1; --flex-shrink: 0;',
|
||||
'shrink' => '--flex-grow: 0; --flex-shrink: 1;',
|
||||
'custom' => '',
|
||||
'none' => '--flex-grow: 0; --flex-shrink: 0;',
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '{{VALUE}};',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
$fields['grow'] = [
|
||||
'label' => esc_html__( 'Flex Grow', 'elementor' ),
|
||||
'type' => Controls_Manager::NUMBER,
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--flex-grow: {{VALUE}};',
|
||||
],
|
||||
'default' => 1,
|
||||
'placeholder' => 1,
|
||||
'responsive' => true,
|
||||
'condition' => [
|
||||
'size' => 'custom',
|
||||
],
|
||||
];
|
||||
|
||||
$fields['shrink'] = [
|
||||
'label' => esc_html__( 'Flex Shrink', 'elementor' ),
|
||||
'type' => Controls_Manager::NUMBER,
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--flex-shrink: {{VALUE}};',
|
||||
],
|
||||
'default' => 1,
|
||||
'placeholder' => 1,
|
||||
'responsive' => true,
|
||||
'condition' => [
|
||||
'size' => 'custom',
|
||||
],
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
use Elementor\Plugin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Group_Control_Grid_Container extends Group_Control_Base {
|
||||
|
||||
protected static $fields;
|
||||
|
||||
public static function get_type() {
|
||||
return 'grid-container';
|
||||
}
|
||||
|
||||
protected function init_fields() {
|
||||
$icon_start = is_rtl() ? 'end' : 'start';
|
||||
$icon_end = is_rtl() ? 'start' : 'end';
|
||||
|
||||
$fields = [];
|
||||
|
||||
$fields['items_grid'] = [
|
||||
'type' => Controls_Manager::HEADING,
|
||||
'label' => esc_html__( 'Items', 'elementor' ),
|
||||
'separator' => 'before',
|
||||
];
|
||||
|
||||
$fields['outline'] = [
|
||||
'label' => esc_html__( 'Grid Outline', 'elementor' ),
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'label_on' => esc_html__( 'Show', 'elementor' ),
|
||||
'label_off' => esc_html__( 'Hide', 'elementor' ),
|
||||
'default' => 'yes',
|
||||
'editor_available' => true,
|
||||
];
|
||||
|
||||
$responsive_unit_defaults = $this->get_responsive_unit_defaults();
|
||||
|
||||
$fields['columns_grid'] = [
|
||||
'label' => esc_html__( 'Columns', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'range' => [
|
||||
'fr' => [
|
||||
'min' => 1,
|
||||
'max' => 12,
|
||||
'step' => 1,
|
||||
],
|
||||
],
|
||||
'size_units' => [ 'fr', 'custom' ],
|
||||
'unit_selectors_dictionary' => [
|
||||
'custom' => '--e-con-grid-template-columns: {{SIZE}}',
|
||||
],
|
||||
'default' => [
|
||||
'unit' => 'fr',
|
||||
'size' => 3,
|
||||
],
|
||||
'mobile_default' => [
|
||||
'unit' => 'fr',
|
||||
'size' => 1,
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--e-con-grid-template-columns: repeat({{SIZE}}, 1fr)',
|
||||
],
|
||||
'responsive' => true,
|
||||
'editor_available' => true,
|
||||
] + $responsive_unit_defaults;
|
||||
|
||||
$fields['rows_grid'] = [
|
||||
'label' => esc_html__( 'Rows', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'range' => [
|
||||
'fr' => [
|
||||
'min' => 1,
|
||||
'max' => 12,
|
||||
'step' => 1,
|
||||
],
|
||||
],
|
||||
'size_units' => [ 'fr', 'custom' ],
|
||||
'unit_selectors_dictionary' => [
|
||||
'custom' => '--e-con-grid-template-rows: {{SIZE}}',
|
||||
],
|
||||
'default' => [
|
||||
'unit' => 'fr',
|
||||
'size' => 2,
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--e-con-grid-template-rows: repeat({{SIZE}}, 1fr)',
|
||||
],
|
||||
'responsive' => true,
|
||||
'editor_available' => true,
|
||||
] + $responsive_unit_defaults;
|
||||
|
||||
$fields['gaps'] = [
|
||||
'label' => esc_html__( 'Gaps', 'elementor' ),
|
||||
'type' => Controls_Manager::GAPS,
|
||||
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
|
||||
'default' => [
|
||||
'unit' => 'px',
|
||||
],
|
||||
'separator' => 'before',
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--gap: {{ROW}}{{UNIT}} {{COLUMN}}{{UNIT}}',
|
||||
],
|
||||
'responsive' => true,
|
||||
'validators' => [
|
||||
'Number' => [
|
||||
'min' => 0,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$fields['auto_flow'] = [
|
||||
'label' => esc_html__( 'Auto Flow', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'options' => [
|
||||
'row' => esc_html__( 'Row', 'elementor' ),
|
||||
'column' => esc_html__( 'Column', 'elementor' ),
|
||||
],
|
||||
'default' => 'row',
|
||||
'separator' => 'before',
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--grid-auto-flow: {{VALUE}}',
|
||||
],
|
||||
'responsive' => true,
|
||||
'editor_available' => true,
|
||||
] + $this->get_responsive_autoflow_defaults();
|
||||
|
||||
$fields['justify_items'] = [
|
||||
'label' => esc_html__( 'Justify Items', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'options' => [
|
||||
'start' => [
|
||||
'title' => esc_html__( 'Start', 'elementor' ),
|
||||
'icon' => 'eicon-align-' . $icon_start . '-h',
|
||||
],
|
||||
'center' => [
|
||||
'title' => esc_html__( 'Center', 'elementor' ),
|
||||
'icon' => 'eicon-align-center-h',
|
||||
],
|
||||
'end' => [
|
||||
'title' => esc_html__( 'End', 'elementor' ),
|
||||
'icon' => 'eicon-align-' . $icon_end . '-h',
|
||||
],
|
||||
'stretch' => [
|
||||
'title' => esc_html__( 'Stretch', 'elementor' ),
|
||||
'icon' => 'eicon-align-stretch-h',
|
||||
],
|
||||
],
|
||||
'default' => '',
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--justify-items: {{VALUE}};',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
$fields['align_items'] = [
|
||||
'label' => esc_html__( 'Align Items', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'options' => [
|
||||
'start' => [
|
||||
'title' => esc_html__( 'Start', 'elementor' ),
|
||||
'icon' => 'eicon-align-start-v',
|
||||
],
|
||||
'center' => [
|
||||
'title' => esc_html__( 'Center', 'elementor' ),
|
||||
'icon' => 'eicon-align-center-v',
|
||||
],
|
||||
'end' => [
|
||||
'title' => esc_html__( 'End', 'elementor' ),
|
||||
'icon' => 'eicon-align-end-v',
|
||||
],
|
||||
'stretch' => [
|
||||
'title' => esc_html__( 'Stretch', 'elementor' ),
|
||||
'icon' => 'eicon-align-stretch-v',
|
||||
],
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--align-items: {{VALUE}};',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
$fields['justify_content'] = [
|
||||
'label' => esc_html__( 'Justify Content', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'label_block' => true,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'start' => [
|
||||
'title' => esc_html__( 'Start', 'elementor' ),
|
||||
'icon' => 'eicon-justify-start-h',
|
||||
],
|
||||
'center' => [
|
||||
'title' => esc_html__( 'Middle', 'elementor' ),
|
||||
'icon' => 'eicon-justify-center-h',
|
||||
],
|
||||
'end' => [
|
||||
'title' => esc_html__( 'End', 'elementor' ),
|
||||
'icon' => 'eicon-justify-end-h',
|
||||
],
|
||||
'space-between' => [
|
||||
'title' => esc_html__( 'Space Between', 'elementor' ),
|
||||
'icon' => 'eicon-justify-space-between-h',
|
||||
],
|
||||
'space-around' => [
|
||||
'title' => esc_html__( 'Space Around', 'elementor' ),
|
||||
'icon' => 'eicon-justify-space-around-h',
|
||||
],
|
||||
'space-evenly' => [
|
||||
'title' => esc_html__( 'Space Evenly', 'elementor' ),
|
||||
'icon' => 'eicon-justify-space-evenly-h',
|
||||
],
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--grid-justify-content: {{VALUE}};',
|
||||
],
|
||||
'condition' => [
|
||||
'columns_grid[unit]' => 'custom',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
$fields['align_content'] = [
|
||||
'label' => esc_html__( 'Align Content', 'elementor' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'label_block' => true,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'start' => [
|
||||
'title' => esc_html__( 'Start', 'elementor' ),
|
||||
'icon' => 'eicon-justify-start-v',
|
||||
],
|
||||
'center' => [
|
||||
'title' => esc_html__( 'Middle', 'elementor' ),
|
||||
'icon' => 'eicon-justify-center-v',
|
||||
],
|
||||
'end' => [
|
||||
'title' => esc_html__( 'End', 'elementor' ),
|
||||
'icon' => 'eicon-justify-end-v',
|
||||
],
|
||||
'space-between' => [
|
||||
'title' => esc_html__( 'Space Between', 'elementor' ),
|
||||
'icon' => 'eicon-justify-space-between-v',
|
||||
],
|
||||
'space-around' => [
|
||||
'title' => esc_html__( 'Space Around', 'elementor' ),
|
||||
'icon' => 'eicon-justify-space-around-v',
|
||||
],
|
||||
'space-evenly' => [
|
||||
'title' => esc_html__( 'Space Evenly', 'elementor' ),
|
||||
'icon' => 'eicon-justify-space-evenly-v',
|
||||
],
|
||||
],
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--grid-align-content: {{VALUE}};',
|
||||
],
|
||||
'condition' => [
|
||||
'rows_grid[unit]' => 'custom',
|
||||
],
|
||||
'responsive' => true,
|
||||
];
|
||||
|
||||
// Only use the auto flow prefix class inside the editor.
|
||||
$auto_flow_prefix_class = Plugin::$instance->editor->is_edit_mode() ? [ 'prefix_class' => 'e-con--' ] : [];
|
||||
|
||||
$fields['_is_row'] = array_merge( $auto_flow_prefix_class, [
|
||||
'type' => Controls_Manager::HIDDEN,
|
||||
'default' => 'row',
|
||||
'condition' => [
|
||||
'auto_flow' => [
|
||||
'row',
|
||||
],
|
||||
],
|
||||
] );
|
||||
|
||||
$fields['_is_column'] = array_merge( $auto_flow_prefix_class, [
|
||||
'type' => Controls_Manager::HIDDEN,
|
||||
'default' => 'column',
|
||||
'condition' => [
|
||||
'auto_flow' => [
|
||||
'column',
|
||||
],
|
||||
],
|
||||
] );
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
protected function get_responsive_unit_defaults() {
|
||||
$responsive_unit_defaults = [];
|
||||
$active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints();
|
||||
|
||||
foreach ( $active_breakpoints as $breakpoint_name => $breakpoint ) {
|
||||
$responsive_unit_defaults[ $breakpoint_name . '_default' ] = [
|
||||
'unit' => 'fr',
|
||||
];
|
||||
}
|
||||
|
||||
return $responsive_unit_defaults;
|
||||
}
|
||||
|
||||
protected function get_responsive_autoflow_defaults() {
|
||||
$responsive_autoflow_defaults = [];
|
||||
$active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints();
|
||||
|
||||
foreach ( $active_breakpoints as $breakpoint_name => $breakpoint ) {
|
||||
$responsive_autoflow_defaults[ $breakpoint_name . '_default' ] = 'row';
|
||||
}
|
||||
|
||||
return $responsive_autoflow_defaults;
|
||||
}
|
||||
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Elementor image size control.
|
||||
*
|
||||
* A base control for creating image size control. Displays input fields to define
|
||||
* one of the default image sizes (thumbnail, medium, medium_large, large) or custom
|
||||
* image dimensions.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Group_Control_Image_Size extends Group_Control_Base {
|
||||
|
||||
/**
|
||||
* Fields.
|
||||
*
|
||||
* Holds all the image size control fields.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
* @static
|
||||
*
|
||||
* @var array Image size control fields.
|
||||
*/
|
||||
protected static $fields;
|
||||
|
||||
/**
|
||||
* Get image size control type.
|
||||
*
|
||||
* Retrieve the control type, in this case `image-size`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return string Control type.
|
||||
*/
|
||||
public static function get_type() {
|
||||
return 'image-size';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attachment image HTML.
|
||||
*
|
||||
* Retrieve the attachment image HTML code.
|
||||
*
|
||||
* Note that some widgets use the same key for the media control that allows
|
||||
* the image selection and for the image size control that allows the user
|
||||
* to select the image size, in this case the third parameter should be null
|
||||
* or the same as the second parameter. But when the widget uses different
|
||||
* keys for the media control and the image size control, when calling this
|
||||
* method you should pass the keys.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @param array $settings Control settings.
|
||||
* @param string $image_size_key Optional. Settings key for image size.
|
||||
* Default is `image`.
|
||||
* @param string $image_key Optional. Settings key for image. Default
|
||||
* is null. If not defined uses image size key
|
||||
* as the image key.
|
||||
*
|
||||
* @return string Image HTML.
|
||||
*/
|
||||
public static function get_attachment_image_html( $settings, $image_size_key = 'image', $image_key = null ) {
|
||||
if ( ! $image_key ) {
|
||||
$image_key = $image_size_key;
|
||||
}
|
||||
|
||||
$image = $settings[ $image_key ];
|
||||
|
||||
// Old version of image settings.
|
||||
if ( ! isset( $settings[ $image_size_key . '_size' ] ) ) {
|
||||
$settings[ $image_size_key . '_size' ] = '';
|
||||
}
|
||||
|
||||
$size = $settings[ $image_size_key . '_size' ];
|
||||
|
||||
$image_class = ! empty( $settings['hover_animation'] ) ? 'elementor-animation-' . $settings['hover_animation'] : '';
|
||||
|
||||
$html = '';
|
||||
|
||||
// If is the new version - with image size.
|
||||
$image_sizes = get_intermediate_image_sizes();
|
||||
|
||||
$image_sizes[] = 'full';
|
||||
|
||||
if ( ! empty( $image['id'] ) && ! wp_attachment_is_image( $image['id'] ) ) {
|
||||
$image['id'] = '';
|
||||
}
|
||||
|
||||
$is_static_render_mode = Plugin::$instance->frontend->is_static_render_mode();
|
||||
|
||||
// On static mode don't use WP responsive images.
|
||||
if ( ! empty( $image['id'] ) && in_array( $size, $image_sizes ) && ! $is_static_render_mode ) {
|
||||
$image_class .= " attachment-$size size-$size wp-image-{$image['id']}";
|
||||
$image_attr = [
|
||||
'class' => trim( $image_class ),
|
||||
];
|
||||
|
||||
$html .= wp_get_attachment_image( $image['id'], $size, false, $image_attr );
|
||||
} else {
|
||||
$image_src = self::get_attachment_image_src( $image['id'], $image_size_key, $settings );
|
||||
|
||||
if ( ! $image_src && isset( $image['url'] ) ) {
|
||||
$image_src = $image['url'];
|
||||
}
|
||||
|
||||
if ( ! empty( $image_src ) ) {
|
||||
$image_class_html = ! empty( $image_class ) ? ' class="' . esc_attr( $image_class ) . '"' : '';
|
||||
|
||||
$html .= sprintf(
|
||||
'<img src="%1$s" title="%2$s" alt="%3$s"%4$s loading="lazy" />',
|
||||
esc_url( $image_src ),
|
||||
esc_attr( Control_Media::get_image_title( $image ) ),
|
||||
esc_attr( Control_Media::get_image_alt( $image ) ),
|
||||
$image_class_html
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Attachment Image HTML
|
||||
*
|
||||
* Filters the Attachment Image HTML
|
||||
*
|
||||
* @since 2.4.0
|
||||
* @param string $html the attachment image HTML string
|
||||
* @param array $settings Control settings.
|
||||
* @param string $image_size_key Optional. Settings key for image size.
|
||||
* Default is `image`.
|
||||
* @param string $image_key Optional. Settings key for image. Default
|
||||
* is null. If not defined uses image size key
|
||||
* as the image key.
|
||||
*/
|
||||
return apply_filters( 'elementor/image_size/get_attachment_image_html', $html, $settings, $image_size_key, $image_key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe print attachment image HTML.
|
||||
*
|
||||
* @uses get_attachment_image_html.
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @param array $settings Control settings.
|
||||
* @param string $image_size_key Optional. Settings key for image size.
|
||||
* Default is `image`.
|
||||
* @param string $image_key Optional. Settings key for image. Default
|
||||
* is null. If not defined uses image size key
|
||||
* as the image key.
|
||||
*/
|
||||
public static function print_attachment_image_html( array $settings, $image_size_key = 'image', $image_key = null ) {
|
||||
Utils::print_wp_kses_extended( self::get_attachment_image_html( $settings, $image_size_key, $image_key ), [ 'image' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all image sizes.
|
||||
*
|
||||
* Retrieve available image sizes with data like `width`, `height` and `crop`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return array An array of available image sizes.
|
||||
*/
|
||||
public static function get_all_image_sizes() {
|
||||
global $_wp_additional_image_sizes;
|
||||
|
||||
$default_image_sizes = [ 'thumbnail', 'medium', 'medium_large', 'large' ];
|
||||
|
||||
$image_sizes = [];
|
||||
|
||||
foreach ( $default_image_sizes as $size ) {
|
||||
$image_sizes[ $size ] = [
|
||||
'width' => (int) get_option( $size . '_size_w' ),
|
||||
'height' => (int) get_option( $size . '_size_h' ),
|
||||
'crop' => (bool) get_option( $size . '_crop' ),
|
||||
];
|
||||
}
|
||||
|
||||
if ( $_wp_additional_image_sizes ) {
|
||||
$image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes );
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-admin/includes/media.php */
|
||||
return apply_filters( 'image_size_names_choose', $image_sizes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attachment image src.
|
||||
*
|
||||
* Retrieve the attachment image source URL.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @param string $attachment_id The attachment ID.
|
||||
* @param string $image_size_key Settings key for image size.
|
||||
* @param array $settings Control settings.
|
||||
*
|
||||
* @return string Attachment image source URL.
|
||||
*/
|
||||
public static function get_attachment_image_src( $attachment_id, $image_size_key, array $settings ) {
|
||||
if ( empty( $attachment_id ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$size = $settings[ $image_size_key . '_size' ];
|
||||
|
||||
if ( 'custom' !== $size ) {
|
||||
$attachment_size = $size;
|
||||
} else {
|
||||
// Use BFI_Thumb script
|
||||
// TODO: Please rewrite this code.
|
||||
require_once ELEMENTOR_PATH . 'includes/libraries/bfi-thumb/bfi-thumb.php';
|
||||
|
||||
$custom_dimension = $settings[ $image_size_key . '_custom_dimension' ];
|
||||
|
||||
$attachment_size = [
|
||||
// Defaults sizes
|
||||
0 => null, // Width.
|
||||
1 => null, // Height.
|
||||
|
||||
'bfi_thumb' => true,
|
||||
'crop' => true,
|
||||
];
|
||||
|
||||
$has_custom_size = false;
|
||||
if ( ! empty( $custom_dimension['width'] ) ) {
|
||||
$has_custom_size = true;
|
||||
$attachment_size[0] = $custom_dimension['width'];
|
||||
}
|
||||
|
||||
if ( ! empty( $custom_dimension['height'] ) ) {
|
||||
$has_custom_size = true;
|
||||
$attachment_size[1] = $custom_dimension['height'];
|
||||
}
|
||||
|
||||
if ( ! $has_custom_size ) {
|
||||
$attachment_size = 'full';
|
||||
}
|
||||
}
|
||||
|
||||
$image_src = wp_get_attachment_image_src( $attachment_id, $attachment_size );
|
||||
|
||||
if ( empty( $image_src[0] ) && 'thumbnail' !== $attachment_size ) {
|
||||
$image_src = wp_get_attachment_image_src( $attachment_id );
|
||||
}
|
||||
|
||||
return ! empty( $image_src[0] ) ? $image_src[0] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get child default arguments.
|
||||
*
|
||||
* Retrieve the default arguments for all the child controls for a specific group
|
||||
* control.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default arguments for all the child controls.
|
||||
*/
|
||||
protected function get_child_default_args() {
|
||||
return [
|
||||
'include' => [],
|
||||
'exclude' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Init fields.
|
||||
*
|
||||
* Initialize image size control fields.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
protected function init_fields() {
|
||||
$fields = [];
|
||||
|
||||
$fields['size'] = [
|
||||
'label' => esc_html__( 'Image Resolution', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
];
|
||||
|
||||
$fields['custom_dimension'] = [
|
||||
'label' => esc_html__( 'Image Dimension', 'elementor' ),
|
||||
'type' => Controls_Manager::IMAGE_DIMENSIONS,
|
||||
'description' => esc_html__( 'You can crop the original image size to any custom size. You can also set a single value for height or width in order to keep the original size ratio.', 'elementor' ),
|
||||
'condition' => [
|
||||
'size' => 'custom',
|
||||
],
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare fields.
|
||||
*
|
||||
* Process image size control fields before adding them to `add_control()`.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @param array $fields Image size control fields.
|
||||
*
|
||||
* @return array Processed fields.
|
||||
*/
|
||||
protected function prepare_fields( $fields ) {
|
||||
$image_sizes = $this->get_image_sizes();
|
||||
|
||||
$args = $this->get_args();
|
||||
|
||||
if ( ! empty( $args['default'] ) && isset( $image_sizes[ $args['default'] ] ) ) {
|
||||
$default_value = $args['default'];
|
||||
} else {
|
||||
// Get the first item for default value.
|
||||
$default_value = array_keys( $image_sizes );
|
||||
$default_value = array_shift( $default_value );
|
||||
}
|
||||
|
||||
$fields['size']['options'] = $image_sizes;
|
||||
|
||||
$fields['size']['default'] = $default_value;
|
||||
|
||||
if ( ! isset( $image_sizes['custom'] ) ) {
|
||||
unset( $fields['custom_dimension'] );
|
||||
}
|
||||
|
||||
return parent::prepare_fields( $fields );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image sizes.
|
||||
*
|
||||
* Retrieve available image sizes after filtering `include` and `exclude` arguments.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @access private
|
||||
*
|
||||
* @return array Filtered image sizes.
|
||||
*/
|
||||
private function get_image_sizes() {
|
||||
$wp_image_sizes = self::get_all_image_sizes();
|
||||
|
||||
$args = $this->get_args();
|
||||
|
||||
if ( $args['include'] ) {
|
||||
$wp_image_sizes = array_intersect_key( $wp_image_sizes, array_flip( $args['include'] ) );
|
||||
} elseif ( $args['exclude'] ) {
|
||||
$wp_image_sizes = array_diff_key( $wp_image_sizes, array_flip( $args['exclude'] ) );
|
||||
}
|
||||
|
||||
$image_sizes = [];
|
||||
|
||||
foreach ( $wp_image_sizes as $size_key => $size_attributes ) {
|
||||
$control_title = ucwords( str_replace( '_', ' ', $size_key ) );
|
||||
if ( is_array( $size_attributes ) ) {
|
||||
$control_title .= sprintf( ' - %d x %d', $size_attributes['width'], $size_attributes['height'] );
|
||||
}
|
||||
|
||||
$image_sizes[ $size_key ] = $control_title;
|
||||
}
|
||||
|
||||
$image_sizes['full'] = esc_html__( 'Full', 'elementor' );
|
||||
|
||||
if ( ! empty( $args['include']['custom'] ) || ! in_array( 'custom', $args['exclude'] ) ) {
|
||||
$image_sizes['custom'] = esc_html__( 'Custom', 'elementor' );
|
||||
}
|
||||
|
||||
return $image_sizes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default options.
|
||||
*
|
||||
* Retrieve the default options of the image size control. Used to return the
|
||||
* default options while initializing the image size control.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default image size control options.
|
||||
*/
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Elementor text shadow control.
|
||||
*
|
||||
* A base control for creating text shadow control. Displays input fields to define
|
||||
* the text shadow including the horizontal shadow, vertical shadow, shadow blur and
|
||||
* shadow color.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
class Group_Control_Text_Shadow extends Group_Control_Base {
|
||||
|
||||
/**
|
||||
* Fields.
|
||||
*
|
||||
* Holds all the text shadow control fields.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @access protected
|
||||
* @static
|
||||
*
|
||||
* @var array Text shadow control fields.
|
||||
*/
|
||||
protected static $fields;
|
||||
|
||||
/**
|
||||
* Get text shadow control type.
|
||||
*
|
||||
* Retrieve the control type, in this case `text-shadow`.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return string Control type.
|
||||
*/
|
||||
public static function get_type() {
|
||||
return 'text-shadow';
|
||||
}
|
||||
|
||||
/**
|
||||
* Init fields.
|
||||
*
|
||||
* Initialize text shadow control fields.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
protected function init_fields() {
|
||||
$controls = [];
|
||||
|
||||
$controls['text_shadow'] = [
|
||||
'label' => esc_html__( 'Text Shadow', 'elementor' ),
|
||||
'type' => Controls_Manager::TEXT_SHADOW,
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => 'text-shadow: {{HORIZONTAL}}px {{VERTICAL}}px {{BLUR}}px {{COLOR}};',
|
||||
],
|
||||
];
|
||||
|
||||
return $controls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default options.
|
||||
*
|
||||
* Retrieve the default options of the text shadow control. Used to return the
|
||||
* default options while initializing the text shadow control.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default text shadow control options.
|
||||
*/
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => [
|
||||
'starter_title' => esc_html__( 'Text Shadow', 'elementor' ),
|
||||
'starter_name' => 'text_shadow_type',
|
||||
'starter_value' => 'yes',
|
||||
'settings' => [
|
||||
'render_type' => 'ui',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Elementor text stroke control.
|
||||
*
|
||||
* A group control for creating a stroke effect on text. Displays input fields to define
|
||||
* the text stroke and color stroke.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
class Group_Control_Text_Stroke extends Group_Control_Base {
|
||||
|
||||
/**
|
||||
* Fields.
|
||||
*
|
||||
* Holds all the text stroke control fields.
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @access protected
|
||||
* @static
|
||||
*
|
||||
* @var array Text Stroke control fields.
|
||||
*/
|
||||
protected static $fields;
|
||||
|
||||
/**
|
||||
* Get text stroke control type.
|
||||
*
|
||||
* Retrieve the control type, in this case `text-stroke`.
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return string Control type.
|
||||
*/
|
||||
public static function get_type() {
|
||||
return 'text-stroke';
|
||||
}
|
||||
|
||||
/**
|
||||
* Init fields.
|
||||
*
|
||||
* Initialize text stroke control fields.
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
protected function init_fields() {
|
||||
$controls = [];
|
||||
|
||||
$controls['text_stroke'] = [
|
||||
'label' => esc_html__( 'Text Stroke', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'size_units' => [ 'px', 'em', 'rem', 'custom' ],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 0,
|
||||
'max' => 10,
|
||||
],
|
||||
'em' => [
|
||||
'min' => 0,
|
||||
'max' => 1,
|
||||
],
|
||||
'rem' => [
|
||||
'min' => 0,
|
||||
'max' => 1,
|
||||
],
|
||||
],
|
||||
'responsive' => true,
|
||||
'selector' => '{{WRAPPER}}',
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '-webkit-text-stroke-width: {{SIZE}}{{UNIT}}; stroke-width: {{SIZE}}{{UNIT}};',
|
||||
],
|
||||
];
|
||||
|
||||
$controls['stroke_color'] = [
|
||||
'label' => esc_html__( 'Stroke Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'default' => '#000',
|
||||
'selector' => '{{WRAPPER}}',
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '-webkit-text-stroke-color: {{VALUE}}; stroke: {{VALUE}};',
|
||||
],
|
||||
];
|
||||
|
||||
return $controls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default options.
|
||||
*
|
||||
* Retrieve the default options of the text stroke control. Used to return the
|
||||
* default options while initializing the text stroke control.
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default text stroke control options.
|
||||
*/
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => [
|
||||
'starter_title' => esc_html__( 'Text Stroke', 'elementor' ),
|
||||
'starter_name' => 'text_stroke_type',
|
||||
'starter_value' => 'yes',
|
||||
'settings' => [
|
||||
'render_type' => 'ui',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
namespace Elementor;
|
||||
|
||||
use Elementor\Core\Settings\Page\Manager as PageManager;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Elementor typography control.
|
||||
*
|
||||
* A base control for creating typography control. Displays input fields to define
|
||||
* the content typography including font size, font family, font weight, text
|
||||
* transform, font style, line height and letter spacing.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Group_Control_Typography extends Group_Control_Base {
|
||||
|
||||
/**
|
||||
* Fields.
|
||||
*
|
||||
* Holds all the typography control fields.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @static
|
||||
*
|
||||
* @var array Typography control fields.
|
||||
*/
|
||||
protected static $fields;
|
||||
|
||||
/**
|
||||
* Scheme fields keys.
|
||||
*
|
||||
* Holds all the typography control scheme fields keys.
|
||||
* Default is an array containing `font_family` and `font_weight`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @static
|
||||
*
|
||||
* @var array Typography control scheme fields keys.
|
||||
*/
|
||||
private static $_scheme_fields_keys = [ 'font_family', 'font_weight' ];
|
||||
|
||||
/**
|
||||
* Get scheme fields keys.
|
||||
*
|
||||
* Retrieve all the available typography control scheme fields keys.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return array Scheme fields keys.
|
||||
*/
|
||||
public static function get_scheme_fields_keys() {
|
||||
return self::$_scheme_fields_keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get typography control type.
|
||||
*
|
||||
* Retrieve the control type, in this case `typography`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return string Control type.
|
||||
*/
|
||||
public static function get_type() {
|
||||
return 'typography';
|
||||
}
|
||||
|
||||
/**
|
||||
* Init fields.
|
||||
*
|
||||
* Initialize typography control fields.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @return array Control fields.
|
||||
*/
|
||||
protected function init_fields() {
|
||||
$fields = [];
|
||||
|
||||
$kit = Plugin::$instance->kits_manager->get_active_kit_for_frontend();
|
||||
|
||||
/**
|
||||
* Retrieve the settings directly from DB, because of an open issue when a controls group is being initialized
|
||||
* from within another group
|
||||
*/
|
||||
$kit_settings = $kit->get_meta( PageManager::META_KEY );
|
||||
|
||||
$default_fonts = isset( $kit_settings['default_generic_fonts'] ) ? $kit_settings['default_generic_fonts'] : 'Sans-serif';
|
||||
|
||||
if ( $default_fonts ) {
|
||||
$default_fonts = ', ' . $default_fonts;
|
||||
}
|
||||
|
||||
$fields['font_family'] = [
|
||||
'label' => esc_html_x( 'Family', 'Typography Control', 'elementor' ),
|
||||
'type' => Controls_Manager::FONT,
|
||||
'default' => '',
|
||||
'selector_value' => 'font-family: "{{VALUE}}"' . $default_fonts . ';',
|
||||
];
|
||||
|
||||
$fields['font_size'] = [
|
||||
'label' => esc_html_x( 'Size', 'Typography Control', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 1,
|
||||
'max' => 200,
|
||||
],
|
||||
'em' => [
|
||||
'max' => 20,
|
||||
],
|
||||
'rem' => [
|
||||
'max' => 20,
|
||||
],
|
||||
'vw' => [
|
||||
'min' => 0.1,
|
||||
'max' => 10,
|
||||
'step' => 0.1,
|
||||
],
|
||||
],
|
||||
'responsive' => true,
|
||||
'selector_value' => 'font-size: {{SIZE}}{{UNIT}}',
|
||||
];
|
||||
|
||||
$fields['font_weight'] = [
|
||||
'label' => esc_html_x( 'Weight', 'Typography Control', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'100' => '100 ' . esc_html_x( '(Thin)', 'Typography Control', 'elementor' ),
|
||||
'200' => '200 ' . esc_html_x( '(Extra Light)', 'Typography Control', 'elementor' ),
|
||||
'300' => '300 ' . esc_html_x( '(Light)', 'Typography Control', 'elementor' ),
|
||||
'400' => '400 ' . esc_html_x( '(Normal)', 'Typography Control', 'elementor' ),
|
||||
'500' => '500 ' . esc_html_x( '(Medium)', 'Typography Control', 'elementor' ),
|
||||
'600' => '600 ' . esc_html_x( '(Semi Bold)', 'Typography Control', 'elementor' ),
|
||||
'700' => '700 ' . esc_html_x( '(Bold)', 'Typography Control', 'elementor' ),
|
||||
'800' => '800 ' . esc_html_x( '(Extra Bold)', 'Typography Control', 'elementor' ),
|
||||
'900' => '900 ' . esc_html_x( '(Black)', 'Typography Control', 'elementor' ),
|
||||
'' => esc_html__( 'Default', 'elementor' ),
|
||||
'normal' => esc_html__( 'Normal', 'elementor' ),
|
||||
'bold' => esc_html__( 'Bold', 'elementor' ),
|
||||
],
|
||||
];
|
||||
|
||||
$fields['text_transform'] = [
|
||||
'label' => esc_html_x( 'Transform', 'Typography Control', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'' => esc_html__( 'Default', 'elementor' ),
|
||||
'uppercase' => esc_html_x( 'Uppercase', 'Typography Control', 'elementor' ),
|
||||
'lowercase' => esc_html_x( 'Lowercase', 'Typography Control', 'elementor' ),
|
||||
'capitalize' => esc_html_x( 'Capitalize', 'Typography Control', 'elementor' ),
|
||||
'none' => esc_html__( 'Normal', 'elementor' ),
|
||||
],
|
||||
];
|
||||
|
||||
$fields['font_style'] = [
|
||||
'label' => esc_html_x( 'Style', 'Typography Control', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'' => esc_html__( 'Default', 'elementor' ),
|
||||
'normal' => esc_html__( 'Normal', 'elementor' ),
|
||||
'italic' => esc_html_x( 'Italic', 'Typography Control', 'elementor' ),
|
||||
'oblique' => esc_html_x( 'Oblique', 'Typography Control', 'elementor' ),
|
||||
],
|
||||
];
|
||||
|
||||
$fields['text_decoration'] = [
|
||||
'label' => esc_html_x( 'Decoration', 'Typography Control', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => '',
|
||||
'options' => [
|
||||
'' => esc_html__( 'Default', 'elementor' ),
|
||||
'underline' => esc_html_x( 'Underline', 'Typography Control', 'elementor' ),
|
||||
'overline' => esc_html_x( 'Overline', 'Typography Control', 'elementor' ),
|
||||
'line-through' => esc_html_x( 'Line Through', 'Typography Control', 'elementor' ),
|
||||
'none' => esc_html__( 'None', 'elementor' ),
|
||||
],
|
||||
];
|
||||
|
||||
$fields['line_height'] = [
|
||||
'label' => esc_html__( 'Line Height', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'desktop_default' => [
|
||||
'unit' => 'em',
|
||||
],
|
||||
'tablet_default' => [
|
||||
'unit' => 'em',
|
||||
],
|
||||
'mobile_default' => [
|
||||
'unit' => 'em',
|
||||
],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 1,
|
||||
],
|
||||
],
|
||||
'responsive' => true,
|
||||
'size_units' => [ 'px', 'em', 'rem', 'custom' ],
|
||||
'selector_value' => 'line-height: {{SIZE}}{{UNIT}}',
|
||||
];
|
||||
|
||||
$fields['letter_spacing'] = [
|
||||
'label' => esc_html__( 'Letter Spacing', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'size_units' => [ 'px', 'em', 'rem', 'custom' ],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => -5,
|
||||
'max' => 10,
|
||||
'step' => 0.1,
|
||||
],
|
||||
'em' => [
|
||||
'min' => 0,
|
||||
'max' => 1,
|
||||
'step' => 0.01,
|
||||
],
|
||||
'rem' => [
|
||||
'min' => 0,
|
||||
'max' => 1,
|
||||
'step' => 0.01,
|
||||
],
|
||||
],
|
||||
'responsive' => true,
|
||||
'selector_value' => 'letter-spacing: {{SIZE}}{{UNIT}}',
|
||||
];
|
||||
|
||||
$fields['word_spacing'] = [
|
||||
'label' => esc_html__( 'Word Spacing', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'size_units' => [ 'px', 'em', 'rem', 'custom' ],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'max' => 50,
|
||||
],
|
||||
'em' => [
|
||||
'min' => 0,
|
||||
'max' => 5,
|
||||
],
|
||||
'rem' => [
|
||||
'min' => 0,
|
||||
'max' => 5,
|
||||
],
|
||||
],
|
||||
'desktop_default' => [
|
||||
'unit' => 'em',
|
||||
],
|
||||
'tablet_default' => [
|
||||
'unit' => 'em',
|
||||
],
|
||||
'mobile_default' => [
|
||||
'unit' => 'em',
|
||||
],
|
||||
'responsive' => true,
|
||||
'selector_value' => 'word-spacing: {{SIZE}}{{UNIT}}',
|
||||
];
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare fields.
|
||||
*
|
||||
* Process typography control fields before adding them to `add_control()`.
|
||||
*
|
||||
* @since 1.2.3
|
||||
* @access protected
|
||||
*
|
||||
* @param array $fields Typography control fields.
|
||||
*
|
||||
* @return array Processed fields.
|
||||
*/
|
||||
protected function prepare_fields( $fields ) {
|
||||
array_walk(
|
||||
$fields, function( &$field, $field_name ) {
|
||||
|
||||
if ( in_array( $field_name, [ 'typography', 'popover_toggle' ] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$selector_value = ! empty( $field['selector_value'] ) ? $field['selector_value'] : str_replace( '_', '-', $field_name ) . ': {{VALUE}};';
|
||||
|
||||
$field['selectors'] = [
|
||||
'{{SELECTOR}}' => $selector_value,
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
return parent::prepare_fields( $fields );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add group arguments to field.
|
||||
*
|
||||
* Register field arguments to typography control.
|
||||
*
|
||||
* @since 1.2.2
|
||||
* @access protected
|
||||
*
|
||||
* @param string $control_id Typography control id.
|
||||
* @param array $field_args Typography control field arguments.
|
||||
*
|
||||
* @return array Field arguments.
|
||||
*/
|
||||
protected function add_group_args_to_field( $control_id, $field_args ) {
|
||||
$field_args = parent::add_group_args_to_field( $control_id, $field_args );
|
||||
|
||||
$field_args['groupPrefix'] = $this->get_controls_prefix();
|
||||
$field_args['groupType'] = 'typography';
|
||||
|
||||
$args = $this->get_args();
|
||||
|
||||
if ( in_array( $control_id, self::get_scheme_fields_keys() ) && ! empty( $args['scheme'] ) ) {
|
||||
$field_args['scheme'] = [
|
||||
'type' => self::get_type(),
|
||||
'value' => $args['scheme'],
|
||||
'key' => $control_id,
|
||||
];
|
||||
}
|
||||
|
||||
return $field_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default options.
|
||||
*
|
||||
* Retrieve the default options of the typography control. Used to return the
|
||||
* default options while initializing the typography control.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Default typography control options.
|
||||
*/
|
||||
protected function get_default_options() {
|
||||
return [
|
||||
'popover' => [
|
||||
'starter_name' => 'typography',
|
||||
'starter_title' => esc_html__( 'Typography', 'elementor' ),
|
||||
'settings' => [
|
||||
'render_type' => 'ui',
|
||||
'groupType' => 'typography',
|
||||
'global' => [
|
||||
'active' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user