PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / 1.8.0
Gutenify – Visual Site Builder Blocks & Starter Templates v1.8.0
1.9.0 1.8.0 1.7.0 1.6.6 1.6.5 1.6.4 trunk 0.0.1 0.0.2 0.0.3 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 74 releases
gutenify / core / dist / blocks / gallery-carousel / index.php

index.php in Gutenify – Visual Site Builder Blocks & Starter Templates 1.8.0, at core/dist/blocks/gallery-carousel/index.php

99 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace gutenify;
4
5 defined( 'ABSPATH' ) || exit;
6
7
8 class Gallery_Carousel {
9 public static function init() {
10 add_action( 'init', array( __CLASS__, 'register_block' ) );
11 // add_filter( 'gutenify_render_block_gutenify/gallery-carousel', array( __CLASS__, 'gutenify_render_gallery_carousel' ), 10, 3 );
12 }
13
14 public static function register_block() {
15 register_block_type( __DIR__ , array(
16 'render_callback' => array( __CLASS__, 'render_callback' )
17 ));
18 }
19
20 public static function render_callback ( $attributes, $context, $props ) {
21 $constants = Helpers::plugin_constants();
22 $plugin_main_slug = $constants['plugin_main_slug'];
23
24 $wrapper_attributes = get_block_wrapper_attributes( array(
25 'class' => esc_attr( implode( ' ', array( 'gutenify--gallery-carousel--' . $attributes['layout'], 'swiper' ) ) )
26 ) );
27
28 $block_content = sprintf(
29 '<div %s><div class="swiper-wrapper">',
30 $wrapper_attributes,
31 );
32
33 $list_items_markup = '';
34
35 if ( ! empty( $attributes['images'] ) ) {
36 foreach ( $attributes['images'] as $image ) {
37 $title = ! empty( $image['id'] ) && ! empty( $attributes['imagesData'][ $image['id'] ]['title'] ) ? $attributes['imagesData'][ $image['id'] ]['title'] : '';
38 $sub_title = ! empty( $image['id'] ) && ! empty( $attributes['imagesData'][ $image['id'] ]['subTitle'] ) ? $attributes['imagesData'][ $image['id'] ]['subTitle'] : '';
39 $description = ! empty( $image['id'] ) && ! empty( $attributes['imagesData'][ $image['id'] ]['description'] ) ? $attributes['imagesData'][ $image['id'] ]['description'] : '';
40 $button_text = ! empty( $image['id'] ) && ! empty( $attributes['imagesData'][ $image['id'] ]['buttonText'] ) ? $attributes['imagesData'][ $image['id'] ]['buttonText'] : '';
41
42 $list_items_markup .= '<div class="gutenify-gallery-carousel-item swiper-slide">';
43 if ( ! empty( $image['url'] ) ) {
44 $list_items_markup .= '
45 <div class="gutenify-slider-image-wrapper">
46 <div class="gutenify-slider-content-image featured-image">
47 <img src="' . ( $image['url'] ) . '" />
48 </div>
49 </div>';
50 }
51 $list_items_markup .='
52 <div class="gutenify-slider-content-wrapper">
53 <div class="gutenify-slider-content-inner">';
54 if ( ! empty( $title ) ) {
55 $list_items_markup .= '<h2 class="gutenify-slider-title">' . esc_html( $title ) . '</h2>';
56 }
57 if ( ! empty( $sub_title ) ) {
58 $list_items_markup .= '<h2 class="gutenify-slider-sub-title">' . esc_html( $sub_title ) . '</h2>';
59 }
60
61 $list_items_markup .= '<div class="gutenify-slider-content-inner-wrapper">';
62 if ( ! empty( $description ) ) {
63 $list_items_markup .= '<div class="gutenify-slider-content clear-fix">
64 <p>' . $description . '</p>
65 </div>';
66 }
67 // if ( ! empty( $button_text ) ) {
68 // $list_items_markup .= '<p class="gutenify-slider-buttons clear-fix gutenify-button-link wp-block-button__link">
69 // ' . $button_text . '
70 // </p>';
71 // }
72 $list_items_markup .= '</div>';
73 $list_items_markup .= '</div>
74 </div></div>';
75 }
76 }
77
78 $block_content .= $list_items_markup;
79 $block_content .= '</div>';
80 $has_navigation = ! empty( $attributes['hasNavigation'] ) && true === $attributes['hasNavigation'];
81 $has_pagination = ! empty( $attributes['hasPagination'] ) && true === $attributes['hasPagination'];
82 if ( $has_pagination ) {
83 $block_content .= '<div class="swiper-pagination"></div>';
84 }
85 if ( $has_navigation ) {
86 $block_content .= '<div class="navigation-wrap">
87 <div class="swiper-button-prev"></div>
88 <div class="swiper-button-next"></div>
89 </div>';
90 }
91 $block_content .= '</div>';
92
93 return $block_content;
94
95 }
96 }
97
98 Gallery_Carousel::init();
99