PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.11.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.11.1
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 1.1.2 All 80 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.11.1, at includes/blocks/ecm-bookmark-count/block.php

89 lines 2.8 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 );
32 $css_generator->add_class_styles(
33 '{{WRAPPER}} .' . $wrapper_class,
34 $this->get_coutineu_button_css( $attributes ),
35 $this->get_coutineu_button_css( $attributes, 'Tablet' ),
36 $this->get_coutineu_button_css( $attributes, 'Mobile' )
37 );
38
39 return $css_generator->generate_css();
40 }
41
42 public function render_block_content( $attributes, $content, $block_instance ) {
43 $attr_array = [
44 'user_id' => Helper::get_attribute_value( $attributes, 'user_id' ),
45 'not_found_text' => Helper::get_attribute_value( $attributes, 'not_found_text' ),
46 'show_label' => Helper::get_attribute_value( $attributes, 'show_label' ) ? 'true' : 'false',
47 'label_single' => Helper::get_attribute_value( $attributes, 'label_single' ),
48 'label_plural' => Helper::get_attribute_value( $attributes, 'label_plural' ),
49 'show_icon' => Helper::get_attribute_value( $attributes, 'show_icon' ) ? 'true' : 'false',
50 'wrapper_class' => Helper::get_attribute_value( $attributes, 'wrapper_class' ),
51 ];
52
53 $shortcode = '[ecm_bookmark_count ' . Helper::attr_shortcode( $attr_array ) . ']';
54 echo do_shortcode( $shortcode );
55 }
56
57 public function get_coutineu_button_wrapper_css( $attributes, $device = '' ) {
58 $css = [];
59 $alignment_css = [];
60
61 $css['width'] = '100%';
62 $css['display'] = 'flex';
63 $css['flex-direction'] = 'column';
64
65 if ( ! empty( $attributes['countAlignment'][ 'value' . $device ] ) ) {
66 $alignment_css['align-items'] = $attributes['countAlignment'][ 'value' . $device ];
67 }
68
69 return array_merge(
70 $alignment_css,
71 $css,
72 );
73
74 }
75
76 public function get_coutineu_button_css( $attributes, $device = '' ) {
77 $css = [];
78
79 if ( $attributes['numberColor'] !== '' ) {
80 $css['color'] = $attributes['numberColor'];
81 }
82 return array_merge(
83 [ 'color' => Color::get_css( isset( $attributes['numberColor'] ) ? $attributes['numberColor'] : '' ) ],
84 $css,
85 );
86 }
87
88 }
89