Changeset 11779
- Timestamp:
- 01/02/2018 10:20:02 AM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-attachments.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-attachments.php
r11447 r11779 1190 1190 */ 1191 1191 function bp_attachments_cover_image_ajax_upload() { 1192 // Bail if not a POST action.1193 1192 if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) { 1194 1193 wp_die(); 1195 1194 } 1196 1195 1197 /**1198 * Sending the json response will be different if1199 * the current Plupload runtime is html41200 */1201 $is_html4 = false;1202 if ( ! empty( $_POST['html4' ] ) ) {1203 $is_html4 = true;1204 }1205 1206 // Check the nonce.1207 1196 check_admin_referer( 'bp-uploader' ); 1208 1197 1209 // Init the BuddyPress parameters. 1210 $bp_params = array(); 1211 1212 // We need it to carry on. 1213 if ( ! empty( $_POST['bp_params'] ) ) { 1214 $bp_params = bp_parse_args( $_POST['bp_params'], array( 1215 'object' => 'user', 1216 'item_id' => bp_loggedin_user_id(), 1217 ), 'attachments_cover_image_ajax_upload' ); 1218 } else { 1198 // Sending the json response will be different if the current Plupload runtime is html4. 1199 $is_html4 = ! empty( $_POST['html4' ] ); 1200 1201 if ( empty( $_POST['bp_params'] ) ) { 1219 1202 bp_attachments_json_response( false, $is_html4 ); 1220 1203 } 1204 1205 $bp_params = bp_parse_args( $_POST['bp_params'], array( 1206 'object' => 'user', 1207 'item_id' => bp_loggedin_user_id(), 1208 ), 'attachments_cover_image_ajax_upload' ); 1209 1210 $bp_params['item_id'] = (int) $bp_params['item_id']; 1211 $bp_params['object'] = sanitize_text_field( $bp_params['object'] ); 1221 1212 1222 1213 // We need the object to set the uploads dir filter. … … 1298 1289 } 1299 1290 1300 // Default error message.1301 1291 $error_message = __( 'There was a problem uploading the cover image.', 'buddypress' ); 1302 1292 1303 // Get BuddyPress Attachments Uploads Dir datas.1304 1293 $bp_attachments_uploads_dir = bp_attachments_uploads_dir_get(); 1305 1294 … … 1323 1312 } 1324 1313 1325 /* *1314 /* 1326 1315 * Generate the cover image so that it fit to feature's dimensions 1327 1316 * 1328 * Unlike the Avatar, Uploading and generating the cover image is happening during1317 * Unlike the avatar, uploading and generating the cover image is happening during 1329 1318 * the same Ajax request, as we already instantiated the BP_Attachment_Cover_Image 1330 1319 * class, let's use it. … … 1337 1326 1338 1327 if ( ! $cover ) { 1339 // Upload error response.1340 1328 bp_attachments_json_response( false, $is_html4, array( 1341 1329 'type' => 'upload_error', … … 1344 1332 } 1345 1333 1346 // Build the url to the file.1347 1334 $cover_url = trailingslashit( $bp_attachments_uploads_dir['baseurl'] ) . $cover_subdir . '/' . $cover['cover_basename']; 1348 1335 1349 // Init Feedback code,1 is success.1336 // 1 is success. 1350 1337 $feedback_code = 1; 1351 1338 … … 1392 1379 */ 1393 1380 function bp_attachments_cover_image_ajax_delete() { 1394 // Bail if not a POST action.1395 1381 if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) { 1396 1382 wp_send_json_error(); … … 1438 1424 do_action( "{$component}_cover_image_deleted", (int) $cover_image_data['item_id'] ); 1439 1425 1440 // Defaults no cover image.1441 1426 $response = array( 1442 1427 'reset_url' => '', 1443 'feedback_code' => 3 ,1428 'feedback_code' => 3, 1444 1429 ); 1445 1430 … … 1452 1437 } 1453 1438 1454 // Finally send the reset url.1455 1439 wp_send_json_success( $response ); 1456 1440
Note: See TracChangeset
for help on using the changeset viewer.