进行了一些小修复

This commit is contained in:
kate522 committed 2026-08-26 16:32:18 +08:00
1 parent 992af2119d
commit 2cb78edabb
26 files changed
+2091 -2383

No files matched your search

+12 -37
View File
@@ -127,37 +127,16 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) :
$settings['authordesc'] = !empty($settings['authordesc_s']);
}
$meta = class_exists('\AKSRT\Core\PostMetaBox') ? \AKSRT\Core\PostMetaBox::get_meta($post->ID) : [];
foreach ([
'show_reading_progress' => 'reading_progress',
'enable_lightbox' => 'lightbox',
'show_related' => 'related_enabled',
'enable_like' => 'like_enabled',
'enable_favorite' => 'favorite_enabled',
'enable_share' => 'share_enabled',
'enable_print' => 'print_enabled',
'enable_pdf' => 'pdf_export_enabled',
] as $meta_key => $setting_key) {
if (($meta[$meta_key] ?? '') === '') {
continue;
}
$settings[$setting_key] = $meta[$meta_key] === '1';
}
if (!empty($meta['related_count'])) {
$settings['related_count'] = max(1, min(20, (int) $meta['related_count']));
}
// Per-post maxheight override (legacy article_maxheight_xz). Global may already set maxheight_enabled.
$meta_maxheight = (int) ($meta['maxheight'] ?? 0);
if ($meta_maxheight > 0) {
if (!empty($meta['article_maxheight_xz'])) {
$settings['maxheight_enabled'] = true;
$settings['maxheight'] = $meta_maxheight;
} elseif (empty($settings['maxheight_enabled'])) {
$settings['maxheight_enabled'] = false;
$settings['maxheight'] = max(0, (int) ($settings['maxheight'] ?? 0));
}
$cover_mode = (string) ($meta['header_image_mode'] ?? '');
$cover_mode = '';
$cover_url = '';
$cover_type = 'none';
// Check global cover toggles; per-post header_image_mode='none' overrides all.
// Cover availability follows the global article display settings.
$image_cover_on = !empty($settings['article_image_cover']);
$slide_cover_on = !empty($settings['article_slide_cover']);
$video_cover_on = !empty($settings['article_video_cover']);
@@ -174,16 +153,13 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) :
}
}
}
// 2. Slide cover — featured_slide URLs and/or cover_images (attachment IDs).
// 2. Slide cover — the reference editor stores attachment IDs.
$slide_images = [];
if ($slide_cover_on) {
$raw_slides = [];
if (!empty($meta['featured_slide'])) {
$raw_slides = array_merge($raw_slides, preg_split('/[,\s]+/', (string) $meta['featured_slide']) ?: []);
}
if (!empty($meta['cover_images'])) {
$raw_slides = array_merge($raw_slides, preg_split('/[,\s]+/', (string) $meta['cover_images']) ?: []);
}
foreach ($raw_slides as $token) {
$token = trim((string) $token);
if ($token === '') {
@@ -217,11 +193,7 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) :
$slide_images = [];
}
} elseif ($image_cover_on) {
if ($cover_mode === 'auto') {
$cover_url = function_exists('aksrt_get_first_content_image_url')
? (string) aksrt_get_first_content_image_url($post->ID)
: '';
}
$cover_url = esc_url_raw((string) ($meta['cover_image'] ?? ''));
if ($cover_url === '' && has_post_thumbnail($post)) {
$cover_url = (string) get_the_post_thumbnail_url($post, 'full');
}
@@ -238,6 +210,13 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) :
$settings['featured_video'] = (string) ($meta['featured_video'] ?? '');
// New route: episode list only.
$episodes = [];
$main_video = esc_url_raw((string) ($meta['featured_video'] ?? ''));
if ($main_video !== '') {
$episodes[] = [
'url' => $main_video,
'title' => sanitize_text_field((string) ($meta['featured_video_title'] ?? '')),
];
}
$raw_eps = $meta['featured_video_episode'] ?? [];
if (is_array($raw_eps)) {
foreach ($raw_eps as $row) {
@@ -265,10 +244,6 @@ if (($settings['cover_type'] ?? '') === 'video' && (string) ($settings['cover_ur
$settings['video_episodes'] = $episodes;
$settings['episode_count'] = count($episodes);
$settings['video_poster'] = (string) ($meta['cover_image'] ?? '');
$meta_copyright = trim((string) ($meta['copyright_text'] ?? ''));
if ($meta_copyright !== '') {
$settings['copyright_text'] = $meta_copyright;
}
return $settings;
}
endif;
+4 -4
View File
@@ -265,7 +265,7 @@ if (!function_exists('aksrt_resource_preview_images')) {
/**
* Collect preview images for resource cards and archive thumbnails.
*
* Priority: curated cover_images meta -> featured image -> gallery/content images.
* Priority: curated featured-slide images -> featured image -> gallery/content images.
*
* @param int|WP_Post|null $post
* @param int $limit
@@ -281,9 +281,9 @@ if (!function_exists('aksrt_resource_preview_images')) {
$images = [];
if (class_exists('\AKSRT\Core\PostMetaBox')) {
$cover_images = (string) \AKSRT\Core\PostMetaBox::get_meta_value($p->ID, 'cover_images', '');
if ($cover_images !== '') {
$cover_ids = array_filter(array_map('absint', preg_split('/[\s,]+/', $cover_images) ?: []));
$featured_slide = (string) \AKSRT\Core\PostMetaBox::get_meta_value($p->ID, 'featured_slide', '');
if ($featured_slide !== '') {
$cover_ids = array_filter(array_map('absint', preg_split('/[\s,]+/', $featured_slide) ?: []));
foreach ($cover_ids as $attachment_id) {
$url = (string) wp_get_attachment_image_url($attachment_id, 'medium_large');
if ($url !== '') {
+1 -4
View File
@@ -49,10 +49,7 @@ if (!function_exists('aksrt_renderer_collect_post_data')) {
$is_mult_thumb = true;
}
$custom_excerpt = class_exists('\AKSRT\Core\PostMetaBox')
? (string) \AKSRT\Core\PostMetaBox::get_meta_value($post_id, 'custom_excerpt', '')
: '';
$excerpt = $custom_excerpt !== '' ? $custom_excerpt : (string) get_the_excerpt($post_id);
$excerpt = (string) get_the_excerpt($post_id);
if ($excerpt === '') {
$excerpt = (string) get_post_field('post_content', $post_id, 'raw');
}
+4 -3
View File
@@ -78,8 +78,7 @@ if (!function_exists('aksrt_get_post_show_layout')):
/**
* legacy-compatible post/page layout override.
*
* Meta key: `_aksrt_show_layout`
* Values: '' (follow) | no_sidebar | sidebar_left | sidebar_right
* Values: false (follow) | no_sidebar | sidebar_left | sidebar_right
*
* @param int|null $post_id Post ID.
*/
@@ -88,7 +87,9 @@ function aksrt_get_post_show_layout($post_id = null): string {
if ($post_id <= 0) {
return '';
}
$value = (string) get_post_meta($post_id, '_aksrt_show_layout', true);
$value = class_exists('\AKSRT\Core\PostMetaBox')
? (string) \AKSRT\Core\PostMetaBox::get_meta_value($post_id, 'show_layout', 'false')
: 'false';
return in_array($value, ['no_sidebar', 'sidebar_left', 'sidebar_right'], true) ? $value : '';
}
endif;