| 1 |
<?php |
| 2 |
namespace HT_Builder\Elementor\Widget; |
| 3 |
|
| 4 |
// Elementor Classes |
| 5 |
use Elementor\Plugin as Elementor; |
| 6 |
use Elementor\Widget_Base; |
| 7 |
use Elementor\Controls_Manager; |
| 8 |
use Elementor\Group_Control_Border; |
| 9 |
use Elementor\Group_Control_Box_Shadow; |
| 10 |
use Elementor\Group_Control_Text_Shadow; |
| 11 |
use Elementor\Group_Control_Typography; |
| 12 |
|
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 15 |
|
| 16 |
class Bl_Post_Title_ELement extends Widget_Base { |
| 17 |
|
| 18 |
public function get_name() { |
| 19 |
return 'bl-single-blog-title'; |
| 20 |
} |
| 21 |
|
| 22 |
public function get_title() { |
| 23 |
return __( 'BL: Post Title', 'ht-builder' ); |
| 24 |
} |
| 25 |
|
| 26 |
public function get_icon() { |
| 27 |
return 'htbuilder-icon eicon-post-title'; |
| 28 |
} |
| 29 |
|
| 30 |
public function get_categories() { |
| 31 |
return ['ht_builder']; |
| 32 |
} |
| 33 |
|
| 34 |
protected function register_controls() { |
| 35 |
|
| 36 |
|
| 37 |
// Post Title |
| 38 |
$this->start_controls_section( |
| 39 |
'blog_title_content', |
| 40 |
[ |
| 41 |
'label' => __( 'Post Title', 'ht-builder' ), |
| 42 |
] |
| 43 |
); |
| 44 |
$this->add_control( |
| 45 |
'blog_title_html_tag', |
| 46 |
[ |
| 47 |
'label' => __( 'Title HTML Tag', 'ht-builder' ), |
| 48 |
'type' => Controls_Manager::SELECT, |
| 49 |
'options' => htbuilder_html_tag_lists(), |
| 50 |
'default' => 'h1', |
| 51 |
] |
| 52 |
); |
| 53 |
|
| 54 |
$this->end_controls_section(); |
| 55 |
|
| 56 |
// Style |
| 57 |
$this->start_controls_section( |
| 58 |
'blog_title_style_section', |
| 59 |
array( |
| 60 |
'label' => __( 'Post Title', 'ht-builder' ), |
| 61 |
'tab' => Controls_Manager::TAB_STYLE, |
| 62 |
) |
| 63 |
); |
| 64 |
|
| 65 |
$this->add_control( |
| 66 |
'blog_title_color', |
| 67 |
[ |
| 68 |
'label' => __( 'Title Color', 'ht-builder' ), |
| 69 |
'type' => Controls_Manager::COLOR, |
| 70 |
'selectors' => [ |
| 71 |
'{{WRAPPER}} .entry-title' => 'color: {{VALUE}};', |
| 72 |
], |
| 73 |
] |
| 74 |
); |
| 75 |
|
| 76 |
$this->add_group_control( |
| 77 |
Group_Control_Typography::get_type(), |
| 78 |
array( |
| 79 |
'name' => 'blog_title_typography', |
| 80 |
'label' => __( 'Typography', 'ht-builder' ), |
| 81 |
'selector' => '{{WRAPPER}} .entry-title', |
| 82 |
) |
| 83 |
); |
| 84 |
|
| 85 |
$this->add_responsive_control( |
| 86 |
'blog_title_margin', |
| 87 |
[ |
| 88 |
'label' => __( 'Margin', 'ht-builder' ), |
| 89 |
'type' => Controls_Manager::DIMENSIONS, |
| 90 |
'size_units' => [ 'px', '%', 'em' ], |
| 91 |
'selectors' => [ |
| 92 |
'{{WRAPPER}} .entry-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 93 |
], |
| 94 |
'separator' => 'before', |
| 95 |
] |
| 96 |
); |
| 97 |
|
| 98 |
$this->add_responsive_control( |
| 99 |
'blog_title_align', |
| 100 |
[ |
| 101 |
'label' => __( 'Alignment', 'ht-builder' ), |
| 102 |
'type' => Controls_Manager::CHOOSE, |
| 103 |
'options' => [ |
| 104 |
'left' => [ |
| 105 |
'title' => __( 'Left', 'ht-builder' ), |
| 106 |
'icon' => 'fa fa-align-left', |
| 107 |
], |
| 108 |
'center' => [ |
| 109 |
'title' => __( 'Center', 'ht-builder' ), |
| 110 |
'icon' => 'fa fa-align-center', |
| 111 |
], |
| 112 |
'right' => [ |
| 113 |
'title' => __( 'Right', 'ht-builder' ), |
| 114 |
'icon' => 'fa fa-align-right', |
| 115 |
], |
| 116 |
'justify' => [ |
| 117 |
'title' => __( 'Justified', 'ht-builder' ), |
| 118 |
'icon' => 'fa fa-align-justify', |
| 119 |
], |
| 120 |
], |
| 121 |
'prefix_class' => 'elementor-align-%s', |
| 122 |
'default' => 'left', |
| 123 |
] |
| 124 |
); |
| 125 |
|
| 126 |
$this->end_controls_section(); |
| 127 |
|
| 128 |
} |
| 129 |
|
| 130 |
protected function render( $instance = [] ) { |
| 131 |
$settings = $this->get_settings_for_display(); |
| 132 |
if( Elementor::instance()->editor->is_edit_mode() ){ |
| 133 |
echo sprintf( '<%1$s class="entry-title">' . __('Blog Title', 'ht-builder' ). '</%1$s>', $settings['blog_title_html_tag'] ); |
| 134 |
}else{ |
| 135 |
echo sprintf( the_title( '<%1$s class="entry-title">', '</%1$s>', false ), $settings['blog_title_html_tag'] ); |
| 136 |
} |
| 137 |
|
| 138 |
} |
| 139 |
|
| 140 |
} |
| 141 |
|