function scg_apply_placeholders($text, $post_link, $title) { if (!$text) return $text; $keywords = scg_get_keywords(); // المقدمة: رابط واحد على الكلمة الأولى $bold_anchor = '' . esc_html($title) . ''; $search = array('{BOLD_TITLE}'); $replace = array($bold_anchor); foreach ($keywords as $i => $k) { $search[] = '{A_KW' . $i . '}'; $replace[] = '' . esc_html($title . ' ' . $k) . ''; // Bold فقط } return str_replace($search, $replace, $text); } function scg_build_for_post($post_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return false; if (wp_is_post_revision($post_id)) return false; if (get_post_type($post_id) !== 'post') return false; $title = get_the_title($post_id); $post_link = get_permalink($post_id); $intros_text = get_option(SCG_OPT_INTROS, ''); $outros_text = get_option(SCG_OPT_OUTROS, ''); $intros = scg_split_units($intros_text); $outros = scg_split_units($outros_text); if (empty($intros)) $intros = array('
{BOLD_TITLE}
'); if (empty($outros)) $outros = array('{BOLD_TITLE}
'); $intro_idx = intval(get_option(SCG_OPT_INTRO_IDX, -1)); $outro_idx = intval(get_option(SCG_OPT_OUTRO_IDX, -1)); $next_intro = ($intro_idx + 1) % count($intros); $next_outro = ($outro_idx + 1) % count($outros); update_option(SCG_OPT_INTRO_IDX, $next_intro); update_option(SCG_OPT_OUTRO_IDX, $next_outro); $intro_tpl = $intros[$next_intro]; $outro_tpl = $outros[$next_outro]; $intro_html = scg_apply_placeholders($intro_tpl, $post_link, $title); $outro_html = scg_apply_placeholders($outro_tpl, $post_link, $title); $keywords = scg_get_keywords(); $pros_kw = array_slice($keywords, 2, 3); $cons_kw = array_slice($keywords, 5, 3); $faq_kw = array_slice($keywords, 9, 3); $get_kw_bold = function(&$arr) use ($title) { if (empty($arr)) return ''; $k = array_shift($arr); return '' . esc_html($title . ' ' . $k) . ''; }; $pros = "{BOLD_TITLE} simplifies digital tasks and offers powerful tools. " . $get_kw_bold($faq_kw) . "
Basic features are free; premium upgrades available. " . $get_kw_bold($faq_kw) . "
Install via official stores. " . $get_kw_bold($faq_kw) . "
Regular updates and verified sources ensure safety.
"; $faq_html = scg_apply_placeholders($faq_tpl, $post_link, $title); $download_section = "Easy installation on Android and iOS devices ensures quick access to advanced features. Furthermore, users can follow step-by-step instructions seamlessly.