From 731e4aed50da7e278376c6643ae219cf52d8bdf2 Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Tue, 15 May 2018 16:01:57 +0000 Subject: [PATCH] WIP #1912 @3 --- .../physioassist/src/Elementor/Setup.php | 21 ++++++++ .../src/Elementor/Widgets/ProfileGrid.php | 50 ++++++++++++++++++- .../assets/styles/common/utilities.styl | 3 ++ .../assets/styles/widgets/toggle.styl | 20 ++++++++ 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 wp-content/themes/physioassist/resources/assets/styles/widgets/toggle.styl diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Setup.php b/wp-content/mu-plugins/physioassist/src/Elementor/Setup.php index 05b3f92c..ffd075f3 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Setup.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Setup.php @@ -23,6 +23,7 @@ class Setup { public function register_customisations() { + //--- Heading Widget // Extend Elementor's heading widget to add a CSS class based on the alignment setting so we can also control the position of the underline add_action( 'elementor/element/heading/section_title/before_section_end', function( $element, $args ) { $elementor = Plugin::instance(); @@ -41,6 +42,26 @@ class Setup { // Todo: consider add a control to the existing heading widget that allows the underline to be disabled (via prefix_class?) + + //--- Toggle Widget + // Override default icons + add_action( 'elementor/element/toggle/section_toggle/before_section_end', function( $element, $args ) { + $elementor = Plugin::instance(); + $icon_control = $elementor->controls_manager->get_control_from_stack( $element->get_name(), 'icon' ); + $icon_active_control = $elementor->controls_manager->get_control_from_stack( $element->get_name(), 'icon_active' ); + + if (is_wp_error($icon_control) || is_wp_error($icon_active_control)) { + return; + } + + $icon_control['default'] = 'fa fa-chevron-right'; + $element->update_control( 'icon', $icon_control ); + + $icon_active_control['default'] = 'fa fa-chevron-down'; + $element->update_control( 'icon_active', $icon_active_control ); + }, 10, 2); + + } public function register_widgets() { diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ProfileGrid.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ProfileGrid.php index 189339f1..9da66a65 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ProfileGrid.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ProfileGrid.php @@ -9,7 +9,7 @@ use Elementor\Utils; class ProfileGrid extends Widget_Base { - protected $_has_template_content = false; // Tell Elementor that content is all rendered dynamically + protected $_has_template_content = true; // Widget name / ID public function get_name() { @@ -129,4 +129,52 @@ class ProfileGrid extends Widget_Base { echo '
'. $html .'
'; } + /** + * Render 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() { + ?> +
+ <# + if ( settings.items ) { + + _.each( settings.items, function( item, index ) { + #> +
+ + + +
+ +

{{{ item.title }}}

+ + <# if ('' !== item.subtitle) { #> +

{{{ item.subtitle }}}

+ <# } #> + +
+ {{{ item.body }}} +
+ + <# if ('' !== item.cta_text && '' !== item.cta_link.url) { #> + + toHtml() ?> + {{ item.cta_text }} + + <# } #> +
+ +
+ <# + }); + } #> +
+