bp_nouveau_ajax_document_update_file_name ()

更新文档名称。

描述

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

function bp_nouveau_ajax_document_update_file_name() {$response = array('feedback' => esc_html__('执行此操作有问题。请再试一次。', 'buddyboss'),);//如果不是POST操作,则保释。如果(!Bp_is_post_request ()) {wp_send_json_error($response);} $document_id = !($_POST['document_id']) ?(int) filter_input(INPUT_POST, 'document_id', FILTER_SANITIZE_STRING): 0;$ attachment_document_id = ! empty( $_POST['attachment_document_id'] ) ? (int) filter_input( INPUT_POST, 'attachment_document_id', FILTER_SANITIZE_STRING ) : 0; $title = ! empty( $_POST['name'] ) ? filter_input( INPUT_POST, 'name', FILTER_SANITIZE_STRING ) : ''; $type = ! empty( $_POST['document_type'] ) ? filter_input( INPUT_POST, 'document_type', FILTER_SANITIZE_STRING ) : ''; if ( 'document' === $type ) { if ( 0 === $document_id || 0 === $attachment_document_id || '' === $title ) { 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 a permission to rename the document.", 'buddyboss' ); wp_send_json_error( $response ); } } $document = bp_document_rename_file( $document_id, $attachment_document_id, $title ); if ( isset( $document['document_id'] ) && $document['document_id'] > 0 ) { wp_send_json_success( array( 'message' => 'success', 'response' => $document, ) ); } else { if ( '' === $document ) { wp_send_json_error( $response ); } else { $response = array( 'feedback' => $document, ); wp_send_json_error( $response ); } } } else { if ( 0 === $document_id || '' === $title ) { wp_send_json_error( $response ); } if ( strpbrk( $title, "\\/?%*:|\"<>" ) !== false ) { $response['feedback'] = esc_html__( "Invalid folder name", 'buddyboss' ); wp_send_json_error( $response ); } if ( (int) $document_id > 0 ) { $has_access = bp_folder_user_can_edit( $document_id ); if ( ! $has_access ) { $response['feedback'] = esc_html__( 'You don\'t have permission to rename folder', 'buddyboss' ); wp_send_json_error( $response ); } } $folder = bp_document_rename_folder( $document_id, $title ); $response = array( 'document_id' => $document_id, 'title' => $title, ); if ( $folder > 0 ) { wp_send_json_success( array( 'message' => 'success', 'response' => $response, ) ); } else { wp_send_json_error( $response ); } } }

更新日志

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

问题吗?

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