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 / import / image-parsers / ablocks / modal-parser.php

modal-parser.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.14.0, at includes/import/image-parsers/ablocks/modal-parser.php

58 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ABlocks\import\ImageParsers\ablocks;
4
5 use ABlocks\import\ImageParsers\AbstractImageParser;
6
7 class ModalParser extends AbstractImageParser {
8
9 public function parse() {
10 $this->parse_background();
11 $this->parse_background_hover();
12 }
13
14 private function parse_background() {
15 if ( ! isset( $this->block['attrs']['panelBackground'] ) || 'image' !== $this->block['attrs']['panelBackground']['backgroundType'] ) {
16 return;
17 }
18
19 $imgUrl = $this->block['attrs']['panelBackground']['imgUrl'];
20 if ( empty( $imgUrl ) ) {
21 return;
22 }
23
24 if ( $this->check_external_url( $imgUrl ) ) {
25 $attachment_id = $this->upload_file( $imgUrl );
26 if ( is_wp_error( $attachment_id ) ) {
27 return;
28 }
29
30 $attachment_url = wp_get_attachment_url( $attachment_id );
31 $this->block['attrs']['panelBackground']['imgId'] = $attachment_id;
32 $this->block['attrs']['panelBackground']['imgUrl'] = $attachment_url;
33 }
34 }
35
36 private function parse_background_hover() {
37 if ( ! isset( $this->block['attrs']['panelBackground'] ) || 'image' !== $this->block['attrs']['panelBackground']['backgroundTypeH'] ) {
38 return;
39 }
40
41 $imgUrl = $this->block['attrs']['panelBackground']['imgUrlH'];
42 if ( empty( $imgUrl ) ) {
43 return;
44 }
45
46 if ( $this->check_external_url( $imgUrl ) ) {
47 $attachment_id = $this->upload_file( $imgUrl );
48 if ( is_wp_error( $attachment_id ) ) {
49 return;
50 }
51
52 $attachment_url = wp_get_attachment_url( $attachment_id );
53 $this->block['attrs']['panelBackground']['imgIdH'] = $attachment_id;
54 $this->block['attrs']['panelBackground']['imgUrlH'] = $attachment_url;
55 }
56 }
57 }
58