edit-tags.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <?php
  2. /**
  3. * Edit Tags Administration Screen.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** WordPress Administration Bootstrap */
  9. require_once( dirname( __FILE__ ) . '/admin.php' );
  10. if ( ! $taxnow ) {
  11. wp_die( __( 'Invalid taxonomy.' ) );
  12. }
  13. $tax = get_taxonomy( $taxnow );
  14. if ( ! $tax ) {
  15. wp_die( __( 'Invalid taxonomy.' ) );
  16. }
  17. if ( ! in_array( $tax->name, get_taxonomies( array( 'show_ui' => true ) ) ) ) {
  18. wp_die( __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) );
  19. }
  20. if ( ! current_user_can( $tax->cap->manage_terms ) ) {
  21. wp_die(
  22. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  23. '<p>' . __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ) . '</p>',
  24. 403
  25. );
  26. }
  27. /**
  28. * $post_type is set when the WP_Terms_List_Table instance is created
  29. *
  30. * @global string $post_type
  31. */
  32. global $post_type;
  33. $wp_list_table = _get_list_table( 'WP_Terms_List_Table' );
  34. $pagenum = $wp_list_table->get_pagenum();
  35. $title = $tax->labels->name;
  36. if ( 'post' != $post_type ) {
  37. $parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
  38. $submenu_file = "edit-tags.php?taxonomy=$taxonomy&amp;post_type=$post_type";
  39. } elseif ( 'link_category' == $tax->name ) {
  40. $parent_file = 'link-manager.php';
  41. $submenu_file = 'edit-tags.php?taxonomy=link_category';
  42. } else {
  43. $parent_file = 'edit.php';
  44. $submenu_file = "edit-tags.php?taxonomy=$taxonomy";
  45. }
  46. add_screen_option(
  47. 'per_page',
  48. array(
  49. 'default' => 20,
  50. 'option' => 'edit_' . $tax->name . '_per_page',
  51. )
  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. $location = false;
  60. $referer = wp_get_referer();
  61. if ( ! $referer ) { // For POST requests.
  62. $referer = wp_unslash( $_SERVER['REQUEST_URI'] );
  63. }
  64. $referer = remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'error', 'message', 'paged' ), $referer );
  65. switch ( $wp_list_table->current_action() ) {
  66. case 'add-tag':
  67. check_admin_referer( 'add-tag', '_wpnonce_add-tag' );
  68. if ( ! current_user_can( $tax->cap->edit_terms ) ) {
  69. wp_die(
  70. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  71. '<p>' . __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) . '</p>',
  72. 403
  73. );
  74. }
  75. $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
  76. if ( $ret && ! is_wp_error( $ret ) ) {
  77. $location = add_query_arg( 'message', 1, $referer );
  78. } else {
  79. $location = add_query_arg(
  80. array(
  81. 'error' => true,
  82. 'message' => 4,
  83. ),
  84. $referer
  85. );
  86. }
  87. break;
  88. case 'delete':
  89. if ( ! isset( $_REQUEST['tag_ID'] ) ) {
  90. break;
  91. }
  92. $tag_ID = (int) $_REQUEST['tag_ID'];
  93. check_admin_referer( 'delete-tag_' . $tag_ID );
  94. if ( ! current_user_can( 'delete_term', $tag_ID ) ) {
  95. wp_die(
  96. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  97. '<p>' . __( 'Sorry, you are not allowed to delete this item.' ) . '</p>',
  98. 403
  99. );
  100. }
  101. wp_delete_term( $tag_ID, $taxonomy );
  102. $location = add_query_arg( 'message', 2, $referer );
  103. // When deleting a term, prevent the action from redirecting back to a term that no longer exists.
  104. $location = remove_query_arg( array( 'tag_ID', 'action' ), $location );
  105. break;
  106. case 'bulk-delete':
  107. check_admin_referer( 'bulk-tags' );
  108. if ( ! current_user_can( $tax->cap->delete_terms ) ) {
  109. wp_die(
  110. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  111. '<p>' . __( 'Sorry, you are not allowed to delete these items.' ) . '</p>',
  112. 403
  113. );
  114. }
  115. $tags = (array) $_REQUEST['delete_tags'];
  116. foreach ( $tags as $tag_ID ) {
  117. wp_delete_term( $tag_ID, $taxonomy );
  118. }
  119. $location = add_query_arg( 'message', 6, $referer );
  120. break;
  121. case 'edit':
  122. if ( ! isset( $_REQUEST['tag_ID'] ) ) {
  123. break;
  124. }
  125. $term_id = (int) $_REQUEST['tag_ID'];
  126. $term = get_term( $term_id );
  127. if ( ! $term instanceof WP_Term ) {
  128. wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
  129. }
  130. wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) );
  131. exit;
  132. case 'editedtag':
  133. $tag_ID = (int) $_POST['tag_ID'];
  134. check_admin_referer( 'update-tag_' . $tag_ID );
  135. if ( ! current_user_can( 'edit_term', $tag_ID ) ) {
  136. wp_die(
  137. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  138. '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
  139. 403
  140. );
  141. }
  142. $tag = get_term( $tag_ID, $taxonomy );
  143. if ( ! $tag ) {
  144. wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
  145. }
  146. $ret = wp_update_term( $tag_ID, $taxonomy, $_POST );
  147. if ( $ret && ! is_wp_error( $ret ) ) {
  148. $location = add_query_arg( 'message', 3, $referer );
  149. } else {
  150. $location = add_query_arg(
  151. array(
  152. 'error' => true,
  153. 'message' => 5,
  154. ),
  155. $referer
  156. );
  157. }
  158. break;
  159. default:
  160. if ( ! $wp_list_table->current_action() || ! isset( $_REQUEST['delete_tags'] ) ) {
  161. break;
  162. }
  163. check_admin_referer( 'bulk-tags' );
  164. $tags = (array) $_REQUEST['delete_tags'];
  165. /** This action is documented in wp-admin/edit-comments.php */
  166. $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $wp_list_table->current_action(), $tags ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  167. break;
  168. }
  169. if ( ! $location && ! empty( $_REQUEST['_wp_http_referer'] ) ) {
  170. $location = remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) );
  171. }
  172. if ( $location ) {
  173. if ( $pagenum > 1 ) {
  174. $location = add_query_arg( 'paged', $pagenum, $location ); // $pagenum takes care of $total_pages.
  175. }
  176. /**
  177. * Filters the taxonomy redirect destination URL.
  178. *
  179. * @since 4.6.0
  180. *
  181. * @param string $location The destination URL.
  182. * @param object $tax The taxonomy object.
  183. */
  184. wp_redirect( apply_filters( 'redirect_term_location', $location, $tax ) );
  185. exit;
  186. }
  187. $wp_list_table->prepare_items();
  188. $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
  189. if ( $pagenum > $total_pages && $total_pages > 0 ) {
  190. wp_redirect( add_query_arg( 'paged', $total_pages ) );
  191. exit;
  192. }
  193. wp_enqueue_script( 'admin-tags' );
  194. if ( current_user_can( $tax->cap->edit_terms ) ) {
  195. wp_enqueue_script( 'inline-edit-tax' );
  196. }
  197. if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $taxonomy ) {
  198. $help = '';
  199. if ( 'category' == $taxonomy ) {
  200. $help = '<p>' . sprintf(
  201. /* translators: %s: URL to Writing Settings screen. */
  202. __( 'You can use categories to define sections of your site and group related posts. The default category is &#8220;Uncategorized&#8221; until you change it in your <a href="%s">writing settings</a>.' ),
  203. 'options-writing.php'
  204. ) . '</p>';
  205. } elseif ( 'link_category' == $taxonomy ) {
  206. $help = '<p>' . __( 'You can create groups of links by using Link Categories. Link Category names must be unique and Link Categories are separate from the categories you use for posts.' ) . '</p>';
  207. } else {
  208. $help = '<p>' . __( 'You can assign keywords to your posts using <strong>tags</strong>. Unlike categories, tags have no hierarchy, meaning there&#8217;s no relationship from one tag to another.' ) . '</p>';
  209. }
  210. if ( 'link_category' == $taxonomy ) {
  211. $help .= '<p>' . __( 'You can delete Link Categories in the Bulk Action pull-down, but that action does not delete the links within the category. Instead, it moves them to the default Link Category.' ) . '</p>';
  212. } else {
  213. $help .= '<p>' . __( 'What&#8217;s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '</p>';
  214. }
  215. get_current_screen()->add_help_tab(
  216. array(
  217. 'id' => 'overview',
  218. 'title' => __( 'Overview' ),
  219. 'content' => $help,
  220. )
  221. );
  222. if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) {
  223. if ( 'category' == $taxonomy ) {
  224. $help = '<p>' . __( 'When adding a new category on this screen, you&#8217;ll fill in the following fields:' ) . '</p>';
  225. } else {
  226. $help = '<p>' . __( 'When adding a new tag on this screen, you&#8217;ll fill in the following fields:' ) . '</p>';
  227. }
  228. $help .= '<ul>' .
  229. '<li>' . __( '<strong>Name</strong> &mdash; The name is how it appears on your site.' ) . '</li>';
  230. if ( ! global_terms_enabled() ) {
  231. $help .= '<li>' . __( '<strong>Slug</strong> &mdash; The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>';
  232. }
  233. if ( 'category' == $taxonomy ) {
  234. $help .= '<li>' . __( '<strong>Parent</strong> &mdash; Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have child categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '</li>';
  235. }
  236. $help .= '<li>' . __( '<strong>Description</strong> &mdash; The description is not prominent by default; however, some themes may display it.' ) . '</li>' .
  237. '</ul>' .
  238. '<p>' . __( 'You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.' ) . '</p>';
  239. get_current_screen()->add_help_tab(
  240. array(
  241. 'id' => 'adding-terms',
  242. 'title' => 'category' == $taxonomy ? __( 'Adding Categories' ) : __( 'Adding Tags' ),
  243. 'content' => $help,
  244. )
  245. );
  246. }
  247. $help = '<p><strong>' . __( 'For more information:' ) . '</strong></p>';
  248. if ( 'category' == $taxonomy ) {
  249. $help .= '<p>' . __( '<a href="https://wordpress.org/support/article/posts-categories-screen/">Documentation on Categories</a>' ) . '</p>';
  250. } elseif ( 'link_category' == $taxonomy ) {
  251. $help .= '<p>' . __( '<a href="https://codex.wordpress.org/Links_Link_Categories_Screen">Documentation on Link Categories</a>' ) . '</p>';
  252. } else {
  253. $help .= '<p>' . __( '<a href="https://wordpress.org/support/article/posts-tags-screen/">Documentation on Tags</a>' ) . '</p>';
  254. }
  255. $help .= '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>';
  256. get_current_screen()->set_help_sidebar( $help );
  257. unset( $help );
  258. }
  259. require_once( ABSPATH . 'wp-admin/admin-header.php' );
  260. /** Also used by the Edit Tag form */
  261. require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
  262. $class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated';
  263. if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) {
  264. $import_link = admin_url( 'admin.php?import=wpcat2tag' );
  265. } else {
  266. $import_link = admin_url( 'import.php' );
  267. }
  268. ?>
  269. <div class="wrap nosubsub">
  270. <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
  271. <?php
  272. if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
  273. /* translators: %s: Search query. */
  274. printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) );
  275. }
  276. ?>
  277. <hr class="wp-header-end">
  278. <?php if ( $message ) : ?>
  279. <div id="message" class="<?php echo $class; ?> notice is-dismissible"><p><?php echo $message; ?></p></div>
  280. <?php
  281. $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] );
  282. endif;
  283. ?>
  284. <div id="ajax-response"></div>
  285. <form class="search-form wp-clearfix" method="get">
  286. <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" />
  287. <input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
  288. <?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>
  289. </form>
  290. <?php
  291. $can_edit_terms = current_user_can( $tax->cap->edit_terms );
  292. if ( $can_edit_terms ) {
  293. ?>
  294. <div id="col-container" class="wp-clearfix">
  295. <div id="col-left">
  296. <div class="col-wrap">
  297. <?php
  298. if ( 'category' == $taxonomy ) {
  299. /**
  300. * Fires before the Add Category form.
  301. *
  302. * @since 2.1.0
  303. * @deprecated 3.0.0 Use {$taxonomy}_pre_add_form instead.
  304. *
  305. * @param object $arg Optional arguments cast to an object.
  306. */
  307. do_action( 'add_category_form_pre', (object) array( 'parent' => 0 ) );
  308. } elseif ( 'link_category' == $taxonomy ) {
  309. /**
  310. * Fires before the link category form.
  311. *
  312. * @since 2.3.0
  313. * @deprecated 3.0.0 Use {$taxonomy}_pre_add_form instead.
  314. *
  315. * @param object $arg Optional arguments cast to an object.
  316. */
  317. do_action( 'add_link_category_form_pre', (object) array( 'parent' => 0 ) );
  318. } else {
  319. /**
  320. * Fires before the Add Tag form.
  321. *
  322. * @since 2.5.0
  323. * @deprecated 3.0.0 Use {$taxonomy}_pre_add_form instead.
  324. *
  325. * @param string $taxonomy The taxonomy slug.
  326. */
  327. do_action( 'add_tag_form_pre', $taxonomy );
  328. }
  329. /**
  330. * Fires before the Add Term form for all taxonomies.
  331. *
  332. * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
  333. *
  334. * @since 3.0.0
  335. *
  336. * @param string $taxonomy The taxonomy slug.
  337. */
  338. do_action( "{$taxonomy}_pre_add_form", $taxonomy );
  339. ?>
  340. <div class="form-wrap">
  341. <h2><?php echo $tax->labels->add_new_item; ?></h2>
  342. <form id="addtag" method="post" action="edit-tags.php" class="validate"
  343. <?php
  344. /**
  345. * Fires inside the Add Tag form tag.
  346. *
  347. * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
  348. *
  349. * @since 3.7.0
  350. */
  351. do_action( "{$taxonomy}_term_new_form_tag" );
  352. ?>
  353. >
  354. <input type="hidden" name="action" value="add-tag" />
  355. <input type="hidden" name="screen" value="<?php echo esc_attr( $current_screen->id ); ?>" />
  356. <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" />
  357. <input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
  358. <?php wp_nonce_field( 'add-tag', '_wpnonce_add-tag' ); ?>
  359. <div class="form-field form-required term-name-wrap">
  360. <label for="tag-name"><?php _ex( 'Name', 'term name' ); ?></label>
  361. <input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
  362. <p><?php _e( 'The name is how it appears on your site.' ); ?></p>
  363. </div>
  364. <?php if ( ! global_terms_enabled() ) : ?>
  365. <div class="form-field term-slug-wrap">
  366. <label for="tag-slug"><?php _e( 'Slug' ); ?></label>
  367. <input name="slug" id="tag-slug" type="text" value="" size="40" />
  368. <p><?php _e( 'The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ); ?></p>
  369. </div>
  370. <?php endif; // global_terms_enabled() ?>
  371. <?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
  372. <div class="form-field term-parent-wrap">
  373. <label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label>
  374. <?php
  375. $dropdown_args = array(
  376. 'hide_empty' => 0,
  377. 'hide_if_empty' => false,
  378. 'taxonomy' => $taxonomy,
  379. 'name' => 'parent',
  380. 'orderby' => 'name',
  381. 'hierarchical' => true,
  382. 'show_option_none' => __( 'None' ),
  383. );
  384. /**
  385. * Filters the taxonomy parent drop-down on the Edit Term page.
  386. *
  387. * @since 3.7.0
  388. * @since 4.2.0 Added `$context` parameter.
  389. *
  390. * @param array $dropdown_args {
  391. * An array of taxonomy parent drop-down arguments.
  392. *
  393. * @type int|bool $hide_empty Whether to hide terms not attached to any posts. Default 0|false.
  394. * @type bool $hide_if_empty Whether to hide the drop-down if no terms exist. Default false.
  395. * @type string $taxonomy The taxonomy slug.
  396. * @type string $name Value of the name attribute to use for the drop-down select element.
  397. * Default 'parent'.
  398. * @type string $orderby The field to order by. Default 'name'.
  399. * @type bool $hierarchical Whether the taxonomy is hierarchical. Default true.
  400. * @type string $show_option_none Label to display if there are no terms. Default 'None'.
  401. * }
  402. * @param string $taxonomy The taxonomy slug.
  403. * @param string $context Filter context. Accepts 'new' or 'edit'.
  404. */
  405. $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'new' );
  406. wp_dropdown_categories( $dropdown_args );
  407. ?>
  408. <?php if ( 'category' == $taxonomy ) : ?>
  409. <p><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
  410. <?php else : ?>
  411. <p><?php _e( 'Assign a parent term to create a hierarchy. The term Jazz, for example, would be the parent of Bebop and Big Band.' ); ?></p>
  412. <?php endif; ?>
  413. </div>
  414. <?php endif; // is_taxonomy_hierarchical() ?>
  415. <div class="form-field term-description-wrap">
  416. <label for="tag-description"><?php _e( 'Description' ); ?></label>
  417. <textarea name="description" id="tag-description" rows="5" cols="40"></textarea>
  418. <p><?php _e( 'The description is not prominent by default; however, some themes may show it.' ); ?></p>
  419. </div>
  420. <?php
  421. if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
  422. /**
  423. * Fires after the Add Tag form fields for non-hierarchical taxonomies.
  424. *
  425. * @since 3.0.0
  426. *
  427. * @param string $taxonomy The taxonomy slug.
  428. */
  429. do_action( 'add_tag_form_fields', $taxonomy );
  430. }
  431. /**
  432. * Fires after the Add Term form fields.
  433. *
  434. * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
  435. *
  436. * @since 3.0.0
  437. *
  438. * @param string $taxonomy The taxonomy slug.
  439. */
  440. do_action( "{$taxonomy}_add_form_fields", $taxonomy );
  441. ?>
  442. <p class="submit">
  443. <?php submit_button( $tax->labels->add_new_item, 'primary', 'submit', false ); ?>
  444. <span class="spinner"></span>
  445. </p>
  446. <?php
  447. if ( 'category' == $taxonomy ) {
  448. /**
  449. * Fires at the end of the Edit Category form.
  450. *
  451. * @since 2.1.0
  452. * @deprecated 3.0.0 Use {$taxonomy}_add_form instead.
  453. *
  454. * @param object $arg Optional arguments cast to an object.
  455. */
  456. do_action( 'edit_category_form', (object) array( 'parent' => 0 ) );
  457. } elseif ( 'link_category' == $taxonomy ) {
  458. /**
  459. * Fires at the end of the Edit Link form.
  460. *
  461. * @since 2.3.0
  462. * @deprecated 3.0.0 Use {$taxonomy}_add_form instead.
  463. *
  464. * @param object $arg Optional arguments cast to an object.
  465. */
  466. do_action( 'edit_link_category_form', (object) array( 'parent' => 0 ) );
  467. } else {
  468. /**
  469. * Fires at the end of the Add Tag form.
  470. *
  471. * @since 2.7.0
  472. * @deprecated 3.0.0 Use {$taxonomy}_add_form instead.
  473. *
  474. * @param string $taxonomy The taxonomy slug.
  475. */
  476. do_action( 'add_tag_form', $taxonomy );
  477. }
  478. /**
  479. * Fires at the end of the Add Term form for all taxonomies.
  480. *
  481. * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
  482. *
  483. * @since 3.0.0
  484. *
  485. * @param string $taxonomy The taxonomy slug.
  486. */
  487. do_action( "{$taxonomy}_add_form", $taxonomy );
  488. ?>
  489. </form></div>
  490. </div>
  491. </div><!-- /col-left -->
  492. <div id="col-right">
  493. <div class="col-wrap">
  494. <?php } ?>
  495. <?php $wp_list_table->views(); ?>
  496. <form id="posts-filter" method="post">
  497. <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" />
  498. <input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
  499. <?php $wp_list_table->display(); ?>
  500. </form>
  501. <?php if ( 'category' == $taxonomy ) : ?>
  502. <div class="form-wrap edit-term-notes">
  503. <p>
  504. <?php
  505. printf(
  506. /* translators: %s: Default category. */
  507. __( '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 default category %s. The default category cannot be deleted.' ),
  508. /** This filter is documented in wp-includes/category-template.php */
  509. '<strong>' . apply_filters( 'the_category', get_cat_name( get_option( 'default_category' ) ), '', '' ) . '</strong>'
  510. );
  511. ?>
  512. </p>
  513. <?php if ( current_user_can( 'import' ) ) : ?>
  514. <p>
  515. <?php
  516. printf(
  517. /* translators: %s: URL to Categories to Tags Converter tool. */
  518. __( 'Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.' ),
  519. esc_url( $import_link )
  520. );
  521. ?>
  522. </p>
  523. <?php endif; ?>
  524. </div>
  525. <?php elseif ( 'post_tag' == $taxonomy && current_user_can( 'import' ) ) : ?>
  526. <div class="form-wrap edit-term-notes">
  527. <p>
  528. <?php
  529. printf(
  530. /* translators: %s: URL to Categories to Tags Converter tool. */
  531. __( 'Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>.' ),
  532. esc_url( $import_link )
  533. );
  534. ?>
  535. </p>
  536. </div>
  537. <?php
  538. endif;
  539. /**
  540. * Fires after the taxonomy list table.
  541. *
  542. * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
  543. *
  544. * @since 3.0.0
  545. *
  546. * @param string $taxonomy The taxonomy name.
  547. */
  548. do_action( "after-{$taxonomy}-table", $taxonomy ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  549. if ( $can_edit_terms ) {
  550. ?>
  551. </div>
  552. </div><!-- /col-right -->
  553. </div><!-- /col-container -->
  554. <?php } ?>
  555. </div><!-- /wrap -->
  556. <?php if ( ! wp_is_mobile() ) : ?>
  557. <script type="text/javascript">
  558. try{document.forms.addtag['tag-name'].focus();}catch(e){}
  559. </script>
  560. <?php
  561. endif;
  562. $wp_list_table->inline_edit();
  563. include( ABSPATH . 'wp-admin/admin-footer.php' );