| @@ -1,132 +1,74 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Plugin Name: B Blocks | |
| 3 | + * Plugin Name: bBlocks | |
| 4 | 4 | * Description: Gutenberg Blocks Collection and Page Builder. |
| 5 | - * Version: 1.3 | |
| 6 | - * Author: bPlugins LLC | |
| 7 | - * Author URI: http://bplugins.com | |
| 8 | - * License: GPLv3 | |
| 9 | - * License URI: https://www.gnu.org/licenses/gpl-2.0.txt | |
| 5 | + * Version: 2.1.8 | |
| 6 | + * Author: bPlugins | |
| 7 | + * Author URI: https://bplugins.com | |
| 8 | + * License: GPLv3 or later | |
| 9 | + * License URI: https://www.gnu.org/licenses/gpl-3.0.html | |
| 10 | 10 | * Text Domain: b-blocks |
| 11 | - */ | |
| 11 | + */ | |
| 12 | 12 | |
| 13 | 13 | // ABS PATH |
| 14 | -if ( !defined( 'ABSPATH' ) ) { | |
| 15 | - exit; | |
| 14 | +if (!defined('ABSPATH')) { | |
| 15 | + exit; | |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -// Constant | |
| 19 | -define( 'B_BLOCKS_PLUGIN_VERSION', '1.3' ); | |
| 20 | -define( "B_BLOCKS_ASSETS_DIR", plugin_dir_url( __FILE__ ) . 'assets/' ); | |
| 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 | + }); | |
| 27 | +} else { | |
| 21 | 28 | |
| 22 | -// Register Block Category | |
| 23 | -function b_blocks_block_categories( $categories ) { | |
| 24 | - return array_merge( | |
| 25 | - array( | |
| 26 | - array( | |
| 27 | - 'slug' => 'bBlocks', | |
| 28 | - 'title' => __( 'B Blocks', 'b-blocks' ), | |
| 29 | - ), | |
| 30 | - ), | |
| 31 | - $categories | |
| 32 | - ); | |
| 33 | -} | |
| 34 | -add_filter( 'block_categories', 'b_blocks_block_categories' ); | |
| 29 | + define( 'B_BLOCKS_FILE', __FILE__ ); | |
| 35 | 30 | |
| 36 | -// Register Blocks | |
| 37 | -function b_blocks_wp_register_script( $block, $options = array() ) { | |
| 38 | - register_block_type( | |
| 39 | - 'b-blocks/' . $block, | |
| 40 | - array_merge( | |
| 41 | - array( | |
| 42 | - 'editor_script' => 'b_blocks_editor_script', | |
| 43 | - 'editor_style' => 'b_blocks_editor_style', | |
| 44 | - 'script' => 'b_blocks_script', | |
| 45 | - 'style' => 'b_blocks_style', | |
| 46 | - ), | |
| 47 | - $options | |
| 48 | - ) | |
| 49 | - ); | |
| 50 | -} | |
| 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'; | |
| 51 | 35 | |
| 52 | -// Enqueue assets | |
| 53 | -function b_blocks_enqueue_block_assets() { | |
| 54 | - wp_enqueue_style( 'bootstrap', B_BLOCKS_ASSETS_DIR . 'css/bootstrap.min.css', '', '4.6.0', 'all' ); | |
| 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'; | |
| 55 | 63 | |
| 56 | - wp_enqueue_script( 'bootstrap', B_BLOCKS_ASSETS_DIR . 'js/bootstrap.bundle.min.js', array( 'jquery' ), '4.6.0', true ); | |
| 57 | - wp_enqueue_script( 'mailtoui', B_BLOCKS_ASSETS_DIR . 'js/mailtoui-min.js', array(), B_BLOCKS_PLUGIN_VERSION, true ); | |
| 58 | -} | |
| 59 | -add_action( 'enqueue_block_assets', 'b_blocks_enqueue_block_assets' ); | |
| 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'; | |
| 60 | 69 | |
| 61 | -function b_blocks_enqueue_assets() { | |
| 62 | - wp_enqueue_style( 'fancybox', B_BLOCKS_ASSETS_DIR . 'css/fancybox.min.css', '', '3.5.6', 'all' ); | |
| 63 | - | |
| 64 | - wp_enqueue_script( 'fancybox', B_BLOCKS_ASSETS_DIR . 'js/fancybox.min.js', array( 'jquery' ), '3.5.6', true ); | |
| 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 | + } | |
| 65 | 74 | } |
| 66 | -add_action( 'wp_enqueue_scripts', 'b_blocks_enqueue_assets' ); | |
| 67 | - | |
| 68 | -function b_blocks_register() { | |
| 69 | - // Resister script in editor | |
| 70 | - wp_register_script( 'b_blocks_editor_script', plugins_url( 'dist/editor.js', __FILE__ ), array( 'wp-blocks', 'wp-element', 'wp-data', 'wp-i18n', 'wp-editor', 'wp-components', 'wp-blob', 'wp-html-entities', 'wp-compose', 'wp-rich-text' ), null, false ); | |
| 71 | - // Register style in editor | |
| 72 | - wp_register_style( 'b_blocks_editor_style', plugins_url( 'dist/editor.css', __FILE__ ), array( 'wp-edit-blocks' ), null ); | |
| 73 | - | |
| 74 | - // Register script in frontend | |
| 75 | - wp_register_script( 'b_blocks_script', plugins_url( 'dist/script.js', __FILE__ ), array( 'jquery' ), null, true ); | |
| 76 | - // Register style in frontend | |
| 77 | - wp_register_style( 'b_blocks_style', plugins_url( 'dist/style.css', __FILE__ ), array( 'wp-editor' ), null ); | |
| 78 | - | |
| 79 | - // Register Blocks | |
| 80 | - b_blocks_wp_register_script( 'posts', array( | |
| 81 | - 'render_callback' => 'render_b_blocks_posts', | |
| 82 | - // 'attributes' => array( | |
| 83 | - // 'postsPerPage' => array( 'type' => 'number', 'default' => 5 ), | |
| 84 | - // ), | |
| 85 | - ) ); | |
| 86 | - b_blocks_wp_register_script( 'slider' ); | |
| 87 | - b_blocks_wp_register_script( 'section' ); | |
| 88 | - b_blocks_wp_register_script( 'section-heading' ); | |
| 89 | - b_blocks_wp_register_script( 'image-gallery' ); | |
| 90 | - b_blocks_wp_register_script( 'price-lists' ); | |
| 91 | - b_blocks_wp_register_script( 'price-list' ); | |
| 92 | - b_blocks_wp_register_script( 'feature-boxes' ); | |
| 93 | - b_blocks_wp_register_script( 'feature-box' ); | |
| 94 | - b_blocks_wp_register_script( 'info-box' ); | |
| 95 | - b_blocks_wp_register_script( 'button-group' ); | |
| 96 | - b_blocks_wp_register_script( 'countdown' ); | |
| 97 | - b_blocks_wp_register_script( 'card' ); | |
| 98 | - b_blocks_wp_register_script( 'mailto' ); | |
| 99 | - b_blocks_wp_register_script( 'modal' ); | |
| 100 | - b_blocks_wp_register_script( 'tabs' ); | |
| 101 | - b_blocks_wp_register_script( 'accordion' ); | |
| 102 | - b_blocks_wp_register_script( 'note' ); | |
| 103 | - b_blocks_wp_register_script( 'gif' ); | |
| 104 | - b_blocks_wp_register_script( 'qr-code' ); | |
| 105 | - b_blocks_wp_register_script( 'highlight-text' ); | |
| 106 | - b_blocks_wp_register_script( 'progress-bar' ); | |
| 107 | - b_blocks_wp_register_script( 'spacer' ); | |
| 108 | - b_blocks_wp_register_script( 'selection' ); | |
| 109 | - b_blocks_wp_register_script( 'divider' ); | |
| 110 | - b_blocks_wp_register_script( 'to-top' ); | |
| 111 | - | |
| 112 | - // WP Localized globals. | |
| 113 | - wp_localize_script( | |
| 114 | - 'b_blocks_editor_script', | |
| 115 | - 'bBlocksAdmin', // Array containing dynamic data for a JS Global. | |
| 116 | - array( | |
| 117 | - 'pluginDirPath' => plugin_dir_path( __DIR__ ), | |
| 118 | - 'pluginDirUrl' => plugin_dir_url( __DIR__ ), | |
| 119 | - 'siteUrl' => get_site_url(), | |
| 120 | - ) | |
| 121 | - ); | |
| 122 | -} | |
| 123 | -add_action( 'init', 'b_blocks_register' ); | |
| 124 | - | |
| 125 | -// After Setup Theme | |
| 126 | -function b_blocks_after_setup_theme() { | |
| 127 | - add_theme_support( 'align-wide' ); | |
| 128 | -} | |
| 129 | -add_action( 'after_setup_theme', 'b_blocks_after_setup_theme' ); | |
| 130 | - | |
| 131 | -// Block Initializer. | |
| 132 | -require_once plugin_dir_path( __FILE__ ) . 'inc/posts.php'; | |