Changeset 52062 for trunk/src/wp-includes/theme-templates.php
- Timestamp:
- 11/08/2021 11:09:53 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/theme-templates.php
r51199 r52062 1 1 <?php 2 3 /** 4 * Sets a custom slug when creating auto-draft template parts. 5 * 6 * This is only needed for auto-drafts created by the regular WP editor. 7 * If this page is to be removed, this won't be necessary. 8 * 9 * @since 5.9.0 10 * 11 */ 12 function wp_set_unique_slug_on_create_template_part( $post_id ) { 13 $post = get_post( $post_id ); 14 if ( 'auto-draft' !== $post->post_status ) { 15 return; 16 } 17 18 if ( ! $post->post_name ) { 19 wp_update_post( 20 array( 21 'ID' => $post_id, 22 'post_name' => 'custom_slug_' . uniqid(), 23 ) 24 ); 25 } 26 27 $terms = get_the_terms( $post_id, 'wp_theme' ); 28 if ( ! is_array( $terms ) || ! count( $terms ) ) { 29 wp_set_post_terms( $post_id, wp_get_theme()->get_stylesheet(), 'wp_theme' ); 30 } 31 } 2 32 3 33 /** … … 15 45 */ 16 46 function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_ID, $post_status, $post_type ) { 17 if ( 'wp_template' !== $post_type ) {47 if ( 'wp_template' !== $post_type && 'wp_template_part' !== $post_type ) { 18 48 return $override_slug; 19 49 }
Note: See TracChangeset
for help on using the changeset viewer.