bp_nouveau_ajax_document_folder_delete()
Delete folder.
Description
Source
File: bp-templates/bp-nouveau/includes/document/ajax.php
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 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 | function bp_nouveau_ajax_document_folder_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 = filter_input( INPUT_POST, '_wpnonce' , FILTER_SANITIZE_STRING ); $check = 'bp_nouveau_media' ; // Nonce check! if ( empty ( $nonce ) || ! wp_verify_nonce( $nonce , $check ) ) { wp_send_json_error( $response ); } if ( empty ( $_POST [ 'folder_id' ] ) ) { $response [ 'feedback' ] = sprintf( '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>' , esc_html__( 'Please provide ID of folder to delete.' , 'buddyboss' ) ); wp_send_json_error( $response ); } $folder_id = filter_input( INPUT_POST, 'folder_id' , FILTER_VALIDATE_INT ); if ( ! bp_folder_user_can_delete( $folder_id ) ) { $response [ 'feedback' ] = sprintf( '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>' , esc_html__( 'You do not have permission to delete this folder.' , 'buddyboss' ) ); wp_send_json_error( $response ); } // delete folder. $folder_id = bp_folder_delete( array ( 'id' => $folder_id ) ); if ( ! $folder_id ) { wp_send_json_error( $response ); } $group_id = ! empty ( $_POST [ 'group_id' ] ) ? (int) $_POST [ 'group_id' ] : false; if ( ! empty ( $group_id ) && bp_is_active( 'groups' ) ) { $group_link = bp_get_group_permalink( groups_get_group( $group_id ) ); $redirect_url = trailingslashit( $group_link . '/documents/' ); } else { $redirect_url = trailingslashit( bp_displayed_user_domain() . bp_get_document_slug() ); } wp_send_json_success( array ( 'redirect_url' => $redirect_url , ) ); } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.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.