/* Accès restreint à la boutique WooCommerce */
add_action('init', function () {
if (session_status() === PHP_SESSION_NONE && !headers_sent()) {
session_start();
}
}, 1);
add_action('template_redirect', function () {
if (is_admin() || wp_doing_ajax()) {
return;
}
if (function_exists('is_account_page') && is_account_page()) {
return;
}
$page_boutique = function_exists('is_woocommerce') && is_woocommerce();
$panier = function_exists('is_cart') && is_cart();
$commande = function_exists('is_checkout') && is_checkout();
if (!$page_boutique && !$panier && !$commande) {
return;
}
if (
session_status() !== PHP_SESSION_ACTIVE ||
empty($_SESSION['acces_espace_prive_jusqua']) ||
time() >= (int) $_SESSION['acces_espace_prive_jusqua']
) {
wp_safe_redirect(
'https://jjgeekzone.fr/wp-content/themes/espinglere/espace-prive.php'
);
exit;
}
});