From cb2782aaa0b445ce2fc666eb83345df1625a5a43 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Sat, 11 Jul 2015 20:00:24 +0000 Subject: [PATCH] Customizer: Replace non-visible error messages for nav menus with error codes. see #32576. Built from https://develop.svn.wordpress.org/trunk@33163 git-svn-id: http://core.svn.wordpress.org/trunk@33135 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-nav-menus.php | 19 +++++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/wp-includes/class-wp-customize-nav-menus.php b/wp-includes/class-wp-customize-nav-menus.php index 47aa859c33..3772496388 100644 --- a/wp-includes/class-wp-customize-nav-menus.php +++ b/wp-includes/class-wp-customize-nav-menus.php @@ -70,23 +70,25 @@ final class WP_Customize_Nav_Menus { check_ajax_referer( 'customize-menus', 'customize-menus-nonce' ); if ( ! current_user_can( 'edit_theme_options' ) ) { - wp_send_json_error( array( 'message' => __( 'Error: invalid user capabilities.' ) ) ); + wp_die( -1 ); } + if ( empty( $_POST['obj_type'] ) || empty( $_POST['type'] ) ) { - wp_send_json_error( array( 'message' => __( 'Missing obj_type or type param.' ) ) ); + wp_send_json_error( 'nav_menus_missing_obj_type_or_type_parameter' ); } $obj_type = sanitize_key( $_POST['obj_type'] ); if ( ! in_array( $obj_type, array( 'post_type', 'taxonomy' ) ) ) { - wp_send_json_error( array( 'message' => __( 'Invalid obj_type param: ' . $obj_type ) ) ); + wp_send_json_error( 'nav_menus_invalid_obj_type' ); } + $taxonomy_or_post_type = sanitize_key( $_POST['type'] ); $page = isset( $_POST['page'] ) ? absint( $_POST['page'] ) : 0; $items = array(); if ( 'post_type' === $obj_type ) { if ( ! get_post_type_object( $taxonomy_or_post_type ) ) { - wp_send_json_error( array( 'message' => __( 'Unknown post type.' ) ) ); + wp_send_json_error( 'nav_menus_invalid_post_type' ); } if ( 0 === $page && 'page' === $taxonomy_or_post_type ) { @@ -138,7 +140,7 @@ final class WP_Customize_Nav_Menus { 'pad_counts' => false, ) ); if ( is_wp_error( $terms ) ) { - wp_send_json_error( array( 'message' => wp_strip_all_tags( $terms->get_error_message(), true ) ) ); + wp_send_json_error( $terms->get_error_code() ); } foreach ( $terms as $term ) { @@ -165,11 +167,12 @@ final class WP_Customize_Nav_Menus { public function ajax_search_available_items() { check_ajax_referer( 'customize-menus', 'customize-menus-nonce' ); - if ( ! current_user_can( 'edit_theme_options' ) ) { - wp_send_json_error( array( 'message' => __( 'Error: invalid user capabilities.' ) ) ); + if ( current_user_can( 'edit_theme_options' ) ) { + wp_die( -1 ); } + if ( empty( $_POST['search'] ) ) { - wp_send_json_error( array( 'message' => __( 'Error: missing search parameter.' ) ) ); + wp_send_json_error( 'nav_menus_missing_search_parameter' ); } $p = isset( $_POST['page'] ) ? absint( $_POST['page'] ) : 0; diff --git a/wp-includes/version.php b/wp-includes/version.php index 1653904c54..046b3c87b4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-beta2-33162'; +$wp_version = '4.3-beta2-33163'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.