函数
media_buttons ( $editor_id = 'content' )
- 参数
-
-
(string)
$editor_id- Required: 否
- Default: ‘content’
-
(string)
- 定义位置
-
-
wp-admin/includes/media.php
, line 632
-
wp-admin/includes/media.php
- 引入
- 2.5.0
- 弃用
- –
Adds the media button to the editor.
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 = ' ';
$id_attribute = 1 === $instance ? ' id="insert-media-button"' : '';
printf(
'',
$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_deprecated( 'media_buttons_context', array( '' ), '3.5.0', 'media_buttons' );
if ( $legacy_filter ) {
// #WP22559. Close if a plugin started by closing to open their own tag.
if ( 0 === stripos( trim( $legacy_filter ), '' ) ) {
$legacy_filter .= '';
}
echo $legacy_filter;
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。