wp_iframe( string|callable $content_func )
Adds the iframe to display content for the media upload page
Description Description
Parameters Parameters
- $content_func
-
(string|callable) (Required)
Source Source
File: wp-admin/includes/media.php
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | function wp_iframe( $content_func /* ... */ ) { _wp_admin_html_begin(); ?> <title><?php bloginfo( 'name' ); ?> › <?php _e( 'Uploads' ); ?> — <?php _e( 'WordPress' ); ?></title> <?php wp_enqueue_style( 'colors' ); // Check callback name for 'media' if ( ( is_array ( $content_func ) && ! empty ( $content_func [1] ) && 0 === strpos ( (string) $content_func [1], 'media' ) ) || ( ! is_array ( $content_func ) && 0 === strpos ( $content_func , 'media' ) ) ) { wp_enqueue_style( 'deprecated-media' ); } wp_enqueue_style( 'ie' ); ?> <script type= "text/javascript" > addLoadEvent = function (func){ if (typeof jQuery!= "undefined" )jQuery(document).ready(func); else if (typeof wpOnload!= 'function' ){wpOnload=func;} else { var oldonload=wpOnload;wpOnload= function (){oldonload();func();}}}; var ajaxurl = '<?php echo admin_url( ' admin-ajax.php ', ' relative ' ); ?>' , pagenow = 'media-upload-popup' , adminpage = 'media-upload-popup' , isRtl = <?php echo (int) is_rtl(); ?>; </script> <?php /** This action is documented in wp-admin/admin-header.php */ do_action( 'admin_enqueue_scripts' , 'media-upload-popup' ); /** * Fires when admin styles enqueued for the legacy (pre-3.5.0) media upload popup are printed. * * @since 2.9.0 */ do_action( 'admin_print_styles-media-upload-popup' ); /** This action is documented in wp-admin/admin-header.php */ do_action( 'admin_print_styles' ); /** * Fires when admin scripts enqueued for the legacy (pre-3.5.0) media upload popup are printed. * * @since 2.9.0 */ do_action( 'admin_print_scripts-media-upload-popup' ); /** This action is documented in wp-admin/admin-header.php */ do_action( 'admin_print_scripts' ); /** * Fires when scripts enqueued for the admin header for the legacy (pre-3.5.0) * media upload popup are printed. * * @since 2.9.0 */ do_action( 'admin_head-media-upload-popup' ); /** This action is documented in wp-admin/admin-header.php */ do_action( 'admin_head' ); if ( is_string ( $content_func ) ) { /** * Fires in the admin header for each specific form tab in the legacy * (pre-3.5.0) media upload popup. * * The dynamic portion of the hook, `$content_func`, refers to the form * callback for the media upload type. Possible values include * 'media_upload_type_form', 'media_upload_type_url_form', and * 'media_upload_library_form'. * * @since 2.5.0 */ do_action( "admin_head_{$content_func}" ); } $body_id_attr = '' ; if ( isset( $GLOBALS [ 'body_id' ] ) ) { $body_id_attr = ' id="' . $GLOBALS [ 'body_id' ] . '"' ; } ?> </head> <body<?php echo $body_id_attr ; ?> class = "wp-core-ui no-js" > <script type= "text/javascript" > document.body.className = document.body.className.replace( 'no-js' , 'js' ); </script> <?php $args = func_get_args(); $args = array_slice ( $args , 1 ); call_user_func_array( $content_func , $args ); /** This action is documented in wp-admin/admin-footer.php */ do_action( 'admin_print_footer_scripts' ); ?> <script type= "text/javascript" > if (typeof wpOnload== 'function' )wpOnload();</script> </body> </html> <?php } |
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Demonstrate how to add new tab in the media upload iframe
// Add the tab.
add_filter(
'media_upload_tabs'
,
'wpdocs_my_upload_tab'
);
function
wpdocs_my_upload_tab(
$tabs
) {
$tabs
[
'mytabname'
] = __(
'My Tab Name'
,
'textdomain'
);
return
$tabs
;
}
// Call the new tab with wp_iframe.
add_action(
'media_upload_mytabname'
,
'wpdocs_add_my_new_form'
);
function
wpdocs_add_my_new_form() {
wp_iframe(
'wpdocs_my_new_form'
);
}
// The tab content.
function
wpdocs_my_new_form() {
echo
'<p>'
. __(
'Example HTML content goes here.'
,
'textdomain'
) .
'</p>'
;
}
Expand full source codeCollapse full source code