Plugin Directory

Changeset 1346074


Ignore:
Timestamp:
02/08/2016 05:27:12 PM (10 years ago)
Author:
markusklems
Message:

New version 0.4.4 - now you can customize the success message that is shown to uploaders after a successful file upload.

Location:
cloudwok-file-upload/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cloudwok-file-upload/trunk/cloudwok.php

    r1337410 r1346074  
    44Plugin URI: http://www.cloudwok.com
    55Description: 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.3
     6Version: 0.4.4
    77Author: CloudWok
    88Author Email: [email protected]
     
    2828
    2929if (!defined('ABSPATH')) die();
     30
     31class WokDataConfigDropzone {
     32    public $label = "";
     33    public $button  = "";
     34}
     35
     36class WokDataConfigSuccess {}
     37
     38class WokDataConfigSuccessMessage {
     39    public $title = "";
     40    public $subtitle  = "";
     41        public $text  = "";
     42}
     43
     44class WokDataConfigForm {
     45    public $button  = "";
     46    public $sent  = "";
     47}
     48
     49class WokDataConfigFormEmail {
     50    public $placeholder  = "";
     51    public $optional  = false;
     52}
     53
     54class WokDataConfigFormName {}
     55
     56class WokDataConfigFormNameFirstName {
     57    public $placeholder  = "";
     58    public $required  = false;
     59}
     60
     61class WokDataConfigFormNameLastName {
     62    public $placeholder  = "";
     63    public $required  = false;
     64}
     65
     66class WokDataConfigFormMessage {
     67    public $placeholder  = "";
     68    public $optional  = false;
     69}
     70
     71class WokDataConfig {}
    3072
    3173// Add Shortcode
     
    4486  }
    4587
     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
    46100    // Attributes
    47101    extract( shortcode_atts(
    48102        array(
     103      'config' => '',
    49104            'wok_id' => '',
    50105            'show_uploads' => True,
     
    62117            'label_send_msg_btn' => '',
    63118            'label_dropzone' => '',
     119            'success_message_title' => '',
     120            'success_message_subtitle' => '',
     121            'success_message_text' => '',
    64122            'label_send_msg_placeholder' => '',
    65123            'label_send_email_placeholder' => '',
     
    84142
    85143    // customize labels and texts
     144    $customizeDataConfig = '';
    86145    $customizeDropzone = '';
    87146    $customizeMessages = '';
    88147
     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
    89153    if(array_key_exists('show_uploads', $atts) && $atts['show_uploads'] == "True") {
    90154        $show_uploads = '<div class="cloudwok-upload-files"></div>';
     
    92156    if(array_key_exists('show_form', $atts) && $atts['show_form']  == "True") {
    93157        $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"';
    100158    }
    101159    if(array_key_exists('hide_form_message_text', $atts) && $atts['hide_form_message_text'] == "True") {
     
    123181    }
    124182
    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));';
    193273    }
    194274
     
    202282
    203283  <script>
     284    ' . $customizeDataConfig .
     285    '
    204286    (function(window, document) {
    205287      var loader = function() {
  • cloudwok-file-upload/trunk/readme.txt

    r1337410 r1346074  
    44Tags: upload, file upload, dropbox, google drive, microsoft onedrive, box, s3, facebook, upload form, feedback
    55Requires at least: 3.0.0
    6 Tested up to: 4.4.1
    7 Stable tag: 0.4.3
     6Tested up to: 4.4.2
     7Stable tag: 0.4.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    108108`[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"]`
    109109
     110Since 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
    110114By 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!
    111115
     
    126130== Changelog ==
    127131
     132= 0.4.4 =
     133You 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.
    128134= 0.4.3 =
    129135You 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.