├── assets
├── fontello
│ ├── font
│ │ ├── afu.eot
│ │ ├── afu.ttf
│ │ ├── afu.woff
│ │ ├── afu.woff2
│ │ └── afu.svg
│ ├── css
│ │ ├── afu-codes.css
│ │ ├── afu-ie7-codes.css
│ │ ├── afu-ie7.css
│ │ ├── afu.css
│ │ ├── animation.css
│ │ └── afu-embedded.css
│ ├── LICENSE.txt
│ ├── config.json
│ ├── README.txt
│ └── demo.html
├── css
│ └── style.css
└── js
│ └── main.js
├── .github
└── CODEOWNERS
├── includes
├── shortcode-template.php
├── admin.php
└── afu-about.php
├── ajax-file-upload.php
├── README.md
└── license.txt
/assets/fontello/font/afu.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevriX/AJAX-File-Upload/HEAD/assets/fontello/font/afu.eot
--------------------------------------------------------------------------------
/assets/fontello/font/afu.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevriX/AJAX-File-Upload/HEAD/assets/fontello/font/afu.ttf
--------------------------------------------------------------------------------
/assets/fontello/font/afu.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevriX/AJAX-File-Upload/HEAD/assets/fontello/font/afu.woff
--------------------------------------------------------------------------------
/assets/fontello/font/afu.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevriX/AJAX-File-Upload/HEAD/assets/fontello/font/afu.woff2
--------------------------------------------------------------------------------
/assets/fontello/css/afu-codes.css:
--------------------------------------------------------------------------------
1 |
2 | .afuico-upload-cloud:before { content: '\e800'; } /* '' */
3 | .afuico-ok:before { content: '\e801'; } /* '' */
4 | .afuico-cancel:before { content: '\e802'; } /* '' */
5 | .afuico-spin6:before { content: '\e803'; } /* '' */
--------------------------------------------------------------------------------
/assets/fontello/css/afu-ie7-codes.css:
--------------------------------------------------------------------------------
1 |
2 | .afuico-upload-cloud { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
3 | .afuico-ok { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
4 | .afuico-cancel { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
5 | .afuico-spin6 { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
--------------------------------------------------------------------------------
/assets/fontello/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Font license info
2 |
3 |
4 | ## Font Awesome
5 |
6 | Copyright (C) 2012 by Dave Gandy
7 |
8 | Author: Dave Gandy
9 | License: SIL ()
10 | Homepage: http://fortawesome.github.com/Font-Awesome/
11 |
12 |
13 | ## Fontelico
14 |
15 | Copyright (C) 2012 by Fontello project
16 |
17 | Author: Crowdsourced, for Fontello project
18 | License: SIL (http://scripts.sil.org/OFL)
19 | Homepage: http://fontello.com
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Code Owners
2 | # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
3 |
4 | # PHP files
5 | *.php @lgadzhev@devrix.com
6 | composer.json @lgadzhev@devrix.com
7 | composer.lock @lgadzhev@devrix.com
8 |
9 | # Frontend files (CSS, Sass, HTML, JS)
10 | *.{css,scss,sass,html,js} @tmanoilov@devrix.com
11 | package.json @tmanoilov@devrix.com
12 | package-lock.json @tmanoilov@devrix.com
13 |
14 | # Full docks can be found at GH's official docs https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
15 |
--------------------------------------------------------------------------------
/assets/fontello/css/afu-ie7.css:
--------------------------------------------------------------------------------
1 | [class^="afuico-"], [class*=" afuico-"] {
2 | font-family: 'afu';
3 | font-style: normal;
4 | font-weight: normal;
5 |
6 | /* fix buttons height */
7 | line-height: 1em;
8 |
9 | /* you can be more comfortable with increased icons size */
10 | /* font-size: 120%; */
11 | }
12 |
13 | .afuico-upload-cloud { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
14 | .afuico-ok { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
15 | .afuico-cancel { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
16 | .afuico-spin6 { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); }
--------------------------------------------------------------------------------
/assets/fontello/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "afu",
3 | "css_prefix_text": "afuico-",
4 | "css_use_suffix": false,
5 | "hinting": true,
6 | "units_per_em": 1000,
7 | "ascent": 850,
8 | "glyphs": [
9 | {
10 | "uid": "de2fc7a5c986ab8c622f63455d7cf814",
11 | "css": "upload-cloud",
12 | "code": 59392,
13 | "src": "fontawesome"
14 | },
15 | {
16 | "uid": "12f4ece88e46abd864e40b35e05b11cd",
17 | "css": "ok",
18 | "code": 59393,
19 | "src": "fontawesome"
20 | },
21 | {
22 | "uid": "5211af474d3a9848f67f945e2ccaf143",
23 | "css": "cancel",
24 | "code": 59394,
25 | "src": "fontawesome"
26 | },
27 | {
28 | "uid": "9bc2902722abb366a213a052ade360bc",
29 | "css": "spin6",
30 | "code": 59395,
31 | "src": "fontelico"
32 | }
33 | ]
34 | }
--------------------------------------------------------------------------------
/assets/css/style.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Did you know? you can modify this by copying the entire plugin folder (ajax-upload-file/)
3 | * into your child theme, and from there you can edit any file except the core files ( for
4 | * core files, any changes made in your child theme won't be applicable )
5 | *
6 | * @since 0.1
7 | * @author Samuel Elh
Settings saved successfully.
Thank you for using AJAX File Upload to quickly process your uploads on the go!
6 | 7 |
A small preview WpChats 3.0 profile edit This plugin will help you add file upload feature to your site, set maximum upload size, allowed file extensions, and much more through a simple shortcode or a custom function.
10 | 11 |Totally AJAX, your uploads will be processed faster and an elegant way. All you need to do is to add the shortcode to your content, or call the plugin's custom function whithin your code and that's it.
12 | 13 |You can use [ajax-file-upload] to output the AJAX file uploader, set its settings, markup, and much more through the shortcode attributes.
unique_identifiermax_sizeallowed_extensionspermissionson_success_alerton_fail_alerton_fail_alert_error_messageon_success_set_input_valueset_background_imageset_image_sourcedisallow_remove_buttondisallow_reuploadupload_button_valueselect_file_button_valueremove_file_button_valueshow_preloaderdefault_loading_texton_success_dialog_prompt_valueThis is a required attribute. Insert anything random that makes the uploader unique, used to store the uploader settings in the database and get them while processing a file for the shortcode in use.
Example use: unique_identifier="my_contact_form"
Allows you to set the maximum file size to upload in KB. 1 MB is equal to 1000 KB.
Example use: max_size=3000 for 3 MB upload
With this attribute you can set the allowed file extensions to upload. Please separate the extensions with commas.
Example use: allowed_extensions="pdf,txt"
Set the required permission for a user to upload a file. You can set all for all users (even logged-out ones), or logged_in for logged-in users only, or a custom user role e.g author. If you choose to set a role, the current user is required to have that role in order to process an upload.
Alert the user that their upload is done. You can set custom messages to output within the dialog. It is optional, and no default alert is there if you don't set this attribute.
Example use: on_success_alert="Your file was successfully uploaded"
When a file is not processed successfully, you can use this attribute to alert the user with a custom message.
Example use: on_fail_alert="We couldn't have your file uploaded. Try again?"
An error message is always included in the AJAX response while a file was not processed with success. To alert this message to the user, you just need to add this attribute with some value that makes it true.
Example use: on_fail_alert_error_message="true"
You might have a hidden or visible input within your form where you want to put the uploaded media URL. If so, then use this attribute and put that field selector as the attribute value. If this field was not found in the DOM, an error will be added to the console.
Example use: on_success_set_input_value="#my_hidden_input"
When uploading an image, you probably want to use this attribute to set an element's background-image property with the returned image upload URL. The value has to be a valid element selector.
Example use: set_background_image=".cover-photo-container"
Same here, when uploading an image you would probably want to set an image source attribute with the returned image upload URL. If so then provide this image selector in the DOM.
Example use: set_image_source="img.profile-pic"
This attribute allows you to not provide a file delete button with the shortcode output. It can be handy when you don't want a user to multiple files everytime as they hit this button. Set its value and the button won't be there.
Example use: disallow_remove_button="1"
This can be handy to prevent users to upload multiple files. Set its value to something that makes it true, as you do, when a user uploads a file, the upload and remove button will both disappear, and the select one will become disabled.
Example use: disallow_reupload=""
The default value is "upload" and translatable through the admin settings. Lets you edit the upload button text.
Example use: upload_button_value="upload file"
The default value is "choose file" and translatable through the admin settings. Lets you edit the select button text..
Example use: select_file_button_value="choisir un fichier"
The default value is "remove" and translatable through the admin settings. Lets you edit the remove button text..
Example use: remove_file_button_value="click to remove this file"
If you have a hidden preloader which you want to show while the upload is being processed, provide its selector in the attribute value.
Example use: show_preloader=".loading"
The default value is "uploading.." and it is translatable. When you don't have show_preloader set, the select file button's text will change to this attribute value while an upload is processing, and the icon will change to a spin icon (icons by fontello.com)
Example use: default_loading_text="Processing your file. please wait.."
This will let your uses get the media URI of what they have uploaded. A dialog box will prompt with acustom message and an input where they can copy the file URL. in the attribute value, you can set the message to show above the input in the dialog box.
Example use: on_success_dialog_prompt_value="Upload done! make sure to copy your URL below and save it!"
In your PHP template, you could call the shortcode with do_shortcode('[ajax-file-upload ..]') WordPress's native shortcode parser function. Or, there's this function ajax_file_upload() you can use instead, carry on.
ajax_file_upload( $args ) accepts an array of arguments, these arguments are basically the shortcode attributes! So, keep consulting the above list if you need an element to add to your function..
Here's an example use:
109 | 110 |$args = array( 111 | "unique_identifier" => "my_subscription_form_file_upload", 112 | "allowed_extensions" => "jpg, png, bmp, gif", 113 | "on_success_alert" => "Your file was uploaded. Please continue with your subscription operation." 114 | ); 115 | echo ajax_file_upload( $args ); 116 |117 | 118 |
This plugin supports child theme. You can copy the entire plugin file to your active theme, and there you can modifications and changes to all the plugin files except the ajax-file-upload.php which is the core file. Neat huh? useful when you want to customize the shortcode template more or edit a little bit of jQuery and CSS..
This plugin creates DOM events that you can hook into to perform your required actions. Here are the events created by far:
127 | 128 |afu? that's the plugin's prefix. This event is initiated when an upload is processed or not, mainly when the ajax request is completed successfully, and it has data attached to it which you can access through event.data method:
window.addEventListener( "afu_got_response", function(e){
133 | var data = e.data; // full data object
134 | if( data.response.success ) { // success
135 | console.log( data.response.media_uri ); // the uploaded media URL
136 | }
137 | }, false);
138 |
139 |
140 | Do a console.log(e.data) there's much more useful data included with the event's attached data.

Same as the previous one, but afu_file_uploaded is only called when the file was successfully uploaded. You can use it to get the media URI with e.data.response.media_uri as you set the event listener
window.addEventListener( "afu_file_uploaded", function(e){
149 | if( "undefined" !== typeof e.data.response.media_uri ) {
150 | console.log( e.data.response.media_uri ); // the uploaded media URL
151 | }
152 | }, false);
153 |
154 |
155 | Runs when a file was not uploaded. Useful data are included about the file, the applied settings and the response.
158 | 159 |window.addEventListener( "afu_error_uploading", function(e){
160 | console.log( e.data ); // debugging
161 | }, false);
162 |
163 |
164 | Runs when a file was not uploaded. Useful data are included about the file, the applied settings and the response.
167 | 168 |window.addEventListener( "afu_file_removed", function(e){
169 | console.log( e.data.this ); // the clicked button
170 | console.log( e.data.container ); // the container div of this button if you want to apply changes to its chilren or so
171 | }, false);
172 |
173 |
174 | Thanks for reading about this plugin. This plugin is totally free and open-source, that means you can contribute to it to add many more cool features and improve it better. Interested? hit me up at samelh.com/contact/. AFU is available on the free open source software repository Github.
177 | 178 |If you like it by far, please take some time to leave us a ☆☆☆☆☆ rating on WordPress, a star ☆ on the Github repository, and thank you for your time!
179 | 180 |181 | Star on Github 182 | - Share on Twitter 183 | - Follow @Samuel_Elh on Twitter 184 | - Find support 185 | - samelh.com 186 |
187 | 188 |Thank you for using AJAX File Upload to quickly process your uploads on the go!
31 | 32 |
This plugin will help you add file upload feature to your site, set maximum upload size, allowed file extensions, and much more through a simple shortcode or a custom function.
35 | 36 |Totally AJAX, your uploads will be processed faster and an elegant way. All you need to do is to add the shortcode to your content, or call the plugin's custom function whithin your code and that's it.
37 | 38 |Go to settings or carry on with the useful documentation
39 | 40 |You can use [ajax-file-upload] to output the AJAX file uploader, set its settings, markup, and much more through the shortcode attributes.
This is a required attribute. Insert anything random that makes the uploader unique, used to store the uploader settings in the database and get them while processing a file for the shortcode in use.
Example use: unique_identifier="my_contact_form"
Allows you to set the maximum file size to upload in KB. 1 MB is equal to 1000 KB.
Example use: max_size=3000 for 3 MB upload
With this attribute you can set the allowed file extensions to upload. Please separate the extensions with commas.
Example use: allowed_extensions="pdf,txt"
Set the required permission for a user to upload a file. You can set all for all users (even logged-out ones), or logged_in for logged-in users only, or a custom user role e.g author. If you choose to set a role, the current user is required to have that role in order to process an upload.
Alert the user that their upload is done. You can set custom messages to output within the dialog. It is optional, and no default alert is there if you don't set this attribute.
Example use: on_success_alert="Your file was successfully uploaded"
When a file is not processed successfully, you can use this attribute to alert the user with a custom message.
Example use: on_fail_alert="We couldn't have your file uploaded. Try again?"
An error message is always included in the AJAX response while a file was not processed with success. To alert this message to the user, you just need to add this attribute with some value that makes it true.
Example use: on_fail_alert_error_message="true"
You might have a hidden or visible input within your form where you want to put the uploaded media URL. If so, then use this attribute and put that field selector as the attribute value. If this field was not found in the DOM, an error will be added to the console.
Example use: on_success_set_input_value="#my_hidden_input"
When uploading an image, you probably want to use this attribute to set an element's background-image property with the returned image upload URL. The value has to be a valid element selector.
Example use: set_background_image=".cover-photo-container"
Same here, when uploading an image you would probably want to set an image source attribute with the returned image upload URL. If so then provide this image selector in the DOM.
Example use: set_image_source="img.profile-pic"
This attribute allows you to not provide a file delete button with the shortcode output. It can be handy when you don't want a user to multiple files everytime as they hit this button. Set its value and the button won't be there.
Example use: disallow_remove_button="1"
This can be handy to prevent users to upload multiple files. Set its value to something that makes it true, as you do, when a user uploads a file, the upload and remove button will both disappear, and the select one will become disabled.
Example use: disallow_reupload=""
The default value is "upload" and translatable through the admin settings. Lets you edit the upload button text.
Example use: upload_button_value="upload file"
The default value is "choose file" and translatable through the admin settings. Lets you edit the select button text..
Example use: select_file_button_value="choisir un fichier"
The default value is "remove" and translatable through the admin settings. Lets you edit the remove button text..
Example use: remove_file_button_value="click to remove this file"
If you have a hidden preloader which you want to show while the upload is being processed, provide its selector in the attribute value.
Example use: show_preloader=".loading"
The default value is "uploading.." and it is translatable. When you don't have show_preloader set, the select file button's text will change to this attribute value while an upload is processing, and the icon will change to a spin icon (icons by fontello.com)
Example use: default_loading_text="Processing your file. please wait.."
This will let your uses get the media URI of what they have uploaded. A dialog box will prompt with acustom message and an input where they can copy the file URL. in the attribute value, you can set the message to show above the input in the dialog box.
Example use: on_success_dialog_prompt_value="Upload done! make sure to copy your URL below and save it!"
In your PHP template, you could call the shortcode with do_shortcode('[ajax-file-upload ..]') WordPress's native shortcode parser function. Or, there's this function ajax_file_upload() you can use instead, carry on.
ajax_file_upload( $args ) accepts an array of arguments, these arguments are basically the shortcode attributes! So, keep consulting the above list if you need an element to add to your function..
Here's an example use:
121 | 122 |123 | $args = array( 124 | "unique_identifier" => "my_subscription_form_file_upload", 125 | "allowed_extensions" => "jpg, png, bmp, gif", 126 | "on_success_alert" => "Your file was uploaded. Please continue with your subscription operation." 127 | ); 128 | echo ajax_file_upload( $args ); 129 |130 | 131 |
This plugin supports child theme. You can copy the entire plugin file to your active theme, and there you can modifications and changes to all the plugin files except the ajax-file-upload.php which is the core file. Neat huh? useful when you want to customize the shortcode template more or edit a little bit of jQuery and CSS..
This plugin creates DOM events that you can hook into to perform your required actions. Here are the events created by far:
140 | 141 |afu? that's the plugin's prefix. This event is initiated when an upload is processed or not, mainly when the ajax request is completed successfully, and it has data attached to it which you can access through event.data method:
146 | window.addEventListener( "afu_got_response", function(e){
147 | var data = e.data; // full data object
148 | if( data.response.success ) { // success
149 | console.log( data.response.media_uri ); // the uploaded media URL
150 | }
151 | }, false);
152 |
153 |
154 | Do a console.log(e.data) there's much more useful data included with the event's attached data.

Same as the previous one, but afu_file_uploaded is only called when the file was successfully uploaded. You can use it to get the media URI with e.data.response.media_uri as you set the event listener
163 | window.addEventListener( "afu_file_uploaded", function(e){
164 | if( "undefined" !== typeof e.data.response.media_uri ) {
165 | console.log( e.data.response.media_uri ); // the uploaded media URL
166 | }
167 | }, false);
168 |
169 |
170 | Runs when a file was not uploaded. Useful data are included about the file, the applied settings and the response.
173 | 174 |
175 | window.addEventListener( "afu_error_uploading", function(e){
176 | console.log( e.data ); // debugging
177 | }, false);
178 |
179 |
180 | Runs when a file was not uploaded. Useful data are included about the file, the applied settings and the response.
183 | 184 |
185 | window.addEventListener( "afu_file_removed", function(e){
186 | console.log( e.data.this ); // the clicked button
187 | console.log( e.data.container ); // the container div of this button if you want to apply changes to its children or so
188 | }, false);
189 |
190 |
191 | Thanks for reading about this plugin. This plugin is totally free and open-source, that means you can contribute to it to add many more cool features and improve it better. Interested? hit me up at samelh.com/contact/. AFU is available on the free open source software repository Github.
194 | 195 |If you like it by far, please take some time to leave us a ☆☆☆☆☆ rating on WordPress, a star ☆ on the Github repository, and thank you for your time!
196 | 197 | 198 | 199 |200 | Star on Github 201 | - Share on Twitter 202 | - Follow @Samuel_Elh on Twitter 203 | - Find support 204 | - samelh.com 205 |
206 | 207 |