Prevent terms in a show_in_quick_edit=false taxonomy from being updated by a faked AJAX request.

The UI for these taxonomies was hidden in [31308], but it remained possible to
send a direct POST request to the `inline-edit` endpoint to bypass the
restriction. The current changeset fixes this.

Props meloniq.
Fixes #26948.

git-svn-id: https://develop.svn.wordpress.org/trunk@31313 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2015-01-31 19:37:12 +00:00
parent 2d737796d2
commit 32f2903248
2 changed files with 82 additions and 0 deletions
+11
View File
@@ -1550,6 +1550,17 @@ function wp_ajax_inline_save() {
if ( empty($data['ping_status']) )
$data['ping_status'] = 'closed';
// Exclude terms from taxonomies that are not supposed to appear in Quick Edit.
if ( ! empty( $data['tax_input'] ) ) {
foreach ( $data['tax_input'] as $taxonomy => $terms ) {
$tax_object = get_taxonomy( $taxonomy );
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
if ( ! apply_filters( 'quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'] ) ) {
unset( $data['tax_input'][ $taxonomy ] );
}
}
}
// Hack: wp_unique_post_slug() doesn't work for drafts, so we will fake that our post is published.
if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ) ) ) {
$post['post_status'] = 'publish';