PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.0
Forumax – AI Powered Advanced Community Forum Plugin v2.5.0
2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 All 30 releases
← All changes | includes/features/bbpc_attachments/code/front.php +15 -19 trunk → 2.5.0 View file →
@@ -118,26 +118,21 @@
118 118
119 119 public function process_attachments( $reply_id, $topic_id, $forum_id, $anonymous_data = null, $reply_author = null ) {
120 120 $uploads = [];
121 121 $revision = false;
122 - $errors = new gdbbp_Error();
123 122
124 123 if ( ! empty( $_FILES ) && ! empty( $_FILES['bbpc_attachment'] ) ) {
125 124 require_once ABSPATH . 'wp-admin/includes/file.php';
126 125
126 + $errors = new gdbbp_Error();
127 127 $overrides = [
128 128 'test_form' => false,
129 - 'upload_error_handler' => 'forumax_bbattachment_handle_upload_error',
129 + 'upload_error_handler' => 'bbpc_bbattachment_handle_upload_error',
130 130 ];
131 131
132 - foreach ( (array) $_FILES['bbpc_attachment']['error'] as $key => $error ) {
132 + foreach ( $_FILES['bbpc_attachment']['error'] as $key => $error ) {
133 133 $file_name = $_FILES['bbpc_attachment']['name'][ $key ];
134 134
135 - // Empty file inputs are not errors.
136 - if ( UPLOAD_ERR_NO_FILE === (int) $error ) {
137 - continue;
138 - }
139 -
140 135 if ( $error == UPLOAD_ERR_OK ) {
141 136 $file = [
142 137 'name' => $file_name,
143 138 'type' => $_FILES['bbpc_attachment']['type'][ $key ],
@@ -159,30 +154,31 @@
159 154 } else {
160 155 $errors->add( 'bbpc_upload', 'File exceeds allowed file size.', $file_name );
161 156 }
162 157 } else {
163 - switch ( (int) $error ) {
164 - case UPLOAD_ERR_INI_SIZE:
158 + switch ( $error ) {
159 + default:
160 + case 'UPLOAD_ERR_NO_FILE':
161 + $errors->add( 'php_upload', 'File not uploaded.', $file_name );
162 + break;
163 + case 'UPLOAD_ERR_INI_SIZE':
165 164 $errors->add( 'php_upload', 'Upload file size exceeds PHP maximum file size allowed.', $file_name );
166 165 break;
167 - case UPLOAD_ERR_FORM_SIZE:
166 + case 'UPLOAD_ERR_FORM_SIZE':
168 167 $errors->add( 'php_upload', 'Upload file size exceeds FORM specified file size.', $file_name );
169 168 break;
170 - case UPLOAD_ERR_PARTIAL:
169 + case 'UPLOAD_ERR_PARTIAL':
171 170 $errors->add( 'php_upload', 'Upload file only partially uploaded.', $file_name );
172 171 break;
173 - case UPLOAD_ERR_CANT_WRITE:
172 + case 'UPLOAD_ERR_CANT_WRITE':
174 173 $errors->add( 'php_upload', 'Can\'t write file to the disk.', $file_name );
175 174 break;
176 - case UPLOAD_ERR_NO_TMP_DIR:
175 + case 'UPLOAD_ERR_NO_TMP_DIR':
177 176 $errors->add( 'php_upload', 'Temporary folder for upload is missing.', $file_name );
178 177 break;
179 - case UPLOAD_ERR_EXTENSION:
178 + case 'UPLOAD_ERR_EXTENSION':
180 179 $errors->add( 'php_upload', 'Server extension restriction stopped upload.', $file_name );
181 180 break;
182 - default:
183 - $errors->add( 'php_upload', 'File not uploaded.', $file_name );
184 - break;
185 181 }
186 182 }
187 183 }
188 184 }
@@ -258,9 +254,9 @@
258 254
259 255 $attachments = forumax_get_post_attachments( $id );
260 256
261 257 $post = get_post( $id );
262 - $author_id = $post ? $post->post_author : 0;
258 + $author_id = $post->post_author;
263 259
264 260 if ( ! empty( $attachments ) ) {
265 261 $content .= '<div class="bbp-attachments">';
266 262 $content .= '<h6>' . __( 'Attachments', 'forumax' ) . ':</h6>';