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

132 lines 6.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\StoreengineOrderInfo;
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\Border;
14 use ABlocks\Controls\Dimensions;
15 use ABlocks\Controls\Range;
16 use ABlocks\Classes\CssGeneratorV2;
17 use ABlocks\Controls\Color;
18
19 class Block extends BlockBaseAbstract {
20 protected $block_name = 'storeengine-order-info';
21
22 public function build_css_v1( $attributes ) {
23 $css_generator = new CssGenerator( $attributes );
24 return $css_generator->generate_css();
25 }
26
27 public function build_css_v2( $attributes ) {
28 $css_generator = new CssGenerator( $attributes );
29
30 $css_generator->add_class_styles(
31 '{{WRAPPER}} .storeengine-thankyou-order-info-shortcode .storeengine-thankyou-order-info-success__content h4',
32 $this->get_status_title_css( $attributes ),
33 $this->get_status_title_css( $attributes, 'Tablet' ),
34 $this->get_status_title_css( $attributes, 'Mobile' )
35 );
36
37 $css_generator->add_class_styles(
38 '{{WRAPPER}} .storeengine-thankyou-order-info-shortcode .storeengine-thankyou-order-info-success__content h4:hover',
39 $this->get_status_title_hover_css( $attributes ),
40 $this->get_status_title_hover_css( $attributes, 'Tablet' ),
41 $this->get_status_title_hover_css( $attributes, 'Mobile' )
42 );
43 $css_generator->add_class_styles(
44 '{{WRAPPER}} .storeengine-thankyou-order-info-shortcode .storeengine-thankyou-order-info-success__content p span,
45 {{WRAPPER}} .storeengine-thankyou-order-info-shortcode .storeengine-thankyou-order-info-success__content p time',
46 $this->get_deatils_title_css( $attributes ),
47 $this->get_deatils_title_css( $attributes, 'Tablet' ),
48 $this->get_deatils_title_css( $attributes, 'Mobile' )
49 );
50
51 $css_generator->add_class_styles(
52 '{{WRAPPER}} .storeengine-thankyou-order-info-shortcode .storeengine-thankyou-order-info-success__content p span:hover,
53 {{WRAPPER}} .storeengine-thankyou-order-info-shortcode .storeengine-thankyou-order-info-success__content p time:hover',
54 $this->get_deatils_title_hover_css( $attributes ),
55 $this->get_deatils_title_hover_css( $attributes, 'Tablet' ),
56 $this->get_deatils_title_hover_css( $attributes, 'Mobile' )
57 );
58 $css_generator->add_class_styles(
59 '{{WRAPPER}} .storeengine-thankyou-order-info-shortcode .storeengine-thankyou-order-info-success .storeengine-thankyou-order-info-success__email p span,
60 {{WRAPPER}} .storeengine-thankyou-order-info-shortcode .storeengine-thankyou-order-info-success .storeengine-thankyou-order-info-success__email p a',
61 $this->get_email_css( $attributes ),
62 $this->get_email_css( $attributes, 'Tablet' ),
63 $this->get_email_css( $attributes, 'Mobile' )
64 );
65 $css_generator->add_class_styles(
66 '{{WRAPPER}} .storeengine-thankyou-order-info-shortcode .storeengine-thankyou-order-info-success .storeengine-thankyou-order-info-success__email p span:hover,
67 {{WRAPPER}} .storeengine-thankyou-order-info-shortcode .storeengine-thankyou-order-info-success .storeengine-thankyou-order-info-success__email p a:hover',
68 $this->get_email_hover_css( $attributes ),
69 $this->get_email_hover_css( $attributes, 'Tablet' ),
70 $this->get_email_hover_css( $attributes, 'Mobile' )
71 );
72
73 return $css_generator->generate_css();
74 }
75
76 public function build_css( $attributes ) {
77 if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
78 return $this->build_css_v2( $attributes );
79 }
80 return $this->build_css_v1( $attributes );
81 }
82
83 public function get_status_title_css( $attributes, $device = '' ) {
84 $typographyGlobal = ( isset( $attributes['titleContentTypographyGlobal'] ) ? $attributes['titleContentTypographyGlobal'] : '' );
85 $typography_value = ! empty( $attributes['titleContentTypography'] ) ? Typography::get_css( $attributes['titleContentTypography'], '', $device, $typographyGlobal ) : array();
86 return array_merge(
87 [ 'color' => Color::get_css( isset( $attributes['titleContentColor'] ) ? $attributes['titleContentColor'] : '' ) ],
88 $typography_value
89 );
90 }
91 public function get_status_title_hover_css( $attributes, $device = '' ) {
92 return [ 'color' => Color::get_css( isset( $attributes['titleContentColorH'] ) ? $attributes['titleContentColorH'] : '' ) ];
93 }
94 public function get_deatils_title_css( $attributes, $device = '' ) {
95 $typographyGlobal = ( isset( $attributes['detailsTypographyGlobal'] ) ? $attributes['detailsTypographyGlobal'] : '' );
96 $typography_value = ! empty( $attributes['detailsTypography'] ) ? Typography::get_css( $attributes['detailsTypography'], '', $device, $typographyGlobal ) : array();
97 return array_merge(
98 [ 'color' => Color::get_css( isset( $attributes['detailsColor'] ) ? $attributes['detailsColor'] : '' ) ],
99 $typography_value
100 );
101 }
102
103 public function get_deatils_title_hover_css( $attributes, $device = '' ) {
104 return [ 'color' => Color::get_css( isset( $attributes['detailsColorH'] ) ? $attributes['detailsColorH'] : '' ) ];
105 }
106
107 public function get_email_css( $attributes, $device = '' ) {
108 $typographyGlobal = ( isset( $attributes['emailTypographyGlobal'] ) ? $attributes['emailTypographyGlobal'] : '' );
109 $typography_value = ! empty( $attributes['emailTypography'] ) ? Typography::get_css( $attributes['emailTypography'], '', $device, $typographyGlobal ) : array();
110
111 return array_merge(
112 [ 'color' => Color::get_css( isset( $attributes['emailColor'] ) ? $attributes['emailColor'] : '' ) ],
113 $typography_value
114 );
115 }
116 public function get_email_hover_css( $attributes, $device = '' ) {
117 return [ 'color' => Color::get_css( isset( $attributes['emailColorH'] ) ? $attributes['emailColorH'] : '' ) ];
118 }
119
120 public function render_block_content( $attributes, $content, $block_instance ) {
121 // StoreEngine core falls back to sample content when there's no real
122 // order (e.g. in the editor), so no dummy flag is needed here.
123 $attr_array = [
124 'ids' => Helper::get_attribute_value( $attributes, 'products_ids' ),
125 ];
126
127 $shortcode = '[storeengine_thankyou_order_info ' . Helper::attr_shortcode( $attr_array ) . ']';
128 echo do_shortcode( $shortcode );
129 }
130
131 }
132