Add a real replacement Posts management page (v2.5.0)

Posts was previously just dark-themed skinning over the native
edit.php list table, unlike Comments/Plugins which are genuine
replacements. Built the same way: new PostsData.php REST controller
(list with status/search filters matching native tabs, trash, restore,
permanent delete) and a Vue page matching the Comments layout.

- SubApps.php registers it as aurora-admin-posts, parented under
  edit.php (same pattern as Plugins under plugins.php).
- redirect_native_pages() redirects direct edit.php visits (typed URL,
  not just the sidebar link) to the Aurora page — gated to the default
  post type only, so Pages and other custom post types are untouched.
- MenuSerializer rewrites the sidebar's Posts/All Posts links the same
  way Plugins/Comments already were.
- Gated by Settings > Posts' "Modern posts table" toggle, re-added now
  that it has a real implementation (it was removed a few commits ago
  for describing a feature that didn't exist).
- Fixed modern_plugins/modern_comments/modern_posts all defaulting to
  visually "on" in the Settings UI to match their actual PHP default.

Verified live: trash/restore/status filters/search all work correctly,
edit.php redirects to the Aurora page, edit.php?post_type=page (Pages)
correctly does not.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
nixpanel
2026-07-05 05:59:11 -05:00
co-authored by Claude Sonnet 5
parent d8bf1ae049
commit 56b6674527
12 changed files with 998 additions and 18 deletions
+32 -14
View File
@@ -46,6 +46,7 @@ class SubApps
"aurora-admin-database" => ["title" => "Database Explorer", "entry" => "database-explorer", "feature" => "database-explorer"],
"aurora-admin-plugins" => ["title" => "Installed Plugins", "entry" => "plugins", "feature" => null],
"aurora-admin-comments" => ["title" => "Comments", "entry" => "comments", "feature" => null],
"aurora-admin-posts" => ["title" => "Posts", "entry" => "posts", "feature" => null],
];
private static $hook_suffixes = [];
@@ -78,6 +79,9 @@ class SubApps
if ($slug === "aurora-admin-plugins") {
return "plugins.php";
}
if ($slug === "aurora-admin-posts") {
return "edit.php";
}
return "aurora-admin";
}
@@ -86,7 +90,7 @@ class SubApps
if ($slug === "aurora-admin-plugins") {
return "activate_plugins";
}
if ($slug === "aurora-admin-comments") {
if ($slug === "aurora-admin-comments" || $slug === "aurora-admin-posts") {
return "edit_posts";
}
return "manage_options";
@@ -112,23 +116,36 @@ class SubApps
{
global $pagenow;
// Settings > Comments > "Modern comments page" — previously always
// redirected regardless of this setting; default true so existing
// installs keep their current behavior until explicitly turned off.
if (!Settings::get("modern_comments", true)) {
return;
}
if ($pagenow !== "edit-comments.php" || !current_user_can("edit_posts")) {
return;
}
if (isset($_GET["page"]) || wp_doing_ajax()) {
return;
}
wp_safe_redirect(admin_url("admin.php?page=aurora-admin-comments"));
exit;
// Settings > Comments > "Modern comments page" — previously always
// redirected regardless of this setting; default true so existing
// installs keep their current behavior until explicitly turned off.
if (
$pagenow === "edit-comments.php" &&
current_user_can("edit_posts") &&
Settings::get("modern_comments", true)
) {
wp_safe_redirect(admin_url("admin.php?page=aurora-admin-comments"));
exit;
}
// Settings > Posts > "Modern posts table". Only the default post-list
// view (edit.php with no post_type, or post_type=post) redirects —
// edit.php?post_type=page (Pages) and other custom post types are
// untouched, since only Posts has a replacement page.
$post_type = isset($_GET["post_type"]) ? sanitize_key(wp_unslash($_GET["post_type"])) : "post";
if (
$pagenow === "edit.php" &&
$post_type === "post" &&
current_user_can("edit_posts") &&
Settings::get("modern_posts", true)
) {
wp_safe_redirect(admin_url("admin.php?page=aurora-admin-posts"));
exit;
}
}
public static function render()
@@ -160,6 +177,7 @@ class SubApps
"userName" => wp_get_current_user()->display_name,
"roles" => $roles,
"tablePrefix" => $wpdb->prefix,
"newPostUrl" => esc_url_raw(admin_url("post-new.php")),
];
$root_id = "aurora-admin-" . self::PAGES[$page]["entry"] . "-root";
?>