<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[45934] trunk/src: Uploads: After an image is uploaded and PHP times out or runs out of memory during post-processing (the server response is HTTP 500 error), try to resize it three more times.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/45934">45934</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/45934","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-09-04 01:10:57 +0000 (Wed, 04 Sep 2019)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Uploads: After an image is uploaded and PHP times out or runs out of memory during post-processing (the server response is HTTP 500 error), try to resize it three more times. Then, if all attempts fail, do a cleanup of any sub-sizes that may have been created and show an error message asking the user to scale the image and upload it again.
See <a href="https://core.trac.wordpress.org/ticket/47872">#47872</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcjs_enqueuesvendorpluploadhandlersjs">trunk/src/js/_enqueues/vendor/plupload/handlers.js</a></li>
<li><a href="#trunksrcjs_enqueuesvendorpluploadwppluploadjs">trunk/src/js/_enqueues/vendor/plupload/wp-plupload.js</a></li>
<li><a href="#trunksrcjsmediaviewsuploaderstatusjs">trunk/src/js/media/views/uploader/status.js</a></li>
<li><a href="#trunksrcwpadminadminajaxphp">trunk/src/wp-admin/admin-ajax.php</a></li>
<li><a href="#trunksrcwpadminincludesajaxactionsphp">trunk/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunksrcwpadminincludesimagephp">trunk/src/wp-admin/includes/image.php</a></li>
<li><a href="#trunksrcwpadminincludesmediaphp">trunk/src/wp-admin/includes/media.php</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcjs_enqueuesvendorpluploadhandlersjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/vendor/plupload/handlers.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/vendor/plupload/handlers.js 2019-09-03 00:56:42 UTC (rev 45933)
+++ trunk/src/js/_enqueues/vendor/plupload/handlers.js 2019-09-04 01:10:57 UTC (rev 45934)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,42 +2,42 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // progress and success handlers for media multi uploads
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function fileQueued(fileObj) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function fileQueued( fileObj ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // Get rid of unused form
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('.media-blank').remove();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '.media-blank' ).remove();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var items = jQuery('#media-items').children(), postid = post_id || 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var items = jQuery( '#media-items' ).children(), postid = post_id || 0;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Collapse a single item
</span><span class="cx" style="display: block; padding: 0 10px"> if ( items.length == 1 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- items.removeClass('open').find('.slidetoggle').slideUp(200);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ items.removeClass( 'open' ).find( '.slidetoggle' ).slideUp( 200 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> // Create a progress bar containing the filename
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('<div class="media-item">')
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '<div class="media-item">' )
</ins><span class="cx" style="display: block; padding: 0 10px"> .attr( 'id', 'media-item-' + fileObj.id )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- .addClass('child-of-' + postid)
- .append('<div class="progress"><div class="percent">0%</div><div class="bar"></div></div>',
- jQuery('<div class="filename original">').text( ' ' + fileObj.name ))
- .appendTo( jQuery('#media-items' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ .addClass( 'child-of-' + postid )
+ .append( '<div class="progress"><div class="percent">0%</div><div class="bar"></div></div>',
+ jQuery( '<div class="filename original">' ).text( ' ' + fileObj.name ) )
+ .appendTo( jQuery( '#media-items' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Disable submit
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('#insert-gallery').prop('disabled', true);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '#insert-gallery' ).prop( 'disabled', true );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function uploadStart() {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( typeof topWin.tb_remove != 'undefined' )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- topWin.jQuery('#TB_overlay').unbind('click', topWin.tb_remove);
- } catch(e){}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ topWin.jQuery( '#TB_overlay' ).unbind( 'click', topWin.tb_remove );
+ } catch( e ){}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function uploadProgress(up, file) {
- var item = jQuery('#media-item-' + file.id);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function uploadProgress( up, file ) {
+ var item = jQuery( '#media-item-' + file.id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('.bar', item).width( (200 * file.loaded) / file.size );
- jQuery('.percent', item).html( file.percent + '%' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '.bar', item ).width( ( 200 * file.loaded ) / file.size );
+ jQuery( '.percent', item ).html( file.percent + '%' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // check to see if a large file failed to upload
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -58,45 +58,48 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function updateMediaForm() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var items = jQuery('#media-items').children();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var items = jQuery( '#media-items' ).children();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Just one file, no need for collapsible part
</span><span class="cx" style="display: block; padding: 0 10px"> if ( items.length == 1 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- items.addClass('open').find('.slidetoggle').show();
- jQuery('.insert-gallery').hide();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ items.addClass( 'open' ).find( '.slidetoggle' ).show();
+ jQuery( '.insert-gallery' ).hide();
</ins><span class="cx" style="display: block; padding: 0 10px"> } else if ( items.length > 1 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- items.removeClass('open');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ items.removeClass( 'open' );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Only show Gallery/Playlist buttons when there are at least two files.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('.insert-gallery').show();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '.insert-gallery' ).show();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Only show Save buttons when there is at least one file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( items.not('.media-blank').length > 0 )
- jQuery('.savebutton').show();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( items.not( '.media-blank' ).length > 0 )
+ jQuery( '.savebutton' ).show();
</ins><span class="cx" style="display: block; padding: 0 10px"> else
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('.savebutton').hide();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '.savebutton' ).hide();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function uploadSuccess(fileObj, serverData) {
- var item = jQuery('#media-item-' + fileObj.id);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function uploadSuccess( fileObj, serverData ) {
+ var item = jQuery( '#media-item-' + fileObj.id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- serverData = serverData.replace(/^<pre>(\d+)<\/pre>$/, '$1');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( typeof serverData === 'string' ) {
+ serverData = serverData.replace( /^<pre>(\d+)<\/pre>$/, '$1' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // if async-upload returned an error message, place it in the media item div and return
- if ( serverData.match(/media-upload-error|error-div/) ) {
- item.html(serverData);
- return;
- } else {
- jQuery('.percent', item).html( pluploadL10n.crunching );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // if async-upload returned an error message, place it in the media item div and return
+ if ( /media-upload-error|error-div/.test( serverData ) ) {
+ item.html( serverData );
+ return;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- prepareMediaItem(fileObj, serverData);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ item.find( '.percent' ).html( pluploadL10n.crunching );
+
+ prepareMediaItem( fileObj, serverData );
</ins><span class="cx" style="display: block; padding: 0 10px"> updateMediaForm();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Increment the counter.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( post_id && item.hasClass('child-of-' + post_id) )
- jQuery('#attachments-count').text(1 * jQuery('#attachments-count').text() + 1);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( post_id && item.hasClass( 'child-of-' + post_id ) ) {
+ jQuery( '#attachments-count' ).text( 1 * jQuery( '#attachments-count' ).text() + 1 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function setResize( arg ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -116,34 +119,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function prepareMediaItem(fileObj, serverData) {
- var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery('#media-item-' + fileObj.id);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function prepareMediaItem( fileObj, serverData ) {
+ var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery( '#media-item-' + fileObj.id );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( f == 2 && shortform > 2 )
</span><span class="cx" style="display: block; padding: 0 10px"> f = shortform;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( typeof topWin.tb_remove != 'undefined' )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- topWin.jQuery('#TB_overlay').click(topWin.tb_remove);
- } catch(e){}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ topWin.jQuery( '#TB_overlay' ).click( topWin.tb_remove );
+ } catch( e ){}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isNaN(serverData) || !serverData ) { // Old style: Append the HTML returned by the server -- thumbnail and form inputs
- item.append(serverData);
- prepareMediaItemInit(fileObj);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isNaN( serverData ) || !serverData ) { // Old style: Append the HTML returned by the server -- thumbnail and form inputs
+ item.append( serverData );
+ prepareMediaItemInit( fileObj );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else { // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- item.load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm();});
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ item.load( 'async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit( fileObj );updateMediaForm();});
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function prepareMediaItemInit(fileObj) {
- var item = jQuery('#media-item-' + fileObj.id);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function prepareMediaItemInit( fileObj ) {
+ var item = jQuery( '#media-item-' + fileObj.id );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('.thumbnail', item).clone().attr('class', 'pinkynail toggle').prependTo(item);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '.thumbnail', item ).clone().attr( 'class', 'pinkynail toggle' ).prependTo( item );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Replace the original filename with the new (unique) one assigned during upload
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('.filename.original', item).replaceWith( jQuery('.filename.new', item) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '.filename.original', item ).replaceWith( jQuery( '.filename.new', item ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Bind AJAX to the new Delete button
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('a.delete', item).click(function(){
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( 'a.delete', item ).click( function(){
</ins><span class="cx" style="display: block; padding: 0 10px"> // Tell the server to delete it. TODO: handle exceptions
</span><span class="cx" style="display: block; padding: 0 10px"> jQuery.ajax({
</span><span class="cx" style="display: block; padding: 0 10px"> url: ajaxurl,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -152,9 +155,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> error: deleteError,
</span><span class="cx" style="display: block; padding: 0 10px"> id: fileObj.id,
</span><span class="cx" style="display: block; padding: 0 10px"> data: {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- id : this.id.replace(/[^0-9]/g, ''),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ id : this.id.replace(/[^0-9]/g, '' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> action : 'trash-post',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ _ajax_nonce : this.href.replace(/^.*wpnonce=/,'' )
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,7 +164,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Bind AJAX to the new Undo button
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('a.undo', item).click(function(){
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( 'a.undo', item ).click( function(){
</ins><span class="cx" style="display: block; padding: 0 10px"> // Tell the server to untrash it. TODO: handle exceptions
</span><span class="cx" style="display: block; padding: 0 10px"> jQuery.ajax({
</span><span class="cx" style="display: block; padding: 0 10px"> url: ajaxurl,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,25 +171,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> type: 'post',
</span><span class="cx" style="display: block; padding: 0 10px"> id: fileObj.id,
</span><span class="cx" style="display: block; padding: 0 10px"> data: {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- id : this.id.replace(/[^0-9]/g,''),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ id : this.id.replace(/[^0-9]/g,'' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> action: 'untrash-post',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- _ajax_nonce: this.href.replace(/^.*wpnonce=/,'')
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ _ajax_nonce: this.href.replace(/^.*wpnonce=/,'' )
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> success: function( ){
</span><span class="cx" style="display: block; padding: 0 10px"> var type,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- item = jQuery('#media-item-' + fileObj.id);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ item = jQuery( '#media-item-' + fileObj.id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( type = jQuery('#type-of-' + fileObj.id).val() )
- jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-0+1);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( type = jQuery( '#type-of-' + fileObj.id ).val() )
+ jQuery( '#' + type + '-counter' ).text( jQuery( '#' + type + '-counter' ).text()-0+1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( post_id && item.hasClass('child-of-'+post_id) )
- jQuery('#attachments-count').text(jQuery('#attachments-count').text()-0+1);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( post_id && item.hasClass( 'child-of-'+post_id ) )
+ jQuery( '#attachments-count' ).text( jQuery( '#attachments-count' ).text()-0+1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('.filename .trashnotice', item).remove();
- jQuery('.filename .title', item).css('font-weight','normal');
- jQuery('a.undo', item).addClass('hidden');
- jQuery('.menu_order_input', item).show();
- item.css( {backgroundColor:'#ceb'} ).animate( {backgroundColor: '#fff'}, { queue: false, duration: 500, complete: function(){ jQuery(this).css({backgroundColor:''}); } }).removeClass('undo');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '.filename .trashnotice', item ).remove();
+ jQuery( '.filename .title', item ).css( 'font-weight','normal' );
+ jQuery( 'a.undo', item ).addClass( 'hidden' );
+ jQuery( '.menu_order_input', item ).show();
+ item.css( {backgroundColor:'#ceb'} ).animate( {backgroundColor: '#fff'}, { queue: false, duration: 500, complete: function(){ jQuery( this ).css({backgroundColor:''}); } }).removeClass( 'undo' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -193,138 +196,139 @@
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Open this item if it says to start open (e.g. to display an error)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('#media-item-' + fileObj.id + '.startopen').removeClass('startopen').addClass('open').find('slidetoggle').fadeIn();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '#media-item-' + fileObj.id + '.startopen' ).removeClass( 'startopen' ).addClass( 'open' ).find( 'slidetoggle' ).fadeIn();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // generic error message
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function wpQueueError(message) {
- jQuery('#media-upload-error').show().html( '<div class="error"><p>' + message + '</p></div>' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wpQueueError( message ) {
+ jQuery( '#media-upload-error' ).show().html( '<div class="error"><p>' + message + '</p></div>' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // file-specific error messages
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function wpFileError(fileObj, message) {
- itemAjaxError(fileObj.id, message);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wpFileError( fileObj, message ) {
+ itemAjaxError( fileObj.id, message );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function itemAjaxError(id, message) {
- var item = jQuery('#media-item-' + id), filename = item.find('.filename').text(), last_err = item.data('last-err');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function itemAjaxError( id, message ) {
+ var item = jQuery( '#media-item-' + id ), filename = item.find( '.filename' ).text(), last_err = item.data( 'last-err' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( last_err == id ) // prevent firing an error for the same file twice
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- item.html('<div class="error-div">' +
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ item.html( '<div class="error-div">' +
</ins><span class="cx" style="display: block; padding: 0 10px"> '<a class="dismiss" href="#">' + pluploadL10n.dismiss + '</a>' +
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- '<strong>' + pluploadL10n.error_uploading.replace('%s', jQuery.trim(filename)) + '</strong> ' +
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '<strong>' + pluploadL10n.error_uploading.replace( '%s', jQuery.trim( filename )) + '</strong> ' +
</ins><span class="cx" style="display: block; padding: 0 10px"> message +
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- '</div>').data('last-err', id);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '</div>' ).data( 'last-err', id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function deleteSuccess(data) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function deleteSuccess( data ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> var type, id, item;
</span><span class="cx" style="display: block; padding: 0 10px"> if ( data == '-1' )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return itemAjaxError(this.id, 'You do not have permission. Has your session expired?');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return itemAjaxError( this.id, 'You do not have permission. Has your session expired?' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( data == '0' )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return itemAjaxError( this.id, 'Could not be deleted. Has it been deleted already?' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> id = this.id;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- item = jQuery('#media-item-' + id);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ item = jQuery( '#media-item-' + id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Decrement the counters.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( type = jQuery('#type-of-' + id).val() )
- jQuery('#' + type + '-counter').text( jQuery('#' + type + '-counter').text() - 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( type = jQuery( '#type-of-' + id ).val() )
+ jQuery( '#' + type + '-counter' ).text( jQuery( '#' + type + '-counter' ).text() - 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( post_id && item.hasClass('child-of-'+post_id) )
- jQuery('#attachments-count').text( jQuery('#attachments-count').text() - 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( post_id && item.hasClass( 'child-of-'+post_id ) )
+ jQuery( '#attachments-count' ).text( jQuery( '#attachments-count' ).text() - 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( jQuery('form.type-form #media-items').children().length == 1 && jQuery('.hidden', '#media-items').length > 0 ) {
- jQuery('.toggle').toggle();
- jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( jQuery( 'form.type-form #media-items' ).children().length == 1 && jQuery( '.hidden', '#media-items' ).length > 0 ) {
+ jQuery( '.toggle' ).toggle();
+ jQuery( '.slidetoggle' ).slideUp( 200 ).siblings().removeClass( 'hidden' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Vanish it.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('.toggle', item).toggle();
- jQuery('.slidetoggle', item).slideUp(200).siblings().removeClass('hidden');
- item.css( {backgroundColor:'#faa'} ).animate( {backgroundColor:'#f4f4f4'}, {queue:false, duration:500} ).addClass('undo');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '.toggle', item ).toggle();
+ jQuery( '.slidetoggle', item ).slideUp( 200 ).siblings().removeClass( 'hidden' );
+ item.css( {backgroundColor:'#faa'} ).animate( {backgroundColor:'#f4f4f4'}, {queue:false, duration:500} ).addClass( 'undo' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('.filename:empty', item).remove();
- jQuery('.filename .title', item).css('font-weight','bold');
- jQuery('.filename', item).append('<span class="trashnotice"> ' + pluploadL10n.deleted + ' </span>').siblings('a.toggle').hide();
- jQuery('.filename', item).append( jQuery('a.undo', item).removeClass('hidden') );
- jQuery('.menu_order_input', item).hide();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '.filename:empty', item ).remove();
+ jQuery( '.filename .title', item ).css( 'font-weight','bold' );
+ jQuery( '.filename', item ).append( '<span class="trashnotice"> ' + pluploadL10n.deleted + ' </span>' ).siblings( 'a.toggle' ).hide();
+ jQuery( '.filename', item ).append( jQuery( 'a.undo', item ).removeClass( 'hidden' ) );
+ jQuery( '.menu_order_input', item ).hide();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function deleteError() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // TODO
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function uploadComplete() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('#insert-gallery').prop('disabled', false);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '#insert-gallery' ).prop( 'disabled', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function switchUploader(s) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function switchUploader( s ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( s ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- deleteUserSetting('uploader');
- jQuery('.media-upload-form').removeClass('html-uploader');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ deleteUserSetting( 'uploader' );
+ jQuery( '.media-upload-form' ).removeClass( 'html-uploader' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( typeof(uploader) == 'object' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( typeof( uploader ) == 'object' )
</ins><span class="cx" style="display: block; padding: 0 10px"> uploader.refresh();
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- setUserSetting('uploader', '1'); // 1 == html uploader
- jQuery('.media-upload-form').addClass('html-uploader');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ setUserSetting( 'uploader', '1' ); // 1 == html uploader
+ jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function uploadError(fileObj, errorCode, message, uploader) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function uploadError( fileObj, errorCode, message, up ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> var hundredmb = 100 * 1024 * 1024, max;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch (errorCode) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ switch ( errorCode ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> case plupload.FAILED:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpFileError(fileObj, pluploadL10n.upload_failed);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpFileError( fileObj, pluploadL10n.upload_failed );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.FILE_EXTENSION_ERROR:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpFileExtensionError( uploader, fileObj, pluploadL10n.invalid_filetype );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpFileExtensionError( up, fileObj, pluploadL10n.invalid_filetype );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.FILE_SIZE_ERROR:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- uploadSizeError(uploader, fileObj);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ uploadSizeError( up, fileObj );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.IMAGE_FORMAT_ERROR:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpFileError(fileObj, pluploadL10n.not_an_image);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpFileError( fileObj, pluploadL10n.not_an_image );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.IMAGE_MEMORY_ERROR:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpFileError(fileObj, pluploadL10n.image_memory_exceeded);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpFileError( fileObj, pluploadL10n.image_memory_exceeded );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.IMAGE_DIMENSIONS_ERROR:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpFileError(fileObj, pluploadL10n.image_dimensions_exceeded);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpFileError( fileObj, pluploadL10n.image_dimensions_exceeded );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.GENERIC_ERROR:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpQueueError(pluploadL10n.upload_failed);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpQueueError( pluploadL10n.upload_failed );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.IO_ERROR:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- max = parseInt( uploader.settings.filters.max_file_size, 10 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ max = parseInt( up.settings.filters.max_file_size, 10 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( max > hundredmb && fileObj.size > hundredmb )
- wpFileError( fileObj, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>') );
- else
- wpQueueError(pluploadL10n.io_error);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( max > hundredmb && fileObj.size > hundredmb ) {
+ wpFileError( fileObj, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
+ } else {
+ wpQueueError( pluploadL10n.io_error );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.HTTP_ERROR:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpQueueError(pluploadL10n.http_error);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpQueueError( pluploadL10n.http_error );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.INIT_ERROR:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('.media-upload-form').addClass('html-uploader');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.SECURITY_ERROR:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpQueueError(pluploadL10n.security_error);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpQueueError( pluploadL10n.security_error );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> /* case plupload.UPLOAD_ERROR.UPLOAD_STOPPED:
</span><span class="cx" style="display: block; padding: 0 10px"> case plupload.UPLOAD_ERROR.FILE_CANCELLED:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('#media-item-' + fileObj.id).remove();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '#media-item-' + fileObj.id ).remove();
</ins><span class="cx" style="display: block; padding: 0 10px"> break;*/
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpFileError(fileObj, pluploadL10n.default_error);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpFileError( fileObj, pluploadL10n.default_error );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -331,7 +335,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function uploadSizeError( up, file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var message, errorDiv;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- message = pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ message = pluploadL10n.file_exceeds_size_limit.replace( '%s', file.name );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Construct the error div.
</span><span class="cx" style="display: block; padding: 0 10px"> errorDiv = jQuery( '<div />' )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -345,51 +349,59 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Append the error.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('#media-items').append( errorDiv );
- up.removeFile(file);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '#media-items' ).append( errorDiv );
+ up.removeFile( file );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function wpFileExtensionError( up, file, message ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jQuery('#media-items').append('<div id="media-item-' + file.id + '" class="media-item error"><p>' + message + '</p></div>');
- up.removeFile(file);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery( '#media-items' ).append( '<div id="media-item-' + file.id + '" class="media-item error"><p>' + message + '</p></div>' );
+ up.removeFile( file );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-jQuery(document).ready(function($){
- $('.media-upload-form').bind('click.uploader', function(e) {
- var target = $(e.target), tr, c;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+jQuery( document ).ready( function( $ ) {
+ var tryAgainCount = {};
+ var tryAgain;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( target.is('input[type="radio"]') ) { // remember the last used image size and alignment
- tr = target.closest('tr');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $( '.media-upload-form' ).bind( 'click.uploader', function( e ) {
+ var target = $( e.target ), tr, c;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( tr.hasClass('align') )
- setUserSetting('align', target.val());
- else if ( tr.hasClass('image-size') )
- setUserSetting('imgsize', target.val());
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( target.is( 'input[type="radio"]' ) ) { // remember the last used image size and alignment
+ tr = target.closest( 'tr' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else if ( target.is('button.button') ) { // remember the last used image link url
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( tr.hasClass( 'align' ) )
+ setUserSetting( 'align', target.val() );
+ else if ( tr.hasClass( 'image-size' ) )
+ setUserSetting( 'imgsize', target.val() );
+
+ } else if ( target.is( 'button.button' ) ) { // remember the last used image link url
</ins><span class="cx" style="display: block; padding: 0 10px"> c = e.target.className || '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- c = c.match(/url([^ '"]+)/);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ c = c.match( /url([^ '"]+)/ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( c && c[1] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- setUserSetting('urlbutton', c[1]);
- target.siblings('.urlfield').val( target.data('link-url') );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ setUserSetting( 'urlbutton', c[1] );
+ target.siblings( '.urlfield' ).val( target.data( 'link-url' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else if ( target.is('a.dismiss') ) {
- target.parents('.media-item').fadeOut(200, function(){
- $(this).remove();
- });
- } else if ( target.is('.upload-flash-bypass a') || target.is('a.uploader-html') ) { // switch uploader to html4
- $('#media-items, p.submit, span.big-file-warning').css('display', 'none');
- switchUploader(0);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } else if ( target.is( 'a.dismiss' ) ) {
+ target.parents( '.media-item' ).fadeOut( 200, function() {
+ $( this ).remove();
+ } );
+ } else if ( target.is( '.upload-flash-bypass a' ) || target.is( 'a.uploader-html' ) ) { // switch uploader to html4
+ $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', 'none' );
+ switchUploader( 0 );
</ins><span class="cx" style="display: block; padding: 0 10px"> e.preventDefault();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else if ( target.is('.upload-html-bypass a') ) { // switch uploader to multi-file
- $('#media-items, p.submit, span.big-file-warning').css('display', '');
- switchUploader(1);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } else if ( target.is( '.upload-html-bypass a' ) ) { // switch uploader to multi-file
+ $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', '' );
+ switchUploader( 1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> e.preventDefault();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else if ( target.is('a.describe-toggle-on') ) { // Show
- target.parent().addClass('open');
- target.siblings('.slidetoggle').fadeIn(250, function(){
- var S = $(window).scrollTop(), H = $(window).height(), top = $(this).offset().top, h = $(this).height(), b, B;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } else if ( target.is( 'a.describe-toggle-on' ) ) { // Show
+ target.parent().addClass( 'open' );
+ target.siblings( '.slidetoggle' ).fadeIn( 250, function() {
+ var S = $( window ).scrollTop(),
+ H = $( window ).height(),
+ top = $( this ).offset().top,
+ h = $( this ).height(),
+ b,
+ B;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( H && top && h ) {
</span><span class="cx" style="display: block; padding: 0 10px"> b = top + h;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -397,65 +409,136 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( b > B ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( b - B < top - S )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- window.scrollBy(0, (b - B) + 10);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ window.scrollBy( 0, ( b - B ) + 10 );
</ins><span class="cx" style="display: block; padding: 0 10px"> else
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- window.scrollBy(0, top - S - 40);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ window.scrollBy( 0, top - S - 40 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> e.preventDefault();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else if ( target.is('a.describe-toggle-off') ) { // Hide
- target.siblings('.slidetoggle').fadeOut(250, function(){
- target.parent().removeClass('open');
- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide
+ target.siblings( '.slidetoggle' ).fadeOut( 250, function() {
+ target.parent().removeClass( 'open' );
+ } );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> e.preventDefault();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // init and set the uploader
- uploader_init = function() {
- var isIE = navigator.userAgent.indexOf('Trident/') != -1 || navigator.userAgent.indexOf('MSIE ') != -1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Attempt to create image sub-sizes when an image was uploaded successfully
+ // but the server responded with HTTP 500 error.
+ tryAgain = function( up, error ) {
+ var file = error.file;
+ var times;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure flash sends cookies (seems in IE it does whitout switching to urlstream mode)
- if ( ! isIE && 'flash' === plupload.predictRuntime( wpUploaderInit ) &&
- ( ! wpUploaderInit.required_features || ! wpUploaderInit.required_features.hasOwnProperty( 'send_binary_string' ) ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! file || ! file.id ) {
+ wpQueueError( error.message || pluploadL10n.default_error );
+ return;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpUploaderInit.required_features = wpUploaderInit.required_features || {};
- wpUploaderInit.required_features.send_binary_string = true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ times = tryAgainCount[ file.id ];
+
+ if ( times && times > 4 ) {
+ // The file may have been uploaded and attachment post created,
+ // but post-processing and resizing failed...
+ // Do a cleanup then tell the user to scale down the image and upload it again.
+ $.ajax({
+ type: 'post',
+ url: ajaxurl,
+ dataType: 'json',
+ data: {
+ action: 'media-create-image-subsizes',
+ _wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce,
+ _wp_temp_image_ref: file.id,
+ _wp_upload_failed_cleanup: true,
+ }
+ });
+
+ if ( error.message && error.status !== 500 ) {
+ wpQueueError( error.message );
+ } else {
+ wpQueueError( pluploadL10n.http_error_image );
+ }
+
+ return;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- uploader = new plupload.Uploader(wpUploaderInit);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! times ) {
+ tryAgainCount[ file.id ] = 1;
+ } else {
+ tryAgainCount[ file.id ] = ++times;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $('#image_resize').bind('change', function() {
- var arg = $(this).prop('checked');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Try to create the missing image sizes.
+ $.ajax({
+ type: 'post',
+ url: ajaxurl,
+ dataType: 'json',
+ data: {
+ action: 'media-create-image-subsizes',
+ _wpnonce: wpUploaderInit.multipart_params._wpnonce,
+ _wp_temp_image_ref: file.id,
+ _legasy_support: 'true',
+ }
+ }).done( function( response ) {
+ var message;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( response.success ) {
+ uploadSuccess( file, response.data.id );
+ } else {
+ if ( response.data && response.data.message ) {
+ message = response.data.message;
+ }
+
+ wpQueueError( message || pluploadL10n.http_error_image );
+ }
+ }).fail( function( jqXHR ) {
+ // If another HTTP 500 error, try try again...
+ if ( jqXHR.status === 500 ) {
+ tryAgain( up, error );
+ return;
+ }
+
+ wpQueueError( pluploadL10n.http_error_image );
+ });
+ }
+
+ // init and set the uploader
+ uploader_init = function() {
+ uploader = new plupload.Uploader( wpUploaderInit );
+
+ $( '#image_resize' ).bind( 'change', function() {
+ var arg = $( this ).prop( 'checked' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> setResize( arg );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( arg )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- setUserSetting('upload_resize', '1');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ setUserSetting( 'upload_resize', '1' );
</ins><span class="cx" style="display: block; padding: 0 10px"> else
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- deleteUserSetting('upload_resize');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ deleteUserSetting( 'upload_resize' );
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- uploader.bind('Init', function(up) {
- var uploaddiv = $('#plupload-upload-ui');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ uploader.bind( 'Init', function( up ) {
+ var uploaddiv = $( '#plupload-upload-ui' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- setResize( getUserSetting('upload_resize', false) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ setResize( getUserSetting( 'upload_resize', false ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( up.features.dragdrop && ! $(document.body).hasClass('mobile') ) {
- uploaddiv.addClass('drag-drop');
- $('#drag-drop-area').on('dragover.wp-uploader', function(){ // dragenter doesn't fire right :(
- uploaddiv.addClass('drag-over');
- }).on('dragleave.wp-uploader, drop.wp-uploader', function(){
- uploaddiv.removeClass('drag-over');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( up.features.dragdrop && ! $( document.body ).hasClass( 'mobile' ) ) {
+ uploaddiv.addClass( 'drag-drop' );
+
+ $( '#drag-drop-area' ).on( 'dragover.wp-uploader', function() { // dragenter doesn't fire right :(
+ uploaddiv.addClass( 'drag-over' );
+ }).on( 'dragleave.wp-uploader, drop.wp-uploader', function() {
+ uploaddiv.removeClass( 'drag-over' );
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- uploaddiv.removeClass('drag-drop');
- $('#drag-drop-area').off('.wp-uploader');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ uploaddiv.removeClass( 'drag-drop' );
+ $( '#drag-drop-area' ).off( '.wp-uploader' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( up.runtime === 'html4' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $('.upload-flash-bypass').hide();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $( '.upload-flash-bypass' ).hide();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -465,8 +548,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> uploader.init();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- uploader.bind('FilesAdded', function( up, files ) {
- $('#media-upload-error').empty();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ uploader.bind( 'FilesAdded', function( up, files ) {
+ $( '#media-upload-error' ).empty();
</ins><span class="cx" style="display: block; padding: 0 10px"> uploadStart();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> plupload.each( files, function( file ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -477,29 +560,53 @@
</span><span class="cx" style="display: block; padding: 0 10px"> up.start();
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- uploader.bind('UploadFile', function(up, file) {
- fileUploading(up, file);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ uploader.bind( 'UploadFile', function( up, file ) {
+ fileUploading( up, file );
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- uploader.bind('UploadProgress', function(up, file) {
- uploadProgress(up, file);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ uploader.bind( 'UploadProgress', function( up, file ) {
+ uploadProgress( up, file );
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- uploader.bind('Error', function(up, err) {
- uploadError(err.file, err.code, err.message, up);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ uploader.bind( 'Error', function( up, error ) {
+ var isImage = error.file && error.file.type && error.file.type.indexOf( 'image/' ) === 0;
+ var status = error && error.status;
+
+ // If the file is an image and the error is HTTP 500 try to create sub-sizes again.
+ if ( status === 500 && isImage ) {
+ tryAgain( up, error );
+ return;
+ }
+
+ uploadError( error.file, error.code, error.message, up );
</ins><span class="cx" style="display: block; padding: 0 10px"> up.refresh();
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- uploader.bind('FileUploaded', function(up, file, response) {
- uploadSuccess(file, response.response);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ uploader.bind( 'FileUploaded', function( up, file, response ) {
+ uploadSuccess( file, response.response );
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- uploader.bind('UploadComplete', function() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ uploader.bind( 'UploadComplete', function() {
</ins><span class="cx" style="display: block; padding: 0 10px"> uploadComplete();
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * When uploading images add a file reference used to retrieve the attachment_id
+ * if the uploading fails due to a server timeout of out of memoty (HTTP 500) error.
+ *
+ * @param {plupload.Uploader} up Uploader instance.
+ * @param {plupload.File} file File for uploading.
+ */
+ uploader.bind( 'BeforeUpload', function( up, file ) {
+ if ( file.type && file.type.indexOf( 'image/' ) === 0 ) {
+ up.settings.multipart_params._wp_temp_image_ref = file.id;
+ } else {
+ unset( up.settings.multipart_params._wp_temp_image_ref );
+ }
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( typeof(wpUploaderInit) == 'object' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( typeof( wpUploaderInit ) == 'object' ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> uploader_init();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcjs_enqueuesvendorpluploadwppluploadjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/vendor/plupload/wp-plupload.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/vendor/plupload/wp-plupload.js 2019-09-03 00:56:42 UTC (rev 45933)
+++ trunk/src/js/_enqueues/vendor/plupload/wp-plupload.js 2019-09-04 01:10:57 UTC (rev 45934)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -33,13 +33,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> Uploader = function( options ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var self = this,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- isIE = navigator.userAgent.indexOf('Trident/') != -1 || navigator.userAgent.indexOf('MSIE ') != -1,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ isIE, // not used, back-compat
</ins><span class="cx" style="display: block; padding: 0 10px"> elements = {
</span><span class="cx" style="display: block; padding: 0 10px"> container: 'container',
</span><span class="cx" style="display: block; padding: 0 10px"> browser: 'browse_button',
</span><span class="cx" style="display: block; padding: 0 10px"> dropzone: 'drop_element'
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- key, error;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ tryAgainCount = {},
+ tryAgain,
+ key,
+ error,
+ fileUploaded;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> this.supports = {
</span><span class="cx" style="display: block; padding: 0 10px"> upload: Uploader.browser.supported
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -95,14 +99,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure flash sends cookies (seems in IE it does without switching to urlstream mode)
- if ( ! isIE && 'flash' === plupload.predictRuntime( this.plupload ) &&
- ( ! this.plupload.required_features || ! this.plupload.required_features.hasOwnProperty( 'send_binary_string' ) ) ) {
-
- this.plupload.required_features = this.plupload.required_features || {};
- this.plupload.required_features.send_binary_string = true;
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Initialize the plupload instance.
</span><span class="cx" style="display: block; padding: 0 10px"> this.uploader = new plupload.Uploader( this.plupload );
</span><span class="cx" style="display: block; padding: 0 10px"> delete this.plupload;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -112,16 +108,103 @@
</span><span class="cx" style="display: block; padding: 0 10px"> delete this.params;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Attempt to create image sub-sizes when an image was uploaded successfully
+ * but the server responded with HTTP 500 error.
+ *
+ * @since 5.3.0
+ *
+ * @param {string} message Error message.
+ * @param {object} data Error data from Plupload.
+ * @param {plupload.File} file File that was uploaded.
+ */
+ tryAgain = function( message, data, file ) {
+ var times;
+
+ if ( ! file || ! file.id ) {
+ error( pluploadL10n.upload_failed, data, file, 'no-retry' );
+ return;
+ }
+
+ times = tryAgainCount[ file.id ];
+
+ if ( times && times > 4 ) {
+ // The file may have been uploaded and attachment post created,
+ // but post-processing and resizing failed...
+ // Do a cleanup then tell the user to scale down the image and upload it again.
+ $.ajax({
+ type: 'post',
+ url: ajaxurl,
+ dataType: 'json',
+ data: {
+ action: 'media-create-image-subsizes',
+ _wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce,
+ _wp_temp_image_ref: file.id,
+ _wp_upload_failed_cleanup: true,
+ }
+ });
+
+ error( message, data, file, 'no-retry' );
+ return;
+ }
+
+ if ( ! times ) {
+ tryAgainCount[ file.id ] = 1;
+ } else {
+ tryAgainCount[ file.id ] = ++times;
+ }
+
+ // Another request to try to create the missing image sub-sizes.
+ $.ajax({
+ type: 'post',
+ url: ajaxurl,
+ dataType: 'json',
+ data: {
+ action: 'media-create-image-subsizes',
+ _wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce,
+ _wp_temp_image_ref: file.id, // Used to find the new attachment_id.
+ }
+ }).done( function( response ) {
+ if ( response.success ) {
+ fileUploaded( self.uploader, file, response );
+ } else {
+ if ( response.data && response.data.message ) {
+ message = response.data.message;
+ }
+
+ error( message, data, file, 'no-retry' );
+ }
+ }).fail( function( jqXHR ) {
+ // If another HTTP 500 error, try try again...
+ if ( jqXHR.status === 500 ) {
+ tryAgain( message, data, file );
+ return;
+ }
+
+ error( message, data, file, 'no-retry' );
+ });
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Custom error callback.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Add a new error to the errors collection, so other modules can track
</span><span class="cx" style="display: block; padding: 0 10px"> * and display errors. @see wp.Uploader.errors.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {string} message
- * @param {object} data
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {string} message Error message.
+ * @param {object} data Error data from Plupload.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param {plupload.File} file File that was uploaded.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {string} retry Whether to try again to create image sub-sizes. Passing 'no-retry' will prevent it.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- error = function( message, data, file ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ error = function( message, data, file, retry ) {
+ var isImage = file.type && file.type.indexOf( 'image/' ) === 0;
+ var status = data && data.status;
+
+ // If the file is an image and the error is HTTP 500 try to create sub-sizes again.
+ if ( retry !== 'no-retry' && status === 500 && isImage ) {
+ tryAgain( message, data, file );
+ return;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( file.attachment ) {
</span><span class="cx" style="display: block; padding: 0 10px"> file.attachment.destroy();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -136,6 +219,36 @@
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * After a file is successfully uploaded, update its model.
+ *
+ * @param {plupload.Uploader} up Uploader instance.
+ * @param {plupload.File} file File that was uploaded.
+ * @param {Object} response Object with response properties.
+ */
+ fileUploaded = function( up, file, response ) {
+ var complete;
+
+ // Remove the "uploading" UI elements
+ _.each( ['file','loaded','size','percent'], function( key ) {
+ file.attachment.unset( key );
+ } );
+
+ file.attachment.set( _.extend( response.data, { uploading: false } ) );
+
+ wp.media.model.Attachment.get( response.data.id, file.attachment );
+
+ complete = Uploader.queue.all( function( attachment ) {
+ return ! attachment.get( 'uploading' );
+ });
+
+ if ( complete ) {
+ Uploader.queue.reset();
+ }
+
+ self.success( file.attachment );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * After the Uploader has been initialized, initialize some behaviors for the dropzone.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {plupload.Uploader} uploader Uploader instance.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -203,10 +316,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * When uploading images add a reference used to retrieve the attachment_id.
+ * Used if the uploading fails due to a server timeout of out of memoty error (HTTP 500).
+ *
+ * @param {plupload.Uploader} up Uploader instance.
+ * @param {plupload.File} file File for uploading.
+ */
+ this.uploader.bind( 'BeforeUpload', function( up, file ) {
+ if ( file.type && file.type.indexOf( 'image/' ) === 0 ) {
+ up.settings.multipart_params._wp_temp_image_ref = file.id;
+ } else {
+ unset( up.settings.multipart_params._wp_temp_image_ref );
+ }
+ } );
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * After files were filtered and added to the queue, create a model for each.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {plupload.Uploader} uploader Uploader instance.
- * @param {Array} files Array of file objects that were added to queue by the user.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {plupload.Uploader} up Uploader instance.
+ * @param {Array} files Array of file objects that were added to queue by the user.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> this.uploader.bind( 'FilesAdded', function( up, files ) {
</span><span class="cx" style="display: block; padding: 0 10px"> _.each( files, function( file ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -259,13 +387,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * After a file is successfully uploaded, update its model.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {plupload.Uploader} uploader Uploader instance.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {plupload.Uploader} up Uploader instance.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param {plupload.File} file File that was uploaded.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {Object} response Object with response properties.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return {mixed}
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> this.uploader.bind( 'FileUploaded', function( up, file, response ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var complete;
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> response = JSON.parse( response.response );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -273,33 +400,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return error( pluploadL10n.default_error, e, file );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! _.isObject( response ) || _.isUndefined( response.success ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! _.isObject( response ) || _.isUndefined( response.success ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return error( pluploadL10n.default_error, null, file );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- else if ( ! response.success )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } else if ( ! response.success ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return error( response.data && response.data.message, response.data, file );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- _.each(['file','loaded','size','percent'], function( key ) {
- file.attachment.unset( key );
- });
-
- file.attachment.set( _.extend( response.data, { uploading: false }) );
- wp.media.model.Attachment.get( response.data.id, file.attachment );
-
- complete = Uploader.queue.all( function( attachment ) {
- return ! attachment.get('uploading');
- });
-
- if ( complete )
- Uploader.queue.reset();
-
- self.success( file.attachment );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Success. Update the UI with the new attachment.
+ fileUploaded( up, file, response );
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * When plupload surfaces an error, send it to the error handler.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {plupload.Uploader} uploader Uploader instance.
- * @param {Object} error Contains code, message and sometimes file and other details.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {plupload.Uploader} up Uploader instance.
+ * @param {Object} pluploadError Contains code, message and sometimes file and other details.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> this.uploader.bind( 'Error', function( up, pluploadError ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var message = pluploadL10n.default_error,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -338,12 +453,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'IMAGE_DIMENSIONS_ERROR': pluploadL10n.image_dimensions_exceeded,
</span><span class="cx" style="display: block; padding: 0 10px"> 'GENERIC_ERROR': pluploadL10n.upload_failed,
</span><span class="cx" style="display: block; padding: 0 10px"> 'IO_ERROR': pluploadL10n.io_error,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'HTTP_ERROR': pluploadL10n.http_error,
</del><span class="cx" style="display: block; padding: 0 10px"> 'SECURITY_ERROR': pluploadL10n.security_error,
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> 'FILE_SIZE_ERROR': function( file ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return pluploadL10n.file_exceeds_size_limit.replace( '%s', file.name );
+ },
+
+ 'HTTP_ERROR': function( file ) {
+ if ( file.type && file.type.indexOf( 'image/' ) === 0 ) {
+ return pluploadL10n.http_error_image;
+ }
+
+ return pluploadL10n.http_error;
+ },
</ins><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $.extend( Uploader.prototype, /** @lends wp.Uploader.prototype */{
</span></span></pre></div>
<a id="trunksrcjsmediaviewsuploaderstatusjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/media/views/uploader/status.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/media/views/uploader/status.js 2019-09-03 00:56:42 UTC (rev 45933)
+++ trunk/src/js/media/views/uploader/status.js 2019-09-04 01:10:57 UTC (rev 45934)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -111,10 +111,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {Backbone.Model} error
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> error: function( error ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- this.views.add( '.upload-errors', new wp.media.view.UploaderStatusError({
- filename: this.filename( error.get('file').name ),
- message: error.get('message')
- }), { at: 0 });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var statusError = new wp.media.view.UploaderStatusError( {
+ filename: this.filename( error.get( 'file' ).name ),
+ message: error.get( 'message' )
+ } );
+
+ // Can show additional info here while retrying to create image sub-sizes.
+ this.views.add( '.upload-errors', statusError, { at: 0 } );
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> dismiss: function() {
</span></span></pre></div>
<a id="trunksrcwpadminadminajaxphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/admin-ajax.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/admin-ajax.php 2019-09-03 00:56:42 UTC (rev 45933)
+++ trunk/src/wp-admin/admin-ajax.php 2019-09-04 01:10:57 UTC (rev 45934)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -105,6 +105,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'send-link-to-editor',
</span><span class="cx" style="display: block; padding: 0 10px"> 'send-attachment-to-editor',
</span><span class="cx" style="display: block; padding: 0 10px"> 'save-attachment-order',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'media-create-image-subsizes',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'heartbeat',
</span><span class="cx" style="display: block; padding: 0 10px"> 'get-revision-diffs',
</span><span class="cx" style="display: block; padding: 0 10px"> 'save-user-color-scheme',
</span></span></pre></div>
<a id="trunksrcwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/ajax-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/ajax-actions.php 2019-09-03 00:56:42 UTC (rev 45933)
+++ trunk/src/wp-admin/includes/ajax-actions.php 2019-09-04 01:10:57 UTC (rev 45934)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -111,6 +111,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = sanitize_key( $_GET['tax'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $tax = get_taxonomy( $taxonomy );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $tax ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -125,10 +126,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ',' !== $comma ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $s = str_replace( $comma, ',', $s );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false !== strpos( $s, ',' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $s = explode( ',', $s );
</span><span class="cx" style="display: block; padding: 0 10px"> $s = $s[ count( $s ) - 1 ];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $s = trim( $s );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -193,6 +196,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate' ) && function_exists( 'gzdeflate' ) && ! $force_gzip ) {
</span><span class="cx" style="display: block; padding: 0 10px"> header( 'Content-Encoding: deflate' );
</span><span class="cx" style="display: block; padding: 0 10px"> $out = gzdeflate( $test_str, 1 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -202,6 +206,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> echo $out;
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'no' == $_GET['test'] ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -230,6 +235,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( "image_editor-$post_id" );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! stream_preview_image( $post_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -295,6 +301,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'fields' => 'ID',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> ) : array() );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $exclude_blog_users = ( $type == 'add' ? get_users(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'blog_id' => $id,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -481,14 +488,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // What type of comment count are we looking for?
</span><span class="cx" style="display: block; padding: 0 10px"> $status = 'all';
</span><span class="cx" style="display: block; padding: 0 10px"> $parsed = parse_url( $url );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $parsed['query'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> parse_str( $parsed['query'], $query_vars );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $query_vars['comment_status'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $status = $query_vars['comment_status'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $query_vars['p'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = (int) $query_vars['p'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $query_vars['comment_type'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $type = $query_vars['comment_type'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -550,19 +561,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $action = $_POST['action'];
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = get_taxonomy( substr( $action, 4 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $names = explode( ',', $_POST[ 'new' . $taxonomy->name ] );
</span><span class="cx" style="display: block; padding: 0 10px"> $parent = isset( $_POST[ 'new' . $taxonomy->name . '_parent' ] ) ? (int) $_POST[ 'new' . $taxonomy->name . '_parent' ] : 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 0 > $parent ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $parent = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $taxonomy->name == 'category' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_category = isset( $_POST['post_category'] ) ? (array) $_POST['post_category'] : array();
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_category = ( isset( $_POST['tax_input'] ) && isset( $_POST['tax_input'][ $taxonomy->name ] ) ) ? (array) $_POST['tax_input'][ $taxonomy->name ] : array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $checked_categories = array_map( 'absint', (array) $post_category );
</span><span class="cx" style="display: block; padding: 0 10px"> $popular_ids = wp_popular_terms_checklist( $taxonomy->name, 0, 10, false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -569,17 +585,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $names as $cat_name ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $cat_name = trim( $cat_name );
</span><span class="cx" style="display: block; padding: 0 10px"> $category_nicename = sanitize_title( $cat_name );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( '' === $category_nicename ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $cat_id || is_wp_error( $cat_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $cat_id = $cat_id['term_id'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $checked_categories[] = $cat_id;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $parent ) { // Do these all at once in a second
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -670,9 +690,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $comment ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( time() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -679,18 +701,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( "delete-comment_$id" );
</span><span class="cx" style="display: block; padding: 0 10px"> $status = wp_get_comment_status( $comment );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $delta = -1;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $delta = -1;
</del><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_POST['trash'] ) && 1 == $_POST['trash'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'trash' == $status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( time() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $r = wp_trash_comment( $comment );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( isset( $_POST['untrash'] ) && 1 == $_POST['untrash'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'trash' != $status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( time() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $r = wp_untrash_comment( $comment );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) { // undo trash, not in trash
</span><span class="cx" style="display: block; padding: 0 10px"> $delta = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -698,12 +723,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'spam' == $status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( time() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $r = wp_spam_comment( $comment );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( isset( $_POST['unspam'] ) && 1 == $_POST['unspam'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'spam' != $status ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( time() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $r = wp_unspam_comment( $comment );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) { // undo spam, not in spam
</span><span class="cx" style="display: block; padding: 0 10px"> $delta = 1;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -716,6 +744,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $r ) { // Decide if we need to send back '1' or a more complicated response including page links and comment counts
</span><span class="cx" style="display: block; padding: 0 10px"> _wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -734,6 +763,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = ! empty( $_POST['taxonomy'] ) ? $_POST['taxonomy'] : 'post_tag';
</span><span class="cx" style="display: block; padding: 0 10px"> $tag = get_term( $tag_id, $taxonomy );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $tag || is_wp_error( $tag ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -754,6 +784,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( "delete-bookmark_$id" );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'manage_links' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -780,6 +811,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( "delete-meta_$id" );
</span><span class="cx" style="display: block; padding: 0 10px"> $meta = get_metadata_by_mid( 'post', $id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $meta ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -787,9 +819,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( delete_meta( $meta->meta_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -804,9 +838,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $action ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $action = 'delete-post';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ check_ajax_referer( "{$action}_$id" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- check_ajax_referer( "{$action}_$id" );
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'delete_post', $id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -833,9 +868,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $action ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $action = 'trash-post';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ check_ajax_referer( "{$action}_$id" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- check_ajax_referer( "{$action}_$id" );
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'delete_post', $id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -868,6 +904,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $action ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $action = 'untrash-post';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_ajax_trash_post( $action );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -882,9 +919,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $action ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $action = 'delete-page';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ check_ajax_referer( "{$action}_$id" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- check_ajax_referer( "{$action}_$id" );
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'delete_page', $id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -906,9 +944,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_ajax_dim_comment() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
+ $comment = get_comment( $id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $comment = get_comment( $id );
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! $comment ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $x = new WP_Ajax_Response(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -928,11 +966,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $current = wp_get_comment_status( $comment );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( time() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( "approve-comment_$id" );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = wp_set_comment_status( $comment, 'approve', true );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -965,27 +1005,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $action ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $action = 'add-link-category';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( $action );
</span><span class="cx" style="display: block; padding: 0 10px"> $tax = get_taxonomy( 'link_category' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( $tax->cap->manage_terms ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $names = explode( ',', wp_unslash( $_POST['newcat'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $x = new WP_Ajax_Response();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $names as $cat_name ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $cat_name = trim( $cat_name );
</span><span class="cx" style="display: block; padding: 0 10px"> $slug = sanitize_title( $cat_name );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( '' === $slug ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $cat_id = wp_insert_term( $cat_name, 'link_category' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $cat_id || is_wp_error( $cat_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $cat_id = $cat_id['term_id'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $cat_name = esc_html( $cat_name );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $x->add(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'what' => 'link-category',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1022,6 +1070,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $tag || is_wp_error( $tag ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $message = __( 'An error has occurred. Please reload the page and try again.' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $message = $tag->get_error_message();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1057,6 +1106,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'supplemental' => compact( 'parents', 'noparents' ),
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $x->add(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'what' => 'term',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1064,6 +1114,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'supplemental' => (array) $tag,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $x->send();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1079,6 +1130,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = sanitize_key( $_POST['tax'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $tax = get_taxonomy( $taxonomy );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $tax ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1123,7 +1175,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> echo $return;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1138,9 +1189,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_ajax_get_comments( $action ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $post_id;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $action ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $action = 'get-comments';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( $action );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1167,6 +1220,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $x = new WP_Ajax_Response();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ob_start();
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $wp_list_table->items as $comment ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1183,6 +1237,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'data' => $comment_list_item,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $x->send();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1202,6 +1257,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_post_ID = (int) $_POST['comment_post_ID'];
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $comment_post_ID );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $post ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1217,6 +1273,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user = wp_get_current_user();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $user->exists() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $user_ID = $user->ID;
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_author = wp_slash( $user->display_name );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1224,6 +1281,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_author_url = wp_slash( $user->user_url );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_content = trim( $_POST['content'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( current_user_can( 'unfiltered_html' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['_wp_unfiltered_html_comment'] = '';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1245,9 +1303,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_parent = 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_POST['comment_ID'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_parent = absint( $_POST['comment_ID'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $comment_auto_approved = false;
</span><span class="cx" style="display: block; padding: 0 10px"> $commentdata = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1273,6 +1333,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $comment_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $comment ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1334,6 +1395,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = (int) $_POST['comment_ID'];
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1352,6 +1414,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $comment_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $comment->comment_ID ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1390,8 +1453,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // For performance reasons, we omit some object properties from the checklist.
</span><span class="cx" style="display: block; padding: 0 10px"> // The following is a hacky way to restore them when adding non-custom items.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $menu_items_data = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $menu_items_data = array();
</del><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $_POST['menu-item'] as $menu_item_data ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> ! empty( $menu_item_data['menu-item-type'] ) &&
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1431,6 +1494,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $item_ids as $menu_item_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $menu_obj = get_post( $menu_item_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $menu_obj->ID ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $menu_obj = wp_setup_nav_menu_item( $menu_obj );
</span><span class="cx" style="display: block; padding: 0 10px"> $menu_obj->title = empty( $menu_obj->title ) ? __( 'Menu Item' ) : $menu_obj->title;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1454,8 +1518,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'link_before' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'walker' => new $walker_class_name,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> echo walk_nav_menu_tree( $menu_items, 0, (object) $args );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1474,6 +1540,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'edit_post', $pid ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_POST['metakeyselect'] ) && '#NONE#' == $_POST['metakeyselect'] && empty( $_POST['metakeyinput'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1490,6 +1557,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), gmdate( __( 'F j, Y' ), $now ), gmdate( __( 'g:i a' ), $now ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $pid = edit_post( $post_data );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $pid ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $pid ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $x = new WP_Ajax_Response(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1518,7 +1586,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $meta = get_metadata_by_mid( 'post', $mid );
</span><span class="cx" style="display: block; padding: 0 10px"> $pid = (int) $meta->post_id;
</span><span class="cx" style="display: block; padding: 0 10px"> $meta = get_object_vars( $meta );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $x = new WP_Ajax_Response(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $x = new WP_Ajax_Response(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'what' => 'meta',
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => $mid,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1531,18 +1600,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $mid = (int) key( $_POST['meta'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $key = wp_unslash( $_POST['meta'][ $mid ]['key'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $value = wp_unslash( $_POST['meta'][ $mid ]['value'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( '' == trim( $key ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( __( 'Please provide a custom field name.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $meta = get_metadata_by_mid( 'post', $mid );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $meta ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 ); // if meta doesn't exist
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) ||
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if (
+ is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) ||
</ins><span class="cx" style="display: block; padding: 0 10px"> ! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) ||
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ! current_user_can( 'edit_post_meta', $meta->post_id, $key )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $meta->meta_value != $value || $meta->meta_key != $key ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $u = update_metadata_by_mid( 'post', $mid, $value, $key );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $u ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1584,10 +1660,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( $action );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'create_users' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $user_id = edit_user();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $user_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( is_wp_error( $user_id ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1599,8 +1678,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $x->send();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_object = get_userdata( $user_id );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_object = get_userdata( $user_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_list_table = _get_list_table( 'WP_Users_List_Table' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $role = current( $user_object->roles );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1799,10 +1878,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'edit_theme_options' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $_POST['menu-locations'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1957,6 +2039,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $data['comment_status'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $data['comment_status'] = 'closed';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $data['ping_status'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $data['ping_status'] = 'closed';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2012,6 +2095,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy = sanitize_key( $_POST['taxonomy'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $tax = get_taxonomy( $taxonomy );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $tax ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2032,6 +2116,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['description'] = $tag->description;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $updated = wp_update_term( $id, $taxonomy, $_POST );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $updated && ! is_wp_error( $updated ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $tag = get_term( $updated['term_id'], $taxonomy );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $tag || is_wp_error( $tag ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2046,13 +2131,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( __( 'Item not updated.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $level = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> $parent = $tag->parent;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> while ( $parent > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $parent_tag = get_term( $parent, $taxonomy );
</span><span class="cx" style="display: block; padding: 0 10px"> $parent = $parent_tag->parent;
</span><span class="cx" style="display: block; padding: 0 10px"> $level++;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_list_table->single_row( $tag, $level );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2076,6 +2164,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'any',
</span><span class="cx" style="display: block; padding: 0 10px"> 'posts_per_page' => 50,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( '' !== $s ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $args['s'] = $s;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2141,10 +2230,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Save widgets order for all sidebars.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $_POST['sidebars'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $sidebars = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( wp_unslash( $_POST['sidebars'] ) as $key => $val ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $sb = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $val ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $val = explode( ',', $val );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $val as $k => $v ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( strpos( $v, 'widget-' ) === false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2155,6 +2247,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $sidebars[ $key ] = $sb;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_set_sidebars_widgets( $sidebars );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2321,6 +2414,82 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Ajax handler for creating missing image sub-sizes for just uploaded images.
+ *
+ * @since 5.3.0
+ */
+function wp_ajax_media_create_image_subsizes() {
+ check_ajax_referer( 'media-form' );
+
+ if ( ! current_user_can( 'upload_files' ) ) {
+ wp_send_json_error( array( 'message' => __( 'Sorry, you are not allowed to upload files.' ) ) );
+ }
+
+ // Using Plupload `file.id` as ref.
+ if ( ! empty( $_POST['_wp_temp_image_ref'] ) ) {
+ $image_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $_POST['_wp_temp_image_ref'] );
+ } else {
+ wp_send_json_error( array( 'message' => __( 'Invalid file reference.' ) ) );
+ }
+
+ // Uploading of images usually fails while creating the sub-sizes, either because of a timeout or out of memory.
+ // At this point the file has been uploaded and an attachment post created, but because of the PHP fatal error
+ // the cliend doesn't know the attachment ID yet.
+ // To be able to find the new attachment_id in these cases we temporarily store an upload reference sent by the client
+ // in the original upload request. It is used to save a transient with the attachment_id as value.
+ // That reference currently is Plupload's `file.id` but can be any sufficiently random alpha-numeric string.
+ $attachment_id = get_transient( '_wp_temp_image_ref:' . $image_ref );
+
+ if ( empty( $attachment_id ) ) {
+ wp_send_json_error( array( 'message' => __( 'Upload failed. Please reload and try again.' ) ) );
+ }
+
+ if ( ! empty( $_POST['_wp_upload_failed_cleanup'] ) ) {
+ // Upload failed. Cleanup.
+ if ( wp_attachment_is_image( $attachment_id ) ) {
+ $attachment = get_post( $attachment_id );
+
+ // Posted at most 10 min ago.
+ if ( $attachment && ( time() - strtotime( $attachment->post_date_gmt ) < 600 ) ) {
+ /**
+ * Runs when an image upload fails during the post-processing phase,
+ * and the newly created attachment post is about to be deleted.
+ *
+ * @since 5.3.0
+ *
+ * @param int $attachment_id The attachment post ID.
+ */
+ do_action( 'wp_upload_failed_cleanup', $attachment_id );
+
+ wp_delete_attachment( $attachment_id, true );
+ wp_send_json_success();
+ }
+ }
+ }
+
+ // This can still be pretty slow and cause timeout or out of memory errors.
+ // The js that handles the response would need to also handle HTTP 500 errors.
+ wp_update_image_subsizes( $attachment_id );
+
+ if ( ! empty( $_POST['_legasy_support'] ) ) {
+ // The old (inline) uploader. Only needs the attachment_id.
+ $response = array( 'id' => $attachment_id );
+ } else {
+ // Media modal and Media Library grid view.
+ $response = wp_prepare_attachment_for_js( $attachment_id );
+
+ if ( ! $response ) {
+ wp_send_json_error( array( 'message' => __( 'Upload failed.' ) ) );
+ }
+ }
+
+ // At this point the image has been uploaded successfully.
+ delete_transient( '_wp_temp_image_ref:' . $image_ref );
+
+ wp_send_json_success( $response );
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Ajax handler for uploading attachments
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.3.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2349,6 +2518,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_REQUEST['post_id'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = $_REQUEST['post_id'];
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'edit_post', $post_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo wp_json_encode(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2375,6 +2545,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // If the context is custom header or background, make sure the uploaded file is an image.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo wp_json_encode(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2438,6 +2609,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_ajax_image_editor() {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = intval( $_POST['postid'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2649,8 +2821,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_id = (int) $_POST['post_ID'];
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $post ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2662,6 +2836,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $active_lock[1] != get_current_user_id() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2686,6 +2861,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_ajax_dismiss_wp_pointer() {
</span><span class="cx" style="display: block; padding: 0 10px"> $pointer = $_POST['pointer'];
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $pointer != sanitize_key( $pointer ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2766,6 +2942,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'year',
</span><span class="cx" style="display: block; padding: 0 10px"> 'monthnum',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $t->query_var && isset( $query[ $t->query_var ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $keys[] = $t->query_var;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2774,9 +2951,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query = array_intersect_key( $query, array_flip( $keys ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $query['post_type'] = 'attachment';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( MEDIA_TRASH
- && ! empty( $_REQUEST['query']['post_status'] )
- && 'trash' === $_REQUEST['query']['post_status'] ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if (
+ MEDIA_TRASH &&
+ ! empty( $_REQUEST['query']['post_status'] ) &&
+ 'trash' === $_REQUEST['query']['post_status']
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $query['post_status'] = 'trash';
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $query['post_status'] = 'inherit';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2869,10 +3049,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( wp_attachment_is( 'audio', $post['ID'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $changed = false;
</span><span class="cx" style="display: block; padding: 0 10px"> $id3data = wp_get_attachment_metadata( $post['ID'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_array( $id3data ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $changed = true;
</span><span class="cx" style="display: block; padding: 0 10px"> $id3data = array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $changes[ $key ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $changed = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2912,6 +3094,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment_data = $_REQUEST['attachments'][ $id ];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( 'update-post_' . $id, 'nonce' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2943,6 +3126,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment = wp_prepare_attachment_for_js( $id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $attachment ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2981,10 +3165,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'edit_post', $attachment_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment = get_post( $attachment_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $attachment ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'attachment' != $attachment->post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3028,6 +3215,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( current_user_can( 'edit_post', $id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // If this attachment is unattached, attach it. Primarily a back compat thing.
</span><span class="cx" style="display: block; padding: 0 10px"> $insert_into_post_id = intval( $_POST['post_id'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 0 == $post->post_parent && $insert_into_post_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_post(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3346,6 +3534,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $update_php = network_admin_url( 'update.php?action=install-theme' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $api->themes as &$theme ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $theme->install_url = add_query_arg(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3390,7 +3579,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $theme->author = wp_kses( $theme->author['display_name'], $themes_allowedtags );
</span><span class="cx" style="display: block; padding: 0 10px"> $theme->version = wp_kses( $theme->version, $themes_allowedtags );
</span><span class="cx" style="display: block; padding: 0 10px"> $theme->description = wp_kses( $theme->description, $themes_allowedtags );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $theme->stars = wp_star_rating(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $theme->stars = wp_star_rating(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'rating' => $theme->rating,
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'percent',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3398,6 +3588,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'echo' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $theme->num_ratings = number_format_i18n( $theme->num_ratings );
</span><span class="cx" style="display: block; padding: 0 10px"> $theme->preview_url = set_url_scheme( $theme->preview_url );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3421,9 +3612,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $_POST['shortcode'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_id = isset( $_POST['post_ID'] ) ? intval( $_POST['post_ID'] ) : 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $post_id > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3436,6 +3630,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> preg_match( '/' . get_shortcode_regex() . '/s', $shortcode, $matches );
</span><span class="cx" style="display: block; padding: 0 10px"> $atts = shortcode_parse_atts( $matches[3] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $matches[5] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = $matches[5];
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( ! empty( $atts['src'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3493,6 +3688,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( has_shortcode( $parsed, 'audio' ) || has_shortcode( $parsed, 'video' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $styles = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $mce_styles = wpview_media_sandbox_styles();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $mce_styles as $style ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $styles .= sprintf( '<link rel="stylesheet" href="%s"/>', $style );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3500,9 +3696,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $html = do_shortcode( $parsed );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_scripts;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $wp_scripts ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_scripts->done = array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ob_start();
</span><span class="cx" style="display: block; padding: 0 10px"> wp_print_scripts( array( 'mediaelement-vimeo', 'wp-mediaelement' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $scripts = ob_get_clean();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3617,6 +3815,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_ajax_destroy_sessions() {
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_userdata( (int) $_POST['user_id'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $user ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'edit_user', $user->ID ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $user = false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3656,6 +3855,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = absint( $_POST['id'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> check_ajax_referer( 'image_editor-' . $attachment_id, 'nonce' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4046,9 +4246,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check filesystem credentials. `delete_theme()` will bail otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> $url = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ob_start();
</span><span class="cx" style="display: block; padding: 0 10px"> $credentials = request_filesystem_credentials( $url );
</span><span class="cx" style="display: block; padding: 0 10px"> ob_end_clean();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_filesystem;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4339,9 +4541,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check filesystem credentials. `delete_plugins()` will bail otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ob_start();
</span><span class="cx" style="display: block; padding: 0 10px"> $credentials = request_filesystem_credentials( $url );
</span><span class="cx" style="display: block; padding: 0 10px"> ob_end_clean();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_filesystem;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4481,6 +4685,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_ajax_edit_theme_plugin_file() {
</span><span class="cx" style="display: block; padding: 0 10px"> $r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); // Validation of args is done in wp_edit_theme_plugin_file().
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $r ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error(
</span><span class="cx" style="display: block; padding: 0 10px"> array_merge(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4510,6 +4715,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $_POST['id'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( __( 'Missing request ID.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $request_id = (int) $_POST['id'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $request_id < 1 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4537,11 +4743,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $_POST['exporter'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( __( 'Missing exporter index.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $exporter_index = (int) $_POST['exporter'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $_POST['page'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( __( 'Missing page index.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $page = (int) $_POST['page'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $send_as_email = isset( $_POST['sendAsEmail'] ) ? ( 'true' === $_POST['sendAsEmail'] ) : false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4595,6 +4803,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> sprintf( __( 'Expected an array describing the exporter at index %s.' ), $exporter_key )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! array_key_exists( 'exporter_friendly_name', $exporter ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error(
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Exporter array index. */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4610,6 +4819,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> sprintf( __( 'Exporter does not include a callback: %s.' ), esc_html( $exporter_friendly_name ) )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_callable( $exporter['callback'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error(
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Exporter friendly name. */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4630,6 +4840,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> sprintf( __( 'Expected response as an array from exporter: %s.' ), esc_html( $exporter_friendly_name ) )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! array_key_exists( 'data', $response ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error(
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Exporter friendly name. */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4636,6 +4847,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> sprintf( __( 'Expected data in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_array( $response['data'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error(
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Exporter friendly name. */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4642,6 +4854,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> sprintf( __( 'Expected data array in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! array_key_exists( 'done', $response ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error(
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Exporter friendly name. */
</span></span></pre></div>
<a id="trunksrcwpadminincludesimagephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/image.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/image.php 2019-09-03 00:56:42 UTC (rev 45933)
+++ trunk/src/wp-admin/includes/image.php 2019-09-04 01:10:57 UTC (rev 45934)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -131,18 +131,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.3.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $attachment_id The image attachment post ID.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array The updated image meta data array.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array|WP_Error The updated image meta data array or WP_Error object
+ * if both the image meta and the attached file are missing.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_update_image_subsizes( $attachment_id ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $image_meta = wp_get_attachment_metadata( $attachment_id );
+ $image_file = get_attached_file( $attachment_id );
+
+ if ( empty( $image_meta ) || ! is_array( $image_meta ) ) {
+ // Previously failed upload?
+ // If there is an uploaded file, make all sub-sizes and generate all of the attachment meta.
+ if ( ! empty( $image_file ) ) {
+ return wp_create_image_subsizes( $image_file, array(), $attachment_id );
+ } else {
+ return new WP_Error( 'invalid_attachment', __( 'The attached file cannot be found.' ) );
+ }
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $missing_sizes = wp_get_missing_image_subsizes( $attachment_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $image_meta = wp_get_attachment_metadata( $attachment_id );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $missing_sizes ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $image_meta;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $image_file = get_attached_file( $attachment_id );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // This also updates the image meta.
</span><span class="cx" style="display: block; padding: 0 10px"> return _wp_make_subsizes( $missing_sizes, $image_file, $image_meta, $attachment_id );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadminincludesmediaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/media.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/media.php 2019-09-03 00:56:42 UTC (rev 45933)
+++ trunk/src/wp-admin/includes/media.php 2019-09-04 01:10:57 UTC (rev 45934)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,6 +80,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $tabs ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo "<ul id='sidemenu'>\n";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $redir_tab ) && array_key_exists( $redir_tab, $tabs ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $current = $redir_tab;
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $tabs ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -108,6 +109,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $link = "<a href='" . esc_url( $href ) . "'$class>$text</a>";
</span><span class="cx" style="display: block; padding: 0 10px"> echo "\t<li id='" . esc_attr( "tab-$callback" ) . "'>$link</li>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> echo "</ul>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -265,10 +267,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function media_send_to_editor( $html ) {
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<script type="text/javascript">
-var win = window.dialogArguments || opener || parent || top;
-win.send_to_editor( <?php echo wp_json_encode( $html ); ?> );
-</script>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script type="text/javascript">
+ var win = window.dialogArguments || opener || parent || top;
+ win.send_to_editor( <?php echo wp_json_encode( $html ); ?> );
+ </script>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> exit;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -286,9 +288,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return int|WP_Error ID of the attachment or a WP_Error object on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrides = array( 'test_form' => false ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> $time = current_time( 'mysql' );
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $post ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // The post date doesn't usually matter for pages, so don't backdate this upload.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'page' !== $post->post_type && substr( $post->post_date, 0, 4 ) > 0 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -306,12 +308,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $ext = pathinfo( $name, PATHINFO_EXTENSION );
</span><span class="cx" style="display: block; padding: 0 10px"> $name = wp_basename( $name, ".$ext" );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $url = $file['url'];
- $type = $file['type'];
- $file = $file['file'];
- $title = sanitize_text_field( $name );
- $content = '';
- $excerpt = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $url = $file['url'];
+ $type = $file['type'];
+ $file = $file['file'];
+ $title = sanitize_text_field( $name );
+ $content = '';
+ $excerpt = '';
+ $image_ref = false;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( preg_match( '#^audio#', $type ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $meta = wp_read_audio_metadata( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -356,6 +359,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $meta['track_number'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $track_number = explode( '/', $meta['track_number'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $track_number[1] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: Audio file track information. 1: Audio track number, 2: Total audio tracks. */
</span><span class="cx" style="display: block; padding: 0 10px"> $content .= ' ' . sprintf( __( 'Track %1$s of %2$s.' ), number_format_i18n( $track_number[0] ), number_format_i18n( $track_number[1] ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -372,7 +376,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Use image exif/iptc data for title and caption defaults if possible.
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 0 === strpos( $type, 'image/' ) ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Image file reference passed by the uploader.
+ if ( ! empty( $_POST['_wp_temp_image_ref'] ) ) {
+ $image_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $_POST['_wp_temp_image_ref'] );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $image_meta = wp_read_image_metadata( $file );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $image_meta ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $title = $image_meta['title'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -401,13 +411,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $attachment['ID'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Save the data
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_attachment( $attachment, $file, $post_id, true );
- if ( ! is_wp_error( $id ) ) {
- wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
+
+ if ( ! is_wp_error( $attachment_id ) ) {
+ // If an image, keep the upload reference until all image sub-sizes are created.
+ if ( $image_ref ) {
+ set_transient( '_wp_temp_image_ref:' . $image_ref, $attachment_id, HOUR_IN_SECONDS );
+ }
+
+ // The image sub-sizes are created during wp_generate_attachment_metadata().
+ // This is generally slow and may cause timeouts or out of memory errors.
+ wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
+
+ // At this point the image is uploaded successfully even if there were specific errors or some sub-sizes were not created.
+ // The transient is not needed any more.
+ if ( $image_ref ) {
+ delete_transient( '_wp_temp_image_ref:' . $image_ref );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $id;
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $attachment_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -426,6 +449,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $time = current_time( 'mysql' );
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $post ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( substr( $post->post_date, 0, 4 ) > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $time = $post->post_date;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -433,6 +457,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $file = wp_handle_sideload( $file_array, $overrides, $time );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $file['error'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'upload_error', $file['error'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -445,10 +470,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Use image exif/iptc data for title and caption defaults if possible.
</span><span class="cx" style="display: block; padding: 0 10px"> $image_meta = wp_read_image_metadata( $file );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $image_meta ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $title = $image_meta['title'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( trim( $image_meta['caption'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $content = $image_meta['caption'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -474,12 +501,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $attachment['ID'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Save the attachment metadata
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_attachment( $attachment, $file, $post_id, true );
- if ( ! is_wp_error( $id ) ) {
- wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
+
+ if ( ! is_wp_error( $attachment_id ) ) {
+ wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $attachment_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -495,22 +523,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_iframe( $content_func ) {
</span><span class="cx" style="display: block; padding: 0 10px"> _wp_admin_html_begin();
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<title><?php bloginfo( 'name' ); ?> › <?php _e( 'Uploads' ); ?> — <?php _e( 'WordPress' ); ?></title>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <title><?php bloginfo( 'name' ); ?> › <?php _e( 'Uploads' ); ?> — <?php _e( 'WordPress' ); ?></title>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_style( 'colors' );
</span><span class="cx" style="display: block; padding: 0 10px"> // Check callback name for 'media'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) )
- || ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (
+ ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) ) ||
+ ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_style( 'deprecated-media' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_style( 'ie' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<script type="text/javascript">
-addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
-var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
-isRtl = <?php echo (int) is_rtl(); ?>;
-</script>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script type="text/javascript">
+ addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
+ var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
+ isRtl = <?php echo (int) is_rtl(); ?>;
+ </script>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /** This action is documented in wp-admin/admin-header.php */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'admin_enqueue_scripts', 'media-upload-popup' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -562,16 +593,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $body_id_attr = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $GLOBALS['body_id'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $body_id_attr = ' id="' . $GLOBALS['body_id'] . '"';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-</head>
-<body<?php echo $body_id_attr; ?> class="wp-core-ui no-js">
-<script type="text/javascript">
-document.body.className = document.body.className.replace('no-js', 'js');
-</script>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </head>
+ <body<?php echo $body_id_attr; ?> class="wp-core-ui no-js">
+ <script type="text/javascript">
+ document.body.className = document.body.className.replace('no-js', 'js');
+ </script>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $args = func_get_args();
</span><span class="cx" style="display: block; padding: 0 10px"> $args = array_slice( $args, 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> call_user_func_array( $content_func, $args );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -578,10 +612,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /** This action is documented in wp-admin/admin-footer.php */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'admin_print_footer_scripts' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
-</body>
-</html>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
+ </body>
+ </html>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -601,19 +636,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $instance++;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = $GLOBALS['post_ID'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_enqueue_media(
- array(
- 'post' => $post,
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_media( array( 'post' => $post ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $img = '<span class="wp-media-buttons-icon"></span> ';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $id_attribute = $instance === 1 ? ' id="insert-media-button"' : '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> printf(
</span><span class="cx" style="display: block; padding: 0 10px"> '<button type="button"%s class="button insert-media add_media" data-editor="%s">%s</button>',
</span><span class="cx" style="display: block; padding: 0 10px"> $id_attribute,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -620,6 +653,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> esc_attr( $editor_id ),
</span><span class="cx" style="display: block; padding: 0 10px"> $img . __( 'Add Media' )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the legacy (pre-3.5.0) media buttons.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -709,12 +743,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $attachment['post_content'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post['post_content'] = $attachment['post_content'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $attachment['post_title'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post['post_title'] = $attachment['post_title'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $attachment['post_excerpt'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post['post_excerpt'] = $attachment['post_excerpt'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $attachment['menu_order'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post['menu_order'] = $attachment['menu_order'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -739,6 +776,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $attachment['image_alt'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $image_alt = wp_unslash( $attachment['image_alt'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $image_alt != get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $image_alt = wp_strip_all_tags( $image_alt, true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -771,18 +809,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> win.tb_remove();
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> exit;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $send_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment = wp_unslash( $_POST['attachments'][ $send_id ] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $attachment['url'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $rel = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( strpos( $attachment['url'], 'attachment_id' ) || get_attachment_link( $send_id ) == $attachment['url'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $rel = " rel='attachment wp-att-" . esc_attr( $send_id ) . "'";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $html = "<a href='{$attachment['url']}'$rel>$html</a>";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -798,6 +839,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $attachment Array of attachment metadata.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $html = apply_filters( 'media_send_to_editor', $html, $send_id, $attachment );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return media_send_to_editor( $html );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -820,6 +862,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Upload File button was clicked
</span><span class="cx" style="display: block; padding: 0 10px"> $id = media_handle_upload( 'async-upload', $_REQUEST['post_id'] );
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $_FILES );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $errors['upload_error'] = $id;
</span><span class="cx" style="display: block; padding: 0 10px"> $id = false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -828,6 +871,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $_POST['insertonlybutton'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $src = $_POST['src'];
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $src ) && ! strpos( $src, '://' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $src = "http://$src";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -844,6 +888,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $type = 'file';
</span><span class="cx" style="display: block; padding: 0 10px"> $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $ext ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $ext_type = wp_ext2type( $ext );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'audio' == $ext_type || 'video' == $ext_type ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -867,10 +912,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $align = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $alt = esc_attr( wp_unslash( $_POST['alt'] ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_POST['align'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $align = esc_attr( wp_unslash( $_POST['align'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $class = " class='align$align'";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $src ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $html = "<img src='" . esc_url( $src ) . "' alt='$alt'$class />";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -895,6 +942,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_POST['save'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $errors['upload_notice'] = __( 'Saved.' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'admin-gallery' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return wp_iframe( 'media_upload_gallery_form', $errors );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( ! empty( $_POST ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -903,6 +951,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_string( $return ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $return ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $errors = $return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -910,9 +959,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'type_url' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $type = 'image';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'video', 'audio', 'file' ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $type = $_GET['type'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -937,6 +988,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Set variables for storage, fix file filename for query strings.
</span><span class="cx" style="display: block; padding: 0 10px"> preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $matches ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'image_sideload_failed', __( 'Invalid image URL' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -975,6 +1027,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $alt = isset( $desc ) ? esc_attr( $desc ) : '';
</span><span class="cx" style="display: block; padding: 0 10px"> $html = "<img src='$src' alt='$alt' />";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $html;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'image_sideload_failed' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -997,6 +1050,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_string( $return ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $return ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $errors = $return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1015,6 +1069,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function media_upload_library() {
</span><span class="cx" style="display: block; padding: 0 10px"> $errors = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $_POST ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $return = media_upload_form_handler();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1050,11 +1105,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'center' => __( 'Center' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'right' => __( 'Right' ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! array_key_exists( (string) $checked, $alignments ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $checked = 'none';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $out = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $alignments as $name => $label ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $name = esc_attr( $name );
</span><span class="cx" style="display: block; padding: 0 10px"> $out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" .
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1061,6 +1118,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ( $checked == $name ? " checked='checked'" : '' ) .
</span><span class="cx" style="display: block; padding: 0 10px"> " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return join( "\n", $out );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1095,6 +1153,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $check ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $check = get_user_setting( 'imgsize', 'medium' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $out = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $size_names as $size => $label ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1160,6 +1219,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $url = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $url_type == 'file' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = $file;
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $url_type == 'post' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1267,6 +1327,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function image_media_send_to_editor( $html, $attachment_id, $attachment ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $attachment_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = $attachment['url'];
</span><span class="cx" style="display: block; padding: 0 10px"> $align = ! empty( $attachment['align'] ) ? $attachment['align'] : 'none';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1293,6 +1354,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_int( $post ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $post ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = new WP_Post( (object) $post );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1338,17 +1400,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $t = (array) get_taxonomy( $taxonomy );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $t['public'] || ! $t['show_ui'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $t['label'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $t['label'] = $taxonomy;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $t['args'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $t['args'] = array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = get_object_term_cache( $post->ID, $taxonomy );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false === $terms ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = wp_get_object_terms( $post->ID, $taxonomy, $t['args'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1358,6 +1424,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $terms as $term ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $values[] = $term->slug;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $t['value'] = join( ', ', $values );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $form_fields[ $taxonomy ] = $t;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1370,6 +1437,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // This was formerly in image_attachment_fields_to_edit().
</span><span class="cx" style="display: block; padding: 0 10px"> if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $alt = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $alt ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $alt = '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1424,8 +1492,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_media_items( $post_id, $errors ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachments = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $post_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $post && $post->post_type == 'attachment' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachments = array( $post->ID => $post );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1451,7 +1521,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $attachment->post_status == 'trash' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $item ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress hidden'><div class='bar'></div></div><div id='media-upload-error-$id' class='hidden'></div><div class='filename hidden'></div>$item\n</div>";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1479,6 +1551,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $attachment_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $thumb_url ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $thumb_url = $thumb_url[0];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1525,8 +1598,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $parsed_args['toggle'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $class = empty( $parsed_args['errors'] ) ? 'startclosed' : 'startopen';
</span><span class="cx" style="display: block; padding: 0 10px"> $toggle_links = "
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
- <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
+ <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $class = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $toggle_links = '';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1553,6 +1626,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $media_dims = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $meta = wp_get_attachment_metadata( $post->ID );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $meta['width'], $meta['height'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> ";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1568,6 +1642,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $media_dims = apply_filters( 'media_meta', $media_dims, $post );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $image_edit_button = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( wp_attachment_is_image( $post->ID ) && wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $nonce = wp_create_nonce( "image_editor-$post->ID" );
</span><span class="cx" style="display: block; padding: 0 10px"> $image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1576,13 +1651,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_url = get_permalink( $attachment_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $item = "
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $type_html
- $toggle_links
- $order
- $display_title
- <table class='slidetoggle describe $class'>
- <thead class='media-item-info' id='media-head-$post->ID'>
- <tr>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $type_html
+ $toggle_links
+ $order
+ $display_title
+ <table class='slidetoggle describe $class'>
+ <thead class='media-item-info' id='media-head-$post->ID'>
+ <tr>
</ins><span class="cx" style="display: block; padding: 0 10px"> <td class='A1B1' id='thumbnail-head-$post->ID'>
</span><span class="cx" style="display: block; padding: 0 10px"> <p><a href='$attachment_url' target='_blank'><img class='thumbnail' src='$thumb_url' alt='' /></a></p>
</span><span class="cx" style="display: block; padding: 0 10px"> <p>$image_edit_button</p>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1591,11 +1666,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <p><strong>" . __( 'File name:' ) . "</strong> $filename</p>
</span><span class="cx" style="display: block; padding: 0 10px"> <p><strong>" . __( 'File type:' ) . "</strong> $post->post_mime_type</p>
</span><span class="cx" style="display: block; padding: 0 10px"> <p><strong>" . __( 'Upload date:' ) . '</strong> ' . mysql2date( __( 'F j, Y' ), $post->post_date ) . '</p>';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $media_dims ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $item .= '<p><strong>' . __( 'Dimensions:' ) . "</strong> $media_dims</p>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $item .= "</td></tr>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $item .= "</td></tr>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $item .= "
</span><span class="cx" style="display: block; padding: 0 10px"> </thead>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1640,11 +1716,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $thumbnail = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $calling_post_id = 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_GET['post_id'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $calling_post_id = absint( $_GET['post_id'] );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( isset( $_POST ) && count( $_POST ) ) {// Like for async-upload where $_GET['post_id'] isn't set
</span><span class="cx" style="display: block; padding: 0 10px"> $calling_post_id = $post->post_parent;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) )
</span><span class="cx" style="display: block; padding: 0 10px"> && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1658,6 +1736,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ( $parsed_args['send'] || $thumbnail || $delete ) && ! isset( $form_fields['buttons'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>" . $parsed_args['send'] . " $thumbnail $delete</td></tr>\n" );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $hidden_fields = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $form_fields as $id => $field ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1684,6 +1763,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $class .= $field['required'] ? ' form-required' : '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $item .= "\t\t<tr class='$class'>\n\t\t\t<th scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}{$required}</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $field[ $field['input'] ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $item .= $field[ $field['input'] ];
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $field['input'] == 'textarea' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1696,6 +1776,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "'{$required_attr} />";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $field['helps'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1727,6 +1808,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $form_fields['_final'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $item .= "\t</tbody>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $item .= "\t</table>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1770,17 +1852,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $args['in_modal'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $t = (array) get_taxonomy( $taxonomy );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $t['public'] || ! $t['show_ui'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $t['label'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $t['label'] = $taxonomy;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $t['args'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $t['args'] = array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = get_object_term_cache( $post->ID, $taxonomy );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false === $terms ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = wp_get_object_terms( $post->ID, $taxonomy, $t['args'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1790,6 +1876,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $terms as $term ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $values[] = $term->slug;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $t['value'] = join( ', ', $values );
</span><span class="cx" style="display: block; padding: 0 10px"> $t['taxonomy'] = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1831,6 +1918,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $hidden_fields = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $item = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $form_fields as $id => $field ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $id[0] == '_' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1876,9 +1964,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $item .= "<input type='text' class='text' id='$id_attr' name='$name' value='" . esc_attr( $field['value'] ) . "' $readonly{$required_attr} />";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $field['helps'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $item .= "</td>\n\t\t</tr>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $extra_rows = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1939,6 +2029,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<script type="text/javascript">post_id = ' . $post_id . ';</script>';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $_GET['chromeless'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<div id="media-upload-header">';
</span><span class="cx" style="display: block; padding: 0 10px"> the_media_upload_tabs();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1979,9 +2070,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $max_upload_size ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $max_upload_size = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-<div id="media-upload-notice">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div id="media-upload-notice">
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $errors['upload_notice'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1989,8 +2080,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-</div>
-<div id="media-upload-error">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </div>
+ <div id="media-upload-error">
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $errors['upload_error'] ) && is_wp_error( $errors['upload_error'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1998,8 +2089,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-</div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_multisite() && ! is_upload_space_available() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Fires when an upload will exceed the defined upload space quota for a network site.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2045,17 +2137,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'drop_element' => 'drag-drop-area',
</span><span class="cx" style="display: block; padding: 0 10px"> 'file_data_name' => 'async-upload',
</span><span class="cx" style="display: block; padding: 0 10px"> 'url' => $upload_action_url,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'filters' => array(
- 'max_file_size' => $max_upload_size . 'b',
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'filters' => array( 'max_file_size' => $max_upload_size . 'b' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'multipart_params' => $post_params,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos
</span><span class="cx" style="display: block; padding: 0 10px"> // when enabled. See #29602.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
- strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) {
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (
+ wp_is_mobile() &&
+ strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
+ strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $plupload_init['multi_selection'] = false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2069,24 +2161,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $plupload_init = apply_filters( 'plupload_init', $plupload_init );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-<script type="text/javascript">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script type="text/javascript">
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> // Verify size is an int. If not return default value.
</span><span class="cx" style="display: block; padding: 0 10px"> $large_size_h = absint( get_option( 'large_size_h' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $large_size_h ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $large_size_h = 1024;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $large_size_w = absint( get_option( 'large_size_w' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $large_size_w ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $large_size_w = 1024;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,
-wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>;
-</script>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,
+ wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>;
+ </script>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div id="plupload-upload-ui" class="hide-if-no-js">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div id="plupload-upload-ui" class="hide-if-no-js">
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Fires before the upload interface loads.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2095,14 +2190,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.3.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'pre-plupload-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div id="drag-drop-area">
- <div class="drag-drop-inside">
- <p class="drag-drop-info"><?php _e( 'Drop files to upload' ); ?></p>
- <p><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p>
- <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e( 'Select Files' ); ?>" class="button" /></p>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div id="drag-drop-area">
+ <div class="drag-drop-inside">
+ <p class="drag-drop-info"><?php _e( 'Drop files to upload' ); ?></p>
+ <p><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p>
+ <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e( 'Select Files' ); ?>" class="button" /></p>
+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-</div>
</del><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Fires after the upload interface loads.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2112,9 +2208,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'post-plupload-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-</div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div id="html-upload-ui" class="hide-if-js">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div id="html-upload-ui" class="hide-if-js">
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Fires before the upload button in the media upload interface.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2122,6 +2218,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'pre-html-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <p id="async-upload-wrap">
</span><span class="cx" style="display: block; padding: 0 10px"> <label class="screen-reader-text" for="async-upload"><?php _e( 'Upload' ); ?></label>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2137,8 +2234,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'post-html-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-</div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <p class="max-upload-size">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2189,27 +2287,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( get_user_setting( 'uploader' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $form_class .= ' html-uploader';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
+ <?php submit_button( '', 'hidden', 'save', false ); ?>
+ <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
+ <?php wp_nonce_field( 'media-form' ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
- <?php submit_button( '', 'hidden', 'save', false ); ?>
-<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
- <?php wp_nonce_field( 'media-form' ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <h3 class="media-title"><?php _e( 'Add media files from your computer' ); ?></h3>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<h3 class="media-title"><?php _e( 'Add media files from your computer' ); ?></h3>
-
</del><span class="cx" style="display: block; padding: 0 10px"> <?php media_upload_form( $errors ); ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<script type="text/javascript">
-jQuery(function($){
- var preloaded = $(".media-item.preloaded");
- if ( preloaded.length > 0 ) {
- preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
- }
- updateMediaForm();
-});
-</script>
-<div id="media-items">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script type="text/javascript">
+ jQuery(function($){
+ var preloaded = $(".media-item.preloaded");
+ if ( preloaded.length > 0 ) {
+ preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
+ }
+ updateMediaForm();
+ });
+ </script>
+ <div id="media-items">
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $id ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2221,13 +2319,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> exit;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-</div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<p class="savebutton ml-submit">
- <?php submit_button( __( 'Save all changes' ), '', 'save', false ); ?>
-</p>
-</form>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <p class="savebutton ml-submit">
+ <?php submit_button( __( 'Save all changes' ), '', 'save', false ); ?>
+ </p>
+ </form>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2257,17 +2356,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( get_user_setting( 'uploader' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $form_class .= ' html-uploader';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
+ <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
+ <?php wp_nonce_field( 'media-form' ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
-<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
- <?php wp_nonce_field( 'media-form' ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <h3 class="media-title"><?php _e( 'Insert media from another website' ); ?></h3>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<h3 class="media-title"><?php _e( 'Insert media from another website' ); ?></h3>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script type="text/javascript">
+ var addExtImage = {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<script type="text/javascript">
-var addExtImage = {
-
</del><span class="cx" style="display: block; padding: 0 10px"> width : '',
</span><span class="cx" style="display: block; padding: 0 10px"> height : '',
</span><span class="cx" style="display: block; padding: 0 10px"> align : 'alignnone',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2281,20 +2380,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( f.alt.value )
</span><span class="cx" style="display: block; padding: 0 10px"> alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php
- /** This filter is documented in wp-admin/includes/media.php */
- if ( ! apply_filters( 'disable_captions', '' ) ) {
- ?>
- if ( f.caption.value ) {
- caption = f.caption.value.replace(/\r\n|\r/g, '\n');
- caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
- return a.replace(/[\r\n\t]+/, ' ');
- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php
+ /** This filter is documented in wp-admin/includes/media.php */
+ if ( ! apply_filters( 'disable_captions', '' ) ) {
+ ?>
+ if ( f.caption.value ) {
+ caption = f.caption.value.replace(/\r\n|\r/g, '\n');
+ caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
+ return a.replace(/[\r\n\t]+/, ' ');
+ });
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- caption = caption.replace(/\s*\n\s*/g, '<br />');
- }
- <?php } ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ caption = caption.replace(/\s*\n\s*/g, '<br />');
+ }
+ <?php
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> cls = caption ? '' : ' class="'+t.align+'"';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> html = '<img alt="'+alt+'" src="'+f.src.value+'"'+cls+' width="'+t.width+'" height="'+t.height+'" />';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2348,17 +2449,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> t.preloadImg.onerror = t.resetImageData;
</span><span class="cx" style="display: block; padding: 0 10px"> t.preloadImg.src = src;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-};
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ };
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-jQuery(document).ready( function($) {
- $('.media-types input').click( function() {
- $('table.describe').toggleClass('not-image', $('#not-image').prop('checked') );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ jQuery(document).ready( function($) {
+ $('.media-types input').click( function() {
+ $('table.describe').toggleClass('not-image', $('#not-image').prop('checked') );
+ });
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-});
-</script>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </script>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div id="media-items">
-<div class="media-item media-blank">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div id="media-items">
+ <div class="media-item media-blank">
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the insert media from URL form HTML.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2368,10 +2469,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $form_html The insert from URL form HTML.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-</div>
-</div>
-</form>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </div>
+ </div>
+ </form>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2401,138 +2503,138 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( get_user_setting( 'uploader' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $form_class .= ' html-uploader';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script type="text/javascript">
+ jQuery(function($){
+ var preloaded = $(".media-item.preloaded");
+ if ( preloaded.length > 0 ) {
+ preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
+ updateMediaForm();
+ }
+ });
+ </script>
+ <div id="sort-buttons" class="hide-if-no-js">
+ <span>
+ <?php _e( 'All Tabs:' ); ?>
+ <a href="#" id="showall"><?php _e( 'Show' ); ?></a>
+ <a href="#" id="hideall" style="display:none;"><?php _e( 'Hide' ); ?></a>
+ </span>
+ <?php _e( 'Sort Order:' ); ?>
+ <a href="#" id="asc"><?php _e( 'Ascending' ); ?></a> |
+ <a href="#" id="desc"><?php _e( 'Descending' ); ?></a> |
+ <a href="#" id="clear"><?php _ex( 'Clear', 'verb' ); ?></a>
+ </div>
+ <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="gallery-form">
+ <?php wp_nonce_field( 'media-form' ); ?>
+ <?php //media_upload_form( $errors ); ?>
+ <table class="widefat">
+ <thead><tr>
+ <th><?php _e( 'Media' ); ?></th>
+ <th class="order-head"><?php _e( 'Order' ); ?></th>
+ <th class="actions-head"><?php _e( 'Actions' ); ?></th>
+ </tr></thead>
+ </table>
+ <div id="media-items">
+ <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?>
+ <?php echo get_media_items( $post_id, $errors ); ?>
+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<script type="text/javascript">
-jQuery(function($){
- var preloaded = $(".media-item.preloaded");
- if ( preloaded.length > 0 ) {
- preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
- updateMediaForm();
- }
-});
-</script>
-<div id="sort-buttons" class="hide-if-no-js">
-<span>
- <?php _e( 'All Tabs:' ); ?>
-<a href="#" id="showall"><?php _e( 'Show' ); ?></a>
-<a href="#" id="hideall" style="display:none;"><?php _e( 'Hide' ); ?></a>
-</span>
- <?php _e( 'Sort Order:' ); ?>
-<a href="#" id="asc"><?php _e( 'Ascending' ); ?></a> |
-<a href="#" id="desc"><?php _e( 'Descending' ); ?></a> |
-<a href="#" id="clear"><?php _ex( 'Clear', 'verb' ); ?></a>
-</div>
-<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="gallery-form">
- <?php wp_nonce_field( 'media-form' ); ?>
- <?php //media_upload_form( $errors ); ?>
-<table class="widefat">
-<thead><tr>
-<th><?php _e( 'Media' ); ?></th>
-<th class="order-head"><?php _e( 'Order' ); ?></th>
-<th class="actions-head"><?php _e( 'Actions' ); ?></th>
-</tr></thead>
-</table>
-<div id="media-items">
- <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?>
- <?php echo get_media_items( $post_id, $errors ); ?>
-</div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <p class="ml-submit">
+ <?php
+ submit_button(
+ __( 'Save all changes' ),
+ 'savebutton',
+ 'save',
+ false,
+ array(
+ 'id' => 'save-all',
+ 'style' => 'display: none;',
+ )
+ );
+ ?>
+ <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
+ <input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" />
+ <input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" />
+ </p>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<p class="ml-submit">
- <?php
- submit_button(
- __( 'Save all changes' ),
- 'savebutton',
- 'save',
- false,
- array(
- 'id' => 'save-all',
- 'style' => 'display: none;',
- )
- );
- ?>
-<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
-<input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" />
-<input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" />
-</p>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div id="gallery-settings" style="display:none;">
+ <div class="title"><?php _e( 'Gallery Settings' ); ?></div>
+ <table id="basic" class="describe"><tbody>
+ <tr>
+ <th scope="row" class="label">
+ <label>
+ <span class="alignleft"><?php _e( 'Link thumbnails to:' ); ?></span>
+ </label>
+ </th>
+ <td class="field">
+ <input type="radio" name="linkto" id="linkto-file" value="file" />
+ <label for="linkto-file" class="radio"><?php _e( 'Image File' ); ?></label>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div id="gallery-settings" style="display:none;">
-<div class="title"><?php _e( 'Gallery Settings' ); ?></div>
-<table id="basic" class="describe"><tbody>
- <tr>
- <th scope="row" class="label">
- <label>
- <span class="alignleft"><?php _e( 'Link thumbnails to:' ); ?></span>
- </label>
- </th>
- <td class="field">
- <input type="radio" name="linkto" id="linkto-file" value="file" />
- <label for="linkto-file" class="radio"><?php _e( 'Image File' ); ?></label>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />
+ <label for="linkto-post" class="radio"><?php _e( 'Attachment Page' ); ?></label>
+ </td>
+ </tr>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />
- <label for="linkto-post" class="radio"><?php _e( 'Attachment Page' ); ?></label>
- </td>
- </tr>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <tr>
+ <th scope="row" class="label">
+ <label>
+ <span class="alignleft"><?php _e( 'Order images by:' ); ?></span>
+ </label>
+ </th>
+ <td class="field">
+ <select id="orderby" name="orderby">
+ <option value="menu_order" selected="selected"><?php _e( 'Menu order' ); ?></option>
+ <option value="title"><?php _e( 'Title' ); ?></option>
+ <option value="post_date"><?php _e( 'Date/Time' ); ?></option>
+ <option value="rand"><?php _e( 'Random' ); ?></option>
+ </select>
+ </td>
+ </tr>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <tr>
- <th scope="row" class="label">
- <label>
- <span class="alignleft"><?php _e( 'Order images by:' ); ?></span>
- </label>
- </th>
- <td class="field">
- <select id="orderby" name="orderby">
- <option value="menu_order" selected="selected"><?php _e( 'Menu order' ); ?></option>
- <option value="title"><?php _e( 'Title' ); ?></option>
- <option value="post_date"><?php _e( 'Date/Time' ); ?></option>
- <option value="rand"><?php _e( 'Random' ); ?></option>
- </select>
- </td>
- </tr>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <tr>
+ <th scope="row" class="label">
+ <label>
+ <span class="alignleft"><?php _e( 'Order:' ); ?></span>
+ </label>
+ </th>
+ <td class="field">
+ <input type="radio" checked="checked" name="order" id="order-asc" value="asc" />
+ <label for="order-asc" class="radio"><?php _e( 'Ascending' ); ?></label>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <tr>
- <th scope="row" class="label">
- <label>
- <span class="alignleft"><?php _e( 'Order:' ); ?></span>
- </label>
- </th>
- <td class="field">
- <input type="radio" checked="checked" name="order" id="order-asc" value="asc" />
- <label for="order-asc" class="radio"><?php _e( 'Ascending' ); ?></label>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <input type="radio" name="order" id="order-desc" value="desc" />
+ <label for="order-desc" class="radio"><?php _e( 'Descending' ); ?></label>
+ </td>
+ </tr>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <input type="radio" name="order" id="order-desc" value="desc" />
- <label for="order-desc" class="radio"><?php _e( 'Descending' ); ?></label>
- </td>
- </tr>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <tr>
+ <th scope="row" class="label">
+ <label>
+ <span class="alignleft"><?php _e( 'Gallery columns:' ); ?></span>
+ </label>
+ </th>
+ <td class="field">
+ <select id="columns" name="columns">
+ <option value="1">1</option>
+ <option value="2">2</option>
+ <option value="3" selected="selected">3</option>
+ <option value="4">4</option>
+ <option value="5">5</option>
+ <option value="6">6</option>
+ <option value="7">7</option>
+ <option value="8">8</option>
+ <option value="9">9</option>
+ </select>
+ </td>
+ </tr>
+ </tbody></table>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <tr>
- <th scope="row" class="label">
- <label>
- <span class="alignleft"><?php _e( 'Gallery columns:' ); ?></span>
- </label>
- </th>
- <td class="field">
- <select id="columns" name="columns">
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3" selected="selected">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- <option value="6">6</option>
- <option value="7">7</option>
- <option value="8">8</option>
- <option value="9">9</option>
- </select>
- </td>
- </tr>
-</tbody></table>
-
-<p class="ml-submit">
-<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" />
-<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" />
-</p>
-</div>
-</form>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <p class="ml-submit">
+ <input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" />
+ <input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" />
+ </p>
+ </div>
+ </form>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2580,175 +2682,174 @@
</span><span class="cx" style="display: block; padding: 0 10px"> list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query( $q );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <form id="filter" method="get">
+ <input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" />
+ <input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
+ <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
+ <input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" />
+ <input type="hidden" name="context" value="<?php echo isset( $_GET['context'] ) ? esc_attr( $_GET['context'] ) : ''; ?>" />
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<form id="filter" method="get">
-<input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" />
-<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
-<input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
-<input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" />
-<input type="hidden" name="context" value="<?php echo isset( $_GET['context'] ) ? esc_attr( $_GET['context'] ) : ''; ?>" />
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <p id="media-search" class="search-box">
+ <label class="screen-reader-text" for="media-search-input"><?php _e( 'Search Media' ); ?>:</label>
+ <input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
+ <?php submit_button( __( 'Search Media' ), '', '', false ); ?>
+ </p>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<p id="media-search" class="search-box">
- <label class="screen-reader-text" for="media-search-input"><?php _e( 'Search Media' ); ?>:</label>
- <input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
- <?php submit_button( __( 'Search Media' ), '', '', false ); ?>
-</p>
-
-<ul class="subsubsub">
- <?php
- $type_links = array();
- $_num_posts = (array) wp_count_attachments();
- $matches = wp_match_mime_types( array_keys( $post_mime_types ), array_keys( $_num_posts ) );
- foreach ( $matches as $_type => $reals ) {
- foreach ( $reals as $real ) {
- if ( isset( $num_posts[ $_type ] ) ) {
- $num_posts[ $_type ] += $_num_posts[ $real ];
- } else {
- $num_posts[ $_type ] = $_num_posts[ $real ];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <ul class="subsubsub">
+ <?php
+ $type_links = array();
+ $_num_posts = (array) wp_count_attachments();
+ $matches = wp_match_mime_types( array_keys( $post_mime_types ), array_keys( $_num_posts ) );
+ foreach ( $matches as $_type => $reals ) {
+ foreach ( $reals as $real ) {
+ if ( isset( $num_posts[ $_type ] ) ) {
+ $num_posts[ $_type ] += $_num_posts[ $real ];
+ } else {
+ $num_posts[ $_type ] = $_num_posts[ $real ];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
- // If available type specified by media button clicked, filter by that type
- if ( empty( $_GET['post_mime_type'] ) && ! empty( $num_posts[ $type ] ) ) {
- $_GET['post_mime_type'] = $type;
- list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
- }
- if ( empty( $_GET['post_mime_type'] ) || $_GET['post_mime_type'] == 'all' ) {
- $class = ' class="current"';
- } else {
- $class = '';
- }
- $type_links[] = '<li><a href="' . esc_url(
- add_query_arg(
- array(
- 'post_mime_type' => 'all',
- 'paged' => false,
- 'm' => false,
- )
- )
- ) . '"' . $class . '>' . __( 'All Types' ) . '</a>';
- foreach ( $post_mime_types as $mime_type => $label ) {
- $class = '';
-
- if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) {
- continue;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If available type specified by media button clicked, filter by that type
+ if ( empty( $_GET['post_mime_type'] ) && ! empty( $num_posts[ $type ] ) ) {
+ $_GET['post_mime_type'] = $type;
+ list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- if ( isset( $_GET['post_mime_type'] ) && wp_match_mime_types( $mime_type, $_GET['post_mime_type'] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $_GET['post_mime_type'] ) || $_GET['post_mime_type'] == 'all' ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $class = ' class="current"';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } else {
+ $class = '';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> $type_links[] = '<li><a href="' . esc_url(
</span><span class="cx" style="display: block; padding: 0 10px"> add_query_arg(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_mime_type' => $mime_type,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_mime_type' => 'all',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'paged' => false,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'm' => false,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ) . '"' . $class . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[ $mime_type ] ), '<span id="' . $mime_type . '-counter">' . number_format_i18n( $num_posts[ $mime_type ] ) . '</span>' ) . '</a>';
- }
- /**
- * Filters the media upload mime type list items.
- *
- * Returned values should begin with an `<li>` tag.
- *
- * @since 3.1.0
- *
- * @param string[] $type_links An array of list items containing mime type link HTML.
- */
- echo implode( ' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
- unset( $type_links );
- ?>
-</ul>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) . '"' . $class . '>' . __( 'All Types' ) . '</a>';
+ foreach ( $post_mime_types as $mime_type => $label ) {
+ $class = '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div class="tablenav">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) {
+ continue;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php
- $page_links = paginate_links(
- array(
- 'base' => add_query_arg( 'paged', '%#%' ),
- 'format' => '',
- 'prev_text' => __( '«' ),
- 'next_text' => __( '»' ),
- 'total' => ceil( $wp_query->found_posts / 10 ),
- 'current' => $q['paged'],
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $_GET['post_mime_type'] ) && wp_match_mime_types( $mime_type, $_GET['post_mime_type'] ) ) {
+ $class = ' class="current"';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $page_links ) {
- echo "<div class='tablenav-pages'>$page_links</div>";
- }
- ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $type_links[] = '<li><a href="' . esc_url(
+ add_query_arg(
+ array(
+ 'post_mime_type' => $mime_type,
+ 'paged' => false,
+ )
+ )
+ ) . '"' . $class . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[ $mime_type ] ), '<span id="' . $mime_type . '-counter">' . number_format_i18n( $num_posts[ $mime_type ] ) . '</span>' ) . '</a>';
+ }
+ /**
+ * Filters the media upload mime type list items.
+ *
+ * Returned values should begin with an `<li>` tag.
+ *
+ * @since 3.1.0
+ *
+ * @param string[] $type_links An array of list items containing mime type link HTML.
+ */
+ echo implode( ' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
+ unset( $type_links );
+ ?>
+ </ul>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div class="alignleft actions">
- <?php
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="tablenav">
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php
+ $page_links = paginate_links(
+ array(
+ 'base' => add_query_arg( 'paged', '%#%' ),
+ 'format' => '',
+ 'prev_text' => __( '«' ),
+ 'next_text' => __( '»' ),
+ 'total' => ceil( $wp_query->found_posts / 10 ),
+ 'current' => $q['paged'],
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $arc_result = $wpdb->get_results( $arc_query );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $page_links ) {
+ echo "<div class='tablenav-pages'>$page_links</div>";
+ }
+ ?>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $month_count = count( $arc_result );
- $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0;
-
- if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
- ?>
-<select name='m'>
-<option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="alignleft actions">
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $arc_result as $arc_row ) {
- if ( $arc_row->yyear == 0 ) {
- continue;
- }
- $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) {
- $default = ' selected="selected"';
- } else {
- $default = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
+
+ $arc_result = $wpdb->get_results( $arc_query );
+
+ $month_count = count( $arc_result );
+ $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0;
+
+ if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
+ ?>
+ <select name='m'>
+ <option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option>
+ <?php
+
+ foreach ( $arc_result as $arc_row ) {
+ if ( $arc_row->yyear == 0 ) {
+ continue;
+ }
+
+ $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
+
+ if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) {
+ $default = ' selected="selected"';
+ } else {
+ $default = '';
+ }
+
+ echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
+ echo esc_html( $wp_locale->get_month( $arc_row->mmonth ) . " $arc_row->yyear" );
+ echo "</option>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
- echo esc_html( $wp_locale->get_month( $arc_row->mmonth ) . " $arc_row->yyear" );
- echo "</option>\n";
- }
- ?>
-</select>
- <?php } ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ?>
+ </select>
+ <?php } ?>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php submit_button( __( 'Filter »' ), '', 'post-query-submit', false ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php submit_button( __( 'Filter »' ), '', 'post-query-submit', false ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-</div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<br class="clear" />
-</div>
-</form>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <br class="clear" />
+ </div>
+ </form>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form">
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form">
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php wp_nonce_field( 'media-form' ); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php //media_upload_form( $errors ); ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<script type="text/javascript">
-<!--
-jQuery(function($){
- var preloaded = $(".media-item.preloaded");
- if ( preloaded.length > 0 ) {
- preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
- updateMediaForm();
- }
-});
--->
-</script>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script type="text/javascript">
+ jQuery(function($){
+ var preloaded = $(".media-item.preloaded");
+ if ( preloaded.length > 0 ) {
+ preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
+ updateMediaForm();
+ }
+ });
+ </script>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div id="media-items">
- <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?>
- <?php echo get_media_items( null, $errors ); ?>
-</div>
-<p class="ml-submit">
- <?php submit_button( __( 'Save all changes' ), 'savebutton', 'save', false ); ?>
-<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
-</p>
-</form>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div id="media-items">
+ <?php add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 ); ?>
+ <?php echo get_media_items( null, $errors ); ?>
+ </div>
+ <p class="ml-submit">
+ <?php submit_button( __( 'Save all changes' ), 'savebutton', 'save', false ); ?>
+ <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
+ </p>
+ </form>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2769,13 +2870,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <label for="caption"><span class="alignleft">' . __( 'Image Caption' ) . '</span></label>
</span><span class="cx" style="display: block; padding: 0 10px"> </th>
</span><span class="cx" style="display: block; padding: 0 10px"> <td class="field"><textarea id="caption" name="caption"></textarea></td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- </tr>
-';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </tr>';
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $caption = '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $default_align = get_option( 'image_default_align' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $default_align ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $default_align = 'none';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2856,9 +2957,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ' . get_submit_button( __( 'Insert into Post' ), '', 'insertonlybutton', false ) . '
</span><span class="cx" style="display: block; padding: 0 10px"> </td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- </tbody></table>
-';
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </tbody></table>';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2926,14 +3025,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $a = '<a href="' . esc_url( admin_url( 'options-media.php' ) ) . '" target="_blank">';
</span><span class="cx" style="display: block; padding: 0 10px"> $end = '</a>';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<p class="hide-if-no-js"><label>
-<input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <p class="hide-if-no-js"><label>
+ <input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: 1: Link start tag, 2: Link end tag, 3: Width, 4: Height. */
</span><span class="cx" style="display: block; padding: 0 10px"> printf( __( 'Scale images to match the large size selected in %1$simage options%2$s (%3$d × %4$d).' ), $a, $end, (int) get_option( 'large_size_w', '1024' ), (int) get_option( 'large_size_h', '1024' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-</label></p>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </label></p>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2959,6 +3060,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function edit_form_image_editor( $post ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $open = isset( $_GET['image-editor'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $open ) {
</span><span class="cx" style="display: block; padding: 0 10px"> require_once ABSPATH . 'wp-admin/includes/image-edit.php';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2965,6 +3067,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $thumb_url = false;
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = intval( $post->ID );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $attachment_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2975,6 +3078,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="wp_attachment_holder wp-clearfix">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( wp_attachment_is_image( $post->ID ) ) :
</span><span class="cx" style="display: block; padding: 0 10px"> $image_edit_button = '';
</span><span class="cx" style="display: block; padding: 0 10px"> if ( wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2984,13 +3088,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $open_style = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $not_open_style = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $open ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $open_style = ' style="display:none"';
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $not_open_style = ' style="display:none"';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <div<?php echo $open_style; ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php echo $attachment_id; ?>">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2998,10 +3103,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <p><?php echo $image_edit_button; ?></p>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <div<?php echo $not_open_style; ?> class="image-editor" id="image-editor-<?php echo $attachment_id; ?>">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php
- if ( $open ) {
- wp_image_editor( $attachment_id );}
- ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php
+
+ if ( $open ) {
+ wp_image_editor( $attachment_id );
+ }
+
+ ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> elseif ( $attachment_id && wp_attachment_is( 'audio', $post ) ) :
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3017,11 +3125,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $meta = wp_get_attachment_metadata( $attachment_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $w = ! empty( $meta['width'] ) ? min( $meta['width'], 640 ) : 0;
</span><span class="cx" style="display: block; padding: 0 10px"> $h = ! empty( $meta['height'] ) ? $meta['height'] : 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $h && $w < $meta['width'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $h = round( ( $meta['height'] * $w ) / $meta['width'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $attr = array( 'src' => $att_url );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $w ) && ! empty( $h ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $attr['width'] = $w;
</span><span class="cx" style="display: block; padding: 0 10px"> $attr['height'] = $h;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3028,6 +3138,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $thumb_id = get_post_thumbnail_id( $attachment_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $thumb_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $attr['poster'] = wp_get_attachment_url( $thumb_id );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3035,7 +3146,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> echo wp_video_shortcode( $attr );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> elseif ( isset( $thumb_url[0] ) ) :
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="wp_attachment_image wp-clearfix" id="media-head-<?php echo $attachment_id; ?>">
</span><span class="cx" style="display: block; padding: 0 10px"> <p id="thumbnail-head-<?php echo $attachment_id; ?>">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3056,6 +3166,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'wp_edit_form_attachment_display', $post );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> endif;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="wp_attachment_details edit-form-section">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3065,19 +3176,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php echo esc_attr( $alt_text ); ?>" />
</span><span class="cx" style="display: block; padding: 0 10px"> </p>
</span><span class="cx" style="display: block; padding: 0 10px"> <p class="attachment-alt-text-description" id="alt-text-description">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php
- printf(
- /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
- __( '<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.' ),
- esc_url( 'https://www.w3.org/WAI/tutorials/images/decision-tree' ),
- 'target="_blank" rel="noopener noreferrer"',
- sprintf(
- '<span class="screen-reader-text"> %s</span>',
- /* translators: Accessibility text. */
- __( '(opens in a new tab)' )
- )
- );
- ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php
+
+ printf(
+ /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
+ __( '<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.' ),
+ esc_url( 'https://www.w3.org/WAI/tutorials/images/decision-tree' ),
+ 'target="_blank" rel="noopener noreferrer"',
+ sprintf(
+ '<span class="screen-reader-text"> %s</span>',
+ /* translators: Accessibility text. */
+ __( '(opens in a new tab)' )
+ )
+ );
+
+ ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </p>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3087,27 +3200,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </p>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
- $editor_args = array(
- 'textarea_name' => 'content',
- 'textarea_rows' => 5,
- 'media_buttons' => false,
- 'tinymce' => false,
- 'quicktags' => $quicktags_settings,
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
+ $editor_args = array(
+ 'textarea_name' => 'content',
+ 'textarea_rows' => 5,
+ 'media_buttons' => false,
+ 'tinymce' => false,
+ 'quicktags' => $quicktags_settings,
+ );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <label for="attachment_content"><strong><?php _e( 'Description' ); ?></strong>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php
- if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
- echo ': ' . __( 'Displayed on attachment pages.' );
- }
- ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php
+
+ if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
+ echo ': ' . __( 'Displayed on attachment pages.' );
+ }
+
+ ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </label>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $extras = get_compat_media_markup( $post->ID );
</span><span class="cx" style="display: block; padding: 0 10px"> echo $extras['item'];
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3119,20 +3237,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function attachment_submitbox_metadata() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = get_post();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post();
+ $attachment_id = $post->ID;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $file = get_attached_file( $post->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $file = get_attached_file( $attachment_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $filename = esc_html( wp_basename( $file ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $media_dims = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = wp_get_attachment_metadata( $post->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = wp_get_attachment_metadata( $attachment_id );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $meta['width'], $meta['height'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> ";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $media_dims .= "<span id='media-dims-$attachment_id'>{$meta['width']} × {$meta['height']}</span> ";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in wp-admin/includes/media.php */
</span><span class="cx" style="display: block; padding: 0 10px"> $media_dims = apply_filters( 'media_meta', $media_dims, $post );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $att_url = wp_get_attachment_url( $post->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $att_url = wp_get_attachment_url( $attachment_id );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="misc-pub-section misc-pub-attachment">
</span><span class="cx" style="display: block; padding: 0 10px"> <label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3142,26 +3263,30 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="misc-pub-section misc-pub-filetype">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php _e( 'File type:' ); ?> <strong>
- <?php
- if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) {
- echo esc_html( strtoupper( $matches[1] ) );
- list( $mime_type ) = explode( '/', $post->post_mime_type );
- if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) {
- if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) {
- echo ' (' . $meta['mime_type'] . ')';
- }
- }
- } else {
- echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) );
- }
- ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php _e( 'File type:' ); ?>
+ <strong>
+ <?php
+
+ if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) {
+ echo esc_html( strtoupper( $matches[1] ) );
+ list( $mime_type ) = explode( '/', $post->post_mime_type );
+ if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) {
+ if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) {
+ echo ' (' . $meta['mime_type'] . ')';
+ }
+ }
+ } else {
+ echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) );
+ }
+
+ ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </strong>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $file_size = false;
</del><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $file_size = false;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $meta['filesize'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $file_size = $meta['filesize'];
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( file_exists( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3168,13 +3293,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $file_size = filesize( $file );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! empty( $file_size ) ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $file_size ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <div class="misc-pub-section misc-pub-filesize">
- <?php _e( 'File size:' ); ?> <strong><?php echo size_format( $file_size ); ?></strong>
- </div>
- <?php
- endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="misc-pub-section misc-pub-filesize">
+ <?php _e( 'File size:' ); ?> <strong><?php echo size_format( $file_size ); ?></strong>
+ </div>
+ <?php
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3200,24 +3325,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $meta[ $key ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>">
- <?php echo $label; ?> <strong>
- <?php
- switch ( $key ) {
- case 'bitrate':
- echo round( $meta['bitrate'] / 1000 ) . 'kb/s';
- if ( ! empty( $meta['bitrate_mode'] ) ) {
- echo ' ' . strtoupper( esc_html( $meta['bitrate_mode'] ) );
- }
- break;
- default:
- echo esc_html( $meta[ $key ] );
- break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="misc-pub-section misc-pub-mime-meta misc-pub-<?php echo sanitize_html_class( $key ); ?>">
+ <?php echo $label; ?>
+ <strong>
+ <?php
+
+ switch ( $key ) {
+ case 'bitrate':
+ echo round( $meta['bitrate'] / 1000 ) . 'kb/s';
+ if ( ! empty( $meta['bitrate_mode'] ) ) {
+ echo ' ' . strtoupper( esc_html( $meta['bitrate_mode'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ?>
- </strong>
- </div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ break;
+ default:
+ echo esc_html( $meta[ $key ] );
+ break;
+ }
+
+ ?>
+ </strong>
+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3244,21 +3373,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $meta['audio'][ $key ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>">
- <?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][ $key ] ); ?></strong>
- </div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="misc-pub-section misc-pub-audio misc-pub-<?php echo sanitize_html_class( $key ); ?>">
+ <?php echo $label; ?> <strong><?php echo esc_html( $meta['audio'][ $key ] ); ?></strong>
+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $media_dims ) :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $media_dims ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <div class="misc-pub-section misc-pub-dimensions">
- <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
- </div>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="misc-pub-section misc-pub-dimensions">
+ <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong>
+ </div>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- endif;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3328,6 +3458,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! class_exists( 'getID3', false ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> require( ABSPATH . WPINC . '/ID3/getid3.php' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $id3 = new getID3();
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $id3->analyze( $file );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3334,39 +3465,51 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $data['video']['lossless'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['lossless'] = $data['video']['lossless'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['video']['bitrate'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['bitrate'] = (int) $data['video']['bitrate'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['video']['bitrate_mode'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['bitrate_mode'] = $data['video']['bitrate_mode'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['filesize'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['filesize'] = (int) $data['filesize'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['mime_type'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['mime_type'] = $data['mime_type'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['playtime_seconds'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['length'] = (int) round( $data['playtime_seconds'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['playtime_string'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['length_formatted'] = $data['playtime_string'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['video']['resolution_x'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['width'] = (int) $data['video']['resolution_x'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['video']['resolution_y'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['height'] = (int) $data['video']['resolution_y'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['fileformat'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['fileformat'] = $data['fileformat'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['video']['dataformat'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['dataformat'] = $data['video']['dataformat'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['video']['encoder'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['encoder'] = $data['video']['encoder'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['video']['codec'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['codec'] = $data['video']['codec'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3416,6 +3559,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! file_exists( $file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $metadata = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! defined( 'GETID3_TEMP_DIR' ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3425,6 +3569,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! class_exists( 'getID3', false ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> require( ABSPATH . WPINC . '/ID3/getid3.php' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $id3 = new getID3();
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $id3->analyze( $file );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3436,15 +3581,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['fileformat'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['fileformat'] = $data['fileformat'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['filesize'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['filesize'] = (int) $data['filesize'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['mime_type'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['mime_type'] = $data['mime_type'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['playtime_seconds'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['length'] = (int) round( $data['playtime_seconds'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $data['playtime_string'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata['length_formatted'] = $data['playtime_string'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3531,7 +3680,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'edit_post', $parent_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $ids = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $_REQUEST['media'] as $att_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $att_id = (int) $att_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3544,6 +3695,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $ids ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $ids_string = implode( ',', $ids );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'attach' === $action ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $ids_string )", $parent_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3558,6 +3710,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $result ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $location = 'upload.php';
</span><span class="cx" style="display: block; padding: 0 10px"> $referer = wp_get_referer();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $referer ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false !== strpos( $referer, 'upload.php' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $location = remove_query_arg( array( 'attached', 'detach' ), $referer );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3566,6 +3719,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $key = 'attach' === $action ? 'attached' : 'detach';
</span><span class="cx" style="display: block; padding: 0 10px"> $location = add_query_arg( array( $key => $result ), $location );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_redirect( $location );
</span><span class="cx" style="display: block; padding: 0 10px"> exit;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php 2019-09-03 00:56:42 UTC (rev 45933)
+++ trunk/src/wp-includes/script-loader.php 2019-09-04 01:10:57 UTC (rev 45934)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1125,7 +1125,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'default_error' => __( 'An error occurred in the upload. Please try again later.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'missing_upload_url' => __( 'There was a configuration error. Please contact the server administrator.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'upload_limit_exceeded' => __( 'You may only upload 1 file.' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'http_error' => __( 'HTTP error.' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'http_error' => __( 'Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.' ),
+ 'http_error_image' => __( 'Post-processing of the image failed. If this is a photo or a large image, please scale it down to 2500px and upload it again.' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'upload_failed' => __( 'Upload failed.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: 1: Opening link tag, 2: Closing link tag. */
</span><span class="cx" style="display: block; padding: 0 10px"> 'big_upload_failed' => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.' ),
</span></span></pre>
</div>
</div>
</body>
</html>