Taxonomy: Introduce `wp-admin/term.php` for editing single terms.
This is similar to `edit.php` -> `post.php` and `users.php` -> `user-edit.php` and fixes a bug where screen options for the list table were shown while editing a term. Fixes #34988. git-svn-id: https://develop.svn.wordpress.org/trunk@36308 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d80a3c7ccd
commit
2241519865
|
@ -7,16 +7,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// don't load directly
|
// don't load directly
|
||||||
if ( !defined('ABSPATH') )
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
die('-1');
|
die( '-1' );
|
||||||
|
|
||||||
if ( empty($tag_ID) ) { ?>
|
|
||||||
<div class="wrap">
|
|
||||||
<h1><?php echo $tax->labels->edit_item; ?></h1>
|
|
||||||
<div id="message" class="notice notice-warning"><p><strong><?php _e( 'You did not select an item for editing.' ); ?></strong></p></div>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back compat hooks
|
// Back compat hooks
|
||||||
|
@ -57,7 +49,7 @@ if ( 'category' == $taxonomy ) {
|
||||||
*/
|
*/
|
||||||
wp_reset_vars( array( 'wp_http_referer' ) );
|
wp_reset_vars( array( 'wp_http_referer' ) );
|
||||||
|
|
||||||
$wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer );
|
$wp_http_referer = remove_query_arg( array( 'action', 'message', 'term_id' ), $wp_http_referer );
|
||||||
|
|
||||||
/** Also used by Edit Tags */
|
/** Also used by Edit Tags */
|
||||||
require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
|
require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
|
||||||
|
@ -103,10 +95,13 @@ do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
|
||||||
*/
|
*/
|
||||||
do_action( "{$taxonomy}_term_edit_form_tag" );
|
do_action( "{$taxonomy}_term_edit_form_tag" );
|
||||||
?>>
|
?>>
|
||||||
<input type="hidden" name="action" value="editedtag" />
|
<input type="hidden" name="action" value="editedtag"/>
|
||||||
<input type="hidden" name="tag_ID" value="<?php echo esc_attr($tag->term_id) ?>" />
|
<input type="hidden" name="tag_ID" value="<?php echo esc_attr( $term_id ) ?>"/>
|
||||||
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy) ?>" />
|
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ) ?>"/>
|
||||||
<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?>
|
<?php
|
||||||
|
wp_original_referer_field( true, 'previous' );
|
||||||
|
wp_nonce_field( 'update-tag_' . $term_id );
|
||||||
|
?>
|
||||||
<table class="form-table">
|
<table class="form-table">
|
||||||
<tr class="form-field form-required term-name-wrap">
|
<tr class="form-field form-required term-name-wrap">
|
||||||
<th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
|
<th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
|
||||||
|
|
|
@ -150,21 +150,18 @@ case 'bulk-delete':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'edit':
|
case 'edit':
|
||||||
$title = $tax->labels->edit_item;
|
|
||||||
|
|
||||||
if ( ! isset( $_REQUEST['tag_ID'] ) ) {
|
if ( ! isset( $_REQUEST['tag_ID'] ) ) {
|
||||||
break;
|
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 ( ! $term instanceof WP_Term ) {
|
||||||
if ( ! $tag )
|
|
||||||
wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) );
|
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;
|
exit;
|
||||||
|
|
||||||
case 'editedtag':
|
case 'editedtag':
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Edit Term Administration Screen.
|
||||||
|
*
|
||||||
|
* @package WordPress
|
||||||
|
* @subpackage Administration
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** WordPress Administration Bootstrap */
|
||||||
|
require_once( dirname( __FILE__ ) . '/admin.php' );
|
||||||
|
|
||||||
|
if ( empty( $_REQUEST['term_id'] ) ) {
|
||||||
|
$sendback = admin_url( 'edit-tags.php' );
|
||||||
|
if ( ! empty( $taxnow ) ) {
|
||||||
|
$sendback = add_query_arg( array( 'taxonomy' => $taxnow ), $sendback );
|
||||||
|
}
|
||||||
|
wp_redirect( esc_url( $sendback ) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$term_id = absint( $_REQUEST['term_id'] );
|
||||||
|
$tag = get_term( $term_id, $taxnow, OBJECT, 'edit' );
|
||||||
|
|
||||||
|
if ( ! $tag instanceof WP_Term ) {
|
||||||
|
wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$tax = get_taxonomy( $tag->taxonomy );
|
||||||
|
$taxonomy = $tax->name;
|
||||||
|
$title = $tax->labels->edit_item;
|
||||||
|
|
||||||
|
if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ) ) ||
|
||||||
|
! current_user_can( $tax->cap->manage_terms )
|
||||||
|
) {
|
||||||
|
wp_die(
|
||||||
|
'<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
|
||||||
|
'<p>' . __( 'You are not allowed to manage this item.' ) . '</p>',
|
||||||
|
403
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_type = get_current_screen()->post_type;
|
||||||
|
|
||||||
|
// Default to the first object_type associated with the taxonomy if no post type was passed.
|
||||||
|
if ( empty( $post_type ) ) {
|
||||||
|
$post_type = reset( $tax->object_type );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( 'post' != $post_type ) {
|
||||||
|
$parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
|
||||||
|
$submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type";
|
||||||
|
} elseif ( 'link_category' == $taxonomy ) {
|
||||||
|
$parent_file = 'link-manager.php';
|
||||||
|
$submenu_file = 'edit-tags.php?taxonomy=link_category';
|
||||||
|
} else {
|
||||||
|
$parent_file = 'edit.php';
|
||||||
|
$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
|
||||||
|
}
|
||||||
|
|
||||||
|
get_current_screen()->set_screen_reader_content( array(
|
||||||
|
'heading_pagination' => $tax->labels->items_list_navigation,
|
||||||
|
'heading_list' => $tax->labels->items_list,
|
||||||
|
) );
|
||||||
|
|
||||||
|
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||||
|
include( ABSPATH . 'wp-admin/edit-tag-form.php' );
|
||||||
|
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
|
@ -926,9 +926,8 @@ function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'action' => 'edit',
|
|
||||||
'taxonomy' => $taxonomy,
|
'taxonomy' => $taxonomy,
|
||||||
'tag_ID' => $term->term_id,
|
'term_id' => $term->term_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $object_type ) {
|
if ( $object_type ) {
|
||||||
|
@ -938,7 +937,7 @@ function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $tax->show_ui ) {
|
if ( $tax->show_ui ) {
|
||||||
$location = add_query_arg( $args, admin_url( 'edit-tags.php' ) );
|
$location = add_query_arg( $args, admin_url( 'term.php' ) );
|
||||||
} else {
|
} else {
|
||||||
$location = '';
|
$location = '';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue