- Replace transfer modal/admin-post flow with reference-style AJAX export/import/template dialogs (admin-transfer.js, TransferController) - Customizer "移出模块" action, reference lazy form loading with t-notice - Common fields use reference labels, dependencies, compact/inline rows, top/bottom-only extra spacing; form header with description/reminder - Remove placement hint, template preview and legacy transfer code - Fix widget audit (current_datetime stub, honor catalog common flags) and regenerate stale golden fixtures for posts_toc, quote, posts Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace AKSRT\WidgetSystem;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
/**
|
|
* Single bootstrap for the schema-driven widget runtime.
|
|
*/
|
|
final class Runtime {
|
|
private static bool $registered = false;
|
|
|
|
public static function init(): void {
|
|
if (self::$registered) {
|
|
return;
|
|
}
|
|
self::$registered = true;
|
|
|
|
add_action('widgets_init', [self::class, 'unregister_core_widgets'], 1);
|
|
add_action('widgets_init', [WidgetAreas::class, 'register'], 5);
|
|
add_action('widgets_init', [self::class, 'register_widgets'], 10);
|
|
add_action('save_post_page', [WidgetAreas::class, 'flush_page_cache']);
|
|
add_action('rest_api_init', static function (): void {
|
|
(new RestController())->register_routes();
|
|
});
|
|
add_action('wp_enqueue_scripts', [AssetManager::class, 'enqueue_active'], 20);
|
|
|
|
AdminFormController::register_hooks();
|
|
TransferController::register_hooks();
|
|
}
|
|
|
|
public static function unregister_core_widgets(): void {
|
|
foreach ([
|
|
'WP_Widget_RSS',
|
|
'WP_Widget_Recent_Posts',
|
|
'WP_Widget_Recent_Comments',
|
|
'WP_Widget_Pages',
|
|
'WP_Widget_Search',
|
|
'WP_Widget_Calendar',
|
|
] as $class) {
|
|
unregister_widget($class);
|
|
}
|
|
}
|
|
|
|
public static function register_widgets(): void {
|
|
foreach (WidgetRegistry::all() as $definition) {
|
|
register_widget(new SchemaWidget($definition));
|
|
}
|
|
}
|
|
}
|