The is the block of code in question:
function media_buttons($editor_id = 'content') {
$context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
$img = '<img src="' . esc_url( admin_url( 'images/media-button.png?ver=20111005' ) ) . '" width="15" height="15" />';
echo '<a href="' . esc_url( get_upload_iframe_src() ) . '" title="' . esc_attr__( 'Add Media' ) . '" rel="nofollow">' . sprintf( $context, $img ) . '</a>';
}
add_action( 'media_buttons', 'media_buttons' );
function _media_button($title, $icon, $type, $id) {
return "<a href='" . esc_url( get_upload_iframe_src($type) ) . "' title='" . esc_attr( $title ) . "' rel="nofollow"><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' onclick='return false;' /></a>";
}
function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) {
global $post_ID;
if ( empty( $post_id ) )
$post_id = $post_ID;
$upload_iframe_src = add_query_arg( 'post_id', (int) $post_id, admin_url('media-upload.php') );
if ( $type && 'media' != $type )
$upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
if ( ! empty( $tab ) )
$upload_iframe_src = add_query_arg('tab', $tab, $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);
}
Posted 12 years ago on Monday August 6, 2012 |
Permalink