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 -579 2.1.0 → 2.1.8 View file →
@@ -1,596 +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.0
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 - ] );
197 - // Add dependent blocks
198 - if ( in_array( 'b-blocks/row', $disabledBlocks ) && !in_array( 'b-blocks/column', $disabledBlocks ) ) {
199 - $disabledBlocks[] = 'b-blocks/column';
200 - }
201 - if ( in_array( 'b-blocks/services', $disabledBlocks ) && !in_array( 'b-blocks/service', $disabledBlocks ) ) {
202 - $disabledBlocks[] = 'b-blocks/service';
203 - }
204 - $blocks = [
205 - 'alert',
206 - // 'anchor-nav',
207 - 'advanced-image',
208 - 'animated-text',
209 - 'advanced-tabs',
210 - 'article-card',
211 - // 'audio-player',
212 - // 'author-box',
213 - 'blockquote',
214 - 'button',
215 - 'button-group',
216 - 'breadcrumb',
217 - // 'business-hours',
218 - // 'call-to-action',
219 - // 'callout',
220 - 'cards',
221 - 'chart',
222 - 'column',
223 - 'container',
224 - 'content-ticker',
225 - 'countdown',
226 - 'counters',
227 - 'data-table',
228 - 'table-head',
229 - 'table-body',
230 - 'table-row',
231 - 'table-cell',
232 - 'table-footer',
233 - 'carousel',
234 - 'carousel-slide',
235 - // 'click-to-share',
236 - // 'code-highlight',
237 - // 'comparison-table',
238 - // 'contact-card',
239 - // 'content-filter',
240 - // 'content-filter-item',
241 - // 'cookie-consent-bar',
242 - // 'coupon-code',
243 - 'divider',
244 - 'dual-color-heading',
245 - 'emoji-stack-separator',
246 - 'event-card',
247 - 'expand-content',
248 - 'facebook-embed',
249 - 'facebook-page',
250 - // 'faq-block',
251 - 'feature-boxes',
252 - // 'feature-tabs',
253 - // 'file-download-card',
254 - 'flip-boxes',
255 - // 'floating-cta',
256 - 'gif',
257 - 'form-builder',
258 - // 'google-map',
259 - // 'hero-section',
260 - // 'howto-schema',
261 - 'html',
262 - // 'icon',
263 - 'icon-box',
264 - // 'icon-list',
265 - // 'image-accordion',
266 - // 'image-box',
267 - 'image-comparison',
268 - 'image-gallery',
269 - 'image-hotspot',
270 - // 'image-mask',
271 - 'image-scroller',
272 - // 'image-slider',
273 - 'info-box',
274 - 'input-field',
275 - 'interactive-checklist',
276 - 'key-takeaways',
277 - // 'logo-grid',
278 - 'logo-slider',
279 - 'lottie-player',
280 - 'list',
281 - 'mailto',
282 - // 'marquee',
283 - 'media-text-section',
284 - // 'milestone-timeline',
285 - // 'modal-popup',
286 - 'navigation',
287 - 'news-ticker',
288 - // 'newsletter-optin',
289 - // 'notification-bar',
290 - // 'off-canvas',
291 - // 'parallax-section',
292 - // 'pdf-embed',
293 - // 'popup-optin',
294 - // 'portfolio-gallery',
295 - // 'post-carousel',
296 - // 'post-filter-grid',
297 - // 'post-masonry-grid',
298 - // 'post-navigation',
299 - // 'post-timeline',
300 - 'posts',
301 - 'price-lists',
302 - 'pricing-table',
303 - // 'pricing-toggle',
304 - 'process-steps',
305 - // 'progress-bar',
306 - // 'progress-circle',
307 - // 'promo-strip',
308 - 'qr-code',
309 - // 'reading-progress',
310 - // 'review-box',
311 - 'row',
312 - 'section-heading',
313 - 'skill-bar',
314 - 'service',
315 - 'services',
316 - 'shape-divider',
317 - 'slider',
318 - // 'scroll-reveal',
319 - 'scroll-to-top',
320 - // 'search-bar',
321 - 'social-share',
322 - // 'social-share-bar',
323 - 'whatsapp-chat',
324 - // 'woo-add-to-cart',
325 - // 'woo-best-sellers',
326 - // 'woo-category-grid',
327 - // 'woo-featured-product',
328 - // 'woo-mini-cart',
329 - // 'woo-product-carousel',
330 - // 'woo-product-filter',
331 - // 'woo-product-grid',
332 - // 'woo-product-reviews',
333 - // 'woo-sale-badge',
334 - // 'woo-single-product',
335 - 'star-rating',
336 - 'stacked-cards',
337 - 'stat-cards',
338 - // 'sticky-sidebar',
339 - 'svg-draw',
340 - 'table-of-content',
341 - // 'taxonomy-grid',
342 - 'td-viewer',
343 - 'team-members',
344 - // 'testimonial-card',
345 - // 'testimonial-slider',
346 - 'testimonials',
347 - // 'testimonials-grid',
348 - 'timeline',
349 - 'toggle-content',
350 - 'accordion-block',
351 - 'video',
352 - // 'video-popup',
353 - 'text-path',
354 - ];
355 - foreach ( $blocks as $block ) {
356 - if ( !in_array( "b-blocks/{$block}", $disabledBlocks ) && !in_array( "b-blocks/{$block}", $premiumBlocks ) ) {
357 - register_block_type( __DIR__ . "/build/{$block}" );
358 - wp_deregister_script( "b-blocks-{$block}-editor-script" );
359 - }
360 - }
361 - // The newsletter-optin view.js uses @wordpress/i18n – register translations
362 - // for the auto-generated view-script handle so frontend error/success strings
363 - // are translatable. The handle is derived from the block name by WordPress core.
364 - // if ( ! in_array( 'b-blocks/newsletter-optin', $disabledBlocks ) ) {
365 - // wp_set_script_translations(
366 - // 'b-blocks-newsletter-optin-view-script',
367 - // 'b-blocks',
368 - // B_BLOCKS_DIR_PATH . 'languages'
369 - // );
370 - // }
371 - // The popup-optin view.js imports @wordpress/i18n for frontend
372 - // validation / status strings, so its view-script handle needs
373 - // translations registered.
374 - // if ( ! in_array( 'b-blocks/popup-optin', $disabledBlocks ) ) {
375 - // wp_set_script_translations(
376 - // 'b-blocks-popup-optin-view-script',
377 - // 'b-blocks',
378 - // B_BLOCKS_DIR_PATH . 'languages'
379 - // );
380 - // }
381 - // The floating-cta view.js imports @wordpress/i18n (__('Button') and __('Dismiss'))
382 - // so its view-script handle also needs translations registered.
383 - // if ( ! in_array( 'b-blocks/floating-cta', $disabledBlocks ) ) {
384 - // wp_set_script_translations(
385 - // 'b-blocks-floating-cta-view-script',
386 - // 'b-blocks',
387 - // B_BLOCKS_DIR_PATH . 'languages'
388 - // );
389 - // }
390 - // The image-slider view.js imports @wordpress/i18n for lightbox aria-labels
391 - // so its view-script handle needs translations registered.
392 - // if ( ! in_array( 'b-blocks/image-slider', $disabledBlocks ) ) {
393 - // wp_set_script_translations(
394 - // 'b-blocks-image-slider-view-script',
395 - // 'b-blocks',
396 - // B_BLOCKS_DIR_PATH . 'languages'
397 - // );
398 - // }
399 - // The testimonial-slider view.js imports @wordpress/i18n for the
400 - // play/pause toggle aria-labels, so its view-script handle needs
401 - // translations registered.
402 - // if ( ! in_array( 'b-blocks/testimonial-slider', $disabledBlocks ) ) {
403 - // wp_set_script_translations(
404 - // 'b-blocks-testimonial-slider-view-script',
405 - // 'b-blocks',
406 - // B_BLOCKS_DIR_PATH . 'languages'
407 - // );
408 - // }
409 - // The post-filter-grid view.js imports @wordpress/i18n for the
410 - // aria-live status announcements, so its view-script handle needs
411 - // translations registered.
412 - // if ( ! in_array( 'b-blocks/post-filter-grid', $disabledBlocks ) ) {
413 - // wp_set_script_translations(
414 - // 'b-blocks-post-filter-grid-view-script',
415 - // 'b-blocks',
416 - // B_BLOCKS_DIR_PATH . 'languages'
417 - // );
418 - // }
419 - // The post-masonry-grid view.js imports @wordpress/i18n for the
420 - // aria-live status announcements, so its view-script handle needs
421 - // translations registered.
422 - // if ( ! in_array( 'b-blocks/post-masonry-grid', $disabledBlocks ) ) {
423 - // wp_set_script_translations(
424 - // 'b-blocks-post-masonry-grid-view-script',
425 - // 'b-blocks',
426 - // B_BLOCKS_DIR_PATH . 'languages'
427 - // );
428 - // }
429 - // The woo-add-to-cart view.js uses @wordpress/i18n for the aria-live
430 - // add-to-cart status announcements, so its view-script handle needs
431 - // translations registered.
432 - // if ( ! in_array( 'b-blocks/woo-add-to-cart', $disabledBlocks ) ) {
433 - // wp_set_script_translations(
434 - // 'b-blocks-woo-add-to-cart-view-script',
435 - // 'b-blocks',
436 - // B_BLOCKS_DIR_PATH . 'languages'
437 - // );
438 - // }
439 - // The woo-mini-cart view.js uses @wordpress/i18n for the cart
440 - // aria-label and aria-live announcements, so its view-script
441 - // handle needs translations registered.
442 - // if ( ! in_array( 'b-blocks/woo-mini-cart', $disabledBlocks ) ) {
443 - // wp_set_script_translations(
444 - // 'b-blocks-woo-mini-cart-view-script',
445 - // 'b-blocks',
446 - // B_BLOCKS_DIR_PATH . 'languages'
447 - // );
448 - // }
449 - // The woo-best-sellers view.js imports @wordpress/i18n for the
450 - // aria-live add-to-cart status announcements ("added to cart",
451 - // error messages), so its view-script handle needs translations
452 - // registered.
453 - // if ( ! in_array( 'b-blocks/woo-best-sellers', $disabledBlocks ) ) {
454 - // wp_set_script_translations(
455 - // 'b-blocks-woo-best-sellers-view-script',
456 - // 'b-blocks',
457 - // B_BLOCKS_DIR_PATH . 'languages'
458 - // );
459 - // }
460 - // The woo-featured-product view.js uses @wordpress/i18n for the
461 - // aria-live add-to-cart status announcements, so its view-script
462 - // handle needs translations registered.
463 - // if ( ! in_array( 'b-blocks/woo-featured-product', $disabledBlocks ) ) {
464 - // wp_set_script_translations(
465 - // 'b-blocks-woo-featured-product-view-script',
466 - // 'b-blocks',
467 - // B_BLOCKS_DIR_PATH . 'languages'
468 - // );
469 - // }
470 - // The woo-product-grid view.js uses @wordpress/i18n for the aria-live
471 - // add-to-cart status announcements, so its view-script handle needs
472 - // translations registered.
473 - // if ( ! in_array( 'b-blocks/woo-product-grid', $disabledBlocks ) ) {
474 - // wp_set_script_translations(
475 - // 'b-blocks-woo-product-grid-view-script',
476 - // 'b-blocks',
477 - // B_BLOCKS_DIR_PATH . 'languages'
478 - // );
479 - // }
480 - // The woo-product-carousel view.js uses @wordpress/i18n for slide
481 - // aria-live announcements and the add-to-cart status region, so its
482 - // view-script handle needs translations registered.
483 - // if ( ! in_array( 'b-blocks/woo-product-carousel', $disabledBlocks ) ) {
484 - // wp_set_script_translations(
485 - // 'b-blocks-woo-product-carousel-view-script',
486 - // 'b-blocks',
487 - // B_BLOCKS_DIR_PATH . 'languages'
488 - // );
489 - // }
490 - // The sticky-sidebar view.js uses @wordpress/i18n for the scrollable
491 - // sidebar aria-label, so its view-script handle needs translations registered.
492 - // if ( ! in_array( 'b-blocks/sticky-sidebar', $disabledBlocks ) ) {
493 - // wp_set_script_translations(
494 - // 'b-blocks-sticky-sidebar-view-script',
495 - // 'b-blocks',
496 - // B_BLOCKS_DIR_PATH . 'languages'
497 - // );
498 - // }
499 - // The search-bar view.js imports @wordpress/i18n for the live-search
500 - // no-results / aria-live result-count strings, so its view-script
501 - // handle needs translations registered.
502 - // if ( ! in_array( 'b-blocks/search-bar', $disabledBlocks ) ) {
503 - // wp_set_script_translations(
504 - // 'b-blocks-search-bar-view-script',
505 - // 'b-blocks',
506 - // B_BLOCKS_DIR_PATH . 'languages'
507 - // );
508 - // }
509 - }
510 -
511 - function registerSettings() {
512 - register_setting( 'bBlocksUtils', 'bBlocksUtils', [
513 - 'show_in_rest' => [
514 - 'name' => 'bBlocksUtils',
515 - 'schema' => [
516 - 'type' => 'string',
517 - ],
518 - ],
519 - 'type' => 'string',
520 - 'default' => wp_json_encode( [
521 - 'nonce' => wp_create_nonce( 'wp_ajax' ),
522 - ] ),
523 - 'sanitize_callback' => 'sanitize_text_field',
524 - ] );
525 - }
526 -
527 - function registerCategories( $categories ) {
528 - return array_merge( [[
529 - 'slug' => 'bBlocks',
530 - 'title' => __( 'bBlocks', 'b-blocks' ),
531 - ]], $categories );
532 - }
533 -
534 - // Register categories
535 - //Allow some additional file types for upload
536 - function uploadMimes( $mimes ) {
537 - $mimes['glb'] = 'model/gltf-binary';
538 - // 3D Viewer
539 - $mimes['gltf'] = 'model/gltf-binary';
540 - // 3D Viewer
541 - $mimes['json'] = 'application/json';
542 - // Lottie Player
543 - $mimes['lottie'] = 'application/json';
544 - // Lottie Player
545 - if ( get_transient( 'b-blocks-enable-svg-mime-type' ) === 'true' ) {
546 - $mimes['svg'] = 'image/svg+xml';
547 - }
548 - return $mimes;
549 - }
550 -
551 - function wpCheckFiletypeAndExt(
552 - $data,
553 - $file,
554 - $filename,
555 - $mimes,
556 - $real_mime = null
557 - ) {
558 - // If file extension is 2 or more
559 - $f_sp = explode( '.', $filename );
560 - $f_exp_count = count( $f_sp );
561 - if ( $f_exp_count <= 1 ) {
562 - return $data;
563 - } else {
564 - $f_name = $f_sp[0];
565 - $ext = $f_sp[$f_exp_count - 1];
566 - }
567 - if ( 'glb' === $ext || 'gltf' === $ext ) {
568 - // 3D Viewer
569 - $type = 'model/gltf-binary';
570 - $proper_filename = '';
571 - return compact( 'ext', 'type', 'proper_filename' );
572 - } elseif ( 'json' === $ext || 'lottie' === $ext ) {
573 - // Lottie Player
574 - $type = 'application/json';
575 - $proper_filename = '';
576 - return compact( 'ext', 'type', 'proper_filename' );
577 - } else {
578 - return $data;
579 - }
580 - }
581 -
582 - public function enableSvgMimeType() {
583 - if ( !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? null ) ), 'wp_ajax' ) ) {
584 - wp_send_json_error();
585 - }
586 - if ( !current_user_can( 'manage_options' ) ) {
587 - wp_send_json_error();
588 - }
589 - set_transient( 'b-blocks-enable-svg-mime-type', 'true', 80 );
590 - wp_send_json_success();
591 - }
592 -
593 - }
594 -
595 - BBlocks::instance();
596 -}
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 +}