Plugin Directory

Changeset 1350971


Ignore:
Timestamp:
02/15/2016 01:38:54 PM (10 years ago)
Author:
markusklems
Message:

version 0.5 of the plugin

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

Legend:

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

    r1346074 r1350971  
    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.4
     6Version: 0.5.0
    77Author: CloudWok
    88Author Email: [email protected]
     
    101101    extract( shortcode_atts(
    102102        array(
    103       'config' => '',
     103      'ref' => '',
    104104            'wok_id' => '',
    105105            'show_uploads' => True,
     
    146146    $customizeMessages = '';
    147147
     148  // new feature since 0.5 - simply reference the embed code
     149  if(array_key_exists('ref', $atts)) {
     150    global $wpdb;
     151    $table_name = $wpdb->prefix . 'cloudwok';
     152    $cloudwok_code_ref = $atts['ref'];
     153    $query="SELECT * FROM $table_name WHERE id=$ref";
     154    $result=$wpdb->get_results($query);
     155    if(!$result || !$result[0] || !$result[0]->code) {
     156      return "<p style=\"color: red;\">Sorry, could not embed [cloudwok ref=" . $ref . " ]. Please check that the shortcode looks like this: [cloudwok ref=number] and please check in the Settings > CloudWok admin sidebar that the code has been saved with ref=" . $ref . ".</p>";
     157    }
     158    // replace escaped double quotes with normal ones
     159    $to_return = str_replace('\"','"', $result[0]->code);
     160    $to_return = str_replace("\'","'", $to_return);
     161    return $to_return;
     162  }
     163
    148164  // break if no wok_id was entered
    149165  if(!array_key_exists('wok_id', $atts)) {
     
    269285    if($customizeDataConfigFlag) {
    270286        $customizeDataConfig = 'var cloudWokConfig =' . json_encode($wdc) . '
    271   document.querySelector(".cloudwok-embed").setAttribute("data-config", JSON.stringify(cloudWokConfig));
    272   console.log("cloudWokConfig: " + JSON.stringify(cloudWokConfig));';
     287  document.querySelector(".cloudwok-embed").setAttribute("data-config", JSON.stringify(cloudWokConfig));';
    273288    }
    274289
     
    304319add_shortcode( 'cloudwok', 'cloudwok_shortcode' );
    305320
     321function cloudwok_activate() {
     322  cw_plugin_create_db();
     323}
     324register_activation_hook( __FILE__, 'cloudwok_activate' );
     325
     326function cw_plugin_create_db() {
     327    global $wpdb;
     328    $charset_collate = $wpdb->get_charset_collate();
     329    $table_name = $wpdb->prefix . 'cloudwok';
     330
     331    $sql1 = "CREATE TABLE $table_name (
     332        id smallint(5) NOT NULL AUTO_INCREMENT,
     333        code varchar(16384) NOT NULL,
     334        UNIQUE KEY id (id)
     335    ) $charset_collate;";
     336
     337    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     338    dbDelta( $sql1 );
     339}
     340
     341function cw_db_get_all() {
     342  global $wpdb;
     343  $table_name = $wpdb->prefix . 'cloudwok';
     344  $query="SELECT * FROM $table_name";
     345  $result=$wpdb->get_results($query);
     346  $to_return = array();
     347  foreach ($result as $row)
     348  {
     349    $to_return[] = $row->id;
     350  }
     351  return json_encode($to_return);
     352}
     353
     354/** Step 1. */
     355function cw_plugin_menu() {
     356    add_options_page( 'Manage CloudWok', 'CloudWok', 'manage_options', 'manage-cloudwok-settings', 'cw_plugin_options' );
     357}
     358
     359/** Step 2  */
     360add_action( 'admin_menu', 'cw_plugin_menu' );
     361
     362/** Step 3. */
     363function cw_plugin_options() {
     364    if ( !current_user_can( 'manage_options' ) )  {
     365        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
     366    }
     367  $adminUrl = plugin_dir_url( __FILE__ ) . 'admin.php';
     368  $nonce = wp_create_nonce( "cWn0Nc€4tW" );
     369  // Add bootstrap css and js
     370  echo '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
     371  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
     372  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
     373  ';
     374  echo '<div class="container-fluid">';
     375  echo '<h2><i class="fa fa-wrench"></i> Manage CloudWok Settings</h2>';
     376  echo '<div class="row">';
     377  echo '<div class="col-md-6">
     378  <h4><button class="btn btn-default" type="button" data-toggle="collapse"    data-target="#cloudwokInfo" aria-expanded="false" aria-controls="cloudwokInfo">
     379  <i class="fa fa-info-circle"></i> Info</button> PLEASE ENTER THE EMBED CODE:</h4>';
     380  echo '<div class="collapse" id="cloudwokInfo">
     381  <div class="well">
     382    Please visit <strong><a href="https://www.cloudwok.com/developers" target="_blank">https://www.cloudwok.com/developers</a></strong> to generate a customized embed code of the CloudWok file-upload widget. Find the "HTML code" tab and click on the clipboard icon to copy the code. Then paste the code into the text area below.
     383  </div>
     384  </div>';
     385  echo '<form>
     386    <div class="form-group">
     387      <textarea class="form-control" rows="16" id="cloudwokEmbedCode">
     388      </textarea>
     389    </div>
     390    <input id="editRef" type="text" style="display:none !important;" />
     391    <button id="saveBtn" class="btn btn-primary pull-left"><i class="fa fa-floppy-o"></i> Save</button>
     392    <button id="newBtn" class="btn btn-default pull-right">Cancel</button>
     393  </form>
     394  </div>';
     395  echo '<div id="cloudwokEmbedCodeList" class="col-md-6">
     396
     397  </div>';
     398  echo '</div>'; // row
     399  echo '</div>'; // container
     400  echo '<script type="text/javascript">';
     401  echo '
     402  function escapeHtml(unsafe) {
     403    return unsafe.replace(/&/g, "__amp;");
     404  }
     405  function unescapeHtml(safe) {
     406    return safe.replace(/__amp;/g, "&").replace(/\\\"/g, "\"").replace(/\\\\\'/g, "\'");
     407  }
     408
     409  function appendRefListItem(ref) {
     410    jQuery("#cloudwokEmbedCodeList").append( "<div id=\"ecListRow"+ref+"\" class=\"row clickable-row\"><div class=\"col-md-4\"><pre>[cloudwok ref="+ref+"]</pre></div><div class=\"col-md-4\"><button id=\"editBtn"+ref+"\" onclick=\"onEditBtnClick("+ref+")\" class=\"btn btn-primary editBtn\" style=\"margin-right: 5px;\"><i class=\"fa fa-pencil\"></i> Edit</button><button  id=\"deleteBtn"+ref+"\" onclick=\"onDeleteBtnClick("+ref+")\" class=\"btn btn-danger\"><i class=\"fa fa-trash\"></i> Delete</button></div></div></div>" );
     411  }
     412
     413  function onEditBtnClick(ref) {
     414    if(jQuery("#editBtn"+ref+".btn-success").length == 0) {
     415      jQuery(".editBtn").removeClass("btn-success").removeClass("btn-primary").addClass("btn-primary");
     416      jQuery("#editBtn"+ref).addClass("btn-success").removeClass("btn-primary");
     417      jQuery("#cloudwokEmbedCode").val("");
     418      jQuery("#editBtn"+ref).prop("disabled", true);
     419      jQuery("#cloudwokEmbedCode").prop("placeholder","Loading embed code...");
     420      jQuery.ajax({
     421          type: "GET",
     422          url: "' . $adminUrl . '",
     423          data: "cwnonce=' . $nonce . '&ref="+ref,
     424          success: function(resp)
     425          {
     426            jQuery("#cloudwokEmbedCode").prop("placeholder","");
     427              var jsonObj = jQuery.parseJSON(resp);
     428              jQuery("#cloudwokEmbedCode").val(unescapeHtml(jsonObj.code));
     429              jQuery("#editRef").val(jsonObj.id);
     430              jQuery("#editBtn"+ref).prop("disabled", false);
     431          }
     432      });
     433    } else {
     434      jQuery("#editBtn"+ref).removeClass("btn-success").addClass("btn-primary");
     435      jQuery("#editRef").val("");
     436      jQuery("#cloudwokEmbedCode").val("");
     437    }
     438  }
     439
     440  function onDeleteBtnClick(ref) {
     441    jQuery("#deleteBtn"+ref).prop("disabled", true);
     442    jQuery.ajax({
     443        type: "DELETE",
     444        url: "' . $adminUrl . '",
     445        data: "cwnonce=' . $nonce . '&ref="+ref,
     446        success: function(resp)
     447        {
     448            jQuery("#ecListRow"+ref).remove();
     449            jQuery("#editRef").val("");
     450            jQuery("#cloudwokEmbedCode").val("");
     451            console.log(resp);
     452        }
     453    });
     454  }
     455
     456  function create() {
     457    var code = escapeHtml(jQuery("#cloudwokEmbedCode").val());
     458    jQuery.ajax({
     459        type: "POST",
     460        url: "' . $adminUrl . '",
     461        data: "cwnonce=' . $nonce . '&code="+code,
     462        success: function(ref)
     463        {
     464            appendRefListItem(ref);
     465            jQuery("#editRef").val(ref);
     466            jQuery("#editBtn"+ref).addClass("btn-success").removeClass("btn-primary");
     467        }
     468    });
     469  }
     470
     471  function update() {
     472    var ref = jQuery("#editRef").val();
     473    var code = escapeHtml(jQuery("#cloudwokEmbedCode").val());
     474    jQuery.ajax({
     475        type: "POST",
     476        url: "' . $adminUrl . '",
     477        data: "cwnonce=' . $nonce . '&ref="+ref+"&code="+code,
     478        success: function(resp)
     479        {
     480        }
     481    });
     482  }
     483
     484  jQuery( "#saveBtn" ).click(function( event ) {
     485    event.preventDefault();
     486    if(!jQuery("#editRef").val()) {
     487      create();
     488    } else {
     489      update();
     490    }
     491  });
     492  jQuery( "#newBtn" ).click(function( event ) {
     493    event.preventDefault();
     494    jQuery("#editRef").val("");
     495    jQuery("#cloudwokEmbedCode").val("");
     496    jQuery(".editBtn").removeClass("btn-success").removeClass("btn-primary").addClass("btn-primary");
     497  });
     498
     499  jQuery( document ).ready(function() {
     500    jQuery("#editRef").val("");
     501    var refList = jQuery.parseJSON(JSON.stringify(' . cw_db_get_all() . '));
     502    jQuery("#cloudwokEmbedCodeList").append( "<div class=\"row\"><div class=\"col-md-4\"><h4><i class=\"fa fa-code\"></i> SHORTCODE</h4></div></div>" );
     503    jQuery.each(refList,function(index,ref) {
     504      appendRefListItem(ref);
     505    });
     506    jQuery("#cloudwokEmbedCode").prop("placeholder","Please enter your embed code here (visit https://www.cloudwok.com/developers to generate your customiezd code)");
     507  });';
     508  echo '</script>';
     509}
     510
    306511?>
  • cloudwok-file-upload/trunk/readme.txt

    r1346074 r1350971  
    55Requires at least: 3.0.0
    66Tested up to: 4.4.2
    7 Stable tag: 0.4.4
     7Stable tag: 0.5.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1515Receive files directly in your Dropbox folder, Google Drive folder, S3 bucket, Box.com folder, or Facebook photo album. With the CloudWok file-upload plugin you can let others upload files to your cloud storage.
    1616
    17 Simply add the following shortcode in your blog post or page: `[cloudwok wok_id="YOUR_WOK_ID" show_powered_by_link="True"]`. There are many options to customize the file-upload plugin. Please take a look at the "Installation" tab for more information how to customize the plugin.
     17There are two ways how you can add the CloudWok file-upload widget to your blog posts or pages:
    1818
    19 With the CloudWok WordPress plugin, you can embed a cloudwok file-upload form into your own website or blog. Visitors of your website can upload files that are transferred directly into your connected Dropbox folder (or Google Drive folder, ...).
     19* **New:** Visit https://www.cloudwok.com/developers to generate a customized HTML embed code. Open the "Settings" menu in your sidebar and click on "CloudWok". Paste the copied HTML embed code into the text area and click "Save". This generates a shortcode, like this one: `[cloudwok ref=1]`. Simply copy and paste the shortcode into your blog post or page and the widget will appear at that place.
     20* **Old:** Simply add the following shortcode in your blog post or page: `[cloudwok wok_id="YOUR_WOK_ID" show_powered_by_link="True"]`. There are many options to customize the file-upload plugin. Please take a look at the "Installation" tab for more information how to customize the plugin.
     21
     22With the CloudWok WordPress plugin, you can embed a cloudwok file-upload form into your own website or blog. Visitors of your website can upload files that are transferred directly into your connected Dropbox folder (or Google Drive folder, ...). This means:
     23
     24* No traffic from the file-upload goes through your WordPress blog. You don't need to worry about WordPress file size limitations or the like.
     25* You don't need to download the uploaded files from your WordPress blog. They end up directly in your Dropbox, Google Drive, ...
    2026
    2127For example, with the CloudWok Wordpress plug-in, you can:
     
    2531* Create a blog where you invite your audience to submit pictures and videos for a contest.
    2632
    27 Share your use case with us by sending us a link to your WordPress site at [email protected]. We are always happy to hear feedback from our users. If you write a blog post about your CloudWok use case, we grant you extra quota for free. Drop me an e-mail if you would like to participate in the free-extra-quota initiative.
     33If you have questions, feedback, or trouble, please contact me via e-mail: [email protected] or open a thread in the support forum. Thanks!
    2834
    2935== Installation ==
     
    5662**Use the plug-in:**
    5763
    58 Now you can add shortcodes like the following to your pages, blog posts, etc:
     64There are two ways how you can add the CloudWok file-upload widget to your blog posts or pages:
     65
     66* **New:** Visit https://www.cloudwok.com/developers to generate a customized HTML embed code. Open the "Settings" menu in your sidebar and click on "CloudWok". Paste the copied HTML embed code into the text area and click "Save". This generates a shortcode, like this one: `[cloudwok ref=1]`. Simply copy and paste the shortcode into your blog post or page and the widget will appear at that place.
     67* **Old:** Simply add the following shortcode in your blog post or page: `[cloudwok wok_id="YOUR_WOK_ID" show_powered_by_link="True"]`. There are many options to customize the file-upload plugin. Please take a look at the "Installation" tab for more information how to customize the plugin.
     68
     69The following configurations only apply to the "old" CloudWok shortcode. If you need further customizations, please use the "new" way, as described above.
    5970
    6071`[cloudwok wok_id="YOUR_WOK_ID" show_powered_by_link="True"]`
     
    112123`[cloudwok wok_id="YOUR_WOK_ID" success_message_title="YOUR OWN TITLE" success_message_subtitle="YOUR OWN SUBTITLE" success_message_text="YOUR OWN TEXT"]`
    113124
    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!
     125By 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"]`.
     126
     127Since version 0.5 of this plugin, we have added an admin panel to the left-hand sidebar (Settings > CloudWok) where you can customize the layout of the plugin with more flexibility. The old shortcodes still work, however, they will not be further extended with new customization features. The new approach (via Settings admin panel) will be updated in upcoming releases of this plugin.
    115128
    116129== Frequently Asked Questions ==
    117 
    118 * Is it possible to change the default texts and labels?
    119 
    120 You can customize texts and labels. Please take a look at this thread: https://wordpress.org/support/topic/custom-text-translation
    121130
    122131Send us an e-mail if you have an issue: [email protected] or a tweet @cloudwok. Or open a thread in the WordPress support forum for this plugin.
     
    124133== Screenshots ==
    125134
    126 1. File-upload form in a WordPress blog post view.
    127 2. Shortcode that adds a file-upload form to a blog post.
    128 3. How to install the plugin via the WordPress plugin directory.
     1351. Go to https://www.cloudwok.com/developers to generate a customized HTML code of the file-upload widget.
     1362. Copy the HTML code.
     1373. Paste the HTML code into the text area located at your WordPress admin sidebar (Settings > CloudWok) and click "Save".
     1384. Edit your blog post. Copy the shortcode into your blog post text where you want it to show.
     1395. Now the file-upload form shows up in your WordPress blog post.
     1406. (old/legacy approach) Shortcode that adds a file-upload form to a blog post.
     1417. How to install the plugin via the WordPress plugin directory.
    129142
    130143== Changelog ==
    131144
     145= 0.5.0 =
     146New shortcode feature. Create a customized widget via the Settings > CloudWok menu in the admin sidebar. The old shortcode still works but will not be further developed. Please use the new shortcode to customize the CloudWok widget.
    132147= 0.4.4 =
    133148You 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.
Note: See TracChangeset for help on using the changeset viewer.