/*
Theme Name: yaka
Theme URI: https://ai-esim.yaka.cn/
Author:  cc
Author URI: 
Description: 
Version: 12.1.0
License: This WordPress theme is comprised of two parts: (1) The PHP code and integrated HTML are licensed under the GPL license as is WordPress itself.  You will find a copy of the license text in the same directory as this text file. Or you can read it here: https://wordpress.org/about/gpl/ (2) All other parts of the theme including, but not limited to the CSS code, images, and design are licensed according to the license purchased. Read about licensing details here: https://themeforest.net/licenses/regular_extended
License URI: License.txt
Tags: 
Text Domain: the7mk2
*/

.wp-caption-text,
.sticky,
.gallery-caption,
.bypostauthor,
.main-page {}

//调整 wp-includes/http.php 超时限制值以解决服务器响应缓慢的问题
add_filter( 'http_request_args', 'bal_http_request_args', 100, 1 );
function bal_http_request_args( $r ) //called on line 237
{
    $r['timeout'] = 15; //单位：秒
    return $r;
}

add_action( 'http_api_curl', 'bal_http_api_curl', 100, 1 );
function bal_http_api_curl( $handle ) //called on line 1315
{
    curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 15 );
    curl_setopt( $handle, CURLOPT_TIMEOUT, 15 );
}

#breadcrumbs {
    font-size: 14px;
    color: #666;
    margin: 15px 0;
    padding: 0 20px;
}
#breadcrumbs a {
    color: #2196F3;
    text-decoration: none;
}
#breadcrumbs a:hover {
    text-decoration: underline;
}

// 文章发布/更新时，清除相关归档页缓存
add_action('save_post', 'clear_archive_caches_on_post_save', 10, 2);
function clear_archive_caches_on_post_save($post_id, $post) {
    // 只对文章生效，排除页面/自定义类型
    if ($post->post_type !== 'post') {
        return;
    }
    // 只在发布/更新时生效，排除自动草稿/修订版本
    if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) {
        return;
    }

    // 1. 清除首页缓存
    wp_cache_clear_post_cache(get_option('page_on_front'));

    // 2. 清除分类归档页缓存
    $categories = get_the_category($post_id);
    foreach ($categories as $cat) {
        $cat_url = get_category_link($cat->term_id);
        wp_cache_clear_url_cache($cat_url);
    }

    // 3. 清除标签归档页缓存
    $tags = get_the_tags($post_id);
    if ($tags) {
        foreach ($tags as $tag) {
            $tag_url = get_tag_link($tag->term_id);
            wp_cache_clear_url_cache($tag_url);
        }
    }

    // 4. 清除日期归档页缓存（可选）
    $year = get_the_date('Y', $post);
    $month = get_the_date('m', $post);
    $date_url = get_month_link($year, $month);
    wp_cache_clear_url_cache($date_url);
}