Ticket #27020: 27020.1.diff
| File 27020.1.diff, 3.7 KB (added by , 12 years ago) |
|---|
-
wp-includes/capabilities.php
1071 1071 break; 1072 1072 } 1073 1073 1074 $post_author_id = $post->post_author; 1075 1076 // If no author set yet, default to current user for cap checks. 1077 if ( ! $post_author_id ) 1078 $post_author_id = $user_id; 1079 1080 // If the user is the author... 1081 if ( $user_id == $post_author_id ) { 1074 // If the post author is set and the user is the author... 1075 if ( $post->post_author && $user_id == $post->post_author ) { 1082 1076 // If the post is published... 1083 1077 if ( 'publish' == $post->post_status ) { 1084 1078 $caps[] = $post_type->cap->delete_published_posts; 1085 1079 } elseif ( 'trash' == $post->post_status ) { 1086 if ( 'publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true) )1080 if ( 'publish' == get_post_meta( $post->ID, '_wp_trash_meta_status', true ) ) { 1087 1081 $caps[] = $post_type->cap->delete_published_posts; 1082 } 1088 1083 } else { 1089 1084 // If the post is draft... 1090 1085 $caps[] = $post_type->cap->delete_posts; … … 1093 1088 // The user is trying to edit someone else's post. 1094 1089 $caps[] = $post_type->cap->delete_others_posts; 1095 1090 // The post is published, extra cap required. 1096 if ( 'publish' == $post->post_status ) 1091 if ( 'publish' == $post->post_status ) { 1097 1092 $caps[] = $post_type->cap->delete_published_posts; 1098 elseif ( 'private' == $post->post_status )1093 } else if ( 'private' == $post->post_status ) { 1099 1094 $caps[] = $post_type->cap->delete_private_posts; 1095 } 1100 1096 } 1101 1097 break; 1102 1098 // edit_post breaks down to edit_posts, edit_published_posts, or … … 1121 1117 break; 1122 1118 } 1123 1119 1124 $post_author_id = $post->post_author; 1125 1126 // If no author set yet, default to current user for cap checks. 1127 if ( ! $post_author_id ) 1128 $post_author_id = $user_id; 1129 1130 // If the user is the author... 1131 if ( $user_id == $post_author_id ) { 1120 // If the post author is set and the user is the author... 1121 if ( $post->post_author && $user_id == $post->post_author ) { 1132 1122 // If the post is published... 1133 1123 if ( 'publish' == $post->post_status ) { 1134 1124 $caps[] = $post_type->cap->edit_published_posts; 1135 1125 } elseif ( 'trash' == $post->post_status ) { 1136 if ( 'publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true) )1126 if ( 'publish' == get_post_meta( $post->ID, '_wp_trash_meta_status', true ) ) { 1137 1127 $caps[] = $post_type->cap->edit_published_posts; 1128 } 1138 1129 } else { 1139 1130 // If the post is draft... 1140 1131 $caps[] = $post_type->cap->edit_posts; … … 1143 1134 // The user is trying to edit someone else's post. 1144 1135 $caps[] = $post_type->cap->edit_others_posts; 1145 1136 // The post is published, extra cap required. 1146 if ( 'publish' == $post->post_status ) 1137 if ( 'publish' == $post->post_status ) { 1147 1138 $caps[] = $post_type->cap->edit_published_posts; 1148 elseif ( 'private' == $post->post_status )1139 } else if ( 'private' == $post->post_status ) { 1149 1140 $caps[] = $post_type->cap->edit_private_posts; 1141 } 1150 1142 } 1151 1143 break; 1152 1144 case 'read_post': … … 1173 1165 break; 1174 1166 } 1175 1167 1176 $post_author_id = $post->post_author; 1177 1178 // If no author set yet, default to current user for cap checks. 1179 if ( ! $post_author_id ) 1180 $post_author_id = $user_id; 1181 1182 if ( $user_id == $post_author_id ) 1168 if ( $post->post_author && $user_id == $post->post_author ) { 1183 1169 $caps[] = $post_type->cap->read; 1184 elseif ( $status_obj->private )1170 } else if ( $status_obj->private ) { 1185 1171 $caps[] = $post_type->cap->read_private_posts; 1186 else1172 } else { 1187 1173 $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); 1174 } 1188 1175 break; 1189 1176 case 'publish_post': 1190 1177 $post = get_post( $args[0] );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)