Make sure we're on the media grid page before calling wp.media().

props azaozz.
fixes #29520 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@29725 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2014-09-09 10:13:33 +00:00
parent 00bfc5bc34
commit 9c48d0f495
2 changed files with 9 additions and 5 deletions

View File

@ -72,11 +72,15 @@ var findPosts;
}; };
$( document ).ready( function() { $( document ).ready( function() {
var $mediaGridWrap = $( '#wp-media-grid' );
// Open up a manage media frame into the grid. // Open up a manage media frame into the grid.
wp.media && wp.media({ if ( $mediaGridWrap.length && window.wp && window.wp.media ) {
frame: 'manage', window.wp.media({
container: $('#wpbody-content > .wrap') frame: 'manage',
}).open(); container: $mediaGridWrap
}).open();
}
$( '#find-posts-submit' ).click( function( event ) { $( '#find-posts-submit' ).click( function( event ) {
if ( ! $( '#find-posts-response input[type="radio"]:checked' ).length ) if ( ! $( '#find-posts-response input[type="radio"]:checked' ).length )

View File

@ -57,7 +57,7 @@ if ( 'grid' === $mode ) {
require_once( ABSPATH . 'wp-admin/admin-header.php' ); require_once( ABSPATH . 'wp-admin/admin-header.php' );
?> ?>
<div class="wrap"> <div class="wrap" id="wp-media-grid">
<h2> <h2>
<?php <?php
echo esc_html( $title ); echo esc_html( $title );