From f11be45fe803e2b4a116db29eef3f1b54fbb658a Mon Sep 17 00:00:00 2001 From: Chris Shultz Date: Sun, 25 Mar 2018 21:52:53 -0700 Subject: [PATCH 01/11] Gutenberg: Creating prePublish action Creates a 'prePublish' action hook that is triggered right before a post is published. --- editor/store/effects.js | 11 ++++++++++- editor/store/selectors.js | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/editor/store/effects.js b/editor/store/effects.js index bf40697c05d5d..ff72958263b32 100644 --- a/editor/store/effects.js +++ b/editor/store/effects.js @@ -20,6 +20,7 @@ import { } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; import { speak } from '@wordpress/a11y'; +import { doAction } from '@wordpress/hooks'; /** * Internal dependencies @@ -64,7 +65,8 @@ import { isBlockSelected, getTemplate, POST_UPDATE_TRANSACTION_ID, - getTemplateLock, + getTemplateLock, isPublishingPost, + isGoingToPublish, } from './selectors'; /** @@ -109,6 +111,13 @@ export default { optimist: { type: BEGIN, id: POST_UPDATE_TRANSACTION_ID }, } ); dispatch( removeNotice( SAVE_POST_NOTICE_ID ) ); + + // Publishing the post but not currently published + if ( isGoingToPublish( state ) ) { + // TODO: Make this asynchronous + doAction( 'prePublish' ); + } + const basePath = wp.api.getPostTypeRoute( getCurrentPostType( state ) ); wp.apiRequest( { path: `/wp/v2/${ basePath }/${ post.id }`, method: 'PUT', data: toSend } ).then( ( newPost ) => { diff --git a/editor/store/selectors.js b/editor/store/selectors.js index 7285e02d7e951..954246933d0ac 100644 --- a/editor/store/selectors.js +++ b/editor/store/selectors.js @@ -173,6 +173,20 @@ export function getPostEdits( state ) { return get( state, [ 'editor', 'present', 'edits' ], {} ); } +/** + * Returns true if the current post is about to be published. + * + * @param {Object} state Global application state. + * + * @return {boolean} True if post is not published but new state is published. + */ +export function isGoingToPublish( state ) { + const currentPost = getCurrentPost( state ); + const edits = getPostEdits( state ); + + return ( 'publish' == edits.status ) && ( 'publish' != currentPost.status ); +} + /** * Returns a single attribute of the post being edited, preferring the unsaved * edit if one exists, but falling back to the attribute for the last known From ca88e2b5451d40ec27ba9e48d9bda811fc980fd4 Mon Sep 17 00:00:00 2001 From: Chris Shultz Date: Tue, 27 Mar 2018 21:09:08 -0700 Subject: [PATCH 02/11] Revert "Gutenberg: Creating prePublish action" This reverts commit 81696afec2bd3c37e78d944b73c7978b06431ad2. Using action hooks and an extra request was deemed too much kludge just to differentiate publishing from Gutenberg. Another iteration is incoming... --- editor/store/effects.js | 11 +---------- editor/store/selectors.js | 14 -------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/editor/store/effects.js b/editor/store/effects.js index ff72958263b32..bf40697c05d5d 100644 --- a/editor/store/effects.js +++ b/editor/store/effects.js @@ -20,7 +20,6 @@ import { } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; import { speak } from '@wordpress/a11y'; -import { doAction } from '@wordpress/hooks'; /** * Internal dependencies @@ -65,8 +64,7 @@ import { isBlockSelected, getTemplate, POST_UPDATE_TRANSACTION_ID, - getTemplateLock, isPublishingPost, - isGoingToPublish, + getTemplateLock, } from './selectors'; /** @@ -111,13 +109,6 @@ export default { optimist: { type: BEGIN, id: POST_UPDATE_TRANSACTION_ID }, } ); dispatch( removeNotice( SAVE_POST_NOTICE_ID ) ); - - // Publishing the post but not currently published - if ( isGoingToPublish( state ) ) { - // TODO: Make this asynchronous - doAction( 'prePublish' ); - } - const basePath = wp.api.getPostTypeRoute( getCurrentPostType( state ) ); wp.apiRequest( { path: `/wp/v2/${ basePath }/${ post.id }`, method: 'PUT', data: toSend } ).then( ( newPost ) => { diff --git a/editor/store/selectors.js b/editor/store/selectors.js index 954246933d0ac..7285e02d7e951 100644 --- a/editor/store/selectors.js +++ b/editor/store/selectors.js @@ -173,20 +173,6 @@ export function getPostEdits( state ) { return get( state, [ 'editor', 'present', 'edits' ], {} ); } -/** - * Returns true if the current post is about to be published. - * - * @param {Object} state Global application state. - * - * @return {boolean} True if post is not published but new state is published. - */ -export function isGoingToPublish( state ) { - const currentPost = getCurrentPost( state ); - const edits = getPostEdits( state ); - - return ( 'publish' == edits.status ) && ( 'publish' != currentPost.status ); -} - /** * Returns a single attribute of the post being edited, preferring the unsaved * edit if one exists, but falling back to the attribute for the last known From 3894220110d93077c6b6897c35f867742ed76c9f Mon Sep 17 00:00:00 2001 From: Chris Shultz Date: Tue, 27 Mar 2018 21:12:12 -0700 Subject: [PATCH 03/11] Extensibility: X-WP-Source='Gutenberg' header added As a method for differentiating requests from Gutenberg editor, a header keyed 'X-WP-Source' is being added and set to 'Gutenberg'. --- lib/compat.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/compat.php b/lib/compat.php index cb247e48995a4..d21e0179cc23b 100644 --- a/lib/compat.php +++ b/lib/compat.php @@ -170,6 +170,7 @@ function gutenberg_shim_api_request_emulate_http( $scripts ) { options.headers = {}; } options.headers['X-HTTP-Method-Override'] = options.method; + options.headers['X-WP-Source'] = 'Gutenberg'; options.method = 'POST'; options.contentType = 'application/json'; From c2508c96292403f34f7026d437ff3b61f62ddf5d Mon Sep 17 00:00:00 2001 From: Chris Shultz Date: Fri, 30 Mar 2018 06:06:00 -0700 Subject: [PATCH 04/11] Extensiblity: Adding pre and post publish slots Adding slots for pre-publish sidebar and post-publish sidebar to be used with `registerPlugin` for plugins to add content to the bottom of these sidebars. The current plan is to use the post-publish sidebar will be used for Jetpack's Publicize feature. --- edit-post/README.md | 29 ++++++++++- .../plugin-post-publish-panel/index.js | 52 +++++++++++++++++++ .../plugin-pre-publish-panel/index.js | 52 +++++++++++++++++++ edit-post/index.js | 4 ++ .../post-publish-panel/postpublish.js | 2 + .../post-publish-panel/prepublish.js | 2 + 6 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 edit-post/components/plugin-post-publish-panel/index.js create mode 100644 edit-post/components/plugin-pre-publish-panel/index.js diff --git a/edit-post/README.md b/edit-post/README.md index e040a84248455..36293aca43ef7 100644 --- a/edit-post/README.md +++ b/edit-post/README.md @@ -7,7 +7,9 @@ Refer to [the plugins module documentation](../plugins/) for more information. ## Plugin Components The following components can be used with the `registerPlugin` ([see documentation](../plugins)) API. -They can be found in the global variable `wp.editPost` when defining `wp-edit-post` as a script dependency. +They can be found in the global variable `wp.editPost` when defining `wp-edit-post` as a script dependency. + +**Note:** Plugin scripts should be enqueued to footer by setting `in_footer' option to true ( [see wp_enqueue_script documentation](https://developer.wordpress.org/reference/functions/wp_enqueue_script/) ). Experimental components can be found under `wp.editPost.__experimental`. Experimental components are still being evaluated and can change in a future version. @@ -109,3 +111,28 @@ The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug st - Required: No +### PluginPrePublishPanel +**Experimental** + +Renders provided content to the pre-publish side panel in the publish flow (side panel that opens when user first pushes "Publish" from main editor). + +#### Usage + +```jsx + +
My plugin content
+
+``` + +### PluginPostPublishPanel +**Experimental** + +Renders provided content to the post-publish panel in the publish flow (panel that opens after user publishes the post) + +#### Usage + +```jsx + +
My plugin content
+
+``` diff --git a/edit-post/components/plugin-post-publish-panel/index.js b/edit-post/components/plugin-post-publish-panel/index.js new file mode 100644 index 0000000000000..1fa0edf548cab --- /dev/null +++ b/edit-post/components/plugin-post-publish-panel/index.js @@ -0,0 +1,52 @@ +/** + * Defines extensibility slot for post-publish sidebar. + * + * Defines slot to be used by plugins to insert content in the post-publish sidebar + * (which appears after a user fully publishes a post). + * + * @see /edit-post/README.md + * + * @file This files defines the PluginPostPublishPanel extension + * @author ChrisShultz + * @since 2.6.0 + */ + +/** + * WordPress dependencies + */ +import { Slot, Fill } from '@wordpress/components'; + +/** + * Internal dependencies + */ + +/** + * Name of slot to fill. + * + * @type {String} + */ +const SLOT_NAME = 'PluginPostPublishPanel'; + +/** + * Renders the plugin sidebar fill. + * + * @return {WPElement} Plugin sidebar fill. + */ +function PluginPostPublishPanel( { children } ) { + return ( + + { children } + + ); +} + +/** + * The plugin sidebar slot. + * + * @return {WPElement} The plugin sidebar slot. + */ +PluginPostPublishPanel.Slot = () => ( + +); + +export default PluginPostPublishPanel; diff --git a/edit-post/components/plugin-pre-publish-panel/index.js b/edit-post/components/plugin-pre-publish-panel/index.js new file mode 100644 index 0000000000000..a187634c7a60f --- /dev/null +++ b/edit-post/components/plugin-pre-publish-panel/index.js @@ -0,0 +1,52 @@ +/** + * Defines extensibility slot for pre-publish sidebar. + * + * Defines slot to be used by plugins to insert content in the pre-publish sidebar + * (which appears when a user pushes "Publish" from the main editor). + * + * @see /edit-post/README.md + * + * @file This files defines the PluginPrePublishPanel extension + * @author ChrisShultz + * @since 2.6.0 + */ + +/** + * WordPress dependencies + */ +import { Slot, Fill } from '@wordpress/components'; + +/** + * Internal dependencies + */ + +/** + * Name of slot to fill. + * + * @type {String} + */ +const SLOT_NAME = 'PluginPrePublishPanel'; + +/** + * Renders the plugin sidebar fill. + * + * @return {WPElement} Plugin sidebar fill. + */ +function PluginPrePublishPanel( { children } ) { + return ( + + { children } + + ); +} + +/** + * The plugin sidebar slot. + * + * @return {WPElement} The plugin sidebar slot. + */ +PluginPrePublishPanel.Slot = () => ( + +); + +export default PluginPrePublishPanel; diff --git a/edit-post/index.js b/edit-post/index.js index 261ec4e7cd1a8..448eb48385e2c 100644 --- a/edit-post/index.js +++ b/edit-post/index.js @@ -14,6 +14,8 @@ import store from './store'; import { initializeMetaBoxState } from './store/actions'; import PluginMoreMenuItem from './components/plugin-more-menu-item'; +import PluginPrePublishPanel from './components/plugin-pre-publish-panel'; +import PluginPostPublishPanel from './components/plugin-post-publish-panel'; /** * Configure heartbeat to refresh the wp-api nonce, keeping the editor @@ -82,6 +84,8 @@ export function initializeEditor( id, post, settings ) { export const __experimental = { PluginMoreMenuItem, + PluginPrePublishPanel, + PluginPostPublishPanel, }; export { default as PluginSidebar } from './components/sidebar/plugin-sidebar'; diff --git a/editor/components/post-publish-panel/postpublish.js b/editor/components/post-publish-panel/postpublish.js index 5d8bbbe178cbc..911a35b16d5f4 100644 --- a/editor/components/post-publish-panel/postpublish.js +++ b/editor/components/post-publish-panel/postpublish.js @@ -15,6 +15,7 @@ import { withSelect } from '@wordpress/data'; * Internal dependencies */ import PostScheduleLabel from '../post-schedule/label'; +import PluginPostPublishPanel from '../../../edit-post/components/plugin-post-publish-panel'; class PostPublishPanelPostpublish extends Component { constructor() { @@ -83,6 +84,7 @@ class PostPublishPanelPostpublish extends Component { + { } ); } diff --git a/editor/components/post-publish-panel/prepublish.js b/editor/components/post-publish-panel/prepublish.js index ec48a249e0e3f..7e24fbf517cf4 100644 --- a/editor/components/post-publish-panel/prepublish.js +++ b/editor/components/post-publish-panel/prepublish.js @@ -11,6 +11,7 @@ import PostVisibility from '../post-visibility'; import PostVisibilityLabel from '../post-visibility/label'; import PostSchedule from '../post-schedule'; import PostScheduleLabel from '../post-schedule/label'; +import PluginPrePublishPanel from '../../../edit-post/components/plugin-pre-publish-panel'; function PostPublishPanelPrepublish() { return ( @@ -29,6 +30,7 @@ function PostPublishPanelPrepublish() { ] }> + { } ); } From 15f2bf281bc2f0888a25bf841d5e60bfda57df1f Mon Sep 17 00:00:00 2001 From: Chris Shultz Date: Fri, 30 Mar 2018 06:21:46 -0700 Subject: [PATCH 05/11] Extensibility: Whitespace cleanup Cleaning up some leading and trailing whitespace issues. --- edit-post/components/plugin-post-publish-panel/index.js | 2 +- edit-post/components/plugin-pre-publish-panel/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/edit-post/components/plugin-post-publish-panel/index.js b/edit-post/components/plugin-post-publish-panel/index.js index 1fa0edf548cab..ac98812499466 100644 --- a/edit-post/components/plugin-post-publish-panel/index.js +++ b/edit-post/components/plugin-post-publish-panel/index.js @@ -4,7 +4,7 @@ * Defines slot to be used by plugins to insert content in the post-publish sidebar * (which appears after a user fully publishes a post). * - * @see /edit-post/README.md + * @see /edit-post/README.md * * @file This files defines the PluginPostPublishPanel extension * @author ChrisShultz diff --git a/edit-post/components/plugin-pre-publish-panel/index.js b/edit-post/components/plugin-pre-publish-panel/index.js index a187634c7a60f..75c45ab857ec6 100644 --- a/edit-post/components/plugin-pre-publish-panel/index.js +++ b/edit-post/components/plugin-pre-publish-panel/index.js @@ -35,7 +35,7 @@ const SLOT_NAME = 'PluginPrePublishPanel'; function PluginPrePublishPanel( { children } ) { return ( - { children } + { children } ); } From 64ca0167fc23d515517d7cef8f94bfc4030d97be Mon Sep 17 00:00:00 2001 From: Chris Shultz Date: Fri, 30 Mar 2018 08:57:19 -0700 Subject: [PATCH 06/11] Extensibility: documentation clean up Fixing typos and clearing out unecessary DocBlock entries. --- edit-post/README.md | 6 +++--- edit-post/components/plugin-post-publish-panel/index.js | 3 --- edit-post/components/plugin-pre-publish-panel/index.js | 3 --- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/edit-post/README.md b/edit-post/README.md index 36293aca43ef7..3a55b869958e1 100644 --- a/edit-post/README.md +++ b/edit-post/README.md @@ -9,7 +9,7 @@ Refer to [the plugins module documentation](../plugins/) for more information. The following components can be used with the `registerPlugin` ([see documentation](../plugins)) API. They can be found in the global variable `wp.editPost` when defining `wp-edit-post` as a script dependency. -**Note:** Plugin scripts should be enqueued to footer by setting `in_footer' option to true ( [see wp_enqueue_script documentation](https://developer.wordpress.org/reference/functions/wp_enqueue_script/) ). +**Note:** Plugin scripts should be enqueued to footer by setting `in_footer` option to true ( [see wp_enqueue_script documentation](https://developer.wordpress.org/reference/functions/wp_enqueue_script/) ). Experimental components can be found under `wp.editPost.__experimental`. Experimental components are still being evaluated and can change in a future version. @@ -132,7 +132,7 @@ Renders provided content to the post-publish panel in the publish flow (panel th #### Usage ```jsx - +
My plugin content
-
+ ``` diff --git a/edit-post/components/plugin-post-publish-panel/index.js b/edit-post/components/plugin-post-publish-panel/index.js index ac98812499466..82a3f9f63a359 100644 --- a/edit-post/components/plugin-post-publish-panel/index.js +++ b/edit-post/components/plugin-post-publish-panel/index.js @@ -4,10 +4,7 @@ * Defines slot to be used by plugins to insert content in the post-publish sidebar * (which appears after a user fully publishes a post). * - * @see /edit-post/README.md - * * @file This files defines the PluginPostPublishPanel extension - * @author ChrisShultz * @since 2.6.0 */ diff --git a/edit-post/components/plugin-pre-publish-panel/index.js b/edit-post/components/plugin-pre-publish-panel/index.js index 75c45ab857ec6..52960b3c1350e 100644 --- a/edit-post/components/plugin-pre-publish-panel/index.js +++ b/edit-post/components/plugin-pre-publish-panel/index.js @@ -4,10 +4,7 @@ * Defines slot to be used by plugins to insert content in the pre-publish sidebar * (which appears when a user pushes "Publish" from the main editor). * - * @see /edit-post/README.md - * * @file This files defines the PluginPrePublishPanel extension - * @author ChrisShultz * @since 2.6.0 */ From b462ae13cfdac02273a59ac476f4829beacf9905 Mon Sep 17 00:00:00 2001 From: Chris Shultz Date: Thu, 5 Apr 2018 12:51:05 -0700 Subject: [PATCH 07/11] Publish sidebar extensibility: cleaning up obsolete syntax Removing obsolete curly brackets around PluginPostPublishPanel.Slot and PluginPrePublishPanel.Slot components. --- editor/components/post-publish-panel/postpublish.js | 2 +- editor/components/post-publish-panel/prepublish.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/components/post-publish-panel/postpublish.js b/editor/components/post-publish-panel/postpublish.js index 911a35b16d5f4..07b9317aaef28 100644 --- a/editor/components/post-publish-panel/postpublish.js +++ b/editor/components/post-publish-panel/postpublish.js @@ -84,7 +84,7 @@ class PostPublishPanelPostpublish extends Component { - { } + ); } diff --git a/editor/components/post-publish-panel/prepublish.js b/editor/components/post-publish-panel/prepublish.js index 7e24fbf517cf4..7651e04ee76c6 100644 --- a/editor/components/post-publish-panel/prepublish.js +++ b/editor/components/post-publish-panel/prepublish.js @@ -30,7 +30,7 @@ function PostPublishPanelPrepublish() { ] }> - { } + ); } From f0acdcf284970a4903c36c050c1e0b5f1b798fff Mon Sep 17 00:00:00 2001 From: Chris Shultz Date: Thu, 5 Apr 2018 18:58:27 -0700 Subject: [PATCH 08/11] Publish sidebar extensibility: removing edit-post editor dependency Now passing pre/post publish plugin slot using new prop and children prop instead of referencing it directly from within editor. props @youknowriad --- edit-post/components/layout/index.js | 8 +++++++- editor/components/post-publish-panel/index.js | 6 +++--- editor/components/post-publish-panel/postpublish.js | 3 +-- editor/components/post-publish-panel/prepublish.js | 5 ++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/edit-post/components/layout/index.js b/edit-post/components/layout/index.js index cef9eacf5e7a2..7be3107e3d3e8 100644 --- a/edit-post/components/layout/index.js +++ b/edit-post/components/layout/index.js @@ -35,6 +35,8 @@ import EditorModeKeyboardShortcuts from '../keyboard-shortcuts'; import MetaBoxes from '../meta-boxes'; import { getMetaBoxContainer } from '../../utils/meta-boxes'; import Sidebar from '../sidebar'; +import PluginPostPublishPanel from '../plugin-post-publish-panel'; +import PluginPrePublishPanel from '../plugin-pre-publish-panel'; function Layout( { mode, @@ -84,7 +86,11 @@ function Layout( { onClose={ closePublishSidebar } forceIsDirty={ hasActiveMetaboxes } forceIsSaving={ isSaving } - /> + prePublishExtension={ } + postPublishExtension={ } + > + + ) } diff --git a/editor/components/post-publish-panel/index.js b/editor/components/post-publish-panel/index.js index a4b37bcef3baa..e6f34b61f7580 100644 --- a/editor/components/post-publish-panel/index.js +++ b/editor/components/post-publish-panel/index.js @@ -69,7 +69,7 @@ class PostPublishPanel extends Component { } render() { - const { isScheduled, onClose, forceIsDirty, forceIsSaving } = this.props; + const { isScheduled, onClose, forceIsDirty, forceIsSaving, prePublishExtension, postPublishExtension } = this.props; const { loading, submitted } = this.state; return (
@@ -91,9 +91,9 @@ class PostPublishPanel extends Component { />
- { ! loading && ! submitted && } + { ! loading && ! submitted && { prePublishExtension } } { loading && ! submitted && } - { submitted && } + { submitted && { postPublishExtension } }
); diff --git a/editor/components/post-publish-panel/postpublish.js b/editor/components/post-publish-panel/postpublish.js index 07b9317aaef28..55e5c8173d4bf 100644 --- a/editor/components/post-publish-panel/postpublish.js +++ b/editor/components/post-publish-panel/postpublish.js @@ -15,7 +15,6 @@ import { withSelect } from '@wordpress/data'; * Internal dependencies */ import PostScheduleLabel from '../post-schedule/label'; -import PluginPostPublishPanel from '../../../edit-post/components/plugin-post-publish-panel'; class PostPublishPanelPostpublish extends Component { constructor() { @@ -84,7 +83,7 @@ class PostPublishPanelPostpublish extends Component { - + { this.props.children } ); } diff --git a/editor/components/post-publish-panel/prepublish.js b/editor/components/post-publish-panel/prepublish.js index 7651e04ee76c6..a1d4769e91ad4 100644 --- a/editor/components/post-publish-panel/prepublish.js +++ b/editor/components/post-publish-panel/prepublish.js @@ -11,9 +11,8 @@ import PostVisibility from '../post-visibility'; import PostVisibilityLabel from '../post-visibility/label'; import PostSchedule from '../post-schedule'; import PostScheduleLabel from '../post-schedule/label'; -import PluginPrePublishPanel from '../../../edit-post/components/plugin-pre-publish-panel'; -function PostPublishPanelPrepublish() { +function PostPublishPanelPrepublish( props ) { return (
{ __( 'Are you ready to publish?' ) }
@@ -30,7 +29,7 @@ function PostPublishPanelPrepublish() { ] }> - + { props.children }
); } From 658fdc43a75ee82269db628e545b53a2a19aca76 Mon Sep 17 00:00:00 2001 From: Chris Shultz Date: Thu, 5 Apr 2018 19:53:01 -0700 Subject: [PATCH 09/11] Publish sidebar extensibility: utilizing new createSlotFill factory Replacing repetitious code with newly created createSlotFill factory function for PluginPrePublishPanel and PluginPostPublishPanel slots. props @gziolo --- .../plugin-post-publish-panel/index.js | 39 ++----------------- .../plugin-pre-publish-panel/index.js | 39 ++----------------- 2 files changed, 6 insertions(+), 72 deletions(-) diff --git a/edit-post/components/plugin-post-publish-panel/index.js b/edit-post/components/plugin-post-publish-panel/index.js index 82a3f9f63a359..9660191545677 100644 --- a/edit-post/components/plugin-post-publish-panel/index.js +++ b/edit-post/components/plugin-post-publish-panel/index.js @@ -5,45 +5,12 @@ * (which appears after a user fully publishes a post). * * @file This files defines the PluginPostPublishPanel extension - * @since 2.6.0 + * @since 2.7.0 */ -/** - * WordPress dependencies - */ -import { Slot, Fill } from '@wordpress/components'; - /** * Internal dependencies */ +import { createSlotFill } from '../../../components/slot-fill'; -/** - * Name of slot to fill. - * - * @type {String} - */ -const SLOT_NAME = 'PluginPostPublishPanel'; - -/** - * Renders the plugin sidebar fill. - * - * @return {WPElement} Plugin sidebar fill. - */ -function PluginPostPublishPanel( { children } ) { - return ( - - { children } - - ); -} - -/** - * The plugin sidebar slot. - * - * @return {WPElement} The plugin sidebar slot. - */ -PluginPostPublishPanel.Slot = () => ( - -); - -export default PluginPostPublishPanel; +export default createSlotFill( 'PluginPostPublishPanel' ); diff --git a/edit-post/components/plugin-pre-publish-panel/index.js b/edit-post/components/plugin-pre-publish-panel/index.js index 52960b3c1350e..b0248e8b8c340 100644 --- a/edit-post/components/plugin-pre-publish-panel/index.js +++ b/edit-post/components/plugin-pre-publish-panel/index.js @@ -5,45 +5,12 @@ * (which appears when a user pushes "Publish" from the main editor). * * @file This files defines the PluginPrePublishPanel extension - * @since 2.6.0 + * @since 2.7.0 */ -/** - * WordPress dependencies - */ -import { Slot, Fill } from '@wordpress/components'; - /** * Internal dependencies */ +import { createSlotFill } from '../../../components/slot-fill'; -/** - * Name of slot to fill. - * - * @type {String} - */ -const SLOT_NAME = 'PluginPrePublishPanel'; - -/** - * Renders the plugin sidebar fill. - * - * @return {WPElement} Plugin sidebar fill. - */ -function PluginPrePublishPanel( { children } ) { - return ( - - { children } - - ); -} - -/** - * The plugin sidebar slot. - * - * @return {WPElement} The plugin sidebar slot. - */ -PluginPrePublishPanel.Slot = () => ( - -); - -export default PluginPrePublishPanel; +export default createSlotFill( 'PluginPrePublishPanel' ); From d6053e1190b5ac0a5f0613288ea11d8e79896c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20=28Greg=29=20Zi=C3=B3=C5=82kowski?= Date: Thu, 17 May 2018 11:46:24 +0200 Subject: [PATCH 10/11] Update README.md --- edit-post/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/edit-post/README.md b/edit-post/README.md index 3a55b869958e1..414a7dbf2dbac 100644 --- a/edit-post/README.md +++ b/edit-post/README.md @@ -7,9 +7,7 @@ Refer to [the plugins module documentation](../plugins/) for more information. ## Plugin Components The following components can be used with the `registerPlugin` ([see documentation](../plugins)) API. -They can be found in the global variable `wp.editPost` when defining `wp-edit-post` as a script dependency. - -**Note:** Plugin scripts should be enqueued to footer by setting `in_footer` option to true ( [see wp_enqueue_script documentation](https://developer.wordpress.org/reference/functions/wp_enqueue_script/) ). +They can be found in the global variable `wp.editPost` when defining `wp-edit-post` as a script dependency. Experimental components can be found under `wp.editPost.__experimental`. Experimental components are still being evaluated and can change in a future version. From 97ad4f155f238e8b32e78d44246bbc7fc907478b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20=28Greg=29=20Zi=C3=B3=C5=82kowski?= Date: Thu, 17 May 2018 11:47:52 +0200 Subject: [PATCH 11/11] Update compat.php --- lib/compat.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/compat.php b/lib/compat.php index d21e0179cc23b..cb247e48995a4 100644 --- a/lib/compat.php +++ b/lib/compat.php @@ -170,7 +170,6 @@ function gutenberg_shim_api_request_emulate_http( $scripts ) { options.headers = {}; } options.headers['X-HTTP-Method-Override'] = options.method; - options.headers['X-WP-Source'] = 'Gutenberg'; options.method = 'POST'; options.contentType = 'application/json';