Make WordPress Core

Changeset 31218


Ignore:
Timestamp:
01/16/2015 09:36:12 PM (10 years ago)
Author:
boonebgorges
Message:

In get_edit_term_link(), default to a valid $object_type.

The $object_type param is used to set the 'post_type' query var, which
determines the post type menu that will be expanded when clicking through to
the term edit page. Not all taxonomies are associated with Posts, so it makes
sense to default to a post_type that the taxonomy is actually associated with.

Props DzeryCZ, juliobox.
Fixes #29251.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r31154 r31218  
    889889 * @since 3.1.0
    890890 *
    891  * @param int $term_id Term ID
    892  * @param string $taxonomy Taxonomy
    893  * @param string $object_type The object type
     891 * @param int    $term_id     Term ID.
     892 * @param string $taxonomy    Taxonomy.
     893 * @param string $object_type The object type. Used to highlight the proper post type menu on the linked page.
     894 *                            Defaults to the first object_type associated with the taxonomy.
    894895 * @return string The edit term link URL for the given term.
    895896 */
     
    907908    );
    908909
    909     if ( $object_type )
     910    if ( $object_type ) {
    910911        $args['post_type'] = $object_type;
     912    } else if ( ! empty( $tax->object_type ) ) {
     913        $args['post_type'] = reset( $tax->object_type );
     914    }
    911915
    912916    $location = add_query_arg( $args, admin_url( 'edit-tags.php' ) );
Note: See TracChangeset for help on using the changeset viewer.