2 require_once('admin.php');
4 $wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder' );
6 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
7 $wpvar = $wpvarstoreset[$i];
9 if (empty($_POST["$wpvar"])) {
10 if (empty($_GET["$wpvar"])) {
13 $$wpvar = $_GET["$wpvar"];
16 $$wpvar = $_POST["$wpvar"];
21 if (isset($_POST['deletepost'])) {
25 // Fix submenu highlighting for pages.
26 if ( isset($_REQUEST['post']) && 'static' == get_post_status($_REQUEST['post']) )
27 $submenu_file = 'page-new.php';
33 check_admin_referer();
35 $post_ID = write_post();
38 if (!empty($_POST['mode'])) {
39 switch($_POST['mode']) {
41 $location = $_POST['referredby'];
44 $location = 'sidebar.php?a=b';
47 $location = 'post.php';
51 $location = 'post.php?posted=true';
54 if ( 'static' == $_POST['post_status'] )
55 $location = "page-new.php?saved=true";
57 if ( isset($_POST['save']) )
58 $location = "post.php?action=edit&post=$post_ID";
60 header("Location: $location");
67 require_once('admin-header.php');
69 $post_ID = $p = (int) $_GET['post'];
71 if ( !current_user_can('edit_post', $post_ID) )
72 die ( __('You are not allowed to edit this post.') );
74 $post = get_post_to_edit($post_ID);
76 if ($post->post_status == 'static')
77 include('edit-page-form.php');
79 include('edit-form-advanced.php');
82 <div id='preview' class='wrap'>
83 <h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?> <small class="quickjump"><a href="#write-post"><?php _e('edit ↑'); ?></a></small></h2>
84 <iframe src="<?php echo add_query_arg('preview', 'true', get_permalink($post->ID)); ?>" width="100%" height="600" ></iframe>
89 case 'editattachment':
90 check_admin_referer();
92 $post_id = (int) $_POST['post_ID'];
94 // Don't let these be changed
95 unset($_POST['guid']);
96 $_POST['post_status'] = 'attachment';
98 // Update the thumbnail filename
99 $oldmeta = $newmeta = get_post_meta($post_id, '_wp_attachment_metadata', true);
100 $newmeta['thumb'] = $_POST['thumb'];
102 if ( '' !== $oldmeta )
103 update_post_meta($post_id, '_wp_attachment_metadata', $newmeta, $oldmeta);
105 add_post_meta($post_id, '_wp_attachment_metadata', $newmeta);
108 check_admin_referer();
110 $post_ID = edit_post();
112 if ($_POST['save']) {
113 $location = $_SERVER['HTTP_REFERER'];
114 } elseif ($_POST['updatemeta']) {
115 $location = $_SERVER['HTTP_REFERER'] . '&message=2#postcustom';
116 } elseif ($_POST['deletemeta']) {
117 $location = $_SERVER['HTTP_REFERER'] . '&message=3#postcustom';
118 } elseif (isset($_POST['referredby']) && $_POST['referredby'] != $_SERVER['HTTP_REFERER']) {
119 $location = $_POST['referredby'];
120 if ( $_POST['referredby'] == 'redo' )
121 $location = get_permalink( $post_ID );
122 } elseif ($action == 'editattachment') {
123 $location = 'attachments.php';
125 $location = 'post.php';
127 header ('Location: ' . $location); // Send user on their way while we keep working
133 check_admin_referer();
135 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
137 $post = & get_post($post_id);
139 if ( !current_user_can('edit_post', $post_id) )
140 die( __('You are not allowed to delete this post.') );
142 if ( $post->post_status == 'attachment' ) {
143 if ( ! wp_delete_attachment($post_id) )
144 die( __('Error in deleting...') );
146 if ( !wp_delete_post($post_id) )
147 die( __('Error in deleting...') );
150 $sendback = $_SERVER['HTTP_REFERER'];
151 if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php';
152 elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php';
153 $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
154 header ('Location: ' . $sendback);
158 $title = __('Edit Comment');
159 $parent_file = 'edit.php';
160 require_once ('admin-header.php');
162 get_currentuserinfo();
164 $comment = (int) $_GET['comment'];
166 if ( ! $comment = get_comment($comment) )
167 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
169 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
170 die( __('You are not allowed to edit comments on this post.') );
172 $comment = get_comment_to_edit($comment);
174 include('edit-form-comment.php');
178 case 'confirmdeletecomment':
180 require_once('./admin-header.php');
182 $comment = (int) $_GET['comment'];
183 $p = (int) $_GET['p'];
185 if ( ! $comment = get_comment($comment) )
186 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
188 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
189 die( __('You are not allowed to delete comments on this post.') );
191 echo "<div class='wrap'>\n";
192 echo "<p>" . __('<strong>Caution:</strong> You are about to delete the following comment:') . "</p>\n";
193 echo "<table border='0'>\n";
194 echo "<tr><td>" . __('Author:') . "</td><td>$comment->comment_author</td></tr>\n";
195 echo "<tr><td>" . __('E-mail:') . "</td><td>$comment->comment_author_email</td></tr>\n";
196 echo "<tr><td>". __('URL:') . "</td><td>$comment->comment_author_url</td></tr>\n";
197 echo "<tr><td>". __('Comment:') . "</td><td>$comment->comment_content</td></tr>\n";
199 echo "<p>" . __('Are you sure you want to do that?') . "</p>\n";
201 echo "<form action='".get_settings('siteurl')."/wp-admin/post.php' method='get'>\n";
202 echo "<input type='hidden' name='action' value='deletecomment' />\n";
203 echo "<input type='hidden' name='p' value='$p' />\n";
204 echo "<input type='hidden' name='comment' value='{$comment->comment_ID}' />\n";
205 echo "<input type='hidden' name='noredir' value='1' />\n";
206 echo "<input type='submit' value='" . __('Yes') . "' />";
208 echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit.php?p=$p&c=1#comments';\" />\n";
214 case 'deletecomment':
216 check_admin_referer();
218 $comment = (int) $_GET['comment'];
219 $p = (int) $_GET['p'];
220 if (isset($_GET['noredir'])) {
226 $postdata = get_post($p) or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
228 if ( ! $comment = get_comment($comment) )
229 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'post.php'));
231 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
232 die( __('You are not allowed to edit comments on this post.') );
234 wp_set_comment_status($comment->comment_ID, "delete");
235 do_action('delete_comment', $comment->comment_ID);
237 if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
238 header('Location: ' . $_SERVER['HTTP_REFERER']);
240 header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
245 case 'unapprovecomment':
247 check_admin_referer();
249 $comment = (int) $_GET['comment'];
250 $p = (int) $_GET['p'];
251 if (isset($_GET['noredir'])) {
257 if ( ! $comment = get_comment($comment) )
258 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
260 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
261 die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
263 wp_set_comment_status($comment->comment_ID, "hold");
265 if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
266 header('Location: ' . $_SERVER['HTTP_REFERER']);
268 header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
273 case 'mailapprovecomment':
275 $comment = (int) $_GET['comment'];
277 if ( ! $comment = get_comment($comment) )
278 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
280 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
281 die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
283 if ('1' != $comment->comment_approved) {
284 wp_set_comment_status($comment->comment_ID, 'approve');
285 if (true == get_option('comments_notify'))
286 wp_notify_postauthor($comment->comment_ID);
289 header('Location: ' . get_option('siteurl') . '/wp-admin/moderation.php?approved=1');
293 case 'approvecomment':
295 $comment = (int) $_GET['comment'];
296 $p = (int) $_GET['p'];
297 if (isset($_GET['noredir'])) {
303 if ( ! $comment = get_comment($comment) )
304 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
306 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
307 die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
309 wp_set_comment_status($comment->comment_ID, "approve");
310 if (get_settings("comments_notify") == true) {
311 wp_notify_postauthor($comment->comment_ID);
315 if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
316 header('Location: ' . $_SERVER['HTTP_REFERER']);
318 header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
323 case 'editedcomment':
327 $referredby = $_POST['referredby'];
328 if (!empty($referredby)) {
329 header('Location: ' . $referredby);
331 header ("Location: edit.php?p=$comment_post_ID&c=1#comments");
337 $title = __('Create New Post');
338 require_once ('./admin-header.php');
340 <?php if ( isset($_GET['posted']) ) : ?>
341 <div id="message" class="updated fade"><p><?php printf(__('Post saved. <a href="%s">View site »</a>'), get_bloginfo('home') . '/'); ?></p></div>
344 if ( current_user_can('edit_posts') ) {
346 get_currentuserinfo();
347 if ( $drafts = get_users_drafts( $user_ID ) ) {
350 <p><strong><?php _e('Your Drafts:') ?></strong>
352 $num_drafts = count($drafts);
353 if ( $num_drafts > 15 ) $num_drafts = 15;
354 for ( $i = 0; $i < $num_drafts; $i++ ) {
355 $draft = $drafts[$i];
358 $draft->post_title = stripslashes($draft->post_title);
359 if ( empty($draft->post_title) )
360 $draft->post_title = sprintf(__('Post # %s'), $draft->ID);
361 echo "<a href='post.php?action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
364 <?php if ( 15 < count($drafts) ) { ?>
365 , <a href="edit.php"><?php echo sprintf(__('and %s more'), (count($drafts) - 15) ); ?> »</a>
372 $post = get_default_post_to_edit();
374 include('edit-form-advanced.php');
377 <?php echo '<h3>'.__('WordPress bookmarklet').'</h3>
378 <p>'.__('Right click on the following link and choose "Add to favorites" to create a posting shortcut.').'</p>'; ?>
382 if ($is_NS4 || $is_gecko) {
384 <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>
386 } else if ($is_winIE) {
388 <a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;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'), get_settings('blogname')); ?></a>
389 <script type="text/javascript">
391 function oneclickbookmarklet(blah) {
392 window.open ("profile.php?action=IErightclick", "oneclickbookmarklet", "width=500, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=120, left=120, screenY=120, top=120");
398 <?php _e('One-click bookmarklet:') ?><br />
399 <a href="javascript:oneclickbookmarklet(0);"><?php _e('click here') ?></a>
401 } else if ($is_opera) {
403 <a href="javascript:location.href='<?php echo get_settings('siteurl'); ?>/wp-admin/post.php?popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
405 } else if ($is_macIE) {
407 <a href="javascript:Q='';location.href='<?php echo get_settings('siteurl'); ?>/wp-admin/bookmarklet.php?text='+escape(document.getSelection())+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
417 <p><?php printf(__('Since you’re a newcomer, you’ll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />
418 You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
419 When you’re promoted, just reload this page and you’ll be able to blog. :)'), get_settings('admin_email')); ?>
428 include('admin-footer.php');