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:
2026-07-25 12:00:07 +08:00
parent e194c603cb
commit c8b4d1a851
2 changed files with 39 additions and 5 deletions
@@ -67,9 +67,14 @@
/* Multi-type toggle lives outside .navbar-but-cluster on live zibll DOM.
* Paint classes (jb-*) set --this-bg on the toggle; force them to show. */
.navbar-top .navbar-form.navbar-but .newadd-btns__toggle.navbar-cta,
.navbar-top .navbar-but .newadd-btns__toggle.navbar-cta {
.navbar-top .navbar-but .newadd-btns__toggle.navbar-cta,
.navbar-top .navbar-form.navbar-but a.navbar-newposts.navbar-cta,
.navbar-top .navbar-form.navbar-but a.newadd-btns.navbar-cta {
display: inline-flex !important;
visibility: visible !important;
opacity: 1 !important;
color: #fff !important;
background: var(--this-bg, var(--color-primary, #2f6df6)) !important;
background: var(--this-bg, linear-gradient(135deg, #59c3fb 10%, #268df7 100%)) !important;
border-radius: var(--navbar-cta-radius, 50px);
cursor: pointer;
}
@@ -798,3 +803,20 @@ body.dark-theme .toggle-theme .theme-icon-sun {
width: min(220px, 42vw);
}
}
/* Ensure publish form is never zero-sized */
.navbar-top .navbar-form.navbar-but {
display: flex !important;
align-items: center !important;
visibility: visible !important;
min-width: 0;
flex: 0 0 auto;
}
.navbar-top .navbar-form.navbar-but .newadd-btns.hover-show {
display: block !important;
visibility: visible !important;
width: fit-content !important;
max-width: fit-content !important;
line-height: normal !important;
}
+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');