first commit
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Core\Kits\Controls;
|
||||
|
||||
use Elementor\Control_Repeater;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Repeater extends Control_Repeater {
|
||||
|
||||
const CONTROL_TYPE = 'global-style-repeater';
|
||||
|
||||
/**
|
||||
* Get control type.
|
||||
*
|
||||
* Retrieve the control type, in this case `global-style-repeater`.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @access public
|
||||
*
|
||||
* @return string Control type.
|
||||
*/
|
||||
public function get_type() {
|
||||
return self::CONTROL_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repeater control default settings.
|
||||
*
|
||||
* Retrieve the default settings of the repeater control. Used to return the
|
||||
* default settings while initializing the repeater control.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array Control default settings.
|
||||
*/
|
||||
protected function get_default_settings() {
|
||||
$settings = parent::get_default_settings();
|
||||
|
||||
$settings['item_actions']['duplicate'] = false;
|
||||
$settings['item_actions']['sort'] = false;
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render repeater control output in the editor.
|
||||
*
|
||||
* Used to generate the control HTML in the editor using Underscore JS
|
||||
* template. The variables for the class are available using `data` JS
|
||||
* object.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @access public
|
||||
*/
|
||||
public function content_template() {
|
||||
?>
|
||||
<div class="elementor-repeater-fields-wrapper"></div>
|
||||
<# if ( itemActions.add ) { #>
|
||||
<div class="elementor-button-wrapper">
|
||||
<button class="elementor-button elementor-button-default elementor-repeater-add" type="button">
|
||||
<i class="eicon-plus" aria-hidden="true"></i><span class="elementor-repeater__add-button__text">{{{ addButtonText }}}</span>
|
||||
</button>
|
||||
</div>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Kits\Documents;
|
||||
|
||||
use Elementor\Core\DocumentTypes\PageBase;
|
||||
use Elementor\Core\Files\CSS\Post as Post_CSS;
|
||||
use Elementor\Core\Kits\Documents\Tabs;
|
||||
use Elementor\Core\Settings\Manager as SettingsManager;
|
||||
use Elementor\Core\Settings\Page\Manager as PageManager;
|
||||
use Elementor\Plugin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Kit extends PageBase {
|
||||
/**
|
||||
* @var Tabs\Tab_Base[]
|
||||
*/
|
||||
private $tabs;
|
||||
|
||||
public function __construct( array $data = [] ) {
|
||||
parent::__construct( $data );
|
||||
|
||||
$this->tabs = [
|
||||
'global-colors' => new Tabs\Global_Colors( $this ),
|
||||
'global-typography' => new Tabs\Global_Typography( $this ),
|
||||
'theme-style-typography' => new Tabs\Theme_Style_Typography( $this ),
|
||||
'theme-style-buttons' => new Tabs\Theme_Style_Buttons( $this ),
|
||||
'theme-style-images' => new Tabs\Theme_Style_Images( $this ),
|
||||
'theme-style-form-fields' => new Tabs\Theme_Style_Form_Fields( $this ),
|
||||
'settings-site-identity' => new Tabs\Settings_Site_Identity( $this ),
|
||||
'settings-background' => new Tabs\Settings_Background( $this ),
|
||||
'settings-layout' => new Tabs\Settings_Layout( $this ),
|
||||
'settings-lightbox' => new Tabs\Settings_Lightbox( $this ),
|
||||
'settings-custom-css' => new Tabs\Settings_Custom_CSS( $this ),
|
||||
];
|
||||
}
|
||||
|
||||
public static function get_properties() {
|
||||
$properties = parent::get_properties();
|
||||
|
||||
$properties['has_elements'] = false;
|
||||
$properties['show_in_finder'] = false;
|
||||
$properties['show_on_admin_bar'] = false;
|
||||
$properties['edit_capability'] = 'edit_theme_options';
|
||||
$properties['support_kit'] = true;
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
public function get_name() {
|
||||
return 'kit';
|
||||
}
|
||||
|
||||
public static function get_title() {
|
||||
return __( 'Kit', 'elementor' );
|
||||
}
|
||||
|
||||
protected function get_have_a_look_url() {
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function get_editor_panel_config() {
|
||||
$config = parent::get_editor_panel_config();
|
||||
$config['default_route'] = 'panel/global/menu';
|
||||
|
||||
$config['needHelpUrl'] = 'https://go.elementor.com/global-settings';
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
public function get_css_wrapper_selector() {
|
||||
return '.elementor-kit-' . $this->get_main_id();
|
||||
}
|
||||
|
||||
public function save( $data ) {
|
||||
$saved = parent::save( $data );
|
||||
|
||||
if ( ! $saved ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Should set is_saving to true, to avoid infinite loop when updating
|
||||
// settings like: 'site_name" or "site_description".
|
||||
$this->set_is_saving( true );
|
||||
|
||||
foreach ( $this->tabs as $tab ) {
|
||||
$tab->on_save( $data );
|
||||
}
|
||||
|
||||
$this->set_is_saving( false );
|
||||
|
||||
// When deleting a global color or typo, the css variable still exists in the frontend
|
||||
// but without any value and it makes the element to be un styled even if there is a default style for the base element,
|
||||
// for that reason this method removes css files of the entire site.
|
||||
Plugin::instance()->files_manager->clear_cache();
|
||||
|
||||
return $saved;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.0.0
|
||||
* @access protected
|
||||
*/
|
||||
protected function _register_controls() {
|
||||
$this->register_document_controls();
|
||||
|
||||
foreach ( $this->tabs as $tab ) {
|
||||
$tab->register_controls();
|
||||
}
|
||||
}
|
||||
|
||||
protected function get_post_statuses() {
|
||||
return [
|
||||
'draft' => sprintf( '%s (%s)', __( 'Disabled', 'elementor' ), __( 'Draft', 'elementor' ) ),
|
||||
'publish' => __( 'Published', 'elementor' ),
|
||||
];
|
||||
}
|
||||
|
||||
public function add_repeater_row( $control_id, $item ) {
|
||||
$meta_key = PageManager::META_KEY;
|
||||
$document_settings = $this->get_meta( $meta_key );
|
||||
|
||||
if ( ! $document_settings ) {
|
||||
$document_settings = [];
|
||||
}
|
||||
|
||||
if ( ! isset( $document_settings[ $control_id ] ) ) {
|
||||
$document_settings[ $control_id ] = [];
|
||||
}
|
||||
|
||||
$document_settings[ $control_id ][] = $item;
|
||||
|
||||
$page_settings_manager = SettingsManager::get_settings_managers( 'page' );
|
||||
$page_settings_manager->save_settings( $document_settings, $this->get_id() );
|
||||
|
||||
/** @var Kit $autosave **/
|
||||
$autosave = $this->get_autosave();
|
||||
|
||||
if ( $autosave ) {
|
||||
$autosave->add_repeater_row( $control_id, $item );
|
||||
}
|
||||
|
||||
// Remove Post CSS.
|
||||
$post_css = Post_CSS::create( $this->post->ID );
|
||||
|
||||
$post_css->delete();
|
||||
|
||||
// Refresh Cache.
|
||||
Plugin::$instance->documents->get( $this->post->ID, false );
|
||||
|
||||
$post_css = Post_CSS::create( $this->post->ID );
|
||||
|
||||
$post_css->enqueue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Core\Kits\Controls\Repeater as Global_Style_Repeater;
|
||||
use Elementor\Repeater;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Global_Colors extends Tab_Base {
|
||||
|
||||
const COLOR_PRIMARY = 'globals/colors?id=primary';
|
||||
const COLOR_SECONDARY = 'globals/colors?id=secondary';
|
||||
const COLOR_TEXT = 'globals/colors?id=text';
|
||||
const COLOR_ACCENT = 'globals/colors?id=accent';
|
||||
|
||||
public function get_id() {
|
||||
return 'global-colors';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Global Colors', 'elementor' );
|
||||
}
|
||||
|
||||
protected function register_tab_controls() {
|
||||
$this->start_controls_section(
|
||||
'section_global_colors',
|
||||
[
|
||||
'label' => __( 'Global Colors', 'elementor' ),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$repeater = new Repeater();
|
||||
|
||||
$repeater->add_control(
|
||||
'title',
|
||||
[
|
||||
'type' => Controls_Manager::TEXT,
|
||||
'label_block' => true,
|
||||
'required' => true,
|
||||
]
|
||||
);
|
||||
|
||||
// Color Value
|
||||
$repeater->add_control(
|
||||
'color',
|
||||
[
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'label_block' => true,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
'{{WRAPPER}}' => '--e-global-color-{{_id.VALUE}}: {{VALUE}}',
|
||||
],
|
||||
'global' => [
|
||||
'active' => false,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$default_colors = [
|
||||
[
|
||||
'_id' => 'primary',
|
||||
'title' => __( 'Primary', 'elementor' ),
|
||||
'color' => '#6EC1E4',
|
||||
],
|
||||
[
|
||||
'_id' => 'secondary',
|
||||
'title' => __( 'Secondary', 'elementor' ),
|
||||
'color' => '#54595F',
|
||||
],
|
||||
[
|
||||
'_id' => 'text',
|
||||
'title' => __( 'Text', 'elementor' ),
|
||||
'color' => '#7A7A7A',
|
||||
],
|
||||
[
|
||||
'_id' => 'accent',
|
||||
'title' => __( 'Accent', 'elementor' ),
|
||||
'color' => '#61CE70',
|
||||
],
|
||||
];
|
||||
|
||||
$this->add_control(
|
||||
'system_colors',
|
||||
[
|
||||
'type' => Global_Style_Repeater::CONTROL_TYPE,
|
||||
'fields' => $repeater->get_controls(),
|
||||
'default' => $default_colors,
|
||||
'item_actions' => [
|
||||
'add' => false,
|
||||
'remove' => false,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'custom_colors',
|
||||
[
|
||||
'type' => Global_Style_Repeater::CONTROL_TYPE,
|
||||
'fields' => $repeater->get_controls(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Core\Kits\Controls\Repeater as Global_Style_Repeater;
|
||||
use Elementor\Group_Control_Typography;
|
||||
use Elementor\Repeater;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Global_Typography extends Tab_Base {
|
||||
|
||||
const TYPOGRAPHY_PRIMARY = 'globals/typography?id=primary';
|
||||
const TYPOGRAPHY_SECONDARY = 'globals/typography?id=secondary';
|
||||
const TYPOGRAPHY_TEXT = 'globals/typography?id=text';
|
||||
const TYPOGRAPHY_ACCENT = 'globals/typography?id=accent';
|
||||
|
||||
const TYPOGRAPHY_NAME = 'typography';
|
||||
const TYPOGRAPHY_GROUP_PREFIX = self::TYPOGRAPHY_NAME . '_';
|
||||
|
||||
public function get_id() {
|
||||
return 'global-typography';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Global Fonts', 'elementor' );
|
||||
}
|
||||
|
||||
protected function register_tab_controls() {
|
||||
$this->start_controls_section(
|
||||
'section_text_style',
|
||||
[
|
||||
'label' => __( 'Global Fonts', 'elementor' ),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$repeater = new Repeater();
|
||||
|
||||
$repeater->add_control(
|
||||
'title',
|
||||
[
|
||||
'type' => Controls_Manager::TEXT,
|
||||
'label_block' => true,
|
||||
'required' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$repeater->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'name' => self::TYPOGRAPHY_NAME,
|
||||
'label' => '',
|
||||
'global' => [
|
||||
'active' => false,
|
||||
],
|
||||
'fields_options' => [
|
||||
'font_family' => [
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--e-global-typography-{{external._id.VALUE}}-font-family: "{{VALUE}}"',
|
||||
],
|
||||
],
|
||||
'font_size' => [
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--e-global-typography-{{external._id.VALUE}}-font-size: {{SIZE}}{{UNIT}}',
|
||||
],
|
||||
],
|
||||
'font_weight' => [
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--e-global-typography-{{external._id.VALUE}}-font-weight: {{VALUE}}',
|
||||
],
|
||||
],
|
||||
'text_transform' => [
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--e-global-typography-{{external._id.VALUE}}-text-transform: {{VALUE}}',
|
||||
],
|
||||
],
|
||||
'font_style' => [
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--e-global-typography-{{external._id.VALUE}}-font-style: {{VALUE}}',
|
||||
],
|
||||
],
|
||||
'text_decoration' => [
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--e-global-typography-{{external._id.VALUE}}-text-decoration: {{VALUE}}',
|
||||
],
|
||||
],
|
||||
'line_height' => [
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--e-global-typography-{{external._id.VALUE}}-line-height: {{SIZE}}{{UNIT}}',
|
||||
],
|
||||
],
|
||||
'letter_spacing' => [
|
||||
'selectors' => [
|
||||
'{{SELECTOR}}' => '--e-global-typography-{{external._id.VALUE}}-letter-spacing: {{SIZE}}{{UNIT}}',
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$typography_key = self::TYPOGRAPHY_GROUP_PREFIX . 'typography';
|
||||
$font_family_key = self::TYPOGRAPHY_GROUP_PREFIX . 'font_family';
|
||||
$font_weight_key = self::TYPOGRAPHY_GROUP_PREFIX . 'font_weight';
|
||||
|
||||
$default_typography = [
|
||||
[
|
||||
'_id' => 'primary',
|
||||
'title' => __( 'Primary', 'elementor' ),
|
||||
$typography_key => 'custom',
|
||||
$font_family_key => 'Roboto',
|
||||
$font_weight_key => '600',
|
||||
],
|
||||
[
|
||||
'_id' => 'secondary',
|
||||
'title' => __( 'Secondary', 'elementor' ),
|
||||
$typography_key => 'custom',
|
||||
$font_family_key => 'Roboto Slab',
|
||||
$font_weight_key => '400',
|
||||
],
|
||||
[
|
||||
'_id' => 'text',
|
||||
'title' => __( 'Text', 'elementor' ),
|
||||
$typography_key => 'custom',
|
||||
$font_family_key => 'Roboto',
|
||||
$font_weight_key => '400',
|
||||
],
|
||||
[
|
||||
'_id' => 'accent',
|
||||
'title' => __( 'Accent', 'elementor' ),
|
||||
$typography_key => 'custom',
|
||||
$font_family_key => 'Roboto',
|
||||
$font_weight_key => '500',
|
||||
],
|
||||
];
|
||||
|
||||
$this->add_control(
|
||||
'system_typography',
|
||||
[
|
||||
'type' => Global_Style_Repeater::CONTROL_TYPE,
|
||||
'fields' => $repeater->get_controls(),
|
||||
'default' => $default_typography,
|
||||
'item_actions' => [
|
||||
'add' => false,
|
||||
'remove' => false,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'custom_typography',
|
||||
[
|
||||
'type' => Global_Style_Repeater::CONTROL_TYPE,
|
||||
'fields' => $repeater->get_controls(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'default_generic_fonts',
|
||||
[
|
||||
'label' => __( 'Fallback Font Family', 'elementor' ),
|
||||
'type' => Controls_Manager::TEXT,
|
||||
'default' => 'Sans-serif',
|
||||
'description' => __( 'The list of fonts used if the chosen font is not available.', 'elementor' ),
|
||||
'label_block' => true,
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Group_Control_Background;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Settings_Background extends Tab_Base {
|
||||
|
||||
public function get_id() {
|
||||
return 'settings-background';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Background', 'elementor' );
|
||||
}
|
||||
|
||||
protected function register_tab_controls() {
|
||||
$this->start_controls_section(
|
||||
'section_background',
|
||||
[
|
||||
'label' => $this->get_title(),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Background::get_type(),
|
||||
[
|
||||
'name' => 'body_background',
|
||||
'types' => [ 'classic', 'gradient' ],
|
||||
'selector' => '{{WRAPPER}}',
|
||||
'fields_options' => [
|
||||
'background' => [
|
||||
'frontend_available' => true,
|
||||
],
|
||||
'color' => [
|
||||
'dynamic' => [],
|
||||
],
|
||||
'color_b' => [
|
||||
'dynamic' => [],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'mobile_browser_background',
|
||||
[
|
||||
'label' => __( 'Mobile Browser Background', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'description' => __( 'The `theme-color` meta tag will only be available in supported browsers and devices.', 'elementor' ),
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Plugin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Settings_Custom_CSS extends Tab_Base {
|
||||
|
||||
public function get_id() {
|
||||
return 'settings-custom-css';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Custom CSS', 'elementor' );
|
||||
}
|
||||
|
||||
protected function register_tab_controls() {
|
||||
Plugin::$instance->controls_manager->add_custom_css_controls( $this->parent, $this->get_id() );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\DB;
|
||||
use Elementor\Plugin;
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Core\Responsive\Responsive;
|
||||
use Elementor\Modules\PageTemplates\Module as PageTemplatesModule;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Settings_Layout extends Tab_Base {
|
||||
|
||||
public function get_id() {
|
||||
return 'settings-layout';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Layout', 'elementor' );
|
||||
}
|
||||
|
||||
protected function register_tab_controls() {
|
||||
$default_breakpoints = Responsive::get_default_breakpoints();
|
||||
|
||||
$this->start_controls_section(
|
||||
'section_' . $this->get_id(),
|
||||
[
|
||||
'label' => __( 'Layout Settings', 'elementor' ),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'container_width',
|
||||
[
|
||||
'label' => __( 'Content Width', 'elementor' ) . ' (px)',
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'default' => [
|
||||
'size' => '1140',
|
||||
],
|
||||
'tablet_default' => [
|
||||
'size' => $default_breakpoints['lg'],
|
||||
],
|
||||
'mobile_default' => [
|
||||
'size' => $default_breakpoints['md'],
|
||||
],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 300,
|
||||
'max' => 1500,
|
||||
'step' => 10,
|
||||
],
|
||||
],
|
||||
'description' => __( 'Sets the default width of the content area (Default: 1140)', 'elementor' ),
|
||||
'selectors' => [
|
||||
'.elementor-section.elementor-section-boxed > .elementor-container' => 'max-width: {{SIZE}}{{UNIT}}',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'space_between_widgets',
|
||||
[
|
||||
'label' => __( 'Widgets Space', 'elementor' ) . ' (px)',
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'default' => [
|
||||
'size' => 20,
|
||||
],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 0,
|
||||
'max' => 40,
|
||||
],
|
||||
],
|
||||
'placeholder' => '20',
|
||||
'description' => __( 'Sets the default space between widgets (Default: 20)', 'elementor' ),
|
||||
'selectors' => [
|
||||
'.elementor-widget:not(:last-child)' => 'margin-bottom: {{SIZE}}{{UNIT}}',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'page_title_selector',
|
||||
[
|
||||
'label' => __( 'Page Title Selector', 'elementor' ),
|
||||
'type' => Controls_Manager::TEXT,
|
||||
'default' => 'h1.entry-title',
|
||||
'placeholder' => 'h1.entry-title',
|
||||
'description' => __( 'Elementor lets you hide the page title. This works for themes that have "h1.entry-title" selector. If your theme\'s selector is different, please enter it above.', 'elementor' ),
|
||||
'label_block' => true,
|
||||
'selectors' => [
|
||||
// Hack to convert the value into a CSS selector.
|
||||
'' => '}{{VALUE}}{display: var(--page-title-display)',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'stretched_section_container',
|
||||
[
|
||||
'label' => __( 'Stretched Section Fit To', 'elementor' ),
|
||||
'type' => Controls_Manager::TEXT,
|
||||
'placeholder' => 'body',
|
||||
'description' => __( 'Enter parent element selector to which stretched sections will fit to (e.g. #primary / .wrapper / main etc). Leave blank to fit to page width.', 'elementor' ),
|
||||
'label_block' => true,
|
||||
'frontend_available' => true,
|
||||
]
|
||||
);
|
||||
|
||||
/**
|
||||
* @var PageTemplatesModule $page_templates_module
|
||||
*/
|
||||
$page_templates_module = Plugin::$instance->modules_manager->get_modules( 'page-templates' );
|
||||
$page_templates = $page_templates_module->add_page_templates( [], null, null );
|
||||
|
||||
$page_template_control_options = [
|
||||
'label' => __( 'Default Page Layout', 'elementor' ),
|
||||
'options' => [
|
||||
// This is here because the "Theme" string is different than the default option's string.
|
||||
'default' => __( 'Theme', 'elementor' ),
|
||||
] + $page_templates,
|
||||
];
|
||||
|
||||
$page_templates_module->add_template_controls( $this->parent, 'default_page_template', $page_template_control_options );
|
||||
|
||||
$this->end_controls_section();
|
||||
|
||||
$this->start_controls_section(
|
||||
'section_breakpoints',
|
||||
[
|
||||
'label' => __( 'Breakpoints', 'elementor' ),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'breakpoint_md_heading',
|
||||
[
|
||||
'label' => __( 'Mobile', 'elementor' ),
|
||||
'type' => Controls_Manager::HEADING,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
Responsive::BREAKPOINT_OPTION_PREFIX . 'md',
|
||||
[
|
||||
'label' => __( 'Breakpoint', 'elementor' ) . ' (px)',
|
||||
'type' => Controls_Manager::NUMBER,
|
||||
'min' => $default_breakpoints['sm'] + 1,
|
||||
'max' => $default_breakpoints['lg'] - 1,
|
||||
'default' => $default_breakpoints['md'],
|
||||
'placeholder' => $default_breakpoints['md'],
|
||||
/* translators: %d: Breakpoint value */
|
||||
'desc' => sprintf( __( 'Sets the breakpoint between tablet and mobile devices. Below this breakpoint mobile layout will appear (Default: %dpx).', 'elementor' ), $default_breakpoints['md'] ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'breakpoint_lg_heading',
|
||||
[
|
||||
'label' => __( 'Tablet', 'elementor' ),
|
||||
'type' => Controls_Manager::HEADING,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
Responsive::BREAKPOINT_OPTION_PREFIX . 'lg',
|
||||
[
|
||||
'label' => __( 'Breakpoint', 'elementor' ) . ' (px)',
|
||||
'type' => Controls_Manager::NUMBER,
|
||||
'min' => $default_breakpoints['md'] + 1,
|
||||
'max' => $default_breakpoints['xl'] - 1,
|
||||
'default' => $default_breakpoints['lg'],
|
||||
'placeholder' => $default_breakpoints['lg'],
|
||||
/* translators: %d: Breakpoint value */
|
||||
'desc' => sprintf( __( 'Sets the breakpoint between desktop and tablet devices. Below this breakpoint tablet layout will appear (Default: %dpx).', 'elementor' ), $default_breakpoints['lg'] ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
public function on_save( $data ) {
|
||||
if ( ! isset( $data['settings'] ) || DB::STATUS_PUBLISH !== $data['settings']['post_status'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$should_compile_css = false;
|
||||
|
||||
foreach ( Responsive::get_editable_breakpoints() as $breakpoint_key => $breakpoint ) {
|
||||
$setting_key = "viewport_{$breakpoint_key}";
|
||||
if ( isset( $data['settings'][ $setting_key ] ) ) {
|
||||
$should_compile_css = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $should_compile_css ) {
|
||||
Responsive::compile_stylesheet_templates();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Settings_Lightbox extends Tab_Base {
|
||||
|
||||
public function get_id() {
|
||||
return 'settings-lightbox';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Lightbox', 'elementor' );
|
||||
}
|
||||
|
||||
protected function register_tab_controls() {
|
||||
$this->start_controls_section(
|
||||
'section_' . $this->get_id(),
|
||||
[
|
||||
'label' => $this->get_title(),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'global_image_lightbox',
|
||||
[
|
||||
'label' => __( 'Image Lightbox', 'elementor' ),
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'default' => 'yes',
|
||||
'description' => __( 'Open all image links in a lightbox popup window. The lightbox will automatically work on any link that leads to an image file.', 'elementor' ),
|
||||
'frontend_available' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_enable_counter',
|
||||
[
|
||||
'label' => __( 'Counter', 'elementor' ),
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'default' => 'yes',
|
||||
'frontend_available' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_enable_fullscreen',
|
||||
[
|
||||
'label' => __( 'Fullscreen', 'elementor' ),
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'default' => 'yes',
|
||||
'frontend_available' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_enable_zoom',
|
||||
[
|
||||
'label' => __( 'Zoom', 'elementor' ),
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'default' => 'yes',
|
||||
'frontend_available' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_enable_share',
|
||||
[
|
||||
'label' => __( 'Share', 'elementor' ),
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'default' => 'yes',
|
||||
'frontend_available' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_title_src',
|
||||
[
|
||||
'label' => __( 'Title', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'options' => [
|
||||
'' => __( 'None', 'elementor' ),
|
||||
'title' => __( 'Title', 'elementor' ),
|
||||
'caption' => __( 'Caption', 'elementor' ),
|
||||
'alt' => __( 'Alt', 'elementor' ),
|
||||
'description' => __( 'Description', 'elementor' ),
|
||||
],
|
||||
'default' => 'title',
|
||||
'frontend_available' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_description_src',
|
||||
[
|
||||
'label' => __( 'Description', 'elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'options' => [
|
||||
'' => __( 'None', 'elementor' ),
|
||||
'title' => __( 'Title', 'elementor' ),
|
||||
'caption' => __( 'Caption', 'elementor' ),
|
||||
'alt' => __( 'Alt', 'elementor' ),
|
||||
'description' => __( 'Description', 'elementor' ),
|
||||
],
|
||||
'default' => 'description',
|
||||
'frontend_available' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_color',
|
||||
[
|
||||
'label' => __( 'Background Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'selectors' => [
|
||||
'.elementor-lightbox' => 'background-color: {{VALUE}}',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_ui_color',
|
||||
[
|
||||
'label' => __( 'UI Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'selectors' => [
|
||||
'.elementor-lightbox' => '--lightbox-ui-color: {{VALUE}}',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_ui_color_hover',
|
||||
[
|
||||
'label' => __( 'UI Hover Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'selectors' => [
|
||||
'.elementor-lightbox' => '--lightbox-ui-color-hover: {{VALUE}}',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_text_color',
|
||||
[
|
||||
'label' => __( 'Text Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'selectors' => [
|
||||
'.elementor-lightbox' => '--lightbox-text-color: {{VALUE}}',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_icons_size',
|
||||
[
|
||||
'label' => __( 'Toolbar Icons Size', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'selectors' => [
|
||||
'.elementor-lightbox' => '--lightbox-header-icons-size: {{SIZE}}{{UNIT}}',
|
||||
],
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'lightbox_slider_icons_size',
|
||||
[
|
||||
'label' => __( 'Navigation Icons Size', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'selectors' => [
|
||||
'.elementor-lightbox' => '--lightbox-navigation-icons-size: {{SIZE}}{{UNIT}}',
|
||||
],
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\DB;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Settings_Site_Identity extends Tab_Base {
|
||||
|
||||
public function get_id() {
|
||||
return 'settings-site-identity';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Site Identity', 'elementor' );
|
||||
}
|
||||
|
||||
protected function register_tab_controls() {
|
||||
$custom_logo_id = get_theme_mod( 'custom_logo' );
|
||||
$custom_logo_src = wp_get_attachment_image_src( $custom_logo_id, 'full' );
|
||||
|
||||
$site_icon_id = get_option( 'site_icon' );
|
||||
$site_icon_src = wp_get_attachment_image_src( $site_icon_id, 'full' );
|
||||
|
||||
$this->start_controls_section(
|
||||
'section_' . $this->get_id(),
|
||||
[
|
||||
'label' => $this->get_title(),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
$this->get_id() . '_refresh_notice',
|
||||
[
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'raw' => __( 'Changes will be reflected in the preview only after the page reloads.', 'elementor' ),
|
||||
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'site_name',
|
||||
[
|
||||
'label' => __( 'Site Name', 'elementor' ),
|
||||
'default' => get_option( 'blogname' ),
|
||||
'placeholder' => __( 'Choose name', 'elementor' ),
|
||||
'label_block' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'site_description',
|
||||
[
|
||||
'label' => __( 'Site Description', 'elementor' ),
|
||||
'default' => get_option( 'blogdescription' ),
|
||||
'placeholder' => __( 'Choose description', 'elementor' ),
|
||||
'label_block' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'site_logo',
|
||||
[
|
||||
'label' => __( 'Site Logo', 'elementor' ),
|
||||
'type' => Controls_Manager::MEDIA,
|
||||
'default' => [
|
||||
'id' => $custom_logo_id,
|
||||
'url' => $custom_logo_src ? $custom_logo_src[0] : '',
|
||||
],
|
||||
'description' => __( 'Suggested image dimensions: 350 × 100 pixels.', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'site_favicon',
|
||||
[
|
||||
'label' => __( 'Site Favicon', 'elementor' ),
|
||||
'type' => Controls_Manager::MEDIA,
|
||||
'default' => [
|
||||
'id' => $site_icon_id,
|
||||
'url' => $site_icon_src ? $site_icon_src[0] : '',
|
||||
],
|
||||
'description' => __( 'Suggested favicon dimensions: 512 × 512 pixels.', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
public function on_save( $data ) {
|
||||
if (
|
||||
! isset( $data['settings'] ) ||
|
||||
DB::STATUS_PUBLISH !== $data['settings']['post_status'] ||
|
||||
// Should check for the current action to avoid infinite loop
|
||||
// when updating options like: "blogname" and "blogdescription".
|
||||
strpos( current_action(), 'update_option_' ) === 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $data['settings']['site_name'] ) ) {
|
||||
update_option( 'blogname', $data['settings']['site_name'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['settings']['site_description'] ) ) {
|
||||
update_option( 'blogdescription', $data['settings']['site_description'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['settings']['site_logo'] ) ) {
|
||||
set_theme_mod( 'custom_logo', $data['settings']['site_logo']['id'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['settings']['site_favicon'] ) ) {
|
||||
update_option( 'site_icon', $data['settings']['site_favicon']['id'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Core\Kits\Documents\Kit;
|
||||
use Elementor\Core\Kits\Manager;
|
||||
use Elementor\Plugin;
|
||||
use Elementor\Settings;
|
||||
use Elementor\Sub_Controls_Stack;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
abstract class Tab_Base extends Sub_Controls_Stack {
|
||||
/**
|
||||
* @var Kit
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
abstract protected function register_tab_controls();
|
||||
|
||||
public function register_controls() {
|
||||
$this->register_tab();
|
||||
|
||||
$this->register_tab_controls();
|
||||
}
|
||||
|
||||
public function on_save( $data ) {}
|
||||
|
||||
protected function register_tab() {
|
||||
Controls_Manager::add_tab( $this->get_id(), $this->get_title() );
|
||||
}
|
||||
|
||||
protected function add_default_globals_notice() {
|
||||
// Get the current section config (array - section id and tab) to use for creating a unique control ID and name
|
||||
$current_section = $this->parent->get_current_section();
|
||||
|
||||
/** @var Manager $module */
|
||||
$kits_manager = Plugin::$instance->kits_manager;
|
||||
|
||||
if ( $kits_manager->is_custom_colors_enabled() || $kits_manager->is_custom_typography_enabled() ) {
|
||||
$this->add_control(
|
||||
$current_section['section'] . '_schemes_notice',
|
||||
[
|
||||
'name' => $current_section['section'] . '_schemes_notice',
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'raw' => sprintf( __( 'In order for Theme Style to affect all relevant Elementor elements, please disable Default Colors and Fonts from the <a href="%s" target="_blank">Settings Page</a>.', 'elementor' ), Settings::get_url() ),
|
||||
'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
|
||||
'render_type' => 'ui',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Group_Control_Border;
|
||||
use Elementor\Group_Control_Box_Shadow;
|
||||
use Elementor\Group_Control_Text_Shadow;
|
||||
use Elementor\Group_Control_Typography;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Theme_Style_Buttons extends Tab_Base {
|
||||
|
||||
public function get_id() {
|
||||
return 'theme-style-buttons';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Buttons', 'elementor' );
|
||||
}
|
||||
|
||||
protected function register_tab_controls() {
|
||||
$button_selectors = [
|
||||
'{{WRAPPER}} button',
|
||||
'{{WRAPPER}} input[type="button"]',
|
||||
'{{WRAPPER}} input[type="submit"]',
|
||||
'{{WRAPPER}} .elementor-button',
|
||||
];
|
||||
|
||||
$button_hover_selectors = [
|
||||
'{{WRAPPER}} button:hover',
|
||||
'{{WRAPPER}} button:focus',
|
||||
'{{WRAPPER}} input[type="button"]:hover',
|
||||
'{{WRAPPER}} input[type="button"]:focus',
|
||||
'{{WRAPPER}} input[type="submit"]:hover',
|
||||
'{{WRAPPER}} input[type="submit"]:focus',
|
||||
'{{WRAPPER}} .elementor-button:hover',
|
||||
'{{WRAPPER}} .elementor-button:focus',
|
||||
];
|
||||
|
||||
$button_selector = implode( ',', $button_selectors );
|
||||
$button_hover_selector = implode( ',', $button_hover_selectors );
|
||||
|
||||
$this->start_controls_section(
|
||||
'section_buttons',
|
||||
[
|
||||
'label' => __( 'Buttons', 'elementor' ),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_default_globals_notice();
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'label' => __( 'Typography', 'elementor' ),
|
||||
'name' => 'button_typography',
|
||||
'selector' => $button_selector,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Text_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'button_text_shadow',
|
||||
'selector' => $button_selector,
|
||||
]
|
||||
);
|
||||
|
||||
$this->start_controls_tabs( 'tabs_button_style' );
|
||||
|
||||
$this->start_controls_tab(
|
||||
'tab_button_normal',
|
||||
[
|
||||
'label' => __( 'Normal', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'button_text_color',
|
||||
[
|
||||
'label' => __( 'Text Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
$button_selector => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'button_background_color',
|
||||
[
|
||||
'label' => __( 'Background Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
$button_selector => 'background-color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Box_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'button_box_shadow',
|
||||
'selector' => $button_selector,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Border::get_type(),
|
||||
[
|
||||
'name' => 'button_border',
|
||||
'selector' => $button_selector,
|
||||
'fields_options' => [
|
||||
'color' => [
|
||||
'dynamic' => [],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'button_border_radius',
|
||||
[
|
||||
'label' => __( 'Border Radius', 'elementor' ),
|
||||
'type' => Controls_Manager::DIMENSIONS,
|
||||
'size_units' => [ 'px', '%' ],
|
||||
'selectors' => [
|
||||
$button_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->start_controls_tab(
|
||||
'tab_button_hover',
|
||||
[
|
||||
'label' => __( 'Hover', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'button_hover_text_color',
|
||||
[
|
||||
'label' => __( 'Text Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
$button_hover_selector => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'button_hover_background_color',
|
||||
[
|
||||
'label' => __( 'Background Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
$button_hover_selector => 'background-color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Box_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'button_hover_box_shadow',
|
||||
'selector' => $button_hover_selector,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Border::get_type(),
|
||||
[
|
||||
'name' => 'button_hover_border',
|
||||
'selector' => $button_hover_selector,
|
||||
'fields_options' => [
|
||||
'color' => [
|
||||
'dynamic' => [],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'button_hover_border_radius',
|
||||
[
|
||||
'label' => __( 'Border Radius', 'elementor' ),
|
||||
'type' => Controls_Manager::DIMENSIONS,
|
||||
'size_units' => [ 'px', '%' ],
|
||||
'selectors' => [
|
||||
$button_hover_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->end_controls_tabs();
|
||||
|
||||
$this->add_responsive_control(
|
||||
'button_padding',
|
||||
[
|
||||
'label' => __( 'Padding', 'elementor' ),
|
||||
'type' => Controls_Manager::DIMENSIONS,
|
||||
'size_units' => [ 'px', 'em', '%' ],
|
||||
'selectors' => [
|
||||
$button_selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
||||
],
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Group_Control_Border;
|
||||
use Elementor\Group_Control_Box_Shadow;
|
||||
use Elementor\Group_Control_Typography;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Theme_Style_Form_Fields extends Tab_Base {
|
||||
|
||||
public function get_id() {
|
||||
return 'theme-style-form-fields';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Form Fields', 'elementor' );
|
||||
}
|
||||
|
||||
protected function register_tab_controls() {
|
||||
$label_selectors = [
|
||||
'{{WRAPPER}} label',
|
||||
];
|
||||
|
||||
$input_selectors = [
|
||||
'{{WRAPPER}} input:not([type="button"]):not([type="submit"])',
|
||||
'{{WRAPPER}} textarea',
|
||||
'{{WRAPPER}} .elementor-field-textual',
|
||||
];
|
||||
|
||||
$input_focus_selectors = [
|
||||
'{{WRAPPER}} input:focus:not([type="button"]):not([type="submit"])',
|
||||
'{{WRAPPER}} textarea:focus',
|
||||
'{{WRAPPER}} .elementor-field-textual:focus',
|
||||
];
|
||||
|
||||
$label_selector = implode( ',', $label_selectors );
|
||||
$input_selector = implode( ',', $input_selectors );
|
||||
$input_focus_selector = implode( ',', $input_focus_selectors );
|
||||
|
||||
$this->start_controls_section(
|
||||
'section_form_fields',
|
||||
[
|
||||
'label' => __( 'Form Fields', 'elementor' ),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_default_globals_notice();
|
||||
|
||||
$this->add_control(
|
||||
'form_label_heading',
|
||||
[
|
||||
'type' => Controls_Manager::HEADING,
|
||||
'label' => __( 'Label', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'form_label_color',
|
||||
[
|
||||
'label' => __( 'Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
$label_selector => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'label' => __( 'Typography', 'elementor' ),
|
||||
'name' => 'form_label_typography',
|
||||
'selector' => $label_selector,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'form_field_heading',
|
||||
[
|
||||
'type' => Controls_Manager::HEADING,
|
||||
'label' => __( 'Field', 'elementor' ),
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'label' => __( 'Typography', 'elementor' ),
|
||||
'name' => 'form_field_typography',
|
||||
'selector' => $input_selector,
|
||||
]
|
||||
);
|
||||
|
||||
$this->start_controls_tabs( 'tabs_form_field_style' );
|
||||
|
||||
$this->start_controls_tab(
|
||||
'tab_form_field_normal',
|
||||
[
|
||||
'label' => __( 'Normal', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_form_field_state_tab_controls( 'form_field', $input_selector );
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->start_controls_tab(
|
||||
'tab_form_field_focus',
|
||||
[
|
||||
'label' => __( 'Focus', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_form_field_state_tab_controls( 'form_field_focus', $input_focus_selector );
|
||||
|
||||
$this->add_control(
|
||||
'form_field_focus_transition_duration',
|
||||
[
|
||||
'label' => __( 'Transition Duration', 'elementor' ) . ' (ms)',
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'selectors' => [
|
||||
$input_selector => 'transition: {{SIZE}}ms',
|
||||
],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 0,
|
||||
'max' => 3000,
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->end_controls_tabs();
|
||||
|
||||
$this->add_responsive_control(
|
||||
'form_field_padding',
|
||||
[
|
||||
'label' => __( 'Padding', 'elementor' ),
|
||||
'type' => Controls_Manager::DIMENSIONS,
|
||||
'size_units' => [ 'px', 'em', '%' ],
|
||||
'selectors' => [
|
||||
$input_selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
||||
],
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
private function add_form_field_state_tab_controls( $prefix, $selector ) {
|
||||
$this->add_control(
|
||||
$prefix . '_text_color',
|
||||
[
|
||||
'label' => __( 'Text Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
$selector => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
$prefix . '_background_color',
|
||||
[
|
||||
'label' => __( 'Background Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
$selector => 'background-color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Box_Shadow::get_type(),
|
||||
[
|
||||
'name' => $prefix . '_box_shadow',
|
||||
'selector' => $selector,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Border::get_type(),
|
||||
[
|
||||
'name' => $prefix . '_border',
|
||||
'selector' => $selector,
|
||||
'fields_options' => [
|
||||
'color' => [
|
||||
'dynamic' => [],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
$prefix . '_border_radius',
|
||||
[
|
||||
'label' => __( 'Border Radius', 'elementor' ),
|
||||
'type' => Controls_Manager::DIMENSIONS,
|
||||
'size_units' => [ 'px', '%' ],
|
||||
'selectors' => [
|
||||
$selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Group_Control_Border;
|
||||
use Elementor\Group_Control_Box_Shadow;
|
||||
use Elementor\Group_Control_Css_Filter;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Theme_Style_Images extends Tab_Base {
|
||||
|
||||
public function get_id() {
|
||||
return 'theme-style-images';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Images', 'elementor' );
|
||||
}
|
||||
|
||||
protected function register_tab_controls() {
|
||||
$image_selectors = [
|
||||
'{{WRAPPER}} img',
|
||||
];
|
||||
|
||||
$image_hover_selectors = [
|
||||
'{{WRAPPER}} img:hover',
|
||||
];
|
||||
|
||||
$image_selectors = implode( ',', $image_selectors );
|
||||
$image_hover_selectors = implode( ',', $image_hover_selectors );
|
||||
|
||||
$this->start_controls_section(
|
||||
'section_images',
|
||||
[
|
||||
'label' => __( 'Images', 'elementor' ),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_default_globals_notice();
|
||||
|
||||
$this->start_controls_tabs( 'tabs_image_style' );
|
||||
|
||||
$this->start_controls_tab(
|
||||
'tab_image_normal',
|
||||
[
|
||||
'label' => __( 'Normal', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Border::get_type(),
|
||||
[
|
||||
'name' => 'image_border',
|
||||
'selector' => $image_selectors,
|
||||
'fields_options' => [
|
||||
'color' => [
|
||||
'dynamic' => [],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'image_border_radius',
|
||||
[
|
||||
'label' => __( 'Border Radius', 'elementor' ),
|
||||
'type' => Controls_Manager::DIMENSIONS,
|
||||
'size_units' => [ 'px', '%' ],
|
||||
'selectors' => [
|
||||
$image_selectors => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'image_opacity',
|
||||
[
|
||||
'label' => __( 'Opacity', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'range' => [
|
||||
'px' => [
|
||||
'max' => 1,
|
||||
'min' => 0.10,
|
||||
'step' => 0.01,
|
||||
],
|
||||
],
|
||||
'selectors' => [
|
||||
$image_selectors => 'opacity: {{SIZE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Box_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'image_box_shadow',
|
||||
'exclude' => [
|
||||
'box_shadow_position',
|
||||
],
|
||||
'selector' => $image_selectors,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Css_Filter::get_type(),
|
||||
[
|
||||
'name' => 'image_css_filters',
|
||||
'selector' => '{{WRAPPER}} img',
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->start_controls_tab(
|
||||
'tab_image_hover',
|
||||
[
|
||||
'label' => __( 'Hover', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Border::get_type(),
|
||||
[
|
||||
'name' => 'image_hover_border',
|
||||
'selector' => '{{WRAPPER}} img:hover',
|
||||
'fields_options' => [
|
||||
'color' => [
|
||||
'dynamic' => [],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'image_hover_border_radius',
|
||||
[
|
||||
'label' => __( 'Border Radius', 'elementor' ),
|
||||
'type' => Controls_Manager::DIMENSIONS,
|
||||
'size_units' => [ 'px', '%' ],
|
||||
'selectors' => [
|
||||
$image_hover_selectors => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'image_hover_opacity',
|
||||
[
|
||||
'label' => __( 'Opacity', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'range' => [
|
||||
'px' => [
|
||||
'max' => 1,
|
||||
'min' => 0.10,
|
||||
'step' => 0.01,
|
||||
],
|
||||
],
|
||||
'selectors' => [
|
||||
$image_hover_selectors => 'opacity: {{SIZE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Box_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'image_hover_box_shadow',
|
||||
'exclude' => [
|
||||
'box_shadow_position',
|
||||
],
|
||||
'selector' => $image_hover_selectors,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Css_Filter::get_type(),
|
||||
[
|
||||
'name' => 'image_hover_css_filters',
|
||||
'selector' => $image_hover_selectors,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'image_hover_transition',
|
||||
[
|
||||
'label' => __( 'Transition Duration', 'elementor' ) . ' (s)',
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'range' => [
|
||||
'px' => [
|
||||
'max' => 3,
|
||||
'step' => 0.1,
|
||||
],
|
||||
],
|
||||
'selectors' => [
|
||||
$image_selectors => 'transition-duration: {{SIZE}}s',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->end_controls_tabs();
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Core\Kits\Documents\Tabs;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Group_Control_Typography;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Theme_Style_Typography extends Tab_Base {
|
||||
|
||||
public function get_id() {
|
||||
return 'theme-style-typography';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return __( 'Typography', 'elementor' );
|
||||
}
|
||||
|
||||
public function register_tab_controls() {
|
||||
$this->start_controls_section(
|
||||
'section_typography',
|
||||
[
|
||||
'label' => __( 'Typography', 'elementor' ),
|
||||
'tab' => $this->get_id(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_default_globals_notice();
|
||||
|
||||
$this->add_control(
|
||||
'body_heading',
|
||||
[
|
||||
'type' => Controls_Manager::HEADING,
|
||||
'label' => __( 'Body', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'body_color',
|
||||
[
|
||||
'label' => __( 'Text Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
'{{WRAPPER}}' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'label' => __( 'Typography', 'elementor' ),
|
||||
'name' => 'body_typography',
|
||||
'selector' => '{{WRAPPER}}',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'paragraph_spacing',
|
||||
[
|
||||
'label' => __( 'Paragraph Spacing', 'elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'selectors' => [
|
||||
'{{WRAPPER}} p' => 'margin-bottom: {{SIZE}}{{UNIT}}',
|
||||
],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
],
|
||||
'em' => [
|
||||
'min' => 0.1,
|
||||
'max' => 20,
|
||||
],
|
||||
'vh' => [
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
],
|
||||
],
|
||||
'size_units' => [ 'px', 'em', 'vh' ],
|
||||
]
|
||||
);
|
||||
|
||||
//Link Selectors
|
||||
$link_selectors = [
|
||||
'{{WRAPPER}} a',
|
||||
];
|
||||
|
||||
$link_hover_selectors = [
|
||||
'{{WRAPPER}} a:hover',
|
||||
];
|
||||
|
||||
$link_selectors = implode( ',', $link_selectors );
|
||||
$link_hover_selectors = implode( ',', $link_hover_selectors );
|
||||
|
||||
$this->add_control(
|
||||
'link_heading',
|
||||
[
|
||||
'type' => Controls_Manager::HEADING,
|
||||
'label' => __( 'Link', 'elementor' ),
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->start_controls_tabs( 'tabs_link_style' );
|
||||
|
||||
$this->start_controls_tab(
|
||||
'tab_link_normal',
|
||||
[
|
||||
'label' => __( 'Normal', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'link_normal_color',
|
||||
[
|
||||
'label' => __( 'Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
$link_selectors => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'label' => __( 'Typography', 'elementor' ),
|
||||
'name' => 'link_normal_typography',
|
||||
'selector' => $link_selectors,
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->start_controls_tab(
|
||||
'tab_link_hover',
|
||||
[
|
||||
'label' => __( 'Hover', 'elementor' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'link_hover_color',
|
||||
[
|
||||
'label' => __( 'Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
$link_hover_selectors => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'label' => __( 'Typography', 'elementor' ),
|
||||
'name' => 'link_hover_typography',
|
||||
'selector' => $link_hover_selectors,
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->end_controls_tabs();
|
||||
|
||||
// Headings.
|
||||
$this->add_element_controls( __( 'H1', 'elementor' ), 'h1', '{{WRAPPER}} h1' );
|
||||
$this->add_element_controls( __( 'H2', 'elementor' ), 'h2', '{{WRAPPER}} h2' );
|
||||
$this->add_element_controls( __( 'H3', 'elementor' ), 'h3', '{{WRAPPER}} h3' );
|
||||
$this->add_element_controls( __( 'H4', 'elementor' ), 'h4', '{{WRAPPER}} h4' );
|
||||
$this->add_element_controls( __( 'H5', 'elementor' ), 'h5', '{{WRAPPER}} h5' );
|
||||
$this->add_element_controls( __( 'H6', 'elementor' ), 'h6', '{{WRAPPER}} h6' );
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
private function add_element_controls( $label, $prefix, $selector ) {
|
||||
$this->add_control(
|
||||
$prefix . '_heading',
|
||||
[
|
||||
'type' => Controls_Manager::HEADING,
|
||||
'label' => $label,
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
$prefix . '_color',
|
||||
[
|
||||
'label' => __( 'Color', 'elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'dynamic' => [],
|
||||
'selectors' => [
|
||||
$selector => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'label' => __( 'Typography', 'elementor' ),
|
||||
'name' => $prefix . '_typography',
|
||||
'selector' => $selector,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Kits;
|
||||
|
||||
use Elementor\Core\Kits\Controls\Repeater;
|
||||
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
|
||||
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
|
||||
use Elementor\Plugin;
|
||||
use Elementor\Core\Files\CSS\Post as Post_CSS;
|
||||
use Elementor\Core\Files\CSS\Post_Preview as Post_Preview;
|
||||
use Elementor\Core\Documents_Manager;
|
||||
use Elementor\Core\Kits\Documents\Kit;
|
||||
use Elementor\TemplateLibrary\Source_Local;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Manager {
|
||||
|
||||
const OPTION_ACTIVE = 'elementor_active_kit';
|
||||
|
||||
public function get_active_id() {
|
||||
$id = get_option( self::OPTION_ACTIVE );
|
||||
|
||||
$kit_document = Plugin::$instance->documents->get( $id );
|
||||
|
||||
if ( ! $kit_document || ! $kit_document instanceof Kit || 'trash' === $kit_document->get_main_post()->post_status ) {
|
||||
$id = $this->create_default();
|
||||
update_option( self::OPTION_ACTIVE, $id );
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function get_active_kit() {
|
||||
$id = $this->get_active_id();
|
||||
|
||||
return Plugin::$instance->documents->get( $id );
|
||||
}
|
||||
|
||||
public function get_active_kit_for_frontend() {
|
||||
$id = $this->get_active_id();
|
||||
|
||||
return Plugin::$instance->documents->get_doc_for_frontend( $id );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init kit controls.
|
||||
*
|
||||
* A temp solution in order to avoid init kit group control from within another group control.
|
||||
*
|
||||
* After moving the `default_font` to the kit, the Typography group control cause initialize the kit controls at: https://github.com/elementor/elementor/blob/e6e1db9eddef7e3c1a5b2ba0c2338e2af2a3bfe3/includes/controls/groups/typography.php#L91
|
||||
* and because the group control is a singleton, its args are changed to the last kit group control.
|
||||
*/
|
||||
public function init_kit_controls() {
|
||||
$this->get_active_kit_for_frontend()->get_settings();
|
||||
}
|
||||
|
||||
public function get_current_settings( $setting = null ) {
|
||||
$kit = $this->get_active_kit_for_frontend();
|
||||
|
||||
if ( ! $kit ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $kit->get_settings( $setting );
|
||||
}
|
||||
|
||||
private function create_default() {
|
||||
$kit = Plugin::$instance->documents->create( 'kit', [
|
||||
'post_type' => Source_Local::CPT,
|
||||
'post_title' => __( 'Default Kit', 'elementor' ),
|
||||
'post_status' => 'publish',
|
||||
] );
|
||||
|
||||
return $kit->get_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Documents_Manager $documents_manager
|
||||
*/
|
||||
public function register_document( $documents_manager ) {
|
||||
$documents_manager->register_document_type( 'kit', Kit::get_class_full_name() );
|
||||
}
|
||||
|
||||
public function localize_settings( $settings ) {
|
||||
$kit = $this->get_active_kit();
|
||||
$kit_controls = $kit->get_controls();
|
||||
$design_system_controls = [
|
||||
'colors' => $kit_controls['system_colors']['fields'],
|
||||
'typography' => $kit_controls['system_typography']['fields'],
|
||||
];
|
||||
|
||||
$settings = array_replace_recursive( $settings, [
|
||||
'kit_id' => $kit->get_main_id(),
|
||||
'kit_config' => [
|
||||
'typography_prefix' => Global_Typography::TYPOGRAPHY_GROUP_PREFIX,
|
||||
'design_system_controls' => $design_system_controls,
|
||||
],
|
||||
'user' => [
|
||||
'can_edit_kit' => $kit->is_editable_by_current_user(),
|
||||
],
|
||||
'i18n' => [
|
||||
'close' => __( 'Close', 'elementor' ),
|
||||
'back' => __( 'Back', 'elementor' ),
|
||||
'site_identity' => __( 'Site Identity', 'elementor' ),
|
||||
'lightbox' => __( 'Lightbox', 'elementor' ),
|
||||
'layout' => __( 'Layout', 'elementor' ),
|
||||
'theme_style' => __( 'Theme Style', 'elementor' ),
|
||||
'add_color' => __( 'Add Color', 'elementor' ),
|
||||
'add_style' => __( 'Add Style', 'elementor' ),
|
||||
'new_item' => __( 'New Item', 'elementor' ),
|
||||
'global_color' => __( 'Global Color', 'elementor' ),
|
||||
'global_fonts' => __( 'Global Fonts', 'elementor' ),
|
||||
'global_colors' => __( 'Global Colors', 'elementor' ),
|
||||
'invalid' => __( 'Invalid', 'elementor' ),
|
||||
'color_cannot_be_deleted' => __( 'System Color can\'t be deleted', 'elementor' ),
|
||||
'font_cannot_be_deleted' => __( 'System Font can\'t be deleted', 'elementor' ),
|
||||
'design_system' => __( 'Design System', 'elementor' ),
|
||||
'buttons' => __( 'Buttons', 'elementor' ),
|
||||
'images' => __( 'Images', 'elementor' ),
|
||||
'form_fields' => __( 'Form Fields', 'elementor' ),
|
||||
'background' => __( 'Background', 'elementor' ),
|
||||
'custom_css' => __( 'Custom CSS', 'elementor' ),
|
||||
'additional_settings' => __( 'Additional Settings', 'elementor' ),
|
||||
'kit_changes_updated' => __( 'Your changes have been updated.', 'elementor' ),
|
||||
'back_to_editor' => __( 'Back to Editor', 'elementor' ),
|
||||
],
|
||||
] );
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
public function preview_enqueue_styles() {
|
||||
$kit = $this->get_kit_for_frontend();
|
||||
|
||||
if ( $kit ) {
|
||||
// On preview, the global style is not enqueued.
|
||||
$this->frontend_before_enqueue_styles();
|
||||
|
||||
Plugin::$instance->frontend->print_fonts_links();
|
||||
}
|
||||
}
|
||||
|
||||
public function frontend_before_enqueue_styles() {
|
||||
$kit = $this->get_kit_for_frontend();
|
||||
|
||||
if ( $kit ) {
|
||||
if ( $kit->is_autosave() ) {
|
||||
$css_file = Post_Preview::create( $kit->get_id() );
|
||||
} else {
|
||||
$css_file = Post_CSS::create( $kit->get_id() );
|
||||
}
|
||||
|
||||
$css_file->enqueue();
|
||||
}
|
||||
}
|
||||
|
||||
public function render_panel_html() {
|
||||
require __DIR__ . '/views/panel.php';
|
||||
}
|
||||
|
||||
public function get_kit_for_frontend() {
|
||||
$kit = false;
|
||||
$active_kit = $this->get_active_kit();
|
||||
$is_kit_preview = is_preview() && isset( $_GET['preview_id'] ) && $active_kit->get_main_id() === (int) $_GET['preview_id'];
|
||||
|
||||
if ( $is_kit_preview ) {
|
||||
$kit = Plugin::$instance->documents->get_doc_or_auto_save( $active_kit->get_main_id(), get_current_user_id() );
|
||||
} elseif ( 'publish' === $active_kit->get_main_post()->post_status ) {
|
||||
$kit = $active_kit;
|
||||
}
|
||||
|
||||
return $kit;
|
||||
}
|
||||
|
||||
public function update_kit_settings_based_on_option( $key, $value ) {
|
||||
/** @var Kit $active_kit */
|
||||
$active_kit = $this->get_active_kit();
|
||||
|
||||
if ( $active_kit->is_saving() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$active_kit->update_settings( [ $key => $value ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Map Scheme To Global
|
||||
*
|
||||
* Convert a given scheme value to its corresponding default global value
|
||||
*
|
||||
* @param string $type 'color'/'typography'
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
private function map_scheme_to_global( $type, $value ) {
|
||||
$schemes_to_globals_map = [
|
||||
'color' => [
|
||||
'1' => Global_Colors::COLOR_PRIMARY,
|
||||
'2' => Global_Colors::COLOR_SECONDARY,
|
||||
'3' => Global_Colors::COLOR_TEXT,
|
||||
'4' => Global_Colors::COLOR_ACCENT,
|
||||
],
|
||||
'typography' => [
|
||||
'1' => Global_Typography::TYPOGRAPHY_PRIMARY,
|
||||
'2' => Global_Typography::TYPOGRAPHY_SECONDARY,
|
||||
'3' => Global_Typography::TYPOGRAPHY_TEXT,
|
||||
'4' => Global_Typography::TYPOGRAPHY_ACCENT,
|
||||
],
|
||||
];
|
||||
|
||||
return $schemes_to_globals_map[ $type ][ $value ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Scheme to Default Global
|
||||
*
|
||||
* If a control has a scheme property, convert it to a default Global.
|
||||
*
|
||||
* @param $scheme - Control scheme property
|
||||
* @return array - Control/group control args
|
||||
* @since 3.0.0
|
||||
* @access public
|
||||
*/
|
||||
public function convert_scheme_to_global( $scheme ) {
|
||||
if ( isset( $scheme['type'] ) && isset( $scheme['value'] ) ) {
|
||||
//_deprecated_argument( $args['scheme'], '3.0.0', 'Schemes are now deprecated - use $args[\'global\'] instead.' );
|
||||
return $this->map_scheme_to_global( $scheme['type'], $scheme['value'] );
|
||||
}
|
||||
|
||||
// Typography control 'scheme' properties usually only include the string with the typography value ('1'-'4').
|
||||
return $this->map_scheme_to_global( 'typography', $scheme );
|
||||
}
|
||||
|
||||
public function register_controls() {
|
||||
$controls_manager = Plugin::$instance->controls_manager;
|
||||
|
||||
$controls_manager->register_control( Repeater::CONTROL_TYPE, new Repeater() );
|
||||
}
|
||||
|
||||
public function is_custom_colors_enabled() {
|
||||
return ! get_option( 'elementor_disable_color_schemes' );
|
||||
}
|
||||
|
||||
public function is_custom_typography_enabled() {
|
||||
return ! get_option( 'elementor_disable_typography_schemes' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add kit wrapper body class.
|
||||
*
|
||||
* It should be added even for non Elementor pages,
|
||||
* in order to support embedded templates.
|
||||
*/
|
||||
private function add_body_class() {
|
||||
$kit = $this->get_kit_for_frontend();
|
||||
|
||||
if ( $kit ) {
|
||||
Plugin::$instance->frontend->add_body_class( 'elementor-kit-' . $kit->get_main_id() );
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
add_action( 'elementor/documents/register', [ $this, 'register_document' ] );
|
||||
add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] );
|
||||
add_filter( 'elementor/editor/footer', [ $this, 'render_panel_html' ] );
|
||||
add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'frontend_before_enqueue_styles' ], 0 );
|
||||
add_action( 'elementor/preview/enqueue_styles', [ $this, 'preview_enqueue_styles' ], 0 );
|
||||
add_action( 'elementor/controls/controls_registered', [ $this, 'register_controls' ] );
|
||||
|
||||
add_action( 'update_option_blogname', function ( $old_value, $value ) {
|
||||
$this->update_kit_settings_based_on_option( 'site_name', $value );
|
||||
}, 10, 2 );
|
||||
|
||||
add_action( 'update_option_blogdescription', function ( $old_value, $value ) {
|
||||
$this->update_kit_settings_based_on_option( 'site_description', $value );
|
||||
}, 10, 2 );
|
||||
|
||||
add_action( 'wp_head', function() {
|
||||
$this->add_body_class();
|
||||
} );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<script type="text/template" id="tmpl-elementor-kit-panel">
|
||||
<main id="elementor-kit__panel-content__wrapper" class="elementor-panel-content-wrapper"></main>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="tmpl-elementor-kit-panel-content">
|
||||
<div id="elementor-kit-panel-content-controls"></div>
|
||||
<#
|
||||
const tabConfig = $e.components.get( 'panel/global' ).getActiveTabConfig();
|
||||
if ( tabConfig.helpUrl ) { #>
|
||||
<div id="elementor-panel__editor__help">
|
||||
<a id="elementor-panel__editor__help__link" href="{{ tabConfig.helpUrl }}" target="_blank">
|
||||
<?php echo __( 'Need Help', 'elementor' ); ?>
|
||||
<i class="eicon-help-o"></i>
|
||||
</a>
|
||||
</div>
|
||||
<# } #>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="tmpl-elementor-global-style-repeater-row">
|
||||
<# let removeClass = 'remove',
|
||||
removeIcon = 'eicon-trash-o';
|
||||
|
||||
if ( ! itemActions.remove ) {
|
||||
removeClass += '--disabled';
|
||||
|
||||
removeIcon = 'eicon-disable-trash-o'
|
||||
}
|
||||
#>
|
||||
<div class="elementor-repeater-row-tool elementor-repeater-tool-{{{ removeClass }}}">
|
||||
<i class="{{{ removeIcon }}}" aria-hidden="true"></i>
|
||||
<# if ( itemActions.remove ) { #>
|
||||
<span class="elementor-screen-only"><?php echo __( 'Remove', 'elementor' ); ?></span>
|
||||
<# } #>
|
||||
</div>
|
||||
<div class="elementor-repeater-row-controls"></div>
|
||||
</script>
|
||||
Reference in New Issue
Block a user