Changeset 810
- Timestamp:
- 11/24/06 16:16:44 (2 years ago)
- Files:
-
- trunk/index.php (modified) (1 diff)
- trunk/wp-admin/admin-ajax.php (modified) (1 diff)
- trunk/wp-admin/admin-db.php (modified) (12 diffs)
- trunk/wp-admin/admin-functions.php (modified) (88 diffs)
- trunk/wp-admin/admin-header.php (modified) (1 diff)
- trunk/wp-admin/bookmarklet.php (modified) (2 diffs)
- trunk/wp-admin/categories.php (modified) (7 diffs)
- trunk/wp-admin/comment.php (modified) (1 diff)
- trunk/wp-admin/custom-fields.js (modified) (1 diff)
- trunk/wp-admin/dbx-admin-key-js.php (modified) (1 diff)
- trunk/wp-admin/edit-category-form.php (modified) (1 diff)
- trunk/wp-admin/edit-comments.php (modified) (6 diffs)
- trunk/wp-admin/edit-form-advanced.php (modified) (5 diffs)
- trunk/wp-admin/edit-form-comment.php (modified) (1 diff)
- trunk/wp-admin/edit-form.php (modified) (1 diff)
- trunk/wp-admin/edit-link-form.php (modified) (3 diffs)
- trunk/wp-admin/edit-page-form.php (modified) (6 diffs)
- trunk/wp-admin/edit-pages.php (modified) (3 diffs)
- trunk/wp-admin/edit.php (modified) (13 diffs)
- trunk/wp-admin/export.php (modified) (5 diffs)
- trunk/wp-admin/import/blogger.php (modified) (1 diff)
- trunk/wp-admin/import/blogware.php (modified) (7 diffs)
- trunk/wp-admin/import/dotclear.php (modified) (18 diffs)
- trunk/wp-admin/import/greymatter.php (modified) (4 diffs)
- trunk/wp-admin/import/mt.php (modified) (1 diff)
- trunk/wp-admin/import/textpattern.php (modified) (18 diffs)
- trunk/wp-admin/import/wordpress.php (modified) (1 diff)
- trunk/wp-admin/index-extra.php (added)
- trunk/wp-admin/install-helper.php (modified) (5 diffs)
- trunk/wp-admin/link-add.php (modified) (2 diffs)
- trunk/wp-admin/link-import.php (modified) (5 diffs)
- trunk/wp-admin/link-manager.php (modified) (7 diffs)
- trunk/wp-admin/link-parse-opml.php (modified) (3 diffs)
- trunk/wp-admin/link.php (modified) (6 diffs)
- trunk/wp-admin/menu-header.php (modified) (3 diffs)
- trunk/wp-admin/menu.php (modified) (2 diffs)
- trunk/wp-admin/moderation.php (modified) (7 diffs)
- trunk/wp-admin/options-misc.php (modified) (2 diffs)
- trunk/wp-admin/options-permalink.php (modified) (1 diff)
- trunk/wp-admin/options-reading.php (modified) (2 diffs)
- trunk/wp-admin/options-writing.php (modified) (1 diff)
- trunk/wp-admin/plugin-editor.php (modified) (2 diffs)
- trunk/wp-admin/plugins.php (modified) (2 diffs)
- trunk/wp-admin/post.php (modified) (2 diffs)
- trunk/wp-admin/profile.php (modified) (3 diffs)
- trunk/wp-admin/setup-config.php (modified) (4 diffs)
- trunk/wp-admin/sidebar.php (modified) (2 diffs)
- trunk/wp-admin/templates.php (modified) (6 diffs)
- trunk/wp-admin/theme-editor.php (modified) (4 diffs)
- trunk/wp-admin/themes.php (modified) (1 diff)
- trunk/wp-admin/update-links.php (modified) (1 diff)
- trunk/wp-admin/upgrade-functions.php (modified) (15 diffs)
- trunk/wp-admin/upgrade-schema.php (modified) (1 diff)
- trunk/wp-admin/upgrade.php (modified) (1 diff)
- trunk/wp-admin/upload-functions.php (modified) (2 diffs)
- trunk/wp-admin/upload-js.php (modified) (8 diffs)
- trunk/wp-admin/upload-rtl.css (modified) (2 diffs)
- trunk/wp-admin/upload.css (modified) (2 diffs)
- trunk/wp-admin/upload.php (modified) (5 diffs)
- trunk/wp-admin/user-edit.php (modified) (2 diffs)
- trunk/wp-admin/users.php (modified) (10 diffs)
- trunk/wp-admin/wp-admin.css (modified) (4 diffs)
- trunk/wp-admin/xfn.js (modified) (1 diff)
- trunk/wp-atom.php (modified) (4 diffs)
- trunk/wp-commentsrss2.php (modified) (3 diffs)
- trunk/wp-content/themes/classic/comments-popup.php (modified) (2 diffs)
- trunk/wp-content/themes/classic/comments.php (modified) (2 diffs)
- trunk/wp-content/themes/classic/header.php (modified) (1 diff)
- trunk/wp-content/themes/classic/sidebar.php (modified) (1 diff)
- trunk/wp-content/themes/default/archives.php (modified) (1 diff)
- trunk/wp-content/themes/default/comments-popup.php (modified) (2 diffs)
- trunk/wp-content/themes/default/comments.php (modified) (3 diffs)
- trunk/wp-content/themes/default/header.php (modified) (1 diff)
- trunk/wp-content/themes/default/page.php (modified) (2 diffs)
- trunk/wp-content/themes/default/sidebar.php (modified) (1 diff)
- trunk/wp-content/themes/default/single.php (modified) (2 diffs)
- trunk/wp-cron.php (modified) (3 diffs)
- trunk/wp-feed.php (modified) (1 diff)
- trunk/wp-includes/author-template.php (modified) (1 diff)
- trunk/wp-includes/bookmark-template.php (modified) (3 diffs)
- trunk/wp-includes/bookmark.php (modified) (2 diffs)
- trunk/wp-includes/cache.php (modified) (3 diffs)
- trunk/wp-includes/capabilities.php (modified) (11 diffs)
- trunk/wp-includes/category-template.php (modified) (3 diffs)
- trunk/wp-includes/category.php (modified) (3 diffs)
- trunk/wp-includes/classes.php (modified) (24 diffs)
- trunk/wp-includes/comment-template.php (modified) (8 diffs)
- trunk/wp-includes/comment.php (modified) (11 diffs)
- trunk/wp-includes/compat.php (modified) (4 diffs)
- trunk/wp-includes/deprecated.php (modified) (8 diffs)
- trunk/wp-includes/feed.php (modified) (1 diff)
- trunk/wp-includes/formatting.php (modified) (15 diffs)
- trunk/wp-includes/functions.php (modified) (10 diffs)
- trunk/wp-includes/general-template.php (modified) (7 diffs)
- trunk/wp-includes/js/autosave.js.php (modified) (1 diff)
- trunk/wp-includes/js/list-manipulation-js.php (modified) (5 diffs)
- trunk/wp-includes/js/tinymce/license.txt (modified) (12 diffs)
- trunk/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js (modified) (3 diffs)
- trunk/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js (modified) (3 diffs)
- trunk/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js (modified) (4 diffs)
- trunk/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js (modified) (1 diff)
- trunk/wp-includes/js/tinymce/plugins/paste/editor_plugin.js (modified) (1 diff)
- trunk/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js (modified) (1 diff)
- trunk/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js (modified) (1 diff)
- trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js (modified) (1 diff)
- trunk/wp-includes/js/tinymce/themes/advanced/charmap.htm (modified) (1 diff)
- trunk/wp-includes/js/tinymce/themes/advanced/color_picker.htm (modified) (1 diff)
- trunk/wp-includes/js/tinymce/themes/advanced/css/editor_content.css (modified) (1 diff)
- trunk/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css (modified) (1 diff)
- trunk/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css (modified) (1 diff)
- trunk/wp-includes/js/tinymce/themes/advanced/editor_template.js (modified) (19 diffs)
- trunk/wp-includes/js/tinymce/themes/advanced/editor_template_src.js (deleted)
- trunk/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif (modified) (previous)
- trunk/wp-includes/js/tinymce/themes/advanced/images/buttons.gif (modified) (previous)
- trunk/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif (modified) (previous)
- trunk/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js (modified) (3 diffs)
- trunk/wp-includes/js/tinymce/themes/advanced/langs/en.js (modified) (2 diffs)
- trunk/wp-includes/js/tinymce/tiny_mce.js (modified) (223 diffs)
- trunk/wp-includes/js/tinymce/tiny_mce_popup.js (modified) (1 diff)
- trunk/wp-includes/js/tinymce/utils/form_utils.js (modified) (4 diffs)
- trunk/wp-includes/js/tinymce/utils/mclayer.js (modified) (1 diff)
- trunk/wp-includes/js/tinymce/utils/mctabs.js (modified) (1 diff)
- trunk/wp-includes/js/tinymce/utils/validate.js (modified) (2 diffs)
- trunk/wp-includes/js/wp-ajax-js.php (modified) (2 diffs)
- trunk/wp-includes/l10n.php (modified) (1 diff)
- trunk/wp-includes/link-template.php (modified) (11 diffs)
- trunk/wp-includes/pluggable.php (modified) (8 diffs)
- trunk/wp-includes/post.php (modified) (21 diffs)
- trunk/wp-includes/query.php (modified) (24 diffs)
- trunk/wp-includes/registration.php (modified) (1 diff)
- trunk/wp-includes/rewrite.php (modified) (25 diffs)
- trunk/wp-includes/script-loader.php (modified) (4 diffs)
- trunk/wp-includes/theme.php (modified) (17 diffs)
- trunk/wp-includes/user.php (modified) (1 diff)
- trunk/wp-includes/wp-db.php (modified) (1 diff)
- trunk/wp-includes/wpmu-functions.php (modified) (1 diff)
- trunk/wp-links-opml.php (modified) (2 diffs)
- trunk/wp-login.php (modified) (1 diff)
- trunk/wp-rss.php (modified) (2 diffs)
- trunk/wp-rss2.php (modified) (3 diffs)
- trunk/wp-settings.php (modified) (4 diffs)
- trunk/wp-trackback.php (modified) (1 diff)
- trunk/xmlrpc.php (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/index.php
r591 r810 1 <?php 1 <?php 2 2 /* Short and sweet */ 3 3 define('WP_USE_THEMES', true); trunk/wp-admin/admin-ajax.php
r753 r810 129 129 case 'add-cat' : // From Manage->Categories 130 130 if ( !current_user_can( 'manage_categories' ) ) 131 die('-1');131 die('-1'); 132 132 if ( !$cat = wp_insert_category( $_POST ) ) 133 133 die('0'); trunk/wp-admin/admin-db.php
r798 r810 49 49 if ( $user->has_cap('edit_posts') || $exclude_zeros == false ) 50 50 return array($user->id); 51 else 51 else 52 52 return false; 53 53 } … … 157 157 158 158 $cat_ID = (int) $catarr['cat_ID']; 159 160 if( $cat_ID == $catarr['category_parent'] ) 161 return false; 159 162 160 163 // First, get all of the original fields … … 202 205 else 203 206 $cats = array_diff($cats, array($cat_ID)); 204 wp_set_post_categories($post_id, $cats); 207 wp_set_post_categories($post_id, $cats); 205 208 } 206 209 … … 213 216 else 214 217 $cats = array_diff($cats, array($cat_ID)); 215 wp_set_link_cats($link_id, $cats); 216 } 217 218 wp_set_link_cats($link_id, $cats); 219 } 220 218 221 wp_cache_delete($cat_ID, 'category'); 219 222 wp_cache_delete('all_category_ids', 'category'); … … 288 291 function wp_revoke_user($id) { 289 292 $id = (int) $id; 290 293 291 294 $user = new WP_User($id); 292 $user->remove_all_caps(); 295 $user->remove_all_caps(); 293 296 } 294 297 … … 388 391 389 392 // Passed link category list overwrites existing category list if not empty. 390 if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])393 if ( isset($linkdata['link_category']) && is_array($linkdata['link_category']) 391 394 && 0 != count($linkdata['link_category']) ) 392 $link_cats = $linkdata['link_category'];393 else 394 $link_cats = $link['link_category'];395 $link_cats = $linkdata['link_category']; 396 else 397 $link_cats = $link['link_category']; 395 398 396 399 // Merge old and new fields with new fields overwriting old ones. 397 400 $linkdata = array_merge($link, $linkdata); 398 $linkdata['link_category'] = $link_cats;401 $linkdata['link_category'] = $link_cats; 399 402 400 403 return wp_insert_link($linkdata); … … 405 408 406 409 do_action('delete_link', $link_id); 407 410 408 411 $categories = wp_get_link_cats($link_id); 409 412 if( is_array( $categories ) ) { … … 421 424 global $wpdb; 422 425 423 $sql = "SELECT category_id 424 FROM $wpdb->link2cat 425 WHERE link_id = $link_ID 426 $sql = "SELECT category_id 427 FROM $wpdb->link2cat 428 WHERE link_id = $link_ID 426 429 ORDER BY category_id"; 427 430 … … 444 447 // First the old categories 445 448 $old_categories = $wpdb->get_col(" 446 SELECT category_id 447 FROM $wpdb->link2cat 449 SELECT category_id 450 FROM $wpdb->link2cat 448 451 WHERE link_id = $link_ID"); 449 452 … … 460 463 foreach ($delete_cats as $del) { 461 464 $wpdb->query(" 462 DELETE FROM $wpdb->link2cat 463 WHERE category_id = $del 464 AND link_id = $link_ID 465 DELETE FROM $wpdb->link2cat 466 WHERE category_id = $del 467 AND link_id = $link_ID 465 468 "); 466 469 } … … 473 476 foreach ($add_cats as $new_cat) { 474 477 $wpdb->query(" 475 INSERT INTO $wpdb->link2cat (link_id, category_id) 478 INSERT INTO $wpdb->link2cat (link_id, category_id) 476 479 VALUES ($link_ID, $new_cat)"); 477 480 } 478 481 } 479 482 480 483 // Update category counts. 481 484 $all_affected_cats = array_unique(array_merge($link_categories, $old_categories)); … … 484 487 $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'"); 485 488 wp_cache_delete($cat_id, 'category'); 486 } 489 do_action('edit_category', $cat_id); 490 } 491 492 do_action('edit_link', $link_ID); 487 493 } // wp_set_link_cats() 488 494 trunk/wp-admin/admin-functions.php
r804 r810 3 3 function write_post() { 4 4 $result = wp_write_post(); 5 if( is_wp_error( $result) )5 if( is_wp_error( $result ) ) 6 6 wp_die( $result->get_error_message() ); 7 7 else … … 14 14 15 15 if ( 'page' == $_POST['post_type'] ) { 16 if ( !current_user_can( 'edit_pages') )17 return new WP_Error( 'edit_pages', __('You are not allowed to create pages on this blog.'));18 } else { 19 if ( !current_user_can( 'edit_posts') )20 return new WP_Error( 'edit_posts', __('You are not allowed to create posts or drafts on this blog.'));16 if ( !current_user_can( 'edit_pages' ) ) 17 return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this blog.' ) ); 18 } else { 19 if ( !current_user_can( 'edit_posts' ) ) 20 return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) ); 21 21 } 22 22 … … 27 27 $_POST['to_ping'] = $_POST['trackback_url']; 28 28 29 if (!empty ( $_POST['post_author_override'])) {29 if (!empty ( $_POST['post_author_override'] ) ) { 30 30 $_POST['post_author'] = (int) $_POST['post_author_override']; 31 31 } else { 32 if (!empty ( $_POST['post_author'])) {32 if (!empty ( $_POST['post_author'] ) ) { 33 33 $_POST['post_author'] = (int) $_POST['post_author']; 34 34 } else { … … 38 38 } 39 39 40 if ( $_POST['post_author'] != $_POST['user_ID']) {40 if ( $_POST['post_author'] != $_POST['user_ID'] ) { 41 41 if ( 'page' == $_POST['post_type'] ) { 42 if ( !current_user_can( 'edit_others_pages') )43 return new WP_Error( 'edit_others_pages', __('You cannot create pages as this user.'));42 if ( !current_user_can( 'edit_others_pages' ) ) 43 return new WP_Error( 'edit_others_pages', __( 'You cannot create pages as this user.' ) ); 44 44 } else { 45 if ( !current_user_can( 'edit_others_posts') )46 return new WP_Error( 'edit_others_posts', __('You cannot post as this user.'));45 if ( !current_user_can( 'edit_others_posts' ) ) 46 return new WP_Error( 'edit_others_posts', __( 'You cannot post as this user.' ) ); 47 47 48 48 } … … 50 50 51 51 // What to do based on which button they pressed 52 if ('' != $_POST['saveasdraft'] )52 if ('' != $_POST['saveasdraft'] ) 53 53 $_POST['post_status'] = 'draft'; 54 if ('' != $_POST['saveasprivate'] )54 if ('' != $_POST['saveasprivate'] ) 55 55 $_POST['post_status'] = 'private'; 56 if ('' != $_POST['publish'] )56 if ('' != $_POST['publish'] ) 57 57 $_POST['post_status'] = 'publish'; 58 if ('' != $_POST['advanced'] )58 if ('' != $_POST['advanced'] ) 59 59 $_POST['post_status'] = 'draft'; 60 60 61 61 if ( 'page' == $_POST['post_type'] ) { 62 if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages'))62 if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) ) 63 63 $_POST['post_status'] = 'draft'; 64 64 } else { 65 if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts'))65 if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) ) 66 66 $_POST['post_status'] = 'draft'; 67 67 } 68 68 69 if (!isset ($_POST['comment_status']))69 if (!isset( $_POST['comment_status'] )) 70 70 $_POST['comment_status'] = 'closed'; 71 71 72 if (!isset ($_POST['ping_status']))72 if (!isset( $_POST['ping_status'] )) 73 73 $_POST['ping_status'] = 'closed'; 74 74 75 if (!empty ( $_POST['edit_date'])) {75 if (!empty ( $_POST['edit_date'] ) ) { 76 76 $aa = $_POST['aa']; 77 77 $mm = $_POST['mm']; … … 80 80 $mn = $_POST['mn']; 81 81 $ss = $_POST['ss']; 82 $jj = ($jj > 31 ) ? 31 : $jj;83 $hh = ($hh > 23 ) ? $hh -24 : $hh;84 $mn = ($mn > 59 ) ? $mn -60 : $mn;85 $ss = ($ss > 59 ) ? $ss -60 : $ss;86 $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss);87 $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date']);82 $jj = ($jj > 31 ) ? 31 : $jj; 83 $hh = ($hh > 23 ) ? $hh -24 : $hh; 84 $mn = ($mn > 59 ) ? $mn -60 : $mn; 85 $ss = ($ss > 59 ) ? $ss -60 : $ss; 86 $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); 87 $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date'] ); 88 88 } 89 89 90 90 // Create the post. 91 $post_ID = wp_insert_post( $_POST);92 add_meta( $post_ID);91 $post_ID = wp_insert_post( $_POST); 92 add_meta( $post_ID ); 93 93 94 94 // Reunite any orphaned attachments with their parent 95 95 if ( $_POST['temp_ID'] ) 96 relocate_children( $_POST['temp_ID'], $post_ID);96 relocate_children( $_POST['temp_ID'], $post_ID ); 97 97 98 98 // Now that we have an ID we can fix any attachment anchor hrefs 99 fix_attachment_links( $post_ID);99 fix_attachment_links( $post_ID ); 100 100 101 101 return $post_ID; … … 103 103 104 104 // Move child posts to a new parent 105 function relocate_children( $old_ID, $new_ID) {105 function relocate_children( $old_ID, $new_ID ) { 106 106 global $wpdb; 107 107 $old_ID = (int) $old_ID; 108 108 $new_ID = (int) $new_ID; 109 return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");109 return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" ); 110 110 } 111 111 112 112 // Replace hrefs of attachment anchors with up-to-date permalinks. 113 function fix_attachment_links( $post_ID) {113 function fix_attachment_links( $post_ID ) { 114 114 global $wp_rewrite; 115 115 116 $post = & get_post( $post_ID, ARRAY_A);117 118 $search = "#<a[^>]+rel=('|\" )[^'\"]*attachment[^>]*>#ie";116 $post = & get_post( $post_ID, ARRAY_A ); 117 118 $search = "#<a[^>]+rel=('|\" )[^'\"]*attachment[^>]*>#ie"; 119 119 120 120 // See if we have any rel="attachment" links 121 if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER) )121 if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) ) 122 122 return; 123 123 124 124 $i = 0; 125 $search = "#[\s]+rel=(\"|' )(.*?)wp-att-(\d+)\\1#i";125 $search = "#[\s]+rel=(\"|' )(.*? )wp-att-(\d+ )\\1#i"; 126 126 foreach ( $anchor_matches[0] as $anchor ) { 127 if ( 0 == preg_match( $search, $anchor, $id_matches) )127 if ( 0 == preg_match( $search, $anchor, $id_matches ) ) 128 128 continue; 129 129 … … 131 131 132 132 // While we have the attachment ID, let's adopt any orphans. 133 $attachment = & get_post( $id, ARRAY_A);134 if ( ! empty( $attachment) && ! is_object(get_post($attachment['post_parent'])) ) {133 $attachment = & get_post( $id, ARRAY_A ); 134 if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) { 135 135 $attachment['post_parent'] = $post_ID; 136 136 // Escape data pulled from DB. 137 $attachment = add_magic_quotes( $attachment);138 wp_update_post( $attachment);137 $attachment = add_magic_quotes( $attachment); 138 wp_update_post( $attachment); 139 139 } 140 140 141 141 $post_search[$i] = $anchor; 142 $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor);142 $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor ); 143 143 ++$i; 144 144 } 145 145 146 $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content']);146 $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] ); 147 147 148 148 // Escape data pulled from DB. 149 $post = add_magic_quotes( $post);150 151 return wp_update_post( $post);149 $post = add_magic_quotes( $post); 150 151 return wp_update_post( $post); 152 152 } 153 153 … … 159 159 160 160 if ( 'page' == $_POST['post_type'] ) { 161 if ( !current_user_can( 'edit_page', $post_ID) )162 wp_die( __('You are not allowed to edit this page.'));163 } else { 164 if ( !current_user_can( 'edit_post', $post_ID) )165 wp_die( __('You are not allowed to edit this post.'));161 if ( !current_user_can( 'edit_page', $post_ID ) ) 162 wp_die( __('You are not allowed to edit this page.' )); 163 } else { 164 if ( !current_user_can( 'edit_post', $post_ID ) ) 165 wp_die( __('You are not allowed to edit this post.' )); 166 166 } 167 167 … … 173 173 $_POST['to_ping'] = $_POST['trackback_url']; 174 174 175 if (!empty ( $_POST['post_author_override'])) {175 if (!empty ( $_POST['post_author_override'] ) ) { 176 176 $_POST['post_author'] = (int) $_POST['post_author_override']; 177 177 } else 178 if (!empty ( $_POST['post_author'])) {178 if (!empty ( $_POST['post_author'] ) ) { 179 179 $_POST['post_author'] = (int) $_POST['post_author']; 180 180 } else { … … 182 182 } 183 183 184 if ( $_POST['post_author'] != $_POST['user_ID']) {184 if ( $_POST['post_author'] != $_POST['user_ID'] ) { 185 185 if ( 'page' == $_POST['post_type'] ) { 186 if ( !current_user_can( 'edit_others_pages') )187 wp_die( __('You cannot edit pages as this user.'));186 if ( !current_user_can( 'edit_others_pages' ) ) 187 wp_die( __('You cannot edit pages as this user.' )); 188 188 } else { 189 if ( !current_user_can( 'edit_others_posts') )190 wp_die( __('You cannot edit posts as this user.'));189 if ( !current_user_can( 'edit_others_posts' ) ) 190 wp_die( __('You cannot edit posts as this user.' )); 191 191 192 192 } … … 194 194 195 195 // What to do based on which button they pressed 196 if ('' != $_POST['saveasdraft'] )196 if ('' != $_POST['saveasdraft'] ) 197 197 $_POST['post_status'] = 'draft'; 198 if ('' != $_POST['saveasprivate'] )198 if ('' != $_POST['saveasprivate'] ) 199 199 $_POST['post_status'] = 'private'; 200 if ('' != $_POST['publish'] )200 if ('' != $_POST['publish'] ) 201 201 $_POST['post_status'] = 'publish'; 202 if ('' != $_POST['advanced'] )202 if ('' != $_POST['advanced'] ) 203 203 $_POST['post_status'] = 'draft'; 204 204 205 205 if ( 'page' == $_POST['post_type'] ) { 206 if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages'))206 if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' )) 207 207 $_POST['post_status'] = 'draft'; 208 208 } else { 209 if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts'))209 if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' )) 210 210 $_POST['post_status'] = 'draft'; 211 211 } 212 212 213 if (!isset ($_POST['comment_status']))213 if (!isset( $_POST['comment_status'] )) 214 214 $_POST['comment_status'] = 'closed'; 215 215 216 if (!isset ($_POST['ping_status']))216 if (!isset( $_POST['ping_status'] )) 217 217 $_POST['ping_status'] = 'closed'; 218 218 219 if (!empty ( $_POST['edit_date'])) {219 if (!empty ( $_POST['edit_date'] ) ) { 220 220 $aa = $_POST['aa']; 221 221 $mm = $_POST['mm']; … … 224 224 $mn = $_POST['mn']; 225 225 $ss = $_POST['ss']; 226 $jj = ($jj > 31 ) ? 31 : $jj;227 $hh = ($hh > 23 ) ? $hh -24 : $hh;228 $mn = ($mn > 59 ) ? $mn -60 : $mn;229 $ss = ($ss > 59 ) ? $ss -60 : $ss;226 $jj = ($jj > 31 ) ? 31 : $jj; 227 $hh = ($hh > 23 ) ? $hh -24 : $hh; 228 $mn = ($mn > 59 ) ? $mn -60 : $mn; 229 $ss = ($ss > 59 ) ? $ss -60 : $ss; 230 230 $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 231 $_POST['post_date_gmt'] = get_gmt_from_date( "$aa-$mm-$jj $hh:$mn:$ss");231 $_POST['post_date_gmt'] = get_gmt_from_date( "$aa-$mm-$jj $hh:$mn:$ss" ); 232 232 } 233 233 234 234 // Meta Stuff 235 if ( $_POST['meta']) {236 foreach ( $_POST['meta'] as $key => $value)237 update_meta( $key, $value['key'], $value['value']);238 } 239 240 if ( $_POST['deletemeta']) {241 foreach ( $_POST['deletemeta'] as $key => $value)242 delete_meta( $key);243 } 244 245 add_meta( $post_ID);246 247 wp_update_post( $_POST);235 if ( $_POST['meta'] ) { 236 foreach ( $_POST['meta'] as $key => $value ) 237 update_meta( $key, $value['key'], $value['value'] ); 238 } 239 240 if ( $_POST['deletemeta'] ) { 241 foreach ( $_POST['deletemeta'] as $key => $value ) 242 delete_meta( $key ); 243 } 244 245 add_meta( $post_ID ); 246 247 wp_update_post( $_POST); 248 248 249 249 // Now that we have an ID we can fix any attachment anchor hrefs 250 fix_attachment_links( $post_ID);250 fix_attachment_links( $post_ID ); 251 251 252 252 return $post_ID; … … 259 259 $comment_post_ID = (int) $_POST['comment_post_ID']; 260 260 261 if (!current_user_can( 'edit_post', $comment_post_ID))262 wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.'));261 if (!current_user_can( 'edit_post', $comment_post_ID )) 262 wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' )); 263 263 264 264 $_POST['comment_author'] = $_POST['newcomment_author']; … … 269 269 $_POST['comment_ID'] = (int) $_POST['comment_ID']; 270 270 271 if (!empty ( $_POST['edit_date'])) {271 if (!empty ( $_POST['edit_date'] ) ) { 272 272 $aa = $_POST['aa']; 273 273 $mm = $_POST['mm']; … … 276 276 $mn = $_POST['mn']; 277 277 $ss = $_POST['ss']; 278 $jj = ($jj > 31 ) ? 31 : $jj;279 $hh = ($hh > 23 ) ? $hh -24 : $hh;280 $mn = ($mn > 59 ) ? $mn -60 : $mn;281 $ss = ($ss > 59 ) ? $ss -60 : $ss;278 $jj = ($jj > 31 ) ? 31 : $jj; 279 $hh = ($hh > 23 ) ? $hh -24 : $hh; 280 $mn = ($mn > 59 ) ? $mn -60 : $mn; 281 $ss = ($ss > 59 ) ? $ss -60 : $ss; 282 282 $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 283 283 } 284 284 285 wp_update_comment( $_POST);285 wp_update_comment( $_POST); 286 286 } 287 287 288 288 // Get an existing post and format it for editing. 289 function get_post_to_edit( $id) {290 291 $post = get_post( $id);292 293 $post->post_content = format_to_edit( $post->post_content, user_can_richedit());294 $post->post_content = apply_filters( 'content_edit_pre', $post->post_content);295 296 $post->post_excerpt = format_to_edit( $post->post_excerpt);297 $post->post_excerpt = apply_filters( 'excerpt_edit_pre', $post->post_excerpt);298 299 $post->post_title = format_to_edit( $post->post_title);300 $post->post_title = apply_filters( 'title_edit_pre', $post->post_title);301 302 $post->post_password = format_to_edit( $post->post_password);303 304 if ( $post->post_type == 'page')305 $post->page_template = get_post_meta( $id, '_wp_page_template', true);289 function get_post_to_edit( $id ) { 290 291 $post = get_post( $id ); 292 293 $post->post_content = format_to_edit( $post->post_content, user_can_richedit() ); 294 $post->post_content = apply_filters( 'content_edit_pre', $post->post_content); 295 296 $post->post_excerpt = format_to_edit( $post->post_excerpt); 297 $post->post_excerpt = apply_filters( 'excerpt_edit_pre', $post->post_excerpt); 298 299 $post->post_title = format_to_edit( $post->post_title ); 300 $post->post_title = apply_filters( 'title_edit_pre', $post->post_title ); 301 302 $post->post_password = format_to_edit( $post->post_password ); 303 304 if ( $post->post_type == 'page' ) 305 $post->page_template = get_post_meta( $id, '_wp_page_template', true ); 306 306 307 307 return $post; … … 310 310 // Default post information to use when populating the "Write Post" form. 311 311 function get_default_post_to_edit() { 312 if ( !empty( $_REQUEST['post_title']) )313 $post_title = wp_specialchars( stripslashes($_REQUEST['post_title']));314 else if ( !empty( $_REQUEST['popuptitle']) ) {315 $post_title = wp_specialchars( stripslashes($_REQUEST['popuptitle']));316 $post_title = funky_javascript_fix( $post_title);312 if ( !empty( $_REQUEST['post_title'] ) ) 313 $post_title = wp_specialchars( stripslashes( $_REQUEST['post_title'] )); 314 else if ( !empty( $_REQUEST['popuptitle'] ) ) { 315 $post_title = wp_specialchars( stripslashes( $_REQUEST
