Skip to content

Commit

Permalink
Add filter for preview interstitial markup (#12463)
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy authored and youknowriad committed Jan 4, 2019
1 parent 5d34eb9 commit 2575d23
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/designers-developers/developers/filters/editor-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,17 @@ var withImageSize = function( size, mediaId, postId ) {
wp.hooks.addFilter( 'editor.PostFeaturedImage.imageSize', 'my-plugin/with-image-size', withImageSize );
```

### `editor.PostPreview.interstitialMarkup`

Filters the interstitial message shown when generating previews.

_Example:_

```js
var customPreviewMessage = function() {
return '<b>Post preview is being generated!</b>';
};

wp.hooks.addFilter( 'editor.PostPreview.interstitialMarkup', 'my-plugin/custom-preview-message', customPreviewMessage );
```

8 changes: 8 additions & 0 deletions packages/editor/src/components/post-preview-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { __, _x } from '@wordpress/i18n';
import { withSelect, withDispatch } from '@wordpress/data';
import { DotTip } from '@wordpress/nux';
import { ifCondition, compose } from '@wordpress/compose';
import { applyFilters } from '@wordpress/hooks';

function writeInterstitialMessage( targetDocument ) {
let markup = renderToString(
Expand Down Expand Up @@ -79,6 +80,13 @@ function writeInterstitialMessage( targetDocument ) {
</style>
`;

/**
* Filters the interstitial message shown when generating previews.
*
* @param {String} markup The preview interstitial markup.
*/
markup = applyFilters( 'editor.PostPreview.interstitialMarkup', markup );

targetDocument.write( markup );
targetDocument.title = __( 'Generating preview…' );
targetDocument.close();
Expand Down

0 comments on commit 2575d23

Please sign in to comment.