Make WordPress Core


Ignore:
Timestamp:
08/03/2011 10:19:00 AM (13 years ago)
Author:
azaozz
Message:

Editor API enhancement, first run (still needs some work), see #17144

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r18489 r18498  
    374374 * @since 2.5.0
    375375 */
    376 function media_buttons() {
    377     $do_image = $do_audio = $do_video = true;
    378     if ( is_multisite() ) {
    379         $media_buttons = get_site_option( 'mu_media_buttons' );
    380         if ( empty($media_buttons['image']) )
    381             $do_image = false;
    382         if ( empty($media_buttons['audio']) )
    383             $do_audio = false;
    384         if ( empty($media_buttons['video']) )
    385             $do_video = false;
    386     }
     376function media_buttons($editor_id = 'content') {
    387377    $out = '';
    388378
    389     if ( $do_image )
    390         $out .= _media_button(__('Add an Image'), 'images/media-button-image.gif?ver=20100531', 'image');
    391     if ( $do_video )
    392         $out .= _media_button(__('Add Video'), 'images/media-button-video.gif?ver=20100531', 'video');
    393     if ( $do_audio )
    394         $out .= _media_button(__('Add Audio'), 'images/media-button-music.gif?ver=20100531', 'audio');
    395 
    396     $out .= _media_button(__('Add Media'), 'images/media-button-other.gif?ver=20100531', 'media');
     379    if ( is_multisite() )
     380        $_buttons = get_site_option('mu_media_buttons');
     381    else
     382        $_buttons = array( 'image' => true, 'video' => true, 'audio' => true );
     383
     384    if ( !empty($_buttons['image']) )
     385        $out .= _media_button(__('Add an Image'), 'images/media-button-image.gif?ver=20100531', 'image', $editor_id);
     386    if ( !empty($_buttons['video']) )
     387        $out .= _media_button(__('Add Video'), 'images/media-button-video.gif?ver=20100531', 'video', $editor_id);
     388    if ( !empty($_buttons['audio']) )
     389        $out .= _media_button(__('Add Audio'), 'images/media-button-music.gif?ver=20100531', 'audio', $editor_id);
     390
     391    $out .= _media_button(__('Add Media'), 'images/media-button-other.gif?ver=20100531', 'media', $editor_id);
    397392
    398393    $context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
     
    402397add_action( 'media_buttons', 'media_buttons' );
    403398
    404 function _media_button($title, $icon, $type) {
    405     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' onclick='return false;' /></a>";
     399function _media_button($title, $icon, $type, $id) {
     400    return "<a href='" . esc_url( get_upload_iframe_src($type) ) . "' id='{$id}-add_{$type}' class='thickbox add_$type' title='$title'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' onclick='return false;' /></a>";
    406401}
    407402
Note: See TracChangeset for help on using the changeset viewer.