Changeset 34154
- Timestamp:
- 09/14/2015 11:00:53 PM (9 years ago)
- Location:
- branches/4.0/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0/src/wp-admin/includes/ajax-actions.php
r29681 r34154 1530 1530 1531 1531 // Status. 1532 if ( isset($data['keep_private']) && 'private' == $data['keep_private'] ) 1532 if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) { 1533 $data['visibility'] = 'private'; 1533 1534 $data['post_status'] = 'private'; 1534 else1535 } else { 1535 1536 $data['post_status'] = $data['_status']; 1537 } 1536 1538 1537 1539 if ( empty($data['comment_status']) ) -
branches/4.0/src/wp-includes/class-wp-xmlrpc-server.php
r29464 r34154 1139 1139 } 1140 1140 1141 private function _validate_boolean( $var ) { 1142 if ( is_bool( $var ) ) { 1143 return $var; 1144 } 1145 1146 if ( is_string( $var ) && 'false' === strtolower( $var ) ) { 1147 return false; 1148 } 1149 1150 return (bool) $var; 1151 } 1152 1153 /** 1154 * Encapsulate the logic for sticking a post 1155 * and determining if the user has permission to do so 1156 * 1157 * @since 4.3.0 1158 * @access private 1159 * 1160 * @param array $post_data 1161 * @param bool $update 1162 * @return void|IXR_Error 1163 */ 1164 private function _toggle_sticky( $post_data, $update = false ) { 1165 $post_type = get_post_type_object( $post_data['post_type'] ); 1166 1167 // Private and password-protected posts cannot be stickied. 1168 if ( 'private' === $post_data['post_status'] || ! empty( $post_data['post_password'] ) ) { 1169 // Error if the client tried to stick the post, otherwise, silently unstick. 1170 if ( ! empty( $post_data['sticky'] ) ) { 1171 return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) ); 1172 } 1173 1174 if ( $update ) { 1175 unstick_post( $post_data['ID'] ); 1176 } 1177 } elseif ( isset( $post_data['sticky'] ) ) { 1178 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) { 1179 return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) ); 1180 } 1181 1182 $sticky = $this->_validate_boolean( $post_data['sticky'] ); 1183 if ( $sticky ) { 1184 stick_post( $post_data['ID'] ); 1185 } else { 1186 unstick_post( $post_data['ID'] ); 1187 } 1188 } 1189 } 1190 1141 1191 /** 1142 1192 * Helper method for wp_newPost and wp_editPost, containing shared logic. … … 1231 1281 1232 1282 if ( $post_data['post_type'] == 'post' ) { 1233 // Private and password-protected posts cannot be stickied. 1234 if ( $post_data['post_status'] == 'private' || ! empty( $post_data['post_password'] ) ) { 1235 // Error if the client tried to stick the post, otherwise, silently unstick. 1236 if ( ! empty( $post_data['sticky'] ) ) 1237 return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) ); 1238 if ( $update ) 1239 unstick_post( $post_ID ); 1240 } elseif ( isset( $post_data['sticky'] ) ) { 1241 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) 1242 return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) ); 1243 if ( $post_data['sticky'] ) 1244 stick_post( $post_ID ); 1245 else 1246 unstick_post( $post_ID ); 1283 $error = $this->_toggle_sticky( $post_data, $update ); 1284 if ( $error ) { 1285 return $error; 1247 1286 } 1248 1287 } … … 4618 4657 // Only posts can be sticky 4619 4658 if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { 4620 if ( $content_struct['sticky'] == true ) 4621 stick_post( $post_ID ); 4622 elseif ( $content_struct['sticky'] == false ) 4623 unstick_post( $post_ID ); 4659 $data = $postdata; 4660 $data['sticky'] = $content_struct['sticky']; 4661 $error = $this->_toggle_sticky( $data ); 4662 if ( $error ) { 4663 return $error; 4664 } 4624 4665 } 4625 4666 … … 4903 4944 $tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : null; 4904 4945 4905 if ( ('publish' == $post_status) ) { 4906 if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') ) 4907 return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.')); 4908 else if ( !current_user_can('publish_posts') ) 4909 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); 4946 if ( 'publish' == $post_status || 'private' == $post_status ) { 4947 if ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) { 4948 return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this page.' ) ); 4949 } elseif ( ! current_user_can( 'publish_posts' ) ) { 4950 return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this post.' ) ); 4951 } 4910 4952 } 4911 4953 … … 4947 4989 // Only posts can be sticky 4948 4990 if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { 4949 if ( $content_struct['sticky'] == true ) 4950 stick_post( $post_ID ); 4951 elseif ( $content_struct['sticky'] == false ) 4952 unstick_post( $post_ID ); 4991 $data = $newpost; 4992 $data['sticky'] = $content_struct['sticky']; 4993 $data['post_type'] = 'post'; 4994 $error = $this->_toggle_sticky( $data, true ); 4995 if ( $error ) { 4996 return $error; 4997 } 4953 4998 } 4954 4999
Note: See TracChangeset
for help on using the changeset viewer.