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-reaction-list / block.php

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

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