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 -594 2.1.6 → 2.1.8 View file →
@@ -1,611 +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.6
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.6' ) );
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/Instagram.php';
120 - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/OptinRateLimit.php';
121 - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/form/FormHandler.php';
122 - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/newsletter/NewsletterHandler.php';
123 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/popup-optin/PopupOptinHandler.php';
124 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/post-filter-grid/PostFilterGrid.php';
125 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/post-masonry-grid/PostMasonryGrid.php';
126 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-add-to-cart/WooAddToCart.php';
127 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-best-sellers/WooBestSellers.php';
128 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-featured-product/WooFeaturedProduct.php';
129 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-mini-cart/WooMiniCart.php';
130 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-product-carousel/WooProductCarousel.php';
131 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-product-grid/WooProductGrid.php';
132 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-product-reviews/WooProductReviews.php';
133 - // require_once B_BLOCKS_DIR_PATH . 'includes/blocks/woo-single-product/WooSingleProduct.php';
134 - // License Activation
135 - if ( file_exists( B_BLOCKS_DIR_PATH . 'includes/LicenseActivation.php' ) && B_BLOCKS_HAS_PRO ) {
136 - require_once B_BLOCKS_DIR_PATH . 'includes/LicenseActivation.php';
137 - }
138 - class BBlocks {
139 - protected static $_instance = null;
140 -
141 - function __construct() {
142 - add_action( 'init', [$this, 'onInit'] );
143 - add_action( 'wp_ajax_bBlocksPipeChecker', [$this, 'bBlocksPipeChecker'] );
144 - add_action( 'wp_ajax_nopriv_bBlocksPipeChecker', [$this, 'bBlocksPipeChecker'] );
145 - add_action( 'admin_init', [$this, 'registerSettings'] );
146 - add_action( 'rest_api_init', [$this, 'registerSettings'] );
147 - add_filter( 'block_categories_all', [$this, 'registerCategories'] );
148 - add_filter( 'upload_mimes', [$this, 'uploadMimes'] );
149 - add_filter(
150 - 'wp_check_filetype_and_ext',
151 - [$this, 'wpCheckFiletypeAndExt'],
152 - 10,
153 - 5
154 - );
155 - add_action( 'wp_ajax_b-blocks-enable-svg-mime-type', [$this, 'enableSvgMimeType'] );
156 - add_filter(
157 - 'plugin_row_meta',
158 - [$this, 'pluginRowMeta'],
159 - 10,
160 - 2
161 - );
162 - }
163 -
164 - function pluginRowMeta( $plugin_meta, $plugin_file ) {
165 - return $plugin_meta;
166 - }
167 -
168 - public static function instance() {
169 - if ( self::$_instance === null ) {
170 - self::$_instance = new self();
171 - }
172 - return self::$_instance;
173 - }
174 -
175 - function bBlocksPipeChecker() {
176 - $nonce = sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? null ) );
177 - if ( !wp_verify_nonce( $nonce, 'wp_ajax' ) ) {
178 - wp_send_json_error( 'Invalid Request' );
179 - }
180 - wp_send_json_success( [
181 - 'isPipe' => BBlocks\Inc\Utils::isPro(),
182 - ] );
183 - }
184 -
185 - function onInit() {
186 - $disabledBlocks = get_option( 'bBlocksDisabledBlocks', [] );
187 - $disabledBlocks = ( is_array( $disabledBlocks ) ? $disabledBlocks : [] );
188 - $premiumBlocks = ( BBlocks\Inc\Utils::isPro() ? [] : [
189 - 'b-blocks/logo-slider',
190 - 'b-blocks/content-ticker',
191 - 'b-blocks/image-hotspot',
192 - 'b-blocks/stacked-cards',
193 - 'b-blocks/key-takeaways',
194 - 'b-blocks/stat-cards',
195 - 'b-blocks/article-card',
196 - 'b-blocks/event-card',
197 - 'b-blocks/file-download-card',
198 - 'b-blocks/google-map',
199 - 'b-blocks/code-highlight'
200 - ] );
201 - // Add dependent blocks
202 - if ( in_array( 'b-blocks/row', $disabledBlocks ) && !in_array( 'b-blocks/column', $disabledBlocks ) ) {
203 - $disabledBlocks[] = 'b-blocks/column';
204 - }
205 - if ( in_array( 'b-blocks/services', $disabledBlocks ) && !in_array( 'b-blocks/service', $disabledBlocks ) ) {
206 - $disabledBlocks[] = 'b-blocks/service';
207 - }
208 - $blocks = [
209 - 'alert',
210 - // 'anchor-nav',
211 - 'advanced-image',
212 - 'animated-text',
213 - 'advanced-tabs',
214 - 'article-card',
215 - 'audio-player',
216 - // 'author-box',
217 - 'blockquote',
218 - 'button',
219 - 'button-group',
220 - 'breadcrumb',
221 - // 'business-hours',
222 - // 'call-to-action',
223 - // 'callout',
224 - 'cards',
225 - 'chart',
226 - 'column',
227 - 'container',
228 - 'content-ticker',
229 - 'countdown',
230 - 'counters',
231 - 'data-table',
232 - 'table-head',
233 - 'table-body',
234 - 'table-row',
235 - 'table-cell',
236 - 'table-footer',
237 - 'carousel',
238 - 'carousel-slide',
239 - // 'click-to-share',
240 - 'code-highlight',
241 - 'comparison-table',
242 - // 'contact-card',
243 - // 'content-filter',
244 - // 'content-filter-item',
245 - // 'cookie-consent-bar',
246 - // 'coupon-code',
247 - 'divider',
248 - 'dual-color-heading',
249 - 'emoji-stack-separator',
250 - 'event-card',
251 - 'expand-content',
252 - 'facebook-embed',
253 - 'facebook-page',
254 - // 'faq-block',
255 - 'feature-boxes',
256 - // 'feature-tabs',
257 - 'file-download-card',
258 - 'flip-boxes',
259 - // 'floating-cta',
260 - 'gif',
261 - 'form-builder',
262 - 'google-map',
263 - 'hero-section',
264 - // 'howto-schema',
265 - 'html',
266 - // 'icon',
267 - 'icon-box',
268 - // 'icon-list',
269 - // 'image-accordion',
270 - // 'image-box',
271 - 'image-comparison',
272 - 'image-gallery',
273 - 'image-hotspot',
274 - // 'image-mask',
275 - 'image-scroller',
276 - // 'image-slider',
277 - 'info-box',
278 - 'infographic',
279 - 'input-field',
280 - 'instagram',
281 - 'interactive-checklist',
282 - 'key-takeaways',
283 - // 'logo-grid',
284 - 'logo-slider',
285 - 'lottie-player',
286 - 'list',
287 - 'mailto',
288 - // 'marquee',
289 - 'media-text-section',
290 - // 'milestone-timeline',
291 - // 'modal-popup',
292 - 'navigation',
293 - 'news-ticker',
294 - // 'newsletter-optin',
295 - // 'notification-bar',
296 - 'off-canvas',
297 - // 'parallax-section',
298 - // 'pdf-embed',
299 - // 'popup-optin',
300 - // 'portfolio-gallery',
301 - // 'post-carousel',
302 - // 'post-filter-grid',
303 - // 'post-masonry-grid',
304 - // 'post-navigation',
305 - // 'post-timeline',
306 - 'posts',
307 - 'price-lists',
308 - 'pricing-table',
309 - // 'pricing-toggle',
310 - 'process-steps',
311 - // 'progress-bar',
312 - // 'progress-circle',
313 - // 'promo-strip',
314 - 'qr-code',
315 - // 'reading-progress',
316 - // 'review-box',
317 - 'row',
318 - 'section-heading',
319 - 'skill-bar',
320 - 'service',
321 - 'services',
322 - 'shape-divider',
323 - 'slider',
324 - // 'scroll-reveal',
325 - 'scroll-to-top',
326 - // 'search-bar',
327 - 'social-share',
328 - // 'social-share-bar',
329 - 'whatsapp-chat',
330 - // 'woo-add-to-cart',
331 - // 'woo-best-sellers',
332 - // 'woo-category-grid',
333 - // 'woo-featured-product',
334 - // 'woo-mini-cart',
335 - // 'woo-product-carousel',
336 - // 'woo-product-filter',
337 - // 'woo-product-grid',
338 - // 'woo-product-reviews',
339 - // 'woo-sale-badge',
340 - // 'woo-single-product',
341 - 'star-rating',
342 - 'stacked-cards',
343 - 'stat-cards',
344 - // 'sticky-sidebar',
345 - 'svg-draw',
346 - 'table-of-content',
347 - // 'taxonomy-grid',
348 - 'td-viewer',
349 - 'team-members',
350 - // 'testimonial-card',
351 - // 'testimonial-slider',
352 - 'testimonials',
353 - // 'testimonials-grid',
354 - 'timeline',
355 - 'timeline-item',
356 - 'toggle-content',
357 - 'accordion-block',
358 - 'video',
359 - // 'video-popup',
360 - 'text-path',
361 - ];
362 - foreach ( $blocks as $block ) {
363 - if ( !in_array( "b-blocks/{$block}", $disabledBlocks ) && !in_array( "b-blocks/{$block}", $premiumBlocks ) ) {
364 - $registered = register_block_type( __DIR__ . "/build/{$block}" );
365 - // Every block shares one editor bundle, so the per-block
366 - // handle is dropped to keep it from being loaded again.
367 - // The handle WordPress generates comes from the block's
368 - // NAME, which is not always its directory — data-table is
369 - // registered as b-blocks/table — so deriving it from the
370 - // directory silently misses those and the bundle runs
371 - // twice, re-registering every inline format.
372 - $name = ( $registered instanceof WP_Block_Type ? $registered->name : "b-blocks/{$block}" );
373 - wp_deregister_script( generate_block_asset_handle( $name, 'editorScript' ) );
374 - }
375 - }
376 - // The newsletter-optin view.js uses @wordpress/i18n – register translations
377 - // for the auto-generated view-script handle so frontend error/success strings
378 - // are translatable. The handle is derived from the block name by WordPress core.
379 - // if ( ! in_array( 'b-blocks/newsletter-optin', $disabledBlocks ) ) {
380 - // wp_set_script_translations(
381 - // 'b-blocks-newsletter-optin-view-script',
382 - // 'b-blocks',
383 - // B_BLOCKS_DIR_PATH . 'languages'
384 - // );
385 - // }
386 - // The popup-optin view.js imports @wordpress/i18n for frontend
387 - // validation / status strings, so its view-script handle needs
388 - // translations registered.
389 - // if ( ! in_array( 'b-blocks/popup-optin', $disabledBlocks ) ) {
390 - // wp_set_script_translations(
391 - // 'b-blocks-popup-optin-view-script',
392 - // 'b-blocks',
393 - // B_BLOCKS_DIR_PATH . 'languages'
394 - // );
395 - // }
396 - // The floating-cta view.js imports @wordpress/i18n (__('Button') and __('Dismiss'))
397 - // so its view-script handle also needs translations registered.
398 - // if ( ! in_array( 'b-blocks/floating-cta', $disabledBlocks ) ) {
399 - // wp_set_script_translations(
400 - // 'b-blocks-floating-cta-view-script',
401 - // 'b-blocks',
402 - // B_BLOCKS_DIR_PATH . 'languages'
403 - // );
404 - // }
405 - // The image-slider view.js imports @wordpress/i18n for lightbox aria-labels
406 - // so its view-script handle needs translations registered.
407 - // if ( ! in_array( 'b-blocks/image-slider', $disabledBlocks ) ) {
408 - // wp_set_script_translations(
409 - // 'b-blocks-image-slider-view-script',
410 - // 'b-blocks',
411 - // B_BLOCKS_DIR_PATH . 'languages'
412 - // );
413 - // }
414 - // The testimonial-slider view.js imports @wordpress/i18n for the
415 - // play/pause toggle aria-labels, so its view-script handle needs
416 - // translations registered.
417 - // if ( ! in_array( 'b-blocks/testimonial-slider', $disabledBlocks ) ) {
418 - // wp_set_script_translations(
419 - // 'b-blocks-testimonial-slider-view-script',
420 - // 'b-blocks',
421 - // B_BLOCKS_DIR_PATH . 'languages'
422 - // );
423 - // }
424 - // The post-filter-grid view.js imports @wordpress/i18n for the
425 - // aria-live status announcements, so its view-script handle needs
426 - // translations registered.
427 - // if ( ! in_array( 'b-blocks/post-filter-grid', $disabledBlocks ) ) {
428 - // wp_set_script_translations(
429 - // 'b-blocks-post-filter-grid-view-script',
430 - // 'b-blocks',
431 - // B_BLOCKS_DIR_PATH . 'languages'
432 - // );
433 - // }
434 - // The post-masonry-grid view.js imports @wordpress/i18n for the
435 - // aria-live status announcements, so its view-script handle needs
436 - // translations registered.
437 - // if ( ! in_array( 'b-blocks/post-masonry-grid', $disabledBlocks ) ) {
438 - // wp_set_script_translations(
439 - // 'b-blocks-post-masonry-grid-view-script',
440 - // 'b-blocks',
441 - // B_BLOCKS_DIR_PATH . 'languages'
442 - // );
443 - // }
444 - // The woo-add-to-cart view.js uses @wordpress/i18n for the aria-live
445 - // add-to-cart status announcements, so its view-script handle needs
446 - // translations registered.
447 - // if ( ! in_array( 'b-blocks/woo-add-to-cart', $disabledBlocks ) ) {
448 - // wp_set_script_translations(
449 - // 'b-blocks-woo-add-to-cart-view-script',
450 - // 'b-blocks',
451 - // B_BLOCKS_DIR_PATH . 'languages'
452 - // );
453 - // }
454 - // The woo-mini-cart view.js uses @wordpress/i18n for the cart
455 - // aria-label and aria-live announcements, so its view-script
456 - // handle needs translations registered.
457 - // if ( ! in_array( 'b-blocks/woo-mini-cart', $disabledBlocks ) ) {
458 - // wp_set_script_translations(
459 - // 'b-blocks-woo-mini-cart-view-script',
460 - // 'b-blocks',
461 - // B_BLOCKS_DIR_PATH . 'languages'
462 - // );
463 - // }
464 - // The woo-best-sellers view.js imports @wordpress/i18n for the
465 - // aria-live add-to-cart status announcements ("added to cart",
466 - // error messages), so its view-script handle needs translations
467 - // registered.
468 - // if ( ! in_array( 'b-blocks/woo-best-sellers', $disabledBlocks ) ) {
469 - // wp_set_script_translations(
470 - // 'b-blocks-woo-best-sellers-view-script',
471 - // 'b-blocks',
472 - // B_BLOCKS_DIR_PATH . 'languages'
473 - // );
474 - // }
475 - // The woo-featured-product view.js uses @wordpress/i18n for the
476 - // aria-live add-to-cart status announcements, so its view-script
477 - // handle needs translations registered.
478 - // if ( ! in_array( 'b-blocks/woo-featured-product', $disabledBlocks ) ) {
479 - // wp_set_script_translations(
480 - // 'b-blocks-woo-featured-product-view-script',
481 - // 'b-blocks',
482 - // B_BLOCKS_DIR_PATH . 'languages'
483 - // );
484 - // }
485 - // The woo-product-grid view.js uses @wordpress/i18n for the aria-live
486 - // add-to-cart status announcements, so its view-script handle needs
487 - // translations registered.
488 - // if ( ! in_array( 'b-blocks/woo-product-grid', $disabledBlocks ) ) {
489 - // wp_set_script_translations(
490 - // 'b-blocks-woo-product-grid-view-script',
491 - // 'b-blocks',
492 - // B_BLOCKS_DIR_PATH . 'languages'
493 - // );
494 - // }
495 - // The woo-product-carousel view.js uses @wordpress/i18n for slide
496 - // aria-live announcements and the add-to-cart status region, so its
497 - // view-script handle needs translations registered.
498 - // if ( ! in_array( 'b-blocks/woo-product-carousel', $disabledBlocks ) ) {
499 - // wp_set_script_translations(
500 - // 'b-blocks-woo-product-carousel-view-script',
501 - // 'b-blocks',
502 - // B_BLOCKS_DIR_PATH . 'languages'
503 - // );
504 - // }
505 - // The sticky-sidebar view.js uses @wordpress/i18n for the scrollable
506 - // sidebar aria-label, so its view-script handle needs translations registered.
507 - // if ( ! in_array( 'b-blocks/sticky-sidebar', $disabledBlocks ) ) {
508 - // wp_set_script_translations(
509 - // 'b-blocks-sticky-sidebar-view-script',
510 - // 'b-blocks',
511 - // B_BLOCKS_DIR_PATH . 'languages'
512 - // );
513 - // }
514 - // The search-bar view.js imports @wordpress/i18n for the live-search
515 - // no-results / aria-live result-count strings, so its view-script
516 - // handle needs translations registered.
517 - // if ( ! in_array( 'b-blocks/search-bar', $disabledBlocks ) ) {
518 - // wp_set_script_translations(
519 - // 'b-blocks-search-bar-view-script',
520 - // 'b-blocks',
521 - // B_BLOCKS_DIR_PATH . 'languages'
522 - // );
523 - // }
524 - }
525 -
526 - function registerSettings() {
527 - register_setting( 'bBlocksUtils', 'bBlocksUtils', [
528 - 'show_in_rest' => [
529 - 'name' => 'bBlocksUtils',
530 - 'schema' => [
531 - 'type' => 'string',
532 - ],
533 - ],
534 - 'type' => 'string',
535 - 'default' => wp_json_encode( [
536 - 'nonce' => wp_create_nonce( 'wp_ajax' ),
537 - ] ),
538 - 'sanitize_callback' => 'sanitize_text_field',
539 - ] );
540 - }
541 -
542 - function registerCategories( $categories ) {
543 - return array_merge( [[
544 - 'slug' => 'bBlocks',
545 - 'title' => __( 'bBlocks', 'b-blocks' ),
546 - ]], $categories );
547 - }
548 -
549 - // Register categories
550 - //Allow some additional file types for upload
551 - function uploadMimes( $mimes ) {
552 - $mimes['glb'] = 'model/gltf-binary';
553 - // 3D Viewer
554 - $mimes['gltf'] = 'model/gltf-binary';
555 - // 3D Viewer
556 - $mimes['json'] = 'application/json';
557 - // Lottie Player
558 - $mimes['lottie'] = 'application/json';
559 - // Lottie Player
560 - if ( get_transient( 'b-blocks-enable-svg-mime-type' ) === 'true' ) {
561 - $mimes['svg'] = 'image/svg+xml';
562 - }
563 - return $mimes;
564 - }
565 -
566 - function wpCheckFiletypeAndExt(
567 - $data,
568 - $file,
569 - $filename,
570 - $mimes,
571 - $real_mime = null
572 - ) {
573 - // If file extension is 2 or more
574 - $f_sp = explode( '.', $filename );
575 - $f_exp_count = count( $f_sp );
576 - if ( $f_exp_count <= 1 ) {
577 - return $data;
578 - } else {
579 - $f_name = $f_sp[0];
580 - $ext = $f_sp[$f_exp_count - 1];
581 - }
582 - if ( 'glb' === $ext || 'gltf' === $ext ) {
583 - // 3D Viewer
584 - $type = 'model/gltf-binary';
585 - $proper_filename = '';
586 - return compact( 'ext', 'type', 'proper_filename' );
587 - } elseif ( 'json' === $ext || 'lottie' === $ext ) {
588 - // Lottie Player
589 - $type = 'application/json';
590 - $proper_filename = '';
591 - return compact( 'ext', 'type', 'proper_filename' );
592 - } else {
593 - return $data;
594 - }
595 - }
596 -
597 - public function enableSvgMimeType() {
598 - if ( !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? null ) ), 'wp_ajax' ) ) {
599 - wp_send_json_error();
600 - }
601 - if ( !current_user_can( 'manage_options' ) ) {
602 - wp_send_json_error();
603 - }
604 - set_transient( 'b-blocks-enable-svg-mime-type', 'true', 80 );
605 - wp_send_json_success();
606 - }
607 -
608 - }
609 -
610 - BBlocks::instance();
611 -}
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 +}