Changeset 8903 for trunk/wp-admin/press-this.php
- Timestamp:
- 09/16/2008 06:30:15 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/press-this.php
r8816 r8903 63 63 $post_ID = wp_insert_post($quick, true); 64 64 65 $content = ''; 66 switch ( $_REQUEST['post_type'] ) { 67 case 'text': 68 case 'quote': 69 $content .= $_REQUEST['content']; 70 break; 71 72 case 'photo': 73 $content = $_REQUEST['content']; 74 75 foreach( (array) $_REQUEST['photo_src'] as $key => $image) { 76 77 // see if files exist in content - we don't want to upload non-used selected files. 78 if( strpos($_REQUEST['content'], $image) !== false ) { 79 $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]); 80 81 // Replace the POSTED content <img> with correct uploaded ones. 82 // escape quote for matching 83 $quoted = preg_quote2($image); 84 if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content); 85 } 65 $content = $_REQUEST['content']; 66 67 if($_REQUEST['photo_src']) 68 foreach( (array) $_REQUEST['photo_src'] as $key => $image) 69 // see if files exist in content - we don't want to upload non-used selected files. 70 if( strpos($_REQUEST['content'], $image) !== false ) { 71 $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]); 72 73 // Replace the POSTED content <img> with correct uploaded ones. 74 // escape quote for matching 75 $quoted = preg_quote2($image); 76 if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content); 86 77 } 87 88 break; 89 90 case "video": 91 if($_REQUEST['embed_code']) 92 $content .= $_REQUEST['embed_code']."\n\n"; 93 $content .= $_REQUEST['content']; 94 break; 95 } 78 96 79 // set the post_content 97 80 $quick['post_content'] = $content; 98 99 81 // error handling for $post 100 82 if ( is_wp_error($post_ID)) { 101 83 wp_die($id); 102 wp_delete_post($post_ID); 84 wp_delete_post($post_ID);error_log('2'); 103 85 // error handling for media_sideload 104 86 } elseif ( is_wp_error($upload)) { … … 115 97 if ( 'post' == $_REQUEST['action'] ) { 116 98 check_admin_referer('press-this'); 117 $post_ID = press_it(); 118 wp_redirect('press-this.php?posted=' . $post_ID); 119 die; 120 } 121 122 // Ajax Requests 99 $post_ID = press_it(); 100 error_log($post_ID); 101 $posted = $post_ID; 102 //wp_redirect('press-this.php?posted=' . press_it()); 103 } 104 105 // Set Variables 123 106 $title = wp_specialchars(aposfix(stripslashes($_GET['t']))); 124 125 107 $selection = trim( aposfix( stripslashes($_GET['s']) ) ); 126 108 if ( ! empty($selection) ) { … … 128 110 $selection = '<p>'.str_replace('<p></p>', '', $selection).'</p>'; 129 111 } 130 131 112 $url = clean_url($_GET['u']); 132 113 $image = $_GET['i']; 133 114 134 if($_REQUEST['ajax'] == 'thickbox') { ?> 135 <script type="text/javascript" charset="utf-8"> 136 jQuery('.cancel').click(function() { 115 if($_REQUEST['ajax']) { 116 switch ($_REQUEST['ajax']) { 117 case 'video': ?> 118 <script type="text/javascript" charset="utf-8"> 119 jQuery('.select').click(function() { 120 append_editor(jQuery('#embed-code').html()); 121 }); 122 jQuery('.close').click(function() { 123 jQuery('#extra_fields').hide(); 124 }); 125 </script> 126 <h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2> 127 <div class="titlewrap" > 128 <textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo format_to_edit($selection); ?></textarea> 129 130 </div> 131 <p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p> 132 <?php break; 133 134 case 'photo_thickbox': ?> 135 <script type="text/javascript" charset="utf-8"> 136 jQuery('.cancel').click(function() { 137 tb_remove(); 138 }); 139 140 jQuery('.select').click(function() { 141 image_selector(); 142 }); 143 </script> 144 <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3> 145 <div class="titlewrap"> 146 <input id="this_photo_description" name="photo_description" class="text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/> 147 </div> 148 149 <p class="centered"><input type="hidden" name="this_photo" value="<?php echo attribute_escape($image); ?>" id="this_photo" /> 150 <a href="#" class="select"><img src="<?php echo clean_url($image); ?>" alt="<?php echo attribute_escape(__('Click to insert.')); ?>" title="<?php echo attribute_escape(__('Click to insert.')); ?>" /></a></p> 151 152 <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p> 153 <?php break; 154 155 case 'photo_thickbox_url': ?> 156 <script type="text/javascript" charset="utf-8"> 157 jQuery('.cancel').click(function() { 158 tb_remove(); 159 }); 160 161 jQuery('.select').click(function() { 162 image_selector(); 163 }); 164 </script> 165 <h3 id="title"><label for="post_title"><?php _e('URL') ?></label></h3> 166 <div class="titlewrap"> 167 <input id="this_photo" name="this_photo" class="text" onkeypress="if(event.keyCode==13) image_selector();" /> 168 </div> 169 170 171 <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3> 172 <div class="titlewrap"> 173 <input id="this_photo_description" name="photo_description" class="text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/> 174 </div> 175 176 <p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p> 177 <?php break; 178 case 'photo_images': 179 function get_images_from_uri($uri) { 180 if( preg_match('/\.(jpg|jpe|jpeg|png|gif)/', $uri) && !strpos($uri,'blogger.com') ) 181 return "'".$uri."'"; 182 183 $content = wp_remote_fopen($uri); 184 if ( false === $content ) return ''; 185 186 $host = parse_url($uri); 187 188 $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))[^<>\'\"]*(\2)([^>\/]*)\/*>/is'; 189 preg_match_all($pattern, $content, $matches); 190 191 if ( empty($matches[0]) ) return ''; 192 193 $sources = array(); 194 foreach ($matches[3] as $src) { 195 // if no http in url 196 if(strpos($src, 'http') === false) 197 // if it doesn't have a relative uri 198 if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === true) 199 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 200 else 201 $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src); 202 203 $sources[] = clean_url($src); 204 error_log($src); 205 } 206 return "'" . implode("','", $sources) . "'"; 207 } 208 209 $url = urldecode($url); 210 $url = str_replace(' ', '%20', $url); 211 echo 'new Array('.get_images_from_uri($url).')'; 212 break; 213 214 case 'photo_js': ?> 215 // gather images and load some default JS 216 var last = null 217 var img, img_tag, aspect, w, h, skip, i, strtoappend = ""; 218 if(!my_src) { 219 var my_src = eval( 220 jQuery.ajax({ 221 type: "GET", 222 url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>", 223 cache : false, 224 async : false, 225 data: "ajax=photo_images&u=<?php echo urlencode($url); ?>", 226 dataType : "script" 227 }).responseText 228 ); 229 } 230 231 for (i = 0; i < my_src.length; i++) { 232 img = new Image(); 233 img.src = my_src[i]; 234 img_attr = 'id="img' + i + '"'; 235 skip = false; 236 if (img.width && img.height) { 237 if (img.width * img.height < 2500) 238 skip = true; 239 aspect = img.width / img.height; 240 scale = (aspect > 1) ? (71 / img.width) : (71 / img.height); 241 242 w = img.width; 243 h = img.height; 244 245 if (scale < 1) { 246 w = parseInt(img.width * scale); 247 h = parseInt(img.height * scale); 248 } 249 img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"'; 250 } 251 if (!skip) strtoappend += '<a href="?ajax=photo_thickbox&i=' + img.src + '&u=<?php echo $url; ?>&height=400&width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>'; 252 } 253 254 function pick(img, desc) { 255 if (img) { 256 if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length; 257 if(length == 0) length = 1; 258 jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>'); 259 jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>'); 260 append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" class="aligncenter"/></p>'); 261 } 262 tinyMCE.activeEditor.resizeToContent(); 263 return false; 264 } 265 266 function image_selector() { 137 267 tb_remove(); 268 desc = jQuery('#this_photo_description').val(); 269 src = jQuery('#this_photo').val(); 270 pick(src, desc); 271 jQuery('#extra_fields').hide(); 272 return false; 273 } 274 275 jQuery(document).ready(function() { 276 jQuery('#extra_fields').html('<h2>Photo <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><div class="photolist"></div><ul id="actions"><li><a href="#" id="photo_add_url" class="thickbox button"><?php _e("Add from URL") ?> +</a></li></ul><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a></p>'); 277 jQuery('.close').click(function() { 278 jQuery('#extra_fields').hide(); 279 }); 280 jQuery('#img_container').html(strtoappend); 281 jQuery('#photo_add_url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500'); 282 tb_init('#extra_fields .thickbox'); 138 283 }); 139 140 jQuery('.select').click(function() { 141 image_selector(); 142 }); 143 </script> 144 <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3> 145 <div class="titlewrap"> 146 <input id="this_photo_description" name="photo_description" class="text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/> 147 </div> 148 149 <p class="centered"><input type="hidden" name="this_photo" value="<?php echo attribute_escape($image); ?>" id="this_photo" /> 150 <a href="#" class="select"><img src="<?php echo clean_url($image); ?>" alt="<?php echo attribute_escape(__('Click to insert.')); ?>" title="<?php echo attribute_escape(__('Click to insert.')); ?>" /></a></p> 151 152 <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p> 153 <?php die; 154 } 155 156 if($_REQUEST['ajax'] == 'thickbox_url') { ?> 157 <script type="text/javascript" charset="utf-8"> 158 jQuery('.cancel').click(function() { 159 tb_remove(); 160 }); 161 162 jQuery('.select').click(function() { 163 image_selector(); 164 }); 165 </script> 166 <h3 id="title"><label for="post_title"><?php _e('URL') ?></label></h3> 167 <div class="titlewrap"> 168 <input id="this_photo" name="this_photo" class="text" onkeypress="if(event.keyCode==13) image_selector();" /> 169 </div> 170 171 172 <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3> 173 <div class="titlewrap"> 174 <input id="this_photo_description" name="photo_description" class="text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/> 175 </div> 176 177 <p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p> 178 <?php die; 179 } 180 181 if($_REQUEST['ajax'] == 'video') { ?> 182 <h2 id="embededcode"><label for="embed_code"><?php _e('Embed Code') ?></label></h2> 183 <div class="titlewrap" > 184 <textarea name="embed_code" id="embed_code" rows="8" cols="40"><?php echo format_to_edit($selection); ?></textarea> 185 </div> 186 <?php die; 187 } 188 189 if($_REQUEST['ajax'] == 'photo_images') { 190 function get_images_from_uri($uri) { 191 if( preg_match('/\.(jpg|jpe|jpeg|png|gif)/', $uri) && !strpos($uri,'blogger.com') ) 192 return "'".$uri."'"; 193 194 $content = wp_remote_fopen($uri); 195 if ( false === $content ) return ''; 196 197 $host = parse_url($uri); 198 199 $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))[^<>\'\"]*(\2)([^>\/]*)\/*>/is'; 200 preg_match_all($pattern, $content, $matches); 201 202 if ( empty($matches[1]) ) return ''; 203 204 $sources = array(); 205 foreach ($matches[3] as $src) { 206 // if no http in url 207 if(strpos($src, 'http') === false) 208 // if it doesn't have a relative uri 209 if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === true) 210 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 211 else 212 $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src); 213 214 $sources[] = clean_url($src); 215 } 216 return "'" . implode("','", $sources) . "'"; 217 } 218 219 $url = urldecode($url); 220 $url = str_replace(' ', '%20', $url); 221 echo 'new Array('.get_images_from_uri($url).')'; 284 <?php break; 285 } 222 286 die; 223 287 } 224 288 225 if($_REQUEST['ajax'] == 'photo_js') { ?>226 // gather images and load some default JS227 var last = null228 var img, img_tag, aspect, w, h, skip, i, strtoappend = "";229 var my_src = eval(230 jQuery.ajax({231 type: "GET",232 url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",233 cache : false,234 async : false,235 data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",236 dataType : "script"237 }).responseText238 );239 240 for (i = 0; i < my_src.length; i++) {241 img = new Image();242 img.src = my_src[i];243 img_attr = 'id="img' + i + '"';244 skip = false;245 if (img.width && img.height) {246 if (img.width * img.height < 2500)247 skip = true;248 aspect = img.width / img.height;249 scale = (aspect > 1) ? (75 / img.width) : (75 / img.height);250 251 w = img.width;252 h = img.height;253 254 if (scale < 1) {255 w = parseInt(img.width * scale);256 h = parseInt(img.height * scale);257 }258 img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';259 }260 if (!skip) strtoappend += '<a href="?ajax=thickbox&i=' + img.src + '&u=<?php echo $url; ?>&height=400&width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';261 }262 263 function pick(img, desc) {264 if (img) {265 if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;266 if(length == 0) length = 1;267 jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');268 jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');269 append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" class="aligncenter"/></p>');270 }271 tinyMCE.activeEditor.resizeToContent();272 return false;273 }274 275 function image_selector() {276 tb_remove();277 desc = jQuery('#this_photo_description').val();278 src = jQuery('#this_photo').val();279 pick(src, desc);280 return false;281 }282 283 jQuery(document).ready(function() {284 jQuery('#extra_fields').html('<div class="photolist"></div><small id="photo_directions"><?php _e("Click images to select:") ?> <span><a href="#" id="photo_add_url" class="thickbox"><?php _e("Add from URL") ?> +</a></span></small><div class="titlewrap"><div id="img_container"></div></div>');285 jQuery('#img_container').html(strtoappend);286 jQuery('#photo_add_url').attr('href', '?ajax=thickbox_url&height=200&width=500');287 tb_init('a.thickbox, area.thickbox, input.thickbox');288 });289 290 <?php die;291 }292 293 if($_REQUEST['ajax'] == 'photo') { ?>294 295 <?php die;296 }297 289 ?> 298 290 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> … … 301 293 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 302 294 <title><?php _e('Press This') ?></title> 303 304 295 <script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce.js?ver=311"></script> 305 296 <?php … … 310 301 wp_enqueue_script( 'post' ); 311 302 wp_enqueue_script('editor_functions'); 312 313 // wp_teeny_mce();314 303 315 304 do_action('admin_print_styles'); … … 337 326 height: "300", 338 327 theme : "advanced", 339 theme_advanced_buttons1 : "bold,italic,underline,blockquote,separator,strikethrough,bullist,numlist, undo,redo,link,unlink",328 theme_advanced_buttons1 : "bold,italic,underline,blockquote,separator,strikethrough,bullist,numlist,justifyleft, justifycenter, justifyright, undo,redo,link,unlink", 340 329 theme_advanced_buttons2 : "", 341 330 theme_advanced_buttons3 : "", … … 354 343 accessibility_focus : false, 355 344 tab_focus : ":next", 356 plugins : "safari,inlinepopups ",345 plugins : "safari,inlinepopups, media", 357 346 entities : "38,amp,60,lt,62,gt", 358 347 force_p_newlines : true, … … 362 351 363 352 jQuery('#tags-input').hide(); 364 365 353 tag_update_quickclicks(); 366 367 354 // add the quickadd form 368 355 jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="submit" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" onclick="return false;" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>'); … … 377 364 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); 378 365 }); 379 380 366 // auto-save tags on post save/publish 381 367 jQuery('#publish').click( tag_save_on_publish ); 382 jQuery('#save-post').click( tag_save_on_publish ); 383 384 function set_menu(type) { 385 jQuery('#text_button').removeClass('ui-tabs-selected'); 386 jQuery('#menu li').removeClass('ui-tabs-selected'); 387 jQuery('#' + type + '_button').addClass('ui-tabs-selected'); 388 jQuery("#post_type").val(type); 389 } 368 jQuery('#save').click( tag_save_on_publish ); 369 390 370 391 371 function set_editor(text) { … … 395 375 396 376 function append_editor(text) { 397 if ( '' != text && tinyMCE.activeEditor ) tinyMCE.execCommand('mceInsertContent', false, text); 377 if ( '' != text && tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) 378 + '<p>' + tinymce.DOM.decode(text) + '</p>'); 379 tinyMCE.execCommand('mceCleanup'); 398 380 } 399 381 400 function set_title(title) { jQuery("#content_type").text(title); }401 402 382 function show(tab_name) { 403 jQuery('body').removeClass('video_split'); 404 jQuery('#extra_fields').hide(); 383 405 384 switch(tab_name) { 406 case 'text' :407 set_menu('text');408 set_title('<?php _e('Post') ?>');409 <?php if ($selection) { ?>410 set_editor('<?php echo $selection; ?><p><a href="<?php echo $url ?>"><?php echo $title; ?></a>.</p>');411 <?php } else { ?>412 set_editor('<p><a href="<?php echo $url ?>"><?php echo $title; ?></a></p>');413 <?php } ?>414 return false;415 break;416 case 'quote' :417 set_menu('quote');418 set_title('<?php _e('Quote') ?>');419 set_editor('<blockquote><?php echo $selection; ?> <p><cite><a href="<?php echo $url; ?>"><?php echo $title; ?> </a> </cite> </p></blockquote>');420 return false;421 break;422 385 case 'video' : 423 set_menu('video');424 set_title('<?php _e('Caption') ?>');425 386 jQuery('#extra_fields').show(); 426 jQuery('body').addClass('video_split');427 387 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo attribute_escape($selection); ?>'}, function() { 428 388 <?php … … 443 403 } 444 404 ?> 445 jQuery('#embed_code').prepend('<?php echo htmlentities($content); ?>'); 446 447 set_editor('<a href="<?php echo $url ?>"><?php echo $title; ?></a>.'); 405 jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>'); 406 448 407 }); 449 408 return false; 450 409 break; 451 410 case 'photo' : 452 set_menu('photo'); 453 set_title('<?php _e('Post') ?>'); 454 <?php if ($selection) { ?> 455 set_editor('<?php echo $selection; ?><p><a href="<?php echo $url ?>"><?php echo $title; ?></a></p>'); 456 <?php } else { ?> 457 set_editor('<p><a href="<?php echo $url ?>"><?php echo $title; ?></a></p>'); 458 <?php } ?> 459 jQuery('#extra_fields').show(); 460 jQuery('#extra_fields').before('<h2 id="waiting"><img src="images/loading.gif" alt="" /><?php echo js_escape( __( 'Loading...' ) ); ?></h2>'); 461 jQuery.ajax({ 462 type: "GET", 463 cache : false, 464 url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>", 465 data: "ajax=photo_js&u=<?php echo urlencode($url)?>", 466 dataType : "script", 467 success : function() { 468 jQuery('#waiting').remove(); 469 } 470 }); 411 if(jQuery('#extra_fields').css('display') == 'none') { 412 jQuery('#extra_fields').show(); 413 jQuery('#extra_fields').before('<p id="waiting"><img src="images/loading.gif" alt="" /><?php echo js_escape( __( 'Loading...' ) ); ?></p>'); 414 jQuery.ajax({ 415 type: "GET", 416 cache : false, 417 url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>", 418 data: "ajax=photo_js&u=<?php echo urlencode($url)?>", 419 dataType : "script", 420 success : function() { 421 jQuery('#waiting').remove(); 422 } 423 }); 424 } else { 425 jQuery('#extra_fields').hide(); 426 } 471 427 return false; 472 428 break; … … 475 431 476 432 jQuery(document).ready(function() { 477 jQuery('#menu li').click(function (){ 478 tab_name = this.id.split('_'); 479 tab_name = tab_name[0]; 480 show(tab_name); 481 }); 433 jQuery('#photo_button').click(function() { show('photo'); return false; }); 434 jQuery('#video_button').click(function() { show('video'); return false; }); 435 482 436 // Set default tabs 483 437 <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?> … … 488 442 show('photo'); 489 443 <?php } ?> 444 445 jQuery('#submit').click(function() { jQuery('saving').css('display', 'block'); }); 490 446 }); 491 492 447 </script> 493 448 </head> 494 449 <body class="press-this"> 495 450 <div id="wphead"> 496 <h1><span id="viewsite"><a href="<?php echo get_option('home'); ?>/"><?php _e('Visit:') ?> <?php bloginfo('name'); ?></a></span></h1>497 451 </div> 498 452 499 <ul id="menu" class="ui-tabs-nav">500 <li id="text_button" class="ui-tabs-selected"><a href="#"><?php _e('Text') ?></a></li>501 <li id="photo_button"><a href="#"><?php _e('Photo') ?></a></li>502 <li id="quote_button"><a href="#"><?php _e('Quote') ?></a></li>503 <li id="video_button"><a href="#"><?php _e('Video') ?></a></li>504 </ul>505 506 453 <?php 507 if ( isset($ _GET['posted']) && intval($_GET['posted']) ) {508 $post_ID = intval($ _GET['posted']);454 if ( isset($posted) && intval($posted) ) { 455 $post_ID = intval($posted); 509 456 ?> 510 457 <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div> … … 515 462 <?php wp_nonce_field('press-this') ?> 516 463 <input type="hidden" name="post_type" id="post_type" value="text"/> 517 <div id="posting"> 518 <h2 id="title"><label for="post_title"><?php _e('Title') ?></label></h2> 519 <div class="titlewrap"> 520 <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> 521 </div> 522 523 <div id="extra_fields" style="display: none"></div> 524 525 <div class="editor_area"> 526 <h2 id="content_type"><label for="content"><?php _e('Post') ?></label></h2> 527 <div class="editor-container"> 528 <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15"><?php if ($selection) { echo wp_richedit_pre($selection); } ?><a href="<?php echo $url ?>"><?php echo $title; ?></a>.</textarea> 464 465 <div id="poststuff"> 466 <div id="side-info-column"> 467 <div class="sleeve"> 468 <h1 id="viewsite"><a class="button" href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?> › <?php _e('Press This') ?></a></span></h1> 469 470 <div id="categorydiv" class="stuffbox"> 471 <h2><?php _e('Categories') ?></h2> 472 <div class="inside"> 473 474 <div id="categories-all" class="ui-tabs-panel"> 475 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 476 <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?> 477 </ul> 478 479 </div> 480 481 <div id="category-adder" class="wp-hidden-children"> 482 <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4> 483 <p id="category-add" class="wp-hidden-child"> 484 <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/> 485 <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?> 486 <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" /> 487 <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?> 488 <span id="category-ajax-response"></span> 489 </p> 490 </div> 491 </div> 492 </div> 493 494 <div class="stuffbox"> 495 <h2><?php _e('Tags') ?></h2> 496 <div class="inside"> 497 498 <div id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></div> 499 500 <div id="tagchecklist"></div> 501 </div> 502 </div> 503 <div id="submitdiv" class="stuffbox"> 504 <h2><?php _e('Publish') ?></h2> 505 <div class="submitbox"> 506 <p class="submit"> 507 <input class="button" type="submit" name="draft" value="<?php _e('Save Draft') ?>" id="save" /> 508 <input class="button" type="submit" name="publish" value="<?php _e('Publish') ?>" id="publish" /> 509 <img src="images/loading-publish.gif" alt="" id="saving" style="display:none;"/> 510 </p> 511 </div> 529 512 </div> 530 513 </div> 531 514 </div> 532 533 <div id="categories"> 534 <div class="submitbox" id="submitpost"> 535 <div id="previewview"></div> 536 <div class="inside"> 537 <h2><?php _e('Categories') ?></h2> 538 <div id="categories-all"> 539 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 540 <?php wp_category_checklist() ?> 541 </ul> 515 516 <div class="posting"> 517 <h2 id="title"><label for="post_title"><?php _e('Title') ?></label></h2> 518 <div class="titlewrap"> 519 <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> 520 </div> 521 522 <div id="extra_fields" style="display: none"></div> 523 524 <div class="postdivrich"> 525 <ul id="actions"> 526 <li id="photo_button"><a href="#" class="button"><?php _e( 'Add Photo' ); ?></a></li> 527 <li id="video_button"><a href="#" class="button"><?php _e( 'Add Video' ); ?></a></li> 528 </ul> 529 530 <h2 id="content_type"><label for="content"><?php _e('Post') ?></label></h2> 531 532 <div class="editor-container"> 533 <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15"><?php if ($selection) { echo wp_richedit_pre($selection); } ?><a href="<?php echo $url ?>"><?php echo $title; ?></a><?php if($selection) echo '.'; ?></textarea> 542 534 </div> 543 544 <h2><?php _e('Tags') ?></h2> 545 <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p> 546 <div id="tagchecklist"></div> 547 </div> 548 549 <p class="submit"> 550 <input type="submit" name="draft" value="<?php _e('Save') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 551 <input type="submit" name="publish" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> 552 <img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/> 553 </p> 535 </div> 554 536 </div> 537 538 555 539 </div> 556 540 </form>
Note: See TracChangeset
for help on using the changeset viewer.