Skip to content

Commit

Permalink
Components: Improve docs for PostFeaturedImage
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jul 11, 2018
1 parent 4e10ade commit a7f4269
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 30 deletions.
70 changes: 41 additions & 29 deletions editor/components/post-featured-image/README.md
@@ -1,47 +1,59 @@
PostFeaturedImage
===========

PostFeaturedImage is a React component used to render the Post Featured Image selection tool.
`PostFeaturedImage` is a React component used to render the Post Featured Image selection tool.

## Setup

It includes a `wp.hooks` filter `editor.PostFeaturedImage` that enables developers to replace or extend it.

## Examples
_Examples:_

Replace the contents of the panel:

```js
function replacePostFeaturedImage() {
return function() {
return wp.element.createElement(
'div',
{},
'The replacement contents or components.'
);
}
}

wp.hooks.addFilter(
'editor.PostFeaturedImage',
'myplugin/myhook',
function() {
return function() {
return wp.element.createElement(
'div',
{},
'The replacement contents or components.'
);
}
}
'my-plugin/replace-post-featured-image',
replacePostFeaturedImage
);
```

Prepend/Append to the panel contents:
Prepend and append to the panel contents:

```js
var el = wp.element.createElement;

function wrapPostFeaturedImage( OriginalComponent ) {
return function( props ) {
return (
el(
wp.element.Fragment,
{},
'Prepend above',
el(
OriginalComponent,
props
),
'Append below'
)
);
}
}

wp.hooks.addFilter(
'editor.PostFeaturedImage',
'myplugin/myhook',
function( original ) {
return function() {
return (
wp.element.createElement(
'div',
{ key: 'outer' + Math.random() },
[
'Prepend above',
_.extend( original( {} ), { key: 'my-key' } ),
'Append below'
]
)
);
}
}
'my-plugin/wrap-post-featured-image',
wrapPostFeaturedImage
);
```
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a7f4269

Please sign in to comment.