From: nael Date: Wed, 24 Apr 2019 16:33:25 +0000 (+0200) Subject: WIP #2686 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=7bbdb2fa25245bce718330a3b49bb8d046376cf0;p=c6-wordpress.git WIP #2686 @1 --- diff --git a/wp-content/mu-plugins/cube/src/Elementor/Setup.php b/wp-content/mu-plugins/cube/src/Elementor/Setup.php index 0bf74ed..a6298ad 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Setup.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Setup.php @@ -33,6 +33,7 @@ class Setup { $elementor->widgets_manager->register_widget_type( new Widgets\PageHeading() ); $elementor->widgets_manager->register_widget_type( new Widgets\HeroBlock() ); $elementor->widgets_manager->register_widget_type( new Widgets\TextBlock() ); + $elementor->widgets_manager->register_widget_type( new Widgets\Heading() ); } protected function _customise_sections() { diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/Heading.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/Heading.php new file mode 100644 index 0000000..70fcf19 --- /dev/null +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/Heading.php @@ -0,0 +1,147 @@ +start_controls_section( + 'section_content', + [ + 'label' => __('Content', 'cube'), + ] + ); + + $this->add_control( + 'title', + [ + 'label' => __('Title', 'elementor'), + 'type' => Controls_Manager::TEXTAREA, + 'placeholder' => __('Enter your title', 'elementor'), + 'default' => '', + ] + ); + + $this->add_control( + 'subtitle', + [ + 'label' => __('Subtitle', 'cube'), + 'type' => Controls_Manager::TEXT, + 'default' => '', + ] + ); + + $this->end_controls_section(); + + } + + /** + * Render the widget output on the frontend. + * Written in PHP and used to generate the final HTML. + * + * @since 1.0.0 + * @access protected + */ + protected function render() { + + $subtitle = $this->get_settings('subtitle'); + $title = $this->get_settings('title'); + + // Inline Editing settings + $this->add_inline_editing_attributes('subtitle', 'none'); + $this->add_inline_editing_attributes('title', 'none'); + + // CSS Classes for elements + $this->add_render_attribute('subtitle', 'class', ['heading-subtitle']); + $this->add_render_attribute('title', 'class', ['heading-title']); + + // Rendered content + echo '
'; + if (!empty($subtitle)) echo "

get_render_attribute_string('subtitle')}>$subtitle

"; + if (!empty($title)) echo "

get_render_attribute_string('title')}>$title

"; + + echo '
'; + } + + /** + * Render text editor widget output in the editor. + * + * Written as a Backbone JavaScript template and used to generate the live preview. + * + * @since 1.0.0 + * @access protected + */ + protected function _content_template() { + ?> + <# + view.addRenderAttribute( 'subtitle', 'class', ['heading-subtitle']); + view.addRenderAttribute( 'title', 'class', ['heading-title']); + + view.addInlineEditingAttributes( 'subtitle', 'none' ); + view.addInlineEditingAttributes( 'title', 'none' ); + + #> +
+ + <# if ('' !== settings.subtitle) { #> +

{{{ settings.subtitle }}}

+ <# } #> + + <# if ('' !== settings.title) { #> +

{{{ settings.title }}}

+ <# } #> +
+