wp-admin/edit-tags.php


Lines:

1 to 100 of 709
<?php

/**
 * Edit Tags Administration Screen.
 *
 * @package WordPress
 * @subpackage Administration
 */


/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';

if ( ! $taxnow ) {
  wp_die( __( 'Invalid taxonomy.' ) );
}

$tax = get_taxonomy( $taxnow );

if ( ! $tax ) {
  wp_die( __( 'Invalid taxonomy.' ) );
}

if ( ! in_array( $tax->name, get_taxonomies( array( 'show_ui' => true ) ), true ) ) {
  wp_die( __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) );
}

if ( ! current_user_can( $tax->cap->manage_terms ) ) {
  wp_die(
    '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
    '<p>' . __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ) . '</p>',
    403
  );
}


/**
 * $post_type is set when the WP_Terms_List_Table instance is created
 *
 * @global string $post_type
 */
global $post_type;

$wp_list_table = _get_list_table( 'WP_Terms_List_Table' );
$pagenum       = $wp_list_table->get_pagenum();

$title = $tax->labels->name;

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' === $tax->name ) {
  $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";
}

add_screen_option(
  'per_page',
  array(
    'default' => 20,
    'option'  => 'edit_' . $tax->name . '_per_page',
  )
);

get_current_screen()->set_screen_reader_content(
  array(
    'heading_pagination' => $tax->labels->items_list_navigation,
    'heading_list'       => $tax->labels->items_list,
  )
);

$location = false;
$referer  = wp_get_referer();
if ( ! $referer ) { // For POST requests.
  $referer = wp_unslash( $_SERVER['REQUEST_URI'] );
}
$referer = remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'error', 'message', 'paged' ), $referer );
switch ( $wp_list_table->current_action() ) {

  case 'add-tag':
    check_admin_referer( 'add-tag', '_wpnonce_add-tag' );

    if ( ! current_user_can( $tax->cap->edit_terms ) ) {
      wp_die(
        '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
        '<p>' . __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) . '</p>',
        403
      );
    }

    $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
    if ( $ret && ! is_wp_error( $ret ) ) {
      $location = add_query_arg( 'message', 1, $referer );
    } else {
      $location = add_query_arg(
        array(
          'error'   => true,

 View on GitHub View on Trac

Called by

    Invoked by

      Calls

      API Letters: ,,,,