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-claim-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-claim-count/block.php

90 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\EcmClaimCount;
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-claim-count';
21
22 public function build_css( $attributes ) {
23 $css_generator = new CssGenerator( $attributes, $this->block_name );
24
25 $css_generator->add_class_styles(
26 '{{WRAPPER}}.ablocks-block--ecm-claim-count',
27 $this->get_coutineu_button_wrapper_css( $attributes ),
28 $this->get_coutineu_button_wrapper_css( $attributes, 'Tablet' ),
29 $this->get_coutineu_button_wrapper_css( $attributes, 'Mobile' )
30 );
31 $wrapper_class = ! empty( $attributes['wrapper_class'] ) ? $attributes['wrapper_class'] : 'claim-count-wrapper';
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 'status' => Helper::get_attribute_value( $attributes, 'status' ),
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_claim_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['align-items'] = 'center';
64
65 if ( ! empty( $attributes['countAlignment'][ 'value' . $device ] ) ) {
66 $alignment_css['justify-content'] = $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['upvoteNumberColor'] !== '' ) {
80 $css['color'] = $attributes['upvoteNumberColor'];
81 }
82
83 return array_merge(
84 [ 'color' => Color::get_css( isset( $attributes['upvoteNumberColor'] ) ? $attributes['upvoteNumberColor'] : '' ) ],
85 $css,
86 );
87 }
88
89 }
90