From 23013c544aaca10c0e36e9e02a51bb8f7bfcc6c7 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 7 Oct 2013 19:01:48 +0000 Subject: [PATCH] Prevent the removal of a manual 'orderby' attribute in the gallery shortcode. props nofearinc. fixes #24868. git-svn-id: https://develop.svn.wordpress.org/trunk@25720 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-editor.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/wp-includes/js/media-editor.js b/src/wp-includes/js/media-editor.js index fc497cd84d..5e2a5fa629 100644 --- a/src/wp-includes/js/media-editor.js +++ b/src/wp-includes/js/media-editor.js @@ -236,6 +236,9 @@ args.perPage = -1; // Mark the `orderby` override attribute. + if( undefined !== attrs.orderby ) + attrs._orderByField = attrs.orderby; + if ( 'rand' === attrs.orderby ) attrs._orderbyRandom = true; @@ -283,9 +286,15 @@ attrs.id = props.uploadedTo; // Check if the gallery is randomly ordered. + delete attrs.orderby; + if ( attrs._orderbyRandom ) attrs.orderby = 'rand'; + else if ( attrs._orderByField && attrs._orderByField != 'rand' ) + attrs.orderby = attrs._orderByField; + delete attrs._orderbyRandom; + delete attrs._orderByField; // If the `ids` attribute is set and `orderby` attribute // is the default value, clear it for cleaner output.