Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 11 years ago

#13305 closed enhancement (wontfix)

Allow multiple post types to use same add_meta_box call (Pass an array for the $page arg)

Reported by: idealien's profile idealien Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

The $page parameter of add_meta_box http://codex.wordpress.org/Function_Reference/add_meta_box currently only accepts a string to "The type of Write screen on which to show the edit screen section ('post', 'page', or 'link')".

In discussing best way to allow for multiple post types to use the same meta box with 3.0 (beta), scribu indicated that currently one would have to call add_meta_box twice.

scibu: come to think of it, you should be able to pass an array for the $page arg

Change History (9)

#1 @idealien
15 years ago

  • Cc idealien added

#2 @idealien
15 years ago

  • Milestone changed from Unassigned to 3.1

#3 @scribu
15 years ago

  • Keywords > 3.0 removed

#4 @scribu
15 years ago

  • Type changed from defect (bug) to enhancement

#5 @kevinB
15 years ago

  • Cc kevinB added

#6 @nacin
15 years ago

Should be simple enough to check if $page is an array, and if so, call add_meta_box again with the same parameters otherwise.

Related: #13937

#7 @markjaquith
15 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Just leverage the variables passed to the do_meta_boxes callback.

function your_callback( $page, $context ) {
    if ( in_array( $page,  array( 'post', 'page' ) ) && 'normal' == $context )
        add_meta_box( 'your-id', 'Title', 'your_box_callback', $page, $context, 'high' );
}

add_action( 'do_meta_boxes', 'your_callback', 10, 2 );

#8 @nacin
15 years ago

  • Milestone Awaiting Triage deleted

This ticket was mentioned in IRC in #wordpress-dev by SergeyBiryukov. View the logs.


11 years ago

Note: See TracTickets for help on using tickets.