Ticket #11198: 11198.patch
File 11198.patch, 8.7 KB (added by , 15 years ago) |
---|
-
wp-admin/includes/post.php
34 34 if (!empty ( $post_data['post_author_override'] ) ) { 35 35 $post_data['post_author'] = (int) $post_data['post_author_override']; 36 36 } else { 37 if (!empty ( $post_data['post_author'] ) ) {37 if (!empty ( $post_data['post_author'] ) ) 38 38 $post_data['post_author'] = (int) $post_data['post_author']; 39 } else {39 else 40 40 $post_data['post_author'] = (int) $post_data['user_ID']; 41 }42 41 } 43 42 44 43 if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) { 45 44 if ( 'page' == $post_data['post_type'] ) { 46 if ( !current_user_can( 'edit_others_pages' ) ) {45 if ( !current_user_can( 'edit_others_pages' ) ) 47 46 return new WP_Error( 'edit_others_pages', $update ? 48 47 __( 'You are not allowed to edit pages as this user.' ) : 49 48 __( 'You are not allowed to create pages as this user.' ) 50 49 ); 51 }52 50 } else { 53 if ( !current_user_can( 'edit_others_posts' ) ) {51 if ( !current_user_can( 'edit_others_posts' ) ) 54 52 return new WP_Error( 'edit_others_posts', $update ? 55 53 __( 'You are not allowed to edit posts as this user.' ) : 56 54 __( 'You are not allowed to post as this user.' ) 57 55 ); 58 }59 56 } 60 57 } 61 58 … … 82 79 $publish_cap = 'publish_posts'; 83 80 $edit_cap = 'edit_published_posts'; 84 81 } 82 85 83 if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $publish_cap )) ) 86 84 if ( $previous_status != 'publish' || !current_user_can( $edit_cap ) ) 87 85 $post_data['post_status'] = 'pending'; … … 204 202 205 203 if ( current_user_can( 'edit_others_posts' ) ) { 206 204 if ( !empty($post_data['sticky']) ) 207 stick_post( $post_ID);205 stick_post( $post_ID ); 208 206 else 209 unstick_post( $post_ID);207 unstick_post( $post_ID ); 210 208 } 211 209 212 210 return $post_ID; … … 218 216 * Updates all bulk edited posts/pages, adding (but not removing) tags and 219 217 * categories. Skips pages when they would be their own parent or child. 220 218 * 221 * @since unknown219 * @since 2.7.0 222 220 * 221 * @param unknown_type $post_data 222 * 223 223 * @return array 224 224 */ 225 225 function bulk_edit_posts( $post_data = null ) { … … 366 366 /** 367 367 * {@internal Missing Short Description}} 368 368 * 369 * @since unknown369 * @since 2.5.0 370 370 * 371 371 * @return unknown 372 372 */ … … 736 736 if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) { 737 737 $attachment['post_parent'] = $post_ID; 738 738 // Escape data pulled from DB. 739 $attachment = add_magic_quotes( $attachment );740 wp_update_post( $attachment );739 $attachment = add_magic_quotes( $attachment ); 740 wp_update_post( $attachment ); 741 741 } 742 742 743 743 $post_search[$i] = $anchor; … … 749 749 $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] ); 750 750 751 751 // Escape data pulled from DB. 752 $post = add_magic_quotes( $post );752 $post = add_magic_quotes( $post ); 753 753 754 return wp_update_post( $post );754 return wp_update_post( $post ); 755 755 } 756 756 757 757 function _fix_attachment_links_replace_cb($match) { … … 779 779 /** 780 780 * {@internal Missing Short Description}} 781 781 * 782 * @since unknown782 * @since 2.5.0 783 783 * 784 784 * @param unknown_type $type 785 785 * @return unknown … … 793 793 /** 794 794 * {@internal Missing Short Description}} 795 795 * 796 * @since unknown796 * @since 2.5.0 797 797 * 798 798 * @param unknown_type $q 799 * @return unknown799 * @return array 800 800 */ 801 801 function wp_edit_posts_query( $q = false ) { 802 802 if ( false === $q ) … … 881 881 * @since unknown 882 882 * 883 883 * @param unknown_type $q 884 * @return unknown884 * @return array 885 885 */ 886 886 function wp_edit_attachments_query( $q = false ) { 887 887 if ( false === $q ) 888 888 $q = $_GET; 889 889 890 $q['m'] 890 $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0; 891 891 $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; 892 892 $q['post_type'] = 'attachment'; 893 893 $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'inherit'; 894 894 895 $media_per_page = get_user_option('upload_per_page'); 895 896 if ( empty($media_per_page) ) 896 897 $media_per_page = 20; … … 914 915 * 915 916 * @param unknown_type $id 916 917 * @param unknown_type $page 918 * 919 * @uses get_user_option() 920 * 917 921 * @return unknown 918 922 */ 919 923 function postbox_classes( $id, $page ) { … … 922 926 $current_user = wp_get_current_user(); 923 927 if ( $closed = get_user_option('closedpostboxes_'.$page, 0, false ) ) { 924 928 if ( !is_array( $closed ) ) return ''; 925 return in_array( $id, $closed )? 'closed' : '';929 return in_array( $id, $closed )? 'closed' : ''; 926 930 } else { 927 931 return ''; 928 932 } … … 936 940 * @param unknown_type $id 937 941 * @param unknown_type $title 938 942 * @param unknown_type $name 939 * @return unknown943 * @return array 940 944 */ 941 function get_sample_permalink( $id, $title = null, $name = null) {945 function get_sample_permalink( $id, $title = null, $name = null ) { 942 946 $post = &get_post($id); 943 if ( !$post->ID) {947 if ( !$post->ID ) 944 948 return array('', ''); 945 } 949 946 950 $original_status = $post->post_status; 947 951 $original_date = $post->post_date; 948 952 $original_name = $post->post_name; 949 953 950 954 // Hack: get_permalink would return ugly permalink for 951 955 // drafts, so we will fake, that our post is published 952 if ( in_array($post->post_status, array('draft', 'pending'))) {956 if ( in_array( $post->post_status, array('draft', 'pending') ) ) { 953 957 $post->post_status = 'publish'; 954 958 $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID); 955 959 } … … 958 962 959 963 // If the user wants to set a new name -- override the current one 960 964 // Note: if empty name is supplied -- use the title instead, see #6072 961 if ( !is_null($name)) {965 if ( !is_null($name) ) 962 966 $post->post_name = sanitize_title($name? $name : $title, $post->ID); 963 }964 967 965 968 $post->filter = 'sample'; 966 969 … … 972 975 $uri = untrailingslashit($uri); 973 976 $uri = strrev( stristr( strrev( $uri ), '/' ) ); 974 977 $uri = untrailingslashit($uri); 975 if ( !empty( $uri) )978 if ( !empty( $uri ) ) 976 979 $uri .='/'; 977 980 $permalink = str_replace('%pagename%', "${uri}%pagename%", $permalink); 978 981 } … … 994 997 * @param unknown_type $id 995 998 * @param unknown_type $new_title 996 999 * @param unknown_type $new_slug 997 * @return unknown1000 * @return string html 998 1001 */ 999 1002 function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { 1000 1003 $post = &get_post($id); … … 1020 1023 } 1021 1024 1022 1025 if ( function_exists('mb_strlen') ) { 1023 if ( mb_strlen($post_name) > 30 ) {1026 if ( mb_strlen($post_name) > 30 ) 1024 1027 $post_name_abridged = mb_substr($post_name, 0, 14). '…' . mb_substr($post_name, -14); 1025 } else {1028 else 1026 1029 $post_name_abridged = $post_name; 1027 }1028 1030 } else { 1029 if ( strlen($post_name) > 30 ) {1031 if ( strlen($post_name) > 30 ) 1030 1032 $post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14); 1031 } else {1033 else 1032 1034 $post_name_abridged = $post_name; 1033 }1034 1035 } 1035 1036 1036 1037 $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>'; … … 1120 1121 * Outputs the notice message to say that someone else is editing this post at the moment. 1121 1122 * 1122 1123 * @since 2.8.5 1124 * 1123 1125 * @return none 1124 1126 */ 1125 1127 function _admin_notice_post_locked() { … … 1151 1153 * 1152 1154 * @uses _wp_translate_postdata() 1153 1155 * @uses _wp_post_revision_fields() 1156 * 1157 * @return unknown 1154 1158 */ 1155 1159 function wp_create_post_autosave( $post_id ) { 1156 1160 $translated = _wp_translate_postdata( true ); … … 1177 1181 * Save draft or manually autosave for showing preview. 1178 1182 * 1179 1183 * @package WordPress 1180 * @since 2.7 1184 * @since 2.7.0 1181 1185 * 1182 1186 * @uses wp_write_post() 1183 1187 * @uses edit_post() … … 1238 1242 * Adds the TinyMCE editor used on the Write and Edit screens. 1239 1243 * 1240 1244 * @package WordPress 1241 * @since 2.7 1245 * @since 2.7.0 1242 1246 * 1243 1247 * TinyMCE is loaded separately from other Javascript by using wp-tinymce.php. It outputs concatenated 1244 1248 * and optionaly pre-compressed version of the core and all default plugins. Additional plugins are loaded … … 1420 1424 // You can modify initArray to add, remove, change elements of the config before tinyMCE.init 1421 1425 // Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init". 1422 1426 // Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0. 1423 if ( $teeny ) {1427 if ( $teeny ) 1424 1428 $initArray = apply_filters('teeny_mce_before_init', $initArray); 1425 } else {1429 else 1426 1430 $initArray = apply_filters('tiny_mce_before_init', $initArray); 1427 }1428 1431 1429 1432 if ( empty($initArray['theme_advanced_buttons3']) && !empty($initArray['theme_advanced_buttons4']) ) { 1430 1433 $initArray['theme_advanced_buttons3'] = $initArray['theme_advanced_buttons4'];