问题是$content
是WordPress中的保留变量,必须使用其他名称。这里,我用过$pre_content
:
<?php
/**
* Plugin Name: T5 Editor content by request
* Description: Default text for post content from GET variable <code>pre_content</code>.
* Author: Fuxia Scholz
* Version: 2012.06.30
*/
/*
* See wp-admin/includes/post.php function get_default_post_to_edit()
* There are also the filters \'default_title\' and \'default_excerpt\'
*/
add_filter( \'default_content\', \'t5_content_by_request\', 10, 2 );
/**
* Fills the default content for post type \'post\' if it is not empty.
*
* @param string $content
* @param object $post
* @return string
*/
function t5_content_by_request( $content, $post )
{
if ( ! empty ( $_GET[\'pre_content\'] )
and current_user_can( \'edit_post\', $post->ID )
and \'\' === $content
)
{
return $_GET[\'pre_content\'];
}
return $content;
}