编辑:legacy-widget.php
<?php /** * Server-side rendering of the `core/legacy-widget` block. * * @package WordPress */ /** * Renders the 'core/legacy-widget' block. * * @since 5.8.0 * * @global WP_Widget_Factory $wp_widget_factory. * * @param array $attributes The block attributes. * * @return string Rendered block. */ function render_block_core_legacy_widget( $attributes ) { global $wp_widget_factory; if ( isset( $attributes['id'] ) ) { $sidebar_id = wp_find_widgets_sidebar( $attributes['id'] ); return wp_render_widget( $attributes['id'], $sidebar_id ); } if ( ! isset( $attributes['idBase'] ) ) { return ''; } $id_base = $attributes['idBase']; $widget_key = $wp_widget_factory->get_widget_key( $id_base ); $widget_object = $wp_widget_factory->get_widget_object( $id_base ); if ( ! $widget_key || ! $widget_object ) { return ''; } if ( isset( $attributes['instance']['encoded'], $attributes['instance']['hash'] ) ) { $serialized_instance = base64_decode( $attributes['instance']['encoded'] ); if ( ! hash_equals( wp_hash( $serialized_instance ), (string) $attributes['instance']['hash'] ) ) { return ''; } $instance = unserialize( $serialized_instance ); } else { $instance = array(); } $args = array( 'widget_id' => $widget_object->id, 'widget_name' => $widget_object->name, ); ob_start(); the_widget( $widget_key, $instance, $args ); return ob_get_clean(); } /** * Registers the 'core/legacy-widget' block. * * @since 5.8.0 */ function register_block_core_legacy_widget() { register_block_type_from_metadata( __DIR__ . '/legacy-widget', array( 'render_callback' => 'render_block_core_legacy_widget', ) ); } add_action( 'init', 'register_block_core_legacy_widget' ); /** * Intercepts any request with legacy-widget-preview in the query param and, if * set, renders a page containing a preview of the requested Legacy Widget * block. * * @since 5.8.0 */ function handle_legacy_widget_preview_iframe() { if ( empty( $_GET['legacy-widget-preview'] ) ) { return; } if ( ! current_user_can( 'edit_theme_options' ) ) { return; } define( 'IFRAME_REQUEST', true ); ?> <!doctype html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="profile" href="https://gmpg.org/xfn/11" /> <?php wp_head(); ?> <style> /* Reset theme styles */ html, body, #page, #content { padding: 0 !important; margin: 0 !important; } /* Hide root level text nodes */ body { font-size: 0 !important; } /* Hide non-widget elements */ body *:not(#page):not(#content):not(.widget):not(.widget *) { display: none !important; font-size: 0 !important; height: 0 !important; left: -9999px !important; max-height: 0 !important; max-width: 0 !important; opacity: 0 !important; pointer-events: none !important; position: absolute !important; top: -9999px !important; transform: translate(-9999px, -9999px) !important; visibility: hidden !important; z-index: -999 !important; } /* Restore widget font-size */ .widget { font-size: var(--global--font-size-base); } </style> </head> <body <?php body_class(); ?>> <div id="page" class="site"> <div id="content" class="site-content"> <?php $registry = WP_Block_Type_Registry::get_instance(); $block = $registry->get_registered( 'core/legacy-widget' ); echo $block->render( $_GET['legacy-widget-preview'] ); ?> </div><!-- #content --> </div><!-- #page --> <?php wp_footer(); ?> </body> </html> <?php exit; } // Use admin_init instead of init to ensure get_current_screen function is already available. // This isn't strictly required, but enables better compatibility with existing plugins. // See: https://github.com/WordPress/gutenberg/issues/32624. add_action( 'admin_init', 'handle_legacy_widget_preview_iframe', 20 );
保存文件
位置:
home
/
robertofarias
/
public_html
/
wp-includes
/
blocks
批量上传
创建
创建
批量权限
批量删除
名称
权限
大小
修改时间
操作
↑ 返回上级
-
-
-
-
accordion
drwxr-xr-x
-
2026-05-01 02:14
权限
删除
重命名
accordion-heading
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
accordion-item
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
accordion-panel
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
archives
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
audio
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
avatar
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
block
drwxr-xr-x
-
2024-07-17 11:52
权限
删除
重命名
button
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
buttons
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
calendar
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
categories
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
code
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
column
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
columns
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comment-author-name
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-content
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comment-date
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-edit-link
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-reply-link
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-template
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination-next
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination-numbers
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination-previous
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-title
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
cover
drwxr-xr-x
-
2026-05-01 02:14
权限
删除
重命名
details
drwxr-xr-x
-
2026-05-01 03:37
权限
删除
重命名
embed
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
file
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
footnotes
drwxr-xr-x
-
2023-08-09 11:43
权限
删除
重命名
freeform
drwxr-xr-x
-
2026-05-01 03:14
权限
删除
重命名
gallery
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
group
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
heading
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
home-link
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
html
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
image
drwxr-xr-x
-
2023-11-08 10:55
权限
删除
重命名
latest-comments
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
latest-posts
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
legacy-widget
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
list
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
list-item
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
loginout
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
math
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
media-text
drwxr-xr-x
-
2026-05-01 01:56
权限
删除
重命名
missing
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
more
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
navigation
drwxr-xr-x
-
2023-11-08 10:55
权限
删除
重命名
navigation-link
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
navigation-submenu
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
nextpage
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
page-list
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
page-list-item
drwxr-xr-x
-
2023-03-30 09:26
权限
删除
重命名
paragraph
drwxr-xr-x
-
2026-05-01 03:14
权限
删除
重命名
pattern
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-author
drwxr-xr-x
-
2025-12-04 05:42
权限
删除
重命名
post-author-biography
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
post-author-name
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
post-comments-count
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
post-comments-form
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-comments-link
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
post-content
drwxr-xr-x
-
2025-04-16 11:06
权限
删除
重命名
post-date
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-excerpt
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-featured-image
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-navigation-link
drwxr-xr-x
-
2023-03-30 09:26
权限
删除
重命名
post-template
drwxr-xr-x
-
2025-04-16 11:06
权限
删除
重命名
post-terms
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-time-to-read
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
post-title
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
preformatted
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
pullquote
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query
drwxr-xr-x
-
2024-04-03 10:16
权限
删除
重命名
query-no-results
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination-next
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination-numbers
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination-previous
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-title
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-total
drwxr-xr-x
-
2025-04-16 11:06
权限
删除
重命名
quote
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
read-more
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
rss
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
search
drwxr-xr-x
-
2026-05-01 03:14
权限
删除
重命名
separator
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
shortcode
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
site-logo
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
site-tagline
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
site-title
drwxr-xr-x
-
2023-03-30 09:26
权限
删除
重命名
social-link
drwxr-xr-x
-
2026-05-01 02:12
权限
删除
重命名
social-links
drwxr-xr-x
-
2026-05-01 02:25
权限
删除
重命名
spacer
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
table
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
tag-cloud
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
template-part
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
term-count
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
term-description
drwxr-xr-x
-
2023-08-09 11:43
权限
删除
重命名
term-name
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
term-template
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
terms-query
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
text-columns
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
verse
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
video
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
widget-group
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
accordion-item.php
-rw-r--r--
2.35 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
accordion.php
-rw-r--r--
1.12 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
archives.php
-rw-r--r--
4.31 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
calendar.php
-rw-r--r--
5.93 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
categories.php
-rw-r--r--
4.54 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
comments-pagination-next.php
-rw-r--r--
1.88 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
comments-pagination-numbers.php
-rw-r--r--
1.59 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
comments-pagination.php
-rw-r--r--
1.23 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
cover.php
-rw-r--r--
3.1 KB
2025-04-16 11:06
编辑
下载
权限
删除
重命名
error_log
-rw-r--r--
39.29 KB
2026-05-01 18:01
编辑
下载
权限
删除
重命名
gallery.php
-rw-r--r--
6.29 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
latest-comments.php
-rw-r--r--
4.91 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
legacy-widget.php
-rw-r--r--
3.92 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
media-text.php
-rw-r--r--
4.28 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
page-list-item.php
-rw-r--r--
361 B
2024-07-17 11:51
编辑
下载
权限
删除
重命名
page-list.php
-rw-r--r--
13.29 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
post-author-biography.php
-rw-r--r--
1.49 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
post-author-name.php
-rw-r--r--
1.91 KB
2025-05-01 11:02
编辑
下载
权限
删除
重命名
post-author.php
-rw-r--r--
2.67 KB
2025-05-01 11:02
编辑
下载
权限
删除
重命名
post-excerpt.php
-rw-r--r--
3.53 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
post-time-to-read.php
-rw-r--r--
6.34 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
query-no-results.php
-rw-r--r--
1.8 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
query-pagination-next.php
-rw-r--r--
3.69 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
query-pagination-numbers.php
-rw-r--r--
4.66 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
query-pagination.php
-rw-r--r--
1.15 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
search.php
-rw-r--r--
23.26 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
site-tagline.php
-rw-r--r--
1.17 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
site-title.php
-rw-r--r--
1.82 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
social-link.php
-rw-r--r--
66.15 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
tag-cloud.php
-rw-r--r--
1.55 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
term-name.php
-rw-r--r--
2.02 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
widget-group.php
-rw-r--r--
2.38 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名