bp_nouveau_ajax_media_delete()
Delete media
Description
Return
(string) HTML
Source
File: bp-templates/bp-nouveau/includes/media/ajax.php
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | function bp_nouveau_ajax_media_delete() { $response = array ( 'feedback' => sprintf( '<div class="bp-feedback error bp-ajax-message"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>' , esc_html__( 'There was a problem performing this action. Please try again.' , 'buddyboss' ) ), ); // Bail if not a POST action. if ( ! bp_is_post_request() ) { wp_send_json_error( $response ); } if ( empty ( $_POST [ '_wpnonce' ] ) ) { wp_send_json_error( $response ); } // Use default nonce $nonce = $_POST [ '_wpnonce' ]; $check = 'bp_nouveau_media' ; // Nonce check! if ( empty ( $nonce ) || ! wp_verify_nonce( $nonce , $check ) ) { wp_send_json_error( $response ); } if ( empty ( $_POST [ 'media' ] ) ) { $response [ 'feedback' ] = sprintf( '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>' , esc_html__( 'Please select media to delete.' , 'buddyboss' ) ); wp_send_json_error( $response ); } $media = $_POST [ 'media' ]; $media_ids = array (); foreach ( $media as $media_id ) { // delete media $m_id = bp_media_delete( $media_id ); if ( $media_id ) { $media_ids [] = $m_id ; } } if ( count ( $media_ids ) != count ( $media ) ) { $response [ 'feedback' ] = sprintf( '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>' , esc_html__( 'There was a problem deleting media.' , 'buddyboss' ) ); wp_send_json_error( $response ); } wp_send_json_success( array ( 'media' => $media , ) ); } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.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.