Make WordPress Core

Opened 9 months ago

Closed 6 months ago

#24868 closed defect (bug) (fixed)

Gallery shortcode removes orderby

Reported by: markoheijnen Owned by: nacin
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords: has-patch commit
Focuses: Cc:


WordPress doesn't support it anymore but when old shortcode still have the orderby value in the shortcode it gets removed when updating the gallery. It's still used in the shortcode and people still can add it manually when using the text editor

Attachments (1)

24868.diff (1.0 KB) - added by nofearinc 9 months ago.

Download all attachments as: .zip

Change History (9)

nofearinc9 months ago

comment:1 nofearinc9 months ago

This is not exactly a great fix, but I wasn't able to find a better solution.

The problem was that all orderby actions are oriented around the Random Order checkbox in the gallery manager. Whenever "Random Order" is checked, the orderby attribute is placed with a value of "rand" and if the checkbox is empty, then no orderby attribute is set.

The patch is adding another field that keeps the old value for persistence. If the "Random Order" value is not checked, the old orderby value is stored. If it is checked, then the value is updated - and finally if it was checked, but then unchecked, the orderby is cleared.

comment:2 nofearinc9 months ago

  • Cc mario@… added

comment:3 markoheijnen9 months ago

  • Cc koopersmith added
  • Keywords has-patch added; needs-patch removed

comment:4 markoheijnen9 months ago

  • Milestone changed from Awaiting Review to 3.7

comment:5 nacin7 months ago

This is not exactly a great fix, but I wasn't able to find a better solution.

Agree with the sentiment. Looks good at a glance.

comment:6 markoheijnen6 months ago

I just checked the code and to me it's good to go in.

comment:7 johnbillion6 months ago

  • Keywords commit added

Just chatted with Marko on this. Tested and confirmed as working.

comment:8 nacin6 months ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 25720:

Prevent the removal of a manual 'orderby' attribute in the gallery shortcode.

props nofearinc.
fixes #24868.

Note: See TracTickets for help on using tickets.