media_buttons() - WordPress 函数参考中文文档

返回介绍

media_buttons()

发布于 2017-09-11 字数2108 浏览 779 评论 0

media_buttons( string $editor_id = 'content' )

Adds the media button to the editor


描述


参数

$editor_id

(string)
(Optional)

Default value: ‘content’


源代码

File: wp-admin/includes/media.php

function media_buttons($editor_id = 'content') {
	static $instance = 0;
	$instance++;

	$post = get_post();
	if ( ! $post && ! empty( $GLOBALS['post_ID'] ) )
		$post = $GLOBALS['post_ID'];

	wp_enqueue_media( array(
		'post' => $post
	) );

	$img = '<span class="wp-media-buttons-icon"></span> ';

	$id_attribute = $instance === 1 ? ' id="insert-media-button"' : '';
	printf( '<button type="button"%s class="button insert-media add_media" data-editor="%s">%s</button>',
		$id_attribute,
		esc_attr( $editor_id ),
		$img . __( 'Add Media' )
	);
	/**
	 * Filters the legacy (pre-3.5.0) media buttons.
	 *
	 * Use {@see 'media_buttons'} action instead.
	 *
	 * @since 2.5.0
	 * @deprecated 3.5.0 Use {@see 'media_buttons'} action instead.
	 *
	 * @param string $string Media buttons context. Default empty.
	 */
	$legacy_filter = apply_filters( 'media_buttons_context', '' );

	if ( $legacy_filter ) {
		//

更新日志

Version 描述
2.5.0 Introduced.

相关函数

Uses

  • wp-admin/includes/media.php:
    media_buttons_context
  • wp-includes/l10n.php:
    __()
  • wp-includes/formatting.php:
    esc_attr()
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/media.php:
    wp_enqueue_media()
  • wp-includes/post.php:
    get_post()
  • Show 1 more use
    Hide more uses


User Contributed Notes

上一篇:mb_substr()

下一篇:media_handle_sideload()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!