first commit
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\ThemeBuilder\Widgets;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
|
||||
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
|
||||
use Elementor\Group_Control_Typography;
|
||||
use ElementorPro\Modules\Posts\Widgets\Posts_Base;
|
||||
use ElementorPro\Modules\ThemeBuilder\Skins;
|
||||
use ElementorPro\Modules\QueryControl\Module as Query_Control;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Posts
|
||||
*/
|
||||
class Archive_Posts extends Posts_Base {
|
||||
|
||||
public function get_name() {
|
||||
return 'archive-posts';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return esc_html__( 'Archive Posts', 'elementor-pro' );
|
||||
}
|
||||
|
||||
public function get_icon() {
|
||||
return 'eicon-archive-posts';
|
||||
}
|
||||
|
||||
public function get_categories() {
|
||||
return [ 'theme-elements-archive' ];
|
||||
}
|
||||
|
||||
public function get_keywords() {
|
||||
return [ 'posts', 'cpt', 'archive', 'loop', 'query', 'cards', 'custom post type' ];
|
||||
}
|
||||
|
||||
public function get_inline_css_depends() {
|
||||
return [ 'posts' ];
|
||||
}
|
||||
|
||||
protected function register_skins() {
|
||||
$this->add_skin( new Skins\Posts_Archive_Skin_Classic( $this ) );
|
||||
$this->add_skin( new Skins\Posts_Archive_Skin_Cards( $this ) );
|
||||
$this->add_skin( new Skins\Posts_Archive_Skin_Full_Content( $this ) );
|
||||
}
|
||||
|
||||
protected function register_controls() {
|
||||
parent::register_controls();
|
||||
|
||||
$this->register_pagination_section_controls();
|
||||
|
||||
$this->register_advanced_section_controls();
|
||||
|
||||
$this->update_control(
|
||||
'pagination_type',
|
||||
[
|
||||
'default' => 'numbers',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function register_advanced_section_controls() {
|
||||
$this->start_controls_section(
|
||||
'section_advanced',
|
||||
[
|
||||
'label' => esc_html__( 'Advanced', 'elementor-pro' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'nothing_found_message',
|
||||
[
|
||||
'label' => esc_html__( 'Nothing Found Message', 'elementor-pro' ),
|
||||
'type' => Controls_Manager::TEXTAREA,
|
||||
'default' => esc_html__( 'It seems we can\'t find what you\'re looking for.', 'elementor-pro' ),
|
||||
'dynamic' => [
|
||||
'active' => true,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
|
||||
$this->start_controls_section(
|
||||
'section_nothing_found_style',
|
||||
[
|
||||
'tab' => Controls_Manager::TAB_STYLE,
|
||||
'label' => esc_html__( 'Nothing Found Message', 'elementor-pro' ),
|
||||
'condition' => [
|
||||
'nothing_found_message!' => '',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'nothing_found_color',
|
||||
[
|
||||
'label' => esc_html__( 'Color', 'elementor-pro' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'global' => [
|
||||
'default' => Global_Colors::COLOR_TEXT,
|
||||
],
|
||||
'selectors' => [
|
||||
'{{WRAPPER}} .elementor-posts-nothing-found' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'name' => 'nothing_found_typography',
|
||||
'global' => [
|
||||
'default' => Global_Typography::TYPOGRAPHY_TEXT,
|
||||
],
|
||||
'selector' => '{{WRAPPER}} .elementor-posts-nothing-found',
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
public function query_posts() {
|
||||
global $wp_query;
|
||||
|
||||
$query_vars = $wp_query->query_vars;
|
||||
|
||||
/**
|
||||
* Posts archive query vars.
|
||||
*
|
||||
* Filters the post query variables when the theme loads the posts archive page.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param array $query_vars The query variables for the `WP_Query`.
|
||||
*/
|
||||
$query_vars = apply_filters( 'elementor/theme/posts_archive/query_posts/query_vars', $query_vars );
|
||||
|
||||
if ( $query_vars !== $wp_query->query_vars ) {
|
||||
$this->query = new \WP_Query( $query_vars ); // SQL_CALC_FOUND_ROWS is used.
|
||||
} else {
|
||||
$this->query = $wp_query;
|
||||
}
|
||||
|
||||
Query_Control::add_to_avoid_list( wp_list_pluck( $this->query->posts, 'ID' ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\ThemeBuilder\Widgets;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Archive_Title extends Title_Widget_Base {
|
||||
|
||||
protected function get_dynamic_tag_name() {
|
||||
return 'archive-title';
|
||||
}
|
||||
|
||||
public function get_name() {
|
||||
// `theme` prefix is to avoid conflicts with a dynamic-tag with same name.
|
||||
return 'theme-archive-title';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return esc_html__( 'Archive Title', 'elementor-pro' );
|
||||
}
|
||||
|
||||
public function get_icon() {
|
||||
return 'eicon-archive-title';
|
||||
}
|
||||
|
||||
public function get_categories() {
|
||||
return [ 'theme-elements-archive' ];
|
||||
}
|
||||
|
||||
public function get_keywords() {
|
||||
return [ 'title', 'heading', 'archive' ];
|
||||
}
|
||||
|
||||
public function get_inline_css_depends() {
|
||||
return [
|
||||
[
|
||||
'name' => 'heading',
|
||||
'is_core_dependency' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\ThemeBuilder\Widgets;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Page_Title extends Title_Widget_Base {
|
||||
|
||||
protected function get_dynamic_tag_name() {
|
||||
return 'page-title';
|
||||
}
|
||||
|
||||
public function get_name() {
|
||||
// `theme` prefix is to avoid conflicts with a dynamic-tag with same name.
|
||||
return 'theme-page-title';
|
||||
}
|
||||
|
||||
public function get_inline_css_depends() {
|
||||
return [
|
||||
[
|
||||
'name' => 'heading',
|
||||
'is_core_dependency' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return esc_html__( 'Page Title', 'elementor-pro' );
|
||||
}
|
||||
|
||||
public function get_icon() {
|
||||
return 'eicon-archive-title';
|
||||
}
|
||||
|
||||
public function get_categories() {
|
||||
return [ 'theme-elements' ];
|
||||
}
|
||||
|
||||
public function get_keywords() {
|
||||
return [ 'title', 'heading', 'page' ];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\ThemeBuilder\Widgets;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
|
||||
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
|
||||
use Elementor\Group_Control_Typography;
|
||||
use ElementorPro\Base\Base_Widget;
|
||||
use ElementorPro\Modules\Posts\Skins\Skin_Content_Base;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Post_Content extends Base_Widget {
|
||||
use Skin_Content_Base;
|
||||
public function get_name() {
|
||||
// `theme` prefix is to avoid conflicts with a dynamic-tag with same name.
|
||||
return 'theme-post-content';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return esc_html__( 'Post Content', 'elementor-pro' );
|
||||
}
|
||||
|
||||
public function get_icon() {
|
||||
return 'eicon-post-content';
|
||||
}
|
||||
|
||||
public function get_categories() {
|
||||
return [ 'theme-elements-single' ];
|
||||
}
|
||||
|
||||
public function get_keywords() {
|
||||
return [ 'content', 'post' ];
|
||||
}
|
||||
|
||||
public function show_in_panel() {
|
||||
// By default don't show.
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function register_controls() {
|
||||
$this->start_controls_section(
|
||||
'section_style',
|
||||
[
|
||||
'label' => esc_html__( 'Style', 'elementor-pro' ),
|
||||
'tab' => Controls_Manager::TAB_STYLE,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'align',
|
||||
[
|
||||
'label' => esc_html__( 'Alignment', 'elementor-pro' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'options' => [
|
||||
'left' => [
|
||||
'title' => esc_html__( 'Left', 'elementor-pro' ),
|
||||
'icon' => 'eicon-text-align-left',
|
||||
],
|
||||
'center' => [
|
||||
'title' => esc_html__( 'Center', 'elementor-pro' ),
|
||||
'icon' => 'eicon-text-align-center',
|
||||
],
|
||||
'right' => [
|
||||
'title' => esc_html__( 'Right', 'elementor-pro' ),
|
||||
'icon' => 'eicon-text-align-right',
|
||||
],
|
||||
'justify' => [
|
||||
'title' => esc_html__( 'Justified', 'elementor-pro' ),
|
||||
'icon' => 'eicon-text-align-justify',
|
||||
],
|
||||
],
|
||||
'selectors' => [
|
||||
'{{WRAPPER}}' => 'text-align: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'text_color',
|
||||
[
|
||||
'label' => esc_html__( 'Text Color', 'elementor-pro' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'default' => '',
|
||||
'selectors' => [
|
||||
'{{WRAPPER}}' => 'color: {{VALUE}};',
|
||||
],
|
||||
'global' => [
|
||||
'default' => Global_Colors::COLOR_TEXT,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'name' => 'typography',
|
||||
'global' => [
|
||||
'default' => Global_Typography::TYPOGRAPHY_TEXT,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
protected function render() {
|
||||
// Post CSS should not be printed here because it overrides the already existing post CSS.
|
||||
$this->render_post_content( false, false );
|
||||
}
|
||||
|
||||
public function render_plain_content() {}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\ThemeBuilder\Widgets;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
|
||||
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
|
||||
use Elementor\Group_Control_Typography;
|
||||
use ElementorPro\Base\Base_Widget;
|
||||
use ElementorPro\Plugin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Post_Excerpt extends Base_Widget {
|
||||
|
||||
public function get_name() {
|
||||
// `theme` prefix is to avoid conflicts with a dynamic-tag with same name.
|
||||
return 'theme-post-excerpt';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return esc_html__( 'Post Excerpt', 'elementor-pro' );
|
||||
}
|
||||
|
||||
public function get_icon() {
|
||||
return 'eicon-post-excerpt';
|
||||
}
|
||||
|
||||
public function get_categories() {
|
||||
return [ 'theme-elements-single' ];
|
||||
}
|
||||
|
||||
public function get_keywords() {
|
||||
return [ 'post', 'excerpt', 'description' ];
|
||||
}
|
||||
|
||||
protected function register_controls() {
|
||||
$this->start_controls_section(
|
||||
'section_content',
|
||||
[
|
||||
'label' => esc_html__( 'Content', 'elementor-pro' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'excerpt',
|
||||
[
|
||||
'type' => Controls_Manager::TEXT,
|
||||
'label_block' => true,
|
||||
'dynamic' => [
|
||||
'active' => true,
|
||||
'default' => Plugin::elementor()->dynamic_tags->tag_data_to_tag_text( null, 'post-excerpt' ),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
|
||||
$this->start_controls_section(
|
||||
'section_style',
|
||||
[
|
||||
'label' => esc_html__( 'Style', 'elementor-pro' ),
|
||||
'tab' => Controls_Manager::TAB_STYLE,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'align',
|
||||
[
|
||||
'label' => esc_html__( 'Alignment', 'elementor-pro' ),
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'options' => [
|
||||
'left' => [
|
||||
'title' => esc_html__( 'Left', 'elementor-pro' ),
|
||||
'icon' => 'eicon-text-align-left',
|
||||
],
|
||||
'center' => [
|
||||
'title' => esc_html__( 'Center', 'elementor-pro' ),
|
||||
'icon' => 'eicon-text-align-center',
|
||||
],
|
||||
'right' => [
|
||||
'title' => esc_html__( 'Right', 'elementor-pro' ),
|
||||
'icon' => 'eicon-text-align-right',
|
||||
],
|
||||
'justify' => [
|
||||
'title' => esc_html__( 'Justified', 'elementor-pro' ),
|
||||
'icon' => 'eicon-text-align-justify',
|
||||
],
|
||||
],
|
||||
'selectors' => [
|
||||
'{{WRAPPER}} .elementor-widget-container' => 'text-align: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'title_color',
|
||||
[
|
||||
'label' => esc_html__( 'Text Color', 'elementor-pro' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'global' => [
|
||||
'default' => Global_Colors::COLOR_TEXT,
|
||||
],
|
||||
'selectors' => [
|
||||
'{{WRAPPER}} .elementor-widget-container' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'name' => 'typography',
|
||||
'global' => [
|
||||
'default' => Global_Typography::TYPOGRAPHY_TEXT,
|
||||
],
|
||||
'selector' => '{{WRAPPER}} .elementor-widget-container',
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
protected function render() {
|
||||
$this->print_unescaped_setting( 'excerpt' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\ThemeBuilder\Widgets;
|
||||
|
||||
use Elementor\Widget_Image;
|
||||
use ElementorPro\Base\Base_Widget_Trait;
|
||||
use ElementorPro\Plugin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Post_Featured_Image extends Widget_Image {
|
||||
|
||||
use Base_Widget_Trait;
|
||||
|
||||
public function get_name() {
|
||||
// `theme` prefix is to avoid conflicts with a dynamic-tag with same name.
|
||||
return 'theme-post-featured-image';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return esc_html__( 'Featured Image', 'elementor-pro' );
|
||||
}
|
||||
|
||||
public function get_icon() {
|
||||
return 'eicon-featured-image';
|
||||
}
|
||||
|
||||
public function get_categories() {
|
||||
return [ 'theme-elements-single' ];
|
||||
}
|
||||
|
||||
public function get_keywords() {
|
||||
return [ 'image', 'featured', 'thumbnail' ];
|
||||
}
|
||||
|
||||
public function get_inline_css_depends() {
|
||||
return [
|
||||
[
|
||||
'name' => 'image',
|
||||
'is_core_dependency' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function register_controls() {
|
||||
parent::register_controls();
|
||||
|
||||
$this->update_control(
|
||||
'image',
|
||||
[
|
||||
'dynamic' => [
|
||||
'default' => Plugin::elementor()->dynamic_tags->tag_data_to_tag_text( null, 'post-featured-image' ),
|
||||
],
|
||||
],
|
||||
[
|
||||
'recursive' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function get_html_wrapper_class() {
|
||||
return parent::get_html_wrapper_class() . ' elementor-widget-' . parent::get_name();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\ThemeBuilder\Widgets;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Post_Title extends Title_Widget_Base {
|
||||
|
||||
public function get_name() {
|
||||
// `theme` prefix is to avoid conflicts with a dynamic-tag with same name.
|
||||
return 'theme-post-title';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return esc_html__( 'Post Title', 'elementor-pro' );
|
||||
}
|
||||
|
||||
public function get_icon() {
|
||||
return 'eicon-post-title';
|
||||
}
|
||||
|
||||
public function get_categories() {
|
||||
return [ 'theme-elements-single' ];
|
||||
}
|
||||
|
||||
public function get_keywords() {
|
||||
return [ 'title', 'heading', 'post' ];
|
||||
}
|
||||
|
||||
protected function get_dynamic_tag_name() {
|
||||
return 'post-title';
|
||||
}
|
||||
|
||||
public function get_common_args() {
|
||||
return [
|
||||
'_css_classes' => [
|
||||
'default' => 'entry-title',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function get_inline_css_depends() {
|
||||
return [
|
||||
[
|
||||
'name' => 'heading',
|
||||
'is_core_dependency' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\ThemeBuilder\Widgets;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Group_Control_Image_Size;
|
||||
use Elementor\Utils;
|
||||
use Elementor\Widget_Image;
|
||||
use ElementorPro\Base\Base_Widget_Trait;
|
||||
use ElementorPro\Modules\ThemeBuilder\Classes\Control_Media_Preview;
|
||||
use ElementorPro\Plugin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Site_Logo extends Widget_Image {
|
||||
|
||||
use Base_Widget_Trait;
|
||||
|
||||
public function get_name() {
|
||||
// `theme` prefix is to avoid conflicts with a dynamic-tag with same name.
|
||||
return 'theme-site-logo';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return esc_html__( 'Site Logo', 'elementor-pro' );
|
||||
}
|
||||
|
||||
public function get_icon() {
|
||||
return 'eicon-site-logo';
|
||||
}
|
||||
|
||||
public function get_categories() {
|
||||
return [ 'theme-elements' ];
|
||||
}
|
||||
|
||||
public function get_keywords() {
|
||||
return [ 'site', 'logo', 'branding' ];
|
||||
}
|
||||
|
||||
public function get_inline_css_depends() {
|
||||
return [
|
||||
[
|
||||
'name' => 'image',
|
||||
'is_core_dependency' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function register_controls() {
|
||||
parent::register_controls();
|
||||
|
||||
$this->update_control(
|
||||
'section_image',
|
||||
[
|
||||
'label' => esc_html__( 'Site Logo', 'elementor-pro' ),
|
||||
]
|
||||
);
|
||||
|
||||
$this->update_control(
|
||||
'image',
|
||||
[
|
||||
'label' => esc_html__( 'Site Logo', 'elementor-pro' ),
|
||||
'type' => Control_Media_Preview::CONTROL_TYPE,
|
||||
'src' => $this->get_site_logo(),
|
||||
'dynamic' => [
|
||||
'default' => Plugin::elementor()->dynamic_tags->tag_data_to_tag_text( null, 'site-logo' ),
|
||||
],
|
||||
],
|
||||
[
|
||||
'recursive' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->update_control(
|
||||
'image_size',
|
||||
[
|
||||
'separator' => 'before',
|
||||
'default' => 'full',
|
||||
]
|
||||
);
|
||||
|
||||
$this->update_control(
|
||||
'link_to',
|
||||
[
|
||||
'options' => [
|
||||
'none' => esc_html__( 'None', 'elementor-pro' ),
|
||||
'site_url' => esc_html__( 'Site URL', 'elementor-pro' ),
|
||||
'custom' => esc_html__( 'Custom URL', 'elementor-pro' ),
|
||||
'file' => esc_html__( 'Media File', 'elementor-pro' ),
|
||||
],
|
||||
'default' => 'site_url',
|
||||
],
|
||||
[
|
||||
'recursive' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->update_control(
|
||||
'caption_source',
|
||||
[
|
||||
'options' => [
|
||||
'none' => esc_html__( 'None', 'elementor-pro' ),
|
||||
'attachment' => esc_html__( 'Attachment Caption', 'elementor-pro' ),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->remove_control( 'caption' );
|
||||
|
||||
$this->add_control(
|
||||
'change_logo_cta',
|
||||
[
|
||||
'type' => Controls_Manager::BUTTON,
|
||||
'label_block' => true,
|
||||
'show_label' => false,
|
||||
'button_type' => 'default elementor-button-center',
|
||||
'text' => esc_html__( 'Change Site Logo', 'elementor-pro' ),
|
||||
'event' => 'elementorProSiteLogo:change',
|
||||
],
|
||||
[
|
||||
'position' => [
|
||||
'of' => 'image',
|
||||
'type' => 'control',
|
||||
'at' => 'after',
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Remove this method when Elementor Core 3.11.0 is required.
|
||||
* Duplicate of render() method from Elementor\Widget_Image class, so it will use the get_link_url() method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function render() {
|
||||
$settings = $this->get_settings_for_display();
|
||||
|
||||
if ( empty( $settings['image']['url'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$has_caption = $this->has_caption( $settings );
|
||||
|
||||
$link = $this->get_link_url( $settings );
|
||||
|
||||
if ( $link ) {
|
||||
$this->add_link_attributes( 'link', $link );
|
||||
|
||||
if ( Plugin::elementor()->editor->is_edit_mode() ) {
|
||||
$this->add_render_attribute( 'link', 'class', 'elementor-clickable' );
|
||||
}
|
||||
|
||||
if ( 'file' === $settings['link_to'] ) {
|
||||
$this->add_lightbox_data_attributes( 'link', $settings['image']['id'], $settings['open_lightbox'] );
|
||||
}
|
||||
} ?>
|
||||
<?php if ( $has_caption ) : ?>
|
||||
<figure class="wp-caption">
|
||||
<?php endif; ?>
|
||||
<?php if ( $link ) : ?>
|
||||
<a <?php $this->print_render_attribute_string( 'link' ); ?>>
|
||||
<?php endif; ?>
|
||||
<?php Group_Control_Image_Size::print_attachment_image_html( $settings ); ?>
|
||||
<?php if ( $link ) : ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ( $has_caption ) : ?>
|
||||
<figcaption class="widget-image-caption wp-caption-text"><?php
|
||||
echo wp_kses_post( $this->get_caption( $settings ) );
|
||||
?></figcaption>
|
||||
<?php endif; ?>
|
||||
<?php if ( $has_caption ) : ?>
|
||||
</figure>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
}
|
||||
|
||||
protected function get_html_wrapper_class() {
|
||||
return parent::get_html_wrapper_class() . ' elementor-widget-' . parent::get_name();
|
||||
}
|
||||
|
||||
protected function get_link_url( $settings ) {
|
||||
switch ( $settings['link_to'] ) {
|
||||
case 'none':
|
||||
return false;
|
||||
|
||||
case 'custom':
|
||||
return ( ! empty( $settings['link']['url'] ) ) ? $settings['link'] : false;
|
||||
|
||||
case 'site_url':
|
||||
return [ 'url' => Plugin::elementor()->dynamic_tags->get_tag_data_content( null, 'site-url' ) ?? '' ];
|
||||
|
||||
default:
|
||||
return [ 'url' => $settings['image']['url'] ];
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this method when removing the render() method.
|
||||
private function has_caption( $settings ) {
|
||||
return ( ! empty( $settings['caption_source'] ) && 'none' !== $settings['caption_source'] );
|
||||
}
|
||||
|
||||
// TODO: Remove this method when removing the render() method.
|
||||
private function get_caption( $settings ) {
|
||||
$caption = '';
|
||||
|
||||
if ( ! empty( $settings['caption_source'] ) && 'attachment' === $settings['caption_source'] ) {
|
||||
$caption = wp_get_attachment_caption( $settings['image']['id'] );
|
||||
}
|
||||
|
||||
return $caption;
|
||||
}
|
||||
|
||||
// Get the site logo from the dynamic tag
|
||||
private function get_site_logo(): string {
|
||||
$site_logo = Plugin::elementor()->dynamic_tags->get_tag_data_content( null, 'site-logo' );
|
||||
return $site_logo['url'] ?? Utils::get_placeholder_image_src();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\ThemeBuilder\Widgets;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Widget_Heading;
|
||||
use ElementorPro\Base\Base_Widget_Trait;
|
||||
use ElementorPro\Plugin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Site_Title extends Widget_Heading {
|
||||
|
||||
use Base_Widget_Trait;
|
||||
|
||||
public function get_name() {
|
||||
// `theme` prefix is to avoid conflicts with a dynamic-tag with same name.
|
||||
return 'theme-site-title';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return esc_html__( 'Site Title', 'elementor-pro' );
|
||||
}
|
||||
|
||||
public function get_icon() {
|
||||
return 'eicon-site-title';
|
||||
}
|
||||
|
||||
public function get_categories() {
|
||||
return [ 'theme-elements' ];
|
||||
}
|
||||
|
||||
public function get_keywords() {
|
||||
return [ 'site', 'title', 'name' ];
|
||||
}
|
||||
|
||||
public function get_inline_css_depends() {
|
||||
return [
|
||||
[
|
||||
'name' => 'heading',
|
||||
'is_core_dependency' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function register_controls() {
|
||||
parent::register_controls();
|
||||
$this->update_control(
|
||||
'title',
|
||||
[
|
||||
'dynamic' => [
|
||||
'default' => Plugin::elementor()->dynamic_tags->tag_data_to_tag_text( null, 'site-title' ),
|
||||
],
|
||||
],
|
||||
[
|
||||
'recursive' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->update_control(
|
||||
'link',
|
||||
[
|
||||
'dynamic' => [
|
||||
'default' => Plugin::elementor()->dynamic_tags->tag_data_to_tag_text( null, 'site-url' ),
|
||||
],
|
||||
],
|
||||
[
|
||||
'recursive' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'site_identity_notice',
|
||||
[
|
||||
// TODO: Remove define() with the release of Elementor 3.22
|
||||
'type' => defined( 'Controls_Manager::ALERT' ) ? Controls_Manager::ALERT : 'alert',
|
||||
'alert_type' => 'info',
|
||||
'content' => sprintf(
|
||||
/* translators: 1: Link opening tag, 2: Link closing tag. */
|
||||
esc_html__( 'To edit the title of your site, go to %1$sSite Identity%2$s.', 'elementor-pro' ),
|
||||
'<a href="#" onclick="elementorPro.modules.themeBuilder.openSiteIdentity( event )" >',
|
||||
'</a>'
|
||||
),
|
||||
],
|
||||
[
|
||||
'position' => [
|
||||
'of' => 'title',
|
||||
'type' => 'control',
|
||||
'at' => 'before',
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function get_html_wrapper_class() {
|
||||
return parent::get_html_wrapper_class() . ' elementor-widget-' . parent::get_name();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace ElementorPro\Modules\ThemeBuilder\Widgets;
|
||||
|
||||
use Elementor\Widget_Heading;
|
||||
use Elementor\Plugin;
|
||||
use ElementorPro\Base\Base_Widget_Trait;
|
||||
use ElementorPro\Plugin as ProPlugin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
abstract class Title_Widget_Base extends Widget_Heading {
|
||||
|
||||
use Base_Widget_Trait;
|
||||
|
||||
abstract protected function get_dynamic_tag_name();
|
||||
|
||||
protected function should_show_page_title() {
|
||||
$current_doc = Plugin::instance()->documents->get( get_the_ID() );
|
||||
if ( $current_doc && 'yes' === $current_doc->get_settings( 'hide_title' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function register_controls() {
|
||||
parent::register_controls();
|
||||
|
||||
$dynamic_tag_name = $this->get_dynamic_tag_name();
|
||||
|
||||
$this->update_control(
|
||||
'title',
|
||||
[
|
||||
'dynamic' => [
|
||||
'default' => ProPlugin::elementor()->dynamic_tags->tag_data_to_tag_text( null, $dynamic_tag_name ),
|
||||
],
|
||||
],
|
||||
[
|
||||
'recursive' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->update_control(
|
||||
'header_size',
|
||||
[
|
||||
'default' => 'h1',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function get_html_wrapper_class() {
|
||||
return parent::get_html_wrapper_class() . ' elementor-page-title elementor-widget-' . parent::get_name();
|
||||
}
|
||||
|
||||
public function render() {
|
||||
if ( $this->should_show_page_title() ) {
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user