From 2613c2557e797cd797b44da73f15a7f58d49832e Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Fri, 31 Aug 2018 01:44:45 -0400 Subject: [PATCH] Implement a save method that puts a link to the embed in the post_content if the plugin ever gets deactivated --- js/block.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/block.js b/js/block.js index 28fd828..b6e682c 100755 --- a/js/block.js +++ b/js/block.js @@ -171,12 +171,19 @@ * into the final markup, which is then serialized by Gutenberg into `post_content`. * @see https://wordpress.org/gutenberg/handbook/block-edit-save/#save * + * Though this block has a render callback, we save the URL of the embed in the post_content + * just in case this plugin is ever deactivated. + * * @return {Element} Element to render. */ - save: function() { - // null because this block is rendered serverside in PHP. - // If there were something returned here, that return would be saved in the post_content. - return null; + save: function( props ) { + return wp.element.createElement( + 'a', + { + href: props.attributes.src, + }, + props.attributes.src + ); }, /**