bp_nouveau_ajax_document_move()
Ajax document move.
Description
Source
File: bp-templates/bp-nouveau/includes/document/ajax.php
function bp_nouveau_ajax_document_move() { $response = array( 'feedback' => 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 ); } // Move document. $folder_id = ! empty( $_POST['folder_id'] ) ? (int) $_POST['folder_id'] : 0; $document_id = ! empty( $_POST['document_id'] ) ? (int) $_POST['document_id'] : 0; $group_id = ! empty( $_POST['group_id'] ) ? (int) $_POST['group_id'] : 0; if ( 0 === $document_id ) { wp_send_json_error( $response ); } if ( (int) $document_id > 0 ) { $has_access = bp_document_user_can_edit( $document_id ); if ( ! $has_access ) { $response['feedback'] = esc_html__( 'You don\'t have permission to move this document.', 'buddyboss' ); wp_send_json_error( $response ); } } if ( (int) $folder_id > 0 ) { $has_access = bp_folder_user_can_edit( $folder_id ); if ( ! $has_access ) { $response['feedback'] = esc_html__( 'You don\'t have permission to move this document.', 'buddyboss' ); wp_send_json_error( $response ); } } $document = bp_document_move_document_to_folder( $document_id, $folder_id, $group_id ); if ( $document > 0 ) { $content = ''; ob_start(); if ( bp_has_document( bp_ajax_querystring( 'document' ) ) ) : if ( empty( $_POST['page'] ) || 1 === (int) filter_input( INPUT_POST, 'page', FILTER_SANITIZE_STRING ) ) : ?> <div class="document-data-table-head"> <span class="data-head-sort-label"><?php esc_html_e( 'Sort By:', 'buddyboss' ); ?></span> <div class="data-head data-head-name"> <span> <?php esc_html_e( 'Name', 'buddyboss' ); ?> <i class="bb-icon-triangle-fill"></i> </span> </div> <div class="data-head data-head-modified"> <span> <?php esc_html_e( 'Modified', 'buddyboss' ); ?> <i class="bb-icon-triangle-fill"></i> </span> </div> <div class="data-head data-head-visibility"> <span> <?php esc_html_e( 'Visibility', 'buddyboss' ); ?> <i class="bb-icon-triangle-fill"></i> </span> </div> </div><!-- .document-data-table-head --> <div id="media-folder-document-data-table"> <?php bp_get_template_part( 'document/activity-document-move' ); bp_get_template_part( 'document/activity-document-folder-move' ); endif; while ( bp_document() ) : bp_the_document(); bp_get_template_part( 'document/document-entry' ); endwhile; if ( bp_document_has_more_items() ) : ?> <div class="pager"> <div class="dt-more-container load-more"> <a class="button outline full" href="<?php bp_document_load_more_link(); ?>"><?php esc_html_e( 'Load More', 'buddyboss' ); ?></a> </div> </div> <?php endif; if ( empty( $_POST['page'] ) || 1 === (int) filter_input( INPUT_POST, 'page', FILTER_SANITIZE_STRING ) ) : ?> </div> <!-- #media-folder-document-data-table --> <?php endif; else : bp_nouveau_user_feedback( 'media-loop-document-none' ); endif; $content .= ob_get_clean(); wp_send_json_success( array( 'message' => 'success', 'html' => $content, ) ); } else { wp_send_json_error( $response ); } }
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.