New bookmarklet action.
git-svn-id: http://svn.automattic.com/wordpress/trunk@3127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
32daaee631
commit
f34d914107
|
@ -212,17 +212,37 @@ function get_post_to_edit($id) {
|
|||
|
||||
// Default post information to use when populating the "Write Post" form.
|
||||
function get_default_post_to_edit() {
|
||||
global $content, $excerpt, $edited_post_title;
|
||||
if ( !empty($_REQUEST['post_title']) )
|
||||
$post_title = wp_specialchars(stripslashes($_REQUEST['post_title']));
|
||||
else if ( !empty($_REQUEST['popuptitle']) ) {
|
||||
$post_title = wp_specialchars(stripslashes($_REQUEST['popuptitle']));
|
||||
$post_title = funky_javascript_fix($post_title);
|
||||
} else {
|
||||
$post_title = '';
|
||||
}
|
||||
|
||||
if ( !empty($_REQUEST['content']) )
|
||||
$post_content = wp_specialchars(stripslashes($_REQUEST['content']));
|
||||
else if ( !empty($post_title) ) {
|
||||
$text = wp_specialchars(stripslashes(urldecode($_REQUEST['text'])));
|
||||
$text = funky_javascript_fix($text);
|
||||
$popupurl = wp_specialchars($_REQUEST['popupurl']);
|
||||
$post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\n$text";
|
||||
}
|
||||
|
||||
if ( !empty($_REQUEST['excerpt']) )
|
||||
$post_excerpt = wp_specialchars(stripslashes($_REQUEST['excerpt']));
|
||||
else
|
||||
$post_excerpt = '';
|
||||
|
||||
$post->post_status = 'draft';
|
||||
$post->comment_status = get_settings('default_comment_status');
|
||||
$post->ping_status = get_settings('default_ping_status');
|
||||
$post->post_pingback = get_settings('default_pingback_flag');
|
||||
$post->post_category = get_settings('default_category');
|
||||
$content = wp_specialchars($content);
|
||||
$post->post_content = apply_filters('default_content', $content);
|
||||
$post->post_title = apply_filters('default_title', $edited_post_title);
|
||||
$post->post_excerpt = apply_filters('default_excerpt', $excerpt);
|
||||
$post->post_content = apply_filters('default_content', $post_content);
|
||||
$post->post_title = apply_filters('default_title', $post_title);
|
||||
$post->post_excerpt = apply_filters('default_excerpt', $post_excerpt);
|
||||
$post->page_template = 'default';
|
||||
$post->post_parent = 0;
|
||||
$post->menu_order = 0;
|
||||
|
|
|
@ -8,6 +8,10 @@ $messages[3] = __('Custom field deleted.');
|
|||
<?php endif; ?>
|
||||
|
||||
<form name="post" action="post.php" method="post" id="post">
|
||||
<?php if ( (isset($mode) && 'bookmarklet' == $mode) ||
|
||||
isset($_GET['popupurl']) ): ?>
|
||||
<input type="hidden" name="mode" value="bookmarklet" />
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2 id="write-post"><?php _e('Write Post'); ?><?php if ( 0 != $post_ID ) : ?>
|
||||
|
@ -204,7 +208,9 @@ if ('publish' != $post->post_status || 0 == $post_ID) {
|
|||
}
|
||||
?>
|
||||
<input name="referredby" type="hidden" id="referredby" value="<?php
|
||||
if ( url_to_postid($_SERVER['HTTP_REFERER']) == $post_ID )
|
||||
if ( !empty($_REQUEST['popupurl']) )
|
||||
echo wp_specialchars($_REQUEST['popupurl']);
|
||||
else if ( url_to_postid($_SERVER['HTTP_REFERER']) == $post_ID )
|
||||
echo 'redo';
|
||||
else
|
||||
echo wp_specialchars($_SERVER['HTTP_REFERER']);
|
||||
|
|
|
@ -36,7 +36,7 @@ case 'post':
|
|||
if (!empty($_POST['mode'])) {
|
||||
switch($_POST['mode']) {
|
||||
case 'bookmarklet':
|
||||
$location = 'bookmarklet.php?a=b';
|
||||
$location = $_POST['referredby'];
|
||||
break;
|
||||
case 'sidebar':
|
||||
$location = 'sidebar.php?a=b';
|
||||
|
@ -52,7 +52,7 @@ case 'post':
|
|||
if ( 'static' == $_POST['post_status'] )
|
||||
$location = "page-new.php?saved=true";
|
||||
|
||||
if ( '' != $_POST['advanced'] || isset($_POST['save']) )
|
||||
if ( isset($_POST['save']) )
|
||||
$location = "post.php?action=edit&post=$post_ID";
|
||||
|
||||
header("Location: $location");
|
||||
|
@ -353,7 +353,8 @@ $bookmarklet_height= (get_settings('use_trackback')) ? 480 : 440;
|
|||
|
||||
if ($is_NS4 || $is_gecko) {
|
||||
?>
|
||||
<a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}void(window.open('<?php echo get_settings('siteurl') ?>/wp-admin/bookmarklet.php?text='+encodeURIComponent(Q)+'&popupurl='+encodeURIComponent(location.href)+'&popuptitle='+encodeURIComponent(document.title),'<?php _e('WordPress bookmarklet') ?>','scrollbars=yes,width=600,height=460,left=100,top=150,status=yes'));"><?php printf(__('Press It - %s'), wp_specialchars(get_settings('blogname'))); ?></a>
|
||||
|
||||
<a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}location.href='<?php echo get_settings('siteurl') ?>/wp-admin/post.php?text='+encodeURIComponent(Q)+'&popupurl='+encodeURIComponent(location.href)+'&popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press It - %s'), wp_specialchars(get_settings('blogname'))); ?></a>
|
||||
<?php
|
||||
} else if ($is_winIE) {
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue