]> _ Git - ccv-wordpress.git/commitdiff
Elementor shared/global template widget, compatibility updates for custom widgets...
authorStephen Cameron <stephen@cubedesigners.com>
Wed, 18 Aug 2021 19:21:54 +0000 (21:21 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Wed, 18 Aug 2021 19:21:54 +0000 (21:21 +0200)
27 files changed:
wp-content/mu-plugins/cube/src/Elementor/Setup.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/DynamicTable.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/FancyList.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/Form.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/JustifiedList.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/LinkCarousel.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/NewsBanner.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/PeopleGrid.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/PhotoGrid.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/PictoGrid.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/ScientificNews.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/Template.php [new file with mode: 0644]
wp-content/mu-plugins/cube/src/Elementor/Widgets/TestimonialCarousel.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/TextBlock.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/Timeline.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/TimelineHorizontal.php
wp-content/themes/CCV/app/setup.php
wp-content/themes/CCV/resources/assets/styles/admin.styl [new file with mode: 0644]
wp-content/themes/CCV/resources/assets/styles/app.styl
wp-content/themes/CCV/resources/assets/styles/common/admin.styl [deleted file]
wp-content/themes/CCV/resources/views/partials/content-single-elementor_library.blade.php [new file with mode: 0644]
wp-content/themes/CCV/resources/views/partials/header.blade.php
wp-content/themes/CCV/resources/views/widgets/link-carousel.blade.php
wp-content/themes/CCV/resources/views/widgets/timeline.blade.php
wp-content/themes/CCV/webpack.mix.js

index 48cca1393eae1e4e3f68e3fdf7c31095680eb724..806e8f693a1f5124a5e8fae1c88b48a2ce3e332c 100644 (file)
@@ -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() );
index 73280f2325822c5798159f9f3e75ebf4b3aad943..bc5d7e965dfda3f1dc531e5fa63825fa45a48de4 100644 (file)
@@ -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',
index befdb74a95fef98be73a316d01aa2e64f5f7f732..50272b9f66a8a876f5b31cd47457afb4f92a9ed7 100644 (file)
@@ -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 }}}',
             ]
         );
index dbd64a814d8f23c07a2ac1362512ca795108309e..dd123522a1773dfbb893a61809baa01b335194aa 100644 (file)
@@ -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 }}}',
             ]
         );
index 48e5d35dc5dd080e28095aaa614453500de06257..2d42d05dc93b42294d4dbfd12ba03ff3281d0846 100644 (file)
@@ -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();
index 8b9e7508691b0f775ec1e25238706d3ae3599a1b..d4fa7f59ada480fc5c94a2ba97fc5e589d3a74ec 100644 (file)
@@ -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',
index 57f1dff98408389b7f049e88cc585affc4c36677..5462e1ea24a0a5068cec4e5c6dfe77ae02cc68c4 100644 (file)
@@ -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 }}}',
             ]
         );
index 4a4d139b94b9c0a49df153c29ebbc49c0470afa1..60a808e26d448e320ef0c3a107a128b9ec15b1b1 100644 (file)
@@ -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'));
     }
 }
index 388f311ebd8528db1a506a9ead5a8d3c322043ec..1d7ac3ba64c2bf3cc719fba1a098295987311455 100644 (file)
@@ -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',
index 74293c7928216684ffa6df0524df2517eef64a16..84a939c7b29f29d8d74b783cbb517e584b2eec12 100644 (file)
@@ -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 }}}',
             ]
         );
index cf7ec2b91faf9193ca893dc0975e6f7c8f3e7624..b2d682ad98d0fb7e22b7ea1b7a793bd7acae9982 100644 (file)
@@ -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 }}}',
             ]
         );
index 715690e5cd5a10c93f1375e0172be97893267ed7..6aa4905cc751e676b0678a855ef3ebddf2f48500 100644 (file)
@@ -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 }}}',
             ]
         );
index 0184156147d828df60fabb2393196489c463af5f..1c9b1eb1e7191c9ad276b20ce3cce808d430f8ea 100644 (file)
@@ -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 (file)
index 0000000..da8362a
--- /dev/null
@@ -0,0 +1,118 @@
+<?php
+
+namespace Cube\Elementor\Widgets;
+
+use Elementor\Plugin;
+use Elementor\Controls_Manager;
+use Elementor\TemplateLibrary\Source_Local;
+
+class Template extends _Base {
+
+    // Widget name / ID
+    public function get_name() {
+        return 'cube-template';
+    }
+
+    // Elementor widget title
+    public function get_title() {
+        return __( 'Shared Template', 'cube' );
+    }
+
+    // Elementor interface icon
+    public function get_icon() {
+        return 'eicon-document-file';
+    }
+
+    public function get_keywords() {
+        return [ 'elementor', 'template', 'library', 'block', 'page' ];
+    }
+
+    public function is_reload_preview_required() {
+        return false;
+    }
+
+    /**
+     * List of scripts the widget depends on.
+     * Used to set scripts dependencies required to run the widget.
+     *
+     * @since 1.0.0
+     * @access public
+     * @return array Widget scripts dependencies.
+     */
+    public function get_script_depends() {
+        return [];
+    }
+    /**
+     * Register the widget controls.
+     * Adds different input fields to allow the user to change and customize the widget settings.
+     *
+     * @since 1.0.0
+     * @access protected
+     */
+    protected function register_controls() {
+
+        $template_library = new Source_Local();
+        $template_collection = $template_library->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.<br><a href="/wp-admin/edit.php?post_type=elementor_library&tabs_group=library" target="_blank">Manage templates &gt;&gt;</a>.',
+                    '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;
+        }
+
+        ?>
+        <div class="cube-template elementor-template">
+            <?php
+            echo Plugin::instance()->frontend->get_builder_content_for_display( $template_id );
+            ?>
+        </div>
+        <?php
+    }
+
+    public function render_plain_content() {}
+}
index 27a19aaed540e753644248c20aec0ddaf17f7349..245e948b24fadc5b14f3b67b9fc288badff2f323 100644 (file)
@@ -3,6 +3,7 @@
 namespace Cube\Elementor\Widgets;
 
 use Elementor\Controls_Manager;
+use Elementor\Repeater;
 
 use function Roots\view;
 use function Roots\asset;
@@ -54,7 +55,7 @@ class TestimonialCarousel extends _Base {
      * @since 1.0.0
      * @access protected
      */
-    protected function _register_controls() {
+    protected function register_controls() {
 
         $this->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 }}}',
             ]
         );
index 03760acc3192e7841666f38b9293bf61f0ed8790..f01960c6dd609e2211ab55450452e79b9933e8e3 100644 (file)
@@ -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',
index df3b870e84e13b105e5979536895a60f5a9bc23b..3b2c7a6aa99064614a961463ce08fbe76160d556 100644 (file)
@@ -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 }}}',
             ]
         );
index 3925fc9bcc24be1250309ad5a515b026e2b72d93..f4355581f377cc8dba82f638d3bed5222ac868fb 100644 (file)
@@ -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 }}}',
             ]
         );
index c5e575d6221d94c7d6b6dad6fcd64897de478049..1c5b8ecdf405cd37f407a0c7648595c128420d73 100755 (executable)
@@ -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/admin.styl b/wp-content/themes/CCV/resources/assets/styles/admin.styl
new file mode 100644 (file)
index 0000000..6a92d6e
--- /dev/null
@@ -0,0 +1,77 @@
+// 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
+  @apply font-body
+  @apply p-3 !important
+
+  // Normally the lists have no margin and the bullet > image sits
+  // in the spacing gutter created by the text-block. In the context
+  // of the editor, it would be hidden so we indent it to make it
+  // visible while editing...
+  ul
+    margin-left: 1.3em
+
+//===== Admin bar tweaks
+$breakpoint-admin-bar = 783px
+$breakpoint-admin-bar-absolute = 600px // When admin bar goes from being 'fixed' to 'absolute'
+$admin-bar-height = 32px
+$admin-bar-height-mobile = 46px
+
+//#wpadminbar
+//  overflow: hidden // Can't do this because it will break dropdown menus in the admin bar
+
+#wp-toolbar
+  display: flex
+  justify-content: space-between
+
+  > *
+    display: flex
+    white-space: nowrap
+
+  // Wrap/hide extra toolbar items on the left when there's not enough space
+  #wp-admin-bar-root-default
+    flex-wrap: wrap
+
+  #wp-admin-bar-top-secondary
+    flex-shrink: 0
+
+body.admin-bar
+  +above($breakpoint-admin-bar)
+    position: relative
+
+    header.site, #mobile-menu
+      top: $admin-bar-height
+
+    .mobile-menu-trigger
+      top: 30px + $admin-bar-height
+
+  +below($breakpoint-admin-bar)
+    header.site, #mobile-menu
+      top: $admin-bar-height-mobile
+
+    .mobile-menu-trigger
+      top: 30px + $admin-bar-height-mobile
+
+  +below($breakpoint-admin-bar-absolute)
+    header.site, #mobile-menu
+      top: 0
+
+    .mobile-menu-trigger
+      top: 30px
+
+/*! purgecss end ignore */
index 09eef779ddb3ed86cce89ba5dfe131aab564713e..2a447e3808fbf874ded793bb899479c1610b92cf 100644 (file)
@@ -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/assets/styles/common/admin.styl b/wp-content/themes/CCV/resources/assets/styles/common/admin.styl
deleted file mode 100644 (file)
index eb8c0cf..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-// Tiny MCE editor styles in Elementor editor
-// Most styles for editor set in text-block.styl body...
-#tinymce
-  @apply font-body
-  @apply p-3 !important
-
-  // Normally the lists have no margin and the bullet > image sits
-  // in the spacing gutter created by the text-block. In the context
-  // of the editor, it would be hidden so we indent it to make it
-  // visible while editing...
-  ul
-    margin-left: 1.3em
-
-//===== Admin bar tweaks
-$breakpoint-admin-bar = 783px
-$breakpoint-admin-bar-absolute = 600px // When admin bar goes from being 'fixed' to 'absolute'
-$admin-bar-height = 32px
-$admin-bar-height-mobile = 46px
-
-#wpadminbar
-  overflow: hidden
-
-#wp-toolbar
-  display: flex
-  justify-content: space-between
-
-  > *
-    display: flex
-    white-space: nowrap
-
-  // Wrap/hide extra toolbar items on the left when there's not enough space
-  #wp-admin-bar-root-default
-    flex-wrap: wrap
-
-  #wp-admin-bar-top-secondary
-    flex-shrink: 0
-
-body.admin-bar
-  +above($breakpoint-admin-bar)
-    position: relative
-
-    header.site, #mobile-menu
-      top: $admin-bar-height
-
-    .mobile-menu-trigger
-      top: 30px + $admin-bar-height
-
-  +below($breakpoint-admin-bar)
-    header.site, #mobile-menu
-      top: $admin-bar-height-mobile
-
-    .mobile-menu-trigger
-      top: 30px + $admin-bar-height-mobile
-
-  +below($breakpoint-admin-bar-absolute)
-    header.site, #mobile-menu
-      top: 0
-
-    .mobile-menu-trigger
-      top: 30px
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 (file)
index 0000000..187b301
--- /dev/null
@@ -0,0 +1,15 @@
+<article @php(post_class())>
+
+  <header class="text-center mb-1v">
+    <h1 class="plain relative bg-purple py-1v px-2v text-white text-xl inline-block rounded-lg">
+      <span class="absolute top-0 left-0 w-full text-center pt-3 uppercase font-light text-xs opacity-50">Elementor Template</span>
+      <span class="block pt-4">{!! $title !!}</span>
+      <span class="font-light text-base opacity-50">ID: {{ get_post_field('post_name') }}</span>
+    </h1>
+  </header>
+
+  <div class="entry-content">
+    @php(the_content())
+  </div>
+
+</article>
index 9181493e9d706f1704bcc09d23eb16b0c131ec09..d4578b98748c39626e94d5e0272727844d59bf07 100644 (file)
@@ -15,7 +15,7 @@
 
     <div class="nav-secondary absolute top-0 right-0 flex items-center">
 
-      {{-- Language switcher (temporarily disabled)
+      {{-- Language switcher --}}
       <ul class="locales flex mr-2">
         @foreach ($languages as $lang)
           <li class="mr-4">
@@ -25,7 +25,6 @@
           </li>
         @endforeach
       </ul>
-      --}}
 
       @if ($button_1)
         <a href="{{ $button_1->url }}"
index 7e39f568c4694bc8a9a12ae7a55896e10fd24c84..7e3c33a26d728cb44e94e4ab8ac81d90fc2367db 100644 (file)
@@ -27,7 +27,7 @@
 <div class="link-carousel swiper-container" data-swiper="{{ $swiper }}">
   <div class="swiper-wrapper">
     @foreach ($links as $link)
-      <a class="link-carousel-item swiper-slide" href="{{ $link['url'] }}">
+      <a class="link-carousel-item swiper-slide" href="{{ $link['link']['url'] }}">
         <div class="link-carousel-item-image">
           <img src="{{ $link['image']['url'] }}" alt="{{ $link['title'] }}">
         </div>
index c4b47f63f346ac1fb9f68e6567c859405c72ffe3..cf87a70d35ee7fb45ba674872c28a8c10e5e3951 100644 (file)
@@ -26,7 +26,8 @@
             $target = $item['cta_link']['is_external'] ? ' target="_blank"' : '';
             $rel = $item['cta_link']['nofollow'] ? ' rel="nofollow"' : '';
           @endphp
-            <a class="btn px-4 py-2 -mt-2" href="{{ $item['cta_link']['url'] }}"{!! $target !!}{!! $rel !!}>
+            <br>
+            <a class="btn px-4 py-2 mt-2" href="{{ $item['cta_link']['url'] }}"{!! $target !!}{!! $rel !!}>
               {{ $item['cta_text'] }}
             </a>
         @endif
index 66ef47683ac51ae16b8341a66f88ff58477cec0c..6a7f509f8ab54ad95e905ddc1b36619f61a4e10e 100644 (file)
@@ -81,6 +81,9 @@ mix.js(src`scripts/app.js`, 'scripts')
 // Main Styles
 mix.stylus(src`styles/app.styl`, 'styles', stylusConfig).options(stylusOptions).tailwind();
 
+// Admin Styles
+mix.stylus(src`styles/admin.styl`, 'styles', stylusConfig).options(stylusOptions).tailwind();
+
 // Assets
 mix.copyDirectory(src`images`, publicPath`images`)
    .copyDirectory(src`fonts`, publicPath`fonts`);