Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/12/2021 08:43:39 PM (5 years ago)
Author:
espellcaste
Message:

Update all references from wp_parse_args to bp_parse_args.

Also, add WPCS improvements to align bp_parse_args correctly.

Props imath
Fixes #8564

File:
1 edited

Legend:

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

    r12901 r13108  
    9292        }
    9393
    94         $r = bp_parse_args( $args, array(
    95                 'object_id' => $object_id,
    96                 'object_directory' => $object_directory,
    97         ), 'cover_image_upload_dir' );
    98 
     94        $r = bp_parse_args(
     95                $args,
     96                array(
     97                        'object_id'        => $object_id,
     98                        'object_directory' => $object_directory,
     99                ),
     100                'cover_image_upload_dir'
     101        );
    99102
    100103        // Set the subdir.
    … …  
    287290        }
    288291
    289         $r = bp_parse_args( $args, array(
    290                 'item_id'   => 0,
    291                 'object'    => 'user',
    292                 'component' => '',
    293                 'image'     => '',
    294                 'crop_w'    => 0,
    295                 'crop_h'    => 0,
    296                 'crop_x'    => 0,
    297                 'crop_y'    => 0
    298         ), 'create_item_' . $type );
     292        $r = bp_parse_args(
     293                $args,
     294                array(
     295                        'item_id'   => 0,
     296                        'object'    => 'user',
     297                        'component' => '',
     298                        'image'     => '',
     299                        'crop_w'    => 0,
     300                        'crop_h'    => 0,
     301                        'crop_x'    => 0,
     302                        'crop_y'    => 0,
     303                ),
     304                'create_item_' . $type
     305        );
    299306
    300307        if ( empty( $r['item_id'] ) || empty( $r['object'] ) || ! file_exists( $r['image'] ) || ! @getimagesize( $r['image'] ) ) {
    … …  
    446453        $attachment_data = false;
    447454
    448         $r = bp_parse_args( $args, array(
    449                 'object_dir' => 'members',
    450                 'item_id'    => bp_loggedin_user_id(),
    451                 'type'       => 'cover-image',
    452                 'file'       => '',
    453         ), 'attachments_get_attachment_src' );
     455        $r = bp_parse_args(
     456                $args,
     457                array(
     458                        'object_dir' => 'members',
     459                        'item_id'    => bp_loggedin_user_id(),
     460                        'type'       => 'cover-image',
     461                        'file'       => '',
     462                ),
     463                'attachments_get_attachment_src'
     464        );
    454465
    455466        /**
    … …  
    698709
    699710        // Get an instance of the class and get the script data.
    700         $attachment = new $class;
    701         $script_data  = $attachment->script_data();
    702 
    703         $args = bp_parse_args( $script_data, array(
    704                 'action'            => '',
    705                 'file_data_name'    => '',
    706                 'max_file_size'     => 0,
    707                 'browse_button'     => 'bp-browse-button',
    708                 'container'         => 'bp-upload-ui',
    709                 'drop_element'      => 'drag-drop-area',
    710                 'bp_params'         => array(),
    711                 'extra_css'         => array(),
    712                 'extra_js'          => array(),
    713                 'feedback_messages' => array(),
    714         ), 'attachments_enqueue_scripts' );
     711        $attachment  = new $class;
     712        $script_data = $attachment->script_data();
     713
     714        $args = bp_parse_args(
     715                $script_data,
     716                array(
     717                        'action'            => '',
     718                        'file_data_name'    => '',
     719                        'max_file_size'     => 0,
     720                        'browse_button'     => 'bp-browse-button',
     721                        'container'         => 'bp-upload-ui',
     722                        'drop_element'      => 'drag-drop-area',
     723                        'bp_params'         => array(),
     724                        'extra_css'         => array(),
     725                        'extra_js'          => array(),
     726                        'feedback_messages' => array(),
     727                ),
     728                'attachments_enqueue_scripts'
     729        );
    715730
    716731        if ( empty( $args['action'] ) || empty( $args['file_data_name'] ) ) {
    … …  
    10221037
    10231038        // Set default args.
    1024         $default_args = wp_parse_args(
     1039        $default_args = bp_parse_args(
    10251040                $args,
    10261041                array(
    … …  
    10501065         * @param array $settings The cover image settings
    10511066         */
    1052         $settings = bp_parse_args( $args, $default_args, $component . '_cover_image_settings' );
     1067        $settings = bp_parse_args(
     1068                $args,
     1069                $default_args,
     1070                $component . '_cover_image_settings'
     1071        );
    10531072
    10541073        // Handle deprecated xProfile fitler.
    … …  
    12821301        }
    12831302
    1284         $bp_params = bp_parse_args( $_POST['bp_params'], array(
    1285                 'object'  => 'user',
    1286                 'item_id' => bp_loggedin_user_id(),
    1287         ), 'attachments_cover_image_ajax_upload' );
     1303        $bp_params = bp_parse_args(
     1304                $_POST['bp_params'],
     1305                array(
     1306                        'object'  => 'user',
     1307                        'item_id' => bp_loggedin_user_id(),
     1308                ),
     1309                'attachments_cover_image_ajax_upload'
     1310        );
    12881311
    12891312        $bp_params['item_id'] = (int) $bp_params['item_id'];
Note: See TracChangeset for help on using the changeset viewer.