| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: aBlocks |
| 4 | 4 | * Description: The WordPress plugin for creating beautiful and functional websites using the Gutenberg editor, with a variety of customizable blocks to design website pages. |
| 5 | - * Requires at least: 6.3 | |
| 5 | + * Requires at least: 6.8 | |
| 6 | 6 | * Requires PHP: 7.4 |
| 7 | - * Version: 2.8.1 | |
| 7 | + * Version: 2.13.1 | |
| 8 | 8 | * Author: Kodezen LLC |
| 9 | 9 | * Author URI: https://ablocks.pro/ |
| 10 | 10 | * License: GPL-3.0+ |
| 11 | 11 | * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| @@ -21,10 +21,14 @@ | ||
| 21 | 21 | public function __construct() { |
| 22 | 22 | // define constants |
| 23 | 23 | $this->define_constants(); |
| 24 | 24 | $this->load_dependency(); |
| 25 | + // Register the free product with the shared StoreEngine SDK (loaded in | |
| 26 | + // load_dependency) so the SDK owns the deactivation popup + opt-in. | |
| 27 | + \ABlocks\Admin\StoreLicense::init(); | |
| 25 | 28 | $this->load_cli(); |
| 26 | 29 | register_activation_hook( __FILE__, [ $this, 'activate' ] ); |
| 30 | + register_deactivation_hook( __FILE__, [ $this, 'deactivate' ] ); | |
| 27 | 31 | $this->set_global_settings(); |
| 28 | 32 | add_action( 'plugins_loaded', [ $this, 'on_plugins_loaded' ] ); |
| 29 | 33 | add_action( 'ablocks_loaded', [ $this, 'init_plugin' ] ); |
| 30 | 34 | } |
| @@ -40,9 +44,9 @@ | ||
| 40 | 44 | /** |
| 41 | 45 | * Define the plugin constants |
| 42 | 46 | */ |
| 43 | 47 | private function define_constants() { |
| 44 | - define( 'ABLOCKS_VERSION', '2.8.1' ); | |
| 48 | + define( 'ABLOCKS_VERSION', '2.13.1' ); | |
| 45 | 49 | define( 'ABLOCKS_PLUGIN_SLUG', 'ablocks' ); |
| 46 | 50 | define( 'ABLOCKS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 47 | 51 | define( 'ABLOCKS_ROOT_URL', plugin_dir_url( __FILE__ ) ); |
| 48 | 52 | define( 'ABLOCKS_ASSETS_URL', ABLOCKS_ROOT_URL . 'assets/' ); |
| @@ -61,8 +65,28 @@ | ||
| 61 | 65 | } |
| 62 | 66 | |
| 63 | 67 | public function load_dependency() { |
| 64 | 68 | require_once ABLOCKS_INCLUDES_DIR_PATH . 'autoload.php'; |
| 69 | + | |
| 70 | + // Load the shared StoreEngine License Management Client SDK. aBlocks (free) | |
| 71 | + // owns this version-managed library (Composer package | |
| 72 | + // `storeengine/wordpress-sdk`); aBlocks Pro (and any add-on) reuses the | |
| 73 | + // already-loaded SDK rather than bundling its own copy. | |
| 74 | + if ( file_exists( ABLOCKS_ROOT_DIR_PATH . 'vendor/autoload.php' ) ) { | |
| 75 | + require_once ABLOCKS_ROOT_DIR_PATH . 'vendor/autoload.php'; | |
| 76 | + } | |
| 77 | + | |
| 78 | + // Require the SDK bootstrap DIRECTLY, not only through Composer's files | |
| 79 | + // autoload. Composer de-dupes the SDK's init.php by a package-stable hash, | |
| 80 | + // so when several active plugins each bundle this SDK only the first one's | |
| 81 | + // autoloader includes it and the rest never register their version. Loading | |
| 82 | + // it here guarantees aBlocks' bundled SDK version always joins the | |
| 83 | + // "newest version wins" election regardless of plugin load order. Requiring | |
| 84 | + // init.php registers this SDK version and, on `plugins_loaded`, loads | |
| 85 | + // functions.php (defining se_license_init()) and the SDK class autoloader. | |
| 86 | + if ( file_exists( ABLOCKS_ROOT_DIR_PATH . 'vendor/storeengine/wordpress-sdk/init.php' ) ) { | |
| 87 | + require_once ABLOCKS_ROOT_DIR_PATH . 'vendor/storeengine/wordpress-sdk/init.php'; | |
| 88 | + } | |
| 65 | 89 | } |
| 66 | 90 | public function load_cli() { |
| 67 | 91 | if ( file_exists( ABLOCKS_ROOT_DIR_PATH . 'dev-cli.php' ) ) { |
| 68 | 92 | require_once ABLOCKS_ROOT_DIR_PATH . 'dev-cli.php'; |
| @@ -70,9 +94,16 @@ | ||
| 70 | 94 | } |
| 71 | 95 | |
| 72 | 96 | public function set_global_settings() { |
| 73 | 97 | $GLOBALS['ablocks_fonts'] = json_decode( get_option( ABLOCKS_FONTS_SETTINGS_NAME, '{}' ), true ); |
| 74 | - $GLOBALS['ablocks_blocks'] = json_decode( get_option( ABLOCKS_BLOCKS_VISIBILITY_SETTINGS_NAME, '{}' ) ); | |
| 98 | + // Merge the saved visibility over the default registry so blocks added in | |
| 99 | + // a new version default to enabled (the user's saved toggles still win). | |
| 100 | + $saved_blocks = json_decode( get_option( ABLOCKS_BLOCKS_VISIBILITY_SETTINGS_NAME, '{}' ), true ); | |
| 101 | + $default_blocks = \ABlocks\Admin\Settings\Blocks::get_default_data(); | |
| 102 | + $GLOBALS['ablocks_blocks'] = (object) array_merge( | |
| 103 | + is_array( $default_blocks ) ? $default_blocks : [], | |
| 104 | + is_array( $saved_blocks ) ? $saved_blocks : [] | |
| 105 | + ); | |
| 75 | 106 | $GLOBALS['ablocks_settings'] = json_decode( get_option( ABLOCKS_SETTINGS_NAME, '{}' ) ); |
| 76 | 107 | $GLOBALS['ablocks_addons'] = json_decode( get_option( ABLOCKS_ADDONS_SETTINGS_NAME, '{}' ) ); |
| 77 | 108 | } |
| 78 | 109 | |
| @@ -89,12 +120,37 @@ | ||
| 89 | 120 | } |
| 90 | 121 | |
| 91 | 122 | public function init_plugin() { |
| 92 | 123 | ABlocks\Migration::init(); |
| 124 | + // Before anything that registers a menu, an ajax action or a REST route, | |
| 125 | + // so the capabilities those gate on already answer correctly. | |
| 126 | + ABlocks\Permissions::init(); | |
| 93 | 127 | ABlocks\PermalinkRewrite::init(); |
| 94 | 128 | ABlocks\Addons::init(); |
| 129 | + // Ahead of every block registration on `init` — aBlocks' own and any | |
| 130 | + // other plugin's — so the attribute the editor adds to every block is | |
| 131 | + // on the server's copy of it too. | |
| 132 | + ABlocks\Classes\FlexItem::init(); | |
| 133 | + // Keeps the server-side previews of dynamic blocks rendering when another | |
| 134 | + // plugin adds attributes to every block in JavaScript only. | |
| 135 | + ABlocks\Classes\BlockRendererAttributes::init(); | |
| 95 | 136 | ABlocks\Blocks::init(); |
| 96 | 137 | ABlocks\Assets::init(); |
| 138 | + ABlocks\Classes\CoreFontRegistry::init(); | |
| 139 | + ABlocks\Classes\GlobalClasses::init(); | |
| 140 | + ABlocks\Classes\Breakpoints::init(); | |
| 141 | + ABlocks\Performance\Optimizations::init(); | |
| 142 | + ABlocks\Performance\DelayJs::init(); | |
| 143 | + ABlocks\Performance\DeferJs::init(); | |
| 144 | + ABlocks\Performance\ImageOptimizer::init(); | |
| 145 | + ABlocks\Performance\LcpPreload::init(); | |
| 146 | + ABlocks\Performance\TouchTargets::init(); | |
| 147 | + ABlocks\Performance\PageCache::init(); | |
| 148 | + ABlocks\Performance\StyleConsolidator::init(); | |
| 149 | + ABlocks\Performance\FragmentCache::init(); | |
| 150 | + ABlocks\Performance\TemplateCache::init(); | |
| 151 | + ABlocks\Performance\ImageTools::init(); | |
| 152 | + ABlocks\Classes\Images\UploadGuard::init(); | |
| 97 | 153 | ABlocks\Ajax::init(); |
| 98 | 154 | ABlocks\API::init(); |
| 99 | 155 | if ( is_admin() ) { |
| 100 | 156 | ABlocks\Admin::init(); |
| @@ -104,8 +160,19 @@ | ||
| 104 | 160 | } |
| 105 | 161 | |
| 106 | 162 | public function activate() { |
| 107 | 163 | ABlocks\Installer::init(); |
| 164 | + } | |
| 165 | + | |
| 166 | + /** | |
| 167 | + * Leave no scheduled work behind when the plugin is switched off. | |
| 168 | + * | |
| 169 | + * Cached files are deliberately left in place: deactivation is often | |
| 170 | + * temporary, and re-activating should not mean rebuilding the whole cache. | |
| 171 | + * They are removed on uninstall, or on demand from the Performance tab. | |
| 172 | + */ | |
| 173 | + public function deactivate() { | |
| 174 | + ABlocks\Classes\PageCache\Scheduler::clear_events(); | |
| 108 | 175 | } |
| 109 | 176 | } |
| 110 | 177 | |
| 111 | 178 | /** |