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('add-post');
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=$post_ID";
54 if ( 'static' == $_POST['post_status'] )
55 $location = "page-new.php?saved=$post_ID";
57 if ( isset($_POST['save']) )
58 $location = "post.php?action=edit&post=$post_ID";
60 wp_redirect($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 clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>
89 case 'editattachment':
90 $post_id = (int) $_POST['post_ID'];
92 check_admin_referer('update-attachment_' . $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 $post_ID = (int) $_POST['post_ID'];
109 check_admin_referer('update-post_' . $post_ID);
111 $post_ID = edit_post();
114 if ( !empty($_POST['referredby']) )
115 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']);
116 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
118 if ($_POST['save']) {
119 $location = wp_get_referer();
120 } elseif ($_POST['updatemeta']) {
121 $location = wp_get_referer() . '&message=2#postcustom';
122 } elseif ($_POST['deletemeta']) {
123 $location = wp_get_referer() . '&message=3#postcustom';
124 } elseif (!empty($referredby) && $referredby != $referer) {
125 $location = $_POST['referredby'];
126 if ( $_POST['referredby'] == 'redo' )
127 $location = get_permalink( $post_ID );
128 } elseif ($action == 'editattachment') {
129 $location = 'attachments.php';
131 $location = 'post.php';
134 wp_redirect($location); // Send user on their way while we keep working
140 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
142 $post = & get_post($post_id);
143 if ( 'static' == $post->post_status )
144 check_admin_referer('delete-page_' . $post_id);
146 check_admin_referer('delete-post_' . $post_id);
148 if ( !current_user_can('edit_post', $post_id) )
149 die( __('You are not allowed to delete this post.') );
151 if ( $post->post_status == 'attachment' ) {
152 if ( ! wp_delete_attachment($post_id) )
153 die( __('Error in deleting...') );
155 if ( !wp_delete_post($post_id) )
156 die( __('Error in deleting...') );
159 $sendback = wp_get_referer();
160 if ( 'static' == $post->post_status )
161 $sendback = get_option('siteurl') . '/wp-admin/edit-pages.php';
162 elseif ( strstr($sendback, 'post.php') )
163 $sendback = get_option('siteurl') .'/wp-admin/post.php';
164 elseif ( strstr($sendback, 'attachments.php') )
165 $sendback = get_option('siteurl') .'/wp-admin/attachments.php';
166 wp_redirect($sendback);
170 $title = __('Edit Comment');
171 $parent_file = 'edit.php';
172 require_once ('admin-header.php');
174 get_currentuserinfo();
176 $comment = (int) $_GET['comment'];
178 if ( ! $comment = get_comment($comment) )
179 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
181 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
182 die( __('You are not allowed to edit comments on this post.') );
184 $comment = get_comment_to_edit($comment);
186 include('edit-form-comment.php');
190 case 'confirmdeletecomment':
192 require_once('./admin-header.php');
194 $comment = (int) $_GET['comment'];
195 $p = (int) $_GET['p'];
197 if ( ! $comment = get_comment_to_edit($comment) )
198 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
200 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
201 die( __('You are not allowed to delete comments on this post.') );
203 echo "<div class='wrap'>\n";
204 echo "<p>" . __('<strong>Caution:</strong> You are about to delete the following comment:') . "</p>\n";
205 echo "<table border='0'>\n";
206 echo "<tr><td>" . __('Author:') . "</td><td>$comment->comment_author</td></tr>\n";
207 echo "<tr><td>" . __('E-mail:') . "</td><td>$comment->comment_author_email</td></tr>\n";
208 echo "<tr><td>". __('URL:') . "</td><td>$comment->comment_author_url</td></tr>\n";
209 echo "<tr><td>". __('Comment:') . "</td><td>$comment->comment_content</td></tr>\n";
211 echo "<p>" . __('Are you sure you want to do that?') . "</p>\n";
213 echo "<form action='".get_settings('siteurl')."/wp-admin/post.php' method='get'>\n";
214 echo "<input type='hidden' name='action' value='deletecomment' />\n";
215 echo "<input type='hidden' name='p' value='$p' />\n";
216 echo "<input type='hidden' name='comment' value='{$comment->comment_ID}' />\n";
217 echo "<input type='hidden' name='noredir' value='1' />\n";
218 wp_nonce_field('delete-comment_' . $comment->comment_ID);
219 echo "<input type='submit' value='" . __('Yes') . "' />";
221 echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit.php?p=$p&c=1#comments';\" />\n";
227 case 'deletecomment':
228 $comment = (int) $_GET['comment'];
229 check_admin_referer('delete-comment_' . $comment);
231 $p = (int) $_GET['p'];
232 if (isset($_GET['noredir'])) {
238 $postdata = get_post($p) or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
240 if ( ! $comment = get_comment($comment) )
241 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'post.php'));
243 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
244 die( __('You are not allowed to edit comments on this post.') );
246 wp_set_comment_status($comment->comment_ID, "delete");
247 do_action('delete_comment', $comment->comment_ID);
249 if ((wp_get_referer() != "") && (false == $noredir)) {
250 wp_redirect(wp_get_referer());
252 wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
257 case 'unapprovecomment':
258 $comment = (int) $_GET['comment'];
259 check_admin_referer('unapprove-comment_' . $comment);
261 $p = (int) $_GET['p'];
262 if (isset($_GET['noredir'])) {
268 if ( ! $comment = get_comment($comment) )
269 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
271 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
272 die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
274 wp_set_comment_status($comment->comment_ID, "hold");
276 if ((wp_get_referer() != "") && (false == $noredir)) {
277 wp_redirect(wp_get_referer());
279 wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
284 case 'mailapprovecomment':
285 $comment = (int) $_GET['comment'];
286 check_admin_referer('approve-comment_' . $comment);
288 if ( ! $comment = get_comment($comment) )
289 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
291 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
292 die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
294 if ('1' != $comment->comment_approved) {
295 wp_set_comment_status($comment->comment_ID, 'approve');
296 if (true == get_option('comments_notify'))
297 wp_notify_postauthor($comment->comment_ID);
300 wp_redirect(get_option('siteurl') . '/wp-admin/moderation.php?approved=1');
304 case 'approvecomment':
305 $comment = (int) $_GET['comment'];
306 check_admin_referer('approve-comment_' . $comment);
308 $p = (int) $_GET['p'];
309 if (isset($_GET['noredir'])) {
315 if ( ! $comment = get_comment($comment) )
316 die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
318 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
319 die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
321 wp_set_comment_status($comment->comment_ID, "approve");
322 if (get_settings("comments_notify") == true) {
323 wp_notify_postauthor($comment->comment_ID);
327 if ((wp_get_referer() != "") && (false == $noredir)) {
328 wp_redirect(wp_get_referer());
330 wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
335 case 'editedcomment':
337 $comment_ID = (int) $_POST['comment_ID'];
338 $comment_post_ID = (int) $_POST['comment_post_ID'];
340 check_admin_referer('update-comment_' . $comment_ID);
344 $location = ( empty($_POST['referredby']) ? "edit.php?p=$comment_post_ID&c=1" : $_POST['referredby'] ) . '#comment-' . $comment_ID;
345 $location = apply_filters('comment_edit_redirect', $location, $comment_ID);
346 wp_redirect($location);
351 $title = __('Create New Post');
352 require_once ('./admin-header.php');
354 <?php if ( isset($_GET['posted']) ) : ?>
355 <div id="message" class="updated fade"><p><strong><?php _e('Post saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?> »</a></p></div>
358 if ( current_user_can('edit_posts') ) {
360 get_currentuserinfo();
361 if ( $drafts = get_users_drafts( $user_ID ) ) {
364 <p><strong><?php _e('Your Drafts:') ?></strong>
366 $num_drafts = count($drafts);
367 if ( $num_drafts > 15 ) $num_drafts = 15;
368 for ( $i = 0; $i < $num_drafts; $i++ ) {
369 $draft = $drafts[$i];
372 $draft->post_title = stripslashes($draft->post_title);
373 if ( empty($draft->post_title) )
374 $draft->post_title = sprintf(__('Post # %s'), $draft->ID);
375 echo "<a href='post.php?action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
378 <?php if ( 15 < count($drafts) ) { ?>
379 , <a href="edit.php"><?php echo sprintf(__('and %s more'), (count($drafts) - 15) ); ?> »</a>
386 $post = get_default_post_to_edit();
388 include('edit-form-advanced.php');
390 <div id="wp-bookmarklet" class="wrap">
391 <?php echo '<h3>'.__('WordPress bookmarklet').'</h3>
392 <p>'.__('Right click on the following link and choose "Add to favorites" to create a posting shortcut.').'</p>'; ?>
396 if ($is_NS4 || $is_gecko) {
398 <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>
400 } else if ($is_winIE) {
402 <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>
403 <script type="text/javascript">
405 function oneclickbookmarklet(blah) {
406 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");
412 <?php _e('One-click bookmarklet:') ?><br />
413 <a href="javascript:oneclickbookmarklet(0);"><?php _e('click here') ?></a>
415 } else if ($is_opera) {
417 <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>
419 } else if ($is_macIE) {
421 <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>
431 <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 />
432 You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
433 When you’re promoted, just reload this page and you’ll be able to blog. :)'), get_settings('admin_email')); ?>
442 include('admin-footer.php');