-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unnecessary filter to inject new post link
- Loading branch information
1 parent
cb96468
commit 57bae09
Showing
3 changed files
with
40 additions
and
13 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
packages/block-library/src/query/edit/inspector-controls/create-new-post-link.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { createInterpolateElement } from '@wordpress/element'; | ||
import { addQueryArgs } from '@wordpress/url'; | ||
|
||
const CreateNewPostLink = ( { | ||
attributes: { query: { postType } = {} } = {}, | ||
} ) => { | ||
if ( ! postType ) return null; | ||
const newPostUrl = addQueryArgs( 'post-new.php', { | ||
post_type: postType, | ||
} ); | ||
return ( | ||
<div className="wp-block-query__create-new-link"> | ||
{ createInterpolateElement( | ||
__( '<a>Add new post</a>' ), | ||
// eslint-disable-next-line jsx-a11y/anchor-has-content | ||
{ a: <a href={ newPostUrl } /> } | ||
) } | ||
</div> | ||
); | ||
}; | ||
|
||
export default CreateNewPostLink; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters