From 6736936a4368637204a9523b9ccd11197dd214d3 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 27 Feb 2014 21:37:36 +0000 Subject: [PATCH] Some playlist cleanup: * Check properties against the `window` object when using `_.isUndefined()` on globals * Fix a typo for `$safe_type` introduced in [27311] See #26631. git-svn-id: https://develop.svn.wordpress.org/trunk@27320 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-editor.js | 8 ++++---- src/wp-includes/js/mediaelement/wp-playlist.js | 7 +++---- src/wp-includes/media.php | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/js/media-editor.js b/src/wp-includes/js/media-editor.js index 36fb899fac..d0ec2b1c91 100644 --- a/src/wp-includes/js/media-editor.js +++ b/src/wp-includes/js/media-editor.js @@ -632,8 +632,8 @@ */ insert: function( html ) { var editor, - hasTinymce = ! _.isUndefined( tinymce ), - hasQuicktags = ! _.isUndefined( QTags ), + hasTinymce = ! _.isUndefined( window.tinymce ), + hasQuicktags = ! _.isUndefined( window.QTags ), wpActiveEditor = window.wpActiveEditor; // Delegate to the global `send_to_editor` if it exists. @@ -798,7 +798,7 @@ id = wpActiveEditor; // If that doesn't work, fall back to `tinymce.activeEditor.id`. - if ( ! id && ! _.isUndefined( tinymce ) && tinymce.activeEditor ) { + if ( ! id && ! _.isUndefined( window.tinymce ) && tinymce.activeEditor ) { id = tinymce.activeEditor.id; } @@ -929,7 +929,7 @@ id = this.id( id ); /* // Save a bookmark of the caret position in IE. - if ( ! _.isUndefined( tinymce ) ) { + if ( ! _.isUndefined( window.tinymce ) ) { editor = tinymce.get( id ); if ( tinymce.isIE && editor && ! editor.isHidden() ) { diff --git a/src/wp-includes/js/mediaelement/wp-playlist.js b/src/wp-includes/js/mediaelement/wp-playlist.js index 9fd7184139..092161a740 100644 --- a/src/wp-includes/js/mediaelement/wp-playlist.js +++ b/src/wp-includes/js/mediaelement/wp-playlist.js @@ -1,4 +1,4 @@ -/*globals window, document, $, jQuery */ +/*globals window, document, jQuery, _, Backbone, _wpmejsSettings */ (function ($, _, Backbone) { "use strict"; @@ -32,7 +32,7 @@ _.bindAll( this, 'bindPlayer', 'ended', 'clickTrack' ); - if ( typeof _wpmejsSettings !== 'undefined' ) { + if ( ! _.isUndefined( window._wpmejsSettings ) ) { settings.pluginPath = _wpmejsSettings.pluginPath; } settings.success = this.bindPlayer; @@ -47,8 +47,7 @@ this.playerNode.attr( 'poster', this.current.get( 'image' ).src ); } dimensions = this.current.get( 'dimensions' ).resized; - this.playerNode.attr( 'width', dimensions.width ); - this.playerNode.attr( 'height', dimensions.height ); + this.playerNode.attr( dimensions ); } else { if ( ! this.data.images ) { this.current.set( 'image', false ); diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 854b2b8a94..a87ffd334e 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -1117,7 +1117,7 @@ function wp_get_playlist( $attr, $type ) { } $data['tracks'] = $tracks; - $safe_type = esc_attr( $safe_type ); + $safe_type = esc_attr( $type ); $safe_style = esc_attr( $style ); ob_start();