From 2e54c26224be3b7f2639412447cd5f3975a5c394 Mon Sep 17 00:00:00 2001 From: "web_103.2" Date: Fri, 16 Oct 2026 12:54:08 +0300 Subject: [PATCH] =?UTF-8?q?task=2017075=20|=20=D1=81=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=BF=D0=BE=D0=B4=D1=81=D1=87=D0=B5=D1=82=20?= =?UTF-8?q?=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=B8=20=D1=87=D1=82=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wp-content/themes/hantico/single-article.php | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/wp-content/themes/hantico/single-article.php b/wp-content/themes/hantico/single-article.php index 94d6356..52dbfa2 100644 --- a/wp-content/themes/hantico/single-article.php +++ b/wp-content/themes/hantico/single-article.php @@ -16,6 +16,26 @@ $terms = get_the_terms(get_the_ID(), 'article_category'); $article_blocks = get_field('new_blocks') ?: []; $article_content = get_field('article_content') ?: ''; + $reading_parts = [$article_content]; + foreach ($article_blocks as $block) { + $layout = $block['acf_fc_layout'] ?? ''; + if ($layout === 'text') { + $reading_parts[] = $block['content'] ?? ''; + } elseif (in_array($layout, ['attention_block', 'attention_blocks', 'quote'], true)) { + $reading_parts[] = $block['text'] ?? ''; + } elseif ($layout === 'block_main') { + foreach (($block['cards'] ?? []) as $card) { + $reading_parts[] = $card['text_card'] ?? ''; + } + } + } + // Разделяем HTML-элементы пробелами, чтобы соседние абзацы не склеивались. + $reading_text = strip_shortcodes(implode(' ', $reading_parts)); + $reading_text = preg_replace('@<(script|style)\b[^>]*>.*?@si', ' ', $reading_text); + $reading_text = preg_replace('/<[^>]*>/', ' ', $reading_text); + $reading_text = html_entity_decode(wp_strip_all_tags($reading_text), ENT_QUOTES | ENT_HTML5, 'UTF-8'); + $word_count = preg_match_all("/[\p{L}\p{N}]+(?:[’'\x{002D}][\p{L}\p{N}]+)*/u", $reading_text); + $reading_minutes = $word_count ? max(1, (int) ceil($word_count / 200)) : 0; $generated = generate_toc($article_content, 'article-content'); $content = $generated['content']; $toc_items = $generated['toc_items']; @@ -70,13 +90,15 @@ +
- Время чтения: — + Время чтения: ≈ мин
+