PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 2.1.7
bBlocks – Essential Gutenberg Blocks & Patterns Collection v2.1.7
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 1.5.4 All 107 releases
b-blocks / plugin.php

plugin.php in bBlocks – Essential Gutenberg Blocks & Patterns Collection 2.1.7, at plugin.php

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