From 1f5e71fd3a3a1d10769df063798ce496799c06c7 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 20 Nov 2012 02:58:33 +0000 Subject: [PATCH] Add media_view_settings and media_view_strings hooks. fixes #21092 for 3.5. see #21390. git-svn-id: https://develop.svn.wordpress.org/trunk@22702 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/media.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index bafb0a4aa6..039354e3c1 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1328,13 +1328,13 @@ function wp_enqueue_media( $args = array() ) { ), admin_url('media-upload.php') ), ); - if ( isset( $args['post'] ) ) - $settings['postId'] = get_post( $args['post'] )->ID; - - wp_localize_script( 'media-views', '_wpMediaViewsL10n', array( - // Settings - 'settings' => $settings, + $post = null; + if ( isset( $args['post'] ) ) { + $post = get_post( $args['post'] ); + $settings['postId'] = $post->ID; + } + $strings = array( // Generic 'url' => __( 'URL' ), 'insertMedia' => __( 'Insert Media' ), @@ -1369,7 +1369,14 @@ function wp_enqueue_media( $args = array() ) { 'updateGallery' => __( 'Update gallery' ), 'continueEditing' => __( 'Continue editing' ), 'addToGallery' => __( 'Add to gallery' ), - ) ); + ); + + $settings = apply_filters( 'media_view_settings', $settings, $post ); + $strings = apply_filters( 'media_view_strings', $strings, $post ); + + $strings['settings'] = $settings; + + wp_localize_script( 'media-views', '_wpMediaViewsL10n', $strings ); wp_enqueue_script( 'media-upload' ); wp_enqueue_style( 'media-views' );