PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / trunk
Gutenify – Visual Site Builder Blocks & Starter Templates vtrunk
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 / slider / index.php

index.php in Gutenify – Visual Site Builder Blocks & Starter Templates trunk, at core/dist/blocks/slider/index.php

117 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 class Slider {
8 public static function init() {
9 add_action( 'init', array( __CLASS__, 'register_block' ) );
10 // add_filter( 'gutenify_render_block_gutenify/slider', array( __CLASS__, 'render_block' ), 10, 3 );
11 }
12 public static function register_block() {
13 register_block_type( __DIR__ , array(
14 'render_callback' => array( __CLASS__, 'render_callback' )
15 ));
16 }
17
18 public static function render_callback( $attr, $block_content ){
19 $constants = Helpers::plugin_constants();
20 $main_slug = $constants['plugin_main_slug'];
21
22 $layout = ! empty( $attr['blockAdvanceOptions']['layout'] ) ? esc_attr( $attr['blockAdvanceOptions']['layout'] ) : 'layout-1';
23
24 $wrapper_attributes = get_block_wrapper_attributes( array(
25 'class' => implode( ' ', array(
26 $main_slug . '-section-' . $layout,
27 'swiper',
28 ) )
29 ) );
30
31 $has_navigation = ! empty( $attr['hasNavigation'] ) && true === $attr['hasNavigation'];
32 $has_pagination = ! empty( $attr['hasPagination'] ) && true === $attr['hasPagination'];
33
34 $new_content = sprintf( '<div %s>', $wrapper_attributes );
35 $new_content .= '<div class="swiper-wrapper">';
36 $new_content .= $block_content;
37 $new_content .= '</div>';
38 if ( $has_navigation ) {
39 $new_content .= '<div class="navigation-wrap">
40 <div class="swiper-button-prev"></div>
41 <div class="swiper-button-next"></div>
42 </div>';
43 }
44
45 if ( $has_pagination ) {
46 $new_content .= '<div class="swiper-pagination"></div>';
47 }
48 $new_content .= '</div>';
49 return $new_content;
50 }
51
52 public static function render_callback1( $attributes, $content, $props ) {
53 $constants = Helpers::plugin_constants();
54
55 $class_name = array();
56 // $class = array( 'swiper-container', 'gutenify-slider' );
57 // $styles = array();
58 // $block_style = ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'is-style-stacked' ) !== false ? 'stacked' : 'horizontal';
59
60
61 $layout = ! empty( $attributes['blockAdvanceOptions']['layout'] ) ? $attributes['blockAdvanceOptions']['layout'] : 'layout-1';
62
63 array_push( $class_name, 'gutenify-section-' . $layout, 'swiper' );
64
65
66
67
68 // if ( isset( $attributes['columns'] ) ) {
69 // array_push( $class, 'has-columns has-' . $attributes['columns'] . '-columns has-responsive-columns' );
70 // }
71
72 // if ( isset( $attributes['listPosition'] ) && 'right' === $attributes['listPosition'] && 'horizontal' === $block_style ) {
73 // array_push( $class, 'has-image-right' );
74 // }
75
76 // if ( isset( $attributes['imageSize'] ) && 'horizontal' === $block_style ) {
77 // array_push( $class, 'has-' . $attributes['imageSize'] . '-image' );
78 // }
79
80 // if ( isset( $attributes['imageStyle'] ) ) {
81 // array_push( $class, 'has-' . $attributes['imageStyle'] . '-image' );
82 // }
83
84 $class_name = apply_filters( 'gutenify--slider--wrapper-class', $class_name, $props );
85
86 $wrapper_attributes = get_block_wrapper_attributes( array(
87 'class' => esc_attr( implode( ' ', $class_name ) )
88 ) );
89
90 $block_content = sprintf( '<div %s> <div class="swiper-wrapper">', $wrapper_attributes );
91
92 $list_items_markup = '';
93
94 $list_items_markup = $content;
95
96 $block_content .= $list_items_markup;
97 $block_content .= '</div>';
98 $has_navigation = ! empty( $attributes['hasNavigation'] ) && true === $attributes['hasNavigation'];
99 $has_pagination = ! empty( $attributes['hasPagination'] ) && true === $attributes['hasPagination'];
100 if ( $has_navigation ) {
101 $block_content .= '<div class="swiper-button-next"></div>
102 <div class="swiper-button-prev"></div>';
103 }
104 if ( $has_pagination ) {
105 $block_content .= '<div class="swiper-pagination"></div>';
106 }
107 $block_content .= '</div>';
108 $block_content .= '</div>';
109
110
111 return $block_content;
112 }
113 }
114
115 Slider::init();
116
117