第一个有致命错误的wordpress插件


first wordpress plugin with Fatal error

试图获得一个简单的插件,并在我的第一步得到错误。

<?php
/*
Plugin Name:!test
*/
require_once(includes_url() . '/pluggable.php');
function is_user_logged_in() {
    $user = wp_get_current_user();
    return $user->exists();
}
echo is_user_logged_in();
?>   

你不能在插件文件中直接调用function。代替它,在钩子中调用它,例如:

function my_shortcode_func( $atts ) {
    $user = wp_get_current_user();
    return $user->exists(); 
}
add_shortcode( 'my_shortcode', 'my_shortcode_func' );