BP_Attachment_Cover_Image::script_data()
Build script datas for the Uploader UI.
Description
Return
(array) The javascript localization data
Source
File: bp-core/classes/class-bp-attachment-cover-image.php
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | public function script_data() { // Get default script data. $script_data = parent::script_data(); if ( bp_is_user() ) { $item_id = bp_displayed_user_id(); $script_data [ 'bp_params' ] = array ( 'object' => 'user' , 'item_id' => $item_id , 'has_cover_image' => bp_attachments_get_user_has_cover_image( $item_id ), 'nonces' => array ( 'remove' => wp_create_nonce( 'bp_delete_cover_image' ), ), ); // Set feedback messages. $script_data [ 'feedback_messages' ] = array ( 1 => __( 'Your new cover photo was uploaded successfully.' , 'buddyboss' ), 2 => __( 'There was a problem deleting your cover photo. Please try again.' , 'buddyboss' ), 3 => __( 'Your cover photo was deleted successfully!' , 'buddyboss' ), ); } elseif ( bp_is_group() ) { $item_id = bp_get_current_group_id(); $script_data [ 'bp_params' ] = array ( 'object' => 'group' , 'item_id' => bp_get_current_group_id(), 'has_cover_image' => bp_attachments_get_group_has_cover_image( $item_id ), 'nonces' => array ( 'remove' => wp_create_nonce( 'bp_delete_cover_image' ), ), ); // Set feedback messages. $script_data [ 'feedback_messages' ] = array ( 1 => __( 'The group cover photo was uploaded successfully.' , 'buddyboss' ), 2 => __( 'There was a problem deleting the group cover photo. Please try again.' , 'buddyboss' ), 3 => __( 'The group cover photo was deleted successfully!' , 'buddyboss' ), ); } else { /** * Filters the cover photo params to include specific BuddyPress params for your object. * e.g. cover photo for blogs single item. * * @since BuddyPress 2.4.0 * * @param array $value The cover photo specific BuddyPress parameters. */ $script_data [ 'bp_params' ] = apply_filters( 'bp_attachment_cover_image_params' , array () ); } // Include our specific js & css. $script_data [ 'extra_js' ] = array ( 'bp-cover-image' ); $script_data [ 'extra_css' ] = array ( 'bp-avatar' ); /** * Filters the cover photo script data. * * @since BuddyPress 2.4.0 * * @param array $script_data Array of data for the cover photo. */ return apply_filters( 'bp_attachments_cover_image_script_data' , $script_data ); } |
Changelog
Version | Description |
---|---|
BuddyPress 2.4.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.