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

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

91 lines 2.6 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 );
24 $css_generator->add_class_styles(
25 '{{WRAPPER}} .ablocks-block--certificate__background-image',
26 $this->get_certificate_bg_img_css( $attributes ),
27 $this->get_certificate_bg_img_css( $attributes, 'Tablet' ),
28 $this->get_certificate_bg_img_css( $attributes, 'Mobile' )
29 );
30 $css_generator->add_class_styles(
31 '{{WRAPPER}} .ablocks-block--certificate__background-image-inner-block',
32 $this->get_certificate_inner_block_css( $attributes ),
33 $this->get_certificate_inner_block_css( $attributes, 'Tablet' ),
34 $this->get_certificate_inner_block_css( $attributes, 'Mobile' )
35 );
36
37 return $css_generator->generate_css();
38 }
39
40
41
42 public function get_certificate_wrapper_css( $attributes, $device = '' ) {
43 $css = array();
44 $css['width'] = '100%';
45 $css['height'] = '100% !important';
46 $css['padding'] = '0px !important';
47 return $css;
48 }
49 public function get_certificate_bg_img_css( $attributes, $device = '' ) {
50 $css = array();
51 if ( ! empty( $attributes['backgroundImage'] ) ) {
52 $css['background-image'] = 'url(' . $attributes['backgroundImage'] . ')';
53 }
54
55 if ( $attributes['pageOrientation'] === 'P' ) {
56 $css['background-size'] = 'inherit';
57 $css['background-repeat'] = 'repeat !important';
58 $css['background-position'] = 'center !important';
59
60 } else {
61 $css['background-image-resize'] = '6';
62 $css['background-repeat'] = 'no-repeat !important';
63 }
64 $css['width'] = '100%';
65 $css['height'] = '100% !important';
66 return $css;
67 }
68
69 public function get_certificate_inner_block_css( $attributes, $device = '' ) {
70 $css = array();
71 if ( ! empty( $attributes['containerWidth'] ) ) {
72 $css['width'] = $attributes['containerWidth'] . '%';
73 }
74 $css['height'] = '100%';
75 $css['box-sizing'] = 'border-box';
76 $css['padding'] = '100px';
77 $css['margin'] = 'auto !important';
78 if ( ! empty( $attributes['certificate_padding'] ) ) {
79 $cssPadding = Dimensions::get_css( $attributes['certificate_padding'], 'padding', $device );
80 }
81
82 return array_merge(
83 $css,
84 $cssPadding
85 );
86 }
87
88
89
90 }
91