Media library work from andy. see #5911
git-svn-id: https://develop.svn.wordpress.org/trunk@6974 602fd350-edb4-49c9-b593-d223f7449a82
@@ -125,6 +125,8 @@ add_filter('comment_excerpt', 'convert_chars');
|
||||
add_filter('list_cats', 'wptexturize');
|
||||
add_filter('single_post_title', 'wptexturize');
|
||||
|
||||
add_filter('wp_sprintf', 'wp_sprintf_l', 10, 2);
|
||||
|
||||
// RSS filters
|
||||
add_filter('the_title_rss', 'strip_tags');
|
||||
add_filter('the_title_rss', 'ent2ncr', 8);
|
||||
|
||||
@@ -1277,4 +1277,97 @@ function wp_pre_kses_less_than_callback( $matches ) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_sprintf() - sprintf() with filters
|
||||
*/
|
||||
function wp_sprintf( $pattern ) {
|
||||
$args = func_get_args( );
|
||||
$len = strlen($pattern);
|
||||
$start = 0;
|
||||
$result = '';
|
||||
$arg_index = 0;
|
||||
while ( $len > $start ) {
|
||||
// Last character: append and break
|
||||
if ( strlen($pattern) - 1 == $start ) {
|
||||
$result .= substr($pattern, -1);
|
||||
break;
|
||||
}
|
||||
|
||||
// Literal %: append and continue
|
||||
if ( substr($pattern, $start, 2) == '%%' ) {
|
||||
$start += 2;
|
||||
$result .= '%';
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get fragment before next %
|
||||
$end = strpos($pattern, '%', $start + 1);
|
||||
if ( false === $end )
|
||||
$end = $len;
|
||||
$fragment = substr($pattern, $start, $end - $start);
|
||||
|
||||
// Fragment has a specifier
|
||||
if ( $pattern{$start} == '%' ) {
|
||||
// Find numbered arguments or take the next one in order
|
||||
if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) {
|
||||
$arg = isset($args[$matches[1]]) ? $args[$matches[1]] : '';
|
||||
$fragment = str_replace("%{$matches[1]}$", '%', $fragment);
|
||||
} else {
|
||||
++$arg_index;
|
||||
$arg = isset($args[$arg_index]) ? $args[$arg_index] : '';
|
||||
}
|
||||
|
||||
// Apply filters OR sprintf
|
||||
$_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );
|
||||
if ( $_fragment != $fragment )
|
||||
$fragment = $_fragment;
|
||||
else
|
||||
$fragment = sprintf($fragment, strval($arg) );
|
||||
}
|
||||
|
||||
// Append to result and move to next fragment
|
||||
$result .= $fragment;
|
||||
$start = $end;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_sprintf_l - List specifier %l for wp_sprintf
|
||||
*
|
||||
* @param unknown_type $pattern
|
||||
* @param unknown_type $args
|
||||
* @return unknown
|
||||
*/
|
||||
function wp_sprintf_l($pattern, $args) {
|
||||
// Not a match
|
||||
if ( substr($pattern, 0, 2) != '%l' )
|
||||
return $pattern;
|
||||
|
||||
// Nothing to work with
|
||||
if ( empty($args) )
|
||||
return '';
|
||||
|
||||
// Translate and filter the delimiter set (avoid ampersands and entities here)
|
||||
$l = apply_filters('wp_sprintf_l', array(
|
||||
'between' => _c(', |between list items'),
|
||||
'between_last_two' => _c(', and |between last two list items'),
|
||||
'between_only_two' => _c(' and |between only two list items'),
|
||||
));
|
||||
|
||||
$args = (array) $args;
|
||||
$result = array_shift($args);
|
||||
if ( count($args) == 1 )
|
||||
$result .= $l['between_two'] . array_shift($args);
|
||||
// Loop when more than two args
|
||||
while ( count($args) ) {
|
||||
$arg = array_shift($args);
|
||||
if ( $i == 1 )
|
||||
$result .= $l['between_last_two'] . $arg;
|
||||
else
|
||||
$result .= $l['between'] . $arg;
|
||||
}
|
||||
return $result . substr($pattern, 2);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -941,8 +941,7 @@ function the_editor($content, $id = 'content', $prev_id = 'title', $media_button
|
||||
|
||||
if ( $media_buttons ) { ?>
|
||||
<div id="media-buttons">
|
||||
<?php _e('Add media:'); ?>
|
||||
<?php do_action( 'media_buttons'); ?>
|
||||
<?php do_action( 'media_buttons' ); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
BIN
wp-includes/images/audio.png
Normal file
|
After Width: | Height: | Size: 574 B |
BIN
wp-includes/images/css.png
Normal file
|
After Width: | Height: | Size: 533 B |
BIN
wp-includes/images/default.png
Normal file
|
After Width: | Height: | Size: 479 B |
BIN
wp-includes/images/doc.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
wp-includes/images/exe.png
Normal file
|
After Width: | Height: | Size: 194 B |
BIN
wp-includes/images/html.png
Normal file
|
After Width: | Height: | Size: 537 B |
BIN
wp-includes/images/js.png
Normal file
|
After Width: | Height: | Size: 517 B |
BIN
wp-includes/images/pdf.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
wp-includes/images/swf.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
wp-includes/images/tar.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
wp-includes/images/text.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
wp-includes/images/video.png
Normal file
|
After Width: | Height: | Size: 596 B |
BIN
wp-includes/images/zip.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
@@ -1,5 +1,6 @@
|
||||
function uploadLoadedMultimedia() {
|
||||
jQuery("#html-upload-ui").empty();
|
||||
function uploadLoaded() {
|
||||
jQuery("#html-upload-ui").remove();
|
||||
jQuery("#flash-upload-ui").show();
|
||||
}
|
||||
|
||||
function fileDialogStart() {
|
||||
@@ -7,7 +8,7 @@ function fileDialogStart() {
|
||||
}
|
||||
|
||||
// progress and success handlers for multimedia multi uploads
|
||||
function fileQueuedMultimedia(fileObj) {
|
||||
function fileQueued(fileObj) {
|
||||
// Create a progress bar containing the filename
|
||||
jQuery('#multimedia-items').append('<div id="multimedia-item-' + fileObj.id + '" class="multimedia-item"><span class="filename original">' + fileObj.name + '</span><div class="progress"><div class="bar"></div></div></div>');
|
||||
|
||||
@@ -15,12 +16,14 @@ function fileQueuedMultimedia(fileObj) {
|
||||
jQuery('#insert-multimedia').attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
function uploadProgressMultimedia(fileObj, bytesDone, bytesTotal) {
|
||||
function uploadStart(fileObj) { return true; }
|
||||
|
||||
function uploadProgress(fileObj, bytesDone, bytesTotal) {
|
||||
// Lengthen the progress bar
|
||||
jQuery('#multimedia-item-' + fileObj.id + ' .bar').width(620*bytesDone/bytesTotal);
|
||||
}
|
||||
|
||||
function uploadSuccessMultimedia(fileObj, serverData) {
|
||||
function uploadSuccess(fileObj, serverData) {
|
||||
// if async-upload returned an error message, place it in the multimedia item div and return
|
||||
if ( serverData.match('media-upload-error') ) {
|
||||
jQuery('#multimedia-item-' + fileObj.id).html(serverData);
|
||||
@@ -34,7 +37,7 @@ function uploadSuccessMultimedia(fileObj, serverData) {
|
||||
jQuery('#multimedia-item-' + fileObj.id).append(serverData);
|
||||
|
||||
// Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
|
||||
jQuery('#multimedia-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail').prependTo('#multimedia-item-' + fileObj.id);
|
||||
jQuery('#multimedia-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail toggle').prependTo('#multimedia-item-' + fileObj.id);
|
||||
|
||||
// Replace the original filename with the new (unique) one assigned during upload
|
||||
jQuery('#multimedia-item-' + fileObj.id + ' .filename.original').replaceWith(jQuery('#multimedia-item-' + fileObj.id + ' .filename.new'));
|
||||
@@ -46,50 +49,24 @@ function uploadSuccessMultimedia(fileObj, serverData) {
|
||||
jQuery('#multimedia-item-' + fileObj.id + ' a.toggle').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150);jQuery(this).parent().eq(0).children('.toggle').toggle();jQuery(this).siblings('a.toggle').focus();return false;});
|
||||
|
||||
// Bind AJAX to the new Delete button
|
||||
jQuery('#multimedia-item-' + fileObj.id + ' a.delete').bind('click',function(){jQuery.ajax({url:'admin-ajax.php',type:'post',data:{id:this.id.replace(/[^0-9]/g,''),action:'delete-post',_ajax_nonce:this.href.replace(/^.*wpnonce=/,'')}});jQuery(this).parents(".multimedia-item").eq(0).slideToggle(300, function(){jQuery(this).remove();});return false;});
|
||||
jQuery('#multimedia-item-' + fileObj.id + ' a.delete').bind('click',function(){jQuery.ajax({url:'admin-ajax.php',type:'post',data:{id:this.id.replace(/[^0-9]/g,''),action:'delete-post',_ajax_nonce:this.href.replace(/^.*wpnonce=/,'')}});jQuery(this).parents(".multimedia-item").eq(0).slideToggle(300, function(){jQuery(this).remove();if(jQuery('.multimedia-item').length==0)jQuery('.insert-gallery').hide();});return false;});
|
||||
|
||||
// Open this item if it says to start open
|
||||
jQuery('#multimedia-item-' + fileObj.id + ' .startopen')
|
||||
.removeClass('startopen')
|
||||
.slideToggle(500)
|
||||
.parent().eq(0).children('.toggle').toggle();
|
||||
|
||||
jQuery('.insert-gallery').show();
|
||||
}
|
||||
|
||||
function uploadCompleteMultimedia(fileObj) {
|
||||
function uploadComplete(fileObj) {
|
||||
// If no more uploads queued, enable the submit button
|
||||
if ( swfu.getStats().files_queued == 0 )
|
||||
jQuery('#insert-multimedia').attr('disabled', '');
|
||||
}
|
||||
|
||||
|
||||
// progress and success handlers for single image upload
|
||||
|
||||
function uploadLoadedImage() {
|
||||
jQuery('#image-alt').attr('disabled', true);
|
||||
jQuery('#image-url').attr('disabled', true);
|
||||
jQuery('#image-title').attr('disabled', true);
|
||||
jQuery('#image-add').attr('disabled', true);
|
||||
}
|
||||
|
||||
function fileQueuedImage(fileObj) {
|
||||
jQuery('#flash-upload-ui').append('<div id="image-progress"><p class="filename">' + fileObj.name + '</p><div class="progress"><div class="bar"></div></div></div>');
|
||||
}
|
||||
|
||||
function uploadProgressImage(fileObj, bytesDone, bytesTotal) {
|
||||
jQuery('#image-progress .bar').width(450*bytesDone/bytesTotal);
|
||||
}
|
||||
|
||||
function uploadSuccessImage(fileObj, serverData) {
|
||||
if ( serverData.match('media-upload-error') ) {
|
||||
jQuery('#media-upload-error').replaceWith(serverData);
|
||||
jQuery('#image-progress').replaceWith('');
|
||||
}
|
||||
else {
|
||||
jQuery('#media-upload-error').replaceWith('');
|
||||
jQuery('#flash-upload-ui').replaceWith(serverData);
|
||||
}
|
||||
}
|
||||
|
||||
// wp-specific error handlers
|
||||
|
||||
// generic message
|
||||
@@ -121,14 +98,6 @@ function fileQueueError(fileObj, error_code, message) {
|
||||
}
|
||||
}
|
||||
|
||||
function fileQueued(fileObj) {
|
||||
try {
|
||||
var txtFileName = document.getElementById("txtFileName");
|
||||
txtFileName.value = fileObj.name;
|
||||
} catch (e) { }
|
||||
|
||||
}
|
||||
|
||||
function fileDialogComplete(num_files_queued) {
|
||||
try {
|
||||
if (num_files_queued > 0) {
|
||||
@@ -139,171 +108,33 @@ function fileDialogComplete(num_files_queued) {
|
||||
}
|
||||
}
|
||||
|
||||
function uploadProgress(fileObj, bytesLoaded, bytesTotal) {
|
||||
|
||||
try {
|
||||
var percent = Math.ceil((bytesLoaded / bytesTotal) * 100)
|
||||
|
||||
fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file
|
||||
var progress = new FileProgress(fileObj, this.customSettings.progress_target);
|
||||
progress.SetProgress(percent);
|
||||
progress.SetStatus("Uploading...");
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
function uploadSuccess(fileObj, server_data) {
|
||||
try {
|
||||
fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file
|
||||
var progress = new FileProgress(fileObj, this.customSettings.progress_target);
|
||||
progress.SetComplete();
|
||||
progress.SetStatus("Complete.");
|
||||
progress.ToggleCancel(false);
|
||||
|
||||
if (server_data === " ") {
|
||||
this.customSettings.upload_successful = false;
|
||||
} else {
|
||||
this.customSettings.upload_successful = true;
|
||||
document.getElementById("hidFileID").value = server_data;
|
||||
}
|
||||
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
function uploadComplete(fileObj) {
|
||||
try {
|
||||
if (this.customSettings.upload_successful) {
|
||||
document.getElementById("btnBrowse").disabled = "true";
|
||||
uploadDone();
|
||||
} else {
|
||||
fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file
|
||||
var progress = new FileProgress(fileObj, this.customSettings.progress_target);
|
||||
progress.SetError();
|
||||
progress.SetStatus("File rejected");
|
||||
progress.ToggleCancel(false);
|
||||
|
||||
var txtFileName = document.getElementById("txtFileName");
|
||||
txtFileName.value = "";
|
||||
//validateForm();
|
||||
|
||||
alert("There was a problem with the upload.\nThe server did not accept it.");
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
function uploadError(fileObj, error_code, message) {
|
||||
|
||||
// first the file specific error
|
||||
if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) {
|
||||
wpFileError(fileObj, swfuploadL10n.missing_upload_url);
|
||||
}
|
||||
else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED ) {
|
||||
wpFileError(fileObj, swfuploadL10n.upload_limit_exceeded);
|
||||
}
|
||||
else {
|
||||
wpFileError(fileObj, swfuploadL10n.default_error);
|
||||
}
|
||||
|
||||
// not sure if this is needed
|
||||
fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file
|
||||
var progress = new FileProgress(fileObj, this.customSettings.progress_target);
|
||||
progress.SetError();
|
||||
progress.ToggleCancel(false);
|
||||
alert(message);return;
|
||||
// first the file specific error
|
||||
if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) {
|
||||
wpFileError(fileObj, swfuploadL10n.missing_upload_url);
|
||||
}
|
||||
else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED ) {
|
||||
wpFileError(fileObj, swfuploadL10n.upload_limit_exceeded);
|
||||
}
|
||||
else {
|
||||
wpFileError(fileObj, swfuploadL10n.default_error);
|
||||
}
|
||||
|
||||
// now the general upload status
|
||||
if ( error_code == SWFUpload.UPLOAD_ERROR.HTTP_ERROR ) {
|
||||
wpQueueError(swfuploadL10n.http_error);
|
||||
}
|
||||
else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED ) {
|
||||
wpQueueError(swfuploadL10n.upload_failed);
|
||||
}
|
||||
else if ( error_code == SWFUpload.UPLOAD_ERROR.IO_ERROR ) {
|
||||
wpQueueError(swfuploadL10n.io_error);
|
||||
}
|
||||
else if ( error_code == SWFUpload.UPLOAD_ERROR.SECURITY_ERROR ) {
|
||||
wpQueueError(swfuploadL10n.security_error);
|
||||
}
|
||||
else if ( error_code == SWFUpload.UPLOAD_ERROR.FILE_CANCELLED ) {
|
||||
wpQueueError(swfuploadL10n.security_error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ********************************************************
|
||||
* Utility for displaying the file upload information
|
||||
* This is not part of SWFUpload, just part of the demo
|
||||
* ******************************************************** */
|
||||
function FileProgress(fileObj, target_id) {
|
||||
this.file_progress_id = fileObj.id;
|
||||
|
||||
this.fileProgressElement = document.getElementById(this.file_progress_id);
|
||||
if (!this.fileProgressElement) {
|
||||
this.fileProgressElement = document.createElement("div");
|
||||
this.fileProgressElement.className = "progressContainer";
|
||||
this.fileProgressElement.id = this.file_progress_id;
|
||||
|
||||
var progressCancel = document.createElement("a");
|
||||
progressCancel.className = "progressCancel";
|
||||
progressCancel.href = "#";
|
||||
progressCancel.style.visibility = "hidden";
|
||||
progressCancel.appendChild(document.createTextNode(" "));
|
||||
|
||||
var progressText = document.createElement("div");
|
||||
progressText.className = "progressName";
|
||||
progressText.appendChild(document.createTextNode(fileObj.name));
|
||||
|
||||
var progressBar = document.createElement("div");
|
||||
progressBar.className = "progressBarInProgress";
|
||||
|
||||
var progressStatus = document.createElement("div");
|
||||
progressStatus.className = "progressBarStatus";
|
||||
progressStatus.innerHTML = " ";
|
||||
|
||||
this.fileProgressElement.appendChild(progressCancel);
|
||||
this.fileProgressElement.appendChild(progressText);
|
||||
this.fileProgressElement.appendChild(progressStatus);
|
||||
this.fileProgressElement.appendChild(progressBar);
|
||||
|
||||
document.getElementById(target_id).appendChild(this.fileProgressElement);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
FileProgress.prototype.SetStart = function() {
|
||||
this.fileProgressElement.className = "progressContainer";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
|
||||
this.fileProgressElement.childNodes[3].style.width = "";
|
||||
}
|
||||
|
||||
FileProgress.prototype.SetProgress = function(percentage) {
|
||||
this.fileProgressElement.className = "progressContainer green";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
|
||||
this.fileProgressElement.childNodes[3].style.width = percentage + "%";
|
||||
}
|
||||
FileProgress.prototype.SetComplete = function() {
|
||||
this.fileProgressElement.className = "progressContainer blue";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarComplete";
|
||||
this.fileProgressElement.childNodes[3].style.width = "";
|
||||
|
||||
|
||||
}
|
||||
FileProgress.prototype.SetError = function() {
|
||||
this.fileProgressElement.className = "progressContainer red";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarError";
|
||||
this.fileProgressElement.childNodes[3].style.width = "";
|
||||
}
|
||||
FileProgress.prototype.SetCancelled = function() {
|
||||
this.fileProgressElement.className = "progressContainer";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarError";
|
||||
this.fileProgressElement.childNodes[3].style.width = "";
|
||||
}
|
||||
FileProgress.prototype.SetStatus = function(status) {
|
||||
this.fileProgressElement.childNodes[2].innerHTML = status;
|
||||
}
|
||||
|
||||
FileProgress.prototype.ToggleCancel = function(show, upload_obj) {
|
||||
this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
|
||||
if (upload_obj) {
|
||||
var file_id = this.file_progress_id;
|
||||
this.fileProgressElement.childNodes[0].onclick = function() { upload_obj.cancelUpload(file_id); return false; };
|
||||
}
|
||||
// now the general upload status
|
||||
if ( error_code == SWFUpload.UPLOAD_ERROR.HTTP_ERROR ) {
|
||||
wpQueueError(swfuploadL10n.http_error);
|
||||
}
|
||||
else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED ) {
|
||||
wpQueueError(swfuploadL10n.upload_failed);
|
||||
}
|
||||
else if ( error_code == SWFUpload.UPLOAD_ERROR.IO_ERROR ) {
|
||||
wpQueueError(swfuploadL10n.io_error);
|
||||
}
|
||||
else if ( error_code == SWFUpload.UPLOAD_ERROR.SECURITY_ERROR ) {
|
||||
wpQueueError(swfuploadL10n.security_error);
|
||||
}
|
||||
else if ( error_code == SWFUpload.UPLOAD_ERROR.FILE_CANCELLED ) {
|
||||
wpQueueError(swfuploadL10n.security_error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ function get_image_tag($id, $alt, $title, $align, $rel = false, $size='medium')
|
||||
list( $img_src, $width, $height ) = image_downsize($id, $size);
|
||||
$hwstring = image_hwstring($width, $height);
|
||||
|
||||
$html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'"'.$hwstring.' class="align-'.attribute_escape($align).' size-'.attribute_escape($size).' attachment wp-att-'.attribute_escape($id).'" />';
|
||||
$html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'" '.$hwstring.'class="align-'.attribute_escape($align).' size-'.attribute_escape($size).' attachment wp-att-'.attribute_escape($id).'" />';
|
||||
|
||||
$html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url );
|
||||
|
||||
|
||||
@@ -362,8 +362,8 @@ function walk_page_dropdown_tree() {
|
||||
// Attachments
|
||||
//
|
||||
|
||||
function the_attachment_link($id = 0, $fullsize = false, $max_dims = false) {
|
||||
echo get_the_attachment_link($id, $fullsize, $max_dims);
|
||||
function the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
|
||||
echo get_the_attachment_link($id, $fullsize, $max_dims, $permalink);
|
||||
}
|
||||
|
||||
function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
|
||||
|
||||
@@ -2302,41 +2302,55 @@ function wp_attachment_is_image( $post_id = 0 ) {
|
||||
*/
|
||||
function wp_mime_type_icon( $mime = 0 ) {
|
||||
$post_id = 0;
|
||||
if ( is_numeric($mime) ) {
|
||||
$mime = (int) $mime;
|
||||
if ( !$post =& get_post( $mime ) )
|
||||
return false;
|
||||
$post_id = (int) $post->ID;
|
||||
$mime = $post->post_mime_type;
|
||||
}
|
||||
|
||||
if ( empty($mime) )
|
||||
return false;
|
||||
$icon = wp_cache_get('mime_type_icon');
|
||||
|
||||
if ( empty($icon) ) {
|
||||
if ( is_numeric($mime) ) {
|
||||
$mime = (int) $mime;
|
||||
if ( !$post =& get_post( $mime ) )
|
||||
return false;
|
||||
$post_id = (int) $post->ID;
|
||||
$mime = $post->post_mime_type;
|
||||
$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $post->guid);
|
||||
}
|
||||
|
||||
$types = array();
|
||||
|
||||
if ( !empty($ext) )
|
||||
$types[] = $ext;
|
||||
|
||||
$icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
|
||||
$icon_dir_uri = apply_filters( 'icon_dir_uri', get_template_directory_uri() . '/images' );
|
||||
$image_dir = apply_filters( 'image_dir', ABSPATH . WPINC . '/images' );
|
||||
$image_dir_uri = apply_filters( 'image_dir', get_option('siteurl') . '/' . WPINC . '/images' );
|
||||
$dirs = array($icon_dir => $icon_dir_uri, $image_dir => $image_dir_uri);
|
||||
|
||||
|
||||
if ( ! empty($mime) ) {
|
||||
$types[] = substr($mime, 0, strpos($mime, '/'));
|
||||
$types[] = substr($mime, strpos($mime, '/') + 1);
|
||||
$types[] = str_replace('/', '_', $mime);
|
||||
}
|
||||
|
||||
$types[] = 'default';
|
||||
|
||||
$exts = array('png', 'gif', 'jpg');
|
||||
|
||||
$icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
|
||||
$icon_dir_uri = apply_filters( 'icon_dir_uri', get_template_directory_uri() . '/images' );
|
||||
|
||||
$types = array(
|
||||
substr($mime, 0, strpos($mime, '/')),
|
||||
substr($mime, strpos($mime, '/') + 1),
|
||||
str_replace('/', '_', $mime)
|
||||
);
|
||||
|
||||
$exts = array('jpg', 'gif', 'png');
|
||||
|
||||
$src = false;
|
||||
|
||||
foreach ( $types as $type ) {
|
||||
foreach ( $exts as $ext ) {
|
||||
$src_file = "$icon_dir/$type.$ext";
|
||||
if ( file_exists($src_file) ) {
|
||||
$src = "$icon_dir_uri/$type.$ext";
|
||||
break 2;
|
||||
foreach ( $types as $type ) {
|
||||
foreach ( $exts as $ext ) {
|
||||
foreach ( $dirs as $dir => $uri ) {
|
||||
$src_file = "$dir/$type.$ext";
|
||||
if ( file_exists($src_file) ) {
|
||||
$icon = "$uri/$type.$ext";
|
||||
break 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_mime_type_icon', $src, $mime, $post_id ); // Last arg is 0 if function pass mime type.
|
||||
return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id ); // Last arg is 0 if function pass mime type.
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -94,7 +94,7 @@ class WP_Scripts {
|
||||
$this->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.0.2');
|
||||
$this->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2');
|
||||
$this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2');
|
||||
$this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080216');
|
||||
$this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080220');
|
||||
// these error messages came from the sample swfupload js, they might need changing.
|
||||
$this->localize( 'swfupload-handlers', 'swfuploadL10n', array(
|
||||
'queue_limit_exceeded' => 'You have attempted to queue too many files.',
|
||||
|
||||