Changeset 55436
- Timestamp:
- 02/28/2023 03:05:50 PM (14 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-template.php
r55335 r55436 336 336 } 337 337 } 338 339 /**340 * Returns the correct template for the site's home page.341 *342 * @access private343 * @since 6.0.0344 *345 * @return array|null A template object, or null if none could be found.346 */347 function _resolve_home_block_template() {348 $show_on_front = get_option( 'show_on_front' );349 $front_page_id = get_option( 'page_on_front' );350 351 if ( 'page' === $show_on_front && $front_page_id ) {352 return array(353 'postType' => 'page',354 'postId' => $front_page_id,355 );356 }357 358 $hierarchy = array( 'front-page', 'home', 'index' );359 $template = resolve_block_template( 'home', $hierarchy, '' );360 361 if ( ! $template ) {362 return null;363 }364 365 return array(366 'postType' => 'wp_template',367 'postId' => $template->id,368 );369 } -
trunk/src/wp-includes/deprecated.php
r55365 r55436 4592 4592 return null; 4593 4593 } 4594 4595 /** 4596 * Returns the correct template for the site's home page. 4597 * 4598 * @access private 4599 * @since 6.0.0 4600 * @deprecated 6.2.0 Site Editor's server-side redirect for missing postType and postId 4601 * query args is removed. Thus, this function is no longer used. 4602 * 4603 * @return array|null A template object, or null if none could be found. 4604 */ 4605 function _resolve_home_block_template() { 4606 _deprecated_function( __FUNCTION__, '6.2.0' ); 4607 4608 $show_on_front = get_option( 'show_on_front' ); 4609 $front_page_id = get_option( 'page_on_front' ); 4610 4611 if ( 'page' === $show_on_front && $front_page_id ) { 4612 return array( 4613 'postType' => 'page', 4614 'postId' => $front_page_id, 4615 ); 4616 } 4617 4618 $hierarchy = array( 'front-page', 'home', 'index' ); 4619 $template = resolve_block_template( 'home', $hierarchy, '' ); 4620 4621 if ( ! $template ) { 4622 return null; 4623 } 4624 4625 return array( 4626 'postType' => 'wp_template', 4627 'postId' => $template->id, 4628 ); 4629 } -
trunk/tests/phpunit/tests/block-template.php
r54889 r55436 189 189 $this->assertSame( '', $resolved_template_path ); 190 190 } 191 192 /**193 * Covers: https://github.com/WordPress/gutenberg/pull/38817.194 *195 * @ticket 55505196 */197 public function test_resolve_home_block_template_default_hierarchy() {198 $template = _resolve_home_block_template();199 200 $this->assertSame( 'wp_template', $template['postType'] );201 $this->assertSame( get_stylesheet() . '//index', $template['postId'] );202 }203 204 /**205 * @ticket 55505206 */207 public function test_resolve_home_block_template_static_homepage() {208 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );209 update_option( 'show_on_front', 'page' );210 update_option( 'page_on_front', $post_id );211 212 $template = _resolve_home_block_template();213 214 $this->assertSame( 'page', $template['postType'] );215 $this->assertSame( $post_id, $template['postId'] );216 217 delete_option( 'show_on_front', 'page' );218 }219 220 /**221 * @ticket 55505222 */223 public function test_resolve_home_block_template_no_resolution() {224 switch_theme( 'stylesheetonly' );225 $template = _resolve_home_block_template();226 227 $this->assertNull( $template );228 }229 191 }
Note: See TracChangeset
for help on using the changeset viewer.