)/i', // function ( $matches ) { // $before = $matches[1]; // attributes before alt // $alt = $matches[2]; // alt value // $after = $matches[3]; // attributes after alt // $close = $matches[4]; // /> or > // if ( mb_strlen( $alt ) > 100 ) { // // Trim at word boundary, max 100 chars // $trimmed = mb_substr( $alt, 0, 100 ); // $last_space = mb_strrpos( $trimmed, ' ' ); // if ( $last_space !== false ) { // $trimmed = mb_substr( $trimmed, 0, $last_space ); // } // $alt = $trimmed; // } // return ']*>/i', function($matches) use ($default_alt) { // $img = $matches[0]; // // Agar alt already hai aur empty nahi hai to skip // if (preg_match('/alt=["\'](.*?)["\']/i', $img, $alt)) { // if (!empty($alt[1])) { // return $img; // } // } // // Alt add ya replace // if (strpos($img, 'alt=') !== false) { // $img = preg_replace('/alt=["\'].*?["\']/i', 'alt="'.$default_alt.'"', $img); // } else { // $img = str_replace('loadHTML(''.$html); // $h1s = $dom->getElementsByTagName('h1'); // $count = 0; // for ($i = $h1s->length - 1; $i >= 0; $i--) { // $h1 = $h1s->item($i); // $count++; // if ($count > 1) { // // remove extra H1 // $h1->parentNode->removeChild($h1); // } // } // return $dom->saveHTML(); // }); // } // } // add_action('template_redirect','bw_fix_multiple_h1_events_page'); add_filter('rank_math/frontend/robots', function($robots) { if (is_author()) { $robots['index'] = 'index'; $robots['follow'] = 'follow'; unset($robots['noindex']); } return $robots; }); // Convert all H1 tags in content to SPAN // add_filter('the_content', 'convert_h1_to_span_in_content'); // function convert_h1_to_span_in_content($content) { // $content = preg_replace('//is', '', $content); // $content = preg_replace('/<\/h1>/is', '', $content); // return $content; // } // function auto_h1_buffer_start() { // if (!is_admin()) { // ob_start('auto_h1_buffer_callback'); // } // } // add_action('template_redirect', 'auto_h1_buffer_start'); // /** // * Modify full HTML before output // */ // function auto_h1_buffer_callback($html) { // // If already has H1 → do nothing // if (stripos($html, ''; // // Insert after
OR before content // $html = preg_replace('/]*>/i', '$0' . $h1, $html, 1); // return $html; // } // // Author pages // if (is_author()) { // $author = get_queried_object(); // $name = esc_html($author->display_name); // $h1 = '

Articles by ' . $name . '

'; // $html = preg_replace('/]*>/i', '$0' . $h1, $html, 1); // return $html; // } // return $html; // } // function force_crypto_news_h1_change() { // if (is_page('crypto-news')) { // ob_start(function($html) { // // Replace only first H1 // $html = preg_replace( // '/]*>.*?<\/h1>/i', // '

Crypto Article

', // $html, // 1 // ); // return $html; // }); // } // } // add_action('template_redirect', 'force_crypto_news_h1_change'); // function fix_crypto_news_h1_category() { // if (is_category('crypto-news')) { // ob_start(function($html) { // // Replace first H1 only // return preg_replace( // '/]*>.*?<\/h1>/i', // '

Crypto Article

', // $html, // 1 // ); // }); // } // } // add_action('template_redirect', 'fix_crypto_news_h1_category'); // add_action('template_redirect', function () { // if (!is_admin()) { // ob_start('auto_hidden_h1_fix'); // } // }); // /** // * Main Logic // */ // function auto_hidden_h1_fix($html) { // // If already has H1 → do nothing // if (stripos($html, ''; // } // // Category // elseif (is_category()) { // $h1 = '

' . single_cat_title('', false) . '

'; // } // // Home page // elseif (is_front_page() || is_home()) { // $h1 = '

Latest Articles

'; // } // // Author // elseif (is_author()) { // $author = get_queried_object(); // $h1 = '

Articles by ' . esc_html($author->display_name) . '

'; // } // // Insert after // if (!empty($h1)) { // $html = preg_replace('/]*>/i', '$0' . $h1, $html, 1); // } // return $html; // } // function auto_add_h2_if_missing($content) { // if (is_admin()) return $content; // // Apply only on single posts & pages // if (is_singular()) { // // Check if H2 already exists // if (stripos($content, ''; // return $h2 . $content; // } // return $content; // } // add_filter('the_content', 'auto_add_h2_if_missing'); // add_action('template_redirect', function () { // if (!is_author() || is_admin()) return; // ob_start(function ($html) { // // If H2 already exists → skip // if (stripos($html, 'display_name) ? $author->display_name : 'Author'; // // Hidden H2 // $h2 = '

Articles by ' . esc_html($name) . '

'; // // Try inserting after
// if (preg_match('/]*>/i', $html)) { // $html = preg_replace('/]*>/i', '$0' . $h2, $html, 1); // } else { // // fallback → after body // $html = preg_replace('/]*>/i', '$0' . $h2, $html, 1); // } // return $html; // }); // }); Coinjar News & Updates - BitcoinWorld