Skip to:
Content

BuddyPress.org

Changeset 10355


Ignore:
Timestamp:
11/15/2015 07:13:42 PM (5 years ago)
Author:
tw2113
Message:

More documentation cleanup for part of BP-Core component.

See #6398.

Location:
trunk/src/bp-core/classes
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-attachment-avatar.php

    r10206 r10355  
    2929     */
    3030    public function __construct() {
    31         // Allowed avatar types
     31        // Allowed avatar types.
    3232        $allowed_types = bp_core_get_allowed_avatar_types();
    3333
     
    3737            'original_max_filesize' => bp_core_avatar_original_max_filesize(),
    3838
    39             // Specific errors for avatars
     39            // Specific errors for avatars.
    4040            'upload_error_strings'  => array(
    4141                9  => sprintf( __( 'That photo is too big. Please upload one smaller than %s', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ),
     
    5151     *
    5252     * @param array $allowed_types Array of allowed avatar types.
    53      *
    5453     * @return string comma separated list of allowed avatar types.
    5554     */
     
    9291     *
    9392     * @param  array $file the temporary file attributes (before it has been moved).
    94      *
    9593     * @return array the file with extra errors if needed.
    9694     */
    9795    public function validate_upload( $file = array() ) {
    98         // Bail if already an error
     96        // Bail if already an error.
    9997        if ( ! empty( $file['error'] ) ) {
    10098            return $file;
    10199        }
    102100
    103         // File size is too big
     101        // File size is too big.
    104102        if ( ! bp_core_check_avatar_size( array( 'file' => $file ) ) ) {
    105103            $file['error'] = 9;
    106104
    107         // File is of invalid type
     105        // File is of invalid type.
    108106        } elseif ( ! bp_core_check_avatar_type( array( 'file' => $file ) ) ) {
    109107            $file['error'] = 10;
    110108        }
    111109
    112         // Return with error code attached
     110        // Return with error code attached.
    113111        return $file;
    114112    }
     
    122120     * @uses  bp_core_avatar_original_max_width()
    123121     *
    124      * @param string $file the absolute path to the file.
    125      *
     122     * @param string $file               The absolute path to the file.
     123     * @param int    $ui_available_width Available width for the UI.
    126124     * @return mixed
    127125     */
    128126    public static function shrink( $file = '', $ui_available_width = 0 ) {
    129         // Get image size
     127        // Get image size.
    130128        $avatar_data = parent::get_image_data( $file );
    131129
    132         // Init the edit args
     130        // Init the edit args.
    133131        $edit_args = array();
    134132
     
    136134        $original_max_width = bp_core_avatar_original_max_width();
    137135
    138         // The ui_available_width is defined and it's smaller than the Avatar original max width
     136        // The ui_available_width is defined and it's smaller than the Avatar original max width.
    139137        if ( ! empty( $ui_available_width ) && $ui_available_width < $original_max_width ) {
    140138            /**
     
    150148        }
    151149
    152         // Do we need to resize the image ?
     150        // Do we need to resize the image?
    153151        if ( isset( $avatar_data['width'] ) && $avatar_data['width'] > $original_max_width ) {
    154152            $edit_args = array(
     
    158156        }
    159157
    160         // Do we need to rotate the image ?
     158        // Do we need to rotate the image?
    161159        $angles = array(
    162160            3 => 180,
     
    169167        }
    170168
    171         // No need to edit the avatar, original file will be used
     169        // No need to edit the avatar, original file will be used.
    172170        if ( empty( $edit_args ) ) {
    173171            return false;
    174172
    175         // Add the file to the edit arguments
     173        // Add the file to the edit arguments.
    176174        } else {
    177175            $edit_args['file'] = $file;
     
    190188     *
    191189     * @param string $file the absolute path to the file.
    192      *
    193      * @return boolean
     190     * @return bool
    194191     */
    195192    public static function is_too_small( $file = '' ) {
     
    218215     * @uses BP_Attachment::crop
    219216     *
    220      * @param array $args
    221      *
     217     * @param array $args Array of arguments for the cropping.
    222218     * @return array The cropped avatars (full and thumb).
    223219     */
    224220    public function crop( $args = array() ) {
    225         // Bail if the original file is missing
     221        // Bail if the original file is missing.
    226222        if ( empty( $args['original_file'] ) ) {
    227223            return false;
     
    235231        $absolute_path = $this->upload_path . $relative_path;
    236232
    237         // Bail if the avatar is not available
     233        // Bail if the avatar is not available.
    238234        if ( ! file_exists( $absolute_path ) )  {
    239235            return false;
     
    250246        }
    251247
    252         // Bail if the avatar folder is missing for this item_id
     248        // Bail if the avatar folder is missing for this item_id.
    253249        if ( ! file_exists( $avatar_folder_dir ) ) {
    254250            return false;
    255251        }
    256252
    257         // Delete the existing avatar files for the object
     253        // Delete the existing avatar files for the object.
    258254        $existing_avatar = bp_core_fetch_avatar( array(
    259255            'object'  => $args['object'],
     
    270266        }
    271267
    272         // Make sure we at least have minimal data for cropping
     268        // Make sure we at least have minimal data for cropping.
    273269        if ( empty( $args['crop_w'] ) ) {
    274270            $args['crop_w'] = bp_core_avatar_full_width();
     
    279275        }
    280276
    281         // Get the file extension
     277        // Get the file extension.
    282278        $data = @getimagesize( $absolute_path );
    283279        $ext  = $data['mime'] == 'image/png' ? 'png' : 'jpg';
     
    301297        }
    302298
    303         // Remove the original
     299        // Remove the original.
    304300        @unlink( $absolute_path );
    305301
    306         // Return the full and thumb cropped avatars
     302        // Return the full and thumb cropped avatars.
    307303        return $avatar_types;
    308304    }
     
    355351     */
    356352    public function script_data() {
    357         // Get default script data
     353        // Get default script data.
    358354        $script_data = parent::script_data();
    359355
    360         // Defaults to Avatar Backbone script
     356        // Defaults to Avatar Backbone script.
    361357        $js_scripts = array( 'bp-avatar' );
    362358
    363         // Default object
     359        // Default object.
    364360        $object = '';
    365361
    366         // Get the possible item ids
     362        // Get the possible item ids.
    367363        $user_id  = $this->get_user_id();
    368364        $group_id = $this->get_group_id();
    369365
    370366        if ( ! empty( $user_id ) ) {
    371             // Should we load the the Webcam Avatar javascript file
     367            // Should we load the the Webcam Avatar javascript file.
    372368            if ( bp_avatar_use_webcam() ) {
    373369                $js_scripts = array( 'bp-webcam' );
     
    384380            );
    385381
    386             // Set feedback messages
     382            // Set feedback messages.
    387383            $script_data['feedback_messages'] = array(
    388384                1 => __( 'There was a problem cropping your profile photo.', 'buddypress' ),
     
    402398            );
    403399
    404             // Set feedback messages
     400            // Set feedback messages.
    405401            $script_data['feedback_messages'] = array(
    406402                1 => __( 'There was a problem cropping the group profile photo.', 'buddypress' ),
     
    422418        }
    423419
    424         // Include the specific css
     420        // Include the specific css.
    425421        $script_data['extra_css'] = array( 'bp-avatar' );
    426422
    427         // Include the specific css
     423        // Include the specific css.
    428424        $script_data['extra_js']  = $js_scripts;
    429425
    430         // Set the object to contextualize the filter
     426        // Set the object to contextualize the filter.
    431427        if ( isset( $script_data['bp_params']['object'] ) ) {
    432428            $object = $script_data['bp_params']['object'];
  • trunk/src/bp-core/classes/class-bp-attachment-cover-image.php

    r10194 r10355  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    1919class BP_Attachment_Cover_Image extends BP_Attachment {
    2020    /**
    21      * The constuctor
     21     * The constuctor.
    2222     *
    2323     * @since 2.4.0
    2424     */
    2525    public function __construct() {
    26         // Allowed cover image types & upload size
     26        // Allowed cover image types & upload size.
    2727        $allowed_types        = bp_attachments_get_allowed_types( 'cover_image' );
    2828        $max_upload_file_size = bp_attachments_get_max_upload_file_size( 'cover_image' );
     
    3535            'required_wp_files'     => array( 'file', 'image' ),
    3636
    37             // Specific errors for cover images
     37            // Specific errors for cover images.
    3838            'upload_error_strings'  => array(
    3939                11  => sprintf( __( 'That image is too big. Please upload one smaller than %s', 'buddypress' ), size_format( $max_upload_file_size ) ),
     
    4949     *
    5050     * @param array $allowed_types Array of allowed cover image types.
    51      *
    52      * @return string comma separated list of allowed cover image types.
     51     * @return string $value Comma-separated list of allowed cover image types.
    5352     */
    5453    public static function get_cover_image_types( $allowed_types = array() ) {
     
    6665     * @since 2.4.0
    6766     *
    68      * @param  array $file the temporary file attributes (before it has been moved).
    69      *
    70      * @return array the file with extra errors if needed.
     67     * @param array $file The temporary file attributes (before it has been moved).
     68     * @return array $file The file with extra errors if needed.
    7169     */
    7270    public function validate_upload( $file = array() ) {
    73         // Bail if already an error
     71        // Bail if already an error.
    7472        if ( ! empty( $file['error'] ) ) {
    7573            return $file;
    7674        }
    7775
    78         // File size is too big
     76        // File size is too big.
    7977        if ( $file['size'] > $this->original_max_filesize ) {
    8078            $file['error'] = 11;
    8179
    82         // File is of invalid type
     80        // File is of invalid type.
    8381        } elseif ( ! bp_attachments_check_filetype( $file['tmp_name'], $file['name'], bp_attachments_get_allowed_mimes( 'cover_image' ) ) ) {
    8482            $file['error'] = 12;
    8583        }
    8684
    87         // Return with error code attached
     85        // Return with error code attached.
    8886        return $file;
    8987    }
    9088
    9189    /**
    92      * Set the directory when uploading a file
    93      *
    94      * @since 2.4.0
    95      *
    96      * @param  array $upload_dir The original Uploads dir.
    97      * @return array upload data (path, url, basedir...)
     90     * Set the directory when uploading a file.
     91     *
     92     * @since 2.4.0
     93     *
     94     * @param array $upload_dir The original Uploads dir.
     95     * @return array $value Upload data (path, url, basedir...).
    9896     */
    9997    public function upload_dir_filter( $upload_dir = array() ) {
    100         // Default values are for profiles
     98        // Default values are for profiles.
    10199        $object_id = bp_displayed_user_id();
    102100
     
    107105        $object_directory = 'members';
    108106
    109         // We're in a group, edit default values
     107        // We're in a group, edit default values.
    110108        if ( bp_is_group() || bp_is_group_create() ) {
    111109            $object_id        = bp_get_current_group_id();
     
    113111        }
    114112
    115         // Set the subdir
     113        // Set the subdir.
    116114        $subdir  = '/' . $object_directory . '/' . $object_id . '/cover-image';
    117115
     
    121119         * @since 2.4.0
    122120         *
    123          * @param array $value       Array containing the path, URL, and other helpful settings.
     121         * @param array $value      Array containing the path, URL, and other helpful settings.
    124122         * @param array $upload_dir The original Uploads dir.
    125123         */
     
    139137     * @since 2.4.0
    140138     *
    141      * @param string $file the absolute path to the file.
     139     * @param string $file       The absolute path to the file.
     140     * @param array  $dimensions Array of dimensions for the cover image.
    142141     * @return mixed
    143142     */
     
    147146        }
    148147
    149         // Get image size
     148        // Get image size.
    150149        $cover_data = parent::get_image_data( $file );
    151150
    152         // Init the edit args
     151        // Init the edit args.
    153152        $edit_args = array();
    154153
    155         // Do we need to resize the image ?
     154        // Do we need to resize the image?
    156155        if ( ( isset( $cover_data['width'] ) && $cover_data['width'] > $dimensions['width'] ) ||
    157156        ( isset( $cover_data['height'] ) && $cover_data['height'] > $dimensions['height'] ) ) {
     
    163162        }
    164163
    165         // Do we need to rotate the image ?
     164        // Do we need to rotate the image?
    166165        $angles = array(
    167166            3 => 180,
     
    174173        }
    175174
    176         // No need to edit the avatar, original file will be used
     175        // No need to edit the avatar, original file will be used.
    177176        if ( empty( $edit_args ) ) {
    178177            return false;
    179178
    180         // Add the file to the edit arguments
     179        // Add the file to the edit arguments.
    181180        } else {
    182181            $edit_args = array_merge( $edit_args, array( 'file' => $file, 'save' => false ) );
    183182        }
    184183
    185         // Get the editor so that we can use a specific save method
     184        // Get the editor so that we can use a specific save method.
    186185        $editor = parent::edit_image( 'cover_image', $edit_args );
    187186
     
    192191        }
    193192
    194         // Save the new image file
     193        // Save the new image file.
    195194        return $editor->save( $this->generate_filename( $file ) );
    196195    }
    197196
    198197    /**
    199      * Generate a filename for the cover image
    200      *
    201      * @since 2.4.0
    202      *
    203      * @param  string $file the absolute path to the file.
    204      * @return string       the absolute path to the new file name
     198     * Generate a filename for the cover image.
     199     *
     200     * @since 2.4.0
     201     *
     202     * @param string $file The absolute path to the file.
     203     * @return string $value The absolute path to the new file name.
    205204     */
    206205    public function generate_filename( $file = '' ) {
     
    218217
    219218    /**
    220      * Build script datas for the Uploader UI
    221      *
    222      * @since 2.4.0
    223      *
    224      * @return array the javascript localization data
     219     * Build script datas for the Uploader UI.
     220     *
     221     * @since 2.4.0
     222     *
     223     * @return array The javascript localization data
    225224     */
    226225    public function script_data() {
    227         // Get default script data
     226        // Get default script data.
    228227        $script_data = parent::script_data();
    229228
     
    240239            );
    241240
    242             // Set feedback messages
     241            // Set feedback messages.
    243242            $script_data['feedback_messages'] = array(
    244243                1 => __( 'Your new cover image was uploaded successfully.', 'buddypress' ),
     
    258257            );
    259258
    260             // Set feedback messages
     259            // Set feedback messages.
    261260            $script_data['feedback_messages'] = array(
    262261                1 => __( 'The group cover image was uploaded successfully.', 'buddypress' ),
     
    265264            );
    266265        } else {
     266
    267267            /**
    268              * Use this filter to include specific BuddyPress params for your object.
     268             * Filters the cover image params to include specific BuddyPress params for your object.
    269269             * e.g. Cover image for blogs single item.
    270270             *
     
    276276        }
    277277
    278         // Include our specific js & css
     278        // Include our specific js & css.
    279279        $script_data['extra_js']  = array( 'bp-cover-image' );
    280280        $script_data['extra_css'] = array( 'bp-avatar' );
    281281
     282        /**
     283         * Filters the cover image script data.
     284         *
     285         * @since 2.4.0
     286         *
     287         * @param array $script_data Array of data for the cover image.
     288         */
    282289        return apply_filters( 'bp_attachments_cover_image_script_data', $script_data );
    283290    }
  • trunk/src/bp-core/classes/class-bp-attachment.php

    r10194 r10355  
    5050     * @since 2.3.0
    5151     * @since 2.4.0 Add the $upload_dir_filter_args argument to the $arguments array
     52     * @uses                                    sanitize_key()
     53     * @uses                                    wp_max_upload_size()
     54     * @uses                                    bp_parse_args()
     55     * @uses                                    BP_Attachment->set_upload_error_strings()
     56     * @uses                                    BP_Attachment->set_upload_dir()
    5257     *
    5358     * @param array|string $args {
     
    6469     *                                          Defaults to 0 (optional).
    6570     * }
    66      * @uses  sanitize_key()
    67      * @uses  wp_max_upload_size()
    68      * @uses  bp_parse_args()
    69      * @uses  BP_Attachment->set_upload_error_strings()
    70      * @uses  BP_Attachment->set_upload_dir()
    7171     */
    7272    public function __construct( $args = '' ) {
    73         // Upload action and the file input name are required parameters
     73        // Upload action and the file input name are required parameters.
    7474        if ( empty( $args['action'] ) || empty( $args['file_input'] ) ) {
    7575            return false;
    7676        }
    7777
    78         // Sanitize the action ID and the file input name
     78        // Sanitize the action ID and the file input name.
    7979        $this->action     = sanitize_key( $args['action'] );
    8080        $this->file_input = sanitize_key( $args['file_input'] );
     
    9292                $this->{$key} = $this->set_upload_error_strings( $param );
    9393
    94             // Sanitize the base dir
     94            // Sanitize the base dir.
    9595            } elseif ( 'base_dir' === $key ) {
    9696                $this->{$key} = sanitize_title( $param );
    9797
    98             // Sanitize the upload dir filter arg to pass
     98            // Sanitize the upload dir filter arg to pass.
    9999            } elseif ( 'upload_dir_filter_args' === $key ) {
    100100                $this->{$key} = (int) $param;
    101101
    102             // Action & File input are already set and sanitized
     102            // Action & File input are already set and sanitized.
    103103            } elseif ( 'action' !== $key && 'file_input' !== $key ) {
    104104                $this->{$key} = $param;
     
    106106        }
    107107
    108         // Set the path/url and base dir for uploads
     108        // Set the path/url and base dir for uploads.
    109109        $this->set_upload_dir();
    110110    }
     
    118118     */
    119119    public function set_upload_dir() {
    120         // Set the directory, path, & url variables
     120        // Set the directory, path, & url variables.
    121121        $this->upload_dir  = bp_upload_dir();
    122122
     
    128128        $this->url         = $this->upload_dir['baseurl'];
    129129
    130         // Ensure URL is https if SSL is set/forced
     130        // Ensure URL is https if SSL is set/forced.
    131131        if ( is_ssl() ) {
    132132            $this->url = str_replace( 'http://', 'https://', $this->url );
     
    142142            $this->url         = trailingslashit( $this->url  ) . $this->base_dir;
    143143
    144             // Finally create the base dir
     144            // Finally create the base dir.
    145145            $this->create_dir();
    146146        }
     
    155155     *
    156156     * @param array $param A list of error messages to add to BuddyPress core ones.
    157      *
    158      * @return array the list of upload errors
     157     * @return array $upload_errors The list of upload errors.
    159158     */
    160159    public function set_upload_error_strings( $param = array() ) {
     
    204203     * @since 2.3.0
    205204     *
    206      * @param  array       $file              The appropriate entry the from $_FILES superglobal.
    207      * @param  string      $upload_dir_filter A specific filter to be applied to 'upload_dir' (optional).
    208      * @param  string|null $time              Optional. Time formatted in 'yyyy/mm'. Default null.
    209      *
    210205     * @uses   wp_handle_upload()        To upload the file
    211206     * @uses   add_filter()              To temporarly overrides WordPress uploads data
     
    213208     * @uses   apply_filters()           Call 'bp_attachment_upload_overrides' to include specific upload overrides
    214209     *
    215      * @return array                     On success, returns an associative array of file attributes.
    216      *                                   On failure, returns an array containing the error message
    217      *                                   (eg: array( 'error' => $message ) )
     210     * @param  array       $file              The appropriate entry the from $_FILES superglobal.
     211     * @param  string      $upload_dir_filter A specific filter to be applied to 'upload_dir' (optional).
     212     * @param  string|null $time              Optional. Time formatted in 'yyyy/mm'. Default null.
     213     * @return array On success, returns an associative array of file attributes.
     214     *               On failure, returns an array containing the error message
     215     *               (eg: array( 'error' => $message ) )
    218216     */
    219217    public function upload( $file, $upload_dir_filter = '', $time = null ) {
     
    238236        add_filter( 'wp_handle_upload_prefilter', array( $this, 'validate_upload' ), 10, 1 );
    239237
    240         // Set Default overrides
     238        // Set Default overrides.
    241239        $overrides = array(
    242240            'action'               => $this->action,
     
    275273        }
    276274
    277         // Make sure the file will be uploaded in the attachment directory
     275        // Make sure the file will be uploaded in the attachment directory.
    278276        if ( ! empty( $upload_dir_filter ) ) {
    279277            add_filter( 'upload_dir', $upload_dir_filter, 10, $this->upload_dir_filter_args );
    280278        }
    281279
    282         // Upload the attachment
     280        // Upload the attachment.
    283281        $this->attachment = wp_handle_upload( $file[ $this->file_input ], $overrides, $time );
    284282
    285         // Restore WordPress Uploads data
     283        // Restore WordPress Uploads data.
    286284        if ( ! empty( $upload_dir_filter ) ) {
    287285            remove_filter( 'upload_dir', $upload_dir_filter, 10, $this->upload_dir_filter_args );
    288286        }
    289287
    290         // Remove the pre WordPress 4.0 static filter
     288        // Remove the pre WordPress 4.0 static filter.
    291289        remove_filter( 'wp_handle_upload_prefilter', array( $this, 'validate_upload' ), 10, 1 );
    292290
    293         // Finally return the uploaded file or the error
     291        // Finally return the uploaded file or the error.
    294292        return $this->attachment;
    295293    }
     
    300298     * In case of a multisite, the mime types are already restricted by
    301299     * the 'upload_filetypes' setting. BuddyPress will respect this setting.
     300     *
    302301     * @see check_upload_mimes()
    303302     *
     
    310309        $valid_mimes = array();
    311310
    312         // Set the allowed mimes for the upload
     311        // Set the allowed mimes for the upload.
    313312        foreach ( (array) $this->allowed_mime_types as $ext ) {
    314313            foreach ( $wp_mimes as $ext_pattern => $mime ) {
     
    333332     *
    334333     * @param  array $file The temporary file attributes (before it has been moved).
    335      *
    336334     * @return array The file.
    337335     */
    338336    public function validate_upload( $file = array() ) {
    339         // Bail if already an error
     337        // Bail if already an error.
    340338        if ( ! empty( $file['error'] ) ) {
    341339            return $file;
     
    346344        }
    347345
    348         // Return the file
     346        // Return the file.
    349347        return $file;
    350348    }
     
    394392     */
    395393    public function create_dir() {
    396         // Bail if no specific base dir is set
     394        // Bail if no specific base dir is set.
    397395        if ( empty( $this->base_dir ) ) {
    398396            return false;
    399397        }
    400398
    401         // Check if upload path already exists
     399        // Check if upload path already exists.
    402400        if ( ! is_dir( $this->upload_path ) ) {
    403401
    404             // If path does not exist, attempt to create it
     402            // If path does not exist, attempt to create it.
    405403            if ( ! wp_mkdir_p( $this->upload_path ) ) {
    406404                return false;
     
    408406        }
    409407
    410         // Directory exists
     408        // Directory exists.
    411409        return true;
    412410    }
     
    452450        }
    453451
    454         // Check image file pathes
     452        // Check image file pathes.
    455453        $path_error = __( 'Cropping the file failed: the file path is not allowed.', 'buddypress' );
    456454
    457         // Make sure it's coming from an uploaded file
     455        // Make sure it's coming from an uploaded file.
    458456        if ( false === strpos( $r['original_file'], $this->upload_path ) ) {
    459457            $wp_error->add( 'crop_error', $path_error );
     
    464462         * If no destination file is provided, WordPress will use a default name
    465463         * and will write the file in the source file's folder.
    466          * If a destination file is provided, we need to make sure it's going into uploads
     464         * If a destination file is provided, we need to make sure it's going into uploads.
    467465         */
    468466        if ( ! empty( $r['dst_file'] ) && false === strpos( $r['dst_file'], $this->upload_path ) ) {
     
    471469        }
    472470
    473         // Check image file types
     471        // Check image file types.
    474472        $check_types = array( 'src_file' => array( 'file' => $r['original_file'], 'error' => _x( 'source file', 'Attachment source file', 'buddypress' ) ) );
    475473        if ( ! empty( $r['dst_file'] ) ) {
     
    478476
    479477        /**
    480          * WordPress image supported types
     478         * WordPress image supported types.
    481479         * @see wp_attachment_is()
    482480         */
     
    499497        }
    500498
    501         // Add the image.php to the required WordPress files, if it's not already the case
     499        // Add the image.php to the required WordPress files, if it's not already the case.
    502500        $required_files = array_flip( $this->required_wp_files );
    503501        if ( ! isset( $required_files['image'] ) ) {
     
    505503        }
    506504
    507         // Load the files
     505        // Load the files.
    508506        $this->includes();
    509507
    510         // Finally crop the image
     508        // Finally crop the image.
    511509        return wp_crop_image( $r['original_file'], (int) $r['crop_x'], (int) $r['crop_y'], (int) $r['crop_w'], (int) $r['crop_h'], (int) $r['dst_w'], (int) $r['dst_h'], $r['src_abs'], $r['dst_file'] );
    512510    }
     
    545543     */
    546544    public static function get_image_data( $file ) {
    547         // Try to get image basic data
     545        // Try to get image basic data.
    548546        list( $width, $height, $sourceImageType ) = @getimagesize( $file );
    549547
     
    553551        }
    554552
    555         // Initialize the image data
     553        // Initialize the image data.
    556554        $image_data = array(
    557555            'width'  => $width,
     
    567565        }
    568566
    569         // Now try to get image's meta data
     567        // Now try to get image's meta data.
    570568        $meta = wp_read_image_metadata( $file );
    571569
    572570        if ( ! empty( $meta ) ) {
    573             // Before 4.0 the Orientation wasn't included
     571            // Before 4.0 the Orientation wasn't included.
    574572            if ( ! isset( $meta['orientation'] ) &&
    575573                is_callable( 'exif_read_data' ) &&
     
    583581            }
    584582
    585             // Now add the metas to image data
     583            // Now add the metas to image data.
    586584            $image_data['meta'] = $meta;
    587585        }
     
    602600     * @since  2.4.0
    603601     *
    604      * @param  string $attachment_type The attachment type (eg: avatar or cover_image). Required.
    605      * @param  array  array $args {
     602     * @param string $attachment_type The attachment type (eg: avatar or cover_image). Required.
     603     * @param array $args {
    606604     *     @type string $file     Absolute path to the image file (required).
    607605     *     @type int    $max_w    Max width attribute for the editor's resize method (optional).
     
    612610     *     @type bool   $save     Whether to use the editor's save method or not (optional).
    613611     * }
    614      *
    615612     * @return string|WP_Image_Editor|WP_Error The edited image path or the WP_Image_Editor object in case of success,
    616613     *                                         an WP_Error object otherwise.
     
    636633        }
    637634
    638         // Get the image editor
     635        // Get the image editor.
    639636        $editor = wp_get_image_editor( $r['file'] );
    640637
     
    648645            $rotated = $editor->rotate( $r['rotate'] );
    649646
    650             // Stop in case of error
     647            // Stop in case of error.
    651648            if ( is_wp_error( $rotated ) ) {
    652649                return $rotated;
     
    657654            $resized = $editor->resize( $r['max_w'], $r['max_h'], $r['crop'] );
    658655
    659             // Stop in case of error
     656            // Stop in case of error.
    660657            if ( is_wp_error( $resized ) ) {
    661658                return $resized;
     
    663660        }
    664661
    665         // Use the editor save method to get a path to the edited image
     662        // Use the editor save method to get a path to the edited image.
    666663        if ( true === $r['save'] ) {
    667664            return $editor->save( $editor->generate_filename() );
    668665
    669         // Need to do some other edit actions or use a specific method to save file
     666        // Need to do some other edit actions or use a specific method to save file.
    670667        } else {
    671668            return $editor;
  • trunk/src/bp-core/classes/class-bp-button.php

    r10108 r10355  
    144144    public $link_text = '';
    145145
    146     /** HTML result ***********************************************************/
    147 
     146    /** HTML result
     147     *
     148     * @var string
     149     */
    148150    public $contents = '';
    149151
     
    161163        $r = wp_parse_args( $args, get_class_vars( __CLASS__ ) );
    162164
    163         // Required button properties
     165        // Required button properties.
    164166        $this->id                = $r['id'];
    165167        $this->component         = $r['component'];
     
    172174            return false;
    173175
    174         // No button if component is not active
     176        // No button if component is not active.
    175177        if ( ! bp_is_active( $this->component ) )
    176178            return false;
    177179
    178         // No button for guests if must be logged in
     180        // No button for guests if must be logged in.
    179181        if ( true == $this->must_be_logged_in && ! is_user_logged_in() )
    180182            return false;
    181183
    182         // block_self
     184        // The block_self property.
    183185        if ( true == $this->block_self ) {
    184186            // No button if you are the current user in a members loop
    185187            // This condition takes precedence, because members loops
    186             // can be found on user profiles
     188            // can be found on user profiles.
    187189            if ( bp_get_member_user_id() ) {
    188190                if ( is_user_logged_in() && bp_loggedin_user_id() == bp_get_member_user_id() ) {
     
    191193
    192194            // No button if viewing your own profile (and not in
    193             // a members loop)
     195            // a members loop).
    194196            } elseif ( bp_is_my_profile() ) {
    195197                return false;
     
    197199        }
    198200
    199         // Wrapper properties
     201        // Wrapper properties.
    200202        if ( false !== $this->wrapper ) {
    201203
    202             // Wrapper ID
     204            // Wrapper ID.
    203205            if ( !empty( $r['wrapper_id'] ) ) {
    204206                $this->wrapper_id    = ' id="' . $r['wrapper_id'] . '"';
    205207            }
    206208
    207             // Wrapper class
     209            // Wrapper class.
    208210            if ( !empty( $r['wrapper_class'] ) ) {
    209211                $this->wrapper_class = ' class="generic-button ' . $r['wrapper_class'] . '"';
     
    212214            }
    213215
    214             // Set before and after
     216            // Set before and after.
    215217            $before = '<' . $r['wrapper'] . $this->wrapper_class . $this->wrapper_id . '>';
    216218            $after  = '</' . $r['wrapper'] . '>';
    217219
    218         // No wrapper
     220        // No wrapper.
    219221        } else {
    220222            $before = $after = '';
    221223        }
    222224
    223         // Link properties
     225        // Link properties.
    224226        if ( !empty( $r['link_id']    ) ) $this->link_id    = ' id="' .    $r['link_id']    . '"';
    225227        if ( !empty( $r['link_href']  ) ) $this->link_href  = ' href="' .  $r['link_href']  . '"';
     
    229231        if ( !empty( $r['link_text']  ) ) $this->link_text  =              $r['link_text'];
    230232
    231         // Build the button
     233        // Build the button.
    232234        $this->contents = $before . '<a'. $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->link_class . '>' . $this->link_text . '</a>' . $after;
    233235
  • trunk/src/bp-core/classes/class-bp-core-notification.php

    r10108 r10355  
    1515 * Use BP_Notifications_Notification instead.
    1616 *
    17  * @package BuddyPress Core
    1817 * @deprecated since 1.9.0
    1918 */
     
    8180     * Constructor
    8281     *
    83      * @param int $id
     82     * @param int $id ID for the notification.
    8483     */
    8584    public function __construct( $id = 0 ) {
     
    102101        $bp = buddypress();
    103102
    104         // Update
     103        // Update.
    105104        if ( !empty( $this->id ) ) {
    106105            $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = %s, is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );
    107106
    108         // Save
     107        // Save.
    109108        } else {
    110109            $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, %s, %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );
     
    149148     * @param int $user_id         ID to check access for.
    150149     * @param int $notification_id Notification ID to check for.
    151      *
    152150     * @return string
    153151     */
     
    164162     *
    165163     * @global wpdb $wpdb WordPress database object
     164     *
     165     * @static
    166166     *
    167167     * @param int    $user_id User ID.
    168168     * @param string $status 'is_new' or 'all'.
    169      *
    170169     * @return array Associative array
    171      * @static
    172170     */
    173171    public static function get_all_for_user( $user_id, $status = 'is_new' ) {
     
    188186     * @global wpdb $wpdb WordPress database object.
    189187     *
    190      * @param int    $user_id
    191      * @param string $component_name
    192      * @param string $component_action
    193      *
    194      * @static
    195      *
     188     * @static
     189     *
     190     * @param int    $user_id          ID of the user to delet notification for.
     191     * @param string $component_name   Component name.
     192     * @param string $component_action Component action.
    196193     * @return mixed
    197194     */
     
    208205     *
    209206     * @global wpdb $wpdb WordPress database object.
     207     *
     208     * @static
    210209     *
    211210     * @param int      $user_id           The ID of the user who the notifications are for.
     
    215214     * @param int|bool $secondary_item_id (optional) The secondary item id of the notifications that we wish to
    216215     *                                    use to delete.
    217      * @static
    218      *
    219216     * @return mixed
    220217     */
     
    236233     * @global wpdb $wpdb WordPress database object.
    237234     *
     235     * @static
     236     *
    238237     * @param int    $user_id          The ID of the user whose sent notifications we wish to delete.
    239238     * @param string $component_name   The name of the component the notification was sent from.
    240239     * @param string $component_action The action of the component the notification was sent from.
    241      * @static
    242      *
    243240     * @return mixed
    244241     */
     
    256253     *
    257254     * @global wpdb $wpdb WordPress database object.
     255     *
     256     * @static
    258257     *
    259258     * @param string $item_id           The item id that they notifications are to be for.
     
    261260     * @param string $component_action  The action that the notifications are to be from.
    262261     * @param string $secondary_item_id Optional secondary item id that the notifications are to have.
    263      * @static
    264      *
    265262     * @return mixed
    266263     */
  • trunk/src/bp-core/classes/class-bp-core-user.php

    r10108 r10355  
    1919 *    $user = new BP_Core_User( $user_id );
    2020 *    $user_avatar = $user->avatar;
    21  *    $user_email = $user->email;
     21 *    $user_email = $user->email;
    2222 *    $user_status = $user->status;
    2323 *    etc.
     
    178178        }
    179179
    180         // Cache a few things that are fetched often
     180        // Cache a few things that are fetched often.
    181181        wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
    182182        wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
     
    282282        $sql['from'] = "FROM {$wpdb->users} u LEFT JOIN {$wpdb->usermeta} um ON um.user_id = u.ID";
    283283
    284         // We search against xprofile fields, so we must join the table
     284        // We search against xprofile fields, so we must join the table.
    285285        if ( $search_terms && bp_is_active( 'xprofile' ) ) {
    286286            $sql['join_profiledata_search'] = "LEFT JOIN {$bp->profile->table_name_data} spd ON u.ID = spd.user_id";
    287287        }
    288288
    289         // Alphabetical sorting is done by the xprofile Full Name field
     289        // Alphabetical sorting is done by the xprofile Full Name field.
    290290        if ( 'alphabetical' == $type ) {
    291291            $sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
     
    349349            $sql['where_meta'] = $wpdb->prepare( " AND umm.meta_key = %s", $meta_key );
    350350
    351             // If a meta value is provided, match it
     351            // If a meta value is provided, match it.
    352352            if ( $meta_value ) {
    353353                $sql['where_meta'] .= $wpdb->prepare( " AND umm.meta_value = %s", $meta_value );
     
    388388        $paged_users     = $wpdb->get_results( $paged_users_sql );
    389389
    390         // Re-jig the SQL so we can get the total user count
     390        // Re-jig the SQL so we can get the total user count.
    391391        unset( $sql['select_main'] );
    392392
     
    420420        $total_users     = $wpdb->get_var( $total_users_sql );
    421421
    422         /***
     422        /**
    423423         * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
    424          * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
     424         * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join).
    425425         */
    426426        if ( !empty( $populate_extras ) ) {
     
    431431            }
    432432
    433             // Add additional data to the returned results
     433            // Add additional data to the returned results.
    434434            $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids, $type );
    435435        }
     
    448448     * @param int    $page            The page number we are currently on, used in conjunction
    449449     *                                with $limit to get the start position for the limit.
    450      * @param bool   $populate_extras Populate extra user fields?
     450     * @param bool   $populate_extras If we should populate extra user fields.
    451451     * @param string $exclude         Comma-separated IDs of users whose results
    452452     *                                aren't to be fetched.
    453      *
    454453     * @return mixed False on error, otherwise associative array of results.
    455454     */
     
    462461        }
    463462
    464         // Multibyte compliance
     463        // Multibyte compliance.
    465464        if ( function_exists( 'mb_strlen' ) ) {
    466465            if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {
     
    506505        $paged_users = $wpdb->get_results( $paged_users_sql );
    507506
    508         /***
     507        /**
    509508         * Lets fetch some other useful data in a separate queries, this will be
    510509         * faster than querying the data for every user in a list. We can't add
     
    517516            $user_ids[] = (int) $user->id;
    518517
    519         // Add additional data to the returned results
     518        // Add additional data to the returned results.
    520519        if ( $populate_extras ) {
    521520            $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
     
    536535     * @param int   $limit           The limit of results we want.
    537536     * @param int   $page            The page we are on for pagination.
    538      * @param bool  $populate_extras Populate extra user fields?
    539      *
     537     * @param bool  $populate_extras If we should populate extra user fields.
    540538     * @return array Associative array.
    541539     */
     
    607605        $paged_users = $wpdb->get_results( $paged_users_sql );
    608606
    609         /***
     607        /**
    610608         * Lets fetch some other useful data in a separate queries, this will be
    611609         * faster than querying the data for every user in a list. We can't add
     
    615613         */
    616614
    617         // Add additional data to the returned results
     615        // Add additional data to the returned results.
    618616        if ( !empty( $populate_extras ) ) {
    619617            $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
     
    632630     * @param int     $limit           The limit of results we want.
    633631     * @param int     $page            The page we are on for pagination.
    634      * @param boolean $populate_extras Populate extra user fields?
    635      *
     632     * @param boolean $populate_extras If we should populate extra user fields.
    636633     * @return array Associative array.
    637634     */
     
    668665        $paged_users = $wpdb->get_results( $paged_users_sql );
    669666
    670         /***
     667        /**
    671668         * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
    672669         * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
     
    675672            $user_ids[] = $user->id;
    676673
    677         // Add additional data to the returned results
     674        // Add additional data to the returned results.
    678675        if ( $populate_extras )
    679676            $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids );
     
    692689     * @param string      $user_ids    The user ids to select information about.
    693690     * @param string|bool $type        The type of fields we wish to get.
    694      *
    695691     * @return mixed False on error, otherwise associative array of results.
    696692     */
     
    703699            return $paged_users;
    704700
    705         // Sanitize user IDs
     701        // Sanitize user IDs.
    706702        $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
    707703
    708         // Fetch the user's full name
     704        // Fetch the user's full name.
    709705        if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {
    710706            $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", bp_xprofile_fullname_field_name() ) );
     
    717713        }
    718714
    719         // Fetch the user's total friend count
     715        // Fetch the user's total friend count.
    720716        if ( 'popular' != $type ) {
    721717            $friend_count = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as total_friend_count FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'total_friend_count' ) ) );
     
    728724        }
    729725
    730         // Fetch whether or not the user is a friend
     726        // Fetch whether or not the user is a friend.
    731727        if ( bp_is_active( 'friends' ) ) {
    732728            $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", bp_loggedin_user_id(), bp_loggedin_user_id() ) );
     
    749745        }
    750746
    751         // Fetch the user's last_activity
     747        // Fetch the user's last_activity.
    752748        if ( 'active' != $type ) {
    753749            $user_activity = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as last_activity FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'last_activity' ) ) );
     
    760756        }
    761757
    762         // Fetch the user's latest update
     758        // Fetch the user's latest update.
    763759        $user_update = $wpdb->get_results( $wpdb->prepare( "SELECT user_id as id, meta_value as latest_update FROM {$wpdb->usermeta} WHERE meta_key = %s AND user_id IN ( {$user_ids} )", bp_get_user_meta_key( 'bp_latest_update' ) ) );
    764760        for ( $i = 0, $count = count( $paged_users ); $i < $count; ++$i ) {
     
    778774     *
    779775     * @param int $user_id User ID.
    780      *
    781776     * @return array Associative array.
    782777     */
     
    793788     * Get last activity data for a user or set of users.
    794789     *
    795      * @param int|array User IDs or multiple user IDs.
    796      *
     790     * @param int|array $user_id User IDs or multiple user IDs.
    797791     * @return array
    798792     */
     
    800794        global $wpdb;
    801795
    802         // Sanitize and remove empty values
     796        // Sanitize and remove empty values.
    803797        $user_ids = array_filter( wp_parse_id_list( $user_id ) );
    804798
     
    825819        }
    826820
    827         // Fetch all user data from the cache
     821        // Fetch all user data from the cache.
    828822        $retval = array();
    829823        foreach ( $user_ids as $user_id ) {
     
    844838     * @param int    $user_id ID of the user whose last_activity you are updating.
    845839     * @param string $time    MySQL-formatted time string.
    846      *
    847840     * @return bool True on success, false on failure.
    848841     */
     
    858851                $table_name,
    859852
    860                 // Data to update
     853                // Data to update.
    861854                array(
    862855                    'date_recorded' => $time,
    863856                ),
    864857
    865                 // WHERE
     858                // WHERE.
    866859                array(
    867860                    'id' => $activity[ $user_id ]['activity_id'],
    868861                ),
    869862
    870                 // Data sanitization format
     863                // Data sanitization format.
    871864                array(
    872865                    '%s',
    873866                ),
    874867
    875                 // WHERE sanitization format
     868                // WHERE sanitization format.
    876869                array(
    877870                    '%d',
     
    879872            );
    880873
    881             // add new date to existing activity entry for caching
     874            // Add new date to existing activity entry for caching.
    882875            $activity[ $user_id ]['date_recorded'] = $time;
    883876
     
    886879                $table_name,
    887880
    888                 // Data
     881                // Data.
    889882                array(
    890883                    'user_id'       => $user_id,
     
    898891                ),
    899892
    900                 // Data sanitization format
     893                // Data sanitization format.
    901894                array(
    902895                    '%d',
     
    911904            );
    912905
    913             // set up activity array for caching
    914             // view the foreach loop in the get_last_activity() method for format
     906            // Set up activity array for caching.
     907            // View the foreach loop in the get_last_activity() method for format.
    915908            $activity = array();
    916909            $activity[ $user_id ] = array(
     
    921914        }
    922915
    923         // set cache
     916        // Set cache.
    924917        wp_cache_set( $user_id, $activity[ $user_id ], 'bp_last_activity' );
    925918
     
    932925     * @since 2.0.0
    933926     *
    934      * @param int $user_id
    935      *
     927     * @param int $user_id ID of the user whose activity should be deleted.
    936928     * @return bool True on success, false on failure or if no last_activity
    937929     *              is found for the user.
     
    949941            buddypress()->members->table_name_last_activity,
    950942
    951             // WHERE
     943            // WHERE.
    952944            array(
    953945                'id' => $existing[ $user_id ]['activity_id'],
    954946            ),
    955947
    956             // WHERE sanitization format
     948            // WHERE sanitization format.
    957949            array(
    958950                '%s',
  • trunk/src/bp-core/classes/class-bp-date-query.php

    r10108 r10355  
    1111
    1212if ( class_exists( 'WP_Date_Query' ) ) :
     13
    1314/**
    1415 * BuddyPress date query class.
     
    3435     * Constructor.
    3536     *
    36      * @param array  $date_query
    37      * @param string $column
     37     * @param array  $date_query Date query arguments.
     38     * @param string $column     THe DB column to query against.
    3839     *
    3940     * @see WP_Date_Query::__construct()
     
    5960     *
    6061     * @param array $retval Current DB columns.
    61      *
    6262     * @return array
    6363     */
  • trunk/src/bp-core/classes/class-bp-embed.php

    r10108 r10355  
    3232        // These are providers that use a regex callback on the URL in question.
    3333        // Do not confuse with oEmbed providers, which require an external ping.
    34         // Used in WP_Embed::shortcode()
     34        // Used in WP_Embed::shortcode().
    3535        $this->handlers = $wp_embed->handlers;
    3636
     
    8383     * @param array  $attr Shortcode attributes.
    8484     * @param string $url  The URL attempting to be embeded.
    85      *
    8685     * @return string The embed HTML on success, otherwise the original URL.
    8786     */
     
    9392        $attr = wp_parse_args( $attr, wp_embed_defaults() );
    9493
    95         // kses converts & into &amp; and we need to undo this
    96         // See https://core.trac.wordpress.org/ticket/11311
     94        // Use kses to convert & into &amp; and we need to undo this
     95        // See https://core.trac.wordpress.org/ticket/11311.
    9796        $url = str_replace( '&amp;', '&', $url );
    9897
    99         // Look for known internal handlers
     98        // Look for known internal handlers.
    10099        ksort( $this->handlers );
    101100        foreach ( $this->handlers as $priority => $handlers ) {
     
    137136        $attr['discover'] = ( apply_filters( 'bp_embed_oembed_discover', false ) && current_user_can( 'unfiltered_html' ) );
    138137
    139         // Set up a new WP oEmbed object to check URL with registered oEmbed providers
     138        // Set up a new WP oEmbed object to check URL with registered oEmbed providers.
    140139        require_once( ABSPATH . WPINC . '/class-oembed.php' );
    141140        $oembed_obj = _wp_oembed_get_object();
    142141
    143         // If oEmbed discovery is true, skip oEmbed provider check
     142        // If oEmbed discovery is true, skip oEmbed provider check.
    144143        $is_oembed_link = false;
    145144        if ( !$attr['discover'] ) {
     
    151150            }
    152151
    153             // If url doesn't match a WP oEmbed provider, stop parsing
     152            // If url doesn't match a WP oEmbed provider, stop parsing.
    154153            if ( !$is_oembed_link )
    155154                return $this->maybe_make_link( $url );
     
    176175     * @param array  $rawattr Untouched shortcode attributes from
    177176     *                        {@link WP_Embed::shortcode()}.
    178      *
    179177     * @return string The embed HTML on success, otherwise the original URL.
    180178     */
     
    183181
    184182        if ( $id ) {
    185             // Setup the cachekey
     183            // Setup the cachekey.
    186184            $cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
    187185
    188             // Let components / plugins grab their cache
     186            // Let components / plugins grab their cache.
    189187            $cache = '';
    190188
     
    203201            $cache = apply_filters( 'bp_embed_get_cache', $cache, $id, $cachekey, $url, $attr, $rawattr );
    204202
    205             // Grab cache and return it if available
     203            // Grab cache and return it if available.
    206204            if ( !empty( $cache ) ) {
    207205
     
    218216                return apply_filters( 'bp_embed_oembed_html', $cache, $url, $attr, $rawattr );
    219217
    220             // If no cache, ping the oEmbed provider and cache the result
     218            // If no cache, ping the oEmbed provider and cache the result.
    221219            } else {
    222220                $html = wp_oembed_get( $url, $attr );
     
    236234                do_action( 'bp_embed_update_cache', $cache, $cachekey, $id );
    237235
    238                 // If there was a result, return it
     236                // If there was a result, return it.
    239237                if ( $html ) {
    240238
     
    245243        }
    246244
    247         // Still unknown
     245        // Still unknown.
    248246        return $this->maybe_make_link( $url );
    249247    }
  • trunk/src/bp-core/classes/class-bp-media-extractor.php

    r10160 r10355  
    6363     * @param int            $what_to_extract Media type to extract (optional).
    6464     * @param array          $extra_args      Bespoke data for a particular extractor (optional).
    65      *
    6665     * @return array {
    6766     *     @type array $has Extracted media counts. {
     
    197196     * @param string $plaintext  Sanitized version of the content.
    198197     * @param array  $extra_args Bespoke data for a particular extractor (optional).
    199      *
    200198     * @return array {
    201199     *     @type array $has Extracted media counts. {
     
    212210        $data = array( 'has' => array( 'links' => 0 ), 'links' => array() );
    213211
    214         // Matches: href="text" and href='text'
     212        // Matches: href="text" and href='text'.
    215213        if ( stripos( $richtext, 'href=' ) !== false ) {
    216214            preg_match_all( '#href=(["\'])([^"\']+)\1#i', $richtext, $matches );
     
    257255     * @param string $plaintext  Sanitized version of the content.
    258256     * @param array  $extra_args Bespoke data for a particular extractor.
    259      *
    260257     * @return array {
    261258     *     @type array $has Extracted media counts. {
     
    292289        }
    293290
    294         // Build results
     291        // Build results.
    295292        foreach ( $mentions as $user_id => $mention_name ) {
    296293            $mention = array( 'name' => strtolower( $mention_name ) );
     
    329326     * @param string $plaintext  Sanitized version of the content.
    330327     * @param array  $extra_args Bespoke data for a particular extractor (optional).
    331      *
    332328     * @return array {
    333329     *     @type array $has Extracted media counts. {
     
    354350        // `<img src>` tags.
    355351        if ( stripos( $richtext, 'src=' ) !== false ) {
    356             preg_match_all( '#src=(["\'])([^"\']+)\1#i', $richtext, $img_srcs );  // matches src="text" and src='text'
     352            preg_match_all( '#src=(["\'])([^"\']+)\1#i', $richtext, $img_srcs );  // Matches src="text" and src='text'.
    357353
    358354            // <img>.
     
    449445     * @param string $plaintext  Sanitized version of the content.
    450446     * @param array  $extra_args Bespoke data for a particular extractor (optional).
    451      *
    452447     * @return array {
    453448     *     @type array $has Extracted media counts. {
     
    477472
    478473                    $shortcode               = array();
    479                     $shortcode['attributes'] = $attrs;             // Attributes
    480                     $shortcode['content']    = $matches[5][ $i ];  // Content
    481                     $shortcode['type']       = $shortcode_name;    // Shortcode
    482                     $shortcode['original']   = $matches[0][ $i ];  // Entire shortcode
     474                    $shortcode['attributes'] = $attrs;             // Attributes.
     475                    $shortcode['content']    = $matches[5][ $i ];  // Content.
     476                    $shortcode['type']       = $shortcode_name;    // Shortcode.
     477                    $shortcode['original']   = $matches[0][ $i ];  // Entire shortcode.
    483478
    484479                    $data['shortcodes'][] = $shortcode;
     
    511506     * @param string $plaintext  Sanitized version of the content.
    512507     * @param array  $extra_args Bespoke data for a particular extractor (optional).
    513      *
    514508     * @return array {
    515509     *     @type array $has Extracted media counts. {
     
    591585     * @param string $plaintext  Sanitized version of the content.
    592586     * @param array  $extra_args Bespoke data for a particular extractor (optional).
    593      *
    594587     * @return array {
    595588     *     @type array $has Extracted media counts. {
     
    644637        }
    645638
    646         // <a href="*.mp3"> tags
     639        // <a href="*.mp3"> tags.
    647640        foreach ( $audio_types as $extension ) {
    648641            $extension = '.' . $extension;
     
    689682     * @param string $plaintext  Sanitized version of the content.
    690683     * @param array  $extra_args Bespoke data for a particular extractor (optional).
    691      *
    692684     * @return array {
    693685     *     @type array $has Extracted media counts. {
     
    768760     * @param string $plaintext  Sanitized version of the content.
    769761     * @param array  $extra_args Bespoke data for a particular extractor (optional).
    770      *
    771762     * @return array
    772763     */
     
    794785                    $image_size = array( $extra_args['width'], $extra_args['height'] );
    795786                } else {
    796                     $image_size = $extra_args['width'];  // e.g. "thumb", "medium".
     787                    $image_size = $extra_args['width'];  // E.g. "thumb", "medium".
    797788                }
    798789
     
    868859     * @param string $plaintext  Sanitized version of the content.
    869860     * @param array  $extra_args Contains data that an implementation might need beyond the defaults.
    870      *
    871861     * @return array
    872862     */
     
    890880                    $image_size = array( $extra_args['width'], $extra_args['height'] );
    891881                } else {
    892                     $image_size = $extra_args['width'];  // e.g. "thumb", "medium".
     882                    $image_size = $extra_args['width'];  // E.g. "thumb", "medium".
    893883                }
    894884            } else {
     
    919909     * @since 2.3.0
    920910     *
    921      * @param string $richtext
    922      *
     911     * @param string $richtext Content to sanitize.
    923912     * @return string
    924913     */
  • trunk/src/bp-core/classes/class-bp-members-suggestions.php

    r10108 r10355  
    8484    public function get_suggestions() {
    8585        $user_query = array(
    86             'count_total'     => '',  // Prevents total count
     86            'count_total'     => '',  // Prevents total count.
    8787            'populate_extras' => false,
    8888            'type'            => 'alphabetical',
  • trunk/src/bp-core/classes/class-bp-suggestions.php

    r10108 r10355  
    5757     * Constructor.
    5858     *
     59     * @since 2.1.0
     60     *
    5961     * @param array $args Optional. If set, used as the parameters for the suggestions service query.
    60      * @since 2.1.0
    6162     */
    6263    public function __construct( array $args = array() ) {
     
    6970     * Set the parameters for the suggestions service query.
    7071     *
     72     * @since 2.1.0
     73     *
    7174     * @param array $args {
    7275     *     @type int    $limit Maximum number of results to display. Optional, default: 16.
     
    7578     *                         Mandatory.
    7679     * }
    77      * @since 2.1.0
    7880     */
    7981    public function set_query( array $args = array() ) {
  • trunk/src/bp-core/classes/class-bp-user-query.php

    r10248 r10355  
    147147    public function __construct( $query = null ) {
    148148
    149         // Store the raw query vars for later access
     149        // Store the raw query vars for later access.
    150150        $this->query_vars_raw = $query;
    151151
    152         // Allow extending classes to register action/filter hooks
     152        // Allow extending classes to register action/filter hooks.
    153153        $this->setup_hooks();
    154154
     
    184184
    185185            // Get user ids
    186             // If the user_ids param is present, we skip the query
     186            // If the user_ids param is present, we skip the query.
    187187            if ( false !== $this->query_vars['user_ids'] ) {
    188188                $this->user_ids = wp_parse_id_list( $this->query_vars['user_ids'] );
     
    193193        }
    194194
    195         // Bail if no user IDs were found
     195        // Bail if no user IDs were found.
    196196        if ( empty( $this->user_ids ) ) {
    197197            return;
    198198        }
    199199
    200         // Fetch additional data. First, using WP_User_Query
     200        // Fetch additional data. First, using WP_User_Query.
    201201        $this->do_wp_user_query();
    202202
    203         // Get BuddyPress specific user data
     203        // Get BuddyPress specific user data.
    204204        $this->populate_extras();
    205205    }
     
    231231        $bp = buddypress();
    232232
    233         // Default query variables used here
     233        // Default query variables used here.
    234234        $type         = '';
    235235        $per_page     = 0;
     
    244244        extract( $this->query_vars );
    245245
    246         // Setup the main SQL query container
     246        // Setup the main SQL query container.
    247247        $sql = array(
    248248            'select'  => '',
     
    253253        );
    254254
    255         /** TYPE **************************************************************/
     255        /* TYPE **************************************************************/
    256256
    257257        // Determines the sort order, which means it also determines where the
    258         // user IDs are drawn from (the SELECT and WHERE statements)
     258        // user IDs are drawn from (the SELECT and WHERE statements).
    259259        switch ( $type ) {
    260260
    261261            // 'online' query happens against the last_activity usermeta key
    262262            // Filter 'bp_user_query_online_interval' to modify the
    263             // number of minutes used as an interval
     263            // number of minutes used as an interval.
    264264            case 'online' :
    265265                $this->uid_name = 'user_id';
     
    282282
    283283            // 'active', 'newest', and 'random' queries
    284             // all happen against the last_activity usermeta key
     284            // all happen against the last_activity usermeta key.
    285285            case 'active' :
    286286            case 'newest' :
     
    303303                break;
    304304
    305             // 'popular' sorts by the 'total_friend_count' usermeta
     305            // 'popular' sorts by the 'total_friend_count' usermeta.
    306306            case 'popular' :
    307307                $this->uid_name = 'user_id';
     
    314314                break;
    315315
    316             // 'alphabetical' sorts depend on the xprofile setup
     316            // 'alphabetical' sorts depend on the xprofile setup.
    317317            case 'alphabetical' :
    318318
     
    321321                // can do so if xprofile sync is enabled, or if xprofile is inactive.
    322322                //
    323                 // @todo remove need for bp_is_active() check
     323                // @todo remove need for bp_is_active() check.
    324324                if ( ! bp_disable_profile_sync() || ! bp_is_active( 'xprofile' ) ) {
    325325                    $this->uid_name = 'ID';
     
    330330
    331331                // When profile sync is disabled, alphabetical sorts must happen against
    332                 // the xprofile table
     332                // the xprofile table.
    333333                } else {
    334334                    $this->uid_name = 'user_id';
     
    347347                break;
    348348
    349             // Any other 'type' falls through
     349            // Any other 'type' falls through.
    350350            default :
    351351                $this->uid_name = 'ID';
     
    355355                // In this case, we assume that a plugin is
    356356                // handling order, so we leave those clauses
    357                 // blank
    358 
     357                // blank.
    359358                break;
    360359        }
    361360
    362         /** WHERE *************************************************************/
    363 
    364         // 'include' - User ids to include in the results
     361        /* WHERE *************************************************************/
     362
     363        // 'include' - User ids to include in the results.
    365364        $include     = false !== $include ? wp_parse_id_list( $include ) : array();
    366365        $include_ids = $this->get_include_ids( $include );
     
    370369        }
    371370
    372         // 'exclude' - User ids to exclude from the results
     371        // 'exclude' - User ids to exclude from the results.
    373372        if ( false !== $exclude ) {
    374373            $exclude_ids    = implode( ',', wp_parse_id_list( $exclude ) );
     
    377376
    378377        // 'user_id' - When a user id is passed, limit to the friends of the user
    379         // @todo remove need for bp_is_active() check
     378        // @todo remove need for bp_is_active() check.
    380379        if ( ! empty( $user_id ) && bp_is_active( 'friends' ) ) {
    381380            $friend_ids = friends_get_friend_user_ids( $user_id );
     
    386385
    387386            // If the user has no friends, the query should always
    388             // return no users
     387            // return no users.
    389388            } else {
    390389                $sql['where'][] = $this->no_results['where'];
     
    392391        }
    393392
    394         /** Search Terms ******************************************************/
     393        /* Search Terms ******************************************************/
    395394
    396395        // 'search_terms' searches user_login and user_nicename
    397         // xprofile field matches happen in bp_xprofile_bp_user_query_search()
     396        // xprofile field matches happen in bp_xprofile_bp_user_query_search().
    398397        if ( false !== $search_terms ) {
    399398            $search_terms = bp_esc_like( wp_kses_normalize_entities( $search_terms ) );
     
    438437
    439438        // 'meta_key', 'meta_value' allow usermeta search
    440         // To avoid global joins, do a separate query
     439        // To avoid global joins, do a separate query.
    441440        if ( false !== $meta_key ) {
    442441            $meta_sql = $wpdb->prepare( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = %s", $meta_key );
     
    455454        }
    456455
    457         // 'per_page', 'page' - handles LIMIT
     456        // 'per_page', 'page' - handles LIMIT.
    458457        if ( !empty( $per_page ) && !empty( $page ) ) {
    459458            $sql['limit'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
     
    472471        $sql = apply_filters_ref_array( 'bp_user_query_uid_clauses', array( $sql, &$this ) );
    473472
    474         // Assemble the query chunks
     473        // Assemble the query chunks.
    475474        $this->uid_clauses['select']  = $sql['select'];
    476475        $this->uid_clauses['where']   = ! empty( $sql['where'] ) ? 'WHERE ' . implode( ' AND ', $sql['where'] ) : '';
     
    502501        global $wpdb;
    503502
    504         // If counting using SQL_CALC_FOUND_ROWS, set it up here
     503        // If counting using SQL_CALC_FOUND_ROWS, set it up here.
    505504        if ( 'sql_calc_found_rows' == $this->query_vars['count_total'] ) {
    506505            $this->uid_clauses['select'] = str_replace( 'SELECT', 'SELECT SQL_CALC_FOUND_ROWS', $this->uid_clauses['select'] );
    507506        }
    508507
    509         // Get the specific user ids
     508        // Get the specific user ids.
    510509        $this->user_ids = $wpdb->get_col( "{$this->uid_clauses['select']} {$this->uid_clauses['where']} {$this->uid_clauses['orderby']} {$this->uid_clauses['order']} {$this->uid_clauses['limit']}" );
    511510
    512         // Get the total user count
     511        // Get the total user count.
    513512        if ( 'sql_calc_found_rows' == $this->query_vars['count_total'] ) {
    514513
     
    557556        $wp_user_query = new WP_User_Query( apply_filters( 'bp_wp_user_query_args', array(
    558557
    559             // Relevant
     558            // Relevant.
    560559            'fields'      => $fields,
    561560            'include'     => $this->user_ids,
    562561
    563562            // Overrides
    564             'blog_id'     => 0,    // BP does not require blog roles
    565             'count_total' => false // We already have a count
     563            'blog_id'     => 0,    // BP does not require blog roles.
     564            'count_total' => false // We already have a count.
    566565
    567566        ), $this ) );
     
    583582        }
    584583
    585         // Reindex for easier matching
     584        // Reindex for easier matching.
    586585        $r = array();
    587586        foreach ( $wp_user_query->results as $u ) {
     
    589588        }
    590589
    591         // Match up to the user ids from the main query
     590        // Match up to the user ids from the main query.
    592591        foreach ( $this->user_ids as $key => $uid ) {
    593592            if ( isset( $r[ $uid ] ) ) {
     
    595594
    596595                // The BP template functions expect an 'id'
    597                 // (as opposed to 'ID') property
     596                // (as opposed to 'ID') property.
    598597                $this->results[ $uid ]->id = $uid;
    599598
    600             // remove user ID from original user_ids property
     599            // Remove user ID from original user_ids property.
    601600            } else {
    602601                unset( $this->user_ids[ $key ] );
     
    619618     * @param array $include Sanitized array of user IDs, as passed to the 'include'
    620619     *                       parameter of the class constructor.
    621      *
    622620     * @return array The list of users to which the main query should be
    623621     *               limited.
     
    640638        global $wpdb;
    641639
    642         // Bail if no users
     640        // Bail if no users.
    643641        if ( empty( $this->user_ids ) || empty( $this->results ) ) {
    644642            return;
     
    647645        // Bail if the populate_extras flag is set to false
    648646        // In the case of the 'popular' sort type, we force
    649         // populate_extras to true, because we need the friend counts
     647        // populate_extras to true, because we need the friend counts.
    650648        if ( 'popular' == $this->query_vars['type'] ) {
    651649            $this->query_vars['populate_extras'] = 1;
     
    656654        }
    657655
    658         // Turn user ID's into a query-usable, comma separated value
     656        // Turn user ID's into a query-usable, comma separated value.
    659657        $user_ids_sql = implode( ',', wp_parse_id_list( $this->user_ids ) );
    660658
     
    679677        do_action_ref_array( 'bp_user_query_populate_extras', array( $this, $user_ids_sql ) );
    680678
    681         // Fetch last_active data from the activity table
     679        // Fetch last_active data from the activity table.
    682680        $last_activities = BP_Core_User::get_last_activity( $this->user_ids );
    683681
    684         // Set a last_activity value for each user, even if it's empty
     682        // Set a last_activity value for each user, even if it's empty.
    685683        foreach ( $this->results as $user_id => $user ) {
    686684            $user_last_activity = isset( $last_activities[ $user_id ] ) ? $last_activities[ $user_id ]['date_recorded'] : '';
     
    691689        // We want the three following pieces of info from usermeta:
    692690        // - friend count
    693         // - latest update
     691        // - latest update.
    694692        $total_friend_count_key = bp_get_user_meta_key( 'total_friend_count' );
    695693        $bp_latest_update_key   = bp_get_user_meta_key( 'bp_latest_update'   );
    696694
    697         // total_friend_count must be set for each user, even if its
    698         // value is 0
     695        // Total_friend_count must be set for each user, even if its
     696        // value is 0.
    699697        foreach ( $this->results as $uindex => $user ) {
    700698            $this->results[$uindex]->total_friend_count = 0;
    701699        }
    702700
    703         // Create, prepare, and run the separate usermeta query
     701        // Create, prepare, and run the separate usermeta query.
    704702        $user_metas = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, meta_key, meta_value FROM {$wpdb->usermeta} WHERE meta_key IN (%s,%s) AND user_id IN ({$user_ids_sql})", $total_friend_count_key, $bp_latest_update_key ) );
    705703
     
    723721
    724722        // When meta_key or meta_value have been passed to the query,
    725         // fetch the resulting values for use in the template functions
     723        // fetch the resulting values for use in the template functions.
    726724        if ( ! empty( $this->query_vars['meta_key'] ) ) {
    727725            $meta_sql = array(
     
    758756     * @param string|array $member_types Array or comma-separated list of member types.
    759757     * @param string       $operator     'IN' or 'NOT IN'.
    760      *
    761758     * @return string
    762759     */
     
    805802        $clause = '';
    806803
    807         // no_results clauses are the same between IN and NOT IN.
     804        // The no_results clauses are the same between IN and NOT IN.
    808805        if ( false !== strpos( $sql_clauses['where'], '0 = 1' ) ) {
    809806            $clause = $this->no_results['where'];
  • trunk/src/bp-core/classes/class-bp-walker-nav-menu-checklist.php

    r10108 r10355  
    103103        }
    104104
    105         // Menu item hidden fields
     105        // Menu item hidden fields.
    106106        $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
    107107        $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />';
  • trunk/src/bp-core/classes/class-bp-walker-nav-menu.php

    r10108 r10355  
    5252     * @param array $elements  See {@link Walker::walk()}.
    5353     * @param int   $max_depth See {@link Walker::walk()}.
    54      *
    5554     * @return string See {@link Walker::walk()}.
    5655     */
     
    6160        $output = '';
    6261
    63         if ( $max_depth < -1 ) // invalid parameter
     62        if ( $max_depth < -1 ) // Invalid parameter.
    6463            return $output;
    6564
    66         if ( empty( $elements ) ) // nothing to walk
     65        if ( empty( $elements ) ) // Nothing to walk.
    6766            return $output;
    6867
    6968        $parent_field = $this->db_fields['parent'];
    7069
    71         // flat display
     70        // Flat display.
    7271        if ( -1 == $max_depth ) {
    7372
     
    119118
    120119        /*
    121          * if we are displaying all levels, and remaining children_elements is not empty,
    122          * then we got orphans, which should be displayed regardless
     120         * If we are displaying all levels, and remaining children_elements is not empty,
     121         * then we got orphans, which should be displayed regardless.
    123122         */
    124123        if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) {
     
    149148     */
    150149    public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
    151         // If we're someway down the tree, indent the HTML with the appropriate number of tabs
     150        // If we're someway down the tree, indent the HTML with the appropriate number of tabs.
    152151        $indent = $depth ? str_repeat( "\t", $depth ) : '';
    153152
     
    165164
    166165        // Add HTML ID
    167         $id = sanitize_html_class( $item->css_id . '-personal-li' );  // Backpat with BP pre-1.7
     166        $id = sanitize_html_class( $item->css_id . '-personal-li' );  // Backpat with BP pre-1.7.
    168167
    169168        /**
     
    182181        $output .= $indent . '<li' . $id . $class_names . '>';
    183182
    184         // Add href attribute
     183        // Add href attribute.
    185184        $attributes = ! empty( $item->link ) ? ' href="' . esc_url( $item->link ) . '"' : '';
    186185
    187         // Construct the link
     186        // Construct the link.
    188187        $item_output = $args->before;
    189188        $item_output .= '<a' . $attributes . '>';
Note: See TracChangeset for help on using the changeset viewer.