PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 81 releases
ablocks / includes / blocks / ecm-bookmark-count / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.14.0, at includes/blocks/ecm-bookmark-count/block.php

91 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ABlocks\Blocks\EcmBookmarkCount;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 use ABlocks\Classes\BlockBaseAbstract;
10 use ABlocks\Classes\CssGenerator;
11 use ABlocks\Helper;
12 use ABlocks\Controls\Background;
13 use ABlocks\Controls\Border;
14 use ABlocks\Controls\Dimensions;
15 use ABlocks\Controls\Range;
16 use ABlocks\Controls\BoxShadow;
17 use ABlocks\Controls\Color;
18
19 class Block extends BlockBaseAbstract {
20 protected $block_name = 'ecm-bookmark-count';
21
22 public function build_css( $attributes ) {
23 $css_generator = new CssGenerator( $attributes, $this->block_name );
24 $wrapper_class = ! empty( $attributes['wrapper_class'] ) ? $attributes['wrapper_class'] : 'wrapper';
25
26 $css_generator->add_class_styles(
27 '{{WRAPPER}} .' . $wrapper_class,
28 $this->get_coutineu_button_wrapper_css( $attributes ),
29 $this->get_coutineu_button_wrapper_css( $attributes, 'Tablet' ),
30 $this->get_coutineu_button_wrapper_css( $attributes, 'Mobile' ),
31 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_coutineu_button_wrapper_css( $attributes, $device ); } )
32 );
33 $css_generator->add_class_styles(
34 '{{WRAPPER}} .' . $wrapper_class,
35 $this->get_coutineu_button_css( $attributes ),
36 $this->get_coutineu_button_css( $attributes, 'Tablet' ),
37 $this->get_coutineu_button_css( $attributes, 'Mobile' ),
38 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_coutineu_button_css( $attributes, $device ); } )
39 );
40
41 return $css_generator->generate_css();
42 }
43
44 public function render_block_content( $attributes, $content, $block_instance ) {
45 $attr_array = [
46 'user_id' => Helper::get_attribute_value( $attributes, 'user_id' ),
47 'not_found_text' => Helper::get_attribute_value( $attributes, 'not_found_text' ),
48 'show_label' => Helper::get_attribute_value( $attributes, 'show_label' ) ? 'true' : 'false',
49 'label_single' => Helper::get_attribute_value( $attributes, 'label_single' ),
50 'label_plural' => Helper::get_attribute_value( $attributes, 'label_plural' ),
51 'show_icon' => Helper::get_attribute_value( $attributes, 'show_icon' ) ? 'true' : 'false',
52 'wrapper_class' => Helper::get_attribute_value( $attributes, 'wrapper_class' ),
53 ];
54
55 $shortcode = '[ecm_bookmark_count ' . Helper::attr_shortcode( $attr_array ) . ']';
56 echo do_shortcode( $shortcode );
57 }
58
59 public function get_coutineu_button_wrapper_css( $attributes, $device = '' ) {
60 $css = [];
61 $alignment_css = [];
62
63 $css['width'] = '100%';
64 $css['display'] = 'flex';
65 $css['flex-direction'] = 'column';
66
67 if ( ! empty( $attributes['countAlignment'][ 'value' . $device ] ) ) {
68 $alignment_css['align-items'] = $attributes['countAlignment'][ 'value' . $device ];
69 }
70
71 return array_merge(
72 $alignment_css,
73 $css,
74 );
75
76 }
77
78 public function get_coutineu_button_css( $attributes, $device = '' ) {
79 $css = [];
80
81 if ( $attributes['numberColor'] !== '' ) {
82 $css['color'] = $attributes['numberColor'];
83 }
84 return array_merge(
85 [ 'color' => Color::get_css( isset( $attributes['numberColor'] ) ? $attributes['numberColor'] : '' ) ],
86 $css,
87 );
88 }
89
90 }
91