if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
* Elementor widget that insert a custom HTML code into the page.
class Widget_Read_More extends Widget_Base {
* Retrieve Read More widget name.
* @return string Widget name.
public function get_name() {
* Retrieve Read More widget title.
* @return string Widget title.
public function get_title() {
return esc_html__( 'Read More', 'elementor' );
* Retrieve Read More widget icon.
* @return string Widget icon.
public function get_icon() {
return 'eicon-post-excerpt';
* Retrieve the list of keywords the widget belongs to.
* @return array Widget keywords.
public function get_keywords() {
return [ 'read', 'more', 'tag', 'excerpt' ];
protected function is_dynamic_content(): bool {
public function has_widget_inner_wrapper(): bool {
return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
* Register HTML widget controls.
* Adds different input fields to allow the user to change and customize the widget settings.
protected function register_controls() {
$this->start_controls_section(
'label' => esc_html__( 'Read More', 'elementor' ),
$default_link_text = esc_html__( 'Continue reading', 'elementor' );
* Read More widgets link text.
* Filters the link text in the "Read More" widget.
* This hook can be used to set different default text in the widget.
* @param string $default_link_text The link text in the "Read More" widget. Default is "Continue reading".
$default_link_text = apply_filters( 'elementor/widgets/read_more/default_link_text', $default_link_text );
'type' => Controls_Manager::ALERT,
'alert_type' => 'warning',
/* translators: %s: The `the_content` function. */
esc_html__( 'Note: This widget only affects themes that use `%s` in archive pages.', 'elementor' ),
'label' => esc_html__( 'Read More Text', 'elementor' ),
'placeholder' => $default_link_text,
'default' => $default_link_text,
$this->end_controls_section();
* Render Read More widget output on the frontend.
* Written in PHP and used to generate the final HTML.
protected function render() {
printf( '<!--more %s-->', wp_kses_post( $this->get_settings_for_display( 'link_text' ) ) );
* Render Read More widget output in the editor.
* Written as a Backbone JavaScript template and used to generate the live preview.
protected function content_template() {
<!--more {{ settings.link_text }}-->