]> _ Git - c6-wordpress.git/commitdiff
wait #7096 @2:00
authorsoufiane <soufiane@cubedesigners.com>
Mon, 23 Sep 2024 16:08:38 +0000 (18:08 +0200)
committersoufiane <soufiane@cubedesigners.com>
Mon, 23 Sep 2024 16:08:38 +0000 (18:08 +0200)
wp-content/mu-plugins/cube/src/Elementor/Setup.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/FeatureBlock.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/PostsBlock.php [new file with mode: 0644]
wp-content/themes/c6/resources/assets/styles/components/headings.styl
wp-content/themes/c6/resources/assets/styles/widgets/posts-block.styl [new file with mode: 0644]
wp-content/themes/c6/resources/views/widgets/posts-block.blade.php [new file with mode: 0644]

index 6e3197c7cb41879dff6d2ee7e8245af6c1e794a7..ec8c658b00bad623dbdbf51eecd31c46ba287ecb 100644 (file)
@@ -37,6 +37,7 @@ class Setup {
         $elementor->widgets_manager->register_widget_type( new Widgets\Heading() );
         $elementor->widgets_manager->register_widget_type( new Widgets\Timeline() );
         $elementor->widgets_manager->register_widget_type( new Widgets\FeatureBlock() );
+        $elementor->widgets_manager->register_widget_type( new Widgets\PostsBlock() );
     }
 
     protected function _customise_sections() {
index e9afffc85f5a8c86371c0d73d1f1234f6764a220..c4f116e07538aa23f897bf434fe0b2effe78ec3b 100644 (file)
@@ -129,17 +129,6 @@ class FeatureBlock extends Widget_Base
             ]
         );
 
-        $this->add_control(
-            'circle',
-            [
-                'label' => __('Circular Background', 'cube'),
-                'type' => Controls_Manager::SWITCHER,
-                'default' => '',
-                'return_value' => 'circle',
-                'prefix_class' => 'feature-block-'
-            ]
-        );
-
         $this->end_controls_section();
 
     }
diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/PostsBlock.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/PostsBlock.php
new file mode 100644 (file)
index 0000000..80acdbb
--- /dev/null
@@ -0,0 +1,126 @@
+<?php
+
+namespace Cube\Elementor\Widgets;
+
+use Elementor\Widget_Base;
+use Elementor\Controls_Manager;
+use Elementor\Utils;
+use Elementor\Repeater;
+
+
+class PostsBlock extends Widget_Base
+{
+
+    // Widget name / ID
+    public function get_name() {
+        return 'cube-posts-block';
+    }
+
+    // Elementor widget title
+    public function get_title() {
+        return __( 'Posts block', 'cube' );
+    }
+
+    // Elementor interface icon
+    public function get_icon() {
+        return 'eicon-image';
+    }
+
+    // Where to display the widget in the Elementor interface
+    public function get_categories() {
+        return [ 'theme-elements' ];
+    }
+
+    /**
+     * 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() {
+
+        $this->start_controls_section(
+            'section_content',
+            [
+                'label' => __( 'Content', 'cube' ),
+            ]
+        );
+
+        // all the items with REPEATER
+        $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' => 'body',
+                        'label' => __('Description', 'cube'),
+                        'type' => Controls_Manager::WYSIWYG,
+                        'default' => '',
+                    ],
+
+                ],
+                'title_field' => '{{{ title }}}',
+            ]
+        );
+
+        $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() {
+        $items = $this->get_settings('items');
+
+        $res = "<div class='posts-block'>";
+                foreach($items as $item) {
+                    $res .= "<div class='posts-block-item'>";
+                    $res .= "<div class='posts-block-item-image-wrapper'>";
+                    if (!empty($item['image']['id'])) {
+                        $res .= wp_get_attachment_image($item['image']['id'], 'large', false, ['class' => 'feature-block-image']);
+                    }
+                    $res .= "</div>";
+                    $res .= "<div class='posts-block-item-description'>";
+                    $res .= "<h3 class='posts-block-item-title'>".$item['title']."</h3>";
+                    $res .= "<p>".$item['body']."</p>";
+                    $res .= "</div>";
+                    $res .= "</div>";
+                }
+        $res .= "</div>";
+
+        echo $res;
+    }
+}
index fed2412128f86164446906458e359c4e7e2b1c5e..f15308244ea5e61347f751e4f14c329dc2bac7ee 100644 (file)
@@ -30,3 +30,7 @@ h4
     +below(600px)
       white-space: normal
       font-size: 30px
+
+.elementor-element.no-left
+  .heading-subtitle-wrapper
+    left: 0
diff --git a/wp-content/themes/c6/resources/assets/styles/widgets/posts-block.styl b/wp-content/themes/c6/resources/assets/styles/widgets/posts-block.styl
new file mode 100644 (file)
index 0000000..ef6d8f8
--- /dev/null
@@ -0,0 +1,18 @@
+.posts-block
+  display: flex;
+  gap: 43px;
+
+  +below(1200px)
+    margin-top: 50px
+
+  +below(768px)
+    flex-direction: column
+
+    img
+      width: 100%
+
+  &-item
+    flex: 1
+
+    &-title
+      font-size: 1.5rem
diff --git a/wp-content/themes/c6/resources/views/widgets/posts-block.blade.php b/wp-content/themes/c6/resources/views/widgets/posts-block.blade.php
new file mode 100644 (file)
index 0000000..8b48c16
--- /dev/null
@@ -0,0 +1,13 @@
+<div class="posts-block flex">
+  @foreach($items as $item)
+    <div class="posts-block-item">
+      <div class="posts-block-item-image-wrapper">
+        @image($item['image']['id'], 'full', ['class' => 'posts-block-item-image'])
+      </div>
+      <div>
+        <h3>{{ $item['title'] }}</h3>
+        <p>{!! $item['content'] !!}</p>
+      </div>
+    </div>
+  @endforeach
+</div>