Changeset 1346074
- Timestamp:
- 02/08/2016 05:27:12 PM (10 years ago)
- Location:
- cloudwok-file-upload/trunk
- Files:
-
- 2 edited
-
cloudwok.php (modified) (8 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cloudwok-file-upload/trunk/cloudwok.php
r1337410 r1346074 4 4 Plugin URI: http://www.cloudwok.com 5 5 Description: CloudWok enables you to let your website visitors upload files directly into a Dropbox, Google Drive, Amazon S3, Box.com, or other cloud storage folder that you own. 6 Version: 0.4. 36 Version: 0.4.4 7 7 Author: CloudWok 8 8 Author Email: [email protected] … … 28 28 29 29 if (!defined('ABSPATH')) die(); 30 31 class WokDataConfigDropzone { 32 public $label = ""; 33 public $button = ""; 34 } 35 36 class WokDataConfigSuccess {} 37 38 class WokDataConfigSuccessMessage { 39 public $title = ""; 40 public $subtitle = ""; 41 public $text = ""; 42 } 43 44 class WokDataConfigForm { 45 public $button = ""; 46 public $sent = ""; 47 } 48 49 class WokDataConfigFormEmail { 50 public $placeholder = ""; 51 public $optional = false; 52 } 53 54 class WokDataConfigFormName {} 55 56 class WokDataConfigFormNameFirstName { 57 public $placeholder = ""; 58 public $required = false; 59 } 60 61 class WokDataConfigFormNameLastName { 62 public $placeholder = ""; 63 public $required = false; 64 } 65 66 class WokDataConfigFormMessage { 67 public $placeholder = ""; 68 public $optional = false; 69 } 70 71 class WokDataConfig {} 30 72 31 73 // Add Shortcode … … 44 86 } 45 87 88 // init wok data-config 89 $wdc = new WokDataConfig(); 90 $wdc->dropzone = new WokDataConfigDropzone(); 91 $wdc->success = new WokDataConfigSuccess(); 92 $wdc->success->message = new WokDataConfigSuccessMessage(); 93 $wdc->form = new WokDataConfigForm(); 94 $wdc->form->email = new WokDataConfigFormEmail(); 95 $wdc->form->name = new WokDataConfigFormName(); 96 $wdc->form->name->firstname = new WokDataConfigFormNameFirstName(); 97 $wdc->form->name->lastname = new WokDataConfigFormNameLastName(); 98 $wdc->form->message = new WokDataConfigFormMessage(); 99 46 100 // Attributes 47 101 extract( shortcode_atts( 48 102 array( 103 'config' => '', 49 104 'wok_id' => '', 50 105 'show_uploads' => True, … … 62 117 'label_send_msg_btn' => '', 63 118 'label_dropzone' => '', 119 'success_message_title' => '', 120 'success_message_subtitle' => '', 121 'success_message_text' => '', 64 122 'label_send_msg_placeholder' => '', 65 123 'label_send_email_placeholder' => '', … … 84 142 85 143 // customize labels and texts 144 $customizeDataConfig = ''; 86 145 $customizeDropzone = ''; 87 146 $customizeMessages = ''; 88 147 148 // break if no wok_id was entered 149 if(!array_key_exists('wok_id', $atts)) { 150 return "Please enter your 4-letter wok id (create a wok on https://www.cloudwok.com)"; 151 } 152 89 153 if(array_key_exists('show_uploads', $atts) && $atts['show_uploads'] == "True") { 90 154 $show_uploads = '<div class="cloudwok-upload-files"></div>'; … … 92 156 if(array_key_exists('show_form', $atts) && $atts['show_form'] == "True") { 93 157 $show_form = '<div class="cloudwok-upload-message"></div>'; 94 }95 if(array_key_exists('show_form_input_name', $atts) && $atts['show_form_input_name'] == "True") {96 $show_form_input_name = ' data-show-name="y"';97 }98 if(array_key_exists('show_form_input_email', $atts) && $atts['show_form_input_email'] == "True") {99 $show_form_input_email = ' data-show-email="y"';100 158 } 101 159 if(array_key_exists('hide_form_message_text', $atts) && $atts['hide_form_message_text'] == "True") { … … 123 181 } 124 182 125 // custom labels 126 if(array_key_exists('label_add_files_btn', $atts) || array_key_exists('label_dropzone', $atts)) { 127 $customizeDropzone = 'document.querySelector( ".cloudwok-embed .cloudwok-dropzone").addEventListener("DOMNodeInserted", customizeDropzone, false); 128 function customizeDropzone(e) { 129 if(e.target && e.target.nodeName == "DIV") { 130 '; 131 if(array_key_exists('label_add_files_btn', $atts)) { 132 $customizeDropzone = $customizeDropzone . 'document.querySelector(".cloudwok-embed .dropzone span.lead > .fileinput-button > span" ).innerHTML = "' . $atts['label_add_files_btn'] . '";'; 133 } 134 if(array_key_exists('label_dropzone', $atts)) { 135 $customizeDropzone = $customizeDropzone . 'document.querySelector(".cloudwok-embed .dropzone span.lead > strong" ).innerHTML = "' . $atts['label_dropzone'] . '";'; 136 } 137 $customizeDropzone = $customizeDropzone . ' 138 }}'; 139 } 140 if(array_key_exists('label_send_msg_btn', $atts) || array_key_exists('label_send_msg_placeholder', $atts) || array_key_exists('prefill_form_fields', $atts) || array_key_exists('required_firstname', $atts) || array_key_exists('required_lastname', $atts) || array_key_exists('invisible_form_input_name', $atts)) { 141 $customizeMessages = 'document.querySelector( ".cloudwok-embed .cloudwok-upload-message").addEventListener("DOMNodeInserted", customizeMessages, false); 142 function customizeMessages(e) { 143 if(e.target && e.target.nodeName == "DIV") {'; 144 if(array_key_exists('label_send_msg_btn', $atts)) { 145 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed .cloudwok-upload-message .btn-start-upload" ).innerHTML = "<i class=\'fa fa-send\'></i> ' . $atts['label_send_msg_btn'] . '";'; 146 } 147 if(array_key_exists('label_send_msg_placeholder', $atts)) { 148 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed .cloudwok-upload-message > form > fieldset > div.form-group > div > textarea" ).innerHTML = "' . $atts['label_send_msg_placeholder'] . '";'; 149 } 150 if(array_key_exists('label_send_msg_placeholder', $atts)) { 151 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed .cloudwok-upload-message > form > fieldset > div.form-group > div > textarea" ).placeholder = "' . $atts['label_send_msg_placeholder'] . '";'; 152 } 153 if(array_key_exists('label_send_email_placeholder', $atts)) { 154 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from]").placeholder = "' . $atts['label_send_email_placeholder'] . '";'; 155 } 156 if(array_key_exists('label_send_firstname_placeholder', $atts)) { 157 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_firstname]").placeholder = "' . $atts['label_send_firstname_placeholder'] . '";'; 158 } 159 if(array_key_exists('label_send_lastname_placeholder', $atts)) { 160 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_lastname]" ).placeholder = "' . $atts['label_send_lastname_placeholder'] . '";'; 161 } 162 if(array_key_exists('required_firstname', $atts) && $atts['required_firstname'] == "True") { 163 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_firstname]" ).required=true;'; 164 } 165 if(array_key_exists('required_lastname', $atts) && $atts['required_lastname'] == "True") { 166 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_lastname]" ).required=true;'; 167 } 168 // fill e-mail, first name, and last name with wp user values 169 if(array_key_exists('prefill_form_fields', $atts)) { 170 if($wp_user_email && array_key_exists('show_form_input_email', $atts) && $atts['show_form_input_email'] == "True") { 171 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from]").value = "' . $wp_user_email . '";'; 172 } 173 if($wp_user_firstname && array_key_exists('show_form_input_name', $atts) && $atts['show_form_input_name'] == "True") { 174 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_firstname]").value = "' . $wp_user_firstname . '";'; 175 } 176 if($wp_user_lastname && array_key_exists('show_form_input_name', $atts) && $atts['show_form_input_name'] == "True") { 177 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_lastname]" ).value = "' . $wp_user_lastname . '";'; 178 } 179 } 180 // you can also hide the message fields 181 if(array_key_exists('show_form_input_name', $atts) && $atts['show_form_input_name'] == "True" && array_key_exists('show_form_input_name', $atts) && $atts['show_form_input_name'] == "True") { 182 if(array_key_exists('invisible_form_input_name', $atts) && $atts['invisible_form_input_name'] == "True") { 183 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_firstname]" ).required=false;'; 184 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_lastname]" ).required=false;'; 185 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed textarea[name=message]" ).required=false;'; 186 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_lastname]" ).style.display = "none";'; 187 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_firstname]" ).style.display = "none";'; 188 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed textarea[name=message]" ).style.display = "none";'; 189 } 190 } 191 $customizeMessages = $customizeMessages . ' 192 }}'; 183 // customization via data-config 184 $customizeDataConfigFlag = false; 185 // init with default values (must do this to prevent duplicate input fields) 186 if(array_key_exists('show_form_input_name', $atts) && $atts['show_form_input_name'] == "True" ) { 187 $wdc->form->name->firstname->optional = true; 188 $customizeDataConfigFlag = true; 189 } 190 if(array_key_exists('show_form_input_email', $atts) && $atts['show_form_input_email'] == "True") { 191 $wdc->form->email->required = false; 192 $customizeDataConfigFlag = true; 193 } 194 // custom dropzone labels // 195 if(array_key_exists('label_dropzone', $atts)) { 196 $wdc->dropzone->label = $atts['label_dropzone']; 197 $customizeDataConfigFlag = true; 198 } 199 if(array_key_exists('label_add_files_btn', $atts)) { 200 $wdc->dropzone->button = $atts['label_add_files_btn'] ; 201 $customizeDataConfigFlag = true; 202 } 203 // customize form // 204 // placeholders 205 if(array_key_exists('label_send_firstname_placeholder', $atts)) { 206 $wdc->form->name->firstname->placeholder = $atts['label_send_firstname_placeholder']; 207 $customizeDataConfigFlag = true; 208 } 209 if(array_key_exists('label_send_lastname_placeholder', $atts)) { 210 $wdc->form->name->lastname->placeholder = $atts['label_send_lastname_placeholder']; 211 $customizeDataConfigFlag = true; 212 } 213 if(array_key_exists('label_send_email_placeholder', $atts)) { 214 $wdc->form->email->placeholder = $atts['label_send_email_placeholder']; 215 $customizeDataConfigFlag = true; 216 } 217 if(array_key_exists('label_send_msg_placeholder', $atts)) { 218 $wdc->form->message->placeholder = $atts['label_send_msg_placeholder']; 219 $customizeDataConfigFlag = true; 220 } 221 // required 222 if(array_key_exists('required_firstname', $atts) && $atts['required_firstname'] == "True") { 223 $wdc->form->name->firstname->optional = false; 224 $customizeDataConfigFlag = true; 225 } 226 if(array_key_exists('required_lastname', $atts) && $atts['required_lastname'] == "True") { 227 $wdc->form->name->lastname->optional = false; 228 $customizeDataConfigFlag = true; 229 } 230 // fill e-mail, first name, and last name with wp user values 231 if(array_key_exists('prefill_form_fields', $atts)) { 232 $wdc->form->email->value = $wp_user_email; 233 $wdc->form->name->firstname->value = $wp_user_firstname; 234 $wdc->form->name->lastname->value = $wp_user_lastname; 235 $customizeDataConfigFlag = true; 236 } 237 // you can also hide the message fields 238 if(array_key_exists('show_form_input_name', $atts) && $atts['show_form_input_name'] == "True" && array_key_exists('show_form_input_name', $atts) &&$atts['show_form_input_name'] == "True") { 239 if(array_key_exists('invisible_form_input_name', $atts) && $atts['invisible_form_input_name'] == "True") { 240 $customizeMessages = 'document.querySelector( ".cloudwok-embed .cloudwok-upload-message").addEventListener("DOMNodeInserted", customizeMessages, false); 241 function customizeMessages(e) { 242 if(e.target && e.target.nodeName == "DIV") {'; 243 $wdc->form->email->required = false; 244 $wdc->form->name->firstname->optional = true; 245 $wdc->form->name->lastname->optional = true; 246 $wdc->form->message->required = false; 247 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_lastname]" ).style.display = "none";'; 248 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed input[name=from_firstname]" ).style.display = "none";'; 249 $customizeMessages = $customizeMessages . 'document.querySelector(".cloudwok-embed textarea[name=message]" ).style.display = "none";'; 250 $customizeMessages = $customizeMessages . ' 251 }}'; 252 $customizeDataConfigFlag = true; 253 } 254 } 255 // sucess message customization 256 if(array_key_exists('success_message_title', $atts)) { 257 $wdc->success->message->title = $atts['success_message_title']; 258 $customizeDataConfigFlag = true; 259 } 260 if(array_key_exists('success_message_subtitle', $atts)) { 261 $wdc->success->message->subtitle = $atts['success_message_subtitle']; 262 $customizeDataConfigFlag = true; 263 } 264 if(array_key_exists('success_message_text', $atts)) { 265 $wdc->success->message->text = $atts['success_message_text']; 266 $customizeDataConfigFlag = true; 267 } 268 // END configData code 269 if($customizeDataConfigFlag) { 270 $customizeDataConfig = 'var cloudWokConfig =' . json_encode($wdc) . ' 271 document.querySelector(".cloudwok-embed").setAttribute("data-config", JSON.stringify(cloudWokConfig)); 272 console.log("cloudWokConfig: " + JSON.stringify(cloudWokConfig));'; 193 273 } 194 274 … … 202 282 203 283 <script> 284 ' . $customizeDataConfig . 285 ' 204 286 (function(window, document) { 205 287 var loader = function() { -
cloudwok-file-upload/trunk/readme.txt
r1337410 r1346074 4 4 Tags: upload, file upload, dropbox, google drive, microsoft onedrive, box, s3, facebook, upload form, feedback 5 5 Requires at least: 3.0.0 6 Tested up to: 4.4. 17 Stable tag: 0.4. 36 Tested up to: 4.4.2 7 Stable tag: 0.4.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 108 108 `[cloudwok wok_id="YOUR_WOK_ID" show_form="True" show_form_input_name="True" required_firstname="True" required_lastname="True" show_form_input_email="True" hide_form_message_text="True"]` 109 109 110 Since version 0.4.4 of this plugin, via `success_message_title="YOUR OWN TITLE"`, `success_message_subtitle="YOUR OWN SUBTITLE"`, `success_message_text="YOUR OWN TEXT"`, you can customize the message that is shown to your users after a successful file upload: 111 112 `[cloudwok wok_id="YOUR_WOK_ID" success_message_title="YOUR OWN TITLE" success_message_subtitle="YOUR OWN SUBTITLE" success_message_text="YOUR OWN TEXT"]` 113 110 114 By default, a small "powered by" text-link to www.cloudwok.com is disabled. If you like our plug-in, we would appreciate it if you would enable the link via `[cloudwok wok_id="YOUR_WOK_ID" show_powered_by_link="True"]`. Send me a link to your WordPress site with enabled "powered by" link, and I'd be happy to send you a small coupon code gift back: [email protected]. Thanks! 111 115 … … 126 130 == Changelog == 127 131 132 = 0.4.4 = 133 You can now use `success_message_title="YOUR OWN TITLE"`, `success_message_subtitle="YOUR OWN SUBTITLE"`, `success_message_text="YOUR OWN TEXT"` to customize the message that is shown to your users after a successful file upload. 128 134 = 0.4.3 = 129 135 You can now use `hide_form_message_text="True"` to hide the message text area from the message form. For example, show user name and email input fields without the message text area: `[cloudwok wok_id="YOUR_WOK_ID" show_form="True" show_form_input_name="True" required_firstname="True" required_lastname="True" show_form_input_email="True" hide_form_message_text="True"]`.
Note: See TracChangeset
for help on using the changeset viewer.