Snapshot synced v3.6.1 working state as baseline
Machine-sync snapshot: the working tree carried the full 3.0.0-3.6.1 arc (licensing/FileManager/DatabaseExplorer removal, all new replacement screens and REST controllers) that had not been committed on this machine. Captured here as a safety baseline before starting the Adminify-parity revamp. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
07d77bda57
commit
e2db2ad4b5
+32
-126
@@ -2,7 +2,6 @@
|
||||
namespace AuroraAdmin\Pages;
|
||||
|
||||
use AuroraAdmin\Utility\Assets;
|
||||
use AuroraAdmin\Licensing\License;
|
||||
use AuroraAdmin\Options\Settings;
|
||||
|
||||
defined("ABSPATH") || exit();
|
||||
@@ -33,25 +32,17 @@ defined("ABSPATH") || exit();
|
||||
*/
|
||||
class SubApps
|
||||
{
|
||||
// "feature" ties a page to a License::PAID_FEATURES key — null means the
|
||||
// page is free. Locked pages still register normally (real capability,
|
||||
// real URL) but render() swaps in an upgrade prompt instead of the real
|
||||
// feature when unlicensed, and maybe_enqueue() loads that prompt's tiny
|
||||
// JS bundle instead of the real (much heavier) feature bundle.
|
||||
const PAGES = [
|
||||
"aurora-admin-menu-creator" => ["title" => "Menu Creator", "entry" => "menu-creator", "feature" => null],
|
||||
"aurora-admin-notices" => ["title" => "Admin Notices", "entry" => "admin-notices", "feature" => null],
|
||||
"aurora-admin-roles" => ["title" => "Role Editor", "entry" => "role-editor", "feature" => "role-editor"],
|
||||
"aurora-admin-activity-log" => ["title" => "Activity Log", "entry" => "activity-log", "feature" => "activity-log"],
|
||||
"aurora-admin-database" => ["title" => "Database Explorer", "entry" => "database-explorer", "feature" => "database-explorer"],
|
||||
"aurora-admin-file-manager" => ["title" => "File Manager", "entry" => "file-manager", "feature" => "file-manager"],
|
||||
"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],
|
||||
"aurora-admin-pages" => ["title" => "Pages", "entry" => "pages", "feature" => null],
|
||||
"aurora-admin-media" => ["title" => "Media Library", "entry" => "media", "feature" => null],
|
||||
"aurora-admin-users" => ["title" => "Users", "entry" => "users", "feature" => null],
|
||||
];
|
||||
public static function pages()
|
||||
{
|
||||
return [
|
||||
"aurora-admin-menu-creator" => ["title" => __("Menu Creator", "aurora-admin"), "entry" => "menu-creator"],
|
||||
"aurora-admin-notices" => ["title" => __("Admin Notices", "aurora-admin"), "entry" => "admin-notices"],
|
||||
"aurora-admin-roles" => ["title" => __("Role Editor", "aurora-admin"), "entry" => "role-editor"],
|
||||
"aurora-admin-activity-log" => ["title" => __("Activity Log", "aurora-admin"), "entry" => "activity-log"],
|
||||
"aurora-admin-plugins" => ["title" => __("Installed Plugins", "aurora-admin"), "entry" => "plugins"],
|
||||
"aurora-admin-bug-report" => ["title" => __("Report a Bug", "aurora-admin"), "entry" => "bug-report"],
|
||||
];
|
||||
}
|
||||
|
||||
private static $hook_suffixes = [];
|
||||
|
||||
@@ -64,12 +55,12 @@ class SubApps
|
||||
|
||||
public static function register_menus()
|
||||
{
|
||||
foreach (self::PAGES as $slug => $page) {
|
||||
foreach (self::pages() as $slug => $page) {
|
||||
$parent = self::parent_slug($slug);
|
||||
$hook = add_submenu_page(
|
||||
$parent,
|
||||
__($page["title"], "aurora-admin"),
|
||||
__($page["title"], "aurora-admin"),
|
||||
$page["title"],
|
||||
$page["title"],
|
||||
self::capability($slug),
|
||||
$slug,
|
||||
[self::class, "render"]
|
||||
@@ -83,18 +74,6 @@ class SubApps
|
||||
if ($slug === "aurora-admin-plugins") {
|
||||
return "plugins.php";
|
||||
}
|
||||
if ($slug === "aurora-admin-posts") {
|
||||
return "edit.php";
|
||||
}
|
||||
if ($slug === "aurora-admin-pages") {
|
||||
return "edit.php?post_type=page";
|
||||
}
|
||||
if ($slug === "aurora-admin-media") {
|
||||
return "upload.php";
|
||||
}
|
||||
if ($slug === "aurora-admin-users") {
|
||||
return "users.php";
|
||||
}
|
||||
return "aurora-admin";
|
||||
}
|
||||
|
||||
@@ -103,34 +82,18 @@ class SubApps
|
||||
if ($slug === "aurora-admin-plugins") {
|
||||
return "activate_plugins";
|
||||
}
|
||||
if ($slug === "aurora-admin-comments" || $slug === "aurora-admin-posts") {
|
||||
return "edit_posts";
|
||||
}
|
||||
if ($slug === "aurora-admin-pages") {
|
||||
return "edit_pages";
|
||||
}
|
||||
if ($slug === "aurora-admin-media") {
|
||||
return "upload_files";
|
||||
}
|
||||
if ($slug === "aurora-admin-users") {
|
||||
return "list_users";
|
||||
}
|
||||
return "manage_options";
|
||||
}
|
||||
|
||||
public static function maybe_enqueue($hook_suffix)
|
||||
{
|
||||
$slug = array_search($hook_suffix, self::$hook_suffixes, true);
|
||||
if ($slug === false || !isset(self::PAGES[$slug])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$page = self::PAGES[$slug];
|
||||
if ($page["feature"] && !License::is_feature_available($page["feature"])) {
|
||||
Assets::enqueue("aurora-admin-locked-feature", "entries/locked-feature.js");
|
||||
$pages = self::pages();
|
||||
if ($slug === false || !isset($pages[$slug])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$page = $pages[$slug];
|
||||
Assets::enqueue("aurora-admin-" . $page["entry"], "entries/" . $page["entry"] . ".js");
|
||||
}
|
||||
|
||||
@@ -138,6 +101,7 @@ class SubApps
|
||||
{
|
||||
global $pagenow;
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only isset() presence check (no value read), used only to skip pages that already have a ?page= param; no state change.
|
||||
if (isset($_GET["page"]) || wp_doing_ajax()) {
|
||||
return;
|
||||
}
|
||||
@@ -161,82 +125,14 @@ class SubApps
|
||||
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;
|
||||
}
|
||||
|
||||
// Settings > Pages > "Modern pages table".
|
||||
if (
|
||||
$pagenow === "edit.php" &&
|
||||
$post_type === "page" &&
|
||||
current_user_can("edit_pages") &&
|
||||
Settings::get("modern_pages", true)
|
||||
) {
|
||||
wp_safe_redirect(admin_url("admin.php?page=aurora-admin-pages"));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Settings > Media > "Modern media library". upload.php serves both
|
||||
// the default grid view and ?mode=list — both redirect the same way.
|
||||
// media-new.php (the upload/drag-drop screen) is a separate file,
|
||||
// untouched, same as post-new.php for Posts/Pages.
|
||||
if (
|
||||
$pagenow === "upload.php" &&
|
||||
current_user_can("upload_files") &&
|
||||
Settings::get("modern_media", true)
|
||||
) {
|
||||
wp_safe_redirect(admin_url("admin.php?page=aurora-admin-media"));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Settings > Users > "Modern users table". user-new.php (account
|
||||
// creation) is a separate file, untouched.
|
||||
if (
|
||||
$pagenow === "users.php" &&
|
||||
current_user_can("list_users") &&
|
||||
Settings::get("modern_users", true)
|
||||
) {
|
||||
wp_safe_redirect(admin_url("admin.php?page=aurora-admin-users"));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public static function render()
|
||||
{
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only, routes rendering to the matching page's Vue root by slug; no state change.
|
||||
$page = isset($_GET["page"]) ? sanitize_text_field(wp_unslash($_GET["page"])) : "";
|
||||
if (!isset(self::PAGES[$page])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$feature = self::PAGES[$page]["feature"];
|
||||
if ($feature && !License::is_feature_available($feature)) {
|
||||
$data = ["feature" => License::feature_label($feature)];
|
||||
?>
|
||||
<div data-aurora-locked-feature="<?php echo esc_attr(wp_json_encode($data)); ?>"></div>
|
||||
<?php
|
||||
$pages = self::pages();
|
||||
if (!isset($pages[$page])) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -258,7 +154,17 @@ class SubApps
|
||||
"newMediaUrl" => esc_url_raw(admin_url("media-new.php")),
|
||||
"newUserUrl" => esc_url_raw(admin_url("user-new.php")),
|
||||
];
|
||||
$root_id = "aurora-admin-" . self::PAGES[$page]["entry"] . "-root";
|
||||
|
||||
// Report a Bug auto-fills its diagnostic fields from these — saves the
|
||||
// reporter from having to look any of it up themselves.
|
||||
if ($page === "aurora-admin-bug-report") {
|
||||
$data["pluginVersion"] = defined("AURORA_ADMIN_VERSION") ? AURORA_ADMIN_VERSION : "";
|
||||
$data["wpVersion"] = get_bloginfo("version");
|
||||
$data["phpVersion"] = phpversion();
|
||||
$data["theme"] = wp_get_theme()->get("Name");
|
||||
}
|
||||
|
||||
$root_id = "aurora-admin-" . $pages[$page]["entry"] . "-root";
|
||||
?>
|
||||
<div
|
||||
id="<?php echo esc_attr($root_id); ?>"
|
||||
|
||||
Reference in New Issue
Block a user