From 94efd847da58cc58565329ebe3128e1359fbf48d Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Wed, 18 Aug 2021 21:21:54 +0200 Subject: [PATCH] Elementor shared/global template widget, compatibility updates for custom widgets, editor improvements and activation of language switcher. WIP #4615 @7.5 --- .../mu-plugins/cube/src/Elementor/Setup.php | 1 + .../src/Elementor/Widgets/BackgroundImage.php | 2 +- .../src/Elementor/Widgets/DynamicTable.php | 96 +++++++------ .../cube/src/Elementor/Widgets/FancyList.php | 25 ++-- .../cube/src/Elementor/Widgets/Form.php | 2 +- .../src/Elementor/Widgets/HeaderSlideshow.php | 2 +- .../src/Elementor/Widgets/JustifiedList.php | 65 +++++---- .../src/Elementor/Widgets/LinkCarousel.php | 71 ++++++---- .../cube/src/Elementor/Widgets/NewsBanner.php | 2 +- .../cube/src/Elementor/Widgets/PeopleGrid.php | 63 +++++---- .../cube/src/Elementor/Widgets/PhotoGrid.php | 46 +++--- .../cube/src/Elementor/Widgets/PictoGrid.php | 63 +++++---- .../src/Elementor/Widgets/ScientificNews.php | 2 +- .../cube/src/Elementor/Widgets/Template.php | 118 ++++++++++++++++ .../Elementor/Widgets/TestimonialCarousel.php | 55 +++++--- .../cube/src/Elementor/Widgets/TextBlock.php | 2 +- .../cube/src/Elementor/Widgets/Timeline.php | 133 ++++++++++-------- .../Elementor/Widgets/TimelineHorizontal.php | 61 ++++---- wp-content/themes/CCV/app/setup.php | 11 ++ .../assets/styles/{common => }/admin.styl | 21 ++- .../CCV/resources/assets/styles/app.styl | 1 - ...content-single-elementor_library.blade.php | 15 ++ .../resources/views/partials/header.blade.php | 3 +- .../views/widgets/link-carousel.blade.php | 2 +- .../views/widgets/timeline.blade.php | 3 +- wp-content/themes/CCV/webpack.mix.js | 3 + 26 files changed, 579 insertions(+), 289 deletions(-) create mode 100644 wp-content/mu-plugins/cube/src/Elementor/Widgets/Template.php rename wp-content/themes/CCV/resources/assets/styles/{common => }/admin.styl (73%) create mode 100644 wp-content/themes/CCV/resources/views/partials/content-single-elementor_library.blade.php diff --git a/wp-content/mu-plugins/cube/src/Elementor/Setup.php b/wp-content/mu-plugins/cube/src/Elementor/Setup.php index 48cca13..806e8f6 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Setup.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Setup.php @@ -39,6 +39,7 @@ class Setup { $elementor = Plugin::$instance; + $elementor->widgets_manager->register_widget_type( new Widgets\Template() ); $elementor->widgets_manager->register_widget_type( new Widgets\TextBlock() ); $elementor->widgets_manager->register_widget_type( new Widgets\BackgroundImage() ); $elementor->widgets_manager->register_widget_type( new Widgets\HeaderSlideshow() ); diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php index 73280f2..bc5d7e9 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php @@ -44,7 +44,7 @@ class BackgroundImage extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_image', diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/DynamicTable.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/DynamicTable.php index befdb74..50272b9 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/DynamicTable.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/DynamicTable.php @@ -4,6 +4,7 @@ namespace Cube\Elementor\Widgets; use Elementor\Widget_Base; use Elementor\Controls_Manager; +use Elementor\Repeater; use function Roots\view; @@ -48,7 +49,7 @@ class DynamicTable extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -67,51 +68,64 @@ class DynamicTable extends Widget_Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'cells', + [ + 'label' => __( 'Cellules du tableau (une valeur par ligne)', 'cube' ), + 'placeholder' => __("Valeur 1\nValeur 2\nValeur 3\n...", 'cube'), + 'type' => Controls_Manager::TEXTAREA, + 'default' => '', + 'label_block' => true, + ] + ); + + $repeater->add_control( + 'bg_color', + [ + 'label' => __( 'Couleur de fond', 'cube' ), + 'type' => Controls_Manager::SELECT, + 'options' => [ + '' => __( 'Défaut', 'cube' ), + 'bg-white' => __( 'Blanc', 'cube' ), + 'bg-light' => __( 'Gris clair', 'cube' ), + ], + ] + ); + + $repeater->add_control( + 'font_style', + [ + 'label' => __( 'Style de police', 'cube' ), + 'type' => Controls_Manager::SELECT, + 'options' => [ + '' => __( 'Défaut', 'cube' ), + 'font-bold' => __( 'Gras', 'cube' ), + ], + ] + ); + + $repeater->add_control( + 'text_align', + [ + 'label' => __( 'Alignement du texte', 'cube' ), + 'type' => Controls_Manager::SELECT, + 'options' => [ + '' => __( 'Défaut', 'cube' ), + 'text-left' => __( 'Gauche', 'cube' ), + 'text-center' => __( 'Centré', 'cube' ), + 'text-right' => __( 'Droit', 'cube' ), + ], + ] + ); + $this->add_control( 'rows', [ 'label' => __( 'Lignes du tableau', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'cells', - 'label' => __( 'Cellules du tableau (une valeur par ligne)', 'cube' ), - 'placeholder' => __("Valeur 1\nValeur 2\nValeur 3\n...", 'cube'), - 'type' => Controls_Manager::TEXTAREA, - 'default' => '', - 'label_block' => true, - ], - [ - 'name' => 'bg_color', - 'label' => __( 'Couleur de fond', 'cube' ), - 'type' => Controls_Manager::SELECT, - 'options' => [ - '' => __( 'Défaut', 'cube' ), - 'bg-white' => __( 'Blanc', 'cube' ), - 'bg-light' => __( 'Gris clair', 'cube' ), - ], - ], - [ - 'name' => 'font_style', - 'label' => __( 'Style de police', 'cube' ), - 'type' => Controls_Manager::SELECT, - 'options' => [ - '' => __( 'Défaut', 'cube' ), - 'font-bold' => __( 'Gras', 'cube' ), - ], - ], - [ - 'name' => 'text_align', - 'label' => __( 'Alignement du texte', 'cube' ), - 'type' => Controls_Manager::SELECT, - 'options' => [ - '' => __( 'Défaut', 'cube' ), - 'text-left' => __( 'Gauche', 'cube' ), - 'text-center' => __( 'Centré', 'cube' ), - 'text-right' => __( 'Droit', 'cube' ), - ], - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ cells }}}', ] ); diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/FancyList.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/FancyList.php index dbd64a8..dd12352 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/FancyList.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/FancyList.php @@ -5,6 +5,7 @@ namespace Cube\Elementor\Widgets; use Elementor\Widget_Base; use Elementor\Controls_Manager; use Elementor\Core\Schemes; +use Elementor\Repeater; use function Roots\view; @@ -48,7 +49,7 @@ class FancyList extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -67,20 +68,24 @@ class FancyList extends Widget_Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'content', + [ + 'default' => '', + 'label' => __( 'Contenus', 'cube' ), + 'type' => Controls_Manager::WYSIWYG, + 'label_block' => true, + ] + ); + $this->add_control( 'items', [ 'label' => __( 'Éléments', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'content', - 'default' => '', - 'label' => __( 'Contenus', 'cube' ), - 'type' => Controls_Manager::WYSIWYG, - 'label_block' => true, - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ content }}}', ] ); diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/Form.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/Form.php index 48e5d35..2d42d05 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/Form.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/Form.php @@ -44,7 +44,7 @@ class Form extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $form_base = new BaseForm(); $forms = $form_base->get_forms(); diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php index 8b9e750..d4fa7f5 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php @@ -54,7 +54,7 @@ class HeaderSlideshow extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/JustifiedList.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/JustifiedList.php index 57f1dff..5462e1e 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/JustifiedList.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/JustifiedList.php @@ -4,6 +4,7 @@ namespace Cube\Elementor\Widgets; use Elementor\Widget_Base; use Elementor\Controls_Manager; +use Elementor\Repeater; use function Roots\view; @@ -48,7 +49,7 @@ class JustifiedList extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -57,37 +58,47 @@ class JustifiedList extends Widget_Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'title', + [ + 'label' => __( 'Titre', 'cube' ), + 'type' => Controls_Manager::WYSIWYG, + 'default' => '', + 'label_block' => true, + ] + ); + + $repeater->add_control( + 'value', + [ + 'label' => __( 'Valeur', 'cube' ), + 'type' => Controls_Manager::WYSIWYG, + 'default' => '', + 'label_block' => true, + ] + ); + + $repeater->add_control( + 'bg_color', + [ + 'label' => __( 'Couleur de fond', 'cube' ), + 'type' => Controls_Manager::SELECT, + 'options' => [ + '' => __( 'Défaut', 'cube' ), + 'bg-white' => __( 'Blanc', 'cube' ), + 'bg-light' => __( 'Gris clair', 'cube' ), + ], + ] + ); + $this->add_control( 'items', [ 'label' => __( 'Éléments', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'title', - 'label' => __( 'Titre', 'cube' ), - 'type' => Controls_Manager::WYSIWYG, - 'default' => '', - 'label_block' => true, - ], - [ - 'name' => 'value', - 'label' => __( 'Valeur', 'cube' ), - 'type' => Controls_Manager::WYSIWYG, - 'default' => '', - 'label_block' => true, - ], - [ - 'name' => 'bg_color', - 'label' => __( 'Couleur de fond', 'cube' ), - 'type' => Controls_Manager::SELECT, - 'options' => [ - '' => __( 'Défaut', 'cube' ), - 'bg-white' => __( 'Blanc', 'cube' ), - 'bg-light' => __( 'Gris clair', 'cube' ), - ], - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ title }}}', ] ); diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/LinkCarousel.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/LinkCarousel.php index 4a4d139..60a808e 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/LinkCarousel.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/LinkCarousel.php @@ -3,6 +3,7 @@ namespace Cube\Elementor\Widgets; use Elementor\Controls_Manager; +use Elementor\Repeater; use Elementor\Utils; use function Roots\view; @@ -55,7 +56,7 @@ class LinkCarousel extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -64,35 +65,45 @@ class LinkCarousel extends _Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'title', + [ + 'label' => __( 'Title', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'default' => '', + ] + ); + + $repeater->add_control( + 'link', + [ + 'label' => __( 'Link URL', 'cube' ), + 'type' => Controls_Manager::URL, + 'label_block' => true, + ] + ); + + $repeater->add_control( + 'image', + [ + 'label' => __('Image', 'cube'), + 'label_block' => true, + 'type' => Controls_Manager::MEDIA, + 'default' => [ + 'url' => Utils::get_placeholder_image_src(), + ], + ] + ); + $this->add_control( 'links', [ 'label' => __( 'Links', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'title', - 'label' => __( 'Title', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'default' => '', - ], - [ - 'name' => 'url', - 'label' => __( 'Link URL', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - ], - [ - 'name' => 'image', - 'label' => __('Image', 'cube'), - 'label_block' => true, - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => Utils::get_placeholder_image_src(), - ], - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ title }}}', ] ); @@ -109,6 +120,16 @@ class LinkCarousel extends _Base { */ protected function render() { $links = $this->get_settings('links'); + + // Previously, the links repeater had a field named 'url' that was a plain text field. + // Elementor now offers a better field type (URL) but it's not compatible with the plain text field structure. + // To avoid losing data, the field was renamed to 'link' and we will merge the data here for outdated elements. + foreach ($links as $index => $link) { + if (empty($link['link']['url']) && isset($link['url'])) { + $links[$index]['link']['url'] = $link['url']; + } + } + echo view('widgets/link-carousel', compact('links')); } } diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/NewsBanner.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/NewsBanner.php index 388f311..1d7ac3b 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/NewsBanner.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/NewsBanner.php @@ -42,7 +42,7 @@ class NewsBanner extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/PeopleGrid.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/PeopleGrid.php index 74293c7..84a939c 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/PeopleGrid.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/PeopleGrid.php @@ -4,6 +4,7 @@ namespace Cube\Elementor\Widgets; use Elementor\Controls_Manager; use Elementor\Utils; +use Elementor\Repeater; use function Roots\view; @@ -43,7 +44,7 @@ class PeopleGrid extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -52,36 +53,46 @@ class PeopleGrid extends _Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'photo', + [ + 'label' => __('Photo', 'cube'), + 'label_block' => true, + 'type' => Controls_Manager::MEDIA, + 'default' => [ + 'url' => Utils::get_placeholder_image_src(), + ], + ] + ); + + $repeater->add_control( + 'name', + [ + 'label' => __( 'Nom', 'cube' ), + 'type' => Controls_Manager::TEXTAREA, + 'label_block' => true, + 'default' => '', + ] + ); + + $repeater->add_control( + 'details', + [ + 'label' => __( 'Détails', 'cube' ), + 'type' => Controls_Manager::TEXTAREA, + 'label_block' => true, + 'default' => '', + ] + ); + $this->add_control( 'people', [ 'label' => __( 'People', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'photo', - 'label' => __('Photo', 'cube'), - 'label_block' => true, - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => Utils::get_placeholder_image_src(), - ], - ], - [ - 'name' => 'name', - 'label' => __( 'Nom', 'cube' ), - 'type' => Controls_Manager::TEXTAREA, - 'label_block' => true, - 'default' => '', - ], - [ - 'name' => 'details', - 'label' => __( 'Détails', 'cube' ), - 'type' => Controls_Manager::TEXTAREA, - 'label_block' => true, - 'default' => '', - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ name }}}', ] ); diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/PhotoGrid.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/PhotoGrid.php index cf7ec2b..b2d682a 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/PhotoGrid.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/PhotoGrid.php @@ -4,6 +4,7 @@ namespace Cube\Elementor\Widgets; use Elementor\Controls_Manager; use Elementor\Utils; +use Elementor\Repeater; use function Roots\view; @@ -43,7 +44,7 @@ class PhotoGrid extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -52,29 +53,36 @@ class PhotoGrid extends _Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'image', + [ + 'label' => __('Photo', 'cube'), + 'label_block' => true, + 'type' => Controls_Manager::MEDIA, + 'default' => [ + 'url' => Utils::get_placeholder_image_src(), + ], + ] + ); + + $repeater->add_control( + 'caption', + [ + 'label' => __( 'Caption', 'cube' ), + 'type' => Controls_Manager::TEXTAREA, + 'label_block' => true, + 'default' => '', + ] + ); + $this->add_control( 'items', [ 'label' => __( 'Photos', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'image', - 'label' => __('Photo', 'cube'), - 'label_block' => true, - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => Utils::get_placeholder_image_src(), - ], - ], - [ - 'name' => 'caption', - 'label' => __( 'Caption', 'cube' ), - 'type' => Controls_Manager::TEXTAREA, - 'label_block' => true, - 'default' => '', - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ caption }}}', ] ); diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/PictoGrid.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/PictoGrid.php index 715690e..6aa4905 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/PictoGrid.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/PictoGrid.php @@ -4,6 +4,7 @@ namespace Cube\Elementor\Widgets; use Elementor\Controls_Manager; use Elementor\Utils; +use Elementor\Repeater; use function Roots\view; @@ -43,7 +44,7 @@ class PictoGrid extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -52,36 +53,46 @@ class PictoGrid extends _Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'image', + [ + 'label' => __('Pictogramme', 'cube'), + 'label_block' => true, + 'type' => Controls_Manager::MEDIA, + 'default' => [ + 'url' => Utils::get_placeholder_image_src(), + ], + ] + ); + + $repeater->add_control( + 'title', + [ + 'label' => __( 'Titre', 'cube' ), + 'type' => Controls_Manager::TEXTAREA, + 'label_block' => true, + 'default' => '', + ] + ); + + $repeater->add_control( + 'description', + [ + 'label' => __( 'Description', 'cube' ), + 'type' => Controls_Manager::TEXTAREA, + 'label_block' => true, + 'default' => '', + ] + ); + $this->add_control( 'items', [ 'label' => __( 'Pictogrammes', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'image', - 'label' => __('Pictogramme', 'cube'), - 'label_block' => true, - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => Utils::get_placeholder_image_src(), - ], - ], - [ - 'name' => 'title', - 'label' => __( 'Titre', 'cube' ), - 'type' => Controls_Manager::TEXTAREA, - 'label_block' => true, - 'default' => '', - ], - [ - 'name' => 'description', - 'label' => __( 'Description', 'cube' ), - 'type' => Controls_Manager::TEXTAREA, - 'label_block' => true, - 'default' => '', - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ description }}}', ] ); diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/ScientificNews.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/ScientificNews.php index 0184156..1c9b1eb 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/ScientificNews.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/ScientificNews.php @@ -44,7 +44,7 @@ class ScientificNews extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/Template.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/Template.php new file mode 100644 index 0000000..da8362a --- /dev/null +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/Template.php @@ -0,0 +1,118 @@ +get_items(['elementor_library_category' => 'global']); + $templates = []; + + foreach($template_collection as $template) { + $templates[$template['template_id']] = "[{$template['type']}] {$template['title']}"; + } + + $this->start_controls_section( + 'section_content', + [ + 'label' => __( 'Embed a Template', 'cube' ), + ] + ); + + $this->add_control( + 'description', + [ + 'type' => Controls_Manager::RAW_HTML, + 'raw' => 'This widget allows shared content blocks to be embedded in multiple places via templates. This enables all embedded blocks to be updated centrally by editing the template. It is possible to nest templates. To appear in the list, the template must be in the "Global" category.
Manage templates >>.', + 'content_classes' => 'elementor-descriptor', + ] + ); + + $this->add_control( + 'template_id', + [ + 'type' => Controls_Manager::SELECT, + 'label' => __( 'Template', 'cube' ), + 'label_block' => true, + 'default' => '', + 'options' => ['' => __('(Sélectionner)', 'cube')] + $templates, + ] + ); + + + $this->end_controls_section(); + + $this->common_controls(); + } + /** + * 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() { + $template_id = $this->get_settings( 'template_id' ); + + if ( 'publish' !== get_post_status( $template_id ) ) { + return; + } + + ?> +
+ frontend->get_builder_content_for_display( $template_id ); + ?> +
+ start_controls_section( 'section_content', @@ -63,32 +64,42 @@ class TestimonialCarousel extends _Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'name', + [ + 'label' => __( 'Name', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'default' => '', + ] + ); + + $repeater->add_control( + 'testimonial', + [ + 'label' => __( 'Testimonial', 'cube' ), + 'type' => Controls_Manager::TEXTAREA, + 'label_block' => true, + ] + ); + + $repeater->add_control( + 'notes', + [ + 'label' => __( 'Notes', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + ] + ); + $this->add_control( 'testimonials', [ 'label' => __( 'Testimonials', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'name', - 'label' => __( 'Name', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'default' => '', - ], - [ - 'name' => 'testimonial', - 'label' => __( 'Testimonial', 'cube' ), - 'type' => Controls_Manager::TEXTAREA, - 'label_block' => true, - ], - [ - 'name' => 'notes', - 'label' => __( 'Notes', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ name }}}', ] ); diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/TextBlock.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/TextBlock.php index 03760ac..f01960c 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/TextBlock.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/TextBlock.php @@ -39,7 +39,7 @@ class TextBlock extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/Timeline.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/Timeline.php index df3b870..3b2c7a6 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/Timeline.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/Timeline.php @@ -4,6 +4,7 @@ namespace Cube\Elementor\Widgets; use Elementor\Controls_Manager; use Elementor\Utils; +use Elementor\Repeater; use function Roots\view; @@ -44,7 +45,7 @@ class Timeline extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -65,65 +66,87 @@ class Timeline extends _Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'highlight', + [ + 'label' => __('Highlight', 'cube'), + 'type' => Controls_Manager::SWITCHER, + 'return_value' => 'yes', + 'default' => 'yes', + ] + ); + + $repeater->add_control( + 'image', + [ + 'label' => __('Image', 'cube'), + 'label_block' => true, + 'type' => Controls_Manager::MEDIA, + 'default' => [ + 'url' => Utils::get_placeholder_image_src(), + ], + ] + ); + + $repeater->add_control( + 'year', + [ + 'label' => __('Year', 'cube'), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'default' => '', + ] + ); + + $repeater->add_control( + 'title', + [ + 'label' => __('Title', 'cube'), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'default' => '', + ] + ); + + $repeater->add_control( + 'details', + [ + 'label' => __('Description', 'cube'), + 'type' => Controls_Manager::WYSIWYG, + 'default' => '', + ] + ); + + $repeater->add_control( + 'cta_text', + [ + 'label' => __('Call to Action text', 'cube'), + 'type' => Controls_Manager::TEXT, + 'default' => '' + ] + ); + + $repeater->add_control( + 'cta_link', + [ + 'label' => __('Call to Action link', 'cube'), + 'type' => Controls_Manager::URL, + 'default' => [ + 'url' => '', + 'is_external' => false, + ], + 'show_external' => true + ] + ); + $this->add_control( 'items', [ 'label' => __('Items', 'cube'), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'highlight', - 'label' => __('Highlight', 'cube'), - 'type' => Controls_Manager::SWITCHER, - 'return_value' => 'yes', - 'default' => 'yes', - ], - [ - 'name' => 'image', - 'label' => __('Image', 'cube'), - 'label_block' => true, - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => Utils::get_placeholder_image_src(), - ], - ], - [ - 'name' => 'year', - 'label' => __('Year', 'cube'), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'default' => '', - ], - [ - 'name' => 'title', - 'label' => __('Title', 'cube'), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'default' => '', - ], - [ - 'name' => 'details', - 'label' => __('Description', 'cube'), - 'type' => Controls_Manager::WYSIWYG, - 'default' => '', - ], - [ - 'name' => 'cta_text', - 'label' => __('Call to Action text', 'cube'), - 'type' => Controls_Manager::TEXT, - 'default' => '' - ], - [ - 'name' => 'cta_link', - 'label' => __('Call to Action link', 'cube'), - 'type' => Controls_Manager::URL, - 'default' => [ - 'url' => '', - 'is_external' => false, - ], - 'show_external' => true - ] - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ year }}} {{{ title }}}', ] ); diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/TimelineHorizontal.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/TimelineHorizontal.php index 3925fc9..f435558 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/TimelineHorizontal.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/TimelineHorizontal.php @@ -4,6 +4,7 @@ namespace Cube\Elementor\Widgets; use Elementor\Controls_Manager; use Elementor\Utils; +use Elementor\Repeater; use function Roots\asset; use function Roots\view; @@ -56,7 +57,7 @@ class TimelineHorizontal extends _Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -65,35 +66,45 @@ class TimelineHorizontal extends _Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'image', + [ + 'label' => __('Image', 'cube'), + 'type' => Controls_Manager::MEDIA, + 'default' => [ + 'url' => Utils::get_placeholder_image_src(), + ], + ] + ); + + $repeater->add_control( + 'title', + [ + 'label' => __('Title', 'cube'), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'default' => '', + ] + ); + + $repeater->add_control( + 'content', + [ + 'label' => __('Contenu', 'cube'), + 'type' => Controls_Manager::WYSIWYG, + 'label_block' => true, + 'default' => '' + ] + ); + $this->add_control( 'items', [ 'label' => __('Items', 'cube'), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'image', - 'label' => __('Image', 'cube'), - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => Utils::get_placeholder_image_src(), - ], - ], - [ - 'name' => 'title', - 'label' => __('Title', 'cube'), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'default' => '', - ], - [ - 'name' => 'content', - 'label' => __('Contenu', 'cube'), - 'type' => Controls_Manager::WYSIWYG, - 'label_block' => true, - 'default' => '' - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ title }}}', ] ); diff --git a/wp-content/themes/CCV/app/setup.php b/wp-content/themes/CCV/app/setup.php index c5e575d..1c5b8ec 100755 --- a/wp-content/themes/CCV/app/setup.php +++ b/wp-content/themes/CCV/app/setup.php @@ -76,6 +76,17 @@ add_action('wp_enqueue_scripts', function () { } }, 100); +/** + * Add admin specific styles + */ +function add_admin_styles() { + if (is_admin()) { + wp_enqueue_style('cube/admin.css', asset('styles/admin.css')->uri(), false, null); + } +} +add_action('admin_enqueue_scripts', __NAMESPACE__ . '\add_admin_styles'); +add_action('elementor/common/after_register_scripts', __NAMESPACE__ . '\add_admin_styles'); + /** * Theme setup */ diff --git a/wp-content/themes/CCV/resources/assets/styles/common/admin.styl b/wp-content/themes/CCV/resources/assets/styles/admin.styl similarity index 73% rename from wp-content/themes/CCV/resources/assets/styles/common/admin.styl rename to wp-content/themes/CCV/resources/assets/styles/admin.styl index eb8c0cf..6a92d6e 100644 --- a/wp-content/themes/CCV/resources/assets/styles/common/admin.styl +++ b/wp-content/themes/CCV/resources/assets/styles/admin.styl @@ -1,3 +1,18 @@ +// Admin specific styles + +/*! purgecss start ignore */ + +// Position Cubedesigners custom widgets above all others in the Elementor sidebar +#elementor-panel-categories + display: flex + flex-direction: column + +#elementor-panel-category-cube + order: -1 + +#elementor-panel-category-pro-elements + order: 99 // Put these at the bottom (or could hide them completely?) + // Tiny MCE editor styles in Elementor editor // Most styles for editor set in text-block.styl body... #tinymce @@ -17,8 +32,8 @@ $breakpoint-admin-bar-absolute = 600px // When admin bar goes from being 'fixed' $admin-bar-height = 32px $admin-bar-height-mobile = 46px -#wpadminbar - overflow: hidden +//#wpadminbar +// overflow: hidden // Can't do this because it will break dropdown menus in the admin bar #wp-toolbar display: flex @@ -58,3 +73,5 @@ body.admin-bar .mobile-menu-trigger top: 30px + +/*! purgecss end ignore */ diff --git a/wp-content/themes/CCV/resources/assets/styles/app.styl b/wp-content/themes/CCV/resources/assets/styles/app.styl index 09eef77..2a447e3 100644 --- a/wp-content/themes/CCV/resources/assets/styles/app.styl +++ b/wp-content/themes/CCV/resources/assets/styles/app.styl @@ -9,7 +9,6 @@ @import 'common/mixins' @import 'common/debug' @import 'common/global' -@import 'common/admin' @import 'common/layout' @import 'common/animations' diff --git a/wp-content/themes/CCV/resources/views/partials/content-single-elementor_library.blade.php b/wp-content/themes/CCV/resources/views/partials/content-single-elementor_library.blade.php new file mode 100644 index 0000000..187b301 --- /dev/null +++ b/wp-content/themes/CCV/resources/views/partials/content-single-elementor_library.blade.php @@ -0,0 +1,15 @@ +
+ +
+

+ Elementor Template + {!! $title !!} + ID: {{ get_post_field('post_name') }} +

+
+ +
+ @php(the_content()) +
+ +
diff --git a/wp-content/themes/CCV/resources/views/partials/header.blade.php b/wp-content/themes/CCV/resources/views/partials/header.blade.php index 9181493..d4578b9 100644 --- a/wp-content/themes/CCV/resources/views/partials/header.blade.php +++ b/wp-content/themes/CCV/resources/views/partials/header.blade.php @@ -15,7 +15,7 @@