Changeset 2591047
- Timestamp:
- 08/30/2021 07:44:40 PM (4 years ago)
- Location:
- frontend-uploader/trunk
- Files:
-
- 5 edited
-
. (modified) (1 prop)
-
frontend-uploader.php (modified) (1 diff)
-
lib/php/akismet.php (modified) (1 diff)
-
readme.md (modified) (2 diffs)
-
readme.txt (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
frontend-uploader/trunk
-
Property
svn:ignore
set to
tests
-
Property
svn:ignore
set to
-
frontend-uploader/trunk/frontend-uploader.php
r2590623 r2591047 5 5 Author: Rinat Khaziev, Daniel Bachhuber 6 6 Version: 1.3.2 7 Author URI: http ://digitallyconscious.com7 Author URI: https://rinat.dev/ 8 8 Text Domain: frontend-uploader 9 Requires at least: 4.6 10 Requires PHP: 7.2 9 11 10 12 GNU General Public License, Free Software Foundation <http://creativecommons.org/licenses/GPL/2.0/> -
frontend-uploader/trunk/lib/php/akismet.php
r1971315 r2591047 22 22 // Permalink of the post with upload form, fallback to wp_get_referer() 23 23 // Fallback is used to 24 $content['permalink'] = isset( $_POST['form_post_id'] ) ? get_permalink( sanitize_text _area( $_POST['form_post_id'] ) ) : wp_get_referer();24 $content['permalink'] = isset( $_POST['form_post_id'] ) ? get_permalink( sanitize_textarea_field( $_POST['form_post_id'] ) ) : wp_get_referer(); 25 25 26 26 // Set required Akismet values -
frontend-uploader/trunk/readme.md
r2590623 r2591047 12 12 13 13 1. `git clone https://github.com/rinatkhaziev/wp-frontend-uploader.git` in your WP plugins directory 14 1. `git submodule update --init --recursive` in the plugin dir to get dependencies15 14 1. Activate the plugin 16 15 1. Set the settings … … 20 19 21 20 1. Pull as usual 22 2. Do `git submodule -q foreach git pull -q origin master` to update submodules 23 3. ... 24 4. Profit 21 2. ... 22 3. Profit 25 23 26 24 ## Developers -
frontend-uploader/trunk/readme.txt
r2590623 r2591047 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.6 6 Tested up to: 5.0 6 Requires PHP: 7.2 7 Tested up to: 5.8 7 8 Stable tag: 1.3.2 8 9 License: GPLv2 or later … … 18 19 **Security** 19 20 20 Allowing uploads from unauthenticated users is inherently risky. The plugin relies on the core allow list for files. However, we explicitly remove HTML, JS and PHP files even if they're in the allow list. To modify the list of allowed file types please refer to *fu_allowed_mime_types* configuration filter section for additional details. 21 Allowing uploads from unauthenticated users is inherently risky. The plugin relies on the core allow list for files. However, we explicitly remove HTML, JS and PHP files even if they're in the allow list. To modify the list of allowed file types and tweak it to your own desire either use the plugin's settings or refer to *fu_allowed_mime_types* configuration filter section for additional details. 22 23 For additional protection we recommend enabling file name obfuscation in plugin settings. 21 24 22 25 = Exploring Customizations = … … 24 27 * You can modify the submission form as needed, and have users submit posts. Please visit the FAQ page for more information. 25 28 * This plugin can be applied to Posts, Pages, and Custom Post Types. You can enable this via Settings > Frontend Uploader Settings. 26 * Form can be used in 3 modes: upload files, submit posts/custom post types, and mixed - submit a post and attach files to it. 27 * Form supports following fields: text, textarea, select, radio buttons, and checkboxes 29 * Form can be used in three modes: 30 - Submit files 31 - Submit posts/pages/custom post types 32 - Submit a post and attach files to it 33 34 * The form supports following fields: text, textarea, select, radio buttons, and checkboxes 28 35 29 36 **Customizing Your Form with Shortcode Parameters** … … 32 39 33 40 At it's most basic form, the shortcode would look like this 34 `[fu-upload-form]` 41 **[fu-upload-form]** 35 42 36 43 This will render a default form for media upload that has title, description and upload fields. (See screenshot 2) … … 38 45 The same shortcode with some customizations would look like this: 39 46 40 `[fu-upload-form class="html-wrapper-class" 41 form_layout="media" title="Upload your media"] 42 [input type="text" name="post_title" id="title" 43 class="required" description="Title"] 44 [textarea name="post_content" class="textarea" 45 id="my-textarea" description="Description (optional)"] 46 [input type="file" name="photo" id="my-photo-submission" 47 class="required" description="Your Photo" multiple="multiple"] 48 [input type="submit" class="btn" value="Submit"] 47 `[fu-upload-form class="html-wrapper-class" form_layout="media" title="Upload your media"] 48 49 [input type="text" name="post_title" id="title" 50 class="required" description="Title"] 51 52 [textarea name="post_content" class="textarea" 53 id="my-textarea" description="Description (optional)"] 54 55 [input type="file" name="photo" id="my-photo-submission" 56 class="required" description="Your Photo" multiple="multiple"] 57 58 [input type="submit" class="btn" value="Submit"] 49 59 [/fu-upload-form]` 50 60 51 61 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. 52 62 53 = Main shortcode: [fu-upload-form] = 63 ## Main shortcode: [fu-upload-form] ## 54 64 55 65 The main shortcode, it has many important parameters that modify form behavior. 56 66 57 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/ 58 59 `[fu-upload-form form_layout="post_media" title="Upload your story and image" 60 class="my-class validate" post_type="story" append_to_post="true" 61 success_page="http://example.com/success-page/" category="1" ][/fu-upload-form]` 62 63 **The list of all parameters for [fu-upload-form]** 64 65 *form_layout* 67 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 a file 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/ 68 69 `[fu-upload-form 70 form_layout="post_media" 71 title="Upload your story and image" 72 class="my-class validate" 73 post_type="story" 74 append_to_post="true" 75 success_page="http://example.com/success-page/" 76 category="1" 77 ][/fu-upload-form]` 78 79 ### The list of all parameters for [fu-upload-form] ### 80 81 **form_layout** 66 82 67 83 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`. 68 Example: 84 85 Example: 86 69 87 `[fu-upload-form form_layout=”post”]` 70 88 71 * title*89 **title** 72 90 73 91 Add this *[fu-upload-form]* shortcode, and this will be the Headline that will be displayed before the form. 74 Example: 75 `fu-upload-form class="your-class" title="Upload your media"]` 76 77 *class* 92 93 Example: 94 95 `[fu-upload-form class="your-class" title="Upload your media"]` 96 97 **class** 78 98 79 99 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.’ 80 Example: 100 101 Example: 102 81 103 `[input type="text" name="post_title" id="title" class="required"]` 82 104 83 *post_type* 84 85 Any post whitelisted in settings post type. Defaults to 'post'. 86 Example: 105 **post_type** 106 107 Set the post type of the upload to one in the plugin settings Allow list. Defaults to 'post'. 108 109 Example: 110 87 111 `[fu-upload-form post_type="my-custom-post-type-slug"]` 88 112 89 *append_to_post* 90 91 Automatically insert images into uploaded post *(true or false)* 92 93 *success_page* 113 **append_to_post** 114 115 Automatically insert images into the uploaded post content *(true or false)* 116 117 Example: 118 119 `[fu-upload-form append_to_post="true"]` 120 121 122 **success_page** 94 123 95 124 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. 96 125 97 *category* 126 Example: 127 128 `[fu-upload-form success_page="https://example.com/thank-you-for-your-submission/"]` 129 130 **category** 98 131 99 132 ID of category the post should be attached (only in post or post+media mode). 100 133 101 *post_id* 134 Example: 135 136 `[fu-upload-form category="1"]` 137 138 **post_id** 102 139 103 140 ID of the post the image should be attached to. Defaults to the post ID of the post the shortcode is on. 104 141 105 *suppress_default_fields* 142 Example: 143 144 `[fu-upload-form post_id="103037"]` 145 146 **suppress_default_fields** 106 147 107 148 Override global setting for supressing default form fields *(true or false)*. 108 Example: 149 150 Example: 151 109 152 `[fu-upload-form suppress_default_fields="true"] ... inner shortcodes omitted... [/fu-upload-form]` 110 153 111 112 = Form Elements = 113 114 Following are form elements you can use, please refer to *Field Attributes* section for more details on what attributes can be used. 154 ### Form Elements ### 155 156 The following are form elements you can use, please refer to *Field Attributes* section for more details on what attributes can be used. 115 157 116 158 Text box for one line of text: 159 117 160 `[input type="text" name="post_title" class="my-class" ]` 118 161 119 162 Text box for multiple lines of text: 163 120 164 `[textarea name="post_content" class="my-text-area"]` 121 165 122 166 File upload field: 167 123 168 `[input type="file" name="my-file"]` 124 169 125 170 Set of checkboxes: 171 126 172 `[checkboxes name="fruits" values="value:Description,124:Banana,cherry:Cherry"]` 127 173 128 174 Set of radio buttons: 175 129 176 `[radio name="fruit" class="checkboxes" description="Pick a fruit" values="value:Description,124:Banana,cherry:Cherry"]` 130 177 131 178 Select: 179 132 180 `[select name="select-fruit" class="select" description="Pick a fruit" values="apple:Apple,banana:Banana,cherry:Cherry"]` 133 181 134 182 Submit button: 183 135 184 `[input type="submit" class="btn" value="Submit"]` 136 185 137 186 Recaptcha: 187 138 188 `[recaptcha]` 139 189 140 190 **Field Attributes** 141 191 142 `id` - id of element 143 144 `name` - name of element 145 146 `class` - extra classes you want to add 147 148 `type` - text or file or submit 149 150 `required` - This attribute specifies that the user must fill in a value before submitting a form. 151 152 `minlength` - minimum amount of characters for field value 153 154 `maxlength` - maximum amount of characters for field value 155 156 `min` - The minimum (numeric or date-time) value for this item, which must not be greater than its maximum (max attribute) value. 157 158 `max` - The maximum (numeric or date-time) value for this item, which must not be less than its minimum (min attribute) value. 159 160 `multiple` - allow multiple file uploads (only for file inputs) 161 162 `placeholder` - A hint to the user of what can be entered in the control. 163 164 `readonly` - This attribute indicates that the user cannot modify the value of the control. 165 166 `disabled` - This Boolean attribute indicates that the form control is not available for interaction 167 168 `value` - input value 169 170 `description` - input label 171 172 `help` - input help text displayed underneath 173 174 `values` - multiple option inputs (checkboxes,select,radio) values in format *value:description, another_value:anotherdescription* 175 176 `wysiwyg_enabled` - enable TinyMCE for textareas 192 Please refer to the excellent [MDN reference](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types "") for input attributes. Generally speaking, any HTML5 attribute should be supported. 193 194 * **id** - id of element 195 196 * **name** - name of element 197 198 * **class** - extra classes you want to add 199 200 * **type** - text or file or submit 201 202 * **required** - This attribute specifies that the user must fill in a value before submitting a form. 203 204 * **minlength** - minimum amount of characters for field value 205 206 * **maxlength** - maximum amount of characters for field value 207 208 * **min** - The minimum (numeric or date-time) value for this item, which must not be greater than its maximum (max attribute) value. 209 210 * **max** - The maximum (numeric or date-time) value for this item, which must not be less than its minimum (min attribute) value. 211 212 * **multiple** - allow multiple file uploads (only for file inputs) 213 214 * **placeholder** - A hint to the user of what can be entered in the control. 215 216 * **readonly** - This attribute indicates that the user cannot modify the value of the control. 217 218 * **disabled** - This Boolean attribute indicates that the form control is not available for interaction 219 220 * **value** - input value 221 222 * **description** - input label 223 224 * **help** - input help text displayed underneath 225 226 * **values** - Comma-separated values for the multiple option inputs (checkboxes, select, radio) in the format of **value:description, another_value:anotherdescription** 227 228 * **wysiwyg_enabled** - enable TinyMCE for textareas. 177 229 178 230 … … 180 232 181 233 Please make sure to read this readme including FAQ section before posting in support forum. 182 183 234 184 235 **Development** … … 234 285 235 286 = Are other filetypes supported? = 236 In addition to the WordPress whitelisted file types, Frontend Uploader 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. 287 288 By default every file type that WordPress allows to upload except HTML and JS are enabled. 289 However, you can tweak what's allowed in the Options -> Frontend Uploader Settings. 290 If you want to handle some other file type please refer to **fu_allowed_mime_types** filter section. 237 291 238 292 = Where does the user submitted content go? = … … 245 299 246 300 247 = I want to be allow users to upload mp3, psd, or any other file restricted by default. = 248 You are able to do that within Frontend Uploader Settings admin page. The settings there cover the most popular extensions/MIME-types. 249 The trick is that the same file might have several different mime-types based on setup of server/client. 250 If you're experiencing any issues, you can set WP_DEBUG to true in your wp-config.php or put 251 `add_filter( 'fu_is_debug', '__return_true' );` in your theme's functions.php to see what MIME-types you are having troubles with. 252 253 [FileExt](http://filext.com/) is a good place to find MIME-types for specific file extension. 254 255 Let's say we want to be able to upload 3gp media files. 256 257 First we look up all MIME-types for 3gp: http://filext.com/file-extension/3gp 258 259 Now that we have all possible MIME-types for .3gp, we can allow the files to be uploaded. 260 261 Following code whitelists 3gp files, if it makes sense to you, you can modify it for other extensions/mime-types. 262 If it confuses you, please don't hesitate to post on support forum. 301 = I want to allow users to upload a file type that's not listed in the plugin settings. = 302 303 By default we rely on [wp_get_mime_types](https://developer.wordpress.org/reference/functions/wp_get_mime_types/) function to populate the values for the allow list. 304 305 It covers the absolute majority of widely used file formats, but let's say you want to allow uploading a source file of a program written in [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language). 306 It can be using either **.pas`** or **.p** 307 It can have MIME type of `text/pascal` or `text/x-pascal` 308 309 [FileExt](http://filext.com/) is a good place to find out more about the file types, but, unfortunately it stopped showing MIME-types somewhere between the first and current version of this readme. 310 311 So we'll have to resort to a search engine and query for "PAS MIME-type". As said earlier, those files can have two MIME-types. 312 313 Now comes the tricky part, WordPress expects the mime types defined in a particular format of a regex pattern for extensions as an array key and MIME-type as a value. 314 315 Needless to say, associative array keys are unique, so we need to apply a little trick: 316 317 `$mime_types['p|pas'] = 'text/pascal'; 318 $mime_types['pas|p'] = 'text/x-pascal';` 319 320 This way we can side-step the unique key requirement while handling both of the MIME-types. 321 263 322 Put this in your theme's functions.php 323 264 324 `add_filter( 'fu_allowed_mime_types', 'my_fu_allowed_mime_types' ); 265 325 function my_fu_allowed_mime_types( $mime_types ) { 266 // Array of 3gp mime types 267 // From http://filext.com (there might be more) 268 $mimes = array( 'audio/3gpp', 'video/3gpp' ); 269 // Iterate through all mime types and add this specific mime to allow it 270 foreach( $mimes as $mime ) { 271 // Preserve the mime_type 272 $orig_mime = $mime; 273 // Leave only alphanumeric characters (needed for unique array key) 274 preg_replace("/[^0-9a-zA-Z ]/", "", $mime ); 275 // Workaround for unique array keys 276 // If you-re going to modify it for your files 277 // Don't forget to change extension in array key 278 // E.g. $mime_types['pdf|pdf_' . $mime ] = $orig_mime 279 $mime_types['3gp|3gp_' . $mime ] = $orig_mime; 280 } 326 $mime_types['p|pas'] = 'text/pascal'; 327 $mime_types['pas|p'] = 'text/x-pascal'; 328 281 329 return $mime_types; 282 330 }` 283 331 332 Unfortunately, that's not all. Sometimes, depending on a server configuration you might get unexpected results for certain file extensions. 333 If you’re experiencing any issues, you can set WP_DEBUG to true in your wp-config.php or put 334 335 `add_filter( ‘fu_is_debug’, ‘__return_true’ );` 336 337 in your theme’s functions.php to see what MIME-types you are having troubles with. 338 284 339 = What about spam protection? = 285 340 The plugin supports Akismet (must be installed and configured properly) and Recaptcha. Just enable it in plugin settings. … … 290 345 291 346 By default Frontend Uploader could be managed with 'edit_posts' capability, if you want to change permissions, this is the right filter 347 292 348 `add_filter( 'fu_manage_permissions', create_function( '$cap', 'return "edit_others_posts"; ) );` 293 349 … … 345 401 == Changelog == 346 402 403 = 1.3.3 (Aug 28, 2021) = 404 * Re-worked the way file type allow list works 405 * Readme formatting updates to hopefully make it clearer 406 347 407 = 1.3.2 (Nov 2, 2018) = 348 408 * Bugfix: allow multiple forms to be properly validated if they're rendered on the same page. … … 538 598 539 599 * Initial release and poorly written readme 600 601 == Upgrade Notice == 602 603 As of 1.3.3 the minimum requirement for PHP is bumped to 7.0, it reached the end of life on 10 Jan 2019, so if, somehow, you're still running it you should upgrade.
Note: See TracChangeset
for help on using the changeset viewer.