prepare_meta_boxes(); $this->add_wordpress_action( 'admin_init','register_meta_boxes' ); } /** * Adding action wrapper * * @param string $action Action name. * @param string $method_name Method which will be executed on action. * @param int $priority Priority. * @param int $accepted_args Number of accepted arguments. */ public function add_wordpress_action( $action, $method_name, $priority = 10, $accepted_args = 1 ) { add_action( $action, array( $this, $method_name ), $priority, $accepted_args ); } /** * Method where we will define meta boxes. */ public function prepare_meta_boxes() { $this->meta_boxes = array(); $this->meta_boxes[] = array( 'id' => 'post_template_metabox', 'title' => __( 'Template', 'bloggster' ), 'pages' => array( 'post' ), 'context' => 'side', 'priority' => 'high', 'autosave' => true, 'fields' => array( array( 'name' => __( 'Select template', 'bloggster' ), 'id' => 'post_template', 'type' => 'select', 'options' => array( 'rsidebar' => __( 'Right sidebar', 'bloggster' ), 'fullwidth' => __( 'Full width', 'bloggster' ), ), ), ), ); } /** * Method which will trigger the loop and register defined metaboxes */ public function register_meta_boxes() { // Make sure there's no errors when the plugin is deactivated or during upgrade. if ( class_exists( 'RW_Meta_Box' ) ) { foreach ( $this->meta_boxes as $meta_box ) { new RW_Meta_Box( $meta_box ); } } } } new Post_Custom_Fields(); ?>