Skip to:
Content

BuddyPress.org

Changeset 11779


Ignore:
Timestamp:
01/02/2018 10:20:02 AM (8 years ago)
Author:
djpaul
Message:

Core, Media: misc. tidy-up for the attachments functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-attachments.php

    r11447 r11779  
    11901190 */
    11911191function bp_attachments_cover_image_ajax_upload() {
    1192     // Bail if not a POST action.
    11931192    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
    11941193        wp_die();
    11951194    }
    11961195
    1197     /**
    1198      * Sending the json response will be different if
    1199      * the current Plupload runtime is html4
    1200      */
    1201     $is_html4 = false;
    1202     if ( ! empty( $_POST['html4' ] ) ) {
    1203         $is_html4 = true;
    1204     }
    1205 
    1206     // Check the nonce.
    12071196    check_admin_referer( 'bp-uploader' );
    12081197
    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'] ) ) {
    12191202        bp_attachments_json_response( false, $is_html4 );
    12201203    }
     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'] );
    12211212
    12221213    // We need the object to set the uploads dir filter.
     
    12981289    }
    12991290
    1300     // Default error message.
    13011291    $error_message = __( 'There was a problem uploading the cover image.', 'buddypress' );
    13021292
    1303     // Get BuddyPress Attachments Uploads Dir datas.
    13041293    $bp_attachments_uploads_dir = bp_attachments_uploads_dir_get();
    13051294
     
    13231312    }
    13241313
    1325     /**
     1314    /*
    13261315     * Generate the cover image so that it fit to feature's dimensions
    13271316     *
    1328      * Unlike the Avatar, Uploading and generating the cover image is happening during
     1317     * Unlike the avatar, uploading and generating the cover image is happening during
    13291318     * the same Ajax request, as we already instantiated the BP_Attachment_Cover_Image
    13301319     * class, let's use it.
     
    13371326
    13381327    if ( ! $cover ) {
    1339         // Upload error response.
    13401328        bp_attachments_json_response( false, $is_html4, array(
    13411329            'type'    => 'upload_error',
     
    13441332    }
    13451333
    1346     // Build the url to the file.
    13471334    $cover_url = trailingslashit( $bp_attachments_uploads_dir['baseurl'] ) . $cover_subdir . '/' . $cover['cover_basename'];
    13481335
    1349     // Init Feedback code, 1 is success.
     1336    // 1 is success.
    13501337    $feedback_code = 1;
    13511338
     
    13921379 */
    13931380function bp_attachments_cover_image_ajax_delete() {
    1394     // Bail if not a POST action.
    13951381    if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) {
    13961382        wp_send_json_error();
     
    14381424        do_action( "{$component}_cover_image_deleted", (int) $cover_image_data['item_id'] );
    14391425
    1440         // Defaults no cover image.
    14411426        $response = array(
    14421427            'reset_url'     => '',
    1443             'feedback_code' => 3 ,
     1428            'feedback_code' => 3,
    14441429        );
    14451430
     
    14521437        }
    14531438
    1454         // Finally send the reset url.
    14551439        wp_send_json_success( $response );
    14561440
Note: See TracChangeset for help on using the changeset viewer.