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.

I was use to pass value to function for the below menu.

add_menu_page('Competition Manager 2013-2014', '2013-2014', 'manage_options', 'manager_2013_2014', 'manager_2013_2014', plugins_url( 'competition-manager/images/cup.png' ), 81 );
share|improve this question
1  
This is not clear. Please expand upon the description of the problem. –  s_ha_dum Apr 30 at 21:53

1 Answer 1

Don’t use a function for the callback, use a class. Something like this:

class Competition_Manager_Page
{
    private $extra;

    public function set_extra( $value )
    {
        $this->extra = $value;
    }

    public function render()
    {
        // show you page content, then:
        print $this->extra;
    }
}

You can extend the class’ functionality later.

Now, when you register the menu, create an instance of that class first, and add you extra data:

$page = new Competition_Manager_Page;
$page->set_extra( 'Test' );

add_menu_page(
    'Competition Manager 2013-2014',
    '2013-2014',
    'manage_options',
    'manager_2013_2014',
    array( $page, 'render' ), // replacement for the former function
    plugins_url( 'competition-manager/images/cup.png' ), 81
);
share|improve this answer
    
Thanks for the replay! –  user1581151 May 6 at 7:22

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.