Press This changes from noel. see #6813

git-svn-id: https://develop.svn.wordpress.org/trunk@8113 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-06-17 19:36:29 +00:00
parent c1a68e5c0f
commit 873dd6bedf
3 changed files with 53 additions and 62 deletions

View File

@ -111,7 +111,7 @@ text-decoration: none;
.howto { .howto {
font-size: 11px; font-size: 11px;
} }
#newtag { padding: 3px; } #newtag { width: 60%; padding: 3px; }
#wphead { #wphead {
height: 2em; height: 2em;
@ -451,4 +451,10 @@ margin-bottom: .25em;
} }
#photo_saving { #photo_saving {
margin-bottom: 8px; margin-bottom: 8px;
}
#post_status {
margin-left: 10px;
margin-bottom: 1em;
display: block;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -6,7 +6,7 @@ if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' ));
<?php <?php
function press_it() { function press_it() {
#define some basic variables #define some basic variables
$quick['post_status'] = 'publish'; $quick['post_status'] = $_REQUEST['post_status'];
$quick['post_category'] = $_REQUEST['post_category']; $quick['post_category'] = $_REQUEST['post_category'];
$quick['tags_input'] = $_REQUEST['tags_input']; $quick['tags_input'] = $_REQUEST['tags_input'];
$quick['post_title'] = $_REQUEST['post_title']; $quick['post_title'] = $_REQUEST['post_title'];
@ -42,7 +42,7 @@ function press_it() {
break; break;
} }
# set the post_content # set the post_content
$quick['post_content'] = $content; $quick['post_content'] = str_replace('<br />', "\n", preg_replace('/<\/?p>/','',$content));
#error handling for $post #error handling for $post
if ( is_wp_error($post_ID) ) { if ( is_wp_error($post_ID) ) {
@ -57,30 +57,6 @@ function press_it() {
return $post_ID; return $post_ID;
} }
function category_div() { ?>
<div id="categories">
<div class="submitbox" id="submitpost">
<div id="previewview"></div>
<div class="inside">
<h2><?php _e('Categories') ?></h2>
<div id="categories-all">
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
<?php wp_category_checklist() ?>
</ul>
</div>
<h2><?php _e('Tags') ?></h2>
<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>
<div id="tagchecklist"></div>
</div>
<p class="submit">
<input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/>
<img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/>
</p>
</div>
<?php }
# For submitted posts. # For submitted posts.
if ( 'post' == $_REQUEST['action'] ) { if ( 'post' == $_REQUEST['action'] ) {
check_admin_referer('press-this'); $post_ID = press_it(); ?> check_admin_referer('press-this'); $post_ID = press_it(); ?>
@ -110,8 +86,8 @@ if ( 'post' == $_REQUEST['action'] ) {
// Ajax Requests // Ajax Requests
$title = wp_specialchars(stripslashes($_GET['t'])); $title = wp_specialchars(stripslashes($_GET['t']));
$selection = trim(wp_specialchars(str_replace("\n", ' ',stripslashes($_GET['s'])))); $selection = trim(str_replace('\\n', "<br />", wp_specialchars(js_escape($_GET['s']))));
$url = $_GET['u']; $url = clean_url($_GET['u']);
$image = $_GET['i']; $image = $_GET['i'];
if($_REQUEST['ajax'] == 'thickbox') { ?> if($_REQUEST['ajax'] == 'thickbox') { ?>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
@ -130,7 +106,6 @@ if($_REQUEST['ajax'] == 'thickbox') { ?>
jQuery('.select').click(function() { jQuery('.select').click(function() {
image_selector(); image_selector();
}); });
</script> </script>
<h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3> <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3>
<div class="titlewrap"> <div class="titlewrap">
@ -154,33 +129,29 @@ if($_REQUEST['ajax'] == 'video') { ?>
} }
if($_REQUEST['ajax'] == 'photo_images') { if($_REQUEST['ajax'] == 'photo_images') {
error_log('photo images');
function get_images_from_uri($uri) { function get_images_from_uri($uri) {
if(preg_match('/\.(jpg|png|gif)/', $uri)) if(preg_match('/\.(jpg|png|gif)/', $uri))
return "'".$uri."'"; return "'".$uri."'";
$content = wp_remote_fopen($uri); $content = wp_remote_fopen($uri);
$host = parse_url($uri);
if ( false === $content ) return ''; if ( false === $content ) return '';
$host = parse_url($uri);
$pattern = '/<img ([^>]*)src=(\"|\')(.+?)(\2)([^>\/]*)\/*>/is'; $pattern = '/<img ([^>]*)src=(\"|\')(.+?)(\2)([^>\/]*)\/*>/is';
preg_match_all($pattern, $content, $matches); preg_match_all($pattern, $content, $matches);
if ( empty($matches[1]) ) { error_log('empty'); return ''; };
if ( empty($matches[1]) ) return '';
$sources = array(); $sources = array();
foreach ($matches[3] as $src) { foreach ($matches[3] as $src) {
error_log($src); if(strpos($src, 'http') === false)
#if ( false !== strpos($src, '&') ) continue; if(strpos($src, '../') === false && strpos($src, './') === false)
if(strpos($src, 'http') === false) { $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
if(strpos($src, '../') === false && strpos($src, './') === false) { else
$src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src);
} else {
$src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); $sources[] = $src;
}
}
$sources[] = $src;
} }
return "'" . implode("','", $sources) . "'"; return "'" . implode("','", $sources) . "'";
} }
@ -226,11 +197,8 @@ if($_REQUEST['ajax'] == 'photo_js') { ?>
if (img.width && img.height) { if (img.width && img.height) {
if (img.width * img.height < 2500) skip = true; if (img.width * img.height < 2500) skip = true;
aspect = img.width / img.height; aspect = img.width / img.height;
if (aspect > 1) { // Image is wide scale = (aspect > 1) ? (75 / img.width) : (75 / img.height);
scale = 75 / img.width;
} else { // Image is tall or square
scale = 75 / img.height;
}
if (scale < 1) { if (scale < 1) {
w = parseInt(img.width * scale); w = parseInt(img.width * scale);
h = parseInt(img.height * scale); h = parseInt(img.height * scale);
@ -252,15 +220,12 @@ if($_REQUEST['ajax'] == 'photo_js') { ?>
<?php die; } <?php die; }
if($_REQUEST['ajax'] == 'photo') { ?> if($_REQUEST['ajax'] == 'photo') { ?>
<div class="photolist"></div> <div class="photolist"></div>
<small><?php _e('Click images to select:') ?></small> <small><?php _e('Click images to select:') ?></small>
<div class="titlewrap"> <div class="titlewrap">
<div id="img_container"></div> <div id="img_container"></div>
</div> </div>
<?php die; } <?php die; }
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
@ -317,7 +282,8 @@ if($_REQUEST['ajax'] == 'photo') { ?>
accessibility_focus : false, accessibility_focus : false,
tab_focus : ":next", tab_focus : ":next",
plugins : "safari,inlinepopups", plugins : "safari,inlinepopups",
entities : "38,amp,60,lt,62,gt" entities : "38,amp,60,lt,62,gt",
force_p_newlines : true
}); });
<?php } ?> <?php } ?>
@ -349,6 +315,7 @@ if($_REQUEST['ajax'] == 'photo') { ?>
jQuery("#post_type").val(type); jQuery("#post_type").val(type);
} }
function set_editor(text) { function set_editor(text) {
if(tinyMCE.activeEditor) tinyMCE.activeEditor.setContent(''); if(tinyMCE.activeEditor) tinyMCE.activeEditor.setContent('');
if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text); if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text);
} }
@ -369,11 +336,7 @@ if($_REQUEST['ajax'] == 'photo') { ?>
jQuery('#content_type').show(); jQuery('#content_type').show();
set_menu('text'); set_menu('text');
set_title('<?php _e('Text') ?>'); set_title('<?php _e('Text') ?>');
<?php if($selection) { ?>
set_editor('<?php echo '<p><a href="'.$url.'">'.$selection.'</a> </p> '; ?>');
<?php } else { ?>
set_editor('<?php echo '<p><a href="'.$url.'">'.$title.'</a> </p> '; ?>');
<?php } ?>
return false; return false;
break; break;
case 'quote' : case 'quote' :
@ -499,7 +462,29 @@ if($_REQUEST['ajax'] == 'photo') { ?>
</div> </div>
</div> </div>
<?php category_div(); ?> <div id="categories">
<div class="submitbox" id="submitpost">
<div id="previewview"></div>
<div class="inside">
<h2><?php _e('Categories') ?></h2>
<div id="categories-all">
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
<?php wp_category_checklist() ?>
</ul>
</div>
<h2><?php _e('Tags') ?></h2>
<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>
<div id="tagchecklist"></div>
</div>
<label for="post_status" id="post_status"><input type="radio" name="post_status" value="publish" checked="checked" id="published" />Published <input type="radio" name="post_status" value="draft" id="unpubplished" /> Unpublished</label>
<p class="submit">
<input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/>
<img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/>
</p>
</div>
</form> </form>
</body> </body>