Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: add permission check for 'Add Post' command in Command Palette
  • Loading branch information
R1shabh-Gupta committed Aug 21, 2025
commit 6534bed888187e4d094da204f067e450ecf34868
10 changes: 10 additions & 0 deletions packages/core-commands/src/admin-navigation-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,23 @@ const getAdminBasicNavigationCommands = () =>
};

export function useAdminNavigationCommands() {
const canCreatePost = useSelect(
( select ) =>
select( coreStore ).canUser( 'create', {
kind: 'postType',
name: 'post',
} ),
[]
);

useCommand( {
name: 'core/add-new-post',
label: __( 'Add Post' ),
icon: plus,
callback: () => {
document.location.assign( 'post-new.php' );
},
disabled: ! canCreatePost,
keywords: [ __( 'post' ), __( 'new' ), __( 'add' ), __( 'create' ) ],
} );

Expand Down