Changeset 33325 for trunk/src/wp-includes/class-wp-xmlrpc-server.php
- Timestamp:
- 07/19/2015 06:08:55 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-xmlrpc-server.php
r33054 r33325 1194 1194 1195 1195 /** 1196 * @since 4.3.0 1197 * 1198 * @param array $post_data 1199 * @param bool $update 1200 * @return void|IXR_Error 1201 */ 1202 private function _toggle_sticky( $post_data, $update = false ) { 1203 $post_type = get_post_type_object( $post_data['post_type'] ); 1204 1205 // Private and password-protected posts cannot be stickied. 1206 if ( 'private' === $post_data['post_status'] || ! empty( $post_data['post_password'] ) ) { 1207 // Error if the client tried to stick the post, otherwise, silently unstick. 1208 if ( ! empty( $post_data['sticky'] ) ) { 1209 return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) ); 1210 } 1211 1212 if ( $update ) { 1213 unstick_post( $post_data['ID'] ); 1214 } 1215 } elseif ( isset( $post_data['sticky'] ) ) { 1216 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) { 1217 return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) ); 1218 } 1219 1220 $sticky = wp_validate_boolean( $post_data['sticky'] ); 1221 if ( $sticky ) { 1222 stick_post( $post_data['ID'] ); 1223 } else { 1224 unstick_post( $post_data['ID'] ); 1225 } 1226 } 1227 } 1228 1229 /** 1196 1230 * Helper method for wp_newPost() and wp_editPost(), containing shared logic. 1197 1231 * … … 1288 1322 1289 1323 if ( $post_data['post_type'] == 'post' ) { 1290 // Private and password-protected posts cannot be stickied. 1291 if ( $post_data['post_status'] == 'private' || ! empty( $post_data['post_password'] ) ) { 1292 // Error if the client tried to stick the post, otherwise, silently unstick. 1293 if ( ! empty( $post_data['sticky'] ) ) 1294 return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) ); 1295 if ( $update ) 1296 unstick_post( $post_ID ); 1297 } elseif ( isset( $post_data['sticky'] ) ) { 1298 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) 1299 return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) ); 1300 if ( $post_data['sticky'] ) 1301 stick_post( $post_ID ); 1302 else 1303 unstick_post( $post_ID ); 1324 $error = $this->_toggle_sticky( $post_data, $update ); 1325 if ( $error ) { 1326 return $error; 1304 1327 } 1305 1328 } … … 4903 4926 // Only posts can be sticky 4904 4927 if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { 4905 if ( $content_struct['sticky'] == true ) 4906 stick_post( $post_ID ); 4907 elseif ( $content_struct['sticky'] == false ) 4908 unstick_post( $post_ID ); 4928 $data = $postdata; 4929 $data['sticky'] = $content_struct['sticky']; 4930 $error = $this->_toggle_sticky( $data ); 4931 if ( $error ) { 4932 return $error; 4933 } 4909 4934 } 4910 4935 … … 5251 5276 // Only posts can be sticky 5252 5277 if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { 5253 if ( $content_struct['sticky'] == true ) 5254 stick_post( $post_ID ); 5255 elseif ( $content_struct['sticky'] == false ) 5256 unstick_post( $post_ID ); 5278 $data = $newpost; 5279 $data['sticky'] = $content_struct['sticky']; 5280 $error = $this->_toggle_sticky( $data, true ); 5281 if ( $error ) { 5282 return $error; 5283 } 5257 5284 } 5258 5285
Note: See TracChangeset
for help on using the changeset viewer.