PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.15.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.15.0
2.15.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 All 82 releases
← All changes | includes/import/image-parsers/ablocks/flip-box-parser.php +57 -0 2.7.6 → 2.15.0 View file →
@@ -1,0 +1,57 @@
1 +<?php
2 +
3 +namespace ABlocks\import\ImageParsers\ablocks;
4 +
5 +use ABlocks\import\ImageParsers\AbstractImageParser;
6 +
7 +class FlipBoxParser 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']['frontCardBackground'] ) || 'image' !== $this->block['attrs']['frontCardBackground']['backgroundType'] ) {
16 + return;
17 + }
18 +
19 + $imgUrl = $this->block['attrs']['frontCardBackground']['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']['frontCardBackground']['imgId'] = $attachment_id;
32 + $this->block['attrs']['frontCardBackground']['imgUrl'] = $attachment_url;
33 + }
34 + }
35 +
36 + private function parse_background_hover() {
37 + if ( ! isset( $this->block['attrs']['frontCardBackground'] ) || 'image' !== $this->block['attrs']['frontCardBackground']['backgroundTypeH'] ) {
38 + return;
39 + }
40 +
41 + $imgUrl = $this->block['attrs']['frontCardBackground']['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']['frontCardBackground']['imgIdH'] = $attachment_id;
54 + $this->block['attrs']['frontCardBackground']['imgUrlH'] = $attachment_url;
55 + }
56 + }
57 +}