PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.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 1.1.2 All 80 releases
← All changes | includes/blocks/qr-code/block.php +54 -0 2.7.62.13.0 View file →
@@ -1,0 +1,54 @@
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 +}