term.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Edit Term Administration Screen.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. * @since 4.5.0
  8. */
  9. /** WordPress Administration Bootstrap */
  10. require_once( dirname( __FILE__ ) . '/admin.php' );
  11. if ( empty( $_REQUEST['tag_ID'] ) ) {
  12. $sendback = admin_url( 'edit-tags.php' );
  13. if ( ! empty( $taxnow ) ) {
  14. $sendback = add_query_arg( array( 'taxonomy' => $taxnow ), $sendback );
  15. }
  16. wp_redirect( esc_url( $sendback ) );
  17. exit;
  18. }
  19. $tag_ID = absint( $_REQUEST['tag_ID'] );
  20. $tag = get_term( $tag_ID, $taxnow, OBJECT, 'edit' );
  21. if ( ! $tag instanceof WP_Term ) {
  22. wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
  23. }
  24. $tax = get_taxonomy( $tag->taxonomy );
  25. $taxonomy = $tax->name;
  26. $title = $tax->labels->edit_item;
  27. if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ) ) ||
  28. ! current_user_can( 'edit_term', $tag->term_id )
  29. ) {
  30. wp_die(
  31. '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
  32. '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
  33. 403
  34. );
  35. }
  36. $post_type = get_current_screen()->post_type;
  37. // Default to the first object_type associated with the taxonomy if no post type was passed.
  38. if ( empty( $post_type ) ) {
  39. $post_type = reset( $tax->object_type );
  40. }
  41. if ( 'post' != $post_type ) {
  42. $parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
  43. $submenu_file = "edit-tags.php?taxonomy=$taxonomy&amp;post_type=$post_type";
  44. } elseif ( 'link_category' == $taxonomy ) {
  45. $parent_file = 'link-manager.php';
  46. $submenu_file = 'edit-tags.php?taxonomy=link_category';
  47. } else {
  48. $parent_file = 'edit.php';
  49. $submenu_file = "edit-tags.php?taxonomy=$taxonomy";
  50. }
  51. get_current_screen()->set_screen_reader_content( array(
  52. 'heading_pagination' => $tax->labels->items_list_navigation,
  53. 'heading_list' => $tax->labels->items_list,
  54. ) );
  55. require_once( ABSPATH . 'wp-admin/admin-header.php' );
  56. include( ABSPATH . 'wp-admin/edit-tag-form.php' );
  57. include( ABSPATH . 'wp-admin/admin-footer.php' );