create_initial_taxonomies() – Creates the initial taxonomies.

You appear to be a bot. Output may be restricted

Description

Creates the initial taxonomies.

This function fires twice: in wp-settings.php before plugins are loaded (for backward compatibility reasons), and again on the initinit action. We must avoid registering rewrite rules before the initinit action.

Usage

create_initial_taxonomies();

Parameters

Returns

void

Source

File name: wordpress/wp-includes/taxonomy.php


Lines:

1 to 100 of 203
function create_initial_taxonomies() {
  global $wp_rewrite;

  WP_Taxonomy::reset_default_labels();

  if ( ! did_action( 'init' ) ) {
    $rewrite = array(
      'category'    => false,
      'post_tag'    => false,
      'post_format' => false,
    );
  } else {

    
/**
 * Filters the post formats rewrite base.
 *
 * @since 3.1.0
 *
 * @param string $context Context of the rewrite base. Default 'type'.
 */
    $post_format_base = apply_filters( 'post_format_rewrite_base', 'type' );
    $rewrite          = array(
      'category'    => array(
        'hierarchical' => true,
        'slug'         => get_option( 'category_base' ) ? get_option( 'category_base' ) : 'category',
        'with_front'   => ! get_option( 'category_base' ) || $wp_rewrite->using_index_permalinks(),
        'ep_mask'      => EP_CATEGORIES,
      ),
      'post_tag'    => array(
        'hierarchical' => false,
        'slug'         => get_option( 'tag_base' ) ? get_option( 'tag_base' ) : 'tag',
        'with_front'   => ! get_option( 'tag_base' ) || $wp_rewrite->using_index_permalinks(),
        'ep_mask'      => EP_TAGS,
      ),
      'post_format' => $post_format_base ? array( 'slug' => $post_format_base ) : false,
    );
  }

  register_taxonomy(
    'category',
    'post',
    array(
      'hierarchical'          => true,
      'query_var'             => 'category_name',
      'rewrite'               => $rewrite['category'],
      'public'                => true,
      'show_ui'               => true,
      'show_admin_column'     => true,
      '_builtin'              => true,
      'capabilities'          => array(
        'manage_terms' => 'manage_categories',
        'edit_terms'   => 'edit_categories',
        'delete_terms' => 'delete_categories',
        'assign_terms' => 'assign_categories',
      ),
      'show_in_rest'          => true,
      'rest_base'             => 'categories',
      'rest_controller_class' => 'WP_REST_Terms_Controller',
    )
  );

  register_taxonomy(
    'post_tag',
    'post',
    array(
      'hierarchical'          => false,
      'query_var'             => 'tag',
      'rewrite'               => $rewrite['post_tag'],
      'public'                => true,
      'show_ui'               => true,
      'show_admin_column'     => true,
      '_builtin'              => true,
      'capabilities'          => array(
        'manage_terms' => 'manage_post_tags',
        'edit_terms'   => 'edit_post_tags',
        'delete_terms' => 'delete_post_tags',
        'assign_terms' => 'assign_post_tags',
      ),
      'show_in_rest'          => true,
      'rest_base'             => 'tags',
      'rest_controller_class' => 'WP_REST_Terms_Controller',
    )
  );

  register_taxonomy(
    'nav_menu',
    'nav_menu_item',
    array(
      'public'                => false,
      'hierarchical'          => false,
      'labels'                => array(
        'name'          => __( 'Navigation Menus' ),
        'singular_name' => __( 'Navigation Menu' ),
      ),
      'query_var'             => false,
      'rewrite'               => false,
      'show_ui'               => false,
      '_builtin'              => true,
      'show_in_nav_menus'     => false,

 View on GitHub View on Trac