X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/76aea3697c6043c1613370f172395b4f65ee71f0..4f4e083f6f77639c41e2b1ddb200de8e34301cee:/wp-admin/includes/media.php
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index d91ffc23..e6e7b6b8 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -1,30 +1,64 @@
__('Choose File'), // handler action suffix => tab text
+ 'type' => __('From Computer'), // handler action suffix => tab text
+ 'type_url' => __('From URL'),
'gallery' => __('Gallery'),
- 'library' => __('Media Library'),
+ 'library' => __('Media Library')
);
return apply_filters('media_upload_tabs', $_default_tabs);
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $tabs
+ * @return unknown
+ */
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'])));
+ if ( empty($attachments) ) {
+ unset($tabs['gallery']);
+ return $tabs;
+ }
+
$tabs['gallery'] = sprintf(__('Gallery (%s)'), "$attachments");
return $tabs;
}
add_filter('media_upload_tabs', 'update_gallery_tab');
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function the_media_upload_tabs() {
global $redir_tab;
$tabs = media_upload_tabs();
@@ -35,47 +69,83 @@ function the_media_upload_tabs() {
$current = $redir_tab;
elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) )
$current = $_GET['tab'];
- else {
- $keys = array_keys($tabs);
- $current = array_shift($keys);
- }
+ else
+ $current = apply_filters('media_upload_default_tab', 'type');
+
foreach ( $tabs as $callback => $text ) {
$class = '';
if ( $current == $callback )
$class = " class='current'";
$href = add_query_arg(array('tab'=>$callback, 's'=>false, 'paged'=>false, 'post_mime_type'=>false, 'm'=>false));
- $link = "$text";
- echo "\t
$link\n";
+ $link = "$text";
+ echo "\t$link\n";
}
echo "\n";
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $id
+ * @param unknown_type $alt
+ * @param unknown_type $title
+ * @param unknown_type $align
+ * @param unknown_type $url
+ * @param unknown_type $rel
+ * @param unknown_type $size
+ * @return unknown
+ */
function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') {
- $html = get_image_tag($id, $alt, $title, $align, $size);
+ $htmlalt = ( empty($alt) ) ? $title : $alt;
- $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : '';
+ $html = get_image_tag($id, $htmlalt, $title, $align, $size);
+
+ $rel = $rel ? ' rel="attachment wp-att-' . esc_attr($id).'"' : '';
if ( $url )
- $html = '$html";
+ $html = '$html";
$html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size );
return $html;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $html
+ * @param unknown_type $id
+ * @param unknown_type $alt
+ * @param unknown_type $title
+ * @param unknown_type $align
+ * @param unknown_type $url
+ * @param unknown_type $size
+ * @return unknown
+ */
function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) {
- if ( empty($alt) || apply_filters( 'disable_captions', '' ) ) return $html;
+ if ( empty($alt) || apply_filters( 'disable_captions', '' ) )
+ return $html;
+
$id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
preg_match( '/width="([0-9]+)/', $html, $matches );
- if ( ! isset($matches[1]) ) return $html;
+ if ( ! isset($matches[1]) )
+ return $html;
+
$width = $matches[1];
- $html = preg_replace( '/align[^\s\'"]+\s?/', '', $html );
- if ( empty($align) ) $align = 'none';
+ $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );
+ if ( empty($align) )
+ $align = 'none';
+
+ $alt = ! empty($alt) ? addslashes($alt) : '';
$shcode = '[caption id="' . $id . '" align="align' . $align
. '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/caption]';
@@ -84,8 +154,15 @@ function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) {
}
add_filter( 'image_send_to_editor', 'image_add_caption', 20, 7 );
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $html
+ */
function media_send_to_editor($html) {
- ?>
+?>
+