fix(nav): never drop top-nav 发布 when submit page URL is empty

aksrt_get_new_post_url() returns '' without a page-submit assignment,
which previously skipped the post action and emptied the multi-type
chip. Fall back to post-new.php, keep a last-resort action list, put
radius/jb paint on the toggle, and force chip visibility CSS.
This commit is contained in:
kate522 committed 2026-07-25 12:00:07 +08:00
1 parent e194c603cb
commit c8b4d1a851
2 files changed
+39 -5

No files matched your search

+15 -3
View File
@@ -53,9 +53,11 @@ if (!function_exists('aksrt_get_new_add_actions')) :
foreach ($types as $type) {
$type = sanitize_key((string) $type);
if ($type === 'post') {
$url = function_exists('aksrt_get_new_post_url') ? aksrt_get_new_post_url() : admin_url('post-new.php');
// Front submit page may be unset → aksrt_get_new_post_url() returns ''.
// Never drop the publish chip for that: fall back to WP post-new.
$url = function_exists('aksrt_get_new_post_url') ? (string) aksrt_get_new_post_url() : '';
if ($url === '') {
continue;
$url = admin_url('post-new.php');
}
$out[] = [
'type' => 'post',
@@ -165,7 +167,17 @@ if (!function_exists('aksrt_render_new_add_btns')) :
function aksrt_render_new_add_btns(array $types, string $class = '', string $label = ''): string {
$actions = aksrt_get_new_add_actions($types);
if (!$actions) {
return '';
// Last resort: keep a write-post entry so the top-nav chip is never blank.
$fallback = function_exists('aksrt_get_new_post_url') ? (string) aksrt_get_new_post_url() : '';
if ($fallback === '') {
$fallback = admin_url('post-new.php');
}
$actions = [[
'type' => 'post',
'url' => $fallback,
'label' => __('写文章', 'aksrt'),
'icon' => 'fas fa-file-alt',
]];
}
if ($label === '') {
$label = __('发布', 'aksrt');