编辑:home-link.php
<?php /** * Server-side rendering of the `core/home-link` block. * * @package WordPress */ /** * Build an array with CSS classes and inline styles defining the colors * which will be applied to the home link markup in the front-end. * * @since 6.0.0 * * @param array $context home link block context. * @return array Colors CSS classes and inline styles. */ function block_core_home_link_build_css_colors( $context ) { $colors = array( 'css_classes' => array(), 'inline_styles' => '', ); // Text color. $has_named_text_color = array_key_exists( 'textColor', $context ); $has_custom_text_color = isset( $context['style']['color']['text'] ); // If has text color. if ( $has_custom_text_color || $has_named_text_color ) { // Add has-text-color class. $colors['css_classes'][] = 'has-text-color'; } if ( $has_named_text_color ) { // Add the color class. $colors['css_classes'][] = sprintf( 'has-%s-color', $context['textColor'] ); } elseif ( $has_custom_text_color ) { // Add the custom color inline style. $colors['inline_styles'] .= sprintf( 'color: %s;', $context['style']['color']['text'] ); } // Background color. $has_named_background_color = array_key_exists( 'backgroundColor', $context ); $has_custom_background_color = isset( $context['style']['color']['background'] ); // If has background color. if ( $has_custom_background_color || $has_named_background_color ) { // Add has-background class. $colors['css_classes'][] = 'has-background'; } if ( $has_named_background_color ) { // Add the background-color class. $colors['css_classes'][] = sprintf( 'has-%s-background-color', $context['backgroundColor'] ); } elseif ( $has_custom_background_color ) { // Add the custom background-color inline style. $colors['inline_styles'] .= sprintf( 'background-color: %s;', $context['style']['color']['background'] ); } return $colors; } /** * Build an array with CSS classes and inline styles defining the font sizes * which will be applied to the home link markup in the front-end. * * @since 6.0.0 * * @param array $context Home link block context. * @return array Font size CSS classes and inline styles. */ function block_core_home_link_build_css_font_sizes( $context ) { // CSS classes. $font_sizes = array( 'css_classes' => array(), 'inline_styles' => '', ); $has_named_font_size = array_key_exists( 'fontSize', $context ); $has_custom_font_size = isset( $context['style']['typography']['fontSize'] ); if ( $has_named_font_size ) { // Add the font size class. $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] ); } elseif ( $has_custom_font_size ) { // Add the custom font size inline style. $font_sizes['inline_styles'] = sprintf( 'font-size: %s;', $context['style']['typography']['fontSize'] ); } return $font_sizes; } /** * Builds an array with classes and style for the li wrapper * * @since 6.0.0 * * @param array $context Home link block context. * @return string The li wrapper attributes. */ function block_core_home_link_build_li_wrapper_attributes( $context ) { $colors = block_core_home_link_build_css_colors( $context ); $font_sizes = block_core_home_link_build_css_font_sizes( $context ); $classes = array_merge( $colors['css_classes'], $font_sizes['css_classes'] ); $style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] ); $classes[] = 'wp-block-navigation-item'; if ( is_front_page() ) { $classes[] = 'current-menu-item'; } elseif ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) { // Edge case where the Reading settings has a posts page set but not a static homepage. $classes[] = 'current-menu-item'; } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ), 'style' => $style_attribute, ) ); return $wrapper_attributes; } /** * Renders the `core/home-link` block. * * @since 6.0.0 * * @param array $attributes The block attributes. * @param string $content The saved content. * @param WP_Block $block The parsed block. * * @return string Returns the post content with the home url added. */ function render_block_core_home_link( $attributes, $content, $block ) { if ( empty( $attributes['label'] ) ) { $attributes['label'] = __( 'Home' ); } $aria_current = ''; if ( is_front_page() ) { $aria_current = ' aria-current="page"'; } elseif ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) { // Edge case where the Reading settings has a posts page set but not a static homepage. $aria_current = ' aria-current="page"'; } return sprintf( '<li %1$s><a class="wp-block-home-link__content wp-block-navigation-item__content" href="%2$s" rel="home"%3$s>%4$s</a></li>', block_core_home_link_build_li_wrapper_attributes( $block->context ), esc_url( home_url() ), $aria_current, wp_kses_post( $attributes['label'] ) ); } /** * Register the home block * * @since 6.0.0 * * @uses render_block_core_home_link() * @throws WP_Error An WP_Error exception parsing the block definition. */ function register_block_core_home_link() { register_block_type_from_metadata( __DIR__ . '/home-link', array( 'render_callback' => 'render_block_core_home_link', ) ); } add_action( 'init', 'register_block_core_home_link' );
保存文件
位置:
home
/
fembzvrs
/
zimeza.com
/
wp-includes
/
blocks
批量上传
创建
创建
批量权限
批量删除
名称
权限
大小
修改时间
操作
↑ 返回上级
-
-
-
-
accordion
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
accordion-heading
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
accordion-item
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
accordion-panel
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
archives
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
audio
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
avatar
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
block
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
button
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
buttons
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
calendar
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
categories
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
code
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
column
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
columns
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comment-author-name
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comment-content
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comment-date
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comment-edit-link
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comment-reply-link
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comment-template
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comments
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comments-pagination
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comments-pagination-next
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comments-pagination-numbers
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comments-pagination-previous
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
comments-title
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
cover
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
details
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
embed
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
file
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
footnotes
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
freeform
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
gallery
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
group
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
heading
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
home-link
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
html
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
image
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
latest-comments
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
latest-posts
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
legacy-widget
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
list
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
list-item
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
loginout
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
math
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
media-text
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
missing
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
more
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
navigation
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
navigation-link
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
navigation-submenu
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
nextpage
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
page-list
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
page-list-item
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
paragraph
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
pattern
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-author
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
post-author-biography
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-author-name
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-comments-count
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
post-comments-form
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-comments-link
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
post-content
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-date
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-excerpt
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-featured-image
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-navigation-link
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-template
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-terms
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
post-time-to-read
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
post-title
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
preformatted
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
pullquote
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
query
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
query-no-results
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
query-pagination
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
query-pagination-next
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
query-pagination-numbers
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
query-pagination-previous
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
query-title
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
query-total
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
quote
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
read-more
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
rss
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
search
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
separator
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
shortcode
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
site-logo
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
site-tagline
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
site-title
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
social-link
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
social-links
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
spacer
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
table
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
tag-cloud
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
template-part
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
term-count
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
term-description
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
term-name
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
term-template
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
terms-query
drwxr-xr-x
-
2025-12-03 02:17
权限
删除
重命名
text-columns
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
verse
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
video
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
widget-group
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
accordion-item.php
-rw-r--r--
2.35 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
accordion.php
-rw-r--r--
1.12 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
calendar.php
-rw-r--r--
5.93 KB
2024-05-23 23:39
编辑
下载
权限
删除
重命名
comment-edit-link.php
-rw-r--r--
1.67 KB
2024-05-23 23:39
编辑
下载
权限
删除
重命名
cover.php
-rw-r--r--
3.1 KB
2025-02-07 20:46
编辑
下载
权限
删除
重命名
file.php
-rw-r--r--
1.83 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
heading.php
-rw-r--r--
1.27 KB
2024-05-23 23:39
编辑
下载
权限
删除
重命名
home-link.php
-rw-r--r--
5.31 KB
2025-02-07 20:46
编辑
下载
权限
删除
重命名
image.php
-rw-r--r--
13.5 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
latest-posts.php
-rw-r--r--
8.53 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
loginout.php
-rw-r--r--
1.63 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
navigation-link.php
-rw-r--r--
13.63 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
page-list-item.php
-rw-r--r--
361 B
2024-05-23 23:39
编辑
下载
权限
删除
重命名
post-author-biography.php
-rw-r--r--
1.49 KB
2024-05-23 23:39
编辑
下载
权限
删除
重命名
post-comments-form.php
-rw-r--r--
2.74 KB
2024-05-23 23:39
编辑
下载
权限
删除
重命名
post-comments-link.php
-rw-r--r--
2.18 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
post-date.php
-rw-r--r--
3.55 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
post-featured-image.php
-rw-r--r--
9.14 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
query-no-results.php
-rw-r--r--
1.8 KB
2024-05-23 23:39
编辑
下载
权限
删除
重命名
site-logo.php
-rw-r--r--
6.19 KB
2024-09-20 05:55
编辑
下载
权限
删除
重命名
site-tagline.php
-rw-r--r--
1.17 KB
2024-05-23 23:39
编辑
下载
权限
删除
重命名
social-link.php
-rw-r--r--
66.15 KB
2025-12-03 02:17
编辑
下载
权限
删除
重命名
tag-cloud.php
-rw-r--r--
1.55 KB
2024-09-20 05:55
编辑
下载
权限
删除
重命名
term-template.php
-rw-r--r--
4.41 KB
2026-02-04 02:17
编辑
下载
权限
删除
重命名
widget-group.php
-rw-r--r--
2.38 KB
2024-05-23 23:39
编辑
下载
权限
删除
重命名