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-upvote-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-upvote-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\EcmUpvoteCount;
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-upvote-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'] : 'upvote-count-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 'post_id' => Helper::get_attribute_value( $attributes, 'post_id' ),
45 'show_label' => Helper::get_attribute_value( $attributes, 'show_label' ) ? 'true' : 'false',
46 'label_single' => Helper::get_attribute_value( $attributes, 'label_single' ),
47 'label_plural' => Helper::get_attribute_value( $attributes, 'label_plural' ),
48 'show_icon' => Helper::get_attribute_value( $attributes, 'show_icon' ) ? 'true' : 'false',
49 'wrapper_class' => Helper::get_attribute_value( $attributes, 'wrapper_class' ),
50 ];
51
52 $shortcode = '[ecm_upvote_count ' . Helper::attr_shortcode( $attr_array ) . ']';
53 echo do_shortcode( $shortcode );
54 }
55
56 public function get_coutineu_button_wrapper_css( $attributes, $device = '' ) {
57 $css = [];
58 $alignment_css = [];
59
60 $css['width'] = '100%';
61 $css['display'] = 'flex';
62 $css['flex-direction'] = 'column';
63
64 if ( ! empty( $attributes['countAlignment'][ 'value' . $device ] ) ) {
65 $alignment_css['align-items'] = $attributes['countAlignment'][ 'value' . $device ];
66 }
67
68 return array_merge(
69 $alignment_css,
70 $css,
71 );
72
73 }
74
75 public function get_coutineu_button_css( $attributes, $device = '' ) {
76 $css = [];
77
78 if ( $attributes['upvoteNumberColor'] !== '' ) {
79 $css['color'] = $attributes['upvoteNumberColor'];
80 }
81
82 return array_merge(
83 [ 'color' => Color::get_css( isset( $attributes['upvoteNumberColor'] ) ? $attributes['upvoteNumberColor'] : '' ) ],
84 $css,
85 );
86 }
87
88 }
89