├── 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 8 | */ 9 | 10 | .afu-process-file {} 11 | .afu-process-file label { 12 | border: 1px solid #ddd; 13 | padding: 4px 11px; 14 | border-radius: 3px; 15 | cursor: pointer; 16 | display: inline-block; 17 | } 18 | .afu-process-file label.select {} 19 | .afu-process-file label.upload { 20 | background: #F6FFEB; 21 | } 22 | .afu-process-file label.remove { 23 | background: #FFF8F0; 24 | } 25 | .afu-process-file label[disabled] { 26 | opacity: 0.4; 27 | -webkit-opacity: 0.4; 28 | -moz-opacity: 0.4; 29 | -ms-opacity: 0.4; 30 | cursor: no-drop; 31 | } -------------------------------------------------------------------------------- /includes/shortcode-template.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | 12 | $rand = rand(); // for multiple uses 13 | 14 | ?> 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 31 | 32 | 33 | 36 | 37 | 38 | 39 | 40 | 41 |
42 | 43 | -------------------------------------------------------------------------------- /assets/fontello/font/afu.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copyright (C) 2016 by original authors @ fontello.com 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /assets/fontello/css/afu.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'afu'; 3 | src: url('../font/afu.eot?11939915'); 4 | src: url('../font/afu.eot?11939915#iefix') format('embedded-opentype'), 5 | url('../font/afu.woff2?11939915') format('woff2'), 6 | url('../font/afu.woff?11939915') format('woff'), 7 | url('../font/afu.ttf?11939915') format('truetype'), 8 | url('../font/afu.svg?11939915#afu') format('svg'); 9 | font-weight: normal; 10 | font-style: normal; 11 | } 12 | /* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */ 13 | /* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */ 14 | /* 15 | @media screen and (-webkit-min-device-pixel-ratio:0) { 16 | @font-face { 17 | font-family: 'afu'; 18 | src: url('../font/afu.svg?11939915#afu') format('svg'); 19 | } 20 | } 21 | */ 22 | 23 | [class^="afuico-"]:before, [class*=" afuico-"]:before { 24 | font-family: "afu"; 25 | font-style: normal; 26 | font-weight: normal; 27 | speak: none; 28 | 29 | display: inline-block; 30 | text-decoration: inherit; 31 | width: 1em; 32 | margin-right: .2em; 33 | text-align: center; 34 | /* opacity: .8; */ 35 | 36 | /* For safety - reset parent styles, that can break glyph codes*/ 37 | font-variant: normal; 38 | text-transform: none; 39 | 40 | /* fix buttons height, for twitter bootstrap */ 41 | line-height: 1em; 42 | 43 | /* Animation center compensation - margins should be symmetric */ 44 | /* remove if not needed */ 45 | margin-left: .2em; 46 | 47 | /* you can be more comfortable with increased icons size */ 48 | /* font-size: 120%; */ 49 | 50 | /* Font smoothing. That was taken from TWBS */ 51 | -webkit-font-smoothing: antialiased; 52 | -moz-osx-font-smoothing: grayscale; 53 | 54 | /* Uncomment for 3D effect */ 55 | /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */ 56 | } 57 | 58 | .afuico-upload-cloud:before { content: '\e800'; } /* '' */ 59 | .afuico-ok:before { content: '\e801'; } /* '' */ 60 | .afuico-cancel:before { content: '\e802'; } /* '' */ 61 | .afuico-spin6:before { content: '\e803'; } /* '' */ -------------------------------------------------------------------------------- /assets/fontello/css/animation.css: -------------------------------------------------------------------------------- 1 | /* 2 | Animation example, for spinners 3 | */ 4 | .animate-spin { 5 | -moz-animation: spin 2s infinite linear; 6 | -o-animation: spin 2s infinite linear; 7 | -webkit-animation: spin 2s infinite linear; 8 | animation: spin 2s infinite linear; 9 | display: inline-block; 10 | } 11 | @-moz-keyframes spin { 12 | 0% { 13 | -moz-transform: rotate(0deg); 14 | -o-transform: rotate(0deg); 15 | -webkit-transform: rotate(0deg); 16 | transform: rotate(0deg); 17 | } 18 | 19 | 100% { 20 | -moz-transform: rotate(359deg); 21 | -o-transform: rotate(359deg); 22 | -webkit-transform: rotate(359deg); 23 | transform: rotate(359deg); 24 | } 25 | } 26 | @-webkit-keyframes spin { 27 | 0% { 28 | -moz-transform: rotate(0deg); 29 | -o-transform: rotate(0deg); 30 | -webkit-transform: rotate(0deg); 31 | transform: rotate(0deg); 32 | } 33 | 34 | 100% { 35 | -moz-transform: rotate(359deg); 36 | -o-transform: rotate(359deg); 37 | -webkit-transform: rotate(359deg); 38 | transform: rotate(359deg); 39 | } 40 | } 41 | @-o-keyframes spin { 42 | 0% { 43 | -moz-transform: rotate(0deg); 44 | -o-transform: rotate(0deg); 45 | -webkit-transform: rotate(0deg); 46 | transform: rotate(0deg); 47 | } 48 | 49 | 100% { 50 | -moz-transform: rotate(359deg); 51 | -o-transform: rotate(359deg); 52 | -webkit-transform: rotate(359deg); 53 | transform: rotate(359deg); 54 | } 55 | } 56 | @-ms-keyframes spin { 57 | 0% { 58 | -moz-transform: rotate(0deg); 59 | -o-transform: rotate(0deg); 60 | -webkit-transform: rotate(0deg); 61 | transform: rotate(0deg); 62 | } 63 | 64 | 100% { 65 | -moz-transform: rotate(359deg); 66 | -o-transform: rotate(359deg); 67 | -webkit-transform: rotate(359deg); 68 | transform: rotate(359deg); 69 | } 70 | } 71 | @keyframes spin { 72 | 0% { 73 | -moz-transform: rotate(0deg); 74 | -o-transform: rotate(0deg); 75 | -webkit-transform: rotate(0deg); 76 | transform: rotate(0deg); 77 | } 78 | 79 | 100% { 80 | -moz-transform: rotate(359deg); 81 | -o-transform: rotate(359deg); 82 | -webkit-transform: rotate(359deg); 83 | transform: rotate(359deg); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /assets/fontello/README.txt: -------------------------------------------------------------------------------- 1 | This webfont is generated by http://fontello.com open source project. 2 | 3 | 4 | ================================================================================ 5 | Please, note, that you should obey original font licenses, used to make this 6 | webfont pack. Details available in LICENSE.txt file. 7 | 8 | - Usually, it's enough to publish content of LICENSE.txt file somewhere on your 9 | site in "About" section. 10 | 11 | - If your project is open-source, usually, it will be ok to make LICENSE.txt 12 | file publicly available in your repository. 13 | 14 | - Fonts, used in Fontello, don't require a clickable link on your site. 15 | But any kind of additional authors crediting is welcome. 16 | ================================================================================ 17 | 18 | 19 | Comments on archive content 20 | --------------------------- 21 | 22 | - /font/* - fonts in different formats 23 | 24 | - /css/* - different kinds of css, for all situations. Should be ok with 25 | twitter bootstrap. Also, you can skip style and assign icon classes 26 | directly to text elements, if you don't mind about IE7. 27 | 28 | - demo.html - demo file, to show your webfont content 29 | 30 | - LICENSE.txt - license info about source fonts, used to build your one. 31 | 32 | - config.json - keeps your settings. You can import it back into fontello 33 | anytime, to continue your work 34 | 35 | 36 | Why so many CSS files ? 37 | ----------------------- 38 | 39 | Because we like to fit all your needs :) 40 | 41 | - basic file, .css - is usually enough, it contains @font-face 42 | and character code definitions 43 | 44 | - *-ie7.css - if you need IE7 support, but still don't wish to put char codes 45 | directly into html 46 | 47 | - *-codes.css and *-ie7-codes.css - if you like to use your own @font-face 48 | rules, but still wish to benefit from css generation. That can be very 49 | convenient for automated asset build systems. When you need to update font - 50 | no need to manually edit files, just override old version with archive 51 | content. See fontello source code for examples. 52 | 53 | - *-embedded.css - basic css file, but with embedded WOFF font, to avoid 54 | CORS issues in Firefox and IE9+, when fonts are hosted on the separate domain. 55 | We strongly recommend to resolve this issue by `Access-Control-Allow-Origin` 56 | server headers. But if you ok with dirty hack - this file is for you. Note, 57 | that data url moved to separate @font-face to avoid problems with to_translate = array( "Here's your uploaded media URI:", "Error occured while processing your file. Please try again.", "upload", "choose file", "remove", "Extension \"%s\" not allowed. Allowed extensions are \"%s\"", "Maximum file size \"%s\" KB breached. Your file size was \"%s\" KB", "You must be logged-in to upload", "Permissions don't allow you to upload", "Error occured while processing your file" ); 13 | 14 | $AJAX_file_upload = new AJAX_file_upload(); 15 | $this->translations = array(); 16 | 17 | foreach( $this->to_translate as $i => $string ) { 18 | $this->translations[$i] = $AJAX_file_upload->translate( $string ); 19 | } 20 | 21 | } 22 | 23 | public function _init() { 24 | add_action('admin_menu', array( &$this, 'admin_menu' ) ); 25 | add_filter( "ajax_file_upload_settings", array( &$this, "filter_settings" ), 0 ); 26 | add_filter( "admin_init", array( &$this, "redirect" ) ); 27 | } 28 | 29 | public static function init() { 30 | $class = null == self::$instance ? new self : self::$instance; 31 | return $class->_init(); 32 | } 33 | 34 | public function admin_menu() { 35 | add_options_page( 'AJAX file upload', 'AJAX file upload', 'manage_options', 'ajax-file-upload', array( &$this, 'screen' ) ); 36 | add_submenu_page( 37 | '', 38 | "Welcome to AJAX File Upload", 39 | '', 40 | 'manage_options', 41 | 'afu-about', 42 | array( &$this, 'about_screen' ) 43 | ); 44 | } 45 | 46 | public function about_screen() { 47 | require 'afu-about.php'; 48 | } 49 | 50 | public function update() { 51 | 52 | if( ! isset( $_POST['_afu_nonce'] ) || !wp_verify_nonce( $_POST['_afu_nonce'], '_afu_nonce' ) ) { 53 | return; 54 | } 55 | 56 | $settings = isset( $_POST["settings"] ) ? $_POST["settings"] : array(); 57 | 58 | if( ! empty( $settings["max"] ) ) { 59 | if( (int) $settings["max"] > 0 ) { 60 | $settings["max"] = (int) $settings["max"]; 61 | } 62 | } 63 | 64 | if( ! empty( $settings["ext"] ) ) { 65 | 66 | $settings["ext"] = explode( ",", $settings["ext"] ); 67 | 68 | foreach( $settings["ext"] as $i => $ext ) { 69 | $settings["ext"][$i] = preg_replace('/\s+/', '', $ext); 70 | } 71 | 72 | } 73 | 74 | if( empty( $settings["permission"] ) ) { 75 | unset( $settings["permission"] ); 76 | } else { 77 | $settings["permission"] = sanitize_text_field( $settings["permission"] ); 78 | } 79 | 80 | update_option( "afu_settings", json_encode( $settings ) ); 81 | 82 | if( ! empty( $_POST["translate"] ) ) { 83 | 84 | $object = array(); 85 | foreach( $_POST["translate"] as $i => $string ) { 86 | $object[ $this->to_translate[$i] ] = sanitize_text_field( $string ); 87 | } 88 | 89 | update_option( "afu_transaltions", base64_encode( json_encode( $object ) ) ); 90 | 91 | wp_redirect( "options-general.php?page=ajax-file-upload&updated=true" ); 92 | exit; 93 | } 94 | 95 | echo '

Settings saved successfully.

'; 96 | 97 | } 98 | 99 | public function filter_settings( $settings ) { 100 | 101 | $meta = get_option( "afu_settings"); 102 | 103 | if( $meta ) { 104 | 105 | $meta = json_decode( $meta ); 106 | 107 | if( ! empty( $meta->max ) ) { 108 | $settings->max_size = (int) $meta->max; 109 | } 110 | 111 | if( ! empty( $meta->ext ) ) { 112 | $settings->extensions = (array) $meta->ext; 113 | } 114 | 115 | if( ! empty( $meta->permission ) ) { 116 | $settings->default_permission = (string) $meta->permission; 117 | } 118 | 119 | } 120 | 121 | return $settings; 122 | 123 | } 124 | 125 | public function screen() { 126 | 127 | $this->update(); 128 | 129 | ?> 130 | 131 |
132 | 133 |

AJAX file upload Documentation

134 | 135 |
136 | 137 |

Hello there! The following are only default settings which can be totally ignored when you set the shortcode attributes. For example, you have [ajax-file-upload unique_identifier=upload_cover_photo max_size=5000] in this case the max. upload size will be the one set in the shortcode attribute which is 5000 kb (5 MB)

138 | 139 |

In other words, these settings will be used only when they are not added to shortcode attribute or a unique_identifier attribute is not set. This attribute is used to get settings for the current shortcode from the database (security procedure, anyone can manipulate settings if you call them through the markup)

140 | 141 |

142 | 146 |

147 | 148 |

149 | 153 |

154 | 155 |

156 | 170 |

171 | 172 |

173 | 174 |

175 | Some basic optional translations:
176 | 177 | to_translate as $i => $string ) : ?> 178 | 179 | 183 | 184 | 185 | 186 |

187 | 188 | 189 |

190 | 191 |

More: AFU custom DOM events (JavaScript) - Using ajax_file_upload() function

192 | 193 | 194 |
195 | 196 |
197 | 198 | 2 | 3 | 4 | 278 | 279 | 291 | 292 | 293 |
294 |

295 | afu 296 | font demo 297 |

298 | 301 |
302 |
303 |
304 |
afuico-upload-cloud0xe800
305 |
afuico-ok0xe801
306 |
afuico-cancel0xe802
307 |
afuico-spin60xe803
308 |
309 |
310 | 311 | 312 | -------------------------------------------------------------------------------- /assets/js/main.js: -------------------------------------------------------------------------------- 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 8 | */ 9 | 10 | jQuery(document).ready(function($) { 11 | 12 | jQuery(document).on("change", "input[name='afu_file']", function(e) { 13 | 14 | var field = $(this) 15 | , container = field.closest(".afu-process-file") 16 | , file = field.val() 17 | , upload = jQuery( "label.upload", container ) 18 | , select = jQuery( "label.select", container ) 19 | , placeholder = jQuery( 'span', select ).text(); 20 | 21 | if( file ) { 22 | upload.removeAttr("disabled"); 23 | jQuery( "span", select ).text( " "+file.replace(/^.*[\\\/]/, '') ); 24 | } else { 25 | upload.attr("disabled", "disabled"); 26 | jQuery( "span", select ).text( placeholder ); 27 | } 28 | 29 | e.preventDefault(); 30 | 31 | }); 32 | 33 | 34 | jQuery(document).on("click", ".afu-process-file label.upload", function(e) { 35 | 36 | var upload = $(this) 37 | , container = upload.closest(".afu-process-file") 38 | , field = jQuery( "input[name='afu_file']", container ) 39 | , file = field.val() 40 | , remove = jQuery( "label.remove", container ) 41 | , nonce = jQuery( "input[name='_afu_nonce']", container ) 42 | , file_data = field.prop('files')[0] 43 | , form_data = new FormData() 44 | , ajaxurl = ajax_file_upload.ajax_path 45 | , select = jQuery( "label.select", container ) 46 | , task = JSON.parse( container.attr("data-task") ); 47 | 48 | if( "disabled" === upload.attr("disabled") ) { 49 | return; 50 | } 51 | 52 | upload.attr("disabled", "disabled"); 53 | 54 | if( "string" !== typeof ajaxurl ) { 55 | console.error("AJAX file upload error: path to admin ajax not set."); 56 | return; 57 | } 58 | 59 | if( nonce.length ) { 60 | nonce = nonce.val(); 61 | } 62 | 63 | if( ! file ) { 64 | console.error("AJAX file upload error: file not set."); 65 | return; 66 | } 67 | 68 | form_data.append('file', file_data); 69 | form_data.append('action', 'ajax_file_upload'); 70 | form_data.append('_afu_nonce', nonce); 71 | if( task.unique_identifier ) { 72 | form_data.append('id', task.unique_identifier); 73 | } 74 | 75 | if( task.on_success_set_input_value ) { 76 | if( jQuery( task.on_success_set_input_value ).length == 0 ) { 77 | console.error( "AJAX file upload error: Your field \"%s\" to set value was not found.", task.on_success_set_input_value ); 78 | task.on_success_set_input_value = false; 79 | } else { 80 | task.on_success_set_input_value = jQuery(task.on_success_set_input_value); 81 | } 82 | } 83 | 84 | if( task.show_preloader ) { 85 | if( jQuery( task.show_preloader ).length == 0 ) { 86 | console.error( "AJAX file upload error: Your preloader \"%s\" was not found.", task.show_preloader ); 87 | task.show_preloader = false; 88 | } else { 89 | task.show_preloader = jQuery(task.show_preloader); 90 | } 91 | } 92 | 93 | if( task.set_background_image ) { 94 | if( jQuery( task.set_background_image ).length == 0 ) { 95 | console.error( "AJAX file upload error: Your set-background-image selector \"%s\" was not found.", task.set_background_image ); 96 | task.set_background_image = false; 97 | } else { 98 | task.set_background_image = jQuery(task.set_background_image); 99 | } 100 | } 101 | 102 | if( task.set_image_source ) { 103 | if( jQuery( task.set_image_source ).length == 0 ) { 104 | console.error( "AJAX file upload error: Your set-image-source selector \"%s\" was not found.", task.set_image_source ); 105 | task.set_image_source = false; 106 | } else { 107 | task.set_image_source = jQuery(task.set_image_source); 108 | } 109 | } 110 | 111 | if( ! task.show_preloader ) { 112 | // if no preloader to show 113 | jQuery( "i.afuico", select ).attr("data-class", function(){ 114 | return $(this).prop("classList")[1]; 115 | }) 116 | .attr("class", function(){ 117 | return $(this).prop("classList")[0]+' afuico-spin6 animate-spin'; 118 | }) 119 | .closest("label").children("span").text(function(){ 120 | return task.default_loading_text ? " "+task.default_loading_text : $(this).text(); 121 | }); 122 | // end if no preloader to show 123 | } else { 124 | // show user preloader 125 | task.show_preloader.fadeIn(); 126 | } 127 | 128 | $.ajax({ 129 | url: ajaxurl, 130 | dataType: 'text', 131 | cache: false, 132 | contentType: false, 133 | processData: false, 134 | data: form_data, 135 | type: 'post', 136 | success: function( response ){ 137 | 138 | response = JSON.parse(response); 139 | 140 | ajax_file_upload.create_event( "afu_got_response", {"response": response, "selector": container} ); 141 | 142 | if( response.success ) { 143 | 144 | ajax_file_upload.create_event( "afu_file_uploaded", {"response": response, "selector": container} ); 145 | 146 | if( task.on_success_alert ) { 147 | alert( task.on_success_alert ); 148 | } 149 | 150 | if( task.on_success_set_input_value ) { 151 | task.on_success_set_input_value.val(response.media_uri); 152 | } 153 | 154 | if( task.on_success_dialog_prompt_value ) { 155 | window.prompt( task.on_success_dialog_prompt_value, response.media_uri ); 156 | } 157 | 158 | if( task.set_background_image ) { 159 | task.set_background_image.css({"background-image": "url('"+response.media_uri+"')"}); 160 | } 161 | 162 | if( task.set_image_source ) { 163 | task.set_image_source.attr("data-src", task.set_image_source.attr("src")); 164 | task.set_image_source.attr("src", response.media_uri); 165 | } 166 | 167 | if( task.disallow_reupload ) { 168 | select.removeAttr("for").attr("onclick", "return"); 169 | upload.fadeOut(200, function(){ 170 | $(this).remove(); 171 | }); 172 | } 173 | 174 | if ( remove ) { 175 | remove.removeAttr("disabled"); 176 | } 177 | 178 | select.children("span").text(function(){ 179 | return $(this).attr("data-text"); 180 | }); 181 | 182 | } else { 183 | 184 | upload.removeAttr("disabled", "disabled"); 185 | ajax_file_upload.create_event( "afu_error_uploading", {"response": response, "selector": container} ); 186 | 187 | if( task.on_fail_alert_error_message && response.error_message ) { 188 | alert(response.error_message); 189 | } 190 | 191 | else if( task.on_fail_alert ) { 192 | alert( task.on_fail_alert ); 193 | } 194 | 195 | if ( remove ) { 196 | remove.attr("disabled", "disabled"); 197 | } 198 | 199 | } 200 | 201 | if( ! task.show_preloader ) { 202 | // if no preloader to show 203 | jQuery( "i.afuico", select ).attr("class", function(){ 204 | return $(this).prop("className").replace(/afuico-spin6 animate-spin/g, $(this).attr('data-class')); 205 | }) 206 | // end if no preloader to show 207 | } else { 208 | // hide user preloader 209 | task.show_preloader.fadeOut(); 210 | } 211 | 212 | }, 213 | error: function() { 214 | 215 | console.error( "Error while uploading file" ); 216 | upload.removeAttr("disabled", "disabled"); 217 | ajax_file_upload.create_event( "afu_error_uploading", {"success": false, "error_message": "$.ajax error", "selector": container } ); 218 | 219 | if( ! task.show_preloader ) { 220 | // if no preloader to show 221 | jQuery( "i.afuico", select ).attr("class", function(){ 222 | return $(this).prop("className").replace(/afuico-spin6 animate-spin/g, $(this).attr('data-class')); 223 | }) 224 | // end if no preloader to show 225 | } else { 226 | // hide user preloader 227 | task.show_preloader.fadeOut(); 228 | } 229 | 230 | if( task.on_fail_alert ) { 231 | alert( task.on_fail_alert ); 232 | } 233 | 234 | } 235 | }); 236 | 237 | e.preventDefault(); 238 | 239 | }); 240 | 241 | 242 | jQuery(document).on("click", ".afu-process-file label.remove", function(e) { 243 | 244 | var remove = $(this) 245 | , container = remove.closest(".afu-process-file") 246 | , upload = jQuery( "label.upload", container ) 247 | , field = jQuery( "input[name='afu_file']", container ) 248 | , file = field.val() 249 | , select = jQuery( "label.select", container ) 250 | , task = JSON.parse( container.attr("data-task") ); 251 | 252 | if( "disabled" === remove.attr("disabled") ) { 253 | return; 254 | } 255 | remove.attr("disabled", "disabled"); 256 | 257 | ajax_file_upload.create_event( "afu_file_removed", { "this": remove, "container": container } ); 258 | 259 | if( task.on_success_set_input_value && jQuery(task.on_success_set_input_value).length ) { 260 | jQuery(task.on_success_set_input_value).val(''); 261 | } 262 | 263 | if( task.set_background_image && jQuery(task.set_background_image).length ) { 264 | jQuery(task.set_background_image).css({"background-image": ""}); 265 | } 266 | 267 | if( task.set_image_source && jQuery(task.set_image_source).length ) { 268 | jQuery(task.set_image_source).attr("src", function(){ 269 | return $(this).attr("src"); 270 | }); 271 | } 272 | 273 | if( task.disallow_reupload ) { 274 | select.removeAttr("for").attr("onclick", "return"); 275 | upload.fadeOut(200, function(){ 276 | $(this).remove(); 277 | }); 278 | remove.fadeOut(200, function(){ 279 | $(this).remove(); 280 | }); 281 | } 282 | 283 | e.preventDefault(); 284 | 285 | }); 286 | 287 | }); -------------------------------------------------------------------------------- /assets/fontello/css/afu-embedded.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'afu'; 3 | src: url('../font/afu.eot?57847401'); 4 | src: url('../font/afu.eot?57847401#iefix') format('embedded-opentype'), 5 | url('../font/afu.svg?57847401#afu') format('svg'); 6 | font-weight: normal; 7 | font-style: normal; 8 | } 9 | @font-face { 10 | font-family: 'afu'; 11 | src: url('data:application/octet-stream;base64,d09GRgABAAAAAAzQAA8AAAAAFXwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABWAAAADMAAABCsP6z7U9TLzIAAAGMAAAAQwAAAFY+IEldY21hc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gjQrBIKy2wSiyyAABBKy2wSyyyAAFBKy2wTCyyAQBBKy2wTSyyAQFBKy2wTiyyAABCKy2wTyyyAAFCKy2wUCyyAQBCKy2wUSyyAQFCKy2wUiyyAAA+Ky2wUyyyAAE+Ky2wVCyyAQA+Ky2wVSyyAQE+Ky2wViyyAABAKy2wVyyyAAFAKy2wWCyyAQBAKy2wWSyyAQFAKy2wWiyyAABDKy2wWyyyAAFDKy2wXCyyAQBDKy2wXSyyAQFDKy2wXiyyAAA/Ky2wXyyyAAE/Ky2wYCyyAQA/Ky2wYSyyAQE/Ky2wYiywNysusSsBFCstsGMssDcrsDsrLbBkLLA3K7A8Ky2wZSywABawNyuwPSstsGYssDgrLrErARQrLbBnLLA4K7A7Ky2waCywOCuwPCstsGkssDgrsD0rLbBqLLA5Ky6xKwEUKy2wayywOSuwOystsGwssDkrsDwrLbBtLLA5K7A9Ky2wbiywOisusSsBFCstsG8ssDorsDsrLbBwLLA6K7A8Ky2wcSywOiuwPSstsHIsswkEAgNFWCEbIyFZQiuwCGWwAyRQeLABFTAtAEu4AMhSWLEBAY5ZsAG5CAAIAGNwsQAFQrIAAQAqsQAFQrMKAgEIKrEABUKzDgABCCqxAAZCugLAAAEACSqxAAdCugBAAAEACSqxAwBEsSQBiFFYsECIWLEDZESxJgGIUVi6CIAAAQRAiGNUWLEDAERZWVlZswwCAQwquAH/hbAEjbECAEQAAA==') format('truetype'); 13 | } 14 | /* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */ 15 | /* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */ 16 | /* 17 | @media screen and (-webkit-min-device-pixel-ratio:0) { 18 | @font-face { 19 | font-family: 'afu'; 20 | src: url('../font/afu.svg?57847401#afu') format('svg'); 21 | } 22 | } 23 | */ 24 | 25 | [class^="afuico-"]:before, [class*=" afuico-"]:before { 26 | font-family: "afu"; 27 | font-style: normal; 28 | font-weight: normal; 29 | speak: none; 30 | 31 | display: inline-block; 32 | text-decoration: inherit; 33 | width: 1em; 34 | margin-right: .2em; 35 | text-align: center; 36 | /* opacity: .8; */ 37 | 38 | /* For safety - reset parent styles, that can break glyph codes*/ 39 | font-variant: normal; 40 | text-transform: none; 41 | 42 | /* fix buttons height, for twitter bootstrap */ 43 | line-height: 1em; 44 | 45 | /* Animation center compensation - margins should be symmetric */ 46 | /* remove if not needed */ 47 | margin-left: .2em; 48 | 49 | /* you can be more comfortable with increased icons size */ 50 | /* font-size: 120%; */ 51 | 52 | /* Uncomment for 3D effect */ 53 | /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */ 54 | } 55 | .afuico-upload-cloud:before { content: '\e800'; } /* '' */ 56 | .afuico-ok:before { content: '\e801'; } /* '' */ 57 | .afuico-cancel:before { content: '\e802'; } /* '' */ 58 | .afuico-spin6:before { content: '\e803'; } /* '' */ -------------------------------------------------------------------------------- /ajax-file-upload.php: -------------------------------------------------------------------------------- 1 | max_size = 2000; 22 | $settings->extensions = array( 'png', 'jpg', 'bmp', 'gif', 'txt', 'mp3', 'mp4', '3gp' ); 23 | $settings->default_permission = 'all'; 24 | 25 | $this->settings = apply_filters( "ajax_file_upload_settings", $settings ); 26 | 27 | } 28 | 29 | public function _init() { 30 | 31 | add_shortcode('ajax-file-upload', array( &$this, '_shortcode' )); 32 | add_action( 'wp_ajax_ajax_file_upload', array( &$this, 'ajax' ) ); 33 | add_action( 'wp_ajax_nopriv_ajax_file_upload', array( &$this, 'ajax' ) ); 34 | add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); 35 | add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); 36 | 37 | if( file_exists( $this->template_path( 'includes/admin.php', true ) ) ) { 38 | require $this->template_path( 'includes/admin.php', true ); 39 | } 40 | 41 | add_filter( "plugin_action_links_" . plugin_basename(__FILE__), array( &$this, 'push_admin_links' ) ); 42 | 43 | } 44 | 45 | public static function shortcode( $atts, $custom = false ) { 46 | $class = null == self::$instance ? new self : self::$instance; 47 | return $class->_shortcode( $atts, $custom ); 48 | } 49 | 50 | public static function init() { 51 | $class = null == self::$instance ? new self : self::$instance; 52 | return $class->_init(); 53 | } 54 | 55 | public static function settings() { 56 | $class = null == self::$instance ? new self : self::$instance; 57 | return $class->$settings; 58 | } 59 | 60 | 61 | public function _shortcode( $atts, $custom = false ) { 62 | 63 | $a = shortcode_atts( array( 64 | 65 | 'unique_identifier' => '', 66 | 'max_size' => '', 67 | 'allowed_extensions' => '', 68 | 'permissions' => '', 69 | 'on_success_alert' => '', 70 | 'on_success_set_input_value' => '', 71 | 'on_fail_alert' => '', 72 | 'set_background_image' => '', 73 | 'set_image_source' => '', 74 | 'disallow_remove_button' => '', 75 | 'disallow_reupload' => '', 76 | 'upload_button_value' => '', 77 | 'select_file_button_value' => '', 78 | 'remove_file_button_value' => '', 79 | 'show_preloader' => '', 80 | 'default_loading_text' => '', 81 | 'on_success_dialog_prompt_value' => '', 82 | 'on_fail_alert_error_message' => '', 83 | 84 | ), $atts ); 85 | 86 | $data_task = array(); 87 | 88 | foreach ( $a as $id => $att ) { 89 | 90 | if( empty( $att ) ) { 91 | $a[$id] = $this->default_atts_values( array( $id => $att ) ); 92 | } 93 | 94 | switch( $id ) { 95 | 96 | case 'max_size': 97 | $a[$id] = (int) $a[$id]; 98 | break; 99 | 100 | case 'allowed_extensions': 101 | 102 | if( ! is_array( $a[$id] ) ) { 103 | $a[$id] = explode( ",", $a[$id] ); 104 | $a[$id] = array_filter( array_unique( $a[$id] ) ); 105 | } 106 | 107 | break; 108 | 109 | case 'on_success_dialog_prompt_value': 110 | 111 | if( isset( $a[$id] ) && empty( $a[$id] ) ) { 112 | $a[$id] = $this->translate( "Here's your uploaded media URI:" ); 113 | } 114 | break; 115 | 116 | // validate other atts !! 117 | 118 | } 119 | 120 | $data_task[$id] = $a[$id]; 121 | 122 | } 123 | 124 | foreach ( $data_task as $id => $att ) { if ( ! $att ) unset( $data_task[$id] ); } 125 | 126 | 127 | // base64 encode 128 | 129 | update_option( 130 | "afu_" . preg_replace('/[^\da-z]/i', '', $a['unique_identifier']) . "_upload_settings", 131 | base64_encode(json_encode( $data_task )) 132 | ); 133 | 134 | $data_task = str_replace( '"', '"', json_encode( $data_task ) ); 135 | 136 | require $this->template_path( 'includes/shortcode-template.php', true ); 137 | 138 | } 139 | 140 | public function default_atts_values( $att ) { 141 | 142 | if( ! is_array( $att ) ) { return; } 143 | 144 | foreach ( $att as $id => $value ) { 145 | 146 | switch ( $id ) { 147 | 148 | case 'max_size': 149 | return $this->settings->max_size; // 1 MB 150 | break; 151 | 152 | case 'permissions': 153 | return 'all'; 154 | break; 155 | 156 | case 'on_fail_alert': 157 | return $this->translate('Error occured while processing your file. Please try again.'); 158 | break; 159 | 160 | case 'upload_button_value': 161 | return $this->translate('upload'); 162 | break; 163 | 164 | case 'select_file_button_value': 165 | return $this->translate('choose file'); 166 | break; 167 | 168 | case 'remove_file_button_value': 169 | return $this->translate('remove'); 170 | break; 171 | 172 | case 'allowed_extensions': 173 | return $this->settings->extensions; 174 | break; 175 | 176 | case 'disallow_remove_button': 177 | return false; 178 | break; 179 | 180 | case 'disallow_reupload': 181 | return false; 182 | break; 183 | 184 | case 'default_loading_text': 185 | return 'uploading..'; 186 | break; 187 | 188 | case 'on_fail_alert_error_message': 189 | return true; 190 | break; 191 | 192 | default: 193 | break; 194 | 195 | } 196 | 197 | } 198 | 199 | return; 200 | 201 | } 202 | 203 | public function upload() {} 204 | 205 | public function process_file( $file = array() ) { 206 | 207 | do_action('afu_before_start_upload', $file); 208 | 209 | require_once( ABSPATH . 'wp-admin/includes/admin.php' ); 210 | 211 | $args = wp_handle_upload( $file, array('test_form' => false ) ); 212 | 213 | if( isset( $args['error'] ) || isset( $args['upload_error_handler'] ) ) { 214 | return false; 215 | } else { 216 | do_action('afu_after_upload_done', $args); 217 | return apply_filters( 'afu_returned_file_url', $args['url'], $args ); 218 | } 219 | 220 | return; 221 | 222 | } 223 | 224 | public function ajax() { 225 | 226 | $response = array(); 227 | $response['success'] = false; 228 | 229 | if( ! isset( $_REQUEST['_afu_nonce'] ) || !wp_verify_nonce( $_REQUEST['_afu_nonce'], '_afu_nonce' ) ) { 230 | header("Content-type: application/json; charset=utf-8"); 231 | $response["error_message"] = "Error while uploading: authenticate error"; 232 | echo json_encode( $response ); 233 | exit; 234 | } 235 | 236 | if( ! empty( $_FILES ) ) { 237 | 238 | foreach( $_FILES as $file ) { 239 | 240 | if( ! empty( $_REQUEST['id'] ) ) { 241 | $settings = get_option( "afu_" . preg_replace('/[^\da-z]/i', '', $_REQUEST['id']) . "_upload_settings" ); 242 | $settings = json_decode( base64_decode( $settings ) ); 243 | } 244 | 245 | $defaul_settings = $this->settings; 246 | 247 | if( empty( $settings->max_size ) ) { 248 | $settings->max_size = $defaul_settings->max_size; 249 | } 250 | 251 | if( empty( $settings->permissions ) ) { 252 | $settings->permission = $defaul_settings->default_permission; 253 | } else { 254 | $settings->permission = $settings->permissions; 255 | unset( $settings->permissions ); 256 | } 257 | 258 | if( empty( $settings->allowed_extensions ) || ! is_array( $settings->allowed_extensions ) ) { 259 | $settings->extensions = $defaul_settings->extensions; 260 | } else { 261 | $settings->extensions = $settings->allowed_extensions; 262 | } 263 | 264 | $bail = false; 265 | $pathinfo = pathinfo( $file['name'] ); 266 | 267 | if( empty( $pathinfo ) || ! is_array( $file ) ) { 268 | $bail = true; 269 | } 270 | 271 | // convert file size to KB 272 | $file['size'] = intval( $file['size'] / 1024 ); 273 | 274 | if( ! $pathinfo['extension'] || ! in_array( strtolower($pathinfo['extension']), $settings->extensions ) ) { 275 | $bail = true; 276 | $response['error_message'] = sprintf( 277 | $this->translate("Extension \"%s\" not allowed. Allowed extensions are \"%s\""), 278 | $pathinfo['extension'], 279 | implode( ", ", $settings->extensions ) 280 | ); 281 | } 282 | 283 | elseif ( $file['size'] > $settings->max_size ) { 284 | $bail = true; 285 | $response['error_message'] = sprintf( 286 | $this->translate("Maximum file size \"%s\" KB breached. Your file size was \"%s\" KB"), 287 | $settings->max_size, 288 | $file['size'] 289 | ); 290 | } 291 | 292 | 293 | if( ! $bail ) { 294 | if( "all" == $settings->permission ) { 295 | $bail = false; 296 | } 297 | elseif ( "logged_in" == $settings->permission ) { 298 | if( ! is_user_logged_in() ) { 299 | $bail = true; 300 | $response['error_message'] = sprintf( 301 | $this->translate("You must be logged-in to upload") 302 | ); 303 | } 304 | } 305 | else { 306 | // custom role 307 | if( ! in_array( $settings->permission, wp_get_current_user()->roles ) ) { 308 | $bail = true; 309 | $response['error_message'] = sprintf( 310 | $this->translate("Permissions don't allow you to upload") 311 | ); 312 | } 313 | } 314 | } 315 | 316 | $bail = apply_filters( "afu_bail_upload", $bail, $file, $settings ); 317 | 318 | if( ! $bail ) { 319 | $media = $this->process_file( $file ); 320 | $response['success'] = false !== $media; 321 | $response['media_uri'] = $media; 322 | } else { 323 | $response['success'] = false; 324 | } 325 | 326 | if( false === $response['success'] && empty( $response['error_message'] ) ) { 327 | $response['error_message'] = $this->translate("Error occured while processing your file" ); 328 | } 329 | 330 | $response["settings"] = $settings; 331 | $response["file"] = $file; 332 | 333 | } 334 | } 335 | 336 | header("Content-type: application/json; charset=utf-8"); 337 | echo json_encode( $response ); 338 | exit; 339 | 340 | } 341 | 342 | public function translate( $string ) { 343 | 344 | $meta = get_option( "afu_transaltions" ); 345 | 346 | if( $meta ) { 347 | $meta = json_decode( base64_decode( $meta ), true ); 348 | 349 | if( ! empty( $meta[$string] ) ) { 350 | return (string) stripslashes( $meta[$string] ); 351 | } 352 | } 353 | 354 | return $string; 355 | 356 | } 357 | 358 | public function enqueue_scripts() { 359 | 360 | wp_enqueue_style( 'afu', $this->template_path( 'assets/css/style.css' ) ); 361 | wp_enqueue_style( 'afu-icons', $this->template_path( 'assets/fontello/css/afu.css' ) ); 362 | wp_enqueue_style( 'afu-icons-animation', $this->template_path( 'assets/fontello/css/animation.css' ) ); 363 | 364 | wp_enqueue_script( 365 | 'afu', 366 | $this->template_path( 'assets/js/main.js' ), 367 | array('jquery'), 368 | null 369 | ); 370 | 371 | } 372 | 373 | public function wp_footer() { 374 | ?> 375 | 389 | ' . __( 'Settings' ) . '' ); 410 | array_push( $links, '' . __( 'About' ) . '' ); 411 | 412 | return $links; 413 | 414 | } 415 | 416 | } 417 | 418 | endif; 419 | 420 | // initialize the plugin 421 | AJAX_file_upload::init(); 422 | 423 | 424 | /** 425 | * Initialize the function ajax_file_upload( arguments ) 426 | * and other functions 427 | */ 428 | 429 | add_action('init', 'ajax_file_upload_init_function'); 430 | 431 | function ajax_file_upload_init_function() { 432 | 433 | /** 434 | * Use it in your template if you don't want to use the shortcode 435 | * or do_shortcode in your coding. 436 | * attributes this time can be inserted as array in first param 437 | * 438 | * @since 0.1 439 | * @param $atts array attributes (optional) 440 | * @return str render shortcode template 441 | */ 442 | 443 | if ( ! function_exists('ajax_file_upload') ) { 444 | function ajax_file_upload( $atts = array() ) { 445 | return AJAX_file_upload::shortcode( $atts, true ); 446 | } 447 | } 448 | 449 | if ( ! function_exists('ajax_file_upload_settings') ) { 450 | function ajax_file_upload_settings() { 451 | $class = new AJAX_file_upload(); 452 | return $class->settings; 453 | } 454 | } 455 | 456 | } 457 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |

Welcome to AJAX File Upload v. 0.1!

4 | 5 |

Thank you for using AJAX File Upload to quickly process your uploads on the go!

6 | 7 |
preview A small preview WpChats 3.0 profile edit
8 | 9 |

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 |

The Shortcode

14 | 15 |

You can use [ajax-file-upload] to output the AJAX file uploader, set its settings, markup, and much more through the shortcode attributes.

16 | 17 |

Shortcode attributes

18 | 19 | 43 | 44 |
45 | 46 |

1. unique_identifier — required

47 |

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"

48 | 49 |

2. max_size — optional

50 |

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

51 | 52 |

3. allowed_extensions — optional

53 |

With this attribute you can set the allowed file extensions to upload. Please separate the extensions with commas.
Example use: allowed_extensions="pdf,txt"

54 | 55 |

4. permissions — optional

56 |

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.

57 | 58 |

5. on_success_alert — optional

59 |

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"

60 | 61 |

6. on_fail_alert — optional

62 |

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?"

63 | 64 |

7. on_fail_alert_error_message — optional

65 |

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"

66 | 67 |

8. on_success_set_input_value — optional

68 |

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"

69 | 70 |

9. set_background_image — optional

71 |

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"

72 | 73 |

10. set_image_source — optional

74 |

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"

75 | 76 |

11. disallow_remove_button — optional

77 |

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"

78 | 79 |

12. disallow_reupload — optional

80 |

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=""

81 | 82 |

13 upload_button_value — optional

83 |

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"

84 | 85 |

14. select_file_button_value — optional

86 |

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"

87 | 88 |

15. remove_file_button_value — optional

89 |

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"

90 | 91 |

16. show_preloader — optional

92 |

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"

93 | 94 |

17. default_loading_text — optional

95 |

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.."

96 | 97 |

18. on_success_dialog_prompt_value — optional

98 |

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!"

99 | 100 |
101 | 102 |

The function

103 | 104 |

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.

105 | 106 |

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..

107 | 108 |

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 |

Further usage

119 | 120 |

Child theme

121 | 122 |

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..

123 | 124 |

JavaScript events

125 | 126 |

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_got_response

129 | 130 |

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:

131 | 132 |
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.

141 | 142 |

143 | 144 |

afu_file_uploaded

145 | 146 |

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

147 | 148 |
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 |

afu_error_uploading

156 | 157 |

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 |

afu_file_removed

165 | 166 |

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 |

Thank you!

175 | 176 |

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 |
189 | -------------------------------------------------------------------------------- /includes/afu-about.php: -------------------------------------------------------------------------------- 1 | '', 5 | 'max_size' => '', 6 | 'allowed_extensions' => '', 7 | 'permissions' => '', 8 | 'on_success_alert' => '', 9 | 'on_fail_alert' => '', 10 | 'on_fail_alert_error_message' => '', 11 | 'on_success_set_input_value' => '', 12 | 'set_background_image' => '', 13 | 'set_image_source' => '', 14 | 'disallow_remove_button' => '', 15 | 'disallow_reupload' => '', 16 | 'upload_button_value' => '', 17 | 'select_file_button_value' => '', 18 | 'remove_file_button_value' => '', 19 | 'show_preloader' => '', 20 | 'default_loading_text' => '', 21 | 'on_success_dialog_prompt_value' => '', 22 | ); 23 | 24 | ?> 25 | 26 |
27 | 28 |

Welcome to AJAX File Upload v. 0.1!

29 | 30 |

Thank you for using AJAX File Upload to quickly process your uploads on the go!

31 | 32 |
preview

A small preview

WpChats 3.0 profile edit
33 | 34 |

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 |

The Shortcode

41 | 42 |

You can use [ajax-file-upload] to output the AJAX file uploader, set its settings, markup, and much more through the shortcode attributes.

43 | 44 |

Shortcode attributes

45 | 46 |
47 | 48 |
    49 | $val ) : ?> 50 |
  1. >
  2. 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |

1. unique_identifier — required

59 |

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"

60 | 61 |

2. max_size — optional

62 |

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

63 | 64 |

3. allowed_extensions — optional

65 |

With this attribute you can set the allowed file extensions to upload. Please separate the extensions with commas.
Example use: allowed_extensions="pdf,txt"

66 | 67 |

4. permissions — optional

68 |

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.

69 | 70 |

5. on_success_alert — optional

71 |

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"

72 | 73 |

6. on_fail_alert — optional

74 |

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?"

75 | 76 |

7. on_fail_alert_error_message — optional

77 |

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"

78 | 79 |

8. on_success_set_input_value — optional

80 |

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"

81 | 82 |

9. set_background_image — optional

83 |

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"

84 | 85 |

10. set_image_source — optional

86 |

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"

87 | 88 |

11. disallow_remove_button — optional

89 |

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"

90 | 91 |

12. disallow_reupload — optional

92 |

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=""

93 | 94 |

13 upload_button_value — optional

95 |

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"

96 | 97 |

14. select_file_button_value — optional

98 |

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"

99 | 100 |

15. remove_file_button_value — optional

101 |

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"

102 | 103 |

16. show_preloader — optional

104 |

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"

105 | 106 |

17. default_loading_text — optional

107 |

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.."

108 | 109 |

18. on_success_dialog_prompt_value — optional

110 |

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!"

111 | 112 |
113 | 114 |

The function

115 | 116 |

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.

117 | 118 |

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..

119 | 120 |

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 |

Further usage

132 | 133 |

Child theme

134 | 135 |

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..

136 | 137 |

JavaScript events

138 | 139 |

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_got_response

142 | 143 |

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:

144 | 145 |
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.

155 | 156 |

157 | 158 |

afu_file_uploaded

159 | 160 |

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

161 | 162 |
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 |

afu_error_uploading

171 | 172 |

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 |

afu_file_removed

181 | 182 |

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 |

Thank you!

192 | 193 |

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 |

Go to settings

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 |
208 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 6 | 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | Preamble 11 | 12 | The licenses for most software are designed to take away your 13 | freedom to share and change it. By contrast, the GNU General Public 14 | License is intended to guarantee your freedom to share and change free 15 | software--to make sure the software is free for all its users. This 16 | General Public License applies to most of the Free Software 17 | Foundation's software and to any other program whose authors commit to 18 | using it. (Some other Free Software Foundation software is covered by 19 | the GNU Library General Public License instead.) You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | this service if you wish), that you receive source code or can get it 26 | if you want it, that you can change the software or use pieces of it 27 | in new free programs; and that you know you can do these things. 28 | 29 | To protect your rights, we need to make restrictions that forbid 30 | anyone to deny you these rights or to ask you to surrender the rights. 31 | These restrictions translate to certain responsibilities for you if you 32 | distribute copies of the software, or if you modify it. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must give the recipients all the rights that 36 | you have. You must make sure that they, too, receive or can get the 37 | source code. And you must show them these terms so they know their 38 | rights. 39 | 40 | We protect your rights with two steps: (1) copyright the software, and 41 | (2) offer you this license which gives you legal permission to copy, 42 | distribute and/or modify the software. 43 | 44 | Also, for each author's protection and ours, we want to make certain 45 | that everyone understands that there is no warranty for this free 46 | software. If the software is modified by someone else and passed on, we 47 | want its recipients to know that what they have is not the original, so 48 | that any problems introduced by others will not reflect on the original 49 | authors' reputations. 50 | 51 | Finally, any free program is threatened constantly by software 52 | patents. We wish to avoid the danger that redistributors of a free 53 | program will individually obtain patent licenses, in effect making the 54 | program proprietary. To prevent this, we have made it clear that any 55 | patent must be licensed for everyone's free use or not licensed at all. 56 | 57 | The precise terms and conditions for copying, distribution and 58 | modification follow. 59 | 60 | GNU GENERAL PUBLIC LICENSE 61 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 62 | 63 | 0. This License applies to any program or other work which contains 64 | a notice placed by the copyright holder saying it may be distributed 65 | under the terms of this General Public License. The "Program", below, 66 | refers to any such program or work, and a "work based on the Program" 67 | means either the Program or any derivative work under copyright law: 68 | that is to say, a work containing the Program or a portion of it, 69 | either verbatim or with modifications and/or translated into another 70 | language. (Hereinafter, translation is included without limitation in 71 | the term "modification".) Each licensee is addressed as "you". 72 | 73 | Activities other than copying, distribution and modification are not 74 | covered by this License; they are outside its scope. The act of 75 | running the Program is not restricted, and the output from the Program 76 | is covered only if its contents constitute a work based on the 77 | Program (independent of having been made by running the Program). 78 | Whether that is true depends on what the Program does. 79 | 80 | 1. You may copy and distribute verbatim copies of the Program's 81 | source code as you receive it, in any medium, provided that you 82 | conspicuously and appropriately publish on each copy an appropriate 83 | copyright notice and disclaimer of warranty; keep intact all the 84 | notices that refer to this License and to the absence of any warranty; 85 | and give any other recipients of the Program a copy of this License 86 | along with the Program. 87 | 88 | You may charge a fee for the physical act of transferring a copy, and 89 | you may at your option offer warranty protection in exchange for a fee. 90 | 91 | 2. You may modify your copy or copies of the Program or any portion 92 | of it, thus forming a work based on the Program, and copy and 93 | distribute such modifications or work under the terms of Section 1 94 | above, provided that you also meet all of these conditions: 95 | 96 | a) You must cause the modified files to carry prominent notices 97 | stating that you changed the files and the date of any change. 98 | 99 | b) You must cause any work that you distribute or publish, that in 100 | whole or in part contains or is derived from the Program or any 101 | part thereof, to be licensed as a whole at no charge to all third 102 | parties under the terms of this License. 103 | 104 | c) If the modified program normally reads commands interactively 105 | when run, you must cause it, when started running for such 106 | interactive use in the most ordinary way, to print or display an 107 | announcement including an appropriate copyright notice and a 108 | notice that there is no warranty (or else, saying that you provide 109 | a warranty) and that users may redistribute the program under 110 | these conditions, and telling the user how to view a copy of this 111 | License. (Exception: if the Program itself is interactive but 112 | does not normally print such an announcement, your work based on 113 | the Program is not required to print an announcement.) 114 | 115 | These requirements apply to the modified work as a whole. If 116 | identifiable sections of that work are not derived from the Program, 117 | and can be reasonably considered independent and separate works in 118 | themselves, then this License, and its terms, do not apply to those 119 | sections when you distribute them as separate works. But when you 120 | distribute the same sections as part of a whole which is a work based 121 | on the Program, the distribution of the whole must be on the terms of 122 | this License, whose permissions for other licensees extend to the 123 | entire whole, and thus to each and every part regardless of who wrote it. 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | --------------------------------------------------------------------------------