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 -580 2.1.1 → 2.1.8 View file →
@@ -1,597 +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.1
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' ) || (bool) preg_match( '/\\.(local|test|ddev\\.site)(:\\d+)?$/', $bb_host ));
32 - define( 'B_BLOCKS_VERSION', ( $bb_isLocal ? (string) time() : '2.1.0' ) );
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 - 'input-field',
276 - 'interactive-checklist',
277 - 'key-takeaways',
278 - // 'logo-grid',
279 - 'logo-slider',
280 - 'lottie-player',
281 - 'list',
282 - 'mailto',
283 - // 'marquee',
284 - 'media-text-section',
285 - // 'milestone-timeline',
286 - // 'modal-popup',
287 - 'navigation',
288 - 'news-ticker',
289 - // 'newsletter-optin',
290 - // 'notification-bar',
291 - 'off-canvas',
292 - // 'parallax-section',
293 - // 'pdf-embed',
294 - // 'popup-optin',
295 - // 'portfolio-gallery',
296 - // 'post-carousel',
297 - // 'post-filter-grid',
298 - // 'post-masonry-grid',
299 - // 'post-navigation',
300 - // 'post-timeline',
301 - 'posts',
302 - 'price-lists',
303 - 'pricing-table',
304 - // 'pricing-toggle',
305 - 'process-steps',
306 - // 'progress-bar',
307 - // 'progress-circle',
308 - // 'promo-strip',
309 - 'qr-code',
310 - // 'reading-progress',
311 - // 'review-box',
312 - 'row',
313 - 'section-heading',
314 - 'skill-bar',
315 - 'service',
316 - 'services',
317 - 'shape-divider',
318 - 'slider',
319 - // 'scroll-reveal',
320 - 'scroll-to-top',
321 - // 'search-bar',
322 - 'social-share',
323 - // 'social-share-bar',
324 - 'whatsapp-chat',
325 - // 'woo-add-to-cart',
326 - // 'woo-best-sellers',
327 - // 'woo-category-grid',
328 - // 'woo-featured-product',
329 - // 'woo-mini-cart',
330 - // 'woo-product-carousel',
331 - // 'woo-product-filter',
332 - // 'woo-product-grid',
333 - // 'woo-product-reviews',
334 - // 'woo-sale-badge',
335 - // 'woo-single-product',
336 - 'star-rating',
337 - 'stacked-cards',
338 - 'stat-cards',
339 - // 'sticky-sidebar',
340 - 'svg-draw',
341 - 'table-of-content',
342 - // 'taxonomy-grid',
343 - 'td-viewer',
344 - 'team-members',
345 - // 'testimonial-card',
346 - // 'testimonial-slider',
347 - 'testimonials',
348 - // 'testimonials-grid',
349 - 'timeline',
350 - 'toggle-content',
351 - 'accordion-block',
352 - 'video',
353 - // 'video-popup',
354 - 'text-path',
355 - ];
356 - foreach ( $blocks as $block ) {
357 - if ( !in_array( "b-blocks/{$block}", $disabledBlocks ) && !in_array( "b-blocks/{$block}", $premiumBlocks ) ) {
358 - register_block_type( __DIR__ . "/build/{$block}" );
359 - wp_deregister_script( "b-blocks-{$block}-editor-script" );
360 - }
361 - }
362 - // The newsletter-optin view.js uses @wordpress/i18n – register translations
363 - // for the auto-generated view-script handle so frontend error/success strings
364 - // are translatable. The handle is derived from the block name by WordPress core.
365 - // if ( ! in_array( 'b-blocks/newsletter-optin', $disabledBlocks ) ) {
366 - // wp_set_script_translations(
367 - // 'b-blocks-newsletter-optin-view-script',
368 - // 'b-blocks',
369 - // B_BLOCKS_DIR_PATH . 'languages'
370 - // );
371 - // }
372 - // The popup-optin view.js imports @wordpress/i18n for frontend
373 - // validation / status strings, so its view-script handle needs
374 - // translations registered.
375 - // if ( ! in_array( 'b-blocks/popup-optin', $disabledBlocks ) ) {
376 - // wp_set_script_translations(
377 - // 'b-blocks-popup-optin-view-script',
378 - // 'b-blocks',
379 - // B_BLOCKS_DIR_PATH . 'languages'
380 - // );
381 - // }
382 - // The floating-cta view.js imports @wordpress/i18n (__('Button') and __('Dismiss'))
383 - // so its view-script handle also needs translations registered.
384 - // if ( ! in_array( 'b-blocks/floating-cta', $disabledBlocks ) ) {
385 - // wp_set_script_translations(
386 - // 'b-blocks-floating-cta-view-script',
387 - // 'b-blocks',
388 - // B_BLOCKS_DIR_PATH . 'languages'
389 - // );
390 - // }
391 - // The image-slider view.js imports @wordpress/i18n for lightbox aria-labels
392 - // so its view-script handle needs translations registered.
393 - // if ( ! in_array( 'b-blocks/image-slider', $disabledBlocks ) ) {
394 - // wp_set_script_translations(
395 - // 'b-blocks-image-slider-view-script',
396 - // 'b-blocks',
397 - // B_BLOCKS_DIR_PATH . 'languages'
398 - // );
399 - // }
400 - // The testimonial-slider view.js imports @wordpress/i18n for the
401 - // play/pause toggle aria-labels, so its view-script handle needs
402 - // translations registered.
403 - // if ( ! in_array( 'b-blocks/testimonial-slider', $disabledBlocks ) ) {
404 - // wp_set_script_translations(
405 - // 'b-blocks-testimonial-slider-view-script',
406 - // 'b-blocks',
407 - // B_BLOCKS_DIR_PATH . 'languages'
408 - // );
409 - // }
410 - // The post-filter-grid view.js imports @wordpress/i18n for the
411 - // aria-live status announcements, so its view-script handle needs
412 - // translations registered.
413 - // if ( ! in_array( 'b-blocks/post-filter-grid', $disabledBlocks ) ) {
414 - // wp_set_script_translations(
415 - // 'b-blocks-post-filter-grid-view-script',
416 - // 'b-blocks',
417 - // B_BLOCKS_DIR_PATH . 'languages'
418 - // );
419 - // }
420 - // The post-masonry-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-masonry-grid', $disabledBlocks ) ) {
424 - // wp_set_script_translations(
425 - // 'b-blocks-post-masonry-grid-view-script',
426 - // 'b-blocks',
427 - // B_BLOCKS_DIR_PATH . 'languages'
428 - // );
429 - // }
430 - // The woo-add-to-cart view.js uses @wordpress/i18n for the aria-live
431 - // add-to-cart status announcements, so its view-script handle needs
432 - // translations registered.
433 - // if ( ! in_array( 'b-blocks/woo-add-to-cart', $disabledBlocks ) ) {
434 - // wp_set_script_translations(
435 - // 'b-blocks-woo-add-to-cart-view-script',
436 - // 'b-blocks',
437 - // B_BLOCKS_DIR_PATH . 'languages'
438 - // );
439 - // }
440 - // The woo-mini-cart view.js uses @wordpress/i18n for the cart
441 - // aria-label and aria-live announcements, so its view-script
442 - // handle needs translations registered.
443 - // if ( ! in_array( 'b-blocks/woo-mini-cart', $disabledBlocks ) ) {
444 - // wp_set_script_translations(
445 - // 'b-blocks-woo-mini-cart-view-script',
446 - // 'b-blocks',
447 - // B_BLOCKS_DIR_PATH . 'languages'
448 - // );
449 - // }
450 - // The woo-best-sellers view.js imports @wordpress/i18n for the
451 - // aria-live add-to-cart status announcements ("added to cart",
452 - // error messages), so its view-script handle needs translations
453 - // registered.
454 - // if ( ! in_array( 'b-blocks/woo-best-sellers', $disabledBlocks ) ) {
455 - // wp_set_script_translations(
456 - // 'b-blocks-woo-best-sellers-view-script',
457 - // 'b-blocks',
458 - // B_BLOCKS_DIR_PATH . 'languages'
459 - // );
460 - // }
461 - // The woo-featured-product view.js uses @wordpress/i18n for the
462 - // aria-live add-to-cart status announcements, so its view-script
463 - // handle needs translations registered.
464 - // if ( ! in_array( 'b-blocks/woo-featured-product', $disabledBlocks ) ) {
465 - // wp_set_script_translations(
466 - // 'b-blocks-woo-featured-product-view-script',
467 - // 'b-blocks',
468 - // B_BLOCKS_DIR_PATH . 'languages'
469 - // );
470 - // }
471 - // The woo-product-grid view.js uses @wordpress/i18n for the aria-live
472 - // add-to-cart status announcements, so its view-script handle needs
473 - // translations registered.
474 - // if ( ! in_array( 'b-blocks/woo-product-grid', $disabledBlocks ) ) {
475 - // wp_set_script_translations(
476 - // 'b-blocks-woo-product-grid-view-script',
477 - // 'b-blocks',
478 - // B_BLOCKS_DIR_PATH . 'languages'
479 - // );
480 - // }
481 - // The woo-product-carousel view.js uses @wordpress/i18n for slide
482 - // aria-live announcements and the add-to-cart status region, so its
483 - // view-script handle needs translations registered.
484 - // if ( ! in_array( 'b-blocks/woo-product-carousel', $disabledBlocks ) ) {
485 - // wp_set_script_translations(
486 - // 'b-blocks-woo-product-carousel-view-script',
487 - // 'b-blocks',
488 - // B_BLOCKS_DIR_PATH . 'languages'
489 - // );
490 - // }
491 - // The sticky-sidebar view.js uses @wordpress/i18n for the scrollable
492 - // sidebar aria-label, so its view-script handle needs translations registered.
493 - // if ( ! in_array( 'b-blocks/sticky-sidebar', $disabledBlocks ) ) {
494 - // wp_set_script_translations(
495 - // 'b-blocks-sticky-sidebar-view-script',
496 - // 'b-blocks',
497 - // B_BLOCKS_DIR_PATH . 'languages'
498 - // );
499 - // }
500 - // The search-bar view.js imports @wordpress/i18n for the live-search
501 - // no-results / aria-live result-count strings, so its view-script
502 - // handle needs translations registered.
503 - // if ( ! in_array( 'b-blocks/search-bar', $disabledBlocks ) ) {
504 - // wp_set_script_translations(
505 - // 'b-blocks-search-bar-view-script',
506 - // 'b-blocks',
507 - // B_BLOCKS_DIR_PATH . 'languages'
508 - // );
509 - // }
510 - }
511 -
512 - function registerSettings() {
513 - register_setting( 'bBlocksUtils', 'bBlocksUtils', [
514 - 'show_in_rest' => [
515 - 'name' => 'bBlocksUtils',
516 - 'schema' => [
517 - 'type' => 'string',
518 - ],
519 - ],
520 - 'type' => 'string',
521 - 'default' => wp_json_encode( [
522 - 'nonce' => wp_create_nonce( 'wp_ajax' ),
523 - ] ),
524 - 'sanitize_callback' => 'sanitize_text_field',
525 - ] );
526 - }
527 -
528 - function registerCategories( $categories ) {
529 - return array_merge( [[
530 - 'slug' => 'bBlocks',
531 - 'title' => __( 'bBlocks', 'b-blocks' ),
532 - ]], $categories );
533 - }
534 -
535 - // Register categories
536 - //Allow some additional file types for upload
537 - function uploadMimes( $mimes ) {
538 - $mimes['glb'] = 'model/gltf-binary';
539 - // 3D Viewer
540 - $mimes['gltf'] = 'model/gltf-binary';
541 - // 3D Viewer
542 - $mimes['json'] = 'application/json';
543 - // Lottie Player
544 - $mimes['lottie'] = 'application/json';
545 - // Lottie Player
546 - if ( get_transient( 'b-blocks-enable-svg-mime-type' ) === 'true' ) {
547 - $mimes['svg'] = 'image/svg+xml';
548 - }
549 - return $mimes;
550 - }
551 -
552 - function wpCheckFiletypeAndExt(
553 - $data,
554 - $file,
555 - $filename,
556 - $mimes,
557 - $real_mime = null
558 - ) {
559 - // If file extension is 2 or more
560 - $f_sp = explode( '.', $filename );
561 - $f_exp_count = count( $f_sp );
562 - if ( $f_exp_count <= 1 ) {
563 - return $data;
564 - } else {
565 - $f_name = $f_sp[0];
566 - $ext = $f_sp[$f_exp_count - 1];
567 - }
568 - if ( 'glb' === $ext || 'gltf' === $ext ) {
569 - // 3D Viewer
570 - $type = 'model/gltf-binary';
571 - $proper_filename = '';
572 - return compact( 'ext', 'type', 'proper_filename' );
573 - } elseif ( 'json' === $ext || 'lottie' === $ext ) {
574 - // Lottie Player
575 - $type = 'application/json';
576 - $proper_filename = '';
577 - return compact( 'ext', 'type', 'proper_filename' );
578 - } else {
579 - return $data;
580 - }
581 - }
582 -
583 - public function enableSvgMimeType() {
584 - if ( !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? null ) ), 'wp_ajax' ) ) {
585 - wp_send_json_error();
586 - }
587 - if ( !current_user_can( 'manage_options' ) ) {
588 - wp_send_json_error();
589 - }
590 - set_transient( 'b-blocks-enable-svg-mime-type', 'true', 80 );
591 - wp_send_json_success();
592 - }
593 -
594 - }
595 -
596 - BBlocks::instance();
597 -}
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 +}