true, 'text' => __('发布', 'aksrt'), 'radius' => 20, 'class' => '', 'types' => []]; $nav = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_header_nav_settings() : ['publish_btn' => true]; // Single source: newposts enabled AND header publish switch. $cfg['enabled'] = !empty($cfg['enabled']) && !empty($nav['publish_btn']); $types = is_array($cfg['types'] ?? null) ? $cfg['types'] : []; if (!$types) { $types = ['post']; if (class_exists('\AKSRT\Settings\Settings')) { $forum = \AKSRT\Settings\Settings::get_forum_settings(); $shop = \AKSRT\Settings\Settings::get_shop_settings(); if (!empty($forum['enabled'])) { $types[] = 'topic'; } if (!empty($shop['enabled'])) { $types[] = 'product'; } } } $cfg['types'] = $types; return $cfg; } endif; if (!function_exists('aksrt_get_new_add_actions')) : /** * Build multi-type publish actions. * * @param string[] $types post|topic|product * @return list */ function aksrt_get_new_add_actions(array $types = ['post']): array { $out = []; 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'); if ($url === '') { continue; } $out[] = [ 'type' => 'post', 'url' => $url, 'label' => __('写文章', 'aksrt'), // FA5 free solid names (avoid FA4 aliases like file-text-o). 'icon' => 'fas fa-file-alt', ]; } elseif ($type === 'topic') { $url = function_exists('aksrt_get_forum_compose_url') ? aksrt_get_forum_compose_url() : ''; if ($url === '') { continue; } $out[] = [ 'type' => 'topic', 'url' => $url, 'label' => __('发帖', 'aksrt'), 'icon' => 'fas fa-comments', ]; } elseif ($type === 'product') { $url = ''; if (function_exists('aksrt_get_product_edit_url')) { $url = (string) aksrt_get_product_edit_url(); } if ($url === '') { $url = admin_url('post-new.php?post_type=aksrt_product'); } $out[] = [ 'type' => 'product', 'url' => $url, 'label' => __('发布商品', 'aksrt'), 'icon' => 'fas fa-shopping-bag', ]; } } return $out; } endif; if (!function_exists('aksrt_normalize_header_cta_label')) : /** * Normalize CTA label HTML: map FA4 classes and keep a single leading icon. */ function aksrt_normalize_header_cta_label(string $label, string $fallback_icon = 'fas fa-pen'): string { $label = trim($label); if ($label === '') { return ' ' . esc_html__('发布', 'aksrt'); } // Common FA4 → FA5 renames used in admin defaults. $replacements = [ 'fa-file-text-o' => 'fa-file-alt', 'fa-file-text' => 'fa-file-alt', 'fa-pencil-square-o' => 'fa-edit', 'fa-pencil' => 'fa-pen', 'fa-comments-o' => 'fa-comments', 'fa-clock-o' => 'fa-clock', 'fa-calendar-check-o'=> 'fa-calendar-check', 'fa-diamond' => 'fa-gem', ]; $label = strtr($label, $replacements); // Ensure icon uses fas (FA5 solid) when only bare "fa " is present. $label = preg_replace('/\bclass=(["\'])fa\s+/', 'class=$1fas ', $label) ?? $label; $label = preg_replace('/