X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/wordpress.git/blobdiff_plain/138998bbd8f7a1ac38b2f1eacbdf7cd522be4b13..ef91a7f4f3c6468973e192335a27ec0e0faca0b5:/wp-admin/edit-tags.php diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index 6ff9e374..e90a87f7 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -10,21 +10,21 @@ require_once( dirname( __FILE__ ) . '/admin.php' ); if ( ! $taxnow ) - wp_die( __( 'Invalid taxonomy' ) ); + wp_die( __( 'Invalid taxonomy.' ) ); $tax = get_taxonomy( $taxnow ); if ( ! $tax ) - wp_die( __( 'Invalid taxonomy' ) ); + wp_die( __( 'Invalid taxonomy.' ) ); if ( ! in_array( $tax->name, get_taxonomies( array( 'show_ui' => true ) ) ) ) { - wp_die( __( 'You are not allowed to manage these items.' ) ); + wp_die( __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) ); } if ( ! current_user_can( $tax->cap->manage_terms ) ) { wp_die( '
' . __( 'You are not allowed to manage these items.' ) . '
', + '' . __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ) . '
', 403 ); } @@ -61,46 +61,33 @@ get_current_screen()->set_screen_reader_content( array( $location = false; $referer = wp_get_referer(); +if ( ! $referer ) { // For POST requests. + $referer = wp_unslash( $_SERVER['REQUEST_URI'] ); +} +$referer = remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'error', 'message', 'paged' ), $referer ); switch ( $wp_list_table->current_action() ) { case 'add-tag': - check_admin_referer( 'add-tag', '_wpnonce_add-tag' ); if ( ! current_user_can( $tax->cap->edit_terms ) ) { wp_die( '' . __( 'You are not allowed to add this item.' ) . '
', + '' . __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) . '
', 403 ); } $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); - $location = 'edit-tags.php?taxonomy=' . $taxonomy; - if ( 'post' != $post_type ) - $location .= '&post_type=' . $post_type; - - if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) { - $location = $referer; - } - if ( $ret && !is_wp_error( $ret ) ) $location = add_query_arg( 'message', 1, $location ); else - $location = add_query_arg( array( 'error' => true, 'message' => 4 ), $location ); + $location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer ); break; case 'delete': - $location = 'edit-tags.php?taxonomy=' . $taxonomy; - if ( 'post' != $post_type ) - $location .= '&post_type=' . $post_type; - - if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) { - $location = $referer; - } - if ( ! isset( $_REQUEST['tag_ID'] ) ) { break; } @@ -108,17 +95,17 @@ case 'delete': $tag_ID = (int) $_REQUEST['tag_ID']; check_admin_referer( 'delete-tag_' . $tag_ID ); - if ( ! current_user_can( $tax->cap->delete_terms ) ) { + if ( ! current_user_can( 'delete_term', $tag_ID ) ) { wp_die( '' . __( 'You are not allowed to delete this item.' ) . '
', + '' . __( 'Sorry, you are not allowed to delete this item.' ) . '
', 403 ); } wp_delete_term( $tag_ID, $taxonomy ); - $location = add_query_arg( 'message', 2, $location ); + $location = add_query_arg( 'message', 2, $referer ); break; @@ -128,7 +115,7 @@ case 'bulk-delete': if ( ! current_user_can( $tax->cap->delete_terms ) ) { wp_die( '' . __( 'You are not allowed to delete these items.' ) . '
', + '' . __( 'Sorry, you are not allowed to delete these items.' ) . '
', 403 ); } @@ -138,39 +125,33 @@ case 'bulk-delete': wp_delete_term( $tag_ID, $taxonomy ); } - $location = 'edit-tags.php?taxonomy=' . $taxonomy; - if ( 'post' != $post_type ) - $location .= '&post_type=' . $post_type; - if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) { - $location = $referer; - } - - $location = add_query_arg( 'message', 6, $location ); + $location = add_query_arg( 'message', 6, $referer ); break; case 'edit': - $title = $tax->labels->edit_item; + if ( ! isset( $_REQUEST['tag_ID'] ) ) { + break; + } - $tag_ID = (int) $_REQUEST['tag_ID']; + $term_id = (int) $_REQUEST['tag_ID']; + $term = get_term( $term_id ); - $tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' ); - if ( ! $tag ) + if ( ! $term instanceof WP_Term ) { wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); - require_once( ABSPATH . 'wp-admin/admin-header.php' ); - include( ABSPATH . 'wp-admin/edit-tag-form.php' ); - include( ABSPATH . 'wp-admin/admin-footer.php' ); + } + wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) ); exit; case 'editedtag': $tag_ID = (int) $_POST['tag_ID']; check_admin_referer( 'update-tag_' . $tag_ID ); - if ( ! current_user_can( $tax->cap->edit_terms ) ) { + if ( ! current_user_can( 'edit_term', $tag_ID ) ) { wp_die( '' . __( 'You are not allowed to edit this item.' ) . '
', + '' . __( 'Sorry, you are not allowed to edit this item.' ) . '
', 403 ); } @@ -181,30 +162,41 @@ case 'editedtag': $ret = wp_update_term( $tag_ID, $taxonomy, $_POST ); - $location = 'edit-tags.php?taxonomy=' . $taxonomy; - if ( 'post' != $post_type ) - $location .= '&post_type=' . $post_type; - - if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) { - $location = $referer; + if ( $ret && ! is_wp_error( $ret ) ) { + $location = add_query_arg( 'message', 3, $referer ); + } else { + $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $referer ); } - - if ( $ret && !is_wp_error( $ret ) ) - $location = add_query_arg( 'message', 3, $location ); - else - $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $location ); + break; +default: + if ( ! $wp_list_table->current_action() || ! isset( $_REQUEST['delete_tags'] ) ) { + break; + } + check_admin_referer( 'bulk-tags' ); + $tags = (array) $_REQUEST['delete_tags']; + /** This action is documented in wp-admin/edit-comments.php */ + $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $wp_list_table->current_action(), $tags ); break; } if ( ! $location && ! empty( $_REQUEST['_wp_http_referer'] ) ) { - $location = remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']) ); + $location = remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ); } if ( $location ) { - if ( ! empty( $_REQUEST['paged'] ) ) { - $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location ); + if ( $pagenum > 1 ) { + $location = add_query_arg( 'paged', $pagenum, $location ); // $pagenum takes care of $total_pages. } - wp_redirect( $location ); + + /** + * Filters the taxonomy redirect destination URL. + * + * @since 4.6.0 + * + * @param string $location The destination URL. + * @param object $tax The taxonomy object. + */ + wp_redirect( apply_filters( 'redirect_term_location', $location, $tax ) ); exit; } @@ -269,13 +261,13 @@ if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $t $help = '' . __( 'For more information:' ) . '
'; if ( 'category' == $taxonomy ) - $help .= '' . __( 'Documentation on Categories' ) . '
'; + $help .= '' . __( 'Documentation on Categories' ) . '
'; elseif ( 'link_category' == $taxonomy ) - $help .= '' . __( 'Documentation on Link Categories' ) . '
'; + $help .= '' . __( 'Documentation on Link Categories' ) . '
'; else - $help .= '' . __( 'Documentation on Tags' ) . '
'; + $help .= '' . __( 'Documentation on Tags' ) . '
'; - $help .= '' . __('Support Forums') . '
'; + $help .= '' . __('Support Forums') . '
'; get_current_screen()->set_help_sidebar( $help ); @@ -284,14 +276,6 @@ if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $t require_once( ABSPATH . 'wp-admin/admin-header.php' ); -if ( ! current_user_can( $tax->cap->edit_terms ) ) { - wp_die( - '' . __( 'You are not allowed to edit this item.' ) . '
', - 403 - ); -} - /** Also used by the Edit Tag form */ require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' ); @@ -307,8 +291,11 @@ if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) {
- ' . __( 'Note:' ) . '
';
- printf(
- /* translators: %s: default category */
- __( 'Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category %s.' ),
- /** This filter is documented in wp-includes/category-template.php */
- '' . apply_filters( 'the_category', get_cat_name( get_option( 'default_category') ) ) . ''
- );
- ?>
-
category to tag converter.' ), esc_url( $import_link ) ) ?>
- -tag to category converter.' ), esc_url( $import_link ) ) ;?>
-
+ ' . __( 'Note:' ) . '
';
+ printf(
+ /* translators: %s: default category */
+ __( 'Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category %s.' ),
+ /** This filter is documented in wp-includes/category-template.php */
+ '' . apply_filters( 'the_category', get_cat_name( get_option( 'default_category') ) ) . ''
+ );
+ ?>
+
category to tag converter.' ), esc_url( $import_link ) ) ?>
+ +tag to category converter.' ), esc_url( $import_link ) ) ;?>
+