refactor: rename the theme brand and every identifier from AKSRT to Jio

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>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-01 20:05:04 +08:00
1 parent 5b16bc6e15
commit 35bb96e82f
997 files changed
+28216 -28188

No files matched your search

+119 -119
View File
@@ -1,15 +1,15 @@
<?php
/**
* AKSRT User Notifications
* Jio User Notifications
*
* Notification CRUD, AJAX handlers, and event-driven notification creators.
*
* @package AKSRT
* @package Jio
*/
defined('ABSPATH') || exit;
if (!function_exists('aksrt_get_user_notifications')) :
if (!function_exists('jio_get_user_notifications')) :
/**
* 获取用户提醒列表(即时提醒,不持久化)
*
@@ -18,7 +18,7 @@ if (!function_exists('aksrt_get_user_notifications')) :
* @param int $user_id 用户 ID,默认当前用户
* @return array<int, array{type:string,title:string,desc:string,url:string,count:int}>
*/
function aksrt_get_user_notifications(int $user_id = 0): array {
function jio_get_user_notifications(int $user_id = 0): array {
$user_id = $user_id > 0 ? $user_id : get_current_user_id();
if ($user_id <= 0) {
return [];
@@ -34,14 +34,14 @@ function aksrt_get_user_notifications(int $user_id = 0): array {
if (
$pending_comments > 0
&& (!class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::notification_enabled('pending_comments'))
&& (!class_exists('\AKSRT\User\NotificationPreferences') || \AKSRT\User\NotificationPreferences::allows($user_id, 'pending_comments'))
&& (!class_exists('\Jio\Settings\Settings') || \Jio\Settings\Settings::notification_enabled('pending_comments'))
&& (!class_exists('\Jio\User\NotificationPreferences') || \Jio\User\NotificationPreferences::allows($user_id, 'pending_comments'))
) {
$items[] = [
'type' => 'pending_comments',
'title' => __('评论待审核', 'aksrt'),
'desc' => sprintf(__('你有 %d 条评论正在等待审核。', 'aksrt'), $pending_comments),
'url' => aksrt_get_user_center_url('comments'),
'title' => __('评论待审核', 'jio'),
'desc' => sprintf(__('你有 %d 条评论正在等待审核。', 'jio'), $pending_comments),
'url' => jio_get_user_center_url('comments'),
'count' => $pending_comments,
];
}
@@ -50,10 +50,10 @@ function aksrt_get_user_notifications(int $user_id = 0): array {
}
endif;
if (!function_exists('aksrt_get_user_notification_count')) :
if (!function_exists('jio_get_user_notification_count')) :
/** 获取用户提醒总数 */
function aksrt_get_user_notification_count(int $user_id = 0): int {
$items = aksrt_get_user_notifications($user_id);
function jio_get_user_notification_count(int $user_id = 0): int {
$items = jio_get_user_notifications($user_id);
$count = 0;
foreach ($items as $item) {
$count += max(0, (int) ($item['count'] ?? 0));
@@ -62,16 +62,16 @@ function aksrt_get_user_notification_count(int $user_id = 0): int {
}
endif;
if (!function_exists('aksrt_get_user_inbox_notifications')) :
if (!function_exists('jio_get_user_inbox_notifications')) :
/** 获取用户通知收件箱 */
function aksrt_get_user_inbox_notifications(int $user_id = 0): array {
function jio_get_user_inbox_notifications(int $user_id = 0): array {
$user_id = $user_id > 0 ? $user_id : get_current_user_id();
if ($user_id <= 0) return [];
global $wpdb;
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
$table = class_exists('\Jio\Core\DBMigrator') ? \Jio\Core\DBMigrator::table('notification') : '';
if ($table === '') return [];
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_notification_settings() : [];
$settings = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_notification_settings() : [];
$limit = max(20, min(5000, (int) ($settings['max_per_user'] ?? 200)));
$rows = $wpdb->get_results($wpdb->prepare(
@@ -101,32 +101,32 @@ function aksrt_get_user_inbox_notifications(int $user_id = 0): array {
}
endif;
if (!function_exists('aksrt_schedule_notification_cleanup')) :
if (!function_exists('jio_schedule_notification_cleanup')) :
/** 注册通知清理定时任务 */
function aksrt_schedule_notification_cleanup(): void {
if (!wp_next_scheduled('aksrt_notification_cleanup')) {
function jio_schedule_notification_cleanup(): void {
if (!wp_next_scheduled('jio_notification_cleanup')) {
$next = (new DateTimeImmutable('tomorrow 04:10', wp_timezone()))->getTimestamp();
wp_schedule_event($next, 'daily', 'aksrt_notification_cleanup');
wp_schedule_event($next, 'daily', 'jio_notification_cleanup');
}
}
endif;
if (!function_exists('aksrt_cleanup_notifications')) :
if (!function_exists('jio_cleanup_notifications')) :
/**
* 清理通知表:
* - 已读通知保留 30 天
* - 未读通知保留 180 天
* - 每个用户最多保留最近 200 条通知
*/
function aksrt_cleanup_notifications(): void {
function jio_cleanup_notifications(): void {
global $wpdb;
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
$table = class_exists('\Jio\Core\DBMigrator') ? \Jio\Core\DBMigrator::table('notification') : '';
if ($table === '') {
return;
}
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_notification_settings() : [
$settings = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_notification_settings() : [
'read_retention_days' => 30,
'unread_retention_days' => 180,
'max_per_user' => 200,
@@ -179,23 +179,23 @@ function aksrt_cleanup_notifications(): void {
}
endif;
add_action('wp', 'aksrt_schedule_notification_cleanup');
add_action('aksrt_notification_cleanup', 'aksrt_cleanup_notifications');
add_action('wp', 'jio_schedule_notification_cleanup');
add_action('jio_notification_cleanup', 'jio_cleanup_notifications');
if (!function_exists('aksrt_add_user_notification')) :
if (!function_exists('jio_add_user_notification')) :
/** 添加一条用户通知 */
function aksrt_add_user_notification(int $user_id, array $payload): void {
function jio_add_user_notification(int $user_id, array $payload): void {
if ($user_id <= 0) return;
$type = sanitize_key((string) ($payload['type'] ?? 'notice'));
if (class_exists('\AKSRT\User\NotificationPreferences') && !\AKSRT\User\NotificationPreferences::allows($user_id, $type)) {
if (class_exists('\Jio\User\NotificationPreferences') && !\Jio\User\NotificationPreferences::allows($user_id, $type)) {
return;
}
if (class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::notification_enabled($type)) {
if (class_exists('\Jio\Settings\Settings') && !\Jio\Settings\Settings::notification_enabled($type)) {
return;
}
global $wpdb;
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
$table = class_exists('\Jio\Core\DBMigrator') ? \Jio\Core\DBMigrator::table('notification') : '';
$created_at = (string) ($payload['created_at'] ?? current_time('mysql', true));
if ($table === '') return;
@@ -211,7 +211,7 @@ function aksrt_add_user_notification(int $user_id, array $payload): void {
'read_at' => !empty($payload['read']) ? current_time('mysql', true) : null,
], ['%d', '%s', '%s', '%s', '%s', '%d', '%s', '%s']);
if ($inserted !== false) {
do_action('aksrt_notification_sent', $user_id, $type, [
do_action('jio_notification_sent', $user_id, $type, [
'title' => (string) ($payload['title'] ?? ''),
'description' => (string) ($payload['desc'] ?? ''),
'target_url' => (string) ($payload['url'] ?? ''),
@@ -220,12 +220,12 @@ function aksrt_add_user_notification(int $user_id, array $payload): void {
}
endif;
if (!function_exists('aksrt_mark_user_notification_read')) :
if (!function_exists('jio_mark_user_notification_read')) :
/** 标记通知已读 */
function aksrt_mark_user_notification_read(int $user_id, string $notification_id = '', bool $mark_all = false): void {
function jio_mark_user_notification_read(int $user_id, string $notification_id = '', bool $mark_all = false): void {
if ($user_id <= 0) return;
global $wpdb;
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
$table = class_exists('\Jio\Core\DBMigrator') ? \Jio\Core\DBMigrator::table('notification') : '';
if ($table === '') return;
if ($mark_all) {
@@ -249,26 +249,26 @@ function aksrt_mark_user_notification_read(int $user_id, string $notification_id
}
endif;
if (!function_exists('aksrt_delete_user_notification')) :
if (!function_exists('jio_delete_user_notification')) :
/** 删除一条用户通知 */
function aksrt_delete_user_notification(int $user_id, string $notification_id): void {
function jio_delete_user_notification(int $user_id, string $notification_id): void {
if ($user_id <= 0 || $notification_id === '') return;
global $wpdb;
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
$table = class_exists('\Jio\Core\DBMigrator') ? \Jio\Core\DBMigrator::table('notification') : '';
if ($table === '') return;
$wpdb->delete($table, ['id' => absint($notification_id), 'user_id' => $user_id], ['%d', '%d']);
}
endif;
if (!function_exists('aksrt_delete_user_notifications')) :
if (!function_exists('jio_delete_user_notifications')) :
/** 批量删除用户通知 */
function aksrt_delete_user_notifications(int $user_id, array $notification_ids): void {
function jio_delete_user_notifications(int $user_id, array $notification_ids): void {
if ($user_id <= 0 || empty($notification_ids)) return;
$ids = array_values(array_filter(array_map('absint', $notification_ids), static function ($id) { return $id > 0; }));
if (empty($ids)) return;
global $wpdb;
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
$table = class_exists('\Jio\Core\DBMigrator') ? \Jio\Core\DBMigrator::table('notification') : '';
if ($table === '') return;
$wpdb->query(
@@ -277,10 +277,10 @@ function aksrt_delete_user_notifications(int $user_id, array $notification_ids):
}
endif;
if (!function_exists('aksrt_get_user_unread_notification_count')) :
if (!function_exists('jio_get_user_unread_notification_count')) :
/** 获取用户未读通知数 */
function aksrt_get_user_unread_notification_count(int $user_id = 0): int {
$items = aksrt_get_user_inbox_notifications($user_id);
function jio_get_user_unread_notification_count(int $user_id = 0): int {
$items = jio_get_user_inbox_notifications($user_id);
$count = 0;
foreach ($items as $item) {
if (empty($item['read']) && !str_starts_with((string) ($item['type'] ?? ''), 'asset_')) $count++;
@@ -289,33 +289,33 @@ function aksrt_get_user_unread_notification_count(int $user_id = 0): int {
}
endif;
if (!function_exists('aksrt_get_user_tab_badge_count')) :
if (!function_exists('jio_get_user_tab_badge_count')) :
/** user 底部 Tab 徽标计数:未读持久化通知 + 即时状态提醒 */
function aksrt_get_user_tab_badge_count(int $user_id = 0): int {
function jio_get_user_tab_badge_count(int $user_id = 0): int {
$user_id = $user_id > 0 ? $user_id : get_current_user_id();
if ($user_id <= 0) {
return 0;
}
if (class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::notification_user_badge_enabled()) {
if (class_exists('\Jio\Settings\Settings') && !\Jio\Settings\Settings::notification_user_badge_enabled()) {
return 0;
}
$count = aksrt_get_user_unread_notification_count($user_id);
if (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::notification_badge_include_stateful()) {
$count += aksrt_get_user_notification_count($user_id);
$count = jio_get_user_unread_notification_count($user_id);
if (class_exists('\Jio\Settings\Settings') && \Jio\Settings\Settings::notification_badge_include_stateful()) {
$count += jio_get_user_notification_count($user_id);
}
return $count;
}
endif;
if (!function_exists('aksrt_get_user_all_notifications')) :
if (!function_exists('jio_get_user_all_notifications')) :
/** 获取用户完整通知列表(持久化通知 + 即时提醒) */
function aksrt_get_user_all_notifications(int $user_id = 0): array {
function jio_get_user_all_notifications(int $user_id = 0): array {
$user_id = $user_id > 0 ? $user_id : get_current_user_id();
if ($user_id <= 0) return [];
$inbox = aksrt_get_user_inbox_notifications($user_id);
$alerts = aksrt_get_user_notifications($user_id);
$inbox = jio_get_user_inbox_notifications($user_id);
$alerts = jio_get_user_notifications($user_id);
$normalized_alerts = [];
foreach ($alerts as $alert) {
@@ -336,100 +336,100 @@ function aksrt_get_user_all_notifications(int $user_id = 0): array {
}
endif;
add_action('wp_ajax_aksrt_mark_notification_read', function () {
add_action('wp_ajax_jio_mark_notification_read', function () {
if (!is_user_logged_in()) {
wp_send_json_error(['message' => __('请先登录', 'aksrt')], 401);
wp_send_json_error(['message' => __('请先登录', 'jio')], 401);
}
$nonce = isset($_POST['nonce']) ? (string) $_POST['nonce'] : '';
if (!wp_verify_nonce($nonce, 'aksrt_public_nonce')) {
wp_send_json_error(['message' => __('安全验证失败', 'aksrt')], 403);
if (!wp_verify_nonce($nonce, 'jio_public_nonce')) {
wp_send_json_error(['message' => __('安全验证失败', 'jio')], 403);
}
$notification_id = sanitize_text_field((string) ($_POST['notification_id'] ?? ''));
$mark_all = !empty($_POST['mark_all']);
aksrt_mark_user_notification_read(get_current_user_id(), $notification_id, $mark_all);
jio_mark_user_notification_read(get_current_user_id(), $notification_id, $mark_all);
wp_send_json_success([
'unread' => aksrt_get_user_unread_notification_count(get_current_user_id()),
'unread' => jio_get_user_unread_notification_count(get_current_user_id()),
]);
});
add_action('wp_ajax_aksrt_delete_notification', function () {
add_action('wp_ajax_jio_delete_notification', function () {
if (!is_user_logged_in()) {
wp_send_json_error(['message' => __('请先登录', 'aksrt')], 401);
wp_send_json_error(['message' => __('请先登录', 'jio')], 401);
}
$nonce = isset($_POST['nonce']) ? (string) $_POST['nonce'] : '';
if (!wp_verify_nonce($nonce, 'aksrt_public_nonce')) {
wp_send_json_error(['message' => __('安全验证失败', 'aksrt')], 403);
if (!wp_verify_nonce($nonce, 'jio_public_nonce')) {
wp_send_json_error(['message' => __('安全验证失败', 'jio')], 403);
}
$notification_id = sanitize_text_field((string) ($_POST['notification_id'] ?? ''));
if ($notification_id === '') {
wp_send_json_error(['message' => __('参数错误', 'aksrt')], 400);
wp_send_json_error(['message' => __('参数错误', 'jio')], 400);
}
aksrt_delete_user_notification(get_current_user_id(), $notification_id);
jio_delete_user_notification(get_current_user_id(), $notification_id);
wp_send_json_success([
'unread' => aksrt_get_user_unread_notification_count(get_current_user_id()),
'unread' => jio_get_user_unread_notification_count(get_current_user_id()),
]);
});
add_action('wp_ajax_aksrt_delete_notifications', function () {
add_action('wp_ajax_jio_delete_notifications', function () {
if (!is_user_logged_in()) {
wp_send_json_error(['message' => __('请先登录', 'aksrt')], 401);
wp_send_json_error(['message' => __('请先登录', 'jio')], 401);
}
$nonce = isset($_POST['nonce']) ? (string) $_POST['nonce'] : '';
if (!wp_verify_nonce($nonce, 'aksrt_public_nonce')) {
wp_send_json_error(['message' => __('安全验证失败', 'aksrt')], 403);
if (!wp_verify_nonce($nonce, 'jio_public_nonce')) {
wp_send_json_error(['message' => __('安全验证失败', 'jio')], 403);
}
$ids = isset($_POST['notification_ids']) ? (array) $_POST['notification_ids'] : [];
aksrt_delete_user_notifications(get_current_user_id(), $ids);
jio_delete_user_notifications(get_current_user_id(), $ids);
wp_send_json_success([
'unread' => aksrt_get_user_unread_notification_count(get_current_user_id()),
'unread' => jio_get_user_unread_notification_count(get_current_user_id()),
]);
});
add_action('wp_ajax_aksrt_check_new_notifications', function () {
add_action('wp_ajax_jio_check_new_notifications', function () {
if (!is_user_logged_in()) {
wp_send_json_error(['message' => __('请先登录', 'aksrt')], 401);
wp_send_json_error(['message' => __('请先登录', 'jio')], 401);
}
$nonce = isset($_POST['nonce']) ? (string) $_POST['nonce'] : '';
if (!wp_verify_nonce($nonce, 'aksrt_public_nonce')) {
wp_send_json_error(['message' => __('安全验证失败', 'aksrt')], 403);
if (!wp_verify_nonce($nonce, 'jio_public_nonce')) {
wp_send_json_error(['message' => __('安全验证失败', 'jio')], 403);
}
$counts = function_exists('aksrt_get_message_center_counts') ? aksrt_get_message_center_counts(get_current_user_id()) : [];
$unread = isset($counts['unread']) ? (int) $counts['unread'] : aksrt_get_user_unread_notification_count(get_current_user_id());
$counts = function_exists('jio_get_message_center_counts') ? jio_get_message_center_counts(get_current_user_id()) : [];
$unread = isset($counts['unread']) ? (int) $counts['unread'] : jio_get_user_unread_notification_count(get_current_user_id());
wp_send_json_success([
'count' => $unread,
'unread' => $unread,
]);
});
function aksrt_notify_post_author_of_comment(WP_Comment $comment): void {
if ((int) $comment->comment_parent > 0 || get_comment_meta($comment->comment_ID, 'aksrt_post_comment_notified', true)) return;
function jio_notify_post_author_of_comment(WP_Comment $comment): void {
if ((int) $comment->comment_parent > 0 || get_comment_meta($comment->comment_ID, 'jio_post_comment_notified', true)) return;
$post = get_post((int) $comment->comment_post_ID);
$owner_id = $post instanceof WP_Post ? (int) $post->post_author : 0;
if ($owner_id <= 0 || $owner_id === (int) $comment->user_id) return;
aksrt_add_user_notification($owner_id, [
jio_add_user_notification($owner_id, [
'type' => 'comment',
'title' => __('文章收到评论', 'aksrt'),
'desc' => sprintf(__('%1$s 评论了你的文章《%2$s》。', 'aksrt'), get_comment_author($comment), get_the_title($post)),
'title' => __('文章收到评论', 'jio'),
'desc' => sprintf(__('%1$s 评论了你的文章《%2$s》。', 'jio'), get_comment_author($comment), get_the_title($post)),
'url' => get_comment_link($comment),
]);
update_comment_meta($comment->comment_ID, 'aksrt_post_comment_notified', 1);
update_comment_meta($comment->comment_ID, 'jio_post_comment_notified', 1);
}
add_action('wp_insert_comment', function ($comment_id, $comment) {
if (!$comment instanceof WP_Comment) return;
if ((int) $comment->comment_approved !== 1) return;
aksrt_notify_post_author_of_comment($comment);
jio_notify_post_author_of_comment($comment);
if ((int) $comment->comment_parent <= 0) return;
if (get_comment_meta($comment_id, 'aksrt_reply_notified', true)) return;
if (get_comment_meta($comment_id, 'jio_reply_notified', true)) return;
$parent = get_comment((int) $comment->comment_parent);
if (!$parent instanceof WP_Comment) return;
@@ -438,13 +438,13 @@ add_action('wp_insert_comment', function ($comment_id, $comment) {
$post_id = (int) $comment->comment_post_ID;
$url = get_comment_link($comment);
aksrt_add_user_notification($target_user_id, [
jio_add_user_notification($target_user_id, [
'type' => 'comment_reply',
'title' => __('评论收到回复', 'aksrt'),
'desc' => sprintf(__('“%s” 回复了你的评论。', 'aksrt'), get_comment_author($comment)),
'title' => __('评论收到回复', 'jio'),
'desc' => sprintf(__('“%s” 回复了你的评论。', 'jio'), get_comment_author($comment)),
'url' => $url ?: get_permalink($post_id),
]);
update_comment_meta($comment_id, 'aksrt_reply_notified', 1);
update_comment_meta($comment_id, 'jio_reply_notified', 1);
}, 20, 2);
add_action('transition_comment_status', function ($new_status, $old_status, $comment) {
@@ -452,81 +452,81 @@ add_action('transition_comment_status', function ($new_status, $old_status, $com
if ($new_status !== 'approve' || $old_status === 'approve') return;
$comment_owner_id = (int) $comment->user_id;
if ($comment_owner_id > 0 && !get_comment_meta($comment->comment_ID, 'aksrt_approved_notified', true)) {
aksrt_add_user_notification($comment_owner_id, [
if ($comment_owner_id > 0 && !get_comment_meta($comment->comment_ID, 'jio_approved_notified', true)) {
jio_add_user_notification($comment_owner_id, [
'type' => 'comment_approved',
'title' => __('评论已通过审核', 'aksrt'),
'desc' => __('你的评论已通过审核,现已公开展示。', 'aksrt'),
'title' => __('评论已通过审核', 'jio'),
'desc' => __('你的评论已通过审核,现已公开展示。', 'jio'),
'url' => get_comment_link($comment),
]);
update_comment_meta($comment->comment_ID, 'aksrt_approved_notified', 1);
update_comment_meta($comment->comment_ID, 'jio_approved_notified', 1);
}
aksrt_notify_post_author_of_comment($comment);
jio_notify_post_author_of_comment($comment);
if ((int) $comment->comment_parent <= 0) return;
if (get_comment_meta($comment->comment_ID, 'aksrt_reply_notified', true)) return;
if (get_comment_meta($comment->comment_ID, 'jio_reply_notified', true)) return;
$parent = get_comment((int) $comment->comment_parent);
if (!$parent instanceof WP_Comment) return;
$target_user_id = (int) $parent->user_id;
if ($target_user_id <= 0 || $target_user_id === (int) $comment->user_id) return;
aksrt_add_user_notification($target_user_id, [
jio_add_user_notification($target_user_id, [
'type' => 'comment_reply',
'title' => __('评论收到回复', 'aksrt'),
'desc' => sprintf(__('“%s” 回复了你的评论。', 'aksrt'), get_comment_author($comment)),
'title' => __('评论收到回复', 'jio'),
'desc' => sprintf(__('“%s” 回复了你的评论。', 'jio'), get_comment_author($comment)),
'url' => get_comment_link($comment),
]);
update_comment_meta($comment->comment_ID, 'aksrt_reply_notified', 1);
update_comment_meta($comment->comment_ID, 'jio_reply_notified', 1);
}, 20, 3);
add_action('aksrt_post_favorited', function (int $post_id, int $actor_id, bool $active): void {
add_action('jio_post_favorited', function (int $post_id, int $actor_id, bool $active): void {
$post = $active ? get_post($post_id) : null;
$owner_id = $post instanceof WP_Post ? (int) $post->post_author : 0;
if ($owner_id <= 0 || $owner_id === $actor_id) return;
$actor = get_userdata($actor_id);
aksrt_add_user_notification($owner_id, [
jio_add_user_notification($owner_id, [
'type' => 'post_favorite',
'title' => __('文章被收藏', 'aksrt'),
'desc' => sprintf(__('%1$s 收藏了你的文章《%2$s》。', 'aksrt'), $actor instanceof WP_User ? $actor->display_name : __('一位用户', 'aksrt'), get_the_title($post)),
'title' => __('文章被收藏', 'jio'),
'desc' => sprintf(__('%1$s 收藏了你的文章《%2$s》。', 'jio'), $actor instanceof WP_User ? $actor->display_name : __('一位用户', 'jio'), get_the_title($post)),
'url' => get_permalink($post),
]);
}, 30, 3);
add_action('aksrt_post_liked', function (int $post_id, int $actor_id, bool $active): void {
add_action('jio_post_liked', function (int $post_id, int $actor_id, bool $active): void {
$post = $active ? get_post($post_id) : null;
$owner_id = $post instanceof WP_Post ? (int) $post->post_author : 0;
if ($owner_id <= 0 || $owner_id === $actor_id) return;
$actor = get_userdata($actor_id);
aksrt_add_user_notification($owner_id, [
jio_add_user_notification($owner_id, [
'type' => 'post_like',
'title' => __('文章收到点赞', 'aksrt'),
'desc' => sprintf(__('%1$s 点赞了你的文章《%2$s》。', 'aksrt'), $actor instanceof WP_User ? $actor->display_name : __('一位用户', 'aksrt'), get_the_title($post)),
'title' => __('文章收到点赞', 'jio'),
'desc' => sprintf(__('%1$s 点赞了你的文章《%2$s》。', 'jio'), $actor instanceof WP_User ? $actor->display_name : __('一位用户', 'jio'), get_the_title($post)),
'url' => get_permalink($post),
]);
}, 30, 3);
add_action('aksrt_comment_liked', function (int $comment_id, int $actor_id, bool $active): void {
add_action('jio_comment_liked', function (int $comment_id, int $actor_id, bool $active): void {
$comment = $active ? get_comment($comment_id) : null;
$owner_id = $comment instanceof WP_Comment ? (int) $comment->user_id : 0;
if ($owner_id <= 0 || $owner_id === $actor_id) return;
$actor = get_userdata($actor_id);
aksrt_add_user_notification($owner_id, [
jio_add_user_notification($owner_id, [
'type' => 'comment_like',
'title' => __('评论收到点赞', 'aksrt'),
'desc' => sprintf(__('%s 点赞了你的评论。', 'aksrt'), $actor instanceof WP_User ? $actor->display_name : __('一位用户', 'aksrt')),
'title' => __('评论收到点赞', 'jio'),
'desc' => sprintf(__('%s 点赞了你的评论。', 'jio'), $actor instanceof WP_User ? $actor->display_name : __('一位用户', 'jio')),
'url' => get_comment_link($comment),
]);
}, 30, 3);
add_action('aksrt_user_followed', function (int $follower_id, int $following_id): void {
add_action('jio_user_followed', function (int $follower_id, int $following_id): void {
if ($following_id <= 0 || $following_id === $follower_id) return;
$follower = get_userdata($follower_id);
aksrt_add_user_notification($following_id, [
jio_add_user_notification($following_id, [
'type' => 'followed',
'title' => __('收到新的关注', 'aksrt'),
'desc' => sprintf(__('%s 关注了你。', 'aksrt'), $follower instanceof WP_User ? $follower->display_name : __('一位用户', 'aksrt')),
'url' => function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($follower_id) : '',
'title' => __('收到新的关注', 'jio'),
'desc' => sprintf(__('%s 关注了你。', 'jio'), $follower instanceof WP_User ? $follower->display_name : __('一位用户', 'jio')),
'url' => function_exists('jio_get_user_home_url') ? jio_get_user_home_url($follower_id) : '',
]);
}, 30, 2);