bp_nouveau_ajax_document_document_save ()

保存文档

描述

文件:bp-templates / bp-nouveau /包括/文档/ ajax.php

function bp_nouveau_ajax_document_document_save() {$response = array('feedback' => sprintf('

%s

', esc_html__('执行此操作有问题。请再试一次。', 'buddyboss')),);//如果不是POST操作,则保释。如果(!Bp_is_post_request ()) {wp_send_json_error($response);} if(空的($_POST['_wpnonce'])) {wp_send_json_error($response);} //使用默认nonce。$nonce = filter_input(INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING);检查美元=“bp_nouveau_media”; // Nonce check! if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, $check ) ) { wp_send_json_error( $response ); } if ( empty( $_POST['documents'] ) ) { $response['feedback'] = sprintf( '

%s

', esc_html__( 'Please upload a document before saving.', 'buddyboss' ) ); wp_send_json_error( $response ); } if ( ! is_user_logged_in() ) { $response['feedback'] = sprintf( '

%s

', esc_html__( 'Please login to upload a document.', 'buddyboss' ) ); wp_send_json_error( $response ); } if ( isset( $_POST['documents'] ) && ! empty( $_POST['documents'] ) && isset( $_POST['folder_id'] ) && (int) $_POST['folder_id'] > 0 ) { $documents = $_POST['documents']; $folder_id = (int) $_POST['folder_id']; if ( ! empty( $documents ) && is_array( $documents ) ) { // set folder id for document. foreach ( $documents as $key => $document ) { if ( 0 === (int) $document['folder_id'] ) { $_POST['documents'][ $key ]['folder_id'] = $folder_id; } } } } // handle media uploaded. $document_ids = bp_document_add_handler( $_POST['documents'] ); $document = ''; if ( ! empty( $document_ids ) ) { ob_start(); if ( bp_has_document( array( 'include' => implode( ',', $document_ids ) ) ) ) { while ( bp_document() ) { bp_the_document(); bp_get_template_part( 'document/document-entry' ); } } $document = ob_get_contents(); ob_end_clean(); } wp_send_json_success( array( 'document' => $document ) ); }

更新日志

更新日志
版本 描述
BuddyBoss 1.4.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队