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 __DIR__ . '/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( sanitize_url( $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 does not 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 ) ), true )
  31. || ! current_user_can( 'edit_term', $tag->term_id )
  32. ) {
  33. wp_die(
  34. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  35. '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
  36. 403
  37. );
  38. }
  39. $post_type = get_current_screen()->post_type;
  40. // Default to the first object_type associated with the taxonomy if no post type was passed.
  41. if ( empty( $post_type ) ) {
  42. $post_type = reset( $tax->object_type );
  43. }
  44. if ( 'post' !== $post_type ) {
  45. $parent_file = ( 'attachment' === $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
  46. $submenu_file = "edit-tags.php?taxonomy=$taxonomy&amp;post_type=$post_type";
  47. } elseif ( 'link_category' === $taxonomy ) {
  48. $parent_file = 'link-manager.php';
  49. $submenu_file = 'edit-tags.php?taxonomy=link_category';
  50. } else {
  51. $parent_file = 'edit.php';
  52. $submenu_file = "edit-tags.php?taxonomy=$taxonomy";
  53. }
  54. get_current_screen()->set_screen_reader_content(
  55. array(
  56. 'heading_pagination' => $tax->labels->items_list_navigation,
  57. 'heading_list' => $tax->labels->items_list,
  58. )
  59. );
  60. wp_enqueue_script( 'admin-tags' );
  61. require_once ABSPATH . 'wp-admin/admin-header.php';
  62. require ABSPATH . 'wp-admin/edit-tag-form.php';
  63. require_once ABSPATH . 'wp-admin/admin-footer.php';