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
ablocks / includes / blocks / academy-certificate / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.14.0, at includes/blocks/academy-certificate/block.php

94 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\AcademyCertificate;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
10 use ABlocks\Controls\Dimensions;
11
12 class Block extends BlockBaseAbstract {
13 protected $block_name = 'academy-certificate';
14
15 public function build_css( $attributes ) {
16 $css_generator = new CssGenerator( $attributes );
17
18 $css_generator->add_class_styles(
19 '{{WRAPPER}}',
20 $this->get_certificate_wrapper_css( $attributes ),
21 $this->get_certificate_wrapper_css( $attributes, 'Tablet' ),
22 $this->get_certificate_wrapper_css( $attributes, 'Mobile' ),
23 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_certificate_wrapper_css( $attributes, $device ); } )
24 );
25 $css_generator->add_class_styles(
26 '{{WRAPPER}} .ablocks-block--certificate__background-image',
27 $this->get_certificate_bg_img_css( $attributes ),
28 $this->get_certificate_bg_img_css( $attributes, 'Tablet' ),
29 $this->get_certificate_bg_img_css( $attributes, 'Mobile' ),
30 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_certificate_bg_img_css( $attributes, $device ); } )
31 );
32 $css_generator->add_class_styles(
33 '{{WRAPPER}} .ablocks-block--certificate__background-image-inner-block',
34 $this->get_certificate_inner_block_css( $attributes ),
35 $this->get_certificate_inner_block_css( $attributes, 'Tablet' ),
36 $this->get_certificate_inner_block_css( $attributes, 'Mobile' ),
37 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_certificate_inner_block_css( $attributes, $device ); } )
38 );
39
40 return $css_generator->generate_css();
41 }
42
43
44
45 public function get_certificate_wrapper_css( $attributes, $device = '' ) {
46 $css = array();
47 $css['width'] = '100%';
48 $css['height'] = '100% !important';
49 $css['padding'] = '0px !important';
50 return $css;
51 }
52 public function get_certificate_bg_img_css( $attributes, $device = '' ) {
53 $css = array();
54 if ( ! empty( $attributes['backgroundImage'] ) ) {
55 $css['background-image'] = 'url(' . $attributes['backgroundImage'] . ')';
56 }
57
58 if ( $attributes['pageOrientation'] === 'P' ) {
59 $css['background-size'] = 'inherit';
60 $css['background-repeat'] = 'repeat !important';
61 $css['background-position'] = 'center !important';
62
63 } else {
64 $css['background-image-resize'] = '6';
65 $css['background-repeat'] = 'no-repeat !important';
66 }
67 $css['width'] = '100%';
68 $css['height'] = '100% !important';
69 return $css;
70 }
71
72 public function get_certificate_inner_block_css( $attributes, $device = '' ) {
73 $css = array();
74 if ( ! empty( $attributes['containerWidth'] ) ) {
75 $css['width'] = $attributes['containerWidth'] . '%';
76 }
77 $css['height'] = '100%';
78 $css['box-sizing'] = 'border-box';
79 $css['padding'] = '100px';
80 $css['margin'] = 'auto !important';
81 if ( ! empty( $attributes['certificate_padding'] ) ) {
82 $cssPadding = Dimensions::get_css( $attributes['certificate_padding'], 'padding', $device );
83 }
84
85 return array_merge(
86 $css,
87 $cssPadding
88 );
89 }
90
91
92
93 }
94