PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.0
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.0
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
← All changes | Inc/Core/FB/BoxBlocksParser.php +29 -19 1.0.42.1.0 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * @package FireBox
4 - * @version 1.0.4 Free
4 + * @version 2.1.0 Free
5 5 *
6 6 * @author FirePlugins <info@fireplugins.com>
7 7 * @link https://www.fireplugins.com
8 - * @copyright Copyright © 2021 FirePlugins All Rights Reserved
8 + * @copyright Copyright © 2023 FirePlugins All Rights Reserved
9 9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 10 */
11 11
12 12 namespace FireBox\Core\FB;
@@ -20,9 +20,9 @@
20 20 {
21 21 public function __construct()
22 22 {
23 23 // filter the post content by setting supported block attributes
24 - add_filter('render_block', [$this, 'modify_block_output'], 10, 2);
24 + add_action('render_block', [$this, 'modify_block_output'], 10, 2);
25 25 }
26 26
27 27 /**
28 28 * Filters the block output by appending out custom data attributes
@@ -42,8 +42,10 @@
42 42
43 43 $blockName = $block['blockName'];
44 44
45 45 $parsable_blocks = [
46 + 'firebox/buttons',
47 + 'firebox/image',
46 48 'core/buttons',
47 49 'core/image'
48 50 ];
49 51
@@ -54,9 +56,9 @@
54 56
55 57 /**
56 58 * Handle Core Buttons Block
57 59 */
58 - if ($blockName == 'core/buttons')
60 + if (in_array($blockName, ['core/buttons', 'firebox/buttons']))
59 61 {
60 62 $buttons = isset($block['innerBlocks']) ? $block['innerBlocks'] : [];
61 63 if (!$buttons)
62 64 {
@@ -70,9 +72,9 @@
70 72 }
71 73 /**
72 74 * Handle Core Image Block
73 75 */
74 - else if ($blockName == 'core/image')
76 + else if (in_array($blockName, ['core/image', 'firebox/image']))
75 77 {
76 78 $new_block_html = $block['innerHTML'];
77 79
78 80 // check if we have an anchor element and add attributes to this elem.
@@ -105,24 +107,27 @@
105 107
106 108 $new_block_html = $block['innerHTML'];
107 109
108 110 // box
109 - if ($atts['box'])
111 + if (!is_null($atts['box']) && $atts['box'] !== 'none')
110 112 {
111 - $new_block_html = str_replace('<' . $element . ' ', '<' . $element . ' data-fbox="' . esc_attr($atts['box']) . '" ', $new_block_html);
112 - }
113 + if ($atts['box'] !== 'current')
114 + {
115 + $new_block_html = str_replace('<' . $element . ' ', '<' . $element . ' data-fbox="' . esc_attr($atts['box']) . '" ', $new_block_html);
116 + }
113 117
114 - // cmd
115 - if ($atts['cmd'])
116 - {
117 - $new_block_html = str_replace('<' . $element . ' ', '<' . $element . ' data-fbox-cmd="' . esc_attr($atts['cmd']) . '" ', $new_block_html);
118 + // cmd
119 + if ($atts['cmd'])
120 + {
121 + $new_block_html = str_replace('<' . $element . ' ', '<' . $element . ' data-fbox-cmd="' . esc_attr($atts['cmd']) . '" ', $new_block_html);
122 + }
123 +
124 + // prevent default
125 + $new_block_html = str_replace('<' . $element . ' ', '<' . $element . ' data-fbox-prevent="1" ', $new_block_html);
118 126 }
119 127
120 - // prevent default
121 - $new_block_html = str_replace('<' . $element . ' ', '<' . $element . ' data-fbox-prevent="' . esc_attr((int) $atts['preventDefault']) . '" ', $new_block_html);
122 -
123 128 // class
124 - if ($atts['class'])
129 + if (isset($atts['class']) && !empty($atts['class']))
125 130 {
126 131 $new_block_html = preg_replace('/<' . $element . '(.*)class="/', "<" . $element . "$1class=\"" . esc_attr($atts['class']) . ' ', $new_block_html);
127 132 }
128 133
@@ -138,14 +143,19 @@
138 143 */
139 144 private function getBlockAttributes($block)
140 145 {
141 146 $atts = [];
147 +
148 + $atts['enabled'] = isset($block['attrs']['dataFBoxEnabled']) ?: false;
149 +
150 + if (!$atts['enabled'])
151 + {
152 + return $atts;
153 + }
142 154
143 - $atts['enabled'] = isset($block['attrs']['dataFBoxEnabled']) ?: false;
144 155 $atts['box'] = isset($block['attrs']['dataFBox']) ? $block['attrs']['dataFBox'] : null;
145 - $atts['cmd'] = isset($block['attrs']['dataFBoxCmd']) ? $block['attrs']['dataFBoxCmd'] : 'close';
156 + $atts['cmd'] = isset($block['attrs']['dataFBoxCmd']) ? $block['attrs']['dataFBoxCmd'] : 'open';
146 157 $atts['class'] = isset($block['attrs']['dataFBoxClass']) ? $block['attrs']['dataFBoxClass'] : '';
147 - $atts['preventDefault'] = isset($block['attrs']['dataFBoxPreventDefault']) ? $block['attrs']['dataFBoxPreventDefault'] : 1;
148 158
149 159 return $atts;
150 160 }
151 161 }