fix(widgets): restore article table of contents behavior and styles
This commit is contained in:
1 parent
fc04bf65e6
commit
ea80cd96cc
15 files changed
+965
-407
No files matched your search
@@ -546,16 +546,6 @@ trait ScriptsPart1b {
|
||||
(string) filemtime($pn_css)
|
||||
);
|
||||
}
|
||||
$section_navs = get_template_directory() . '/assets/js/section-navs.js';
|
||||
if (file_exists($section_navs)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-section-navs',
|
||||
$base_uri . '/assets/js/section-navs.js',
|
||||
['jquery'],
|
||||
(string) filemtime($section_navs),
|
||||
true
|
||||
);
|
||||
}
|
||||
$pn_js = get_template_directory() . '/assets/js/posts-navs-page.js';
|
||||
if (file_exists($pn_js)) {
|
||||
wp_enqueue_script(
|
||||
|
||||
@@ -69,7 +69,6 @@ trait ScriptsPart1c {
|
||||
'/(?:<!--\s*wp:(?:code|preformatted|aksrt\/enlighter)\b|<pre\b|data-enlighter-language)/i',
|
||||
$display_content
|
||||
);
|
||||
$heading_count = preg_match_all('/<h[1-4]\b/i', $display_content);
|
||||
$has_hidden_content = $is_paid_content_single || (bool) preg_match(
|
||||
'/(?:<!--\s*wp:aksrt\/paid-fragment\b|\[(?:aksrt_hide|hide|reply|vip|payshow|hidecontent|content)\b|aksrt-(?:hidden-content|paywall))/i',
|
||||
$content
|
||||
@@ -106,10 +105,15 @@ trait ScriptsPart1c {
|
||||
$layout = function_exists('aksrt_get_post_show_layout')
|
||||
? (string) aksrt_get_post_show_layout($post_id)
|
||||
: '';
|
||||
$article_nav_enabled = !array_key_exists('article_nav', $settings) || !empty($settings['article_nav']);
|
||||
if ($article_nav_enabled && function_exists('get_post_meta') && class_exists(DomainModel::class)) {
|
||||
$extension_meta = get_post_meta($post_id, DomainModel::POST_META_KEY, true);
|
||||
$article_nav_enabled = !is_array($extension_meta) || empty($extension_meta['no_article-navs']);
|
||||
}
|
||||
|
||||
$requirements['is_article'] = $is_article;
|
||||
$requirements['has_code'] = $has_code;
|
||||
$requirements['has_toc'] = $is_article && $heading_count >= 2;
|
||||
$requirements['has_toc'] = $is_article && $article_nav_enabled;
|
||||
$requirements['has_video'] = $has_video;
|
||||
$requirements['has_hidden_content'] = $has_hidden_content || $has_yiyan || $has_inserted_content;
|
||||
$requirements['needs_pay_box'] = $is_paid_content_single || (bool) preg_match('/\[(?:payshow|hidecontent)\b|wp:aksrt\/paid-fragment/i', $content);
|
||||
|
||||
Reference in new issue
Block a user