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-admin/includes/media.php

    r15590 r15688  
    344344</html>
    345345<?php
    346 }
    347 
    348 /**
    349  * {@internal Missing Short Description}}
    350  *
    351  * @since unknown
    352  */
    353 function media_buttons() {
    354     $do_image = $do_audio = $do_video = true;
    355     if ( is_multisite() ) {
    356         $media_buttons = get_site_option( 'mu_media_buttons' );
    357         if ( empty($media_buttons['image']) )
    358             $do_image = false;
    359         if ( empty($media_buttons['audio']) )
    360             $do_audio = false;
    361         if ( empty($media_buttons['video']) )
    362             $do_video = false;
    363     }
    364     $out = '';
    365 
    366     if ( $do_image )
    367         $out .= _media_button(__('Add an Image'), 'images/media-button-image.gif?ver=20100531', 'image');
    368     if ( $do_video )
    369         $out .= _media_button(__('Add Video'), 'images/media-button-video.gif?ver=20100531', 'video');
    370     if ( $do_audio )
    371         $out .= _media_button(__('Add Audio'), 'images/media-button-music.gif?ver=20100531', 'audio');
    372 
    373     $out .= _media_button(__('Add Media'), 'images/media-button-other.gif?ver=20100531', 'media');
    374 
    375     $context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
    376 
    377     printf($context, $out);
    378 }
    379 add_action( 'media_buttons', 'media_buttons' );
    380 
    381 function _media_button($title, $icon, $type) {
    382     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>";
    383 }
    384 
    385 function get_upload_iframe_src($type) {
    386     global $post_ID, $temp_ID;
    387     $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
    388     $upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php');
    389 
    390     if ( 'media' != $type )
    391         $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
    392     $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src);
    393 
    394     return add_query_arg('TB_iframe', true, $upload_iframe_src);
    395346}
    396347
Note: See TracChangeset for help on using the changeset viewer.