-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from ConvertKit/broadcasts-no-posts
Broadcasts Block: Display message in editor when no Broadcasts exist
- Loading branch information
Showing
5 changed files
with
148 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Broadcasts Block specific functions for Gutenberg. | ||
* | ||
* @since 2.0.1 | ||
* | ||
* @package ConvertKit | ||
* @author ConvertKit | ||
*/ | ||
|
||
/** | ||
* Custom callback function to render the ConvertKit Broadcasts Block preview in the Gutenberg Editor. | ||
* | ||
* @since 2.0.1 | ||
*/ | ||
function convertKitGutenbergBroadcastsBlockRenderPreview( block, props ) { | ||
|
||
// If no Broadcasts exist, return a prompt to tell the editor what to do. | ||
if ( ! block.has_posts ) { | ||
return wp.element.createElement( | ||
'div', | ||
{ | ||
// convertkit-no-content class allows resources/backend/css/gutenberg.css | ||
// to apply styling/branding to the block. | ||
className: 'convertkit-' + block.name + ' convertkit-no-content' | ||
}, | ||
block.gutenberg_help_description | ||
); | ||
} | ||
|
||
// A Product is specified. | ||
// Use the block's PHP's render() function by calling the ServerSideRender component. | ||
return wp.element.createElement( | ||
wp.components.ServerSideRender, | ||
{ | ||
block: 'convertkit/' + block.name, | ||
attributes: props.attributes, | ||
className: 'convertkit-' + block.name, | ||
} | ||
); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters