<?php
/**
* Twenty Twenty-Five functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package WordPress
* @subpackage Twenty_Twenty_Five
* @since Twenty Twenty-Five 1.0
*/
if ( ! function_exists( 'twentytwentyfive_post_format_setup' ) ) :
/**
* Adds theme support for post formats.
*
* @since Twenty Twenty-Five 1.0
*
* @return void
*/
function twentytwentyfive_post_format_setup() {
add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) );
}
endif;
add_action( 'after_setup_theme', 'twentytwentyfive_post_format_setup' );
if ( ! function_exists( 'twentytwentyfive_editor_style' ) ) :
/**
* Enqueues editor-style.css in the editors.
*
* @since Twenty Twenty-Five 1.0
*
* @return void
*/
function twentytwentyfive_editor_style() {
add_editor_style( 'assets/css/editor-style.css' );
}
endif;
add_action( 'after_setup_theme', 'twentytwentyfive_editor_style' );
if ( ! function_exists( 'twentytwentyfive_enqueue_styles' ) ) :
/**
* Enqueues the theme stylesheet on the front.
*
* @since Twenty Twenty-Five 1.0
*
* @return void
*/
function twentytwentyfive_enqueue_styles() {
$suffix = SCRIPT_DEBUG ? '' : '.min';
$src = 'style' . $suffix . '.css';
wp_enqueue_style(
'twentytwentyfive-style',
get_parent_theme_file_uri( $src ),
array(),
wp_get_theme()->get( 'Version' )
);
wp_style_add_data(
'twentytwentyfive-style',
'path',
get_parent_theme_file_path( $src )
);
}
endif;
add_action( 'wp_enqueue_scripts', 'twentytwentyfive_enqueue_styles' );
if ( ! function_exists( 'twentytwentyfive_block_styles' ) ) :
/**
* Registers custom block styles.
*
* @since Twenty Twenty-Five 1.0
*
* @return void
*/
function twentytwentyfive_block_styles() {
register_block_style(
'core/list',
array(
'name' => 'checkmark-list',
'label' => __( 'Checkmark', 'twentytwentyfive' ),
'inline_style' => '
ul.is-style-checkmark-list {
list-style-type: "\2713";
}
ul.is-style-checkmark-list li {
padding-inline-start: 1ch;
}',
)
);
}
endif;
add_action( 'init', 'twentytwentyfive_block_styles' );
if ( ! function_exists( 'twentytwentyfive_pattern_categories' ) ) :
/**
* Registers pattern categories.
*
* @since Twenty Twenty-Five 1.0
*
* @return void
*/
function twentytwentyfive_pattern_categories() {
register_block_pattern_category(
'twentytwentyfive_page',
array(
'label' => __( 'Pages', 'twentytwentyfive' ),
'description' => __( 'A collection of full page layouts.', 'twentytwentyfive' ),
)
);
register_block_pattern_category(
'twentytwentyfive_post-format',
array(
'label' => __( 'Post formats', 'twentytwentyfive' ),
'description' => __( 'A collection of post format patterns.', 'twentytwentyfive' ),
)
);
}
endif;
add_action( 'init', 'twentytwentyfive_pattern_categories' );
if ( ! function_exists( 'twentytwentyfive_register_block_bindings' ) ) :
/**
* Registers the post format block binding source.
*
* @since Twenty Twenty-Five 1.0
*
* @return void
*/
function twentytwentyfive_register_block_bindings() {
register_block_bindings_source(
'twentytwentyfive/format',
array(
'label' => _x( 'Post format name', 'Label for the block binding placeholder in the editor', 'twentytwentyfive' ),
'get_value_callback' => 'twentytwentyfive_format_binding',
)
);
}
endif;
add_action( 'init', 'twentytwentyfive_register_block_bindings' );
if ( ! function_exists( 'twentytwentyfive_format_binding' ) ) :
/**
* Callback function for the post format name block binding source.
*
* @since Twenty Twenty-Five 1.0
*
* @return string|void Post format name, or nothing if the format is 'standard'.
*/
function twentytwentyfive_format_binding() {
$post_format_slug = get_post_format();
if ( $post_format_slug && 'standard' !== $post_format_slug ) {
return get_post_format_string( $post_format_slug );
}
}
endif;
/* YX OG image fallback: guarantee og:image for feed cards (added 2026-10-29) */
add_action( 'wpseo_head', 'yx_og_image_fallback', 25 );
function yx_og_image_fallback() {
$up = wp_upload_dir();
$default = $up['baseurl'] . '/2026/10/yx-wolf-nobrand-web.jpg';
$img = '';
if ( is_singular() ) {
$img = get_the_post_thumbnail_url( get_queried_object_id(), 'large' );
}
if ( ! $img ) { $img = $default; }
if ( $img ) {
echo '<meta property="og:image" content="' . esc_url( $img ) . '" />' . "\n";
echo '<meta property="og:image:alt" content="' . esc_attr( get_bloginfo( 'name' ) ) . '" />' . "\n";
}
}
/* Bing 站长验证(2026-10-29) */
add_action('wp_head', 'yx_bing_verify');
function yx_bing_verify() {
echo '<meta name="msvalidate.01" content="CC07C563A6253A819C2AE2EE7C965589" />' . "\n";
}
/* 强制站点地址为正式域名(覆盖 wp-config 中的 WP_HOME/WP_SITEURL 常量,2026-10-29) */
add_filter('home_url', function($url){
return preg_replace('#^https?://43\.134\.166\.252#', 'https://yilanhappiness.com', $url);
});
add_filter('site_url', function($url){
return preg_replace('#^https?://43\.134\.166\.252#', 'https://yilanhappiness.com', $url);
});
/* 应急修复:将所有写死的服务器 IP 资源地址改写为正式域名(https 下 http/IP 图被浏览器拦截导致图版消失,2026-10-29) */
add_filter('render_block', function($block_content){
if (is_string($block_content)) {
$block_content = preg_replace('#https?://43\.134\.166\.252#', 'https://yilanhappiness.com', $block_content);
}
return $block_content;
});
/* Yoast 结构化数据( JSON-LD )站点地址强制走域名(根治 WebSite @id / 站内搜索旧 IP,2026-10-29) */
add_filter('wpseo_schema_graph', function($graph){
if (is_array($graph)) {
array_walk_recursive($graph, function(&$val) use ($graph){
if (is_string($val)) {
$val = preg_replace('#https?://43\.134\.166\.252#', 'https://yilanhappiness.com', $val);
}
});
}
return $graph;
});
/* Yoast canonical / og:url 强制走正式域名(覆盖缓存旧 IP,2026-10-29) */
add_filter('wpseo_canonical', function($c){
return preg_replace('#^https?://43\.134\.166\.252#', 'https://yilanhappiness.com', $c);
});
add_filter('wpseo_opengraph_url', function($u){
return preg_replace('#^https?://43\.134\.166\.252#', 'https://yilanhappiness.com', $u);
});
Warning: Cannot modify header information - headers already sent by (output started at /usr/local/lighthouse/softwares/wordpress/wp-content/themes/twentytwentyfive/functions.php:1) in /usr/local/lighthouse/softwares/wordpress/wp-includes/pluggable.php on line 1539
Warning: Cannot modify header information - headers already sent by (output started at /usr/local/lighthouse/softwares/wordpress/wp-content/themes/twentytwentyfive/functions.php:1) in /usr/local/lighthouse/softwares/wordpress/wp-includes/pluggable.php on line 1542