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
← All changes | includes/blocks/storeengine-shipping-info/block.php +112 -0 2.7.4 → 2.14.0 View file →
@@ -1,0 +1,112 @@
1 +<?php
2 +
3 +namespace ABlocks\Blocks\StoreengineShippingInfo;
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-shipping-info';
22 +
23 + public function build_css_v1( $attributes ) {
24 + $css_generator = new CssGenerator( $attributes );
25 + return $css_generator->generate_css();
26 + }
27 +
28 +
29 + public function build_css_v2( $attributes ) {
30 + $css_generator = new CssGenerator( $attributes, $this->block_name );
31 +
32 + $css_generator->add_class_styles(
33 + '{{WRAPPER}} .storeengine-order-shipping-shortcode .storeengine-order-shipping-heading',
34 + $this->get_shipping_heading_css( $attributes, '' ),
35 + $this->get_shipping_heading_css( $attributes, 'Tablet' ),
36 + $this->get_shipping_heading_css( $attributes, 'Mobile' ),
37 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_shipping_heading_css( $attributes, $device ); } )
38 + );
39 +
40 + $css_generator->add_class_styles(
41 + '{{WRAPPER}} .storeengine-order-shipping-shortcode .storeengine-order-shipping-heading:hover',
42 + $this->get_shipping_heading_hover_css( $attributes, '' ),
43 + $this->get_shipping_heading_hover_css( $attributes, 'Tablet' ),
44 + $this->get_shipping_heading_hover_css( $attributes, 'Mobile' ),
45 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_shipping_heading_hover_css( $attributes, $device ); } )
46 + );
47 + $css_generator->add_class_styles(
48 + '{{WRAPPER}} .storeengine-order-shipping-shortcode .storeengine-order-shipping-address p',
49 + $this->get_shipping_address_css( $attributes, '' ),
50 + $this->get_shipping_address_css( $attributes, 'Tablet' ),
51 + $this->get_shipping_address_css( $attributes, 'Mobile' ),
52 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_shipping_address_css( $attributes, $device ); } )
53 + );
54 +
55 + $css_generator->add_class_styles(
56 + '{{WRAPPER}} .storeengine-order-shipping-shortcode .storeengine-order-shipping-address p:hover',
57 + $this->get_shipping_address_hover_css( $attributes, '' ),
58 + $this->get_shipping_address_hover_css( $attributes, 'Tablet' ),
59 + $this->get_shipping_address_hover_css( $attributes, 'Mobile' ),
60 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_shipping_address_hover_css( $attributes, $device ); } )
61 + );
62 +
63 + return $css_generator->generate_css();
64 + }
65 +
66 + public function build_css( $attributes ) {
67 + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
68 + return $this->build_css_v2( $attributes );
69 + }
70 + return $this->build_css_v1( $attributes );
71 + }
72 +
73 + public function get_shipping_heading_css( $attributes, $device = '' ) {
74 + $typographyGlobal = ( isset( $attributes['shipping_heading_typograhyGlobal'] ) ? $attributes['shipping_heading_typograhyGlobal'] : '' );
75 + $typography_value = isset( $attributes['shipping_heading_typography'] ) ?
76 + Typography::get_css( $attributes['shipping_heading_typography'], '', $device, $typographyGlobal )
77 + : [];
78 +
79 + return array_merge(
80 + [ 'color' => Color::get_css( isset( $attributes['shipping_heading_color'] ) ? $attributes['shipping_heading_color'] : '' ) ],
81 + $typography_value,
82 + );
83 +
84 + }
85 +
86 + public function get_shipping_heading_hover_css( $attributes, $device = '' ) {
87 + return [ 'color' => Color::get_css( isset( $attributes['shipping_heading_hover_color'] ) ? $attributes['shipping_heading_hover_color'] : '' ) ];
88 + }
89 + public function get_shipping_address_css( $attributes, $device = '' ) {
90 + $typographyGlobal = ( isset( $attributes['shipping_address_typographyGlobal'] ) ? $attributes['shipping_address_typograhyGlobal'] : '' );
91 + $typography_value = isset( $attributes['shipping_address_typography'] ) ?
92 + Typography::get_css( $attributes['shipping_address_typography'], '', $device, $typographyGlobal )
93 + : [];
94 +
95 + return array_merge(
96 + [ 'color' => Color::get_css( isset( $attributes['shipping_address_color'] ) ? $attributes['shipping_address_color'] : '' ) ],
97 + $typography_value,
98 + );
99 +
100 + }
101 +
102 + public function get_shipping_address_hover_css( $attributes, $device = '' ) {
103 + return [ 'color' => Color::get_css( isset( $attributes['shipping_address_hover_color'] ) ? $attributes['shipping_address_hover_color'] : '' ) ];
104 + }
105 +
106 + public function render_block_content( $attributes, $content, $block_instance ) {
107 + // StoreEngine core falls back to sample content when there's no real
108 + // order (e.g. in the editor), so no dummy flag is needed here.
109 + echo do_shortcode( '[storeengine_order_shipping_address]' );
110 + }
111 +
112 +}