Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SlotFill in Status & Availability panel to match existing hook #6300

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 22 additions & 2 deletions edit-post/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'plugin-name/sidebar-na
_Example:_

```jsx
const { __ } = wp.i18n;
const { PanelBody } = wp.components;
const { PluginSidebar } = wp.editPost;

Expand All @@ -30,7 +31,7 @@ const MyPluginSidebar = () => (
title="My sidebar title"
>
<PanelBody>
My sidebar content
{ __( 'My sidebar content' ) }
</PanelBody>
</PluginSidebar>
);
Expand Down Expand Up @@ -61,14 +62,15 @@ The text within the component appears as the menu item label.
_Example:_

```jsx
const { __ } = wp.i18n;
const { PluginSidebarMoreMenuItem } = wp.editPost;

const MySidebarMoreMenuItem = () => (
<PluginSidebarMoreMenuItem
target="my-sidebar"
icon="yes"
>
My sidebar title
{ __( 'My sidebar title' ) }
</PluginSidebarMoreMenuItem>
);
```
Expand All @@ -90,3 +92,21 @@ The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug st
- Required: No


### `PluginPostStatusInfo`

Renders a row in the Status & Visibility panel of the Document sidebar.
It should be noted that this is named and implemented around the function it serves and not its location, which may change in future iterations.

_Example:_
```jsx
const { __ } = wp.i18n;
const { PluginPostStatusInfo } = wp.editPost;

const MyPluginPostStatusInfo = () => (
<PluginPostStatusInfo>
{ __( 'My post status info' ) }
</PluginPostStatusInfo>
);
```


18 changes: 18 additions & 0 deletions edit-post/components/sidebar/plugin-post-status-info/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Defines as extensibility slot for the Status & Visibility panel.
*/

/**
* WordPress dependencies
*/
import { createSlotFill, PanelRow } from '@wordpress/components';

export const { Fill: PluginPostStatusInfo, Slot } = createSlotFill( 'PluginPostStatusInfo' );

PluginPostStatusInfo.Slot = () => (
<PanelRow>
<Slot />
</PanelRow>
);

export default PluginPostStatusInfo;
2 changes: 2 additions & 0 deletions edit-post/components/sidebar/post-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import PostSticky from '../post-sticky';
import PostAuthor from '../post-author';
import PostFormat from '../post-format';
import PostPendingStatus from '../post-pending-status';
import PluginPostStatusInfo from '../plugin-post-status-info';

/**
* Module Constants
Expand All @@ -32,6 +33,7 @@ function PostStatus( { isOpened, onTogglePanel } ) {
<PostSticky />
<PostPendingStatus />
<PostAuthor />
<PluginPostStatusInfo.Slot />
<PostTrash />
</PanelBody>
);
Expand Down
1 change: 1 addition & 0 deletions edit-post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,6 @@ export function initializeEditor( id, post, settings ) {
} );
}

export { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';
export { default as PluginSidebar } from './components/sidebar/plugin-sidebar';
export { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';