WordPress.org

Make WordPress Core

Ticket #13937: add_meta_box.diff

File add_meta_box.diff, 2.4 KB (added by scribu, 8 years ago)
  • wp-admin/includes/template.php

     
    27612761/**
    27622762 * Add a meta box to an edit form.
    27632763 *
     2764 * The list of arguments is below:
     2765 *              'id' (string) String for use in the 'id' attribute of tags.
     2766 *              'title' (string) Title of the meta box.
     2767 *              'callback' (callback) Function that fills the box with the desired content. The function should echo its output.
     2768 *              'callback_args' (array) A list of arguments to pass to the callback.
     2769 *              'page' (string) The type of edit page on which to show the box (post, page, link).
     2770 *              'context' (string) The context within the page where the boxes should show ('normal', 'advanced').
     2771 *              'priority' (string) The priority within the context where the boxes should show ('high', 'low').
     2772 *
    27642773 * @since 2.5.0
    27652774 *
    2766  * @param string $id String for use in the 'id' attribute of tags.
    2767  * @param string $title Title of the meta box.
    2768  * @param string $callback Function that fills the box with the desired content. The function should echo its output.
    2769  * @param string $page The type of edit page on which to show the box (post, page, link).
    2770  * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
    2771  * @param string $priority The priority within the context where the boxes should show ('high', 'low').
     2775 * @param string|array $args List of arguments
    27722776 */
    2773 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) {
     2777function add_meta_box( $args ) {
     2778
     2779        $argc = func_num_args();
     2780
     2781        if ( $argc > 1 ) {
     2782                _deprecated_argument( __FUNCTION__, '3.1', __('Passing individual arguments is deprecated. Use an associative array of arguments instead.') );
     2783
     2784                $argv = func_get_args();
     2785
     2786                $args = array();
     2787                foreach ( array( 'id', 'title', 'callback', 'page', 'context', 'priority', 'callback_args' ) as $i => $name ) {
     2788                        if ( $i < $argc )
     2789                                $args[ $name ] = $argv[ $i ];
     2790                        else
     2791                                break;
     2792                }
     2793        }
     2794
     2795        $defaults = array(
     2796                'id' => '',
     2797                'title' => '',
     2798                'callback' => '',
     2799                'callback_args' => null,
     2800                'page' => '',
     2801                'context' => 'advanced',
     2802                'priority' => 'default',
     2803        );
     2804
     2805        extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
     2806
    27742807        global $wp_meta_boxes;
    27752808
    27762809        if ( !isset($wp_meta_boxes) )