下面的“word\\u count”函数根据其调用位置返回不同的值。为什么?
add_action(\'save_post\', \'my_custom_save\', 10, 2);
function myPlugin($post)
{
global $rockScore;
global $text;
$text = strip_tags($post->post_content);
echo word_count($post); //returns "350"
}
function word_count($post)
{
global $text;
$word_count = explode(\' \', $text);
$word_count = count($word_count);
return $word_count;
}
function my_custom_save($postID, $post){
if (defined(\'DOING_AUTOSAVE\') && DOING_AUTOSAVE) {
return $postID;
}
else
{
if($parent_id = wp_is_post_revision($postID))
{
$postID = $parent_id;
}
echo word_count($post);die; //still returns "1"
}
}
register_activation_hook(__FILE__, \'myPlugin\');