WordPress.org

Make WordPress Core

Changeset 35139


Ignore:
Timestamp:
10/13/2015 04:39:47 PM (6 years ago)
Author:
wonderboymusic
Message:

Taxonomy: get_terms_to_edit() can also return false or WP_Error. Vars using it should be set to empty string when errors are returned to avoid producing fatal errors when used in string operations.

Props valendesigns.
Fixes #30472.

Location:
trunk/src/wp-admin/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/meta-boxes.php

    r35129 r35139  
    428428    $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
    429429    $comma = _x( ',', 'tag delimiter' );
     430    $terms_to_edit = get_terms_to_edit( $post->ID, $tax_name );
     431    if ( ! is_string( $terms_to_edit ) ) {
     432        $terms_to_edit = '';
     433    }
    430434?>
    431435<div class="tagsdiv" id="<?php echo $tax_name; ?>">
     
    433437    <div class="nojs-tags hide-if-js">
    434438    <p><?php echo $taxonomy->labels->add_or_remove_items; ?></p>
    435     <textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms ); ?>><?php echo str_replace( ',', $comma . ' ', get_terms_to_edit( $post->ID, $tax_name ) ); // textarea_escaped by esc_attr() ?></textarea></div>
     439    <textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms ); ?>><?php echo str_replace( ',', $comma . ' ', $terms_to_edit ); // textarea_escaped by esc_attr() ?></textarea></div>
    436440    <?php if ( $user_can_assign_terms ) : ?>
    437441    <div class="ajaxtag hide-if-no-js">
  • trunk/src/wp-admin/includes/template-functions.php

    r35128 r35139  
    315315        } elseif ( $taxonomy->show_ui ) {
    316316
     317            $terms_to_edit = get_terms_to_edit( $post->ID, $taxonomy_name );
     318            if ( ! is_string( $terms_to_edit ) ) {
     319                $terms_to_edit = '';
     320            }
     321
    317322            echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
    318                 . esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
     323                . esc_html( str_replace( ',', ', ', $terms_to_edit ) ) . '</div>';
    319324
    320325        }
Note: See TracChangeset for help on using the changeset viewer.