-
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.
Query: Fix add new post link position via private SlotFill (#49819)
- Loading branch information
1 parent
70c707b
commit 404ba01
Showing
10 changed files
with
92 additions
and
27 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
packages/block-editor/src/components/block-info-slot-fill/index.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,17 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { privateApis as componentsPrivateApis } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { unlock } from '../../lock-unlock'; | ||
|
||
const { createPrivateSlotFill } = unlock( componentsPrivateApis ); | ||
const { Fill, Slot } = createPrivateSlotFill( 'BlockInformation' ); | ||
|
||
const BlockInfo = ( props ) => <Fill { ...props } />; | ||
BlockInfo.Slot = ( props ) => <Slot { ...props } />; | ||
|
||
export default BlockInfo; |
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
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
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
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