hook = $hook; $this->title = $title; $this->menu = $menu; $this->permissions = $permissions; $this->slug = $slug; $this->body_content_cb = $body_content_cb; /* Add the page */ add_action('admin_menu', array($this,'add_page')); } /** * Adds the custom page. * Adds callbacks to the load-* and admin_footer-* hooks */ function add_page(){ /* Add the page */ $this->page = add_submenu_page($this->hook,$this->title, $this->menu, $this->permissions,$this->slug, array($this,'render_page'),10); /* Add callbacks for this screen only */ add_action('load-'.$this->page, array($this,'page_actions'),9); add_action('admin_footer-'.$this->page,array($this,'footer_scripts')); } /** * Prints the jQuery script to initiliase the metaboxes * Called on admin_footer-* */ function footer_scripts(){ ?> page, null); do_action('add_meta_boxes', $this->page, null); /* User can choose between 1 or 2 columns (default 2) */ add_screen_option('layout_columns', array('max' => 2, 'default' => 2) ); /* Enqueue WordPress' script for handling the metaboxes */ wp_enqueue_script('postbox'); } /** * Renders the page */ function render_page(){ ?>
This class is just a simple example of a custom admin page with metaboxes. The class is intended to act as a skeleton class. You can use it to add several admin pages, but you might find that some pages require a seperate class extension.
This content always sits at the top of the page
An example of a metabox