Using WordPress ‘media_upload_header()’ PHP function

The media_upload_header WordPress PHP function outputs the legacy media upload header.

Usage

media_upload_header();

Parameters

  • None

More information

See WordPress Developer Resources: media_upload_header

Examples

Displaying the legacy media upload header in a custom admin page

// Add a custom admin page
add_action('admin_menu', 'custom_media_upload_page');
function custom_media_upload_page() {
    add_menu_page('Custom Media Upload', 'Custom Media Upload', 'manage_options', 'custom-media-upload', 'custom_media_upload_callback', '', 6);
}

// Callback function for the custom admin page
function custom_media_upload_callback() {
    // Output the legacy media upload header
    **media_upload_header**();
    // Your custom content goes here
}

Adding the legacy media upload header to a custom meta box

// Add a custom meta box
add_action('add_meta_boxes', 'add_custom_media_upload_metabox');
function add_custom_media_upload_metabox() {
    add_meta_box('custom-media-upload', 'Custom Media Upload', 'custom_media_upload_metabox_callback', 'post');
}

// Callback function for the custom meta box
function custom_media_upload_metabox_callback() {
    // Output the legacy media upload header
    **media_upload_header**();
    // Your custom content goes here
}

Displaying the legacy media upload header in a custom plugin settings page

// Add a custom plugin settings page
add_action('admin_menu', 'custom_plugin_settings_page');
function custom_plugin_settings_page() {
    add_options_page('Custom Plugin Settings', 'Custom Plugin Settings', 'manage_options', 'custom-plugin-settings', 'custom_plugin_settings_callback');
}

// Callback function for the custom plugin settings page
function custom_plugin_settings_callback() {
    // Output the legacy media upload header
    **media_upload_header**();
    // Your custom content goes here
}

Displaying the legacy media upload header in a custom theme options page

// Add a custom theme options page
add_action('admin_menu', 'custom_theme_options_page');
function custom_theme_options_page() {
    add_theme_page('Custom Theme Options', 'Custom Theme Options', 'edit_theme_options', 'custom-theme-options', 'custom_theme_options_callback');
}

// Callback function for the custom theme options page
function custom_theme_options_callback() {
    // Output the legacy media upload header
    **media_upload_header**();
    // Your custom content goes here
}

Displaying the legacy media upload header in a custom post type edit screen

// Register a custom post type
add_action('init', 'register_custom_post_type');
function register_custom_post_type() {
    $args = array(
        'label' => 'Custom Post Type',
        'public' => true,
        'supports' => array('title', 'editor', 'thumbnail')
    );
    register_post_type('custom_post_type', $args);
}

// Add a custom meta box to the custom post type edit screen
add_action('add_meta_boxes_custom_post_type', 'add_custom_media_upload_metabox_to_custom_post_type');
function add_custom_media_upload_metabox_to_custom_post_type() {
    add_meta_box('custom-media-upload', 'Custom Media Upload', 'custom_media_upload_metabox_to_custom_post_type_callback', null, 'normal', 'default');
}

// Callback function for the custom meta box
function custom_media_upload_metabox_to_custom_post_type_callback() {
    // Output the legacy media