-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'Feed Information' sidebar to edit screen for feeds.
This sidebar currently contains an editable Feed URL field. See #1187.
- Loading branch information
1 parent
e248034
commit 3a0c6d4
Showing
4 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* global pfBlockEditorFeeds */ | ||
|
||
import { registerPlugin } from '@wordpress/plugins' | ||
import { useDispatch, useSelect } from '@wordpress/data' | ||
import { PluginDocumentSettingPanel } from '@wordpress/edit-post' | ||
import { __ } from '@wordpress/i18n' | ||
import { TextControl } from '@wordpress/components' | ||
|
||
const BlockEditorFeedsInfobox = ( {} ) => { | ||
const { editPost } = useDispatch( 'core/editor' ) | ||
|
||
const { feedPostType } = pfBlockEditorFeeds | ||
|
||
const { | ||
feedUrl, | ||
postId, | ||
postStatus, | ||
postType | ||
} = useSelect( ( select ) => { | ||
const editedPostId = select( 'core/editor' ).getCurrentPostId() | ||
const editedPostMeta = select( 'core/editor' ).getEditedPostAttribute( 'meta' ) | ||
|
||
return { | ||
feedUrl: editedPostMeta?.feed_url || '', | ||
postId: editedPostId, | ||
postType: select( 'core/editor' ).getEditedPostAttribute( 'type' ), | ||
} | ||
} ) | ||
|
||
const isFeed = feedPostType === postType | ||
|
||
// Show only on Feed. | ||
if ( ! isFeed ) { | ||
return null | ||
} | ||
|
||
return ( | ||
<PluginDocumentSettingPanel | ||
icon="controls-forward" | ||
name="pressforward-block-editor-feeds-infobox" | ||
title={ __( 'Feed Information', 'pressforward' ) } | ||
> | ||
<TextControl | ||
label={ __( 'Feed URL', 'pressforward' ) } | ||
value={ feedUrl } | ||
onChange={ ( newValue ) => { | ||
editPost( { meta: { 'feed_url': newValue } } ) | ||
} } | ||
/> | ||
</PluginDocumentSettingPanel> | ||
) | ||
} | ||
|
||
registerPlugin( | ||
'pressforward-block-editor-feeds-infobox', | ||
{ | ||
render: BlockEditorFeedsInfobox, | ||
} | ||
); |
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