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:
1 parent
ef7b5939ba
commit
4c562428b4
24 files changed
+792
-273
No files matched your search
@@ -10,7 +10,10 @@ defined('ABSPATH') || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
$links = function_exists('jio_get_friend_links') ? jio_get_friend_links() : [];
|
||||
$post_id = (int) get_queried_object_id();
|
||||
$settings = function_exists('jio_get_page_links_settings') ? jio_get_page_links_settings($post_id) : [];
|
||||
$links_html = function_exists('jio_page_links_html') ? jio_page_links_html($post_id) : '';
|
||||
$search_html = function_exists('jio_link_get_search_cover') ? jio_link_get_search_cover($post_id) : '';
|
||||
|
||||
if (function_exists('jio_archive_open_shell')) {
|
||||
jio_archive_open_shell([
|
||||
@@ -26,39 +29,40 @@ if (function_exists('jio_archive_open_shell')) {
|
||||
'title' => esc_html__('友情链接', 'jio'),
|
||||
'desc' => __('与这些优秀的站点交换友链', 'jio'),
|
||||
]);
|
||||
echo $search_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- helper returns escaped markup.
|
||||
|
||||
if (!empty($settings['content_s']) && ($settings['content_position'] ?? 'top') === 'top') {
|
||||
echo '<div class="zib-widget mb20"><article class="article content-main__body">';
|
||||
the_content();
|
||||
echo '</article></div>';
|
||||
}
|
||||
|
||||
echo $links_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- helper returns escaped markup.
|
||||
|
||||
if (!empty($settings['content_s']) && ($settings['content_position'] ?? 'top') !== 'top') {
|
||||
echo '<div class="zib-widget mb20"><article class="article content-main__body">';
|
||||
the_content();
|
||||
echo '</article></div>';
|
||||
}
|
||||
|
||||
if (!empty($settings['submit_s']) && !empty($settings['submit_title'])) {
|
||||
printf(
|
||||
'<p class="text-center" style="margin-top:24px;"><a class="padding-h10 hollow but c-theme btn-block" href="#submit-links-modal" data-toggle="modal">%s</a></p>',
|
||||
esc_html((string) $settings['submit_title'])
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if (!empty($links)) : ?>
|
||||
<div class="friends-grid">
|
||||
<?php foreach ($links as $link) : ?>
|
||||
<a class="friend-card" href="<?php echo esc_url($link['url'] ?? '#'); ?>" target="_blank" rel="noopener noreferrer">
|
||||
<?php
|
||||
$logo = $link['logo'] ?? '';
|
||||
if ($logo) {
|
||||
echo '<img class="friend-card__avatar" src="' . esc_url($logo) . '" alt="">';
|
||||
} else {
|
||||
$initial = function_exists('mb_substr') ? mb_substr((string) ($link['name'] ?? 'A'), 0, 1, 'UTF-8') : substr((string) ($link['name'] ?? 'A'), 0, 1);
|
||||
echo '<div class="friend-card__avatar" style="display:flex;align-items:center;justify-content:center;font-weight:800;color:var(--color-primary);font-family:var(--font-heading);">' . esc_html($initial) . '</div>';
|
||||
}
|
||||
?>
|
||||
<div class="friend-card__info">
|
||||
<h3 class="friend-card__name"><?php echo esc_html($link['name'] ?? ''); ?></h3>
|
||||
<p class="friend-card__desc"><?php echo esc_html($link['description'] ?? ''); ?></p>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="no-results content-stream__empty">
|
||||
<p><?php esc_html_e('暂无友链,请在主题后台添加。', 'jio'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="text-center" style="margin-top:32px;">
|
||||
<a class="btn-outline" href="<?php echo esc_url(home_url('/')); ?>"><?php esc_html_e('返回首页', 'jio'); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
if (!empty($settings['submit_s'])) {
|
||||
echo jio_submit_links_modal([ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- helper returns escaped markup.
|
||||
'title' => (string) ($settings['submit_title'] ?? ''),
|
||||
'dec' => (string) ($settings['submit_dec'] ?? ''),
|
||||
'sign' => !empty($settings['submit_sign_s']),
|
||||
'cats' => (array) ($settings['submit_cats'] ?? []),
|
||||
], $post_id);
|
||||
}
|
||||
|
||||
if (function_exists('jio_archive_close_shell')) {
|
||||
jio_archive_close_shell(['has_sidebar' => false]);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user