PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/adapter/module/helper.php +38 -0 1.6.6 → 1.8.16 View file →
@@ -173,7 +173,45 @@
173 173 $result->params = json_encode($result->params);
174 174 }
175 175 }
176 176
177 + /**
178 + * If we are not able to find a widget, then we should look into the
179 + * posts and pages in search of a Gutenberg block and extract the
180 + * settings from there.
181 + *
182 + * @since 10.1.52
183 + */
184 + if (!$result->id)
185 + {
186 + // split the module name in chunks:
187 + // [MOD] | [COMPONENT] | ...
188 + $block = explode('_', $name);
189 + // construct gutenberg block identifier
190 + $block = $block[1] . '/' . implode('-', array_slice($block, 2)) . '-widget-block';
191 +
192 + // look for a post/page that contains the block name of the requested module
193 + $query = new WP_Query([
194 + 's' => '<!-- wp:' . $block,
195 + ]);
196 +
197 + // fetch all the matching posts, if any
198 + foreach ($query->get_posts() as $post)
199 + {
200 + // use the same ID of the post
201 + $result->id = $post->ID;
202 +
203 + // escape characters of the module block name for being safely used in a regex
204 + $regex = preg_quote($block, '/');
205 +
206 + // extract parameters from block name
207 + if (preg_match("/<!-- wp:$regex\s+({(?:.*?)})(?:.*?)-->/", $post->post_content, $match))
208 + {
209 + // keep the parameters encoded in JSON format for Joomla compatibility
210 + $result->params = $match[1];
211 + }
212 + }
213 + }
214 +
177 215 return $result;
178 216 }
179 217 }