Changeset 34155
- Timestamp:
- 09/14/2015 11:01:04 PM (9 years ago)
- Location:
- branches/3.9/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.9/src/wp-admin/includes/ajax-actions.php
r28164 r34155 1324 1324 $data['parent_id'] = $data['post_parent']; 1325 1325 1326 // status 1327 if ( isset($data['keep_private']) && 'private' == $data['keep_private'] ) 1326 // Status. 1327 if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) { 1328 $data['visibility'] = 'private'; 1328 1329 $data['post_status'] = 'private'; 1329 else1330 } else { 1330 1331 $data['post_status'] = $data['_status']; 1332 } 1331 1333 1332 1334 if ( empty($data['comment_status']) ) -
branches/3.9/src/wp-includes/class-wp-xmlrpc-server.php
r28083 r34155 1109 1109 } 1110 1110 1111 private function _validate_boolean( $var ) { 1112 if ( is_bool( $var ) ) { 1113 return $var; 1114 } 1115 1116 if ( is_string( $var ) && 'false' === strtolower( $var ) ) { 1117 return false; 1118 } 1119 1120 return (bool) $var; 1121 } 1122 1123 /** 1124 * Encapsulate the logic for sticking a post 1125 * and determining if the user has permission to do so 1126 * 1127 * @since 4.3.0 1128 * @access private 1129 * 1130 * @param array $post_data 1131 * @param bool $update 1132 * @return void|IXR_Error 1133 */ 1134 private function _toggle_sticky( $post_data, $update = false ) { 1135 $post_type = get_post_type_object( $post_data['post_type'] ); 1136 1137 // Private and password-protected posts cannot be stickied. 1138 if ( 'private' === $post_data['post_status'] || ! empty( $post_data['post_password'] ) ) { 1139 // Error if the client tried to stick the post, otherwise, silently unstick. 1140 if ( ! empty( $post_data['sticky'] ) ) { 1141 return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) ); 1142 } 1143 1144 if ( $update ) { 1145 unstick_post( $post_data['ID'] ); 1146 } 1147 } elseif ( isset( $post_data['sticky'] ) ) { 1148 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) { 1149 return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) ); 1150 } 1151 1152 $sticky = $this->_validate_boolean( $post_data['sticky'] ); 1153 if ( $sticky ) { 1154 stick_post( $post_data['ID'] ); 1155 } else { 1156 unstick_post( $post_data['ID'] ); 1157 } 1158 } 1159 } 1160 1111 1161 /** 1112 1162 * Helper method for wp_newPost and wp_editPost, containing shared logic. … … 1201 1251 1202 1252 if ( $post_data['post_type'] == 'post' ) { 1203 // Private and password-protected posts cannot be stickied. 1204 if ( $post_data['post_status'] == 'private' || ! empty( $post_data['post_password'] ) ) { 1205 // Error if the client tried to stick the post, otherwise, silently unstick. 1206 if ( ! empty( $post_data['sticky'] ) ) 1207 return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) ); 1208 if ( $update ) 1209 unstick_post( $post_ID ); 1210 } elseif ( isset( $post_data['sticky'] ) ) { 1211 if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) 1212 return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) ); 1213 if ( $post_data['sticky'] ) 1214 stick_post( $post_ID ); 1215 else 1216 unstick_post( $post_ID ); 1253 $error = $this->_toggle_sticky( $post_data, $update ); 1254 if ( $error ) { 1255 return $error; 1217 1256 } 1218 1257 } … … 4587 4626 // Only posts can be sticky 4588 4627 if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { 4589 if ( $content_struct['sticky'] == true ) 4590 stick_post( $post_ID ); 4591 elseif ( $content_struct['sticky'] == false ) 4592 unstick_post( $post_ID ); 4628 $data = $postdata; 4629 $data['sticky'] = $content_struct['sticky']; 4630 $error = $this->_toggle_sticky( $data ); 4631 if ( $error ) { 4632 return $error; 4633 } 4593 4634 } 4594 4635 … … 4863 4904 $tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : null; 4864 4905 4865 if ( ('publish' == $post_status) ) { 4866 if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') ) 4867 return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.')); 4868 else if ( !current_user_can('publish_posts') ) 4869 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); 4906 if ( 'publish' == $post_status || 'private' == $post_status ) { 4907 if ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) { 4908 return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this page.' ) ); 4909 } elseif ( ! current_user_can( 'publish_posts' ) ) { 4910 return new IXR_Error( 401, __( 'Sorry, you do not have the right to publish this post.' ) ); 4911 } 4870 4912 } 4871 4913 … … 4907 4949 // Only posts can be sticky 4908 4950 if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { 4909 if ( $content_struct['sticky'] == true ) 4910 stick_post( $post_ID ); 4911 elseif ( $content_struct['sticky'] == false ) 4912 unstick_post( $post_ID ); 4951 $data = $newpost; 4952 $data['sticky'] = $content_struct['sticky']; 4953 $data['post_type'] = 'post'; 4954 $error = $this->_toggle_sticky( $data, true ); 4955 if ( $error ) { 4956 return $error; 4957 } 4913 4958 } 4914 4959
Note: See TracChangeset
for help on using the changeset viewer.