diff --git a/wp-admin/css/press-this.css b/wp-admin/css/press-this.css index 07d158e934..8dad13b1c3 100644 --- a/wp-admin/css/press-this.css +++ b/wp-admin/css/press-this.css @@ -356,6 +356,7 @@ padding: 0; height: 300px; float: left; } + #embed_code { border: 0; width: 99%; @@ -394,3 +395,52 @@ padding: 0; .ac_match { text-decoration: underline; } + + +.photolist { +display: none; +} + +#extra_fields small { +display: block; +margin-top: .5em; +padding-bottom: .25em; +} + +#TB_ajaxContent #options { +position: absolute; +top: 20px; +right: 25px; +background: white; +padding: 5px; +} +#TB_ajaxContent h3 { +margin-bottom: .25em; +} + +.updated { + margin: 0; + margin-left: 15px; + margin-right: 15px; + padding: 0; + max-width: 980px; + border-width: 1px; + border-style: solid; + padding: 0 0.6em; + max-width: 950px; + margin-top: 1em; + margin-bottom: 1em; +} + +.updated p, .error p { + margin: 0.6em 0; +} + +.updated a, .error a { + text-decoration: underline; +} + +.updated a { + text-decoration: none; + padding-bottom: 2px; +} \ No newline at end of file diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 4f7b344542..4d42def8d7 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -116,15 +116,16 @@ function media_handle_upload($file_id, $post_id, $post_data = array()) { } -function media_sideload_image($file, $post_id) { +function media_sideload_image($file, $post_id, $desc = null) { if (!empty($file) ) { // Upload File button was clicked $file_array['name'] = basename($file); $file_array['tmp_name'] = download_url($file); + $desc = @$desc; - $sideload = media_handle_sideload($file_array, $post_id); + $sideload = media_handle_sideload($file_array, $post_id, $desc); $id = $sideload['id']; $src = $sideload['src']; @@ -141,18 +142,15 @@ function media_sideload_image($file, $post_id) { 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'"; - } */ + $alt = @$desc; + if ( !empty($src) ) - $html = ""; + $html = ""; return $html; } -function media_handle_sideload($file_array, $post_id, $post_data = array()) { +function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) { $overrides = array('test_form'=>false); $file = wp_handle_sideload($file_array, $overrides); @@ -172,6 +170,8 @@ function media_handle_sideload($file_array, $post_id, $post_data = array()) { if ( trim($image_meta['caption']) ) $content = $image_meta['caption']; } + + $title = @$desc; // Construct the attachment array $attachment = array_merge( array( diff --git a/wp-admin/press-this.php b/wp-admin/press-this.php index 74e03f4f58..4be9329d62 100644 --- a/wp-admin/press-this.php +++ b/wp-admin/press-this.php @@ -5,64 +5,64 @@ if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' )); '; - - $content .= media_sideload_image($_REQUEST['photo_src'], $post_ID); - - if ($_REQUEST['photo_link']) - $content .= ''; - - if ($_REQUEST['content']) - $content .= $content . "\n\n".$_REQUEST['content']; - - break; - case "video": - if($_REQUEST['embed_code']) - $content .= $_REQUEST['embed_code']."\n\n"; - $content .= $_REQUEST['content']; - break; + $content = ''; + switch ( $_REQUEST['post_type'] ) { + case 'text': + case 'quote': + $content .= $_REQUEST['content']; + break; + + case 'photo': + foreach($_REQUEST['photo_src'] as $key => $data) { + #quote for matching + $quoted = str_replace('/', '\/', preg_quote($data)); + + # see if files exist in content - we don't want to upload non-used selected files. + preg_match('/'.$quoted.'/', $_REQUEST['content'], $matches[0]); + if($matches[0]) + media_sideload_image($data, $post_ID, $_REQUEST['photo_description'][$key]); + } + $content = $_REQUEST['content']; + break; + + case "video": + if($_REQUEST['embed_code']) + $content .= $_REQUEST['embed_code']."\n\n"; + $content .= $_REQUEST['content']; + break; } - + # set the post_content $quick['post_content'] = $content; + #error handling for $post if ( is_wp_error($post_ID) ) { wp_die($id); wp_delete_post($post_ID); - } else { + + #error handling for media_sideload + } else { $quick['ID'] = $post_ID; wp_update_post($quick); } return $post_ID; } - function tag_div() { ?> +function tag_div() { ?>
- +function category_div() { ?>| | Close Window
'); + set_editor("
"); return false; break; @@ -372,7 +404,7 @@ if($_REQUEST['ajax'] == 'photo') { ?> $content = $selection; } ?> jQuery('#embed_code').prepend(''); - set_editor(''); + set_editor(""); }); @@ -383,9 +415,12 @@ if($_REQUEST['ajax'] == 'photo') { ?> case 'photo' : reset_height(); set_menu('photo'); - set_title('Caption'); - set_editor(''); - + set_title('Post'); + + set_editor(""); + + set_editor('') + jQuery('#extra_fields').show(); jQuery('#extra_fields').load(''); jQuery('#extra_fields').prepend('