Skip to content

Commit

Permalink
Sort post formats alphabetically by translated name. (#26305)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed Oct 20, 2020
1 parent 1327b59 commit 741d019
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/editor/src/components/post-format/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,30 @@ import { useInstanceId } from '@wordpress/compose';
*/
import PostFormatCheck from './check';

// All WP post formats, sorted alphabetically by translated name.
export const POST_FORMATS = [
{ id: 'aside', caption: __( 'Aside' ) },
{ id: 'audio', caption: __( 'Audio' ) },
{ id: 'chat', caption: __( 'Chat' ) },
{ id: 'gallery', caption: __( 'Gallery' ) },
{ id: 'link', caption: __( 'Link' ) },
{ id: 'image', caption: __( 'Image' ) },
{ id: 'link', caption: __( 'Link' ) },
{ id: 'quote', caption: __( 'Quote' ) },
{ id: 'standard', caption: __( 'Standard' ) },
{ id: 'status', caption: __( 'Status' ) },
{ id: 'video', caption: __( 'Video' ) },
{ id: 'audio', caption: __( 'Audio' ) },
{ id: 'chat', caption: __( 'Chat' ) },
];
].sort( ( a, b ) => {
const normalizedA = a.caption.toUpperCase();
const normalizedB = b.caption.toUpperCase();

if ( normalizedA < normalizedB ) {
return -1;
}
if ( normalizedA > normalizedB ) {
return 1;
}
return 0;
} );

export default function PostFormat() {
const instanceId = useInstanceId( PostFormat );
Expand Down

0 comments on commit 741d019

Please sign in to comment.