Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.
Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)
Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
(dropped 3 stale entries, added the 17 missing ones)
Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
when it is empty
Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.
Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
131 lines
4.4 KiB
PHP
131 lines
4.4 KiB
PHP
<?php
|
|
/**
|
|
* Header multi-function cluster (legacy publish/VIP subset).
|
|
*
|
|
* @package Jio
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
if (!function_exists('jio_get_new_add_actions')) :
|
|
/**
|
|
* Build multi-type publish actions.
|
|
*
|
|
* @param string[] $types Currently only post is supported.
|
|
* @return list<array{type:string,url:string,label:string,icon:string}>
|
|
*/
|
|
function jio_get_new_add_actions(array $types = ['post']): array {
|
|
$out = [];
|
|
foreach ($types as $type) {
|
|
$type = sanitize_key((string) $type);
|
|
if ($type === 'post') {
|
|
// Front submit page may be unset → jio_get_new_post_url() returns ''.
|
|
// Never drop the publish chip for that: fall back to WP post-new.
|
|
$url = function_exists('jio_get_new_post_url') ? (string) jio_get_new_post_url() : '';
|
|
if ($url === '') {
|
|
$url = admin_url('post-new.php');
|
|
}
|
|
$out[] = [
|
|
'type' => 'post',
|
|
'url' => $url,
|
|
'label' => __('写文章', 'jio'),
|
|
'icon' => 'fa fas fa-file-alt',
|
|
];
|
|
}
|
|
}
|
|
return $out;
|
|
}
|
|
endif;
|
|
|
|
if (!function_exists('jio_render_new_add_btns')) :
|
|
/**
|
|
* Publish chip (legacy newadd-btns, single action).
|
|
*
|
|
* Mirrors the single-button branch of the reference zib_get_new_add_btns():
|
|
* the paint classes ride on the anchor itself and the label is emitted
|
|
* verbatim. Only the post action exists, so there is no dropdown branch.
|
|
*
|
|
* @param string[] $types
|
|
*/
|
|
function jio_render_new_add_btns(array $types, string $class = '', string $label = ''): string {
|
|
if (class_exists('\Jio\Settings\Settings') && \Jio\Settings\Settings::close_sign()) {
|
|
return '';
|
|
}
|
|
|
|
$actions = jio_get_new_add_actions($types);
|
|
if (!$actions) {
|
|
return '';
|
|
}
|
|
|
|
$a = $actions[0];
|
|
if ($label === '') {
|
|
$label = __('发布', 'jio');
|
|
}
|
|
|
|
return '<a rel="nofollow" class="newadd-btns ' . esc_attr($class) . ' btn-newadd" href="' . esc_url($a['url']) . '">'
|
|
. $label . '</a>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Saved through sanitize_type 'html' (wp_kses_post).
|
|
}
|
|
endif;
|
|
|
|
if (!function_exists('jio_render_header_menu_buttons')) :
|
|
/**
|
|
* Publish + optional VIP open button for header CTA.
|
|
*/
|
|
function jio_render_header_menu_buttons(): string {
|
|
$settings = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::read_domain('page_display', 'header-nav') : [];
|
|
$enabled = !isset($settings['nav_newposts']) || !empty($settings['nav_newposts']);
|
|
$text = trim((string) ($settings['nav_newposts_text'] ?? ''));
|
|
$pill = !isset($settings['nav_newposts_radius']) || !empty($settings['nav_newposts_radius']);
|
|
$skin = sanitize_html_class((string) (($settings['nav_newposts_class'] ?? '') ?: 'jb-blue'));
|
|
|
|
$html = '';
|
|
if ($enabled) {
|
|
// legacy default: but nowave jb-blue (+ radius).
|
|
$class = 'but nowave ' . $skin;
|
|
if ($pill && !str_contains($class, 'radius')) {
|
|
$class .= ' radius';
|
|
}
|
|
$label = $text !== '' ? $text : __('发布', 'jio');
|
|
$btn = jio_render_new_add_btns(['post'], $class, $label);
|
|
if ($btn !== '') {
|
|
$html .= $btn;
|
|
}
|
|
}
|
|
|
|
// VIP open CTA for guests / non-VIP (legacy: .pay-vip modal).
|
|
$user_id = get_current_user_id();
|
|
$show_vip = false;
|
|
if (class_exists('\Jio\Settings\Settings')) {
|
|
$vs = \Jio\Settings\Settings::get_payment_vip_settings();
|
|
$show_vip = !empty($vs['enabled']) && !empty($vs['nav_pay_vip'])
|
|
&& !\Jio\Settings\Settings::close_sign();
|
|
}
|
|
if ($show_vip) {
|
|
$is_vip = false;
|
|
if ($user_id > 0 && function_exists('jio_get_user_vip_level')) {
|
|
$is_vip = (int) jio_get_user_vip_level($user_id) > 0;
|
|
}
|
|
if (!$is_vip) {
|
|
$cls = $user_id > 0 ? 'pay-vip' : 'signin-loader';
|
|
$hover = '';
|
|
if (class_exists('\Jio\Content\VipService')) {
|
|
$svc = \Jio\Content\VipService::get_instance();
|
|
if (method_exists($svc, 'render_vip_card')) {
|
|
$cards = $svc->render_vip_card(1, $user_id) . $svc->render_vip_card(2, $user_id);
|
|
if ($cards !== '') {
|
|
$hover = '<div class="sub-menu hover-show-con sub-vip-card">' . $cards . '</div>';
|
|
}
|
|
}
|
|
}
|
|
// legacy: span.hover-show wraps button + .sub-menu.sub-vip-card
|
|
$html .= '<span class="hover-show inline-block">';
|
|
$html .= '<a class="' . esc_attr($cls) . ' but jb-red radius payvip-icon ml10" href="javascript:;">'
|
|
. '<svg class="em12 mr3" aria-hidden="true"><use xlink:href="#icon-vip_1"></use></svg>'
|
|
. esc_html__('开通会员', 'jio') . '</a>' . $hover . '</span>';
|
|
}
|
|
}
|
|
|
|
return $html;
|
|
}
|
|
endif;
|