Make WordPress Core


Ignore:
Timestamp:
07/04/2017 07:58:35 PM (7 years ago)
Author:
boonebgorges
Message:

Avoid PHP notices when checking termmeta capabilities against a non-existent term.

Previously, checks like current_user_can( 'edit_term_meta', $term_id )
returned the proper value, but generated a PHP notice due to the fact
that get_term( $term_id ) could, in certain instances, return
WP_Error objects.

Props caercam.
Fixes #40891.

File:
1 edited

Legend:

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

    r40638 r40999  
    281281            case 'term':
    282282                $term = get_term( $object_id );
    283                 if ( ! $term ) {
     283                if ( ! $term instanceof WP_Term ) {
    284284                    break;
    285285                }
Note: See TracChangeset for help on using the changeset viewer.