Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added support for "context" and "priority"

Add support for the "context" and "priority" arguments in the
"add_meta_box" function. These arguments have been added to the
"register_post_options_section" method, which are then passed on to the
call to the "add_meta_box" function. This update allows the user to have
more control over the placement of the meta boxes.
  • Loading branch information...
commit e80e21baa2eb994c77964615fd0fc0db4d0699ce 1 parent ff1ac7d
Zack Tollman authored
Showing with 14 additions and 12 deletions.
  1. +14 −12 post-options-api.php
View
26 post-options-api.php
@@ -267,7 +267,7 @@ function _admin_init() {
// Adds the metabox for each post type
foreach ( $this->post_types as $post_type => $sections )
foreach ( $sections as $section_id )
- add_meta_box( 'post-options-' . $section_id, $this->sections[$section_id]['title'], array( &$this, '_meta_box_post_options' ), $post_type, 'normal', 'default', array( 'section_id' => $section_id ) );
+ add_meta_box( 'post-options-' . $section_id, $this->sections[$section_id]['title'], array( &$this, '_meta_box_post_options' ), $post_type, $this->sections[$section_id]['context'], $this->sections[$section_id]['priority'], array( 'section_id' => $section_id ) );
// Register the save_post action (for all post types)
add_action( 'save_post', array( &$this, '_save_post' ), 10, 2 );
@@ -425,17 +425,19 @@ function _meta_box_post_options( $post, $metabox ) {
}
}
- // Register a post options section
- public function register_post_options_section( $id, $title ) {
- if ( ! isset( $this->sections[$id] ) ) {
- $this->sections[$id] = array(
- 'title' => $title
- );
- return true;
- }
-
- return false;
- }
+ // Register a post options section
+ public function register_post_options_section( $id, $title, $context = 'advanced', $priority = 'default') {
+ if ( ! isset( $this->sections[$id] ) ) {
+ $this->sections[$id] = array(
+ 'title' => $title,
+ 'context' => $context,
+ 'priority' => $priority
+ );
+ return true;
+ }
+
+ return false;
+ }
/*
* Register Post Option
Please sign in to comment.
Something went wrong with that request. Please try again.