@@ -219,13 +219,22 @@ function botiga_filter_loop_add_to_cart( $button, $product, $args ) {
219
219
function botiga_page_has_woo_blocks () {
220
220
global $ post ;
221
221
222
- if ( $ post ) {
223
- if ( isset ( $ post ->post_content ) && strpos ( $ post ->post_content , 'woocommerce/ ' ) ) {
224
- return true ;
225
- }
222
+ $ result = false ;
223
+ if ( $ post ) {
224
+ if ( isset ( $ post ->post_content ) && strpos ( $ post ->post_content , 'woocommerce/ ' ) ) {
225
+ $ result = true ;
226
+ }
226
227
}
227
228
228
- return false ;
229
+ /**
230
+ * Hook 'botiga_page_has_woo_blocks' to allow filtering the page whether a page has WooCommerce blocks.
231
+ *
232
+ * @param bool $result Whether the page has a WooCommerce block.
233
+ * @param string $post_content string The content of the post.
234
+ *
235
+ * @since 2.3.4
236
+ */
237
+ return apply_filters ( 'botiga_page_has_woo_blocks ' , $ result , $ post ->post_content );
229
238
}
230
239
231
240
/**
@@ -240,17 +249,27 @@ function botiga_page_has_woo_shortcode() {
240
249
'latest_arrivals ' , // third-party shortcode
241
250
);
242
251
243
- if ( $ post ) {
244
- if ( isset ( $ post ->post_content ) ) {
245
- foreach ( $ shortcodes as $ shortcode ) {
246
- if ( has_shortcode ( $ post ->post_content , $ shortcode ) ) {
247
- return true ;
248
- }
249
- }
250
- }
252
+ $ result = false ;
253
+ if ( $ post ) {
254
+ if ( isset ( $ post ->post_content ) ) {
255
+ foreach ( $ shortcodes as $ shortcode ) {
256
+ if ( has_shortcode ( $ post ->post_content , $ shortcode ) ) {
257
+ $ result = true ;
258
+ break ;
259
+ }
260
+ }
261
+ }
251
262
}
252
263
253
- return false ;
264
+ /**
265
+ * Hook 'botiga_page_has_woo_shortcode' to allow filtering the page whether a page has the defined shortcodes.
266
+ *
267
+ * @param bool $result Whether the page has a WooCommerce shortcode.
268
+ * @param string $post_content string The content of the post.
269
+ *
270
+ * @since 2.3.4
271
+ */
272
+ return apply_filters ( 'botiga_page_has_woo_shortcode ' , $ result , $ post ->post_content );
254
273
}
255
274
256
275
/**
0 commit comments