/**
 * ============================================================
 *  ضبط دقيق: إرجاع سلوك قوالب جنة + إصلاح SEO
 * ============================================================
 */

/* ---------- 1) إخفاء عنوان الموقع المكرر (Jannah يطبع h1) ---------- */
add_filter( 'TieLabs/logo_data', function ( $logo ) {
	// لا نلمس الشعار، لكن نمنع تكرار h1 عبر CSS في السكين.
	return $logo;
} );

/* ---------- 2) ضمان تحميل iLightBox حتى مع الدمج ---------- */
add_action( 'wp_enqueue_scripts', 'orsozox_ensure_lightbox', 22 );

function orsozox_ensure_lightbox() {
	if ( is_admin() || ! function_exists( 'tie_get_option' ) ) {
		return;
	}
	if ( ! tie_get_option( 'lightbox_all' ) ) {
		return;
	}

	// نضمن المقابض مسجّلة (جنة تسجّلها في inc/theme-setup.php).
	if ( ! wp_script_is( 'tie-js-ilightbox', 'registered' ) ) {
		wp_register_script(
			'tie-js-ilightbox',
			get_template_directory_uri() . '/assets/ilightbox/lightbox.js',
			array( 'jquery' ),
			(string) wp_get_theme( 'jannah' )->get( 'Version' ),
			true
		);
	}
	if ( ! wp_style_is( 'tie-css-ilightbox', 'registered' ) ) {
		$skin = tie_get_option( 'lightbox_skin', 'dark' );
		wp_register_style(
			'tie-css-ilightbox',
			get_template_directory_uri() . '/assets/ilightbox/' . $skin . '-skin/skin.css',
			array(),
			(string) wp_get_theme( 'jannah' )->get( 'Version' )
		);
	}

	wp_enqueue_script( 'tie-js-ilightbox' );
	wp_enqueue_style( 'tie-css-ilightbox' );

	// تمرير إعدادات الليتبوكس لـ JS (الطريقة الرسمية في جنة).
	$settings = array(
		'lightbox_skin'   => tie_get_option( 'lightbox_skin', 'dark' ),
		'lightbox_thumbs' => tie_get_option( 'lightbox_thumbs' ),
		'lightbox_arrows' => tie_get_option( 'lightbox_arrows' ),
		'lightbox_all'    => tie_get_option( 'lightbox_all' ),
		'lightbox_gallery' => tie_get_option( 'lightbox_gallery' ),
	);
	wp_localize_script( 'tie-js-ilightbox', 'osxLightbox', $settings );
}

/* ---------- 3) tieFitVids — نفعّله صريحًا للفيديو ---------- */
add_action( 'wp_footer', 'orsozox_activate_fitvids', 99 );

function orsozox_activate_fitvids() {
	if ( is_admin() ) {
		return;
	}
	$js = <<<'JS'
(function () {
	function run() {
		if (window.jQuery && jQuery.fn.tieFitVids) {
			jQuery('.entry-content, .osx-article, .post-content').tieFitVids();
		}
	}
	if (document.readyState !== 'loading') { run(); }
	else { document.addEventListener('DOMContentLoaded', run); }
	window.addEventListener('load', run);
})();
JS;
	echo '<script>' . $js . '</script>' . "\n";
}

/* ---------- 4) إصلاح تكرار h1: عنوان الموقع → div ---------- */
add_filter( 'TieLabs/logo_html', function ( $html ) {
	if ( is_front_page() && ! is_paged() ) {
		// في الرئيسية عنوان الهيرو هو h1، فنُزيل h1 من الشعار.
		$html = str_replace( array( '<h1', '</h1>' ), array( '<div', '</div>' ), $html );
	}
	return $html;
} );

/* ---------- 5) منع تحميل أصول الإضافات الميتة (تعزيز) ---------- */
add_action( 'wp_print_styles', 'orsozox_dequeue_dead_assets', 200 );
add_action( 'wp_print_scripts', 'orsozox_dequeue_dead_assets', 200 );

function orsozox_dequeue_dead_assets() {
	if ( is_admin() ) {
		return;
	}
	$dead = array( 'tie-css-buddypress', 'tie-css-bbpress', 'tie-css-woocommerce', 'tie-css-mptt', 'tie-css-taqyeem', 'tie-css-crypto', 'tie-js-woocommerce' );

	foreach ( $dead as $h ) {
		if ( wp_style_is( $h, 'enqueued' ) ) {
			wp_dequeue_style( $h );
		}
		if ( wp_script_is( $h, 'enqueued' ) ) {
			wp_dequeue_script( $h );
		}
	}
}
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://orsozox.com/bible/bible-sitemap-books.xml</loc>
    <lastmod>2026-04-07T22:05:57Z</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://orsozox.com/bible/bible-sitemap-chapters.xml</loc>
    <lastmod>2026-04-07T22:05:57Z</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://orsozox.com/bible/bible-sitemap-verses.xml</loc>
    <lastmod>2026-04-07T22:05:57Z</lastmod>
  </sitemap>
</sitemapindex>