'
. esc_html__( 'CyyWordpress 主题需要 PHP 8.1 或更高版本。', 'cyywordpress' )
. '
';
}
);
return; // Do not load theme in unsupported environments.
}
global $wp_version;
if ( version_compare( $wp_version, '6.0', '<' ) ) {
add_action(
'admin_notices',
function (): void {
echo '',
)
);
register_sidebar(
array(
'name' => esc_html__( '页脚 Widget 1', 'cyywordpress' ),
'id' => 'sidebar-footer-1',
'description' => esc_html__( '页脚第一列 Widget 区域。', 'cyywordpress' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( '页脚 Widget 2', 'cyywordpress' ),
'id' => 'sidebar-footer-2',
'description' => esc_html__( '页脚第二列 Widget 区域。', 'cyywordpress' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( '页脚 Widget 3', 'cyywordpress' ),
'id' => 'sidebar-footer-3',
'description' => esc_html__( '页脚第三列 Widget 区域。', 'cyywordpress' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( '导航栏右侧', 'cyywordpress' ),
'id' => 'sidebar-header',
'description' => esc_html__( '出现在导航栏右侧的 Widget 区域(搜索等)。', 'cyywordpress' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '',
)
);
}
add_action( 'widgets_init', 'cyywordpress_widgets_init' );
// ---------------------------------------------------------------------------
// Initialise asset, SEO and schema classes
// ---------------------------------------------------------------------------
add_action(
'after_setup_theme',
function (): void {
CyyWordpress_Assets::init();
CyyWordpress_SEO::init();
CyyWordpress_Schema::init();
}
);
// ---------------------------------------------------------------------------
// Lazy-load attributes on all attachment images
// ---------------------------------------------------------------------------
add_filter(
'wp_get_attachment_image_attributes',
function ( array $attr ): array {
$attr['loading'] = 'lazy';
$attr['decoding'] = 'async';
return $attr;
}
);
// ---------------------------------------------------------------------------
// Remove WordPress emoji CDN (performance)
// ---------------------------------------------------------------------------
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );