Skip to content

Instantly share code, notes, and snippets.

@WerdsWords
Last active December 20, 2015 01:49
Show Gist options
  • Save WerdsWords/6051602 to your computer and use it in GitHub Desktop.
Save WerdsWords/6051602 to your computer and use it in GitHub Desktop.
#14: the_editor_content
<?php
/**
* Inject a post template into the post editor
*
* @see _WP_Editors::editor(), wp_editor()
*
* @param string $content The editor content.
*
* @return string The filtered editor content.
*/
function wpdocs_post_editor_template( $content ) {
// Only return the filtered content if it's empty
if ( empty( $content ) ) {
$template = 'The <code><a href="">NAME</a></code> filter allows you to do X.' . "\n\n";
$template .= 'It is evaluated in <code><a href="">FUNCTION</a></code> in the <a href="">FILE</a> file.' . "\n\n";
$template .= '<code>NAME</code> accepts # argument.' . "\n\n";
$template .= 'Example:' . "\n\n";
$template .= 'View the <a href="">code example on Gist</a>.';
return $template;
} else {
return $content;
}
}
add_filter( 'the_editor_content', 'wpdocs_post_editor_template' );
@WerdsWords
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment