Changeset 59449
- Timestamp:
- 11/22/2024 10:55:12 AM (4 months ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-template.php
r59201 r59449 16 16 add_action( 'pre_get_posts', '_resolve_template_for_new_post' ); 17 17 } 18 } 19 20 /** 21 * Renders a warning screen for empty block templates. 22 * 23 * @since 6.8.0 24 * 25 * @param WP_Block_Template $block_template The block template object. 26 * @return string The warning screen HTML. 27 */ 28 function wp_render_empty_block_template_warning( $block_template ) { 29 wp_enqueue_style( 'wp-empty-template-alert' ); 30 return sprintf( 31 /* translators: %1$s: Block template title. %2$s: Empty template warning message. %3$s: Edit template link. %4$s: Edit template button label. */ 32 '<div id="wp-empty-template-alert"> 33 <h2>%1$s</h2> 34 <p>%2$s</p> 35 <a href="%3$s" class="wp-element-button"> 36 %4$s 37 </a> 38 </div>', 39 esc_html( $block_template->title ), 40 __( 'This page is blank because the template is empty. You can reset or customize it in the Site Editor.' ), 41 get_edit_post_link( $block_template->wp_id, 'site-editor' ), 42 __( 'Edit template' ) 43 ); 18 44 } 19 45 … … 69 95 $_wp_current_template_id = $block_template->id; 70 96 71 if ( empty( $block_template->content ) && is_user_logged_in() ) { 72 $_wp_current_template_content = 73 sprintf( 74 /* translators: %s: Template title */ 75 __( 'Empty template: %s' ), 76 $block_template->title 77 ); 97 if ( empty( $block_template->content ) ) { 98 if ( is_user_logged_in() ) { 99 $_wp_current_template_content = wp_render_empty_block_template_warning( $block_template ); 100 } else { 101 if ( $block_template->has_theme_file ) { 102 // Show contents from theme template if user is not logged in. 103 $theme_template = _get_block_template_file( 'wp_template', $block_template->slug ); 104 $_wp_current_template_content = file_get_contents( $theme_template['path'] ); 105 } else { 106 $_wp_current_template_content = $block_template->content; 107 } 108 } 78 109 } elseif ( ! empty( $block_template->content ) ) { 79 110 $_wp_current_template_content = $block_template->content; -
trunk/src/wp-includes/script-loader.php
r59135 r59449 1628 1628 $styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) ); 1629 1629 $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" ); 1630 $styles->add( 'wp-empty-template-alert', "/wp-includes/css/wp-empty-template-alert$suffix.css" ); 1630 1631 $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' ); 1631 1632 … … 1810 1811 'login', 1811 1812 'site-health', 1813 'wp-empty-template-alert', 1812 1814 // Includes CSS. 1813 1815 'buttons',
Note: See TracChangeset
for help on using the changeset viewer.