refactor: one site-wide Divi cache clear and one compatibility row (review M-1, M-2)
DiviSaver's site-wide scopes and the Theme Builder tools now share DiviThemeBuilder::clearSiteCaches(), which clears the Theme Builder cache even when ET_Core_PageResource is missing. lit-site-status no longer lists et_theme_builder_clear_wp_cache twice: the Theme Builder functions row covers it, and the post-type row uses DiviThemeBuilder::postTypes(). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -59,19 +59,15 @@ final class DiviCompatibility
|
|||||||
'GlobalLayout::is_global_layout_template (globale Module)' =>
|
'GlobalLayout::is_global_layout_template (globale Module)' =>
|
||||||
static fn (): bool => method_exists(DiviLibraryStore::GLOBAL_LAYOUT, 'is_global_layout_template'),
|
static fn (): bool => method_exists(DiviLibraryStore::GLOBAL_LAYOUT, 'is_global_layout_template'),
|
||||||
'ET_Core_PageResource (CSS-Cache)' => static fn (): bool => class_exists('ET_Core_PageResource'),
|
'ET_Core_PageResource (CSS-Cache)' => static fn (): bool => class_exists('ET_Core_PageResource'),
|
||||||
'et_theme_builder_clear_wp_cache (Theme-Builder-Cache)' =>
|
|
||||||
static fn (): bool => function_exists('et_theme_builder_clear_wp_cache'),
|
|
||||||
'Block-Typ divi/global-layout (Instanzen globaler Module)' =>
|
'Block-Typ divi/global-layout (Instanzen globaler Module)' =>
|
||||||
static fn (): bool => self::knowsGlobalLayout(),
|
static fn (): bool => self::knowsGlobalLayout(),
|
||||||
'Taxonomien layout_category, layout_tag (Bibliothek)' =>
|
'Taxonomien layout_category, layout_tag (Bibliothek)' =>
|
||||||
static fn (): bool => taxonomy_exists('layout_category') && taxonomy_exists('layout_tag'),
|
static fn (): bool => taxonomy_exists('layout_category') && taxonomy_exists('layout_tag'),
|
||||||
|
// Includes et_theme_builder_clear_wp_cache (Theme Builder cache of every site-wide clear, review M-2).
|
||||||
'Theme Builder: Funktionen et_theme_builder_* und et_()' =>
|
'Theme Builder: Funktionen et_theme_builder_* und et_()' =>
|
||||||
static fn (): bool => (new DiviThemeBuilder())->missing() === [],
|
static fn (): bool => (new DiviThemeBuilder())->missing() === [],
|
||||||
'Theme Builder: Post-Typen et_template und Layouts' => static fn (): bool => array_filter(
|
'Theme Builder: Post-Typen et_template und Layouts' => static fn (): bool => array_filter(
|
||||||
array_merge(
|
DiviThemeBuilder::postTypes(),
|
||||||
[DiviThemeBuilder::THEME_BUILDER, DiviThemeBuilder::TEMPLATE],
|
|
||||||
array_values(DiviThemeBuilder::LAYOUT_TYPES)
|
|
||||||
),
|
|
||||||
static fn (string $type): bool => ! post_type_exists($type)
|
static fn (string $type): bool => ! post_type_exists($type)
|
||||||
) === [],
|
) === [],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use LIT\MCP\Abilities\Errors;
|
|||||||
use LIT\MCP\Abilities\FollowUp;
|
use LIT\MCP\Abilities\FollowUp;
|
||||||
use LIT\MCP\Abilities\Rollback;
|
use LIT\MCP\Abilities\Rollback;
|
||||||
use LIT\MCP\Abilities\WriteFailed;
|
use LIT\MCP\Abilities\WriteFailed;
|
||||||
|
use LIT\MCP\Integrations\Divi\ThemeBuilder\DiviThemeBuilder;
|
||||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||||
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
@@ -106,16 +107,12 @@ class DiviSaver
|
|||||||
}
|
}
|
||||||
FollowUp::run(
|
FollowUp::run(
|
||||||
static function () use ($postId, $scope): void {
|
static function () use ($postId, $scope): void {
|
||||||
if (! class_exists('ET_Core_PageResource')) {
|
if (class_exists('ET_Core_PageResource')) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
\ET_Core_PageResource::remove_static_resources($postId, 'all', true);
|
\ET_Core_PageResource::remove_static_resources($postId, 'all', true);
|
||||||
|
}
|
||||||
// A global library entry is part of every page that shows it (spec §5.6 step 5).
|
// A global library entry is part of every page that shows it (spec §5.6 step 5).
|
||||||
if ($scope->clearsSiteCss()) {
|
if ($scope->clearsSiteCss()) {
|
||||||
\ET_Core_PageResource::remove_static_resources('all', 'all', true);
|
DiviThemeBuilder::clearSiteCaches();
|
||||||
if (function_exists('et_theme_builder_clear_wp_cache')) {
|
|
||||||
et_theme_builder_clear_wp_cache('all');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'divi static css',
|
'divi static css',
|
||||||
|
|||||||
@@ -341,12 +341,21 @@ class DiviThemeBuilder
|
|||||||
/** Divi's Theme Builder cache and every static CSS file (spec §5.6 step 5; api.php:249-254). */
|
/** Divi's Theme Builder cache and every static CSS file (spec §5.6 step 5; api.php:249-254). */
|
||||||
public function clearCaches(): void
|
public function clearCaches(): void
|
||||||
{
|
{
|
||||||
if (function_exists('et_theme_builder_clear_wp_cache')) {
|
self::clearSiteCaches();
|
||||||
et_theme_builder_clear_wp_cache('all');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The site-wide clear shared by the Theme Builder tools and DiviSaver's site-wide scopes (review M-1): every
|
||||||
|
* static CSS file and Divi's Theme Builder cache, each when Divi provides it.
|
||||||
|
*/
|
||||||
|
public static function clearSiteCaches(): void
|
||||||
|
{
|
||||||
if (class_exists('ET_Core_PageResource')) {
|
if (class_exists('ET_Core_PageResource')) {
|
||||||
\ET_Core_PageResource::remove_static_resources('all', 'all', true);
|
\ET_Core_PageResource::remove_static_resources('all', 'all', true);
|
||||||
}
|
}
|
||||||
|
if (function_exists('et_theme_builder_clear_wp_cache')) {
|
||||||
|
et_theme_builder_clear_wp_cache('all');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ final class DiviCompatibilityTest extends TestCase
|
|||||||
'Taxonomien scope, layout_type, module_width (Bibliothek)',
|
'Taxonomien scope, layout_type, module_width (Bibliothek)',
|
||||||
'GlobalLayout::is_global_layout_template (globale Module)',
|
'GlobalLayout::is_global_layout_template (globale Module)',
|
||||||
'ET_Core_PageResource (CSS-Cache)',
|
'ET_Core_PageResource (CSS-Cache)',
|
||||||
'et_theme_builder_clear_wp_cache (Theme-Builder-Cache)',
|
|
||||||
'Block-Typ divi/global-layout (Instanzen globaler Module)',
|
'Block-Typ divi/global-layout (Instanzen globaler Module)',
|
||||||
'Taxonomien layout_category, layout_tag (Bibliothek)',
|
'Taxonomien layout_category, layout_tag (Bibliothek)',
|
||||||
'Theme Builder: Funktionen et_theme_builder_* und et_()',
|
'Theme Builder: Funktionen et_theme_builder_* und et_()',
|
||||||
@@ -44,10 +43,13 @@ final class DiviCompatibilityTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Review M-2: et_theme_builder_clear_wp_cache is one of DiviThemeBuilder::FUNCTIONS – reported once. */
|
||||||
public function testChecksTheThemeBuilderInternals(): void
|
public function testChecksTheThemeBuilderInternals(): void
|
||||||
{
|
{
|
||||||
$labels = array_keys(DiviCompatibility::defaults());
|
$labels = array_keys(DiviCompatibility::defaults());
|
||||||
|
|
||||||
|
self::assertNotContains('et_theme_builder_clear_wp_cache (Theme-Builder-Cache)', $labels);
|
||||||
|
|
||||||
self::assertContains('Theme Builder: Funktionen et_theme_builder_* und et_()', $labels);
|
self::assertContains('Theme Builder: Funktionen et_theme_builder_* und et_()', $labels);
|
||||||
self::assertContains('Theme Builder: Post-Typen et_template und Layouts', $labels);
|
self::assertContains('Theme Builder: Post-Typen et_template und Layouts', $labels);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,21 @@ final class DiviThemeBuilderTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Review M-1: one site-wide clear – every static CSS file and the Theme Builder cache. */
|
||||||
|
public function testClearCachesClearsTheSiteWideCaches(): void
|
||||||
|
{
|
||||||
|
\ET_Core_PageResource::$removed = [];
|
||||||
|
$cleared = [];
|
||||||
|
Functions\when('et_theme_builder_clear_wp_cache')->alias(static function (string $what) use (&$cleared): void {
|
||||||
|
$cleared[] = $what;
|
||||||
|
});
|
||||||
|
|
||||||
|
(new DiviThemeBuilder())->clearCaches();
|
||||||
|
|
||||||
|
self::assertSame([['all', 'all', true]], \ET_Core_PageResource::$removed);
|
||||||
|
self::assertSame(['all'], $cleared);
|
||||||
|
}
|
||||||
|
|
||||||
/** Audit L4: a template is listed when any Theme Builder post's _et_template row names it. */
|
/** Audit L4: a template is listed when any Theme Builder post's _et_template row names it. */
|
||||||
public function testIsListedAnywhereAsksEveryThemeBuilderPost(): void
|
public function testIsListedAnywhereAsksEveryThemeBuilderPost(): void
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user