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-continue-button/block.php +128 -0 2.7.5 → 2.14.0 View file →
@@ -1,0 +1,128 @@
1 +<?php
2 +namespace ABlocks\Blocks\StoreengineContinueButton;
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +
8 +use ABlocks\Classes\BlockBaseAbstract;
9 +use ABlocks\Classes\CssGenerator;
10 +use ABlocks\Helper;
11 +use ABlocks\Controls\Typography;
12 +use ABlocks\Controls\Background;
13 +use ABlocks\Controls\Border;
14 +use ABlocks\Controls\Dimensions;
15 +use ABlocks\Controls\Range;
16 +use ABlocks\Controls\BoxShadow;
17 +use ABlocks\Controls\Color;
18 +
19 +class Block extends BlockBaseAbstract {
20 + protected $block_name = 'storeengine-continue-button';
21 +
22 + public function build_css( $attributes ) {
23 + $css_generator = new CssGenerator( $attributes, $this->block_name );
24 +
25 + $css_generator->add_class_styles(
26 + '{{WRAPPER}} .storeengine-continue-shopping-shortcode',
27 + $this->get_coutineu_button_wrapper_css( $attributes ),
28 + $this->get_coutineu_button_wrapper_css( $attributes, 'Tablet' ),
29 + $this->get_coutineu_button_wrapper_css( $attributes, 'Mobile' ),
30 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_coutineu_button_wrapper_css( $attributes, $device ); } )
31 + );
32 + $css_generator->add_class_styles(
33 + '{{WRAPPER}} .storeengine-continue-shopping-shortcode a',
34 + $this->get_coutineu_button_css( $attributes ),
35 + $this->get_coutineu_button_css( $attributes, 'Tablet' ),
36 + $this->get_coutineu_button_css( $attributes, 'Mobile' ),
37 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_coutineu_button_css( $attributes, $device ); } )
38 + );
39 + $css_generator->add_class_styles(
40 + '{{WRAPPER}} .storeengine-continue-shopping-shortcode a:hover',
41 + $this->get_coutineu_button_hover_css( $attributes ),
42 + $this->get_coutineu_button_hover_css( $attributes, 'Tablet' ),
43 + $this->get_coutineu_button_hover_css( $attributes, 'Mobile' ),
44 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_coutineu_button_hover_css( $attributes, $device ); } )
45 + );
46 +
47 + return $css_generator->generate_css();
48 + }
49 + public function get_coutineu_button_wrapper_css( $attributes, $device = '' ) {
50 + $css = [];
51 + $alignment_css = [];
52 +
53 + $css['width'] = '100%';
54 + $css['display'] = 'flex';
55 +
56 + if ( ! empty( $attributes['buttonAlignment'][ 'value' . $device ] ) ) {
57 + $alignment_css['justify-content'] = $attributes['buttonAlignment'][ 'value' . $device ];
58 + }
59 +
60 + return array_merge(
61 + $alignment_css,
62 + $css,
63 + );
64 +
65 + }
66 +
67 + public function get_coutineu_button_css( $attributes, $device = '' ) {
68 + $css = [];
69 +
70 + if ( $attributes['buttonColor'] !== '' ) {
71 + $css['color'] = $attributes['buttonColor'];
72 + }
73 + // if ( $attributes['buttonWidth'] !== '' ) {
74 + // $css['width'] = $attributes['buttonWidth'] . '%';
75 + // }
76 + if ( $attributes['buttonBackground'] !== '' ) {
77 + $css['background'] = $attributes['buttonBackground'];
78 + }
79 + $typography = isset( $attributes['buttonTypography'] ) && is_array( $attributes['buttonTypography'] )
80 + ? $attributes['buttonTypography']
81 + : [];
82 + $typographyValueGlobal = ( isset( $attributes['buttonTypographyGlobal'] ) ? $attributes['buttonTypographyGlobal'] : '' );
83 +
84 + $typography_value = array_merge( $typography, [ 'font-weight' => '400' ] );
85 +
86 + if ( ! empty( $attributes['padding'] ) ) {
87 + $cssPadding = Dimensions::get_css( $attributes['padding'], 'padding', $device );
88 + }
89 +
90 + return array_merge(
91 + [ 'color' => Color::get_css( isset( $attributes['buttonColor'] ) ? $attributes['buttonColor'] : '' ) ],
92 + [ 'background' => Color::get_css( isset( $attributes['buttonBackground'] ) ? $attributes['buttonBackground'] : '' ) ],
93 + $css,
94 + Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
95 + Border::get_css( $attributes['buttonBorder'], '', $device ),
96 + $cssPadding,
97 + BoxShadow::get_css( $attributes['boxShadow'], '', $device ),
98 + Range::get_css([
99 + 'attributeValue' => $attributes['buttonWidth'],
100 + 'attribute_object_key' => 'value',
101 + 'isResponsive' => true,
102 + 'hasUnit' => true,
103 + 'defaultValue' => 100,
104 + 'unitDefaultValue' => '%',
105 + 'property' => 'width',
106 + 'device' => $device,
107 + ])
108 + );
109 + }
110 +
111 + public function get_coutineu_button_hover_css( $attributes, $device = '' ) {
112 + return array_merge(
113 + [ 'color' => Color::get_css( isset( $attributes['buttonColorH'] ) ? $attributes['buttonColorH'] : '' ) ],
114 + [ 'background' => Color::get_css( isset( $attributes['buttonBackgroundH'] ) ? $attributes['buttonBackgroundH'] : '' ) ],
115 + Border::get_hover_css( $attributes['buttonBorder'] ?? [], '', $device ),
116 + BoxShadow::get_hover_css( $attributes['boxShadow'], '', $device ),
117 + );
118 +
119 + }
120 + public function render_block_content( $attributes, $content, $block_instance ) {
121 + $attr_array = [
122 + // 'ids' => Helper::get_attribute_value( $attributes, 'products_ids' ),
123 + ];
124 + $shortcode = '[storeengine_continue_shopping ' . Helper::attr_shortcode( $attr_array ) . ']';
125 + echo do_shortcode( $shortcode );
126 + }
127 +
128 +}