diff --git a/CHANGELOG.md b/CHANGELOG.md index 02f0d26..6c87752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [v3.10.1] - 2026-11-24 + +- Fix: keep the block editor's default styles for classic themes with editor styles (WP 7.0) + ## [v3.10.0] - 2026-11-12 - Feat: declare REST API route args, so params are documented and validated by WordPress (malformed values now return a 400) diff --git a/openpub-base.php b/openpub-base.php index 9069a96..7066121 100644 --- a/openpub-base.php +++ b/openpub-base.php @@ -4,7 +4,7 @@ * Plugin Name: Yard | OpenPub Base * Plugin URI: https://www.openwebconcept.nl/ * Description: Acts as foundation for other OpenPub related content plugins. This plugin implements actions to allow for other plugins to add and/or change Custom Posttypes, Metaboxes, Taxonomies, en Posts 2 posts relations. - * Version: 3.10.0 + * Version: 3.10.1 * Author: Yard | Digital Agency * Author URI: https://www.yard.nl/ * License: GPL-3.0 diff --git a/src/Base/Admin/AdminServiceProvider.php b/src/Base/Admin/AdminServiceProvider.php index d1abc89..05ffb10 100644 --- a/src/Base/Admin/AdminServiceProvider.php +++ b/src/Base/Admin/AdminServiceProvider.php @@ -14,6 +14,32 @@ public function register(): void $this->plugin->loader->addFilter('post_type_link', $this, 'filterPostLink', 10, 4); $this->plugin->loader->addFilter('preview_post_link', $this, 'filterPreviewLink', 10, 2); $this->plugin->loader->addAction('rest_prepare_openpub-item', $this, 'filterPreviewInNewTabLink', 10, 2); + $this->plugin->loader->addFilter('block_editor_settings_all', $this, 'filterEditorStyles', 20); + } + + /** + * Keep the block editor's default styles for classic themes with editor styles (WP 7.0). + */ + public function filterEditorStyles(array $settings): array + { + // Block themes manage their own editor styles. + if (function_exists('wp_theme_has_theme_json') && wp_theme_has_theme_json()) { + return $settings; + } + + if (empty($settings['styles']) || ! is_array($settings['styles'])) { + return $settings; + } + + // While any style is typed 'theme' (and "Use theme styles" is on), the editor drops its default and layout styles. + foreach ($settings['styles'] as &$style) { + if ('theme' === ($style['__unstableType'] ?? null)) { + $style['__unstableType'] = 'base-layout'; + } + } + unset($style); + + return $settings; } /** diff --git a/src/Base/Foundation/Plugin.php b/src/Base/Foundation/Plugin.php index c6752db..ffe7c22 100644 --- a/src/Base/Foundation/Plugin.php +++ b/src/Base/Foundation/Plugin.php @@ -8,7 +8,7 @@ class Plugin { public const NAME = 'openpub-base'; - public const VERSION = '3.10.0'; + public const VERSION = '3.10.1'; protected string $rootPath; public Config $config;