Changeset 1688580
- Timestamp:
- 07/01/2017 12:18:35 AM (8 years ago)
- Location:
- frontend-uploader/trunk
- Files:
-
- 3 added
- 5 edited
-
frontend-uploader.php (modified) (32 diffs)
-
languages/frontend-uploader-ja.mo (added)
-
languages/frontend-uploader-ja.po (added)
-
lib/php/frontend-uploader-settings.php (modified) (1 diff)
-
lib/php/functions.php (modified) (5 diffs)
-
lib/php/recaptcha.php (modified) (1 diff)
-
lib/views/html-email.tpl.php (added)
-
readme.txt (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
frontend-uploader/trunk/frontend-uploader.php
r1468826 r1688580 4 4 Description: Allow your visitors to upload content and moderate it. 5 5 Author: Rinat Khaziev, Daniel Bachhuber 6 Version: 1. 16 Version: 1.2 7 7 Author URI: http://digitallyconscious.com 8 8 … … 26 26 27 27 // Define consts and bootstrap and dependencies 28 define( 'FU_VERSION', '1. 1' );28 define( 'FU_VERSION', '1.2' ); 29 29 define( 'FU_ROOT' , dirname( __FILE__ ) ); 30 30 define( 'FU_FILE_PATH' , FU_ROOT . '/' . basename( __FILE__ ) ); … … 44 44 public $settings_slug = 'frontend_uploader_settings'; 45 45 public $is_debug = false; 46 public $lang = 'en_US'; 47 public $lang_short = 'en'; 46 48 /** 47 49 * Should consist of fields to be proccessed automatically on content submission … … 110 112 add_filter( 'posts_where', array( $this, 'filter_posts_where' ) ); 111 113 112 113 114 $this->allowed_mime_types = $this->_get_mime_types(); 114 115 // Configuration filter to change manage permissions … … 119 120 add_action( 'fu_after_upload', array( $this, '_maybe_insert_images_into_post' ), 10, 3 ); 120 121 122 $this->_set_language(); 123 121 124 // Maybe enable Akismet protection 122 125 $this->_enable_akismet_protection(); … … 126 129 } 127 130 128 /** 129 * Slightly convoluted workaround to allow modifying of allowed MIME types for WP < 3.5, 130 * Workaround for IE sometimes setting image/pjepg and image/x-png for JPEGs and PNGs respectively 131 132 /** 133 * Set current language (used for captcha and jquery validate l18n ) 134 */ 135 function _set_language() { 136 // Filter is needed for wordpress.com 137 $this->lang = apply_filters( 'fu_wplang', get_bloginfo( 'language' ) ); 138 $this->lang_short = substr( $this->lang, 0, 2 ); 139 } 140 141 142 /** 143 * Add extra mime-types 144 * 145 * This is mostly legacy, and really should be deprecated or refactored due to unneccessary complexity 146 * 147 * @return [type] [description] 131 148 */ 132 149 function _get_mime_types() { 133 // Use wp_get_mime_types if available, fallback to get_allowed_mime_types() 134 $mime_types = function_exists( 'wp_get_mime_types' ) ? wp_get_mime_types() : get_allowed_mime_types() ; 150 $mime_types = wp_get_mime_types(); 135 151 $fu_mime_types = fu_get_mime_types(); 136 // Workaround for IE 137 $mime_types['jpg|jpe|jpeg|pjpg'] = 'image/pjpeg'; 138 $mime_types['png|xpng'] = 'image/x-png'; 152 139 153 $enabled = isset( $this->settings['enabled_files'] ) && is_array( $this->settings['enabled_files'] ) ? $this->settings['enabled_files'] : array(); 140 // Iterate through default extensions 154 155 // $fu_mime_types holds extra mimes that are not allowed by WP 141 156 foreach ( $fu_mime_types as $extension => $details ) { 142 157 // Skip if it's not in the settings … … 144 159 continue; 145 160 146 // Iterate through mime-types for this extension161 // Files have multiple mimes sometimes, we need to cover all of them 147 162 foreach ( $details['mimes'] as $ext_mime ) { 148 163 $mime_types[ $extension . '|' . $extension . sanitize_title_with_dashes( $ext_mime ) ] = $ext_mime; … … 158 173 unset( $mime_types[$ext_key] ); 159 174 } 175 160 176 return $mime_types; 161 177 } … … 191 207 } 192 208 193 194 209 /** 195 210 * Since 4.01 shortcode contents is texturized by default, … … 244 259 add_filter( 'upload_mimes', array( $this, '_get_mime_types' ), 999 ); 245 260 246 247 261 $media_ids = $errors = array(); 248 262 // Bail if there are no files 249 263 if ( empty( $_FILES ) ) 250 return false;264 return array(); 251 265 252 266 // File field name could be user defined, so we just get the first file … … 263 277 $k['name'] = sanitize_file_name( $k['name'] ); 264 278 279 // 280 if ( $k['error'] === 4 ) { 281 continue; 282 } 283 265 284 // Skip to the next file if upload went wrong 266 if ( $k['tmp_name'] == "" ) { 285 if ( $k['error'] !== 0 ) { 286 $errors['fu-error-media'][] = array( 'name' => $k['name'], 'code' => $k['error'] ); 267 287 continue; 268 288 } … … 291 311 elseif ( isset( $_POST['post_content'] ) ) 292 312 $caption = sanitize_text_field( $_POST['post_content'] ); 293 // TODO: remove or refactor 294 $filename = !empty( $this->settings['default_file_name'] ) ? $this->settings['default_file_name'] :pathinfo( $k['name'], PATHINFO_FILENAME );313 314 $filename = pathinfo( $k['name'], PATHINFO_FILENAME ); 295 315 $post_overrides = array( 296 316 'post_status' => $this->_is_public() ? 'publish' : 'private', … … 300 320 ); 301 321 302 // Obfuscate filename, just in case303 322 $m = $k; 304 $fn = explode( '.', $k['name'] ); 305 $k['name'] = uniqid() . '.' . end( $fn ); 323 324 // Obfuscate filename if setting is present 325 if ( isset( $this->settings['obfuscate_file_name'] ) && 'on' == $this->settings['obfuscate_file_name'] ){ 326 $fn = explode( '.', $k['name'] ); 327 $m['name'] = uniqid( mt_rand( 1, 1000 ) , true ) . '.' . end( $fn ); 328 } 306 329 307 330 // Trying to upload the file 308 $upload_id = media_handle_sideload( $k, (int) $post_id, $post_overrides['post_title'], $post_overrides ); 309 $m = $k; 331 $upload_id = media_handle_sideload( $m, (int) $post_id, $post_overrides['post_title'], $post_overrides ); 310 332 311 333 if ( !is_wp_error( $upload_id ) ) … … 432 454 433 455 $post_id = wp_insert_post( $post_array, true ); 456 457 458 434 459 // Something went wrong 435 460 if ( is_wp_error( $post_id ) ) { 436 $errors [] = 'fu-error-post';461 $errors = array( 'fu-error-post' => 1 ); 437 462 $success = false; 438 463 } else { … … 485 510 // Bail if something fishy is going on 486 511 if ( !wp_verify_nonce( $_POST['fu_nonce'], FU_NONCE ) ) { 487 wp_safe_redirect( add_query_arg( array( 'response' => 'fu-error', 'errors' => 'fu-nonce-failure' ), wp_get_referer() ) ); 512 wp_safe_redirect( add_query_arg( array( 'response' => 'fu-error', 'errors' => array( 'fu-nonce-failure' => 1 ) ), wp_get_referer() ) ); 513 exit; 514 } 515 516 // Bail if supplied post type is not allowed 517 if ( isset( $_POST['post_type'] ) && ! $this->is_allowed_post_type( sanitize_key( $_POST['post_type'] ) ) ) { 518 wp_safe_redirect( add_query_arg( array( 'response' => 'fu-error', 'errors' => array( 'fu-disallowed-post-type' => sanitize_key( $_POST['post_type'] ) ) ), wp_get_referer() ) ); 488 519 exit; 489 520 } … … 517 548 case 'post_media'; 518 549 $result = $this->_upload_post(); 550 551 519 552 if ( ! is_wp_error( $result['post_id'] ) ) { 520 553 $media_result = $this->_upload_files( $result['post_id'] ); 521 522 554 // Make sure we don't merge a non-array (_upload_files might return null, false or WP_Error) 523 if ( $media_result &&is_array( $media_result ) )555 if ( is_array( $media_result ) ) 524 556 $result = array_merge( $result, $media_result ); 525 557 } … … 557 589 return; 558 590 591 559 592 // TODO: It'd be nice to add the list of upload files 560 593 $to = !empty( $this->settings['notification_email'] ) && filter_var( $this->settings['notification_email'], FILTER_VALIDATE_EMAIL ) ? $this->settings['notification_email'] : get_option( 'admin_email' ); 561 594 $subj = __( 'New content was uploaded on your site', 'frontend-uploader' ); 562 wp_mail( $to, $subj, $this->settings['admin_notification_text'] ); 563 } 595 596 add_filter( 'wp_mail_content_type', 'fu_email_content_type' ); 597 598 wp_mail( $to, $subj, $this->_get_html_email_template( $result ) ); 599 600 remove_filter( 'wp_mail_content_type', 'fu_email_content_type' ); 601 } 602 603 /** 604 * Get html template 605 * 606 * @since 1.2 607 * 608 * @param array $result [description] 609 * @return [type] [description] 610 */ 611 function _get_html_email_template( $result = array() ) { 612 global $fu_result; 613 $fu_result = $result; 614 ob_start(); 615 include_once FU_ROOT . "/lib/views/html-email.tpl.php"; 616 return ob_get_clean(); 617 } 618 564 619 565 620 /** … … 706 761 * Approve a media file 707 762 * 708 * TODO: refactor in 0.6709 *710 763 * @return [type] [description] 711 764 */ … … 714 767 if ( false === $this->_check_perms_and_nonce() || 0 === (int) $_GET['id'] ) { 715 768 wp_safe_redirect( get_admin_url( null, 'upload.php?page=manage_frontend_uploader&error=id_or_perm' ) ); 769 exit; 716 770 } 717 771 … … 724 778 do_action( 'fu_media_approved', $post ); 725 779 726 $this->update_ 35_gallery_shortcode( $post->post_parent, $post->ID );780 $this->update_gallery_shortcode( $post->post_parent, $post->ID ); 727 781 wp_safe_redirect( get_admin_url( null, 'upload.php?page=manage_frontend_uploader&approved=1' ) ); 782 exit; 728 783 } 729 784 … … 740 795 // check for permissions and id 741 796 $url = get_admin_url( null, 'edit.php?page=manage_frontend_uploader_posts&error=id_or_perm' ); 742 if ( !current_user_can( $this->manage_permissions ) || intval( $_GET['id'] ) === 0 ) 797 if ( !current_user_can( $this->manage_permissions ) || intval( $_GET['id'] ) === 0 ) { 743 798 wp_safe_redirect( $url ); 799 exit; 800 } 744 801 745 802 $post = get_post( $_GET['id'] ); 746 803 747 if ( !is_wp_error( $post ) ) {804 if ( is_object( $post ) ) { 748 805 $post->post_status = 'publish'; 749 806 wp_update_post( $post ); … … 996 1053 */ 997 1054 function upload_form( $atts, $content = null ) { 1055 static $inst = 0; 1056 998 1057 add_shortcode( 'input', array( $this, 'shortcode_content_parser' ) ); 999 1058 add_shortcode( 'textarea', array( $this, 'shortcode_content_parser' ) ); … … 1025 1084 $this->enqueue_scripts(); 1026 1085 1027 $form_layout = in_array( $form_layout, array( 'post', 'image', 'media', 'post_image', 'post_media' ) ) ? $form_layout : 'media';1086 $form_layout = in_array( $form_layout, array( 'post', 'image', 'media', 'post_image', 'post_media' ), true ) ? $form_layout : 'media'; 1028 1087 1029 1088 ob_start(); 1030 1089 ?> 1031 <form action="<?php echo admin_url( 'admin-ajax.php' ) ?>" method="post" id="ugc-media-form " class="<?php echo esc_attr( $class )?> fu-upload-form" enctype="multipart/form-data">1090 <form action="<?php echo admin_url( 'admin-ajax.php' ) ?>" method="post" id="ugc-media-form-<?php echo $inst++; ?>" class="<?php echo esc_attr( $class )?> fu-upload-form" enctype="multipart/form-data"> 1032 1091 <div class="ugc-inner-wrapper"> 1033 1092 <h2><?php echo esc_html( $title ) ?></h2> … … 1277 1336 1278 1337 $output = ''; 1279 $map = a rray(1338 $map = apply_filters( 'fu_response_notices', array( 1280 1339 'fu-sent' => array( 1281 1340 'text' => __( 'Your file was successfully uploaded!', 'frontend-uploader' ), … … 1294 1353 'class' => 'failure', 1295 1354 ), 1296 ) ;1355 ) ); 1297 1356 1298 1357 if ( isset( $res['response'] ) && isset( $map[ $res['response'] ] ) ) 1299 1358 $output .= $this->_notice_html( $map[ $res['response'] ]['text'] , $map[ $res['response'] ]['class'] ); 1300 1359 1301 if ( !empty( $res['errors' ] ) )1360 if ( !empty( $res['errors' ] ) && 'fu-error' === $res['response'] ) 1302 1361 $output .= $this->_display_errors( $res['errors' ] ); 1303 1362 … … 1308 1367 * 1309 1368 * @since 0.4 1310 * @param string $errors [description]1369 * @param mixed $errors either a comma separated string of error codes or 1311 1370 * @return string HTML 1312 1371 */ 1313 1372 function _display_errors( $errors ) { 1373 if ( ! $errors ) 1374 return; 1375 1314 1376 $output = ''; 1315 1377 $map = array( … … 1319 1381 'fu-disallowed-mime-type' => array( 1320 1382 'text' => __( 'This kind of file is not allowed. Please, try again selecting other file.', 'frontend-uploader' ), 1321 'format' => $this->is_debug ? '%1$s : <br/> File name: %2$s <br> MIME-TYPE: %3$s' : '%1$s: <br>%2$s',1383 'format' => $this->is_debug ? '%1$s File name: %2$s MIME-TYPE: %3$s' : '%1$s: %2$s', 1322 1384 ), 1323 'fu- invalid-post' => array(1324 'text' =>__( 'Th e content you are trying to post is invalid.', 'frontend-uploader' ),1385 'fu-disallowed-post-type' => array( 1386 'text' =>__( 'This post type is not allowed.', 'frontend-uploader' ), 1325 1387 ), 1326 1388 'fu-error-media' => array( 1327 'text' =>__( "Couldn't upload the file", 'frontend-uploader' ), 1389 'text' =>__( "Couldn't upload the file due to server error", 'frontend-uploader' ), 1390 'format' => '%1$s - %2$s' 1328 1391 ), 1329 1392 'fu-error-post' => array( 1330 'text' =>__( "Couldn't create the post ", 'frontend-uploader' ),1393 'text' =>__( "Couldn't create the post due to server error", 'frontend-uploader' ), 1331 1394 ), 1332 1395 'fu-suspicious-file' => array( … … 1338 1401 // $error is the key of error, $details - additional information about the error 1339 1402 foreach ( (array) $errors as $error => $details ) { 1403 1404 if ( ! isset( $map[ $error] ) ) { 1405 continue; 1406 } 1340 1407 1341 1408 // We might have multiple errors of the same type, let's walk through them … … 1353 1420 } 1354 1421 } 1422 1355 1423 return $output; 1356 1424 } … … 1366 1434 wp_enqueue_script( 'frontend-uploader-js', FU_URL . 'lib/js/frontend-uploader.js', array( 'jquery', 'jquery-validate' ) ); 1367 1435 // Include localization strings for default messages of validation plugin 1368 // Filter is needed for wordpress.com 1369 $wplang = apply_filters( 'fu_wplang', defined( 'WPLANG' ) ? WPLANG : '' ); 1370 if ( $wplang ) { 1371 $lang = explode( '_', $wplang ); 1372 $relative_path = "lib/js/validate/localization/messages_{$lang[0]}.js"; 1436 if ( $this->lang ) { 1437 $relative_path = "lib/js/validate/localization/messages_{$this->lang_short}.js"; 1373 1438 $url = FU_URL . $relative_path; 1374 1439 if ( file_exists( FU_ROOT . "/{$relative_path}" ) ) … … 1391 1456 1392 1457 /** 1393 * 3.5 brings new Media UI 1394 * Unfortunately, we have to specify ids of approved attachments explicitly, 1458 * We have to specify ids of approved attachments explicitly in shortcode, 1395 1459 * Otherwise, editors have to pick photos after they have already approved them in "Manage UGC" 1396 1460 * … … 1399 1463 * @return post id/wp_error 1400 1464 */ 1401 function update_ 35_gallery_shortcode( $post_id, $attachment_id ) {1465 function update_gallery_shortcode( $post_id, $attachment_id ) { 1402 1466 global $wp_version; 1403 1467 // Bail of wp is older than 3.5 -
frontend-uploader/trunk/lib/php/frontend-uploader-settings.php
r1402587 r1688580 163 163 ), 164 164 array( 165 'name' => 'default_file_name', 166 'label' => __( 'Default file name', 'frontend-uploader' ), 167 'desc' => __( 'Leave blank to use original file name', 'frontend-uploader' ), 168 'type' => 'text', 169 'default' => 'Unnamed', 170 /* No need to set a sanitize callback. It is handled automagically. */ 165 'name' => 'obfuscate_file_name', 166 'label' => __( 'Obfuscate file name', 'frontend-uploader' ), 167 'desc' => __( 'Yes', 'frontend-uploader' ), 168 'type' => 'checkbox', 169 'default' => '', 171 170 ), 172 171 array( -
frontend-uploader/trunk/lib/php/functions.php
r1402587 r1688580 11 11 // Generated with dyn_php class: http://www.phpclasses.org/package/2923-PHP-Generate-PHP-code-programmatically.html 12 12 $mimes_exts = array( 13 'doc'=>14 array(15 'label'=> 'Microsoft Word Document',16 'mimes'=>17 array(18 'application/msword',19 ),20 ),21 'docx'=>22 array(23 'label'=> 'Microsoft Word Open XML Document',24 'mimes'=>25 array(26 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',27 ),28 ),29 'xls'=>30 array(31 'label'=> 'Excel Spreadsheet',32 'mimes'=>33 array(34 'application/vnd.ms-excel',35 'application/msexcel',36 'application/x-msexcel',37 'application/x-ms-excel',38 'application/vnd.ms-excel',39 'application/x-excel',40 'application/x-dos_ms_excel',41 'application/xls',42 ),43 ),44 'xlsx'=>45 array(46 'label'=> 'Microsoft Excel Open XML Spreadsheet',47 'mimes'=>48 array(49 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',50 ),51 ),52 'pdf'=>53 array(54 'label'=> 'Portable Document Format File',55 'mimes'=>56 array(57 'application/pdf',58 'application/x-pdf',59 'application/acrobat',60 'applications/vnd.pdf',61 'text/pdf',62 'text/x-pdf',63 ),64 ),65 'psd'=>66 array(67 'label'=> 'Adobe Photoshop Document',68 'mimes'=>69 array(70 'image/photoshop',71 'image/x-photoshop',72 'image/psd',73 'application/photoshop',74 'application/psd',75 'zz-application/zz-winassoc-psd',76 'image/vnd.adobe.photoshop',77 ),78 ),79 13 'csv'=> 80 14 array( … … 89 23 'application/vnd.msexcel', 90 24 'text/anytext', 91 ),92 ),93 'ppt'=>94 array(95 'label'=> 'PowerPoint Presentation',96 'mimes'=>97 array(98 'application/vnd.ms-powerpoint',99 'application/mspowerpoint',100 'application/ms-powerpoint',101 'application/mspowerpnt',102 'application/vnd-mspowerpoint',103 ),104 ),105 'pptx'=>106 array(107 'label'=> 'PowerPoint Open XML Presentation',108 'mimes'=>109 array(110 'application/vnd.openxmlformats-officedocument.presentationml.presentation',111 25 ), 112 26 ), … … 142 56 ), 143 57 ), 144 'mp4'=> 145 array( 146 'label'=> 'MPEG-4 Video File', 147 'mimes'=> 148 array( 149 'video/mp4v-es', 150 'audio/mp4', 151 'application/mp4', 152 ), 153 ), 154 'm4a'=> array( 155 'label'=> 'MPEG-4 Audio File', 156 'mimes'=> array( 157 'audio/aac', 'audio/aacp', 'audio/3gpp', 'audio/3gpp2', 'audio/mp4', 'audio/MP4A-LATM','audio/mpeg4-generic', 'audio/x-m4a', 'audio/m4a' 158 ) ), 159 'mov'=> 160 array( 161 'label'=> 'Apple QuickTime Movie', 162 'mimes'=> 163 array( 164 'video/quicktime', 165 'video/x-quicktime', 166 'image/mov', 167 'audio/aiff', 168 'audio/x-midi', 169 'audio/x-wav', 170 'video/avi', 171 ), 172 ), 173 'mpg'=> 174 array( 175 'label'=> 'MPEG Video File', 176 'mimes'=> 177 array( 178 'video/mpeg', 179 'video/mpg', 180 'video/x-mpg', 181 'video/mpeg2', 182 'application/x-pn-mpg', 183 'video/x-mpeg', 184 'video/x-mpeg2a', 185 'audio/mpeg', 186 'audio/x-mpeg', 187 'image/mpg', 188 ), 189 ), 58 190 59 'mid'=> 191 60 array( … … 221 90 ), 222 91 ), 223 'wmv'=>224 array(225 'label'=> 'Windows Media Video File',226 'mimes'=>227 array(228 'video/x-ms-wmv',229 ),230 ),231 92 ); 232 93 … … 260 121 return '<div class="g-recaptcha" data-sitekey="' . esc_attr( fu_get_option( 'recaptcha_site_key' ) ) . '"></div>'; 261 122 } 123 124 function fu_get_file_array() { 125 $walker = function ($arr, $fileInfokey, callable $walker) { 126 $ret = array(); 127 foreach ($arr as $k => $v) { 128 if (is_array($v)) { 129 $ret[$k] = $walker($v, $fileInfokey, $walker); 130 } else { 131 $ret[$k][$fileInfokey] = $v; 132 } 133 } 134 return $ret; 135 }; 136 137 $files = array(); 138 foreach ($_FILES as $name => $values) { 139 // init for array_merge 140 if (!isset($files[$name])) { 141 $files[$name] = array(); 142 } 143 if (!is_array($values['error'])) { 144 // normal syntax 145 $files[$name] = $values; 146 } else { 147 // html array feature 148 foreach ($values as $fileInfoKey => $subArray) { 149 $files[$name] = array_replace_recursive($files[$name], $walker($subArray, $fileInfoKey, $walker)); 150 } 151 } 152 } 153 154 return $files; 155 } 156 157 function fu_email_content_type( $content_type ) { 158 return 'text/html'; 159 } -
frontend-uploader/trunk/lib/php/recaptcha.php
r1468826 r1688580 5 5 6 6 function fu_add_recaptcha_js() { 7 global $frontend_uploader; 7 8 ?> 8 <script src=' https://www.google.com/recaptcha/api.js' async defer></script>9 <script src='<?php echo esc_url( add_query_arg( array( 'hl' => $frontend_uploader->lang_short ), 'https://www.google.com/recaptcha/api.js' ) ) ?>' async defer></script> 9 10 <?php 10 11 } 11 12 12 function fu_recaptcha_check_submission( $should_process, $layout ) { 13 13 -
frontend-uploader/trunk/readme.txt
r1468826 r1688580 4 4 Tags: frontend, image, images, media, uploader, upload, video, audio, photo, photos, picture, pictures, file, user generated content, ugc, frontend upload 5 5 Requires at least: 4.1 6 Tested up to: 4. 67 Stable tag: 1. 16 Tested up to: 4.8 7 Stable tag: 1.2 8 8 License: GPLv2 or later 9 9 … … 16 16 This plugin is a simple way for users to submit content to your site. The plugin uses a set of shortcodes to let you create highly customizable submission forms to your posts and pages. Once the content is submitted, it is held for moderation until you approve it. It’s that easy! 17 17 18 **Exploring Customizations** 18 = Exploring Customizations = 19 19 20 20 * You can modify the submission form as needed, and have users submit posts. Please visit the FAQ page for more information. 21 21 * This plugin can be applied to Posts, Pages, and Custom Post Types. You can enable this via Settings > Frontend Uploader Settings. 22 * In addition to the WordPress whitelisted file types, this also supports uploading of Microsoft Office and Adobe files, as well as various video and audio files. You can enable these file types via Settings > Frontend Uploader Settings. 23 * The plugin allows you to upload all filetypes that are whitelisted in WordPress. If you’d like to add more file types and are comfortable with theme development, there's a filter that'll allow you to add some exotic MIME-type. 24 25 You can also manage UGC for selected custom post types (Please refer to the plugin's settings page). By default, UGC is enabled for posts and attachments. If you want to be able to get any other post types UGC submissions just select desired post types at the plugin's settings page, and pass post_type='my_post_type' to the **[fu-upload-form]** shortcode. 22 * Form can be used in 3 modes: upload files, submit posts/custom post types, and mixed - submit a post and attach files to it. 23 * Form supports following fields: text, textarea, select, radio buttons, and checkboxes 26 24 27 25 **Customizing Your Form with Shortcode Parameters** 28 26 29 Frontend Uploader uses shortcodes to insert a form into a page or post. The default form shortcode is **[fu-upload-form]** but you can modify the plugin's behavior with additional parameters. 30 31 If you would like to build a custom form, it must begin with *[fu-upload-form]* and end with *[/fu-upload-form]*. 32 33 The **[fu-upload-form]** shortcode has several parameters important parameters: 27 Frontend Uploader is flexible and powerful, but unfortunately there's no visual form constructor at the moment - you have to use shortcodes. Please read this documentation carefully in order to leverage the plugin's features. 28 29 At it's most basic form, the shortcode would look like this 30 `[fu-upload-form]` 31 32 This will render a default form for media upload that has title, description and upload fields. (See screenshot 2) 33 34 The same shortcode with some customizations would look like this: 35 36 `[fu-upload-form class="html-wrapper-class" form_layout="media" title="Upload your media"] 37 [input type="text" name="post_title" id="title" class="required" description="Title"] 38 [textarea name="post_content" class="textarea" id="my-textarea" description="Description (optional)"] 39 [input type="file" name="photo" id="my-photo-submission" class="required" description="Your Photo" multiple="multiple"] 40 [input type="submit" class="btn" value="Submit"] 41 [/fu-upload-form]` 42 43 As you can see, form elements are represented by shortcodes: [input], [textarea], [radio], [checkboxes], [file]. Each of them has a set of attributes, e.g. `id, class, name, value, values, type, description, minlength, maxlength. Please refer to "Form Elements" section of this readme for more details on elements and their attributes. 44 45 = Main shortcode: [fu-upload-form] = 46 47 The main shortcode, it has many important parameters that modify form behavior. 48 49 In the following example we are creating a form with title "Upload your story and image". The form will allow to submit a custom post type *story* with an image which is going to be automatically inserted at the end of the story. The story will have a category with ID 1. On successful submission user will be redirected to http://example.com/success-page/ 50 51 `[fu-upload-form form_layout="post_media" title="Upload your story and image" class="my-class validate" post_type="story" append_to_post="true" success_page="http://example.com/success-page/" category="1" ][/fu-upload-form]` 52 53 * The list of all parameters for [fu-upload-form] * 34 54 35 55 `form_layout` 36 This determines whether the form is saved as a post/custom post type (‘post’), as a media file (`media`), or as a post with images (`post_media`). Default value is `media`. Example: **[fu-upload-form class="your-class" title="Upload your media" form_layout=”post”]** 56 57 This determines whether the form is saved as a post/custom post type (‘post’), as a media file (`media`), or as a post with images (`post_media`). Default value is `media`. 58 Example: *[fu-upload-form form_layout=”post”]* 37 59 38 60 `title` 39 Add this *[fu-upload-form]* shortcode, and this will be the Headline that will be displayed before the form. Example: **[fu-upload-form class="your-class" title="Upload your media"]** 61 62 Add this *[fu-upload-form]* shortcode, and this will be the Headline that will be displayed before the form. 63 Example: **[fu-upload-form class="your-class" title="Upload your media"]** 40 64 41 65 `class` 42 HTML class of the form, defaults to 'validate'. If you want your form being validated - do not remove validate class. If you would like to item to be required before a user can submit, you can set it to ‘required.’ Example: **[input type="text" name="post_title" id="title" class="required"]** 66 67 HTML class of the form, defaults to 'validate'. If you want your form being validated - do not remove validate class. If you would like to item to be required before a user can submit, you can set it to ‘required.’ 68 Example: *[input type="text" name="post_title" id="title" class="required"]* 43 69 44 70 `post_type` 45 Any post whitelisted in settings post type. Defaults to 'post'. Example: **[fu-upload-form post_type="my-custom-post-type-slug"]** 46 71 72 Any post whitelisted in settings post type. Defaults to 'post'. 73 Example: *[fu-upload-form post_type="my-custom-post-type-slug"]* 47 74 48 75 `append_to_post` 76 49 77 Automatically insert images into uploaded post *(true or false)* 50 78 51 79 `success_page` 80 52 81 URL to redirect on successful submission, defaults to the URL where the form is being displayed. For security reasons this should be an URL on your site (no external links). You can use **[fu-upload-response]** shortcode to display success/error messages on the redirect page. 53 82 54 83 `category` 84 55 85 ID of category the post should be attached (only in post or post+media mode). 56 86 57 87 `post_id` 88 58 89 ID of the post the image should be attached to. Defaults to the post ID of the post the shortcode is on. 59 90 60 91 `suppress_default_fields` 61 In it's basic form shortcode adds some default fields for you - Title, Description, and file upload. However, you can create a customized shortcode. 62 Override global setting for supressing default form fields *(true or false)*. Example: **[fu-upload-form suppress_default_fields="true"] ... inner shortcodes omitted... [/fu-upload-form]** 63 64 65 Within **[fu-upload-form]**, you can add form fields. 66 67 * `[input type="text" ]` A text box for one line of text 68 * `[textarea]` => A text box for multiple lines of text 69 * `[input type="file"]` => A file uploader 70 * `[checkboxes values="value:Description,124:Banana,cherry:Cherry"]` => A set of checkboxes 71 * `[radio name="foo" class="checkboxes" description="Pick a fruit" values="value:Description,124:Banana,cherry:Cherry"]` => A set of radio buttons 72 * `[select name="foo" class="select" description="Pick a fruit" values="apple:Apple,banana:Banana,cherry:Cherry"]` => A select 92 93 Override global setting for supressing default form fields *(true or false)*. 94 Example: `[fu-upload-form suppress_default_fields="true"] ... inner shortcodes omitted... [/fu-upload-form]` 95 96 97 = Form Elements = 98 99 * `[input type="text" name="post_title" class="my-class" ]` A text box for one line of text 100 * `[textarea name="post_content" class="my-text-area"]` => A text box for multiple lines of text 101 * `[input type="file" name="my-file"]` => A file uploader 102 * `[checkboxes name="fruits" values="value:Description,124:Banana,cherry:Cherry"]` => A set of checkboxes 103 * `[radio name="fruit" class="checkboxes" description="Pick a fruit" values="value:Description,124:Banana,cherry:Cherry"]` => A set of radio buttons 104 * `[select name="select-fruit" class="select" description="Pick a fruit" values="apple:Apple,banana:Banana,cherry:Cherry"]` => A select 73 105 * `[input type="submit" class="btn" value="Submit"]` => A submit button 74 106 … … 102 134 103 135 104 ** Support ** 136 == Support == 105 137 106 138 Please make sure to read this readme including FAQ section before posting in support forum. 107 139 108 140 109 ** Development**141 **Development** 110 142 111 143 [Fork the plugin or report an issue on Github](https://github.com/rinatkhaziev/wp-frontend-uploader/) … … 145 177 You can modify the form as you'd like but you have to make sure that 'post_title' field is present, otherwise upload might fail 146 178 147 = Example of default media upload form =148 149 Here's example of default form (*you don't need to enter all that if you want to use default form, just use `[fu-upload-form]`*):150 151 `[fu-upload-form class="your-class" title="Upload your media"]152 [input type="text" name="post_title" id="title" class="required" description="Title"]153 [textarea name="post_content" class="textarea" id="ug_caption" description="Description (optional)"]154 [input type="file" name="photo" id="ug_photo" class="required" description="Your Photo" multiple="multiple"]155 [input type="submit" class="btn" value="Submit"]156 [/fu-upload-form]`157 158 179 = I get a white screen or "0" when trying to upload a file = 159 The major cause of this is either request timeout or request exceeding maximum request size. This means that either the file was uploading for too long or it was too big. TwoPHP settings to look at are:160 [max_execution_time](http://us1.php.net/manual/en/info.configuration.php#ini.max-execution-time) and [upload_max_filesize](http://us3.php.net/manual/en/ini.core.php#ini.upload-max-filesize) . If you don't have any ability to modify these settings, please contact your hosting company's support.180 The major cause of this is either request timeout or request exceeding maximum request size. This means that either the file was uploading for too long or it was too big. PHP settings to look at are: 181 [max_execution_time](http://us1.php.net/manual/en/info.configuration.php#ini.max-execution-time) and [upload_max_filesize](http://us3.php.net/manual/en/ini.core.php#ini.upload-max-filesize), and [post_max_size](http://us3.php.net/manual/en/ini.core.php#ini.post-max-size). If you don't have any ability to modify these settings, please contact your hosting company's support. 161 182 162 183 = Where are the plugin's settings? = … … 180 201 You can suppress rendering of default form fields with "Suppress default fields" checkbox in settings 181 202 182 = I want to customize my form =183 You can include additional elements with a set of shortcodes184 [input type="text" name="post_title" id="title" class="required" description="Title" multiple=""]185 [select name="foo" class="select" id="ug_select" description="Pick a fruit" values="Apple,Banana,Cherry"]186 [textarea name="post_content" class="textarea" id="ug_caption" description="Description (optional)"]187 [checkboxes name="foo" class="checkboxes" description="Pick a fruit" values="value:Description,124:Banana,cherry:Cherry"]188 203 189 204 = I want to be allow users to upload mp3, psd, or any other file restricted by default. = … … 224 239 }` 225 240 226 = There's no captcha!=227 The plugin uses Akismet as spam protection (you have to have Akismet installed and configured). Just enable Akismet support in the plugin's settings and voila.241 = What about spam protection? = 242 The plugin supports Akismet (must be installed and configured properly) and Recaptcha. Just enable it in plugin settings. 228 243 229 244 = Configuration Filters = … … 287 302 == Changelog == 288 303 304 = 1.2 (Jun 30, 2017) = 305 * Added image preview in email notification 306 * Minor bugfixes and cleanup 307 289 308 = 1.1 (Aug 5, 2016) = 290 309 * Refactored admin list tables to prevent "Headers already sent error"
Note: See TracChangeset
for help on using the changeset viewer.