Making WordPress.org


Ignore:
Timestamp:
09/02/2020 04:13:40 AM (4 years ago)
Author:
dd32
Message:

Plugin Directory: Block Validator: Avoid a PHP Warning when a plugin belongs to no sections.

get_the_terms() returns false when a post has no terms, an array of terms, or a WP_Error on failure (which we're ignoring here).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-block-validator.php

    r10225 r10229  
    122122        if ( $post && wp_verify_nonce( $_POST['block-directory-nonce'], 'block-directory-edit-' . $post->ID ) ) {
    123123            if ( current_user_can( 'edit_post', $post->ID ) || current_user_can( 'plugin_admin_edit', $post->ID ) ) {
    124                 $terms = wp_list_pluck( get_the_terms( $post->ID, 'plugin_section' ), 'slug' );
     124                $terms = wp_list_pluck( get_the_terms( $post->ID, 'plugin_section' ) ?: [], 'slug' );
    125125                if ( 'add' === $_POST['block-directory-edit'] ) {
    126126                    $terms[] = 'block';
Note: See TracChangeset for help on using the changeset viewer.