mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-02 03:34:33 +00:00
Editor: Add block theme infrastructure
Adds the required infrastructure to render block-based themes. This is sourced from the Gutenberg plugin. Fixes #54335. Props bernhard-reiter, youknowriad, ntsekouras, hellofromtonya. git-svn-id: https://develop.svn.wordpress.org/trunk@52062 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1,5 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Sets a custom slug when creating auto-draft template parts.
|
||||
*
|
||||
* This is only needed for auto-drafts created by the regular WP editor.
|
||||
* If this page is to be removed, this won't be necessary.
|
||||
*
|
||||
* @since 5.9.0
|
||||
*
|
||||
*/
|
||||
function wp_set_unique_slug_on_create_template_part( $post_id ) {
|
||||
$post = get_post( $post_id );
|
||||
if ( 'auto-draft' !== $post->post_status ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $post->post_name ) {
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $post_id,
|
||||
'post_name' => 'custom_slug_' . uniqid(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$terms = get_the_terms( $post_id, 'wp_theme' );
|
||||
if ( ! is_array( $terms ) || ! count( $terms ) ) {
|
||||
wp_set_post_terms( $post_id, wp_get_theme()->get_stylesheet(), 'wp_theme' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique slug for templates.
|
||||
*
|
||||
@@ -14,7 +44,7 @@
|
||||
* @return string The original, desired slug.
|
||||
*/
|
||||
function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_ID, $post_status, $post_type ) {
|
||||
if ( 'wp_template' !== $post_type ) {
|
||||
if ( 'wp_template' !== $post_type && 'wp_template_part' !== $post_type ) {
|
||||
return $override_slug;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user