PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.3
Elementor Website Builder – more than just a page builder v3.26.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / includes / widgets / read-more.php

read-more.php in Elementor Website Builder – more than just a page builder 3.26.3, at includes/widgets/read-more.php

162 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor HTML widget.
10 *
11 * Elementor widget that insert a custom HTML code into the page.
12 *
13 */
14 class Widget_Read_More extends Widget_Base {
15
16 /**
17 * Get widget name.
18 *
19 * Retrieve Read More widget name.
20 *
21 * @since 2.4.0
22 * @access public
23 *
24 * @return string Widget name.
25 */
26 public function get_name() {
27 return 'read-more';
28 }
29
30 /**
31 * Get widget title.
32 *
33 * Retrieve Read More widget title.
34 *
35 * @since 2.4.0
36 * @access public
37 *
38 * @return string Widget title.
39 */
40 public function get_title() {
41 return esc_html__( 'Read More', 'elementor' );
42 }
43
44 /**
45 * Get widget icon.
46 *
47 * Retrieve Read More widget icon.
48 *
49 * @since 2.4.0
50 * @access public
51 *
52 * @return string Widget icon.
53 */
54 public function get_icon() {
55 return 'eicon-post-excerpt';
56 }
57
58 /**
59 * Get widget keywords.
60 *
61 * Retrieve the list of keywords the widget belongs to.
62 *
63 * @since 2.4.0
64 * @access public
65 *
66 * @return array Widget keywords.
67 */
68 public function get_keywords() {
69 return [ 'read', 'more', 'tag', 'excerpt' ];
70 }
71
72 protected function is_dynamic_content(): bool {
73 return false;
74 }
75
76 public function has_widget_inner_wrapper(): bool {
77 return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
78 }
79
80 /**
81 * Register HTML widget controls.
82 *
83 * Adds different input fields to allow the user to change and customize the widget settings.
84 *
85 * @since 3.1.0
86 * @access protected
87 */
88 protected function register_controls() {
89 $this->start_controls_section(
90 'section_title',
91 [
92 'label' => esc_html__( 'Read More', 'elementor' ),
93 ]
94 );
95
96 $default_link_text = esc_html__( 'Continue reading', 'elementor' );
97
98 /**
99 * Read More widgets link text.
100 *
101 * Filters the link text in the "Read More" widget.
102 *
103 * This hook can be used to set different default text in the widget.
104 *
105 * @param string $default_link_text The link text in the "Read More" widget. Default is "Continue reading".
106 */
107 $default_link_text = apply_filters( 'elementor/widgets/read_more/default_link_text', $default_link_text );
108
109 $this->add_control(
110 'theme_support',
111 [
112 'type' => Controls_Manager::ALERT,
113 'alert_type' => 'warning',
114 'content' => sprintf(
115 /* translators: %s: The `the_content` function. */
116 esc_html__( 'Note: This widget only affects themes that use `%s` in archive pages.', 'elementor' ),
117 'the_content'
118 ),
119 ]
120 );
121
122 $this->add_control(
123 'link_text',
124 [
125 'label' => esc_html__( 'Read More Text', 'elementor' ),
126 'placeholder' => $default_link_text,
127 'default' => $default_link_text,
128 'dynamic' => [
129 'active' => true,
130 ],
131 ]
132 );
133
134 $this->end_controls_section();
135 }
136
137 /**
138 * Render Read More widget output on the frontend.
139 *
140 * Written in PHP and used to generate the final HTML.
141 *
142 * @access protected
143 */
144 protected function render() {
145 printf( '<!--more %s-->', wp_kses_post( $this->get_settings_for_display( 'link_text' ) ) );
146 }
147
148 /**
149 * Render Read More widget output in the editor.
150 *
151 * Written as a Backbone JavaScript template and used to generate the live preview.
152 *
153 * @since 2.9.0
154 * @access protected
155 */
156 protected function content_template() {
157 ?>
158 <!--more {{ settings.link_text }}-->
159 <?php
160 }
161 }
162