返回介绍

wp_iframe()

发布于 2017-09-11 12:11:29 字数 6177 浏览 1004 评论 0 收藏 0

wp_iframe( string|callable $content_func )

Adds the iframe to display content for the media upload page


description


参数

$content_func

(string|callable) (Required)


源代码

File: wp-admin/includes/media.php

function wp_iframe($content_func /* ... */) {
	_wp_admin_html_begin();
?>
<title><?php bloginfo('name') ?> &rsaquo; <?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}" );
}
?>
</head>
<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> 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
}

更新日志

Versiondescription
2.5.0Introduced.

相关函数

Uses

  • wp-admin/includes/template.php: _wp_admin_html_begin()
  • wp-admin/includes/media.php: admin_print_styles-media-upload-popup
  • wp-admin/includes/media.php: admin_print_scripts-media-upload-popup
  • wp-admin/includes/media.php: admin_head-media-upload-popup
  • wp-admin/includes/media.php: admin_head_{$content_func}
  • wp-admin/admin-header.php: admin_enqueue_scripts
  • wp-admin/admin-header.php: admin_print_styles
  • wp-admin/admin-header.php: admin_print_scripts
  • wp-admin/admin-header.php: admin_head
  • wp-admin/admin-footer.php: admin_print_footer_scripts
  • wp-includes/l10n.php: _e()
  • wp-includes/general-template.php: bloginfo()
  • wp-includes/l10n.php: is_rtl()
  • wp-includes/link-template.php: admin_url()
  • wp-includes/functions.wp-styles.php: wp_enqueue_style()
  • wp-includes/plugin.php: do_action()
  • Show 11 more uses Hide more uses

Used By

  • wp-admin/includes/media.php: wp_media_upload_handler()
  • wp-admin/includes/media.php: media_upload_gallery()
  • wp-admin/includes/media.php: media_upload_library()

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    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>';
    }
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文