Changeset 34153
- Timestamp:
- 09/14/2015 11:00:40 PM (9 years ago)
- Location:
- branches/4.1/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.1/src/wp-admin/includes/ajax-actions.php
r31430 r34153 1539 1539 1540 1540 // Status. 1541 if ( isset($data['keep_private']) && 'private' == $data['keep_private'] ) 1541 if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) { 1542 $data['visibility'] = 'private'; 1542 1543 $data['post_status'] = 'private'; 1543 else1544 } else { 1544 1545 $data['post_status'] = $data['_status']; 1546 } 1545 1547 1546 1548 if ( empty($data['comment_status']) ) -
branches/4.1/src/wp-includes/class-wp-xmlrpc-server.php
r30681 r34153 1150 1150 } 1151 1151 1152 private function _validate_boolean( $var ) { 1153 if ( is_bool( $var ) ) { 1154 return $var; 1155 } 1156 1157 if ( is_string( $var ) && 'false' === strtolower( $var ) ) { 1158 return false; 1159 } 1160 1161 return (bool) $var; 1162 } 1163 1164 /** 1165 * Encapsulate the logic for sticking a post 1166 * and determining if the user has permission to do so 1167 * 1168 * @since 4.3.0 1169 * @access private 1170 * 1171 * @param array $post_data 1172 * @param bool $update 1173 * @return void|IXR_Error 1174 */ 1175 private function _toggle_sticky( $post_data, $update = false ) { 1176 $post_type = get_post_type_object( $post_data['post_type'] ); 1177 1178 // Private and password-protected posts cannot be stickied. 1179 if ( 'private' === $post_data['post_status'] || ! empty( $post_data['post_password'] ) ) { 1180 // Error if the client tried to stick the post, otherwise, silently unstick. 1181 if ( ! empty( $post_data['sticky'] ) ) { 1182 return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) ); 1183 } 1184 1185 if ( $update ) { 1186 unstick_post( $post_data['ID'] ); 1187 } 1188 } elseif ( isset( $post_data['sticky'] ) ) { 1189 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) { 1190 return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) ); 1191 } 1192 1193 $sticky = $this->_validate_boolean( $post_data['sticky'] ); 1194 if ( $sticky ) { 1195 stick_post( $post_data['ID'] ); 1196 } else { 1197 unstick_post( $post_data['ID'] ); 1198 } 1199 } 1200 } 1201 1152 1202 /** 1153 1203 * Helper method for wp_newPost and wp_editPost, containing shared logic. … … 1242 1292 1243 1293 if ( $post_data['post_type'] == 'post' ) { 1244 // Private and password-protected posts cannot be stickied. 1245 if ( $post_data['post_status'] == 'private' || ! empty( $post_data['post_password'] ) ) { 1246 // Error if the client tried to stick the post, otherwise, silently unstick. 1247 if ( ! empty( $post_data['sticky'] ) ) 1248 return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) ); 1249 if ( $update ) 1250 unstick_post( $post_ID ); 1251 } elseif ( isset( $post_data['sticky'] ) ) { 1252 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) 1253 return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) ); 1254 if ( $post_data['sticky'] ) 1255 stick_post( $post_ID ); 1256 else 1257 unstick_post( $post_ID ); 1294 $error = $this->_toggle_sticky( $post_data, $update ); 1295 if ( $error ) { 1296 return $error; 1258 1297 } 1259 1298 } … … 4584 4623 // Only posts can be sticky 4585 4624 if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { 4586 if ( $content_struct['sticky'] == true ) 4587 stick_post( $post_ID ); 4588 elseif ( $content_struct['sticky'] == false ) 4589 unstick_post( $post_ID ); 4625 $data = $postdata; 4626 $data['sticky'] = $content_struct['sticky']; 4627 $error = $this->_toggle_sticky( $data ); 4628 if ( $error ) { 4629 return $error; 4630 } 4590 4631 } 4591 4632 … … 4873 4914 $tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : null; 4874 4915 4875 if ( ('publish' == $post_status) ) { 4876 if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') ) 4877 return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.')); 4878 else if ( !current_user_can('publish_posts') ) 4879 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); 4916 if ( 'publish' == $post_status || 'private' == $post_status ) { 4917 if ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) { 4918 return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this page.' ) ); 4919 } elseif ( ! current_user_can( 'publish_posts' ) ) { 4920 return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this post.' ) ); 4921 } 4880 4922 } 4881 4923 … … 4917 4959 // Only posts can be sticky 4918 4960 if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { 4919 if ( $content_struct['sticky'] == true ) 4920 stick_post( $post_ID ); 4921 elseif ( $content_struct['sticky'] == false ) 4922 unstick_post( $post_ID ); 4961 $data = $newpost; 4962 $data['sticky'] = $content_struct['sticky']; 4963 $data['post_type'] = 'post'; 4964 $error = $this->_toggle_sticky( $data, true ); 4965 if ( $error ) { 4966 return $error; 4967 } 4923 4968 } 4924 4969
Note: See TracChangeset
for help on using the changeset viewer.