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 filter for preview interstitial markup #12463

Merged
merged 3 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
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.interstitialMessage`

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.interstitialMessage', '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.interstitialMessage', markup );

targetDocument.write( markup );
targetDocument.close();
}
Expand Down