term.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. if ( 'post' !== get_current_screen()->post_type ) {
  17. $sendback = add_query_arg( 'post_type', get_current_screen()->post_type, $sendback );
  18. }
  19. wp_redirect( esc_url_raw( $sendback ) );
  20. exit;
  21. }
  22. $tag_ID = absint( $_REQUEST['tag_ID'] );
  23. $tag = get_term( $tag_ID, $taxnow, OBJECT, 'edit' );
  24. if ( ! $tag instanceof WP_Term ) {
  25. wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
  26. }
  27. $tax = get_taxonomy( $tag->taxonomy );
  28. $taxonomy = $tax->name;
  29. $title = $tax->labels->edit_item;
  30. if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ) ) ||
  31. ! current_user_can( 'edit_term', $tag->term_id ) ) {
  32. wp_die(
  33. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  34. '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
  35. 403
  36. );
  37. }
  38. $post_type = get_current_screen()->post_type;
  39. // Default to the first object_type associated with the taxonomy if no post type was passed.
  40. if ( empty( $post_type ) ) {
  41. $post_type = reset( $tax->object_type );
  42. }
  43. if ( 'post' != $post_type ) {
  44. $parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
  45. $submenu_file = "edit-tags.php?taxonomy=$taxonomy&amp;post_type=$post_type";
  46. } elseif ( 'link_category' == $taxonomy ) {
  47. $parent_file = 'link-manager.php';
  48. $submenu_file = 'edit-tags.php?taxonomy=link_category';
  49. } else {
  50. $parent_file = 'edit.php';
  51. $submenu_file = "edit-tags.php?taxonomy=$taxonomy";
  52. }
  53. get_current_screen()->set_screen_reader_content(
  54. array(
  55. 'heading_pagination' => $tax->labels->items_list_navigation,
  56. 'heading_list' => $tax->labels->items_list,
  57. )
  58. );
  59. wp_enqueue_script( 'admin-tags' );
  60. require_once( ABSPATH . 'wp-admin/admin-header.php' );
  61. include( ABSPATH . 'wp-admin/edit-tag-form.php' );
  62. include( ABSPATH . 'wp-admin/admin-footer.php' );