WordPress.org

Make WordPress Core

Ticket #22559: 22559.2.diff

File 22559.2.diff, 1.2 KB (added by nacin, 5 years ago)

Refreshed to fix/improve docs.

  • wp-admin/includes/media.php

     
    387387                'post' => get_post()
    388388        ) );
    389389
    390         // $context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
    391 
    392390        $img = '<span class="wp-media-buttons-icon"></span> ';
    393391
    394392        echo '<a href="#" class="button insert-media add_media" data-editor="' . esc_attr( $editor_id ) . '" title="' . esc_attr__( 'Add Media' ) . '">' . $img . __( 'Add Media' ) . '</a>';
    395393
    396         // echo '<a href="' . esc_url( get_upload_iframe_src() ) . '" class="thickbox add_media" id="' . esc_attr( $editor_id ) . '-add_media" title="' . esc_attr__( 'Add Media' ) . '" onclick="return false;">' . sprintf( $context, $img ) . '</a>';
     394        // Don't use this filter. Want to add a button? Use the media_buttons action.
     395        $legacy_filter = apply_filters('media_buttons_context', ''); // deprecated
     396
     397        if ( $legacy_filter ) {
     398                // #WP22559. Close <a> if a plugin started by closing <a> to open their own <a> tag.
     399                if ( 0 === stripos( trim( $legacy_filter ), '</a>' ) )
     400                        $legacy_filter .= '</a>';
     401                echo $legacy_filter;
     402        }
    397403}
    398404add_action( 'media_buttons', 'media_buttons' );
    399405