[ Index ] |
|
Code source de WordPress 2.1.2 |
1 <?php 2 require_once ('admin.php'); 3 4 $parent_file = 'edit.php'; 5 $submenu_file = 'edit.php'; 6 7 wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder')); 8 9 if ( isset( $_POST['deletepost'] ) ) 10 $action = 'delete'; 11 12 switch($action) { 13 case 'postajaxpost': 14 case 'post': 15 $parent_file = 'post-new.php'; 16 $submenu_file = 'post-new.php'; 17 check_admin_referer('add-post'); 18 19 $post_ID = 'post' == $action ? write_post() : edit_post(); 20 21 // Redirect. 22 if (!empty($_POST['mode'])) { 23 switch($_POST['mode']) { 24 case 'bookmarklet': 25 $location = $_POST['referredby']; 26 break; 27 case 'sidebar': 28 $location = 'sidebar.php?a=b'; 29 break; 30 default: 31 $location = 'post-new.php'; 32 break; 33 } 34 } else { 35 $location = "post-new.php?posted=$post_ID"; 36 } 37 38 if ( isset($_POST['save']) ) 39 $location = "post.php?action=edit&post=$post_ID"; 40 41 wp_redirect($location); 42 exit(); 43 break; 44 45 case 'edit': 46 $title = __('Edit'); 47 $editing = true; 48 $post_ID = $p = (int) $_GET['post']; 49 $post = get_post($post_ID); 50 51 if ( 'page' == $post->post_type ) { 52 wp_redirect("page.php?action=edit&post=$post_ID"); 53 exit(); 54 } 55 56 if($post->post_status == 'draft') { 57 wp_enqueue_script('prototype'); 58 wp_enqueue_script('autosave'); 59 } 60 require_once ('admin-header.php'); 61 62 if ( !current_user_can('edit_post', $post_ID) ) 63 die ( __('You are not allowed to edit this post.') ); 64 65 $post = get_post_to_edit($post_ID); 66 67 include ('edit-form-advanced.php'); 68 69 ?> 70 <div id='preview' class='wrap'> 71 <h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?></h2> 72 <iframe src="<?php echo attribute_escape(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe> 73 </div> 74 <?php 75 break; 76 77 case 'editattachment': 78 $post_id = (int) $_POST['post_ID']; 79 80 check_admin_referer('update-attachment_' . $post_id); 81 82 // Don't let these be changed 83 unset($_POST['guid']); 84 $_POST['post_type'] = 'attachment'; 85 86 // Update the thumbnail filename 87 $newmeta = wp_get_attachment_metadata( $post_id, true ); 88 $newmeta['thumb'] = $_POST['thumb']; 89 90 wp_update_attachment_metadata( $post_id, $newmeta ); 91 92 case 'editpost': 93 $post_ID = (int) $_POST['post_ID']; 94 check_admin_referer('update-post_' . $post_ID); 95 96 $post_ID = edit_post(); 97 98 if ( 'post' == $_POST['originalaction'] ) { 99 if (!empty($_POST['mode'])) { 100 switch($_POST['mode']) { 101 case 'bookmarklet': 102 $location = $_POST['referredby']; 103 break; 104 case 'sidebar': 105 $location = 'sidebar.php?a=b'; 106 break; 107 default: 108 $location = 'post-new.php'; 109 break; 110 } 111 } else { 112 $location = "post-new.php?posted=$post_ID"; 113 } 114 115 if ( isset($_POST['save']) ) 116 $location = "post.php?action=edit&post=$post_ID"; 117 } else { 118 $referredby = ''; 119 if ( !empty($_POST['referredby']) ) 120 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); 121 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); 122 123 if ($_POST['save']) { 124 $location = "post.php?action=edit&post=$post_ID"; 125 } elseif ($_POST['updatemeta']) { 126 $location = wp_get_referer() . '&message=2#postcustom'; 127 } elseif ($_POST['deletemeta']) { 128 $location = wp_get_referer() . '&message=3#postcustom'; 129 } elseif (!empty($referredby) && $referredby != $referer) { 130 $location = $_POST['referredby']; 131 if ( $_POST['referredby'] == 'redo' ) 132 $location = get_permalink( $post_ID ); 133 } elseif ($action == 'editattachment') { 134 $location = 'attachments.php'; 135 } else { 136 $location = 'post-new.php'; 137 } 138 } 139 140 wp_redirect($location); // Send user on their way while we keep working 141 142 exit(); 143 break; 144 145 case 'delete': 146 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 147 check_admin_referer('delete-post_' . $post_id); 148 149 $post = & get_post($post_id); 150 151 if ( !current_user_can('delete_post', $post_id) ) 152 wp_die( __('You are not allowed to delete this post.') ); 153 154 if ( $post->post_type == 'attachment' ) { 155 if ( ! wp_delete_attachment($post_id) ) 156 wp_die( __('Error in deleting...') ); 157 } else { 158 if ( !wp_delete_post($post_id) ) 159 wp_die( __('Error in deleting...') ); 160 } 161 162 $sendback = wp_get_referer(); 163 if (strstr($sendback, 'post.php')) $sendback = get_option('siteurl') .'/wp-admin/post-new.php'; 164 elseif (strstr($sendback, 'attachments.php')) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; 165 $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); 166 wp_redirect($sendback); 167 exit(); 168 break; 169 170 default: 171 wp_redirect('edit.php'); 172 exit(); 173 break; 174 } // end switch 175 include ('admin-footer.php'); 176 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 30 19:41:27 2007 | par Balluche grâce à PHPXref 0.7 |