/*
Theme Name: Kadence Child
Template: kadence
Version: 1.0
Author: Den Slav
Description: Child theme for Kadence
*/

$inc_path = get_stylesheet_directory() . '/inc/';

foreach ( glob( $inc_path . '*.php' ) as $file ) {
    require_once $file;
}

add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    if ( empty( $data ) ) {
        return $data;
    }

    // Переводим массив схемы в строку JSON
    $json_string = json_encode(
        $data,
        JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
    );

    // Старые домены
    $old_domains = array(
        'chickenroad-2.at',
        '2minus1.at',
    'sapi-bellu.at',
    );

    // Новый домен
    $new_domain = 'sapi-bellu.at';

    // Заменяем все старые домены на новый
    $json_string = str_replace(
        $old_domains,
        $new_domain,
        $json_string
    );

    // Возвращаем изменённые данные обратно в массив
    $custom_data = json_decode( $json_string, true );

    return is_array( $custom_data ) ? $custom_data : $data;
}, 99, 2 );