Skip to content

Commit

Permalink
Remove the edit-context filter of the post title
Browse files Browse the repository at this point in the history
This was originally used to provide a friendlier note when a note
was published rather than (no title) is live. A change in Gutenberg
11.4.0 caused this to not work anymore and instead crash the editor
when the note was saved.

See WordPress/gutenberg@647547a
from WordPress/gutenberg#31569
  • Loading branch information
jeremyfelt committed Nov 26, 2021
1 parent e7a0c88 commit d93ddd7
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions includes/post-type-note.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
add_action( 'admin_init', __NAMESPACE__ . '\flush_rewrite_rules', 10 );
add_filter( 'allowed_block_types', __NAMESPACE__ . '\filter_allowed_block_types', 10, 2 );
add_filter( 'wp_insert_post_data', __NAMESPACE__ . '\filter_wp_insert_post_data', 10 );
add_filter( 'rest_prepare_' . get_slug(), __NAMESPACE__ . '\filter_rest_prepare', 10, 3 );
add_action( 'init', __NAMESPACE__ . '\register_meta' );
add_filter( 'the_content', __NAMESPACE__ . '\prepend_reply_to_markup', 5 );

Expand Down Expand Up @@ -238,25 +237,6 @@ function filter_wp_insert_post_data( $post_data ) {
return $post_data;
}

/**
* Filter the title returned with a REST response when a new note
* is created.
*
* This avoids the display of "(no title) is now live." when a post
* type with no title is first published.
*
* @param WP_REST_Response $response The response object.
* @param WP_Post $post Post object.
* @param WP_REST_Request $request Request object.
*/
function filter_rest_prepare( $response, $post, $request ) {
if ( 'edit' === $request['context'] ) {
$response->data['title'] = __( 'Your note', 'shortnotes' );
}

return $response;
}

/**
* Retrieve the markup used to indicate a note is a reply.
*
Expand Down

0 comments on commit d93ddd7

Please sign in to comment.