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 / storeengine-billing-info / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.11.1, at includes/blocks/storeengine-billing-info/block.php

103 lines 4.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\StoreengineBillingInfo;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 use ABlocks\Classes\BlockBaseAbstract;
10 use ABlocks\Classes\CssGenerator;
11 use ABlocks\Classes\CssGeneratorV2;
12 use ABlocks\Helper;
13 use ABlocks\Controls\Typography;
14 use ABlocks\Controls\Background;
15 use ABlocks\Controls\Border;
16 use ABlocks\Controls\Dimensions;
17 use ABlocks\Controls\Range;
18 use ABlocks\Controls\Color;
19
20 class Block extends BlockBaseAbstract {
21 protected $block_name = 'storeengine-billing-info';
22
23 public function build_css_v1( $attributes ) {
24 $css_generator = new CssGenerator( $attributes );
25 return $css_generator->generate_css();
26 }
27
28 public function build_css_v2( $attributes ) {
29 $css_generator = new CssGenerator( $attributes, $this->block_name );
30
31 $css_generator->add_class_styles(
32 '{{WRAPPER}} .storeengine-order-billing-shortcode .storeengine-order-billing-heading',
33 $this->get_billing_heading_css( $attributes, '' ),
34 $this->get_billing_heading_css( $attributes, 'Tablet' ),
35 $this->get_billing_heading_css( $attributes, 'Mobile' )
36 );
37 $css_generator->add_class_styles(
38 '{{WRAPPER}} .storeengine-order-billing-shortcode .storeengine-order-billing-heading:hover',
39 $this->get_billing_heading_hover_css( $attributes, '' ),
40 $this->get_billing_heading_hover_css( $attributes, 'Tablet' ),
41 $this->get_billing_heading_hover_css( $attributes, 'Mobile' )
42 );
43 $css_generator->add_class_styles(
44 '{{WRAPPER}} .storeengine-order-billing-shortcode .storeengine-order-billing-address p',
45 $this->get_billing_address_css( $attributes, '' ),
46 $this->get_billing_address_css( $attributes, 'Tablet' ),
47 $this->get_billing_address_css( $attributes, 'Mobile' )
48 );
49 $css_generator->add_class_styles(
50 '{{WRAPPER}} .storeengine-order-billing-shortcode .storeengine-order-billing-address p:hover',
51 $this->get_billing_address_hover_css( $attributes, '' ),
52 $this->get_billing_address_hover_css( $attributes, 'Tablet' ),
53 $this->get_billing_address_hover_css( $attributes, 'Mobile' )
54 );
55
56 return $css_generator->generate_css();
57 }
58
59 public function build_css( $attributes ) {
60 if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
61 return $this->build_css_v2( $attributes );
62 }
63 return $this->build_css_v1( $attributes );
64 }
65
66 public function get_billing_heading_css( $attributes, $device = '' ) {
67 $typographyValueGlobal = ! empty( $attributes['heading_typograhyGlobal'] ) ? $attributes['heading_typograhyGlobal'] : '';
68 $typography_css = isset( $attributes['heading_typograhy'] ) ? $attributes['heading_typograhy'] : [];
69
70 return array_merge(
71 [ 'color' => Color::get_css( isset( $attributes['heading_color'] ) ? $attributes['heading_color'] : '' ) ],
72 Typography::get_css( $typography_css, '', $device, $typographyValueGlobal ),
73 );
74 }
75
76 public function get_billing_heading_hover_css( $attributes, $device = '' ) {
77 return [ 'color' => Color::get_css( isset( $attributes['heading_hover_color'] ) ? $attributes['heading_hover_color'] : '' ) ];
78
79 }
80
81
82 public function get_billing_address_css( $attributes, $device = '' ) {
83 $typographyValueGlobal = ! empty( $attributes['address_typograhyGlobal'] ) ? $attributes['address_typograhyGlobal'] : '';
84 $typography_css = isset( $attributes['address_typograhy'] ) ? $attributes['address_typograhy'] : [];
85
86 return array_merge(
87 [ 'color' => Color::get_css( isset( $attributes['address_color'] ) ? $attributes['address_color'] : '' ) ],
88 Typography::get_css( $typography_css, '', $device, $typographyValueGlobal )
89 );
90 }
91
92 public function get_billing_address_hover_css( $attributes, $device = '' ) {
93 return [ 'color' => Color::get_css( isset( $attributes['address_hover_color'] ) ? $attributes['address_hover_color'] : '' ) ];
94 }
95
96 public function render_block_content( $attributes, $content, $block_instance ) {
97 // StoreEngine core falls back to sample content when there's no real
98 // order (e.g. in the editor), so no dummy flag is needed here.
99 echo do_shortcode( '[storeengine_order_billing_address]' );
100 }
101
102 }
103