Skip to content

Commit

Permalink
Replicate more core changes in gutenberg
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Nov 25, 2021
1 parent 8ca07a4 commit 9da9eea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Expand Up @@ -214,6 +214,10 @@ public function update_item( $request ) {

$changes = $this->prepare_item_for_database( $request );

if ( is_wp_error( $changes ) ) {
return $changes;
}

if ( 'custom' === $template->source ) {
$result = wp_update_post( wp_slash( (array) $changes ), true );
} else {
Expand Down Expand Up @@ -252,7 +256,12 @@ public function create_item_permissions_check( $request ) {
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
*/
public function create_item( $request ) {
$changes = $this->prepare_item_for_database( $request );
$changes = $this->prepare_item_for_database( $request );

if ( is_wp_error( $changes ) ) {
return $changes;
}

$changes->post_name = $request['slug'];
$result = wp_insert_post( wp_slash( (array) $changes ), true );
if ( is_wp_error( $result ) ) {
Expand Down Expand Up @@ -354,7 +363,9 @@ protected function prepare_item_for_database( $request ) {
$changes->tax_input = array(
'wp_theme' => $template->theme,
);
$changes->origin = $template->source;
$changes->meta_input = array(
'origin' => $template->source,
);
} else {
$changes->post_name = $template->slug;
$changes->ID = $template->wp_id;
Expand Down Expand Up @@ -564,7 +575,7 @@ public function get_item_schema() {
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
'source' => array(
'origin' => array(
'description' => __( 'Source of customized template', 'gutenberg' ),
'type' => 'string',
'context' => array( 'embed', 'view', 'edit' ),
Expand Down
1 change: 0 additions & 1 deletion lib/full-site-editing/class-wp-block-template.php
Expand Up @@ -72,7 +72,6 @@ class WP_Block_Template {
* When customized, origin takes on the value of source and source becomes
* 'custom'.
*
* @since 5.9.0
* @var string
*/
public $origin;
Expand Down

0 comments on commit 9da9eea

Please sign in to comment.