bp_nouveau_ajax_document_folder_save ()

保存的文件夹

描述

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

function bp_nouveau_ajax_document_folder_save() {$response = array('feedback' => 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 ( ! is_user_logged_in() ) { $response['feedback'] = esc_html__( 'Please login to create a folder.', 'buddyboss' ); wp_send_json_error( $response ); } if ( empty( $_POST['title'] ) ) { $response['feedback'] = esc_html__( 'Please enter title of folder.', 'buddyboss' ); wp_send_json_error( $response ); } if ( strpbrk( $_POST['title'], "\\/?%*:|\"<>" ) !== false ) { $response['feedback'] = esc_html__( "Invalid folder name", 'buddyboss' ); wp_send_json_error( $response ); } // save media. $id = ! empty( $_POST['folder_id'] ) ? filter_input( INPUT_POST, 'folder_id', FILTER_VALIDATE_INT ) : false; $group_id = ! empty( $_POST['group_id'] ) ? (int) $_POST['group_id'] : false; $title = wp_strip_all_tags( $_POST['title'] ); $privacy = ! empty( $_POST['privacy'] ) ? filter_input( INPUT_POST, 'privacy', FILTER_SANITIZE_STRING ) : 'public'; $parent = ! empty( $_POST['parent'] ) ? (int) filter_input( INPUT_POST, 'parent', FILTER_VALIDATE_INT ) : 0; $folder_id = ! empty( $_POST['folder_id'] ) ? (int) filter_input( INPUT_POST, 'folder_id', FILTER_VALIDATE_INT ) : 0; if ( $parent > 0 ) { $id = false; } if ( ! $id && ! $parent ) { $parent = $folder_id; } if ( $parent > 0 ) { $parent_folder = BP_Document_Folder::get_folder_data( array( $parent ) ); $privacy = $parent_folder[0]->privacy; } if ( (int) $parent > 0 ) { $has_access = bp_folder_user_can_edit( $parent ); if ( ! $has_access ) { $response['feedback'] = esc_html__( 'You don\'t have a permission to create a folder inside this folder.', 'buddyboss' ); wp_send_json_error( $response ); } } $folder_id = bp_folder_add( array( 'id' => $id, 'title' => $title, 'privacy' => $privacy, 'group_id' => $group_id, 'parent' => $parent, ) ); if ( ! $folder_id ) { $response['feedback'] = esc_html__( 'There was a problem when trying to create the folder.', 'buddyboss' ); wp_send_json_error( $response ); } $folder = new BP_Document_Folder( $folder_id ); if ( $group_id > 0 ) { $ul = bp_document_user_document_folder_tree_view_li_html( $folder->user_id, $group_id ); } else { $ul = bp_document_user_document_folder_tree_view_li_html( bp_loggedin_user_id() ); } $document = ''; if ( ! empty( $folder_id ) ) { ob_start(); if ( bp_has_folders( array( 'include' => $folder_id ) ) ) { while ( bp_folder() ) { bp_the_folder(); bp_get_template_part( 'document/document-entry' ); } } $document = ob_get_contents(); ob_end_clean(); } $response = array( 'document' => $document, 'tree_view' => $ul, 'folder_id' => $folder_id, ); wp_send_json_success( $response ); }

更新日志

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

问题吗?

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