Changeset 11819
- Timestamp:
- 01/25/2018 08:15:02 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-attachments.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-attachments.php
r11779 r11819 448 448 $type_dir = trailingslashit( $bp_attachments_uploads_dir['basedir'] ) . $type_subdir; 449 449 450 if ( ! is_dir( $type_dir ) ) {450 if ( 0 !== validate_file( $type_dir ) || ! is_dir( $type_dir ) ) { 451 451 return $attachment_data; 452 452 } … … 1304 1304 $cover_dir = trailingslashit( $bp_attachments_uploads_dir['basedir'] ) . $cover_subdir; 1305 1305 1306 if ( ! is_dir( $cover_dir ) ) {1306 if ( 0 !== validate_file( $cover_dir ) || ! is_dir( $cover_dir ) ) { 1307 1307 // Upload error response. 1308 1308 bp_attachments_json_response( false, $is_html4, array( … … 1383 1383 } 1384 1384 1385 $cover_image_data = $_POST; 1386 1387 if ( empty( $cover_image_data['object'] ) || empty( $cover_image_data['item_id'] ) ) { 1385 if ( empty( $_POST['object'] ) || empty( $_POST['item_id'] ) ) { 1388 1386 wp_send_json_error(); 1389 1387 } 1390 1388 1391 // Check the nonce. 1389 $args = array( 1390 'object' => sanitize_text_field( $_POST['object'] ), 1391 'item_id' => (int) $_POST['item_id'], 1392 ); 1393 1394 // Check permissions. 1392 1395 check_admin_referer( 'bp_delete_cover_image', 'nonce' ); 1393 1394 // Capability check. 1395 if ( ! bp_attachments_current_user_can( 'edit_cover_image', $cover_image_data ) ) { 1396 if ( ! bp_attachments_current_user_can( 'edit_cover_image', $args ) ) { 1396 1397 wp_send_json_error(); 1397 1398 } 1398 1399 1399 1400 // Set object for the user's case. 1400 if ( 'user' === $ cover_image_data['object'] ) {1401 if ( 'user' === $args['object'] ) { 1401 1402 $component = 'xprofile'; 1402 1403 $dir = 'members'; … … 1404 1405 // Set it for any other cases. 1405 1406 } else { 1406 $component = $ cover_image_data['object'] . 's';1407 $component = $args['object'] . 's'; 1407 1408 $dir = $component; 1408 1409 } 1409 1410 1410 1411 // Handle delete. 1411 if ( bp_attachments_delete_file( array( 'item_id' => $ cover_image_data['item_id'], 'object_dir' => $dir, 'type' => 'cover-image' ) ) ) {1412 if ( bp_attachments_delete_file( array( 'item_id' => $args['item_id'], 'object_dir' => $dir, 'type' => 'cover-image' ) ) ) { 1412 1413 /** 1413 1414 * Fires if the cover image was successfully deleted. … … 1422 1423 * @param int $item_id Inform about the item id the cover image was deleted for. 1423 1424 */ 1424 do_action( "{$component}_cover_image_deleted", (int) $ cover_image_data['item_id'] );1425 do_action( "{$component}_cover_image_deleted", (int) $args['item_id'] ); 1425 1426 1426 1427 $response = array(
Note: See TracChangeset
for help on using the changeset viewer.