bp_nouveau_ajax_document_edit_folder()
Rename folder.
Description
Source
File: bp-templates/bp-nouveau/includes/document/ajax.php
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 | function bp_nouveau_ajax_document_edit_folder() { $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 [ 'title' ] ) ) { $response [ 'feedback' ] = sprintf( '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>' , esc_html__( 'Please enter title of folder.' , 'buddyboss' ) ); wp_send_json_error( $response ); } if ( strpbrk ( $_POST [ 'title' ], "\\/?%*:|\"<>" ) !== false ) { $response [ 'feedback' ] = sprintf( '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>' , esc_html__( 'Invalid folder name' , 'buddyboss' ) ); wp_send_json_error( $response ); } // save folder. $title = $_POST [ 'title' ]; $id = ! empty ( $_POST [ 'id' ] ) ? (int) $_POST [ 'id' ] : 0; $group_id = ! empty ( $_POST [ 'group_id' ] ) ? (int) $_POST [ 'group_id' ] : 0; if ( (int) $id > 0 ) { $has_access = bp_folder_user_can_edit( $id ); if ( ! $has_access ) { $response [ 'feedback' ] = sprintf( '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>' , esc_html__( 'You don\'t have permission to rename this folder' , 'buddyboss' ) ); wp_send_json_error( $response ); } } if ( ! empty ( $_POST [ 'privacy' ] ) ) { $privacy = $_POST [ 'privacy' ]; } else { $folder_id = bp_document_get_root_parent_id( $_POST [ 'id' ] ); $folder = new BP_Document_Folder( $folder_id ); $privacy = $folder ->privacy; } if ( $group_id > 0 ) { $privacy = 'grouponly' ; } $folder_id = bp_document_rename_folder( $id , $title , $privacy ); if ( ! $folder_id ) { $response [ 'feedback' ] = sprintf( '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>' , esc_html__( 'There was a problem when trying to rename the folder.' , 'buddyboss' ) ); wp_send_json_error( $response ); } wp_send_json_success( array ( 'message' => 'success' , ) ); } |
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.