WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/03/2010 02:58:59 AM (10 years ago)
Author:
nacin
Message:

Move some post and taxonomy functions from admin/includes to wp-includes in preparation for QuickPress template tag. Moves get_tags_to_edit, get_terms_to_edit, get_default_post_to_edit, media_buttons, _media_button, get_upload_iframe_src. Also introduce get_media_buttons as a wrapper for media_buttons. props jorbin, see #14966.

File:
1 edited

Legend:

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

    r15590 r15688  
    13961396    $oembed->providers[$format] = array( $provider, $regex );
    13971397}
     1398
     1399/**
     1400 *
     1401 *
     1402 *
     1403 */
     1404function get_media_buttons(){
     1405    $do_image = $do_audio = $do_video = true;
     1406    if ( is_multisite() ) {
     1407        $media_buttons = get_site_option( 'mu_media_buttons' );
     1408        if ( empty($media_buttons['image']) )
     1409            $do_image = false;
     1410        if ( empty($media_buttons['audio']) )
     1411            $do_audio = false;
     1412        if ( empty($media_buttons['video']) )
     1413            $do_video = false;
     1414    }
     1415    $out = '';
     1416
     1417    if ( $do_image )
     1418        $out .= _media_button(__('Add an Image'), 'images/media-button-image.gif?ver=20100531', 'image');
     1419    if ( $do_video )
     1420        $out .= _media_button(__('Add Video'), 'images/media-button-video.gif?ver=20100531', 'video');
     1421    if ( $do_audio )
     1422        $out .= _media_button(__('Add Audio'), 'images/media-button-music.gif?ver=20100531', 'audio');
     1423
     1424    $out .= _media_button(__('Add Media'), 'images/media-button-other.gif?ver=20100531', 'media');
     1425
     1426    $context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
     1427
     1428    return sprintf($context, $out);
     1429
     1430
     1431}
     1432
     1433/**
     1434 * {@internal Missing Short Description}}
     1435 *
     1436 * @since unknown
     1437 */
     1438function media_buttons() {
     1439    echo get_media_buttons();
     1440}
     1441add_action( 'media_buttons', 'media_buttons' );
     1442
     1443function _media_button($title, $icon, $type) {
     1444    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>";
     1445}
     1446
     1447function get_upload_iframe_src($type) {
     1448    global $post_ID, $temp_ID;
     1449    $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
     1450    $upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php');
     1451
     1452    if ( 'media' != $type )
     1453        $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
     1454    $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src);
     1455
     1456    return add_query_arg('TB_iframe', true, $upload_iframe_src);
     1457}
Note: See TracChangeset for help on using the changeset viewer.