Docs and breathing room for get_media_buttons() and friends. see #14966.

git-svn-id: http://svn.automattic.com/wordpress/trunk@15689 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-10-03 03:08:39 +00:00
parent 4e666d5d44
commit 054e18cb05
1 changed files with 31 additions and 18 deletions

View File

@ -1397,33 +1397,35 @@ function wp_oembed_add_provider( $format, $provider, $regex = false ) {
}
/**
* Generate HTML for the editor media buttons (image, video, audio).
*
* @since 3.1.0
*
*
* @return string HTML
*/
function get_media_buttons(){
function get_media_buttons() {
$do_image = $do_audio = $do_video = true;
if ( is_multisite() ) {
$media_buttons = get_site_option( 'mu_media_buttons' );
if ( empty($media_buttons['image']) )
if ( empty( $media_buttons['image'] ) )
$do_image = false;
if ( empty($media_buttons['audio']) )
if ( empty( $media_buttons['audio'] ) )
$do_audio = false;
if ( empty($media_buttons['video']) )
if ( empty( $media_buttons['video'] ) )
$do_video = false;
}
$out = '';
if ( $do_image )
$out .= _media_button(__('Add an Image'), 'images/media-button-image.gif?ver=20100531', 'image');
$out .= _media_button( __( 'Add an Image' ), 'images/media-button-image.gif?ver=20100531', 'image' );
if ( $do_video )
$out .= _media_button(__('Add Video'), 'images/media-button-video.gif?ver=20100531', 'video');
$out .= _media_button( __( 'Add Video' ), 'images/media-button-video.gif?ver=20100531', 'video' );
if ( $do_audio )
$out .= _media_button(__('Add Audio'), 'images/media-button-music.gif?ver=20100531', 'audio');
$out .= _media_button( __( 'Add Audio' ), 'images/media-button-music.gif?ver=20100531', 'audio' );
$out .= _media_button(__('Add Media'), 'images/media-button-other.gif?ver=20100531', 'media');
$out .= _media_button( __( 'Add Media' ), 'images/media-button-other.gif?ver=20100531', 'media' );
$context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
$context = apply_filters( 'media_buttons_context', __( 'Upload/Insert %s' ) );
return sprintf($context, $out);
@ -1440,18 +1442,29 @@ function media_buttons() {
}
add_action( 'media_buttons', 'media_buttons' );
function _media_button($title, $icon, $type) {
return "<a href='" . esc_url( get_upload_iframe_src($type) ) . "' id='add_$type' class='thickbox' title='$title'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' /></a>";
/**
* {@internal Missing Short Description}}
*
* @since unknown
* @access private
*/
function _media_button( $title, $icon, $type ) {
return "<a href='" . esc_url( get_upload_iframe_src( $type ) ) . "' id='add_$type' class='thickbox' title='$title'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' /></a>";
}
function get_upload_iframe_src($type) {
/**
* {@internal Missing Short Description}}
*
* @since unknown
*/
function get_upload_iframe_src( $type ) {
global $post_ID, $temp_ID;
$uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
$upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php');
$uploading_iframe_ID = (int) ( 0 == $post_ID ? $temp_ID : $post_ID );
$upload_iframe_src = add_query_arg( 'post_id', $uploading_iframe_ID, 'media-upload.php' );
if ( 'media' != $type )
$upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
$upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src);
$upload_iframe_src = add_query_arg( 'type', $type, $upload_iframe_src );
$upload_iframe_src = apply_filters( $type . '_upload_iframe_src', $upload_iframe_src );
return add_query_arg('TB_iframe', true, $upload_iframe_src);
return add_query_arg( 'TB_iframe', true, $upload_iframe_src );
}