__('Choose File'), // handler action suffix => tab text 'gallery' => __('Gallery'), 'library' => __('Media Library'), ); return apply_filters('media_upload_tabs', $_default_tabs); } function update_gallery_tab($tabs) { global $wpdb; if ( !isset($_REQUEST['post_id']) ) { unset($tabs['gallery']); return $tabs; } if ( intval($_REQUEST['post_id']) ) $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id']))); $tabs['gallery'] = sprintf(__('Gallery (%s)'), "$attachments"); return $tabs; } add_filter('media_upload_tabs', 'update_gallery_tab'); function the_media_upload_tabs() { $tabs = media_upload_tabs(); if ( !empty($tabs) ) { echo "
\n"; } } function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') { $html = get_image_tag($id, $alt, $title, $align, $size); $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : ''; if ( $url ) $html = '$html"; $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size ); return $html; } function media_send_to_editor($html) { ?> false); $file = wp_handle_upload($_FILES[$file_id], $overrides); if ( isset($file['error']) ) return new wp_error( 'upload_error', $file['error'] ); $url = $file['url']; $type = $file['type']; $file = $file['file']; $title = preg_replace('/\.[^.]+$/', '', basename($file)); $content = ''; // use image exif/iptc data for title and caption defaults if possible if ( $image_meta = @wp_read_image_metadata($file) ) { if ( trim($image_meta['title']) ) $title = $image_meta['title']; if ( trim($image_meta['caption']) ) $content = $image_meta['caption']; } // Construct the attachment array $attachment = array_merge( array( 'post_mime_type' => $type, 'guid' => $url, 'post_parent' => $post_id, 'post_title' => $title, 'post_content' => $content, ), $post_data ); // Save the data $id = wp_insert_attachment($attachment, $file, $post_parent); if ( !is_wp_error($id) ) { wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); } return $id; } function media_sideload_image($file, $post_id) { if (!empty($file) ) { // Upload File button was clicked $file_array['name'] = basename($file); $file_array['tmp_name'] = download_url($file); $sideload = media_handle_sideload($file_array, $post_id); $id = $sideload['id']; $src = $sideload['src']; unset($file_array['tmp_name']); unset($file_array); if ( is_wp_error($id) ) { $errors['upload_error'] = $id; $id = false; } } if ( !empty($src) && !strpos($src, '://') ) $src = "http://$src"; /*$alt = attribute_escape($_POST['insertonly']['alt']); if ( isset($_POST['insertonly']['align']) ) { $align = attribute_escape($_POST['insertonly']['align']); $class = " class='align$align'"; } */ if ( !empty($src) ) $html = ""; return $html; } function media_handle_sideload($file_array, $post_id, $post_data = array()) { $overrides = array('test_form'=>false); $file = wp_handle_sideload($file_array, $overrides); if ( isset($file['error']) ) return new wp_error( 'upload_error', $file['error'] ); $url = $file['url']; $type = $file['type']; $file = $file['file']; $title = preg_replace('/\.[^.]+$/', '', basename($file)); $content = ''; // use image exif/iptc data for title and caption defaults if possible if ( $image_meta = @wp_read_image_metadata($file) ) { if ( trim($image_meta['title']) ) $title = $image_meta['title']; if ( trim($image_meta['caption']) ) $content = $image_meta['caption']; } // Construct the attachment array $attachment = array_merge( array( 'post_mime_type' => $type, 'guid' => $url, 'post_parent' => $post_id, 'post_title' => $title, 'post_content' => $content, ), $post_data ); // Save the data $id = wp_insert_attachment($attachment, $file, $post_parent); if ( !is_wp_error($id) ) { wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); } return array('id' => $id, 'src' => $url); } // wrap iframe content (produced by $content_func) in a doctype, html head/body etc // any additional function args will be passed to content_func function wp_iframe($content_func /* ... */) { ?> >$filename | |
$post->post_mime_type | |
" . mysql2date($post->post_date, get_option('time_format')) . " | |
" . apply_filters('media_meta', '', $post) . " | |
$send $delete | |
\n\t\t\t | ";
if ( !empty($field[$field['input']]) )
$item .= $field[$field['input']];
elseif ( $field['input'] == 'textarea' ) {
$item .= "";
} else {
$item .= "";
}
if ( !empty($field['helps']) )
$item .= " " . join( " \n", array_unique((array) $field['helps']) ) . ' '; $item .= " | \n\t\t
---|---|
$html | |
{$form_fields['_final']} |
* | |
---|---|
* | |
' . __('Link text, e.g. "Still Alive by Jonathan Coulton"') . ' | |
* | |
---|---|
* | |
' . __('Link text, e.g. "Lucy on YouTube"') . ' | |
* | |
---|---|
* | |
' . __('Link text, e.g. "Ransom Demands (PDF)"') . ' | |