Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort post formats alphabetically by translated name. #26305

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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