PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 2.1.8
bBlocks – Essential Gutenberg Blocks & Patterns Collection v2.1.8
2.1.8 2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 All 108 releases
← All changes | plugin.php +57 -590 2.1.5 → 2.1.8 View file →
@@ -1,607 +1,74 @@
1 1 <?php
2 -
3 2 /**
4 3 * Plugin Name: bBlocks
5 4 * Description: Gutenberg Blocks Collection and Page Builder.
6 - * Version: 2.1.5
5 + * Version: 2.1.8
7 6 * Author: bPlugins
8 7 * Author URI: https://bplugins.com
9 8 * License: GPLv3 or later
10 9 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
11 10 * Text Domain: b-blocks
12 - */
11 + */
12 +
13 13 // ABS PATH
14 -if ( !defined( 'ABSPATH' ) ) {
15 - exit;
14 +if (!defined('ABSPATH')) {
15 + exit;
16 16 }
17 -if ( function_exists( 'b_blocks_fs' ) ) {
18 - register_activation_hook( __FILE__, function () {
19 - if ( is_plugin_active( 'b-blocks/plugin.php' ) ) {
20 - deactivate_plugins( 'b-blocks/plugin.php' );
21 - }
22 - if ( is_plugin_active( 'b-blocks-pro/plugin.php' ) ) {
23 - deactivate_plugins( 'b-blocks-pro/plugin.php' );
24 - }
25 - } );
17 +
18 +if (function_exists('b_blocks_fs')) {
19 + register_activation_hook(__FILE__, function () {
20 + if (is_plugin_active('b-blocks/plugin.php')) {
21 + deactivate_plugins('b-blocks/plugin.php');
22 + }
23 + if (is_plugin_active('b-blocks-pro/plugin.php')) {
24 + deactivate_plugins('b-blocks-pro/plugin.php');
25 + }
26 + });
26 27 } else {
27 - // Constant. On a local dev host, use a changing version so the browser
28 - // always loads freshly-built assets (no stale-bundle caching). Production
29 - // keeps the real, stable version.
30 - $bb_host = ( isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '' );
31 - $bb_isLocal = $bb_host && (0 === strpos( $bb_host, 'localhost' ) || 0 === strpos( $bb_host, '127.0.0.1' ) || preg_match( '/\\.(local|test|ddev\\.site)(:\\d+)?$/', $bb_host ));
32 - define( 'B_BLOCKS_VERSION', ( $bb_isLocal ? time() : '2.1.5' ) );
33 - define( 'B_BLOCKS_DIR_PATH', plugin_dir_path( __FILE__ ) );
34 - define( 'B_BLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) );
35 - define( 'B_BLOCKS_HAS_PRO', 'b-blocks-pro/plugin.php' === plugin_basename( __FILE__ ) );
36 - define( 'B_BLOCKS_BUILD', B_BLOCKS_DIR_URL . 'build/' );
37 - define( 'B_BLOCKS_ASSETS', B_BLOCKS_DIR_URL . 'assets/' );
38 - if ( !function_exists( 'b_blocks_fs' ) ) {
39 - // Create a helper function for easy SDK access.
40 - function b_blocks_fs() {
41 - global $b_blocks_fs;
42 - if ( !isset( $b_blocks_fs ) ) {
43 - // Include Freemius SDK.
44 - require_once dirname( __FILE__ ) . '/freemius/start.php';
45 - $b_blocks_fs = fs_dynamic_init( array(
46 - 'id' => '12845',
47 - 'slug' => 'b-blocks',
48 - 'premium_slug' => 'b-blocks-pro',
49 - 'type' => 'plugin',
50 - 'public_key' => 'pk_d6426b344df4918bc066a7a0b4719',
51 - 'is_premium' => false,
52 - 'premium_suffix' => 'Pro',
53 - 'has_addons' => false,
54 - 'has_paid_plans' => true,
55 - 'trial' => array(
56 - 'days' => 7,
57 - 'is_require_payment' => true,
58 - ),
59 - 'menu' => array(
60 - 'slug' => 'b-blocks',
61 - 'first-path' => 'admin.php?page=b-blocks',
62 - 'contact' => false,
63 - 'support' => false,
64 - ),
65 - 'is_live' => true,
66 - 'is_org_compliant' => true,
67 - ) );
68 - }
69 - return $b_blocks_fs;
70 - }
71 28
72 - // Init Freemius.
73 - b_blocks_fs();
74 - // Signal that SDK was initiated.
75 - do_action( 'b_blocks_fs_loaded' );
76 - }
77 - // Generate Styles
78 - class BBlocksStyleGenerator {
79 - public static $styles = [];
29 + define( 'B_BLOCKS_FILE', __FILE__ );
80 30
81 - public static function addStyle( $selector, $styles ) {
82 - if ( array_key_exists( $selector, self::$styles ) ) {
83 - self::$styles[$selector] = wp_parse_args( self::$styles[$selector], $styles );
84 - } else {
85 - self::$styles[$selector] = $styles;
86 - }
87 - }
31 + require_once plugin_dir_path( __FILE__ ) . 'includes/Constants.php';
32 + require_once B_BLOCKS_DIR_PATH . 'includes/FInit.php';
33 + require_once B_BLOCKS_DIR_PATH . 'includes/StyleGenerator.php';
34 + require_once B_BLOCKS_DIR_PATH . 'includes/Sanitize.php';
88 35
89 - public static function renderStyle() {
90 - $output = '';
91 - foreach ( self::$styles as $selector => $style ) {
92 - $new = '';
93 - foreach ( $style as $property => $value ) {
94 - if ( '' === $value ) {
95 - $new .= "{$property} ;";
96 - } else {
97 - $new .= " {$property}: {$value};";
98 - }
99 - }
100 - $output .= "{$selector} { {$new} }";
101 - }
102 - return $output;
103 - }
36 + // Require files
37 + require_once B_BLOCKS_DIR_PATH . 'includes/Dashboard.php';
38 + require_once B_BLOCKS_DIR_PATH . 'includes/EnqueueScripts.php';
39 + require_once B_BLOCKS_DIR_PATH . 'includes/Utils.php';
40 + require_once B_BLOCKS_DIR_PATH . 'includes/GetCSS.php';
41 + require_once B_BLOCKS_DIR_PATH . 'includes/Ajax.php';
42 + require_once B_BLOCKS_DIR_PATH . 'includes/posts/Posts.php';
43 + require_once B_BLOCKS_DIR_PATH . 'includes/Templates/Templates.php';
44 + require_once B_BLOCKS_DIR_PATH . 'includes/blocks/LoginForm.php';
45 + require_once B_BLOCKS_DIR_PATH . 'includes/blocks/cursor.php';
46 + require_once B_BLOCKS_DIR_PATH . 'includes/Ai.php';
47 + require_once B_BLOCKS_DIR_PATH . 'includes/ApiKeys.php';
48 + require_once B_BLOCKS_DIR_PATH . 'includes/Instagram.php';
49 + require_once B_BLOCKS_DIR_PATH . 'includes/blocks/OptinRateLimit.php';
50 + require_once B_BLOCKS_DIR_PATH . 'includes/blocks/form/FormHandler.php';
51 + require_once B_BLOCKS_DIR_PATH . 'includes/blocks/newsletter/NewsletterHandler.php';
52 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/popup-optin/PopupOptinHandler.php';
53 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/post-filter-grid/PostFilterGrid.php';
54 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/post-masonry-grid/PostMasonryGrid.php';
55 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-add-to-cart/WooAddToCart.php';
56 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-best-sellers/WooBestSellers.php';
57 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-featured-product/WooFeaturedProduct.php';
58 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-mini-cart/WooMiniCart.php';
59 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-product-carousel/WooProductCarousel.php';
60 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-product-grid/WooProductGrid.php';
61 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-product-reviews/WooProductReviews.php';
62 + // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-single-product/WooSingleProduct.php';
104 63
105 - }
64 + // Blocks, settings and uploads
65 + require_once B_BLOCKS_DIR_PATH . 'includes/BlocksList.php';
66 + require_once B_BLOCKS_DIR_PATH . 'includes/RegisterBlocks.php';
67 + require_once B_BLOCKS_DIR_PATH . 'includes/RegisterSettings.php';
68 + require_once B_BLOCKS_DIR_PATH . 'includes/UploadFileTypes.php';
106 69
107 - // Require files
108 - require_once B_BLOCKS_DIR_PATH . 'includes/Dashboard.php';
109 - require_once B_BLOCKS_DIR_PATH . 'includes/EnqueueScripts.php';
110 - require_once B_BLOCKS_DIR_PATH . 'includes/Utils.php';
111 - require_once B_BLOCKS_DIR_PATH . 'includes/GetCSS.php';
112 - require_once B_BLOCKS_DIR_PATH . 'includes/Ajax.php';
113 - require_once B_BLOCKS_DIR_PATH . 'includes/posts/Posts.php';
114 - require_once B_BLOCKS_DIR_PATH . 'includes/Templates/Templates.php';
115 - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/LoginForm.php';
116 - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/cursor.php';
117 - require_once B_BLOCKS_DIR_PATH . 'includes/Ai.php';
118 - require_once B_BLOCKS_DIR_PATH . 'includes/ApiKeys.php';
119 - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/OptinRateLimit.php';
120 - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/form/FormHandler.php';
121 - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/newsletter/NewsletterHandler.php';
122 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/popup-optin/PopupOptinHandler.php';
123 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/post-filter-grid/PostFilterGrid.php';
124 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/post-masonry-grid/PostMasonryGrid.php';
125 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-add-to-cart/WooAddToCart.php';
126 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-best-sellers/WooBestSellers.php';
127 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-featured-product/WooFeaturedProduct.php';
128 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-mini-cart/WooMiniCart.php';
129 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-product-carousel/WooProductCarousel.php';
130 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-product-grid/WooProductGrid.php';
131 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-product-reviews/WooProductReviews.php';
132 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-single-product/WooSingleProduct.php';
133 - // License Activation
134 - if ( file_exists( B_BLOCKS_DIR_PATH . 'includes/LicenseActivation.php' ) && B_BLOCKS_HAS_PRO ) {
135 - require_once B_BLOCKS_DIR_PATH . 'includes/LicenseActivation.php';
136 - }
137 - class BBlocks {
138 - protected static $_instance = null;
139 -
140 - function __construct() {
141 - add_action( 'init', [$this, 'onInit'] );
142 - add_action( 'wp_ajax_bBlocksPipeChecker', [$this, 'bBlocksPipeChecker'] );
143 - add_action( 'wp_ajax_nopriv_bBlocksPipeChecker', [$this, 'bBlocksPipeChecker'] );
144 - add_action( 'admin_init', [$this, 'registerSettings'] );
145 - add_action( 'rest_api_init', [$this, 'registerSettings'] );
146 - add_filter( 'block_categories_all', [$this, 'registerCategories'] );
147 - add_filter( 'upload_mimes', [$this, 'uploadMimes'] );
148 - add_filter(
149 - 'wp_check_filetype_and_ext',
150 - [$this, 'wpCheckFiletypeAndExt'],
151 - 10,
152 - 5
153 - );
154 - add_action( 'wp_ajax_b-blocks-enable-svg-mime-type', [$this, 'enableSvgMimeType'] );
155 - add_filter(
156 - 'plugin_row_meta',
157 - [$this, 'pluginRowMeta'],
158 - 10,
159 - 2
160 - );
161 - }
162 -
163 - function pluginRowMeta( $plugin_meta, $plugin_file ) {
164 - return $plugin_meta;
165 - }
166 -
167 - public static function instance() {
168 - if ( self::$_instance === null ) {
169 - self::$_instance = new self();
170 - }
171 - return self::$_instance;
172 - }
173 -
174 - function bBlocksPipeChecker() {
175 - $nonce = sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? null ) );
176 - if ( !wp_verify_nonce( $nonce, 'wp_ajax' ) ) {
177 - wp_send_json_error( 'Invalid Request' );
178 - }
179 - wp_send_json_success( [
180 - 'isPipe' => BBlocks\Inc\Utils::isPro(),
181 - ] );
182 - }
183 -
184 - function onInit() {
185 - $disabledBlocks = get_option( 'bBlocksDisabledBlocks', [] );
186 - $disabledBlocks = ( is_array( $disabledBlocks ) ? $disabledBlocks : [] );
187 - $premiumBlocks = ( BBlocks\Inc\Utils::isPro() ? [] : [
188 - 'b-blocks/logo-slider',
189 - 'b-blocks/content-ticker',
190 - 'b-blocks/image-hotspot',
191 - 'b-blocks/stacked-cards',
192 - 'b-blocks/key-takeaways',
193 - 'b-blocks/stat-cards',
194 - 'b-blocks/article-card',
195 - 'b-blocks/event-card',
196 - 'b-blocks/file-download-card'
197 - ] );
198 - // Add dependent blocks
199 - if ( in_array( 'b-blocks/row', $disabledBlocks ) && !in_array( 'b-blocks/column', $disabledBlocks ) ) {
200 - $disabledBlocks[] = 'b-blocks/column';
201 - }
202 - if ( in_array( 'b-blocks/services', $disabledBlocks ) && !in_array( 'b-blocks/service', $disabledBlocks ) ) {
203 - $disabledBlocks[] = 'b-blocks/service';
204 - }
205 - $blocks = [
206 - 'alert',
207 - // 'anchor-nav',
208 - 'advanced-image',
209 - 'animated-text',
210 - 'advanced-tabs',
211 - 'article-card',
212 - 'audio-player',
213 - // 'author-box',
214 - 'blockquote',
215 - 'button',
216 - 'button-group',
217 - 'breadcrumb',
218 - // 'business-hours',
219 - // 'call-to-action',
220 - // 'callout',
221 - 'cards',
222 - 'chart',
223 - 'column',
224 - 'container',
225 - 'content-ticker',
226 - 'countdown',
227 - 'counters',
228 - 'data-table',
229 - 'table-head',
230 - 'table-body',
231 - 'table-row',
232 - 'table-cell',
233 - 'table-footer',
234 - 'carousel',
235 - 'carousel-slide',
236 - // 'click-to-share',
237 - // 'code-highlight',
238 - 'comparison-table',
239 - // 'contact-card',
240 - // 'content-filter',
241 - // 'content-filter-item',
242 - // 'cookie-consent-bar',
243 - // 'coupon-code',
244 - 'divider',
245 - 'dual-color-heading',
246 - 'emoji-stack-separator',
247 - 'event-card',
248 - 'expand-content',
249 - 'facebook-embed',
250 - 'facebook-page',
251 - // 'faq-block',
252 - 'feature-boxes',
253 - // 'feature-tabs',
254 - 'file-download-card',
255 - 'flip-boxes',
256 - // 'floating-cta',
257 - 'gif',
258 - 'form-builder',
259 - 'google-map',
260 - 'hero-section',
261 - // 'howto-schema',
262 - 'html',
263 - // 'icon',
264 - 'icon-box',
265 - // 'icon-list',
266 - // 'image-accordion',
267 - // 'image-box',
268 - 'image-comparison',
269 - 'image-gallery',
270 - 'image-hotspot',
271 - // 'image-mask',
272 - 'image-scroller',
273 - // 'image-slider',
274 - 'info-box',
275 - 'infographic',
276 - 'input-field',
277 - 'interactive-checklist',
278 - 'key-takeaways',
279 - // 'logo-grid',
280 - 'logo-slider',
281 - 'lottie-player',
282 - 'list',
283 - 'mailto',
284 - // 'marquee',
285 - 'media-text-section',
286 - // 'milestone-timeline',
287 - // 'modal-popup',
288 - 'navigation',
289 - 'news-ticker',
290 - // 'newsletter-optin',
291 - // 'notification-bar',
292 - 'off-canvas',
293 - // 'parallax-section',
294 - // 'pdf-embed',
295 - // 'popup-optin',
296 - // 'portfolio-gallery',
297 - // 'post-carousel',
298 - // 'post-filter-grid',
299 - // 'post-masonry-grid',
300 - // 'post-navigation',
301 - // 'post-timeline',
302 - 'posts',
303 - 'price-lists',
304 - 'pricing-table',
305 - // 'pricing-toggle',
306 - 'process-steps',
307 - // 'progress-bar',
308 - // 'progress-circle',
309 - // 'promo-strip',
310 - 'qr-code',
311 - // 'reading-progress',
312 - // 'review-box',
313 - 'row',
314 - 'section-heading',
315 - 'skill-bar',
316 - 'service',
317 - 'services',
318 - 'shape-divider',
319 - 'slider',
320 - // 'scroll-reveal',
321 - 'scroll-to-top',
322 - // 'search-bar',
323 - 'social-share',
324 - // 'social-share-bar',
325 - 'whatsapp-chat',
326 - // 'woo-add-to-cart',
327 - // 'woo-best-sellers',
328 - // 'woo-category-grid',
329 - // 'woo-featured-product',
330 - // 'woo-mini-cart',
331 - // 'woo-product-carousel',
332 - // 'woo-product-filter',
333 - // 'woo-product-grid',
334 - // 'woo-product-reviews',
335 - // 'woo-sale-badge',
336 - // 'woo-single-product',
337 - 'star-rating',
338 - 'stacked-cards',
339 - 'stat-cards',
340 - // 'sticky-sidebar',
341 - 'svg-draw',
342 - 'table-of-content',
343 - // 'taxonomy-grid',
344 - 'td-viewer',
345 - 'team-members',
346 - // 'testimonial-card',
347 - // 'testimonial-slider',
348 - 'testimonials',
349 - // 'testimonials-grid',
350 - 'timeline',
351 - 'timeline-item',
352 - 'toggle-content',
353 - 'accordion-block',
354 - 'video',
355 - // 'video-popup',
356 - 'text-path',
357 - ];
358 - foreach ( $blocks as $block ) {
359 - if ( !in_array( "b-blocks/{$block}", $disabledBlocks ) && !in_array( "b-blocks/{$block}", $premiumBlocks ) ) {
360 - $registered = register_block_type( __DIR__ . "/build/{$block}" );
361 - // Every block shares one editor bundle, so the per-block
362 - // handle is dropped to keep it from being loaded again.
363 - // The handle WordPress generates comes from the block's
364 - // NAME, which is not always its directory — data-table is
365 - // registered as b-blocks/table — so deriving it from the
366 - // directory silently misses those and the bundle runs
367 - // twice, re-registering every inline format.
368 - $name = ( $registered instanceof WP_Block_Type ? $registered->name : "b-blocks/{$block}" );
369 - wp_deregister_script( generate_block_asset_handle( $name, 'editorScript' ) );
370 - }
371 - }
372 - // The newsletter-optin view.js uses @wordpress/i18n – register translations
373 - // for the auto-generated view-script handle so frontend error/success strings
374 - // are translatable. The handle is derived from the block name by WordPress core.
375 - // if ( ! in_array( 'b-blocks/newsletter-optin', $disabledBlocks ) ) {
376 - // wp_set_script_translations(
377 - // 'b-blocks-newsletter-optin-view-script',
378 - // 'b-blocks',
379 - // B_BLOCKS_DIR_PATH . 'languages'
380 - // );
381 - // }
382 - // The popup-optin view.js imports @wordpress/i18n for frontend
383 - // validation / status strings, so its view-script handle needs
384 - // translations registered.
385 - // if ( ! in_array( 'b-blocks/popup-optin', $disabledBlocks ) ) {
386 - // wp_set_script_translations(
387 - // 'b-blocks-popup-optin-view-script',
388 - // 'b-blocks',
389 - // B_BLOCKS_DIR_PATH . 'languages'
390 - // );
391 - // }
392 - // The floating-cta view.js imports @wordpress/i18n (__('Button') and __('Dismiss'))
393 - // so its view-script handle also needs translations registered.
394 - // if ( ! in_array( 'b-blocks/floating-cta', $disabledBlocks ) ) {
395 - // wp_set_script_translations(
396 - // 'b-blocks-floating-cta-view-script',
397 - // 'b-blocks',
398 - // B_BLOCKS_DIR_PATH . 'languages'
399 - // );
400 - // }
401 - // The image-slider view.js imports @wordpress/i18n for lightbox aria-labels
402 - // so its view-script handle needs translations registered.
403 - // if ( ! in_array( 'b-blocks/image-slider', $disabledBlocks ) ) {
404 - // wp_set_script_translations(
405 - // 'b-blocks-image-slider-view-script',
406 - // 'b-blocks',
407 - // B_BLOCKS_DIR_PATH . 'languages'
408 - // );
409 - // }
410 - // The testimonial-slider view.js imports @wordpress/i18n for the
411 - // play/pause toggle aria-labels, so its view-script handle needs
412 - // translations registered.
413 - // if ( ! in_array( 'b-blocks/testimonial-slider', $disabledBlocks ) ) {
414 - // wp_set_script_translations(
415 - // 'b-blocks-testimonial-slider-view-script',
416 - // 'b-blocks',
417 - // B_BLOCKS_DIR_PATH . 'languages'
418 - // );
419 - // }
420 - // The post-filter-grid view.js imports @wordpress/i18n for the
421 - // aria-live status announcements, so its view-script handle needs
422 - // translations registered.
423 - // if ( ! in_array( 'b-blocks/post-filter-grid', $disabledBlocks ) ) {
424 - // wp_set_script_translations(
425 - // 'b-blocks-post-filter-grid-view-script',
426 - // 'b-blocks',
427 - // B_BLOCKS_DIR_PATH . 'languages'
428 - // );
429 - // }
430 - // The post-masonry-grid view.js imports @wordpress/i18n for the
431 - // aria-live status announcements, so its view-script handle needs
432 - // translations registered.
433 - // if ( ! in_array( 'b-blocks/post-masonry-grid', $disabledBlocks ) ) {
434 - // wp_set_script_translations(
435 - // 'b-blocks-post-masonry-grid-view-script',
436 - // 'b-blocks',
437 - // B_BLOCKS_DIR_PATH . 'languages'
438 - // );
439 - // }
440 - // The woo-add-to-cart view.js uses @wordpress/i18n for the aria-live
441 - // add-to-cart status announcements, so its view-script handle needs
442 - // translations registered.
443 - // if ( ! in_array( 'b-blocks/woo-add-to-cart', $disabledBlocks ) ) {
444 - // wp_set_script_translations(
445 - // 'b-blocks-woo-add-to-cart-view-script',
446 - // 'b-blocks',
447 - // B_BLOCKS_DIR_PATH . 'languages'
448 - // );
449 - // }
450 - // The woo-mini-cart view.js uses @wordpress/i18n for the cart
451 - // aria-label and aria-live announcements, so its view-script
452 - // handle needs translations registered.
453 - // if ( ! in_array( 'b-blocks/woo-mini-cart', $disabledBlocks ) ) {
454 - // wp_set_script_translations(
455 - // 'b-blocks-woo-mini-cart-view-script',
456 - // 'b-blocks',
457 - // B_BLOCKS_DIR_PATH . 'languages'
458 - // );
459 - // }
460 - // The woo-best-sellers view.js imports @wordpress/i18n for the
461 - // aria-live add-to-cart status announcements ("added to cart",
462 - // error messages), so its view-script handle needs translations
463 - // registered.
464 - // if ( ! in_array( 'b-blocks/woo-best-sellers', $disabledBlocks ) ) {
465 - // wp_set_script_translations(
466 - // 'b-blocks-woo-best-sellers-view-script',
467 - // 'b-blocks',
468 - // B_BLOCKS_DIR_PATH . 'languages'
469 - // );
470 - // }
471 - // The woo-featured-product view.js uses @wordpress/i18n for the
472 - // aria-live add-to-cart status announcements, so its view-script
473 - // handle needs translations registered.
474 - // if ( ! in_array( 'b-blocks/woo-featured-product', $disabledBlocks ) ) {
475 - // wp_set_script_translations(
476 - // 'b-blocks-woo-featured-product-view-script',
477 - // 'b-blocks',
478 - // B_BLOCKS_DIR_PATH . 'languages'
479 - // );
480 - // }
481 - // The woo-product-grid view.js uses @wordpress/i18n for the aria-live
482 - // add-to-cart status announcements, so its view-script handle needs
483 - // translations registered.
484 - // if ( ! in_array( 'b-blocks/woo-product-grid', $disabledBlocks ) ) {
485 - // wp_set_script_translations(
486 - // 'b-blocks-woo-product-grid-view-script',
487 - // 'b-blocks',
488 - // B_BLOCKS_DIR_PATH . 'languages'
489 - // );
490 - // }
491 - // The woo-product-carousel view.js uses @wordpress/i18n for slide
492 - // aria-live announcements and the add-to-cart status region, so its
493 - // view-script handle needs translations registered.
494 - // if ( ! in_array( 'b-blocks/woo-product-carousel', $disabledBlocks ) ) {
495 - // wp_set_script_translations(
496 - // 'b-blocks-woo-product-carousel-view-script',
497 - // 'b-blocks',
498 - // B_BLOCKS_DIR_PATH . 'languages'
499 - // );
500 - // }
501 - // The sticky-sidebar view.js uses @wordpress/i18n for the scrollable
502 - // sidebar aria-label, so its view-script handle needs translations registered.
503 - // if ( ! in_array( 'b-blocks/sticky-sidebar', $disabledBlocks ) ) {
504 - // wp_set_script_translations(
505 - // 'b-blocks-sticky-sidebar-view-script',
506 - // 'b-blocks',
507 - // B_BLOCKS_DIR_PATH . 'languages'
508 - // );
509 - // }
510 - // The search-bar view.js imports @wordpress/i18n for the live-search
511 - // no-results / aria-live result-count strings, so its view-script
512 - // handle needs translations registered.
513 - // if ( ! in_array( 'b-blocks/search-bar', $disabledBlocks ) ) {
514 - // wp_set_script_translations(
515 - // 'b-blocks-search-bar-view-script',
516 - // 'b-blocks',
517 - // B_BLOCKS_DIR_PATH . 'languages'
518 - // );
519 - // }
520 - }
521 -
522 - function registerSettings() {
523 - register_setting( 'bBlocksUtils', 'bBlocksUtils', [
524 - 'show_in_rest' => [
525 - 'name' => 'bBlocksUtils',
526 - 'schema' => [
527 - 'type' => 'string',
528 - ],
529 - ],
530 - 'type' => 'string',
531 - 'default' => wp_json_encode( [
532 - 'nonce' => wp_create_nonce( 'wp_ajax' ),
533 - ] ),
534 - 'sanitize_callback' => 'sanitize_text_field',
535 - ] );
536 - }
537 -
538 - function registerCategories( $categories ) {
539 - return array_merge( [[
540 - 'slug' => 'bBlocks',
541 - 'title' => __( 'bBlocks', 'b-blocks' ),
542 - ]], $categories );
543 - }
544 -
545 - // Register categories
546 - //Allow some additional file types for upload
547 - function uploadMimes( $mimes ) {
548 - $mimes['glb'] = 'model/gltf-binary';
549 - // 3D Viewer
550 - $mimes['gltf'] = 'model/gltf-binary';
551 - // 3D Viewer
552 - $mimes['json'] = 'application/json';
553 - // Lottie Player
554 - $mimes['lottie'] = 'application/json';
555 - // Lottie Player
556 - if ( get_transient( 'b-blocks-enable-svg-mime-type' ) === 'true' ) {
557 - $mimes['svg'] = 'image/svg+xml';
558 - }
559 - return $mimes;
560 - }
561 -
562 - function wpCheckFiletypeAndExt(
563 - $data,
564 - $file,
565 - $filename,
566 - $mimes,
567 - $real_mime = null
568 - ) {
569 - // If file extension is 2 or more
570 - $f_sp = explode( '.', $filename );
571 - $f_exp_count = count( $f_sp );
572 - if ( $f_exp_count <= 1 ) {
573 - return $data;
574 - } else {
575 - $f_name = $f_sp[0];
576 - $ext = $f_sp[$f_exp_count - 1];
577 - }
578 - if ( 'glb' === $ext || 'gltf' === $ext ) {
579 - // 3D Viewer
580 - $type = 'model/gltf-binary';
581 - $proper_filename = '';
582 - return compact( 'ext', 'type', 'proper_filename' );
583 - } elseif ( 'json' === $ext || 'lottie' === $ext ) {
584 - // Lottie Player
585 - $type = 'application/json';
586 - $proper_filename = '';
587 - return compact( 'ext', 'type', 'proper_filename' );
588 - } else {
589 - return $data;
590 - }
591 - }
592 -
593 - public function enableSvgMimeType() {
594 - if ( !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? null ) ), 'wp_ajax' ) ) {
595 - wp_send_json_error();
596 - }
597 - if ( !current_user_can( 'manage_options' ) ) {
598 - wp_send_json_error();
599 - }
600 - set_transient( 'b-blocks-enable-svg-mime-type', 'true', 80 );
601 - wp_send_json_success();
602 - }
603 -
604 - }
605 -
606 - BBlocks::instance();
607 -}
70 + // License Activation
71 + if (file_exists(B_BLOCKS_DIR_PATH . 'includes/LicenseActivation.php') && B_BLOCKS_HAS_PRO ) {
72 + require_once B_BLOCKS_DIR_PATH . 'includes/LicenseActivation.php';
73 + }
74 +}