PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.12.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.12.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-reaction-list / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.12.0, at includes/blocks/ecm-reaction-list/block.php

123 lines 4.5 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\EcmReactionList;
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\Typography;
13 use ABlocks\Controls\Background;
14 use ABlocks\Controls\Border;
15 use ABlocks\Controls\Dimensions;
16 use ABlocks\Controls\Range;
17 use ABlocks\Controls\BoxShadow;
18 use ABlocks\Controls\Color;
19 use ABlocks\Controls\Alignment;
20
21 class Block extends BlockBaseAbstract {
22 protected $block_name = 'ecm-reaction-list';
23
24 public function build_css( $attributes ) {
25 $css_generator = new CssGenerator( $attributes, $this->block_name );
26
27 $css_generator->add_class_styles(
28 '{{WRAPPER}} p.ecm-shortcode--reaction__list-title',
29 $this->getTitleTextCSS( $attributes ),
30 $this->getTitleTextCSS( $attributes, 'Tablet' ),
31 $this->getTitleTextCSS( $attributes, 'Mobile' )
32 );
33 $css_generator->add_class_styles(
34 '{{WRAPPER}} ul.ecm-shortcode--reaction__list',
35 $this->get_alignment_css( $attributes ),
36 $this->get_alignment_css( $attributes, 'Tablet' ),
37 $this->get_alignment_css( $attributes, 'Mobile' )
38 );
39 $css_generator->add_class_styles(
40 '{{WRAPPER}} p.ecm-shortcode--reaction__list-meta',
41 $this->getListTextCSS( $attributes ),
42 $this->getListTextCSS( $attributes, 'Tablet' ),
43 $this->getListTextCSS( $attributes, 'Mobile' )
44 );
45 $css_generator->add_class_styles(
46 '{{WRAPPER}} div.ecm-shortcode--reaction',
47 $this->nobookmarksTextCSS( $attributes ),
48 $this->nobookmarksTextCSS( $attributes, 'Tablet' ),
49 $this->nobookmarksTextCSS( $attributes, 'Mobile' )
50 );
51 return $css_generator->generate_css();
52 }
53
54 public function render_block_content( $attributes, $content, $block_instance ) {
55 $attr_array = [
56 'user_id' => Helper::get_attribute_value( $attributes, 'user_id' ),
57 'not_found_text' => Helper::get_attribute_value( $attributes, 'not_found_text' ),
58 ];
59
60 // if ( isset( $block_instance->context['postId'] ) && ! empty( $block_instance->context['postId'] ) && empty( $attr_array['product_id'] ) ) {
61 // $attr_array['product_id'] = $block_instance->context['postId'];
62 // }
63
64 // // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
65 // if ( isset( $_GET['context'] ) && 'edit' === sanitize_text_field( $_GET['context'] ) ) {
66 // $attr_array['dummy'] = true;
67 // }
68
69 $shortcode = '[ecm_reaction_list ' . Helper::attr_shortcode( $attr_array ) . ']';
70 echo do_shortcode( $shortcode );
71
72 }
73
74 public function getTitleTextCSS( $attributes, $device = '' ) {
75 // $typographyGlobal = ( isset( $attributes['couponTypographyGlobal'] ) ? $attributes['couponTypographyGlobal'] : '' );
76 return array_merge(
77 [ 'color' => Color::get_css( isset( $attributes['reacTitleColor'] ) ? $attributes['reacTitleColor'] : '' ) ],
78
79 Typography::get_css( $attributes['reacTitleTypography'], '', $device ),
80
81 );
82 }
83 public function get_alignment_css( $attributes, $device = '' ) {
84 $css = [
85 'flex-direction' => 'column',
86 'display' => 'flex'
87 ];
88
89 if ( isset( $attributes['reactionAlignment'] ) ) {
90 $css = array_merge( $css, Alignment::get_css( $attributes['reactionAlignment'], 'align-items', $device ) );
91 $css = array_merge( $css, Alignment::get_css( $attributes['reactionAlignment'], 'text-align', $device ) );
92 $css['list-style-type'] = $attributes['reactionUlStyle'];
93 }
94 return array_merge(
95 [ 'color' => Color::get_css( isset( $attributes['reacTitleColor'] ) ? $attributes['reacTitleColor'] : '' ) ],
96 Typography::get_css( $attributes['reacTitleTypography'], '', $device ),
97 $css,
98 );
99 }
100 public function getListTextCSS( $attributes, $device = '' ) {
101 // $typographyGlobal = ( isset( $attributes['couponTypographyGlobal'] ) ? $attributes['couponTypographyGlobal'] : '' );
102 return array_merge(
103 [ 'color' => Color::get_css( isset( $attributes['reacListColor'] ) ? $attributes['reacListColor'] : '' ) ],
104
105 Typography::get_css( $attributes['reacListTypography'], '', $device ),
106
107 );
108 }
109 public function nobookmarksTextCSS( $attributes, $device = '' ) {
110 $css = ['flex-direction' => 'column'];
111
112 if ( isset( $attributes['reactionAlignment'] ) ) {
113 $css = array_merge( $css, Alignment::get_css( $attributes['reactionAlignment'], 'align-items', $device ) );
114 }
115 return array_merge(
116 [ 'color' => Color::get_css( isset( $attributes['nobookmarksColor'] ) ? $attributes['nobookmarksColor'] : '' ) ],
117
118 Typography::get_css( $attributes['nobookmarksTypography'], '', $device ),
119 $css,
120 );
121 }
122 }
123