diff --git a/CHANGELOG.md b/CHANGELOG.md index 009edd7..120364f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [2.1.0] + +### Changed + +- Core Framework now requires WordPress 6.6 or newer. The block editor integration is built against the `react-jsx-runtime` script that WordPress first ships in 6.6. Sites on WordPress 6.0 to 6.5 should stay on Core Framework 2.0.2. + +### Fixed + +- Fixed the block editor going blank with the Core Framework Gutenberg integration enabled. The editor script was loaded with an outdated, hard-coded dependency list that left out WordPress's `react-jsx-runtime`, so rendering the Core Framework class panel threw on an undefined `ReactJSXRuntime` and took the whole editor down. The script now loads the dependencies its build declares. + ## [2.0.2] - 2026-08-28 ### Fixed diff --git a/README.md b/README.md index 099879c..d115938 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Core Framework is a visual CSS framework and design-token builder for the web, W [![GitHub stars](https://img.shields.io/github/stars/corebunch/core-framework?style=flat&label=stars&labelColor=171923&color=ffd43b)](https://github.com/corebunch/core-framework/stargazers) [![License: MIT](https://img.shields.io/badge/license-MIT-5c62ff?labelColor=171923)](LICENSE) [![Runtime: Bun](https://img.shields.io/badge/runtime-Bun-f9f1e1?labelColor=171923)](https://bun.sh) -[![WordPress](https://img.shields.io/badge/WordPress-6.0%2B-21759b?labelColor=171923)](https://wordpress.org/plugins/core-framework/) +[![WordPress](https://img.shields.io/badge/WordPress-6.6%2B-21759b?labelColor=171923)](https://wordpress.org/plugins/core-framework/) [Website](https://coreframework.com) · [Product tour](#product-tour) · [Quick start](#quick-start) · [Documentation](https://docs.coreframework.com) · [Contributing](CONTRIBUTING.md) · [Marketplace](https://coreframework.com/marketplace) @@ -219,7 +219,7 @@ Then publish `packages/www/dist` at the matching path, such as `https://example. ## WordPress development -Requirements: WordPress 6.0 or newer, PHP 8.0 or newer, Composer, Bun 1.3.x, and a local HTTPS certificate. +Requirements: WordPress 6.6 or newer, PHP 8.0 or newer, Composer, Bun 1.3.x, and a local HTTPS certificate. 1. Link the plugin package into your WordPress installation: diff --git a/packages/wp/Tests/GutenbergEnqueueTest.php b/packages/wp/Tests/GutenbergEnqueueTest.php new file mode 100644 index 0000000..538401b --- /dev/null +++ b/packages/wp/Tests/GutenbergEnqueueTest.php @@ -0,0 +1,99 @@ + '0.0.0-test' ) ); + } +} + +if ( ! function_exists( 'plugin_dir_path' ) ) { + function plugin_dir_path( $file ) { + return rtrim( dirname( $file ), '/\\' ) . '/'; + } +} + +if ( ! function_exists( 'plugins_url' ) ) { + function plugins_url( $path = '', $plugin = '' ) { + return 'https://example.test/wp-content/plugins/core-framework/' . ltrim( $path, '/' ); + } +} + +if ( ! function_exists( 'wp_enqueue_script' ) ) { + function wp_enqueue_script( $handle, $src = '', $deps = array(), $ver = false, $args = array() ) { + $GLOBALS['cf_test_enqueued_scripts'][ $handle ] = array( + 'src' => $src, + 'deps' => $deps, + 'ver' => $ver, + ); + } +} + +final class CoreFrameworkGutenbergEnqueueTestPlugin { + public function enqueue_core_framework_connector(): void {} + + public function isDev(): bool { + return false; + } +} + +if ( ! function_exists( 'CoreFramework' ) ) { + function CoreFramework() { + return new CoreFrameworkGutenbergEnqueueTestPlugin(); + } +} + +final class GutenbergEnqueueTest extends TestCase { + private const HANDLE = 'core-framework-gutenberg-plugin'; + + protected function setUp(): void { + $GLOBALS['cf_test_enqueued_scripts'] = array(); + } + + private function enqueue(): array { + ( new GutenbergFunctions() )->enqueue_scripts(); + + $this->assertArrayHasKey( self::HANDLE, $GLOBALS['cf_test_enqueued_scripts'] ); + + return $GLOBALS['cf_test_enqueued_scripts'][ self::HANDLE ]; + } + + private function manifest(): array { + return require dirname( __DIR__ ) . '/gutenberg/index.asset.php'; + } + + public function test_bundle_declares_the_jsx_runtime_it_calls(): void { + $bundle = file_get_contents( dirname( __DIR__ ) . '/gutenberg/index.js' ); + + $this->assertStringContainsString( 'ReactJSXRuntime', $bundle ); + $this->assertContains( 'react-jsx-runtime', $this->manifest()['dependencies'] ); + } + + public function test_enqueue_depends_on_the_jsx_runtime(): void { + $this->assertContains( 'react-jsx-runtime', $this->enqueue()['deps'] ); + } + + public function test_enqueue_uses_the_shipped_asset_manifest(): void { + $script = $this->enqueue(); + $manifest = $this->manifest(); + + $this->assertSame( $manifest['dependencies'], $script['deps'] ); + $this->assertSame( $manifest['version'], $script['ver'] ); + } +} diff --git a/packages/wp/core-framework.php b/packages/wp/core-framework.php index 63dc78e..d92fda7 100644 --- a/packages/wp/core-framework.php +++ b/packages/wp/core-framework.php @@ -18,7 +18,7 @@ * License: MIT * License URI: https://opensource.org/license/mit * Requires PHP: 8.0 - * Requires at least: 6.0 + * Requires at least: 6.6 * Namespace: CoreFramework */ diff --git a/packages/wp/readme.txt b/packages/wp/readme.txt index 659204c..0c4def3 100644 --- a/packages/wp/readme.txt +++ b/packages/wp/readme.txt @@ -1,7 +1,7 @@ === Core Framework === Contributors: coreframework Tags: css, framework, stylesheet, bricks, oxygen -Requires at least: 6.0 +Requires at least: 6.6 Requires PHP: 8.0 Tested up to: 7.0 Stable tag: 2.0.2 diff --git a/packages/wp/wp/App/Gutenberg/Functions.php b/packages/wp/wp/App/Gutenberg/Functions.php index 4e48a5a..ce9e2e7 100644 --- a/packages/wp/wp/App/Gutenberg/Functions.php +++ b/packages/wp/wp/App/Gutenberg/Functions.php @@ -262,17 +262,33 @@ public function add_colors( $theme_json ) { public function enqueue_scripts() { CoreFramework()->enqueue_core_framework_connector(); - $version = $this->plugin->version(); + $script_path = plugin_dir_path( CORE_FRAMEWORK_ABSOLUTE ) . 'gutenberg/index.js'; + $script_asset_path = plugin_dir_path( CORE_FRAMEWORK_ABSOLUTE ) . 'gutenberg/index.asset.php'; + $script_asset = array( + 'dependencies' => array( + 'react', + 'react-jsx-runtime', + 'wp-block-editor', + 'wp-components', + 'wp-compose', + 'wp-data', + 'wp-element', + 'wp-plugins', + ), + 'version' => \file_exists( $script_path ) + ? \filemtime( $script_path ) + : $this->plugin->version(), + ); - if ( \file_exists( plugin_dir_path( CORE_FRAMEWORK_ABSOLUTE ) . 'gutenberg/index.js' ) ) { - $version = \filemtime( plugin_dir_path( CORE_FRAMEWORK_ABSOLUTE ) . 'gutenberg/index.js' ); + if ( \file_exists( $script_asset_path ) ) { + $script_asset = require $script_asset_path; } wp_enqueue_script( 'core-framework-gutenberg-plugin', plugins_url( 'gutenberg/index.js', CORE_FRAMEWORK_ABSOLUTE ), - array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ), - $version, + $script_asset['dependencies'], + $script_asset['version'], true ); }