Skip to content

Instantly share code, notes, and snippets.

@ideadude
Created December 3, 2017 19:00
Show Gist options
  • Save ideadude/84f0b08e41f612c5137596785bc698a6 to your computer and use it in GitHub Desktop.
Save ideadude/84f0b08e41f612c5137596785bc698a6 to your computer and use it in GitHub Desktop.
If a post has a code block, add a GPL note to the bottom of the post. (For Gutenberg issue #3773)
/**
* If a post has a code block, add a GPL note to the bottom of the post.
* This gist is meant to be run with the pull requests related to this
* issue on the Gutenberg GitHub repo: https://github.com/WordPress/gutenberg/issues/3773
*/
function test_mark_code_posts_for_gpl($content) {
if(gutenberg_content_has_block($content, 'core/code'))
$content .= '<p><strong>All code in this post is licensed under the GPL.</p>';
return $content;
}
add_filter('the_content', 'test_mark_code_posts_for_gpl', 5); //gutenberg currently renders blocks on priority 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment