start_controls_section( 'section_title', [ 'label' => esc_html__( 'Content', 'uicore-elements' ), ] ); $this->add_control( 'header_size', [ 'label' => esc_html__( 'HTML Tag', 'uicore-elements' ), 'type' => Controls_Manager::SELECT, 'options' => [ 'h1' => 'H1', 'h2' => 'H2', 'h3' => 'H3', 'h4' => 'H4', 'h5' => 'H5', 'h6' => 'H6', 'div' => 'div', 'span' => 'span', 'p' => 'p', ], 'default' => 'p', ] ); $this->add_responsive_control( 'align', [ 'label' => esc_html__( 'Alignment', 'uicore-elements' ), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => esc_html__( 'Left', 'uicore-elements' ), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => esc_html__( 'Center', 'uicore-elements' ), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => esc_html__( 'Right', 'uicore-elements' ), 'icon' => 'eicon-text-align-right', ], 'justify' => [ 'title' => esc_html__( 'Justified', 'uicore-elements' ), 'icon' => 'eicon-text-align-justify', ], ], 'default' => '', 'selectors' => [ '{{WRAPPER}}' => 'text-align: {{VALUE}};', ], ] ); $this->add_control( 'fallabck_text', [ 'label' => __( 'Fallback text', 'uicore-elements' ), 'description' => esc_html__('If is empty and page does not have any description nothing will be displayed.', 'uicore-elements'), 'type' => Controls_Manager::TEXT, ] ); $this->end_controls_section(); $this->start_controls_section( 'section_title_style', [ 'label' => esc_html__( 'Content', 'uicore-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'title_color', [ 'label' => esc_html__( 'Text Color', 'uicore-elements' ), 'type' => Controls_Manager::COLOR, 'global' => [ 'default' => Global_Colors::COLOR_PRIMARY, ], 'selectors' => [ '{{WRAPPER}} .ui-e-page-description' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'typography', 'global' => [ 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, ], 'selector' => '{{WRAPPER}} .ui-e-page-description', ] ); $this->add_group_control( Group_Control_Text_Stroke::get_type(), [ 'name' => 'text_stroke', 'selector' => '{{WRAPPER}} .ui-e-page-description', ] ); $this->add_group_control( Group_Control_Text_Shadow::get_type(), [ 'name' => 'text_shadow', 'selector' => '{{WRAPPER}} .ui-e-page-description', ] ); $this->add_control( 'blend_mode', [ 'label' => esc_html__( 'Blend Mode', 'uicore-elements' ), 'type' => Controls_Manager::SELECT, 'options' => [ '' => esc_html__( 'Normal', 'uicore-elements' ), 'multiply' => 'Multiply', 'screen' => 'Screen', 'overlay' => 'Overlay', 'darken' => 'Darken', 'lighten' => 'Lighten', 'color-dodge' => 'Color Dodge', 'saturation' => 'Saturation', 'color' => 'Color', 'difference' => 'Difference', 'exclusion' => 'Exclusion', 'hue' => 'Hue', 'luminosity' => 'Luminosity', ], 'selectors' => [ '{{WRAPPER}} .ui-e-page-description' => 'mix-blend-mode: {{VALUE}}', ], 'separator' => 'none', ] ); $this->end_controls_section(); } /** * Render heading widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.0.0 * @access protected */ protected function render() { $settings = $this->get_settings_for_display(); $this->add_render_attribute( 'title', 'class', 'ui-e-page-description' ); if( !\Elementor\Plugin::$instance->editor->is_edit_mode() ) { $post_id = Helper::get_current_meta_id(); $title = get_post_meta($post_id, 'page_description', true); }else{ if($settings['fallabck_text']){ $title = $settings['fallabck_text']; }else{ $title = 'This is the page description. You can change this text by editing the page using the default WordPress editor.'; } } if(!$title && $settings['fallabck_text']){ $title = $settings['fallabck_text']; } $title_html = sprintf( '<%1$s %2$s>%3$s', Utils::validate_html_tag($settings['header_size']), $this->get_render_attribute_string( 'title' ), \esc_html($title) ); // PHPCS - the variable $title_html holds safe data. echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Render heading widget output in the editor. * * Written as a Backbone JavaScript template and used to generate the live preview. * * @since 2.9.0 * @access protected */ protected function content_template() { } } \Elementor\Plugin::instance()->widgets_manager->register(new PageDescription());