Make WordPress Core

Changeset 32954


Ignore:
Timestamp:
06/26/2015 02:12:27 PM (9 years ago)
Author:
boonebgorges
Message:

Improve error checking in get_edit_term_link().

The function should not throw notices when an improper term or taxonomy is
passed.

Props tmatsuur, MikeHansenMe.
Fixes #32786.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r32926 r32954  
    904904 * @param string $object_type The object type. Used to highlight the proper post type menu on the linked page.
    905905 *                            Defaults to the first object_type associated with the taxonomy.
    906  * @return string The edit term link URL for the given term.
     906 * @return string|null The edit term link URL for the given term, or null on failure.
    907907 */
    908908function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) {
    909909    $tax = get_taxonomy( $taxonomy );
    910     if ( !current_user_can( $tax->cap->edit_terms ) )
     910    if ( ! $tax || ! current_user_can( $tax->cap->edit_terms ) ) {
    911911        return;
     912    }
    912913
    913914    $term = get_term( $term_id, $taxonomy );
     915    if ( ! $term || is_wp_error( $term ) ) {
     916        return;
     917    }
    914918
    915919    $args = array(
Note: See TracChangeset for help on using the changeset viewer.