PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.0.7
Easy Elements for Elementor – Addons & Website Templates v1.0.7
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / widgets / post-title / post-title.php

post-title.php in Easy Elements for Elementor – Addons & Website Templates 1.0.7, at widgets/post-title/post-title.php

167 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 use Elementor\Controls_Manager;
3 use Elementor\Widget_Base;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 if( class_exists("Easyel_Post_Title_Widget")) {
10 return;
11 }
12
13 class Easyel_Post_Title_Widget extends \Elementor\Widget_Base {
14
15 public function get_style_depends() {
16 $handle = 'eel-post-title';
17 $css_path = plugin_dir_path( __FILE__ ) . 'css/post-title.css';
18
19 if ( ! wp_style_is( $handle, 'registered' ) && file_exists( $css_path ) ) {
20 wp_register_style( $handle, plugins_url( 'css/post-title.css', __FILE__ ), [], defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $css_path ) : '1.0.0' );
21 }
22 return [ $handle ];
23 }
24
25 public function get_name() {
26 return 'eel-post-title';
27 }
28
29 public function get_title() {
30 return __( 'Post Title', 'easy-elements' );
31 }
32
33 public function get_icon() {
34 return 'easyicon easyelIcon-post-title';
35 }
36
37 public function get_categories() {
38 return [ 'easyelements_category_pro' ];
39 }
40
41 public function get_keywords() {
42 return [ 'post', 'title', 'link', 'click', 'text', 'heading' ];
43 }
44 protected function register_controls() {
45
46 $this->start_controls_section(
47 'content_section',
48 [
49 'label' => esc_html__('Post Title Settings', 'easy-elements'),
50 'tab' => Controls_Manager::TAB_CONTENT,
51 ]
52 );
53
54 $this->add_control(
55 'title_tag',
56 [
57 'label' => esc_html__('HTML Tag', 'easy-elements'),
58 'type' => Controls_Manager::SELECT,
59 'default' => 'h1',
60 'options' => [
61 'h1' => 'H1',
62 'h2' => 'H2',
63 'h3' => 'H3',
64 'h4' => 'H4',
65 'h5' => 'H5',
66 'h6' => 'H6',
67 'div' => 'div',
68 'span' => 'span',
69 'p' => 'p',
70 ],
71 ]
72 );
73
74 $this->add_control(
75 'link_to_post',
76 [
77 'label' => esc_html__('Link to Post', 'easy-elements'),
78 'type' => Controls_Manager::SWITCHER,
79 'label_on' => esc_html__('Yes', 'easy-elements'),
80 'label_off' => esc_html__('No', 'easy-elements'),
81 'default' => '',
82 ]
83 );
84
85 $this->add_control(
86 'align',
87 [
88 'label' => esc_html__('Alignment', 'easy-elements'),
89 'type' => Controls_Manager::CHOOSE,
90 'options' => [
91 'left' => [
92 'title' => esc_html__('Left', 'easy-elements'),
93 'icon' => 'eicon-text-align-left',
94 ],
95 'center' => [
96 'title' => esc_html__('Center', 'easy-elements'),
97 'icon' => 'eicon-text-align-center',
98 ],
99 'right' => [
100 'title' => esc_html__('Right', 'easy-elements'),
101 'icon' => 'eicon-text-align-right',
102 ],
103 ],
104 'default' => 'left',
105 'toggle' => true,
106 ]
107 );
108
109 $this->add_control(
110 'title_color',
111 [
112 'label' => esc_html__('Title Color', 'easy-elements'),
113 'type' => Controls_Manager::COLOR,
114 'selectors' => [
115 '{{WRAPPER}} .eel-post-title' => 'color: {{VALUE}};',
116 ],
117 ]
118 );
119
120 $this->add_group_control(
121 \Elementor\Group_Control_Typography::get_type(),
122 [
123 'name' => 'content_typography',
124 'selector' => '{{WRAPPER}} .eel-post-title',
125 ]
126 );
127 $this->add_responsive_control(
128 'margin',
129 [
130 'label' => esc_html__('Margin', 'easy-elements'),
131 'type' => Controls_Manager::DIMENSIONS,
132 'size_units' => [ 'px', 'em', '%' ],
133 'selectors' => [
134 '{{WRAPPER}} .eel-post-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
135 ],
136 ]
137 );
138
139 $this->end_controls_section();
140
141 }
142
143 protected function render() {
144 $settings = $this->get_settings_for_display();
145 $tag = !empty($settings['title_tag']) ? $settings['title_tag'] : 'h1';
146 $align = !empty($settings['align']) ? $settings['align'] : 'left';
147 $link = !empty($settings['link_to_post']);
148 $title = '';
149 if ( isset($easy_elements_original_post) && $easy_elements_original_post instanceof WP_Post ) {
150 $title = get_the_title( $easy_elements_original_post );
151 $post_url = get_permalink( $easy_elements_original_post );
152 } else {
153 $title = get_the_title();
154 $post_url = get_permalink();
155 }
156 ?>
157 <<?php echo esc_attr($tag); ?> class="eel-post-title" style="text-align:<?php echo esc_attr($align); ?>;">
158 <?php if ( $link ) : ?>
159 <a href="<?php echo esc_url($post_url); ?>"><?php echo esc_html($title); ?></a>
160 <?php else : ?>
161 <?php echo esc_html($title); ?>
162 <?php endif; ?>
163 </<?php echo esc_attr($tag); ?>>
164 <?php
165 }
166 }
167