feat(links): move friend links to native WordPress links with review flow

- enable the native Links manager and drop the custom friend-link option/REST path
- add per-page link settings for the friends template
- render link categories from get_bookmarks() with search and page-content options
- add a validated public link submission endpoint with logo upload, captcha, rate limiting and duplicate checks
- create pending links for review and notify administrators by email and in-app message
- add native Links admin pending count, columns and edit notes
- cover the new submission and cleanup contracts

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-05 19:54:33 +08:00
1 parent ef7b5939ba
commit 4c562428b4
24 files changed
+792 -273

No files matched your search

-1
View File
@@ -189,7 +189,6 @@ trait DisplayPageGroups {
'tabbar' => self::get_footer_tabbar_settings(),
'floating_buttons' => self::get_floating_buttons_settings(),
'header_theme' => self::get_header_theme_config(),
'friend_links' => self::get_friend_links(),
'cms_features' => self::get_cms_features(),
'page_display' => self::get_page_display_settings(),
'footer_theme' => self::get_footer_theme_config(),
-26
View File
@@ -1,26 +0,0 @@
<?php
/**
* @package Jio
*/
namespace Jio\Settings;
defined('ABSPATH') || exit;
class DisplayRuntime {
/** 获取友链列表 */
public static function get_friend_links(): array {
$links = get_option('jio_friend_links', []) ?: [];
return array_values(array_filter($links, static function ($link) {
return !empty($link['active']);
}));
}
/** 保存友链 */
public static function save_friend_links(array $links): void {
update_option('jio_friend_links', $links);
}
}
+24 -1
View File
@@ -220,7 +220,30 @@ final class MailNotifications {
}
public static function friend_link_submitted(array $link): void {
self::send_admin('links_submit_admin', ['title' => (string) ($link['name'] ?? ''), 'username' => __('访客', 'jio'), 'url' => (string) ($link['url'] ?? '')]);
$url = admin_url('link-manager.php?orderby=visible&order=asc');
self::send_admin('links_submit_admin', [
'title' => (string) ($link['link_name'] ?? $link['name'] ?? ''),
'username' => (string) ($link['username'] ?? __('访客', 'jio')),
'url' => (string) ($link['link_url'] ?? $link['url'] ?? $url),
'review_url' => $url,
]);
if (!class_exists('\Jio\Messages\Message') || !class_exists('\Jio\Settings\Integration') || !\Jio\Settings\Integration::message_enabled()) {
return;
}
$title = sprintf(__('新的链接待审核:%s', 'jio'), (string) ($link['link_name'] ?? $link['name'] ?? ''));
$content = sprintf(
__('网站有新的链接提交:%1$s(%2$s),提交人:%3$s。', 'jio'),
(string) ($link['link_name'] ?? $link['name'] ?? ''),
(string) ($link['link_url'] ?? $link['url'] ?? ''),
(string) ($link['username'] ?? __('访客', 'jio'))
);
foreach (get_users(['role' => 'administrator', 'fields' => 'ID', 'number' => 20]) as $admin_id) {
\Jio\Messages\Message::get_instance()->send((int) $admin_id, 'system', $content, [
'title' => $title,
'target_url' => $url,
]);
}
}
/** @param array<string,mixed> $vars */
+1 -1
View File
@@ -13,7 +13,7 @@ final class MailTemplates {
/** @return array<string, array<string, mixed>> */
public static function definitions(): array {
return [
'links_submit_admin' => self::event('友情链接提交通知', '新友情链接提交:{title}\n提交人:{username}\n链接:{url}\n请登录后台审核。', ['title', 'username', 'url']),
'links_submit_admin' => self::event('友情链接提交通知', '新友情链接提交:{title}\n提交人:{username}\n链接:{url}\n请登录后台审核:{review_url}', ['title', 'username', 'url', 'review_url']),
'order_paid_admin' => self::event('新订单通知(管理员)', '收到一笔新订单。\n订单号:{order_number}\n用户:{username}\n商品:{product}\n金额:{amount} {currency}\n支付方式:{payment_method}', ['order_number', 'username', 'product', 'amount', 'currency', 'payment_method']),
'withdraw_submitted_admin' => self::event('提现申请通知(管理员)', '用户 {username} 提交了提现申请。\n订单号:{withdrawal_number}\n金额:{amount}\n方式:{method}', ['username', 'withdrawal_number', 'amount', 'method']),
'post_pending_admin' => self::event('投稿待审核通知', '用户 {username} 提交了待审核内容:{title}\n查看地址:{url}', ['username', 'title', 'url']),
-16
View File
@@ -40,7 +40,6 @@ class Settings {
'jio_floating_buttons',
'jio_credit_settings',
'jio_notification_settings',
'jio_friend_links',
'jio_category_recommend',
];
@@ -705,21 +704,6 @@ class Settings {
public static function apply_list_per_page($query): void {
PostDisplay::apply_list_per_page($query);
}
/** 获取友链列表 */
public static function get_friend_links(): array {
return DisplayRuntime::get_friend_links();
}
/** 保存友链 */
public static function save_friend_links(array $links): void {
DisplayRuntime::save_friend_links($links);
}
/** 获取微信公众号登录完整配置。 */
public static function get_weixingzh_settings(): array {
return Integration::get_weixingzh_settings();