| @@ -1,347 +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.0.41 | |
| 5 | + * Version: 2.1.8 | |
| 7 | 6 | * Author: bPlugins |
| 8 | 7 | * Author URI: https://bplugins.com |
| 9 | - * License: GPLv3 | |
| 10 | - * License URI: https://www.gnu.org/licenses/gpl-3.0.txt | |
| 8 | + * License: GPLv3 or later | |
| 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 | |
| 28 | - define( 'B_BLOCKS_VERSION', ( isset( $_SERVER['HTTP_HOST'] ) && ('localhost' === $_SERVER['HTTP_HOST'] || 'muradwahid.local' === $_SERVER['HTTP_HOST']) ? time() : '2.0.41' ) ); | |
| 29 | - define( 'B_BLOCKS_DIR_PATH', plugin_dir_path( __FILE__ ) ); | |
| 30 | - define( 'B_BLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) ); | |
| 31 | - define( 'B_BLOCKS_HAS_PRO', 'b-blocks-pro/plugin.php' === plugin_basename( __FILE__ ) ); | |
| 32 | - define( 'B_BLOCKS_BUILD', B_BLOCKS_DIR_URL . 'build/' ); | |
| 33 | - define( 'B_BLOCKS_ASSETS', B_BLOCKS_DIR_URL . 'assets/' ); | |
| 34 | - if ( !function_exists( 'b_blocks_fs' ) ) { | |
| 35 | - // Create a helper function for easy SDK access. | |
| 36 | - function b_blocks_fs() { | |
| 37 | - global $b_blocks_fs; | |
| 38 | - if ( !isset( $b_blocks_fs ) ) { | |
| 39 | - // Include Freemius SDK. | |
| 40 | - require_once dirname( __FILE__ ) . '/freemius/start.php'; | |
| 41 | - $b_blocks_fs = fs_dynamic_init( array( | |
| 42 | - 'id' => '12845', | |
| 43 | - 'slug' => 'b-blocks', | |
| 44 | - 'premium_slug' => 'b-blocks-pro', | |
| 45 | - 'type' => 'plugin', | |
| 46 | - 'public_key' => 'pk_d6426b344df4918bc066a7a0b4719', | |
| 47 | - 'is_premium' => false, | |
| 48 | - 'premium_suffix' => 'Pro', | |
| 49 | - 'has_addons' => false, | |
| 50 | - 'has_paid_plans' => true, | |
| 51 | - 'trial' => array( | |
| 52 | - 'days' => 7, | |
| 53 | - 'is_require_payment' => true, | |
| 54 | - ), | |
| 55 | - 'menu' => array( | |
| 56 | - 'slug' => 'b-blocks', | |
| 57 | - 'first-path' => 'admin.php?page=b-blocks', | |
| 58 | - 'contact' => false, | |
| 59 | - 'support' => false, | |
| 60 | - ), | |
| 61 | - 'is_live' => true, | |
| 62 | - 'is_org_compliant' => true, | |
| 63 | - ) ); | |
| 64 | - } | |
| 65 | - return $b_blocks_fs; | |
| 66 | - } | |
| 67 | 28 | |
| 68 | - // Init Freemius. | |
| 69 | - b_blocks_fs(); | |
| 70 | - // Signal that SDK was initiated. | |
| 71 | - do_action( 'b_blocks_fs_loaded' ); | |
| 72 | - } | |
| 73 | - // Generate Styles | |
| 74 | - class BBlocksStyleGenerator { | |
| 75 | - public static $styles = []; | |
| 29 | + define( 'B_BLOCKS_FILE', __FILE__ ); | |
| 76 | 30 | |
| 77 | - public static function addStyle( $selector, $styles ) { | |
| 78 | - if ( array_key_exists( $selector, self::$styles ) ) { | |
| 79 | - self::$styles[$selector] = wp_parse_args( self::$styles[$selector], $styles ); | |
| 80 | - } else { | |
| 81 | - self::$styles[$selector] = $styles; | |
| 82 | - } | |
| 83 | - } | |
| 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'; | |
| 84 | 35 | |
| 85 | - public static function renderStyle() { | |
| 86 | - $output = ''; | |
| 87 | - foreach ( self::$styles as $selector => $style ) { | |
| 88 | - $new = ''; | |
| 89 | - foreach ( $style as $property => $value ) { | |
| 90 | - if ( $value == '' ) { | |
| 91 | - $new .= "{$property} ;"; | |
| 92 | - } else { | |
| 93 | - $new .= " {$property}: {$value};"; | |
| 94 | - } | |
| 95 | - } | |
| 96 | - $output .= "{$selector} { {$new} }"; | |
| 97 | - } | |
| 98 | - return $output; | |
| 99 | - } | |
| 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'; | |
| 100 | 63 | |
| 101 | - } | |
| 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'; | |
| 102 | 69 | |
| 103 | - // Require files | |
| 104 | - require_once B_BLOCKS_DIR_PATH . 'includes/Dashboard.php'; | |
| 105 | - require_once B_BLOCKS_DIR_PATH . 'includes/EnqueueScripts.php'; | |
| 106 | - require_once B_BLOCKS_DIR_PATH . 'includes/Utils.php'; | |
| 107 | - require_once B_BLOCKS_DIR_PATH . 'includes/GetCSS.php'; | |
| 108 | - require_once B_BLOCKS_DIR_PATH . 'includes/Ajax.php'; | |
| 109 | - require_once B_BLOCKS_DIR_PATH . 'includes/posts/Posts.php'; | |
| 110 | - require_once B_BLOCKS_DIR_PATH . 'includes/Templates/Templates.php'; | |
| 111 | - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/LoginForm.php'; | |
| 112 | - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/cursor.php'; | |
| 113 | - require_once B_BLOCKS_DIR_PATH . 'includes/Ai.php'; | |
| 114 | - require_once B_BLOCKS_DIR_PATH . 'includes/ApiKeys.php'; | |
| 115 | - require_once B_BLOCKS_DIR_PATH . 'includes/blocks/form/FormHandler.php'; | |
| 116 | - // License Activation | |
| 117 | - if ( file_exists( B_BLOCKS_DIR_PATH . 'includes/LicenseActivation.php' ) && B_BLOCKS_HAS_PRO ) { | |
| 118 | - require_once B_BLOCKS_DIR_PATH . 'includes/LicenseActivation.php'; | |
| 119 | - } | |
| 120 | - class BBlocks { | |
| 121 | - protected static $_instance = null; | |
| 122 | - | |
| 123 | - function __construct() { | |
| 124 | - add_action( 'init', [$this, 'onInit'] ); | |
| 125 | - add_action( 'wp_ajax_bBlocksPipeChecker', [$this, 'bBlocksPipeChecker'] ); | |
| 126 | - add_action( 'wp_ajax_nopriv_bBlocksPipeChecker', [$this, 'bBlocksPipeChecker'] ); | |
| 127 | - add_action( 'admin_init', [$this, 'registerSettings'] ); | |
| 128 | - add_action( 'rest_api_init', [$this, 'registerSettings'] ); | |
| 129 | - add_filter( 'block_categories_all', [$this, 'registerCategories'] ); | |
| 130 | - add_filter( 'upload_mimes', [$this, 'uploadMimes'] ); | |
| 131 | - add_filter( | |
| 132 | - 'wp_check_filetype_and_ext', | |
| 133 | - [$this, 'wpCheckFiletypeAndExt'], | |
| 134 | - 10, | |
| 135 | - 5 | |
| 136 | - ); | |
| 137 | - add_action( 'wp_ajax_b-blocks-enable-svg-mime-type', [$this, 'enableSvgMimeType'] ); | |
| 138 | - add_filter( | |
| 139 | - 'plugin_row_meta', | |
| 140 | - [$this, 'pluginRowMeta'], | |
| 141 | - 10, | |
| 142 | - 2 | |
| 143 | - ); | |
| 144 | - } | |
| 145 | - | |
| 146 | - function pluginRowMeta( $plugin_meta, $plugin_file ) { | |
| 147 | - if ( strpos( $plugin_file, 'b-blocks' ) !== false && time() < strtotime( '2025-12-06' ) ) { | |
| 148 | - $new_links = array( | |
| 149 | - 'deal' => "<a href='https://bblockswp.com/pricing/?from=plugins.php' target='_blank' style='font-weight: 600; color: #ff7a00;'>🎉 Black Friday Sale - Get up to 40% OFF Now!</a>", | |
| 150 | - ); | |
| 151 | - $plugin_meta = array_merge( $plugin_meta, $new_links ); | |
| 152 | - } | |
| 153 | - return $plugin_meta; | |
| 154 | - } | |
| 155 | - | |
| 156 | - public static function instance() { | |
| 157 | - if ( self::$_instance === null ) { | |
| 158 | - self::$_instance = new self(); | |
| 159 | - } | |
| 160 | - return self::$_instance; | |
| 161 | - } | |
| 162 | - | |
| 163 | - function bBlocksPipeChecker() { | |
| 164 | - $nonce = sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? null ) ); | |
| 165 | - if ( !wp_verify_nonce( $nonce, 'wp_ajax' ) ) { | |
| 166 | - wp_send_json_error( 'Invalid Request' ); | |
| 167 | - } | |
| 168 | - wp_send_json_success( [ | |
| 169 | - 'isPipe' => BBlocks\Inc\Utils::isPro(), | |
| 170 | - ] ); | |
| 171 | - } | |
| 172 | - | |
| 173 | - function onInit() { | |
| 174 | - $disabledBlocks = get_option( 'bBlocksDisabledBlocks', [] ); | |
| 175 | - $disabledBlocks = ( is_array( $disabledBlocks ) ? $disabledBlocks : [] ); | |
| 176 | - $premiumBlocks = ( BBlocks\Inc\Utils::isPro() ? [] : [ | |
| 177 | - 'b-blocks/logo-slider', | |
| 178 | - 'b-blocks/content-ticker', | |
| 179 | - 'b-blocks/image-hotspot', | |
| 180 | - 'b-blocks/stacked-cards' | |
| 181 | - ] ); | |
| 182 | - // Add dependent blocks | |
| 183 | - if ( in_array( 'b-blocks/row', $disabledBlocks ) && !in_array( 'b-blocks/column', $disabledBlocks ) ) { | |
| 184 | - $disabledBlocks[] = 'b-blocks/column'; | |
| 185 | - } | |
| 186 | - if ( in_array( 'b-blocks/services', $disabledBlocks ) && !in_array( 'b-blocks/service', $disabledBlocks ) ) { | |
| 187 | - $disabledBlocks[] = 'b-blocks/service'; | |
| 188 | - } | |
| 189 | - $blocks = [ | |
| 190 | - 'alert', | |
| 191 | - 'advanced-image', | |
| 192 | - 'animated-text', | |
| 193 | - 'advanced-tabs', | |
| 194 | - 'button', | |
| 195 | - 'button-group', | |
| 196 | - 'breadcrumb', | |
| 197 | - 'cards', | |
| 198 | - 'chart', | |
| 199 | - 'column', | |
| 200 | - 'container', | |
| 201 | - 'content-ticker', | |
| 202 | - 'countdown', | |
| 203 | - 'counters', | |
| 204 | - // 'data-table', | |
| 205 | - 'carousel', | |
| 206 | - 'carousel-slide', | |
| 207 | - 'dual-color-heading', | |
| 208 | - 'emoji-stack-separator', | |
| 209 | - 'facebook-embed', | |
| 210 | - 'facebook-page', | |
| 211 | - 'feature-boxes', | |
| 212 | - 'flip-boxes', | |
| 213 | - 'gif', | |
| 214 | - 'form-builder', | |
| 215 | - 'html', | |
| 216 | - 'icon-box', | |
| 217 | - 'image-comparison', | |
| 218 | - 'image-gallery', | |
| 219 | - 'image-hotspot', | |
| 220 | - 'image-scroller', | |
| 221 | - 'info-box', | |
| 222 | - 'input-field', | |
| 223 | - 'logo-slider', | |
| 224 | - 'lottie-player', | |
| 225 | - 'list', | |
| 226 | - 'mailto', | |
| 227 | - 'navigation', | |
| 228 | - 'news-ticker', | |
| 229 | - 'posts', | |
| 230 | - 'price-lists', | |
| 231 | - 'pricing-table', | |
| 232 | - 'qr-code', | |
| 233 | - 'row', | |
| 234 | - 'section-heading', | |
| 235 | - 'skill-bar', | |
| 236 | - 'service', | |
| 237 | - 'services', | |
| 238 | - 'shape-divider', | |
| 239 | - 'slider', | |
| 240 | - 'scroll-to-top', | |
| 241 | - 'social-share', | |
| 242 | - 'whatsapp-chat', | |
| 243 | - 'star-rating', | |
| 244 | - 'stacked-cards', | |
| 245 | - 'svg-draw', | |
| 246 | - 'table-of-content', | |
| 247 | - 'td-viewer', | |
| 248 | - 'team-members', | |
| 249 | - 'testimonials', | |
| 250 | - 'toggle-content', | |
| 251 | - 'accordion-block', | |
| 252 | - 'video', | |
| 253 | - 'text-path', | |
| 254 | - ]; | |
| 255 | - foreach ( $blocks as $block ) { | |
| 256 | - if ( !in_array( "b-blocks/{$block}", $disabledBlocks ) && !in_array( "b-blocks/{$block}", $premiumBlocks ) ) { | |
| 257 | - register_block_type( __DIR__ . "/build/{$block}" ); | |
| 258 | - wp_deregister_script( "b-blocks-{$block}-editor-script" ); | |
| 259 | - } | |
| 260 | - } | |
| 261 | - } | |
| 262 | - | |
| 263 | - function registerSettings() { | |
| 264 | - register_setting( 'bBlocksUtils', 'bBlocksUtils', [ | |
| 265 | - 'show_in_rest' => [ | |
| 266 | - 'name' => 'bBlocksUtils', | |
| 267 | - 'schema' => [ | |
| 268 | - 'type' => 'string', | |
| 269 | - ], | |
| 270 | - ], | |
| 271 | - 'type' => 'string', | |
| 272 | - 'default' => wp_json_encode( [ | |
| 273 | - 'nonce' => wp_create_nonce( 'wp_ajax' ), | |
| 274 | - ] ), | |
| 275 | - 'sanitize_callback' => 'sanitize_text_field', | |
| 276 | - ] ); | |
| 277 | - } | |
| 278 | - | |
| 279 | - function registerCategories( $categories ) { | |
| 280 | - return array_merge( [[ | |
| 281 | - 'slug' => 'bBlocks', | |
| 282 | - 'title' => __( 'bBlocks', 'b-blocks' ), | |
| 283 | - ]], $categories ); | |
| 284 | - } | |
| 285 | - | |
| 286 | - // Register categories | |
| 287 | - //Allow some additional file types for upload | |
| 288 | - function uploadMimes( $mimes ) { | |
| 289 | - $mimes['glb'] = 'model/gltf-binary'; | |
| 290 | - // 3D Viewer | |
| 291 | - $mimes['gltf'] = 'model/gltf-binary'; | |
| 292 | - // 3D Viewer | |
| 293 | - $mimes['json'] = 'application/json'; | |
| 294 | - // Lottie Player | |
| 295 | - $mimes['lottie'] = 'application/json'; | |
| 296 | - // Lottie Player | |
| 297 | - if ( get_transient( 'b-blocks-enable-svg-mime-type' ) === 'true' ) { | |
| 298 | - $mimes['svg'] = 'image/svg+xml'; | |
| 299 | - } | |
| 300 | - return $mimes; | |
| 301 | - } | |
| 302 | - | |
| 303 | - function wpCheckFiletypeAndExt( | |
| 304 | - $data, | |
| 305 | - $file, | |
| 306 | - $filename, | |
| 307 | - $mimes, | |
| 308 | - $real_mime = null | |
| 309 | - ) { | |
| 310 | - // If file extension is 2 or more | |
| 311 | - $f_sp = explode( '.', $filename ); | |
| 312 | - $f_exp_count = count( $f_sp ); | |
| 313 | - if ( $f_exp_count <= 1 ) { | |
| 314 | - return $data; | |
| 315 | - } else { | |
| 316 | - $f_name = $f_sp[0]; | |
| 317 | - $ext = $f_sp[$f_exp_count - 1]; | |
| 318 | - } | |
| 319 | - if ( $ext == 'glb' || $ext == 'gltf' ) { | |
| 320 | - // 3D Viewer | |
| 321 | - $type = 'model/gltf-binary'; | |
| 322 | - $proper_filename = ''; | |
| 323 | - return compact( 'ext', 'type', 'proper_filename' ); | |
| 324 | - } else { | |
| 325 | - if ( $ext == 'json' || $ext === 'lottie' ) { | |
| 326 | - // Lottie Player | |
| 327 | - $type = 'application/json'; | |
| 328 | - $proper_filename = ''; | |
| 329 | - return compact( 'ext', 'type', 'proper_filename' ); | |
| 330 | - } else { | |
| 331 | - return $data; | |
| 332 | - } | |
| 333 | - } | |
| 334 | - } | |
| 335 | - | |
| 336 | - public function enableSvgMimeType() { | |
| 337 | - if ( !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? null ) ), 'wp_ajax' ) ) { | |
| 338 | - wp_send_json_error(); | |
| 339 | - } | |
| 340 | - set_transient( 'b-blocks-enable-svg-mime-type', 'true', 80 ); | |
| 341 | - wp_send_json_success(); | |
| 342 | - } | |
| 343 | - | |
| 344 | - } | |
| 345 | - | |
| 346 | - BBlocks::instance(); | |
| 347 | -} | |
| 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 | +} | |