Skip to content

Commit

Permalink
Filters are incorrectly applied in the __experimental/menu-items cont…
Browse files Browse the repository at this point in the history
…roller (#34857)

* We don't need to apply these filters (title_save_pre, exceprt_save_pre, content_save_pre) as they get applied later inside the wp_insert_post function.

* Implement a regression test to check that we don't call fiilter callbacks more than once.

* Revert accidental change.

* Implement a regression test to check that we don't call fiilter callbacks more than once when updating a menu item.

* Refactor the method name.

* Fix code style.

* Remove the unit tests as suggested here: #34857 (comment)
  • Loading branch information
anton-vlasenko authored Sep 21, 2021
1 parent b12bbe4 commit d13c648
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions lib/class-wp-rest-menu-items-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,17 +543,6 @@ protected function prepare_item_for_database( $request ) {
$prepared_nav_item[ $key ] = implode( ' ', array_map( 'sanitize_html_class', $value ) );
}

// Apply the same filters as when calling wp_insert_post().

/** This filter is documented in wp-includes/post.php */
$prepared_nav_item['menu-item-title'] = wp_unslash( apply_filters( 'title_save_pre', wp_slash( $prepared_nav_item['menu-item-title'] ) ) );

/** This filter is documented in wp-includes/post.php */
$prepared_nav_item['menu-item-attr-title'] = wp_unslash( apply_filters( 'excerpt_save_pre', wp_slash( $prepared_nav_item['menu-item-attr-title'] ) ) );

/** This filter is documented in wp-includes/post.php */
$prepared_nav_item['menu-item-description'] = wp_unslash( apply_filters( 'content_save_pre', wp_slash( $prepared_nav_item['menu-item-description'] ) ) );

// Valid url.
if ( '' !== $prepared_nav_item['menu-item-url'] ) {
$prepared_nav_item['menu-item-url'] = esc_url_raw( $prepared_nav_item['menu-item-url'] );
Expand Down

0 comments on commit d13c648

Please sign in to comment.