PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / trunk
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder vtrunk
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 1.2.0 1.2.1 All 78 releases
ablocks / includes / blocks / qr-code / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder trunk, at includes/blocks/qr-code/block.php

55 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\QRCode;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
10 use ABlocks\Controls\Alignment;
11 use ABlocks\Controls\Range;
12 use ABlocks\Classes\CssGeneratorV2;
13
14 class Block extends BlockBaseAbstract {
15 protected $block_name = 'qr-code';
16
17
18 public function build_css_v1( $attributes ) {
19 // Generate CSS start
20 $css_generator = new CssGenerator( $attributes );
21 return $css_generator->generate_css();
22
23 }
24 public function build_css_v2( $attributes ) {
25 // Generate CSS start
26 $css_generator = new CssGenerator( $attributes );
27 $css_generator->add_class_styles(
28 '{{WRAPPER}}.ablocks-block--qr-code:not(.ablocks-block-container),
29 {{WRAPPER}}.ablocks-block--qr-code .ablocks-block-container',
30 $this->get_qr_code_css( $attributes ),
31 $this->get_qr_code_css( $attributes, 'Tablet' ),
32 $this->get_qr_code_css( $attributes, 'Mobile' )
33 );
34 return $css_generator->generate_css();
35
36 }
37 public function build_css( $attributes ) {
38 if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
39 return $this->build_css_v2( $attributes );
40 }
41 return $this->build_css_v1( $attributes );
42 }
43 public function get_qr_code_css( $attributes, $device = '' ) {
44 $qr_code_css = Range::get_css( [] );
45
46 if ( ! empty( $attributes['alignment'][ 'value' . $device ] ) ) {
47 $qr_code_css['justify-content'] = $attributes['alignment'][ 'value' . $device ];
48 $qr_code_css['display'] = 'flex';
49 }
50 return array_merge(
51 $qr_code_css
52 );
53 }
54 }
55