Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Situation

I got a class where i add a meta box to the post edit screen.

EDIT: This is the working version now

/**
 * Calls the class on the post edit screen
 */
function call_someClass() 
{
    return new someClass();
}
if ( is_admin() )
    add_action( 'load-post.php', 'call_someClass' );

/** 
 * The Class
 */
class someClass
{
    public function __construct()
    {
        add_action( 'add_meta_boxes', array( &$this, 'add_meta_box' ) );
    }

    /**
     * Adds the meta box container
     */
    public function add_meta_box( /* $args */ )
    {
        add_meta_box( 
             'post_format_box'
            ,__( 'Post Format Content', self::LANG )
            ,array( &$this, 'render' )
            ,'post' 
            ,'advanced'
            ,'high'
        );
    }


    /**
     * Render Meta Box content
     */
    public function render( /* $args */ ) 
    {
        return '<h1>TEST ME NOW</h1>';
    }
}

Problem

The meta box is showing, and the meta box callback functions output get's rendered inside my meta box... but inside an error message. Seems that i'm too tired to get around this:

Error Message (exact display as in the meta box)

Warning: call_user_func() expects parameter 1 to be a valid callback, function ' TEST ME NOW ' not found or invalid function name in R:\development\xampp\htdocs\wordpress\wp-admin\includes\template.php on line 963

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Your callback function is wrong implemented

add_meta_box( 
             'post_format_box'
            ,__( 'Post Format Content', self::LANG )
            ,@$this->render()
            ,'post' 
            ,'advanced'
            ,'high'
        );

Should be

add_meta_box( 
             'post_format_box'
            ,__( 'Post Format Content', self::LANG )
            ,array($this, 'render)
            ,'post' 
            ,'advanced'
            ,'high'
        );
share|improve this answer
    
omg. thanks. working all day inside the class and ... so (...) +1 & solution. –  kaiser Apr 14 '11 at 14:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.