Plugin Directory

Changeset 1522309


Ignore:
Timestamp:
10/26/2016 09:39:03 AM (9 years ago)
Author:
Zuige
Message:

WP Libre Forms 1.1 release

Location:
wp-libre-form
Files:
26 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-libre-form/tags/1.1/assets/scripts/wplf-form.js

    r1359097 r1522309  
    33 */
    44
    5 (function($) {
     5// Fetch polyfill: https://github.com/github/fetch
     6!function(t){"use strict";function e(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t=String(t)),t}function o(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return y.iterable&&(e[Symbol.iterator]=function(){return e}),e}function n(t){this.map={},t instanceof n?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function s(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function i(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function a(t){var e=new FileReader;return e.readAsArrayBuffer(t),i(e)}function h(t){var e=new FileReader;return e.readAsText(t),i(e)}function u(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(y.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(y.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(y.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(t){if(!y.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw new Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):y.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},y.blob?(this.blob=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(a)},this.text=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return h(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var t=s(this);return t?t:Promise.resolve(this._bodyText)},y.formData&&(this.formData=function(){return this.text().then(p)}),this.json=function(){return this.text().then(JSON.parse)},this}function f(t){var e=t.toUpperCase();return b.indexOf(e)>-1?e:t}function d(t,e){e=e||{};var r=e.body;if(d.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new n(t.headers)),this.method=t.method,this.mode=t.mode,r||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=e.credentials||this.credentials||"omit",(e.headers||!this.headers)&&(this.headers=new n(e.headers)),this.method=f(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function p(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}}),e}function c(t){var e=new n,r=(t.getAllResponseHeaders()||"").trim().split("\n");return r.forEach(function(t){var r=t.trim().split(":"),o=r.shift().trim(),n=r.join(":").trim();e.append(o,n)}),e}function l(t,e){e||(e={}),this.type="default",this.status=e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText,this.headers=e.headers instanceof n?e.headers:new n(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var y={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};n.prototype.append=function(t,o){t=e(t),o=r(o);var n=this.map[t];n||(n=[],this.map[t]=n),n.push(o)},n.prototype["delete"]=function(t){delete this.map[e(t)]},n.prototype.get=function(t){var r=this.map[e(t)];return r?r[0]:null},n.prototype.getAll=function(t){return this.map[e(t)]||[]},n.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},n.prototype.set=function(t,o){this.map[e(t)]=[r(o)]},n.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(o){t.call(e,o,r,this)},this)},this)},n.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),o(t)},n.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),o(t)},n.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),o(t)},y.iterable&&(n.prototype[Symbol.iterator]=n.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];d.prototype.clone=function(){return new d(this)},u.call(d.prototype),u.call(l.prototype),l.prototype.clone=function(){return new l(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new n(this.headers),url:this.url})},l.error=function(){var t=new l(null,{status:0,statusText:""});return t.type="error",t};var m=[301,302,303,307,308];l.redirect=function(t,e){if(-1===m.indexOf(e))throw new RangeError("Invalid status code");return new l(null,{status:e,headers:{location:t}})},t.Headers=n,t.Request=d,t.Response=l,t.fetch=function(t,e){return new Promise(function(r,o){function n(){return"responseURL"in i?i.responseURL:/^X-Request-URL:/m.test(i.getAllResponseHeaders())?i.getResponseHeader("X-Request-URL"):void 0}var s;s=d.prototype.isPrototypeOf(t)&&!e?t:new d(t,e);var i=new XMLHttpRequest;i.onload=function(){var t={status:i.status,statusText:i.statusText,headers:c(i),url:n()},e="response"in i?i.response:i.responseText;r(new l(e,t))},i.onerror=function(){o(new TypeError("Network request failed"))},i.ontimeout=function(){o(new TypeError("Network request failed"))},i.open(s.method,s.url,!0),"include"===s.credentials&&(i.withCredentials=!0),"responseType"in i&&y.blob&&(i.responseType="blob"),s.headers.forEach(function(t,e){i.setRequestHeader(e,t)}),i.send("undefined"==typeof s._bodyInit?null:s._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this);
    67
    7 $(document).ready(function() {
     8// Promise polyfill: https://github.com/taylorhakes/promise-polyfill
     9!function(t){function e(){}function n(t,e){return function(){t.apply(e,arguments)}}function o(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(t,this)}function r(t,e){for(;3===t._state;)t=t._value;return 0===t._state?void t._deferreds.push(e):(t._handled=!0,void a(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._state?i:f)(e.promise,t._value);var o;try{o=n(t._value)}catch(r){return void f(e.promise,r)}i(e.promise,o)}))}function i(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var r=e.then;if(e instanceof o)return t._state=3,t._value=e,void u(t);if("function"==typeof r)return void s(n(r,e),t)}t._state=1,t._value=e,u(t)}catch(i){f(t,i)}}function f(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&a(function(){t._handled||d(t._value)});for(var e=0,n=t._deferreds.length;n>e;e++)r(t,t._deferreds[e]);t._deferreds=null}function c(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function s(t,e){var n=!1;try{t(function(t){n||(n=!0,i(e,t))},function(t){n||(n=!0,f(e,t))})}catch(o){if(n)return;n=!0,f(e,o)}}var l=setTimeout,a="function"==typeof setImmediate&&setImmediate||function(t){l(t,0)},d=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};o.prototype["catch"]=function(t){return this.then(null,t)},o.prototype.then=function(t,n){var o=new this.constructor(e);return r(this,new c(t,n,o)),o},o.all=function(t){var e=Array.prototype.slice.call(t);return new o(function(t,n){function o(i,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(t){o(i,t)},n)}e[i]=f,0===--r&&t(e)}catch(c){n(c)}}if(0===e.length)return t([]);for(var r=e.length,i=0;i<e.length;i++)o(i,e[i])})},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o(function(e){e(t)})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){for(var o=0,r=t.length;r>o;o++)t[o].then(e,n)})},o._setImmediateFn=function(t){a=t},o._setUnhandledRejectionFn=function(t){d=t},"undefined"!=typeof module&&module.exports?module.exports=o:t.Promise||(t.Promise=o)}(this);
    810
    9   // ajax form submissions
    10   $('.libre-form').submit(function(e) {
    1111
    12     var $form = $(this);
     12(function(){
    1313
    14     // add class to enable css changes to indicate ajax loading
    15     $form.addClass('sending');
     14window.wplf = {
     15  successCallbacks: [],
     16  errorCallbacks: []
     17};
    1618
    17     // reset errors
    18     $form.find('.wplf-error').remove();
     19document.addEventListener("DOMContentLoaded", function(){
     20  [].forEach.call(document.querySelectorAll(".libre-form"), function(form){
    1921
    20     // submit form to ajax handler in admin-ajax.php
    21     $.post( ajax_object.ajax_url + '?action=wplf_submit',
    22       $(this).serialize(),
    23       function(response) {
    24         console.log(response);
     22    form.addEventListener("submit", function(e){
     23
     24      // add class to enable css changes to indicate ajax loading
     25      form.classList.add("sending");
     26
     27      [].forEach.call(form.querySelectorAll(".wplf-error"), function(error){
     28        // reset errors
     29        error.parentNode.removeChild(error);
     30      });
     31
     32      var data = new FormData(form);
     33
     34      window.data = data;
     35
     36      fetch(ajax_object.ajax_url  + '?action=wplf_submit', {
     37        method: "POST",
     38        body: data
     39      }).then(function(response){
     40
     41        return response.text();
     42
     43      }).then(function(response){
     44
     45        response = JSON.parse(response);
     46
    2547        if( 'success' in response ) {
    2648          // show success message if one exists
    27           $form.after(response.success);
    28         }
     49
     50          var success = document.createElement("p");
     51          success.className = "wplf-success";
     52          success.innerHTML = response.success;
     53
     54          form.parentNode.insertBefore(success, form.nextSibling);
     55        }
     56
    2957        if( 'ok' in response && response.ok ) {
    3058          // submit succesful!
    31           $form.remove();
     59          form.parentNode.removeChild(form);
     60
     61          window.wplf.successCallbacks.forEach(function(func){
     62            func(response);
     63          });
    3264        }
     65
    3366        if( 'error' in response ) {
    3467          // show error message in form
    35           $form.append('<p class="wplf-error error">' + response.error + '</p>');
     68
     69          var error = document.createElement("p");
     70          error.className = "wplf-error error";
     71          error.textContent = response.error;
     72
     73          form.appendChild(error);
     74
     75          window.wplf.errorCallbacks.forEach(function(func){
     76            func(response);
     77          });
    3678        }
    37       }
    38     ).always(function() {
    39       // finished XHR request
    40       $form.removeClass('sending');
    41     });;
    4279
    43     // don't actually submit the form, causing a page reload
    44     e.preventDefault();
    45     return false;
     80        form.classList.remove('sending');
     81
     82      }).catch(function(error){
     83
     84        console.warn("Fetch error: ", error);
     85        form.classList.remove("sending");
     86
     87      });
     88
     89      // don't actually submit the form, causing a page reload
     90
     91      e.preventDefault();
     92    });
    4693
    4794  });
    4895});
    49 
    50 })(jQuery);
    51 
     96})();
  • wp-libre-form/tags/1.1/classes/class-cpt-wplf-form.php

    r1450731 r1522309  
    2424
    2525    // post.php / post-new.php view
     26    add_filter( 'get_sample_permalink_html', array( $this, 'modify_permalink_html' ), 10, 2 );
    2627    add_action( 'save_post', array( $this, 'save_cpt' ) );
    2728    add_filter( 'content_save_pre' , array( $this, 'strip_form_tags' ), 10, 1 );
     
    3031
    3132    // edit.php view
     33    add_filter( 'post_row_actions', array( $this, 'remove_row_actions' ), 10, 2 );
    3234    add_filter( 'manage_edit-wplf-form_columns' , array( $this, 'custom_columns_cpt' ), 100, 1 );
    3335    add_action( 'manage_posts_custom_column' , array( $this, 'custom_columns_display_cpt' ), 10, 2 );
     
    3840    // front end
    3941    add_shortcode( 'libre-form', array( $this, 'shortcode' ) );
     42    add_action( 'wp', array( $this, 'maybe_set_404_for_single_form' ) );
    4043    add_filter( 'the_content', array( $this, 'use_shortcode_for_preview' ) );
    4144    add_action( 'wp_enqueue_scripts', array( $this, 'maybe_enqueue_frontend_script' ) );
     
    9396  }
    9497
     98  /**
     99   * Modify post.php permalink html to show notice if form isn't publicly visible.
     100   */
     101  function modify_permalink_html( $html, $post_id ) {
     102    $publicly_visible = $this->get_publicly_visible_state( $post_id );
     103
     104    if( get_post_type( $post_id ) === 'wplf-form' && !$publicly_visible ) {
     105      $html .= '<span>' . __( 'Permalink is for preview purposes only.', 'wp-libre-form' ) . '</span>';
     106    }
     107
     108    return $html;
     109  }
    95110
    96111  /**
     
    165180  }
    166181
     182  /**
     183   * Remove view action in edit.php for forms
     184   */
     185  function remove_row_actions( $actions, $post ) {
     186    $publicly_visible = $this->get_publicly_visible_state( $post->ID );
     187
     188    if( $post->post_type === 'wplf-form' && !$publicly_visible )
     189      unset( $actions['view'] );
     190
     191    return $actions;
     192  }
    167193
    168194  /**
     
    315341  <label for="wplf_email_copy_enabled">
    316342    <input type="checkbox" <?php echo $email_enabled ? 'checked="checked"' : ''; ?> id="wplf_email_copy_enabled" name="wplf_email_copy_enabled">
    317     <?php _e( 'Send an email copy when a form is submitted?' ); ?>
     343    <?php _e( 'Send an email copy when a form is submitted?', 'wp-libre-form' ); ?>
    318344  </label>
    319345</p>
     
    333359<p><?php _e('Submissions from this form will use this formatting in their title.', 'wp-libre-form'); ?></p>
    334360<p><?php _e('You may use any field values enclosed in "%" markers.', 'wp-libre-form');?></p>
    335 <p><input type="text" name="wplf_title_format" value="<?php echo esc_attr( $format ); ?>" placeholder="<?php echo esc_attr( $default ); ?>" class="code" style="width:100%"></p>
    336 <?php
    337   }
    338 
     361<p><input type="text" name="wplf_title_format" value="<?php echo esc_attr( $format ); ?>" placeholder="<?php echo esc_attr( $default ); ?>" class="code" style="width:100%" autocomplete="off"></p>
     362<?php
     363  }
    339364
    340365  /**
     
    385410    // save email copy
    386411    if ( isset( $_POST['wplf_email_copy_to'] ) ) {
    387       update_post_meta( $post_id, '_wplf_email_copy_to', sanitize_email( $_POST['wplf_email_copy_to'] ) );
     412      $emailField = $_POST['wplf_email_copy_to'];
     413      $to = '';
     414
     415      if( strpos( $emailField, "," ) > 0 ) {
     416        // Intentional. Makes no sense if the first character is a comma, so pass it along as a single address.
     417        // sanitize_email() should take care of the rest.
     418        $emailArray = explode( ",", $emailField );
     419        foreach($emailArray as $email){
     420          $email = trim($email);
     421          $email = sanitize_email( $email ) . ", ";
     422          $to .= $email;
     423        }
     424        $to = rtrim( $to, ", " );
     425      }
     426      else {
     427        $to = sanitize_email( $emailField );
     428      }
     429
     430      if( !empty( $to ) ) {
     431        update_post_meta( $post_id, '_wplf_email_copy_to', $to );
     432      } else {
     433        delete_post_meta( $post_id, '_wplf_email_copy_to' );
     434      }
    388435    }
    389436
     
    423470        $content = get_post( $id )->post_content;
    424471      }
     472
     473      $multipart = "";
     474      // check if form contains file inputs
     475      if(strpos($content, "type='file'") > -1 || strpos($content, "type=\"file\"") > -1){
     476        $multipart = "enctype='multipart/form-data'";
     477      }
     478
    425479      ob_start();
    426480?>
    427 <form class="libre-form libre-form-<?php echo $id . ' ' . $xclass; ?>">
     481<form class="libre-form libre-form-<?php echo $id . ' ' . $xclass; ?>" <?php echo $multipart; ?>>
     482  <?php if( is_singular( 'wplf-form' ) && current_user_can( 'edit_post', $id ) ) {
     483    $publicly_visible = $this->get_publicly_visible_state( $id );
     484    if( !$publicly_visible ) {
     485?>
     486      <p style="background:#f5f5f5;border-left:4px solid #dc3232;padding:6px 12px;">
     487        <b style="color:#dc3232;"><?php _e( 'This form preview URL is not public and cannot be shared.', 'wp-libre-form' ) ?>.</b><br />
     488        <?php _e( 'Non-logged in visitors will see a 404 error page instead.', 'wp-libre-form' ) ?>
     489      </p>
     490<?php
     491    }
     492  } ?>
    428493  <?php echo apply_filters( 'wplf_form', $content ); ?>
    429494  <input type="hidden" name="referrer" value="<?php the_permalink(); ?>">
     495  <input type="hidden" name="_referrer_id" value="<?php esc_attr_e( get_the_id() ) ?>">
    430496  <input type="hidden" name="_form_id" value="<?php esc_attr_e( $id ); ?>">
    431497</form>
     
    447513
    448514    // register the script, but only enqueue it if the current post contains a form in it
    449     wp_register_script( 'wplf-form-js', plugins_url( 'assets/scripts/wplf-form.js', dirname(__FILE__) ), array( 'jquery' ) );
     515    wp_register_script( 'wplf-form-js', plugins_url( 'assets/scripts/wplf-form.js', dirname(__FILE__) ), array(), WPLF_VERSION, true );
    450516
    451517    if( is_a( $post, 'WP_Post' ) && ( has_shortcode( $post->post_content, 'libre-form') || $post->post_type === 'wplf-form') ) {
     
    480546    return $content;
    481547  }
     548
     549  /**
     550   * Set and show 404 page for visitors trying to see single form.
     551   * And yes, it is a global $post. That's right.
     552   */
     553  function maybe_set_404_for_single_form() {
     554    global $post;
     555
     556    if( !is_singular( 'wplf-form' ) )
     557      return;
     558
     559    $publicly_visible = $this->get_publicly_visible_state( $post->ID );
     560    if( $publicly_visible )
     561      return;
     562
     563    if( !current_user_can( 'edit_post', $post->ID ) ) {
     564      global $wp_query;
     565      $wp_query->set_404();
     566    }
     567  }
     568
     569  /**
     570   * Wrapper function to check if form is publicly visible.
     571   */
     572  function get_publicly_visible_state( $id ) {
     573    return apply_filters( 'wplf-form-publicly-visible', false, $id );
     574  }
    482575}
    483576
  • wp-libre-form/tags/1.1/classes/class-cpt-wplf-submission.php

    r1359097 r1522309  
    107107    global $pagenow;
    108108
    109     if( 'edit.php' != $pagenow ) {
     109    $allowed = array("wplf-submission"); // show filter on these post types (currently only one?)
     110    $allowed = apply_filters("wplf-dropdown-filter", $allowed);
     111    $post_type = get_query_var("post_type");
     112
     113    if( 'edit.php' != $pagenow || !in_array($post_type, $allowed)) {
    110114      return;
    111115    }
    112116
    113     // TODO: put this in a transient
    114     $forms = get_posts( array(
    115       'post_per_page' => '-1',
    116       'post_type' => 'wplf-form',
    117     ) );
     117    $transient = get_transient("wplf-form-filter");
     118
     119    if($transient){
     120      $forms = $transient;
     121    }
     122
     123    else{
     124      $forms = get_posts( array(
     125        'post_per_page' => '-1',
     126        'post_type' => 'wplf-form',
     127      ) );
     128
     129      set_transient("wplf-form-filter", $forms, 15 *  MINUTE_IN_SECONDS);
     130    }
     131
    118132?>
    119133<label for="filter-by-form" class="screen-reader-text">Filter by form</label>
     
    171185    $postmeta = get_post_meta( $post->ID );
    172186    $fields = array_keys( $postmeta );
     187    $home_path = get_home_path();
    173188?>
    174189<p>
     
    183198      <?php foreach( $fields as $field ) : ?>
    184199        <?php if( '_' != $field[0]  ) : ?>
    185         <?php $value = $postmeta[ $field ][0]; ?>
     200        <?php
     201        $value = $postmeta[ $field ][0];
     202        $possible_link = '';
     203        $attachment_url = wp_get_attachment_url( $value ); // get_edit_post_link returns something awkward.
     204
     205        // Maybe add a filter for target="_blank"? Wouldn't enable by default.
     206
     207        if ( $attachment_url ) {
     208          // If this is true, $value was a valid attachment_id.
     209          // Caveat: if user enters a numeric value here, it could be interpreted as attachment.
     210          $attachment_url = get_edit_post_link($value);
     211          $possible_link = "<a href='$attachment_url' style='float: right;'>Edit attachment</a>";
     212        } elseif ( file_exists( $home_path . substr( $value, 1 ) ) ) {
     213          // This is bit less ambiguous. Check if there's a file, and if there is, get link for it.
     214          $attachment_url = get_home_url() . $value;
     215          $possible_link = "<a href='$attachment_url' style='float: right;'>Open file</a>";
     216        }
     217        ?>
    186218        <tr>
    187           <th><strong><?php echo $field; ?></strong></th>
     219          <th><strong><?php echo $field; ?></strong> <?php echo $possible_link; ?></th>
    188220          <?php if( strlen( $value ) > 60 || strpos( $value, "\n" ) ) : ?>
    189221          <td><textarea style="width:100%" readonly><?php echo esc_textarea( $value ); ?></textarea></td>
     
    202234
    203235endif;
    204 
  • wp-libre-form/tags/1.1/inc/wplf-ajax.php

    r1359097 r1522309  
    1919  if( $return->ok ) {
    2020    // form existence has already been validated via filters
     21
     22
    2123    $form = get_post( intval( $_POST['_form_id'] ) );
    2224
     
    5355    }
    5456
     57    // handle files
     58    foreach( $_FILES as $key => $file) {
     59      // Is this enough security wise?
     60      // Currenly only supports 1 file per input
     61      $attach_id = media_handle_upload( $key, 0, array(), array( "test_form" => false ) );
     62      add_post_meta( $post_id, $key, wp_get_attachment_url($attach_id) );
     63      add_post_meta( $post_id, $key . "_attachment", $attach_id );
     64    }
     65
     66
     67
    5568    $return->submission_id = $post_id;
    5669    $return->submission_title = $post_title;
     70    $return->form_id = $form->ID;
    5771
    5872    // return the success message for the form
     
    6983  wp_die();
    7084}
    71 
  • wp-libre-form/tags/1.1/inc/wplf-form-actions.php

    r1365849 r1522309  
    1919    $to = isset($form_meta['_wplf_email_copy_to']) ? $form_meta['_wplf_email_copy_to'][0] : get_option( 'admin_email' );
    2020    $subject = wp_sprintf( __('New submission from %s', 'wp-libre-form'), $referrer );
    21     $content = wp_sprintf( __('Form "%s" (ID %d) was submitted with values below: ', 'wp-libre-form'), $form_title, $form_id ) . "\n\n";
     21    $content = wp_sprintf( __('Form "%s" (ID %d) was submitted with values below: ', 'wp-libre-form'), $form_title, $form_id );
     22    $content = apply_filters( 'wplf_email_copy_content_start', $content, $form_title, $form_id ). "\n\n";
     23
    2224    foreach( $_POST as $key => $value ) {
    2325      if( '_' === $key[0] ) {
     
    2628      $content .= esc_html( $key ) . ': ' . esc_html( print_r( $value, true ) ) . "\n";
    2729    }
    28     wp_mail( $to, $subject, $content );
     30
     31    wp_mail(
     32      apply_filters( 'wplf_email_copy_to', $to ),
     33      apply_filters( 'wplf_email_copy_subject', $subject ),
     34      apply_filters( 'wplf_email_copy_content', $content ),
     35      apply_filters( 'wplf_email_copy_headers', '' ),
     36      apply_filters( 'wplf_email_copy_attachments', array() )
     37    );
    2938  }
    3039}
    31 
  • wp-libre-form/tags/1.1/lang/wp-libre-form-fi.po

    r1359097 r1522309  
    22msgstr ""
    33"Project-Id-Version: WP Libre Form\n"
    4 "POT-Creation-Date: 2016-02-21 23:16+0100\n"
    5 "PO-Revision-Date: 2016-02-21 23:16+0100\n"
     4"POT-Creation-Date: 2016-10-26 10:29+0100\n"
     5"PO-Revision-Date: 2016-10-26 10:30+0100\n"
    66"Last-Translator: Antti Kuosmanen <antti@seravo.fi>\n"
    77"Language-Team: Antti Kuosmanen <antti@seravo.fi>\n"
     
    1111"Content-Transfer-Encoding: 8bit\n"
    1212"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    13 "X-Generator: Poedit 1.8.6\n"
     13"X-Generator: Poedit 1.8.8\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"X-Poedit-WPHeader: wp-libre-form.php\n"
     
    2121"X-Poedit-SearchPathExcluded-0: *.js\n"
    2222
    23 #: classes/class-cpt-wplf-form.php:53
     23#: classes/class-cpt-wplf-form.php:56
    2424msgctxt "post type general name"
    2525msgid "Forms"
    2626msgstr "Lomakkeet"
    2727
    28 #: classes/class-cpt-wplf-form.php:54
     28#: classes/class-cpt-wplf-form.php:57
    2929msgctxt "post type singular name"
    3030msgid "Form"
    3131msgstr "Lomake"
    3232
    33 #: classes/class-cpt-wplf-form.php:55
     33#: classes/class-cpt-wplf-form.php:58
    3434msgctxt "admin menu"
    3535msgid "Forms"
    3636msgstr "Lomakkeet"
    3737
    38 #: classes/class-cpt-wplf-form.php:56
     38#: classes/class-cpt-wplf-form.php:59
    3939msgctxt "add new on admin bar"
    4040msgid "Form"
    4141msgstr "Lomake"
    4242
    43 #: classes/class-cpt-wplf-form.php:57
     43#: classes/class-cpt-wplf-form.php:60
    4444msgctxt "form"
    4545msgid "New Form"
    4646msgstr "Uusi lomake"
    4747
    48 #: classes/class-cpt-wplf-form.php:58
     48#: classes/class-cpt-wplf-form.php:61
    4949msgid "Add New Form"
    5050msgstr "Luo uusi lomake"
    5151
    52 #: classes/class-cpt-wplf-form.php:59
     52#: classes/class-cpt-wplf-form.php:62
    5353msgid "New Form"
    5454msgstr "Uusi lomake"
    5555
    56 #: classes/class-cpt-wplf-form.php:60
     56#: classes/class-cpt-wplf-form.php:63
    5757msgid "Edit Form"
    5858msgstr "Muokkaa lomaketta"
    5959
    60 #: classes/class-cpt-wplf-form.php:61
     60#: classes/class-cpt-wplf-form.php:64
    6161msgid "View Form"
    6262msgstr "Näytä lomake"
    6363
    64 #: classes/class-cpt-wplf-form.php:62 classes/class-cpt-wplf-submission.php:121
     64#: classes/class-cpt-wplf-form.php:65 classes/class-cpt-wplf-submission.php:135
    6565msgid "All Forms"
    6666msgstr "Kaikki lomakkeet"
    6767
    68 #: classes/class-cpt-wplf-form.php:63
     68#: classes/class-cpt-wplf-form.php:66
    6969msgid "Search Forms"
    7070msgstr "Etsi lomakkeita"
    7171
    72 #: classes/class-cpt-wplf-form.php:64
     72#: classes/class-cpt-wplf-form.php:67
    7373msgid "No forms found."
    7474msgstr "Lomakkeita ei löytynt."
    7575
    76 #: classes/class-cpt-wplf-form.php:65
     76#: classes/class-cpt-wplf-form.php:68
    7777msgid "No forms found in Trash."
    7878msgstr "Roskakorissa ei ole lomakkeita."
    7979
    80 #: classes/class-cpt-wplf-form.php:148
     80#: classes/class-cpt-wplf-form.php:105
     81msgid "Permalink is for preview purposes only."
     82msgstr "Kestolinkki toimii vain esikatseluna."
     83
     84#: classes/class-cpt-wplf-form.php:163
    8185msgid "Please enter your name"
    8286msgstr "Kirjoita nimesi"
    8387
    84 #: classes/class-cpt-wplf-form.php:149
     88#: classes/class-cpt-wplf-form.php:164
    8589msgctxt "Default placeholder name"
    8690msgid "John Doe"
    8791msgstr "Matti Meikäläinen"
    8892
    89 #: classes/class-cpt-wplf-form.php:151
     93#: classes/class-cpt-wplf-form.php:166
    9094msgid "Please enter your email address"
    9195msgstr "Kirjoita sähköpostiosoitteesi"
    9296
    93 #: classes/class-cpt-wplf-form.php:151 classes/class-cpt-wplf-form.php:154
     97#: classes/class-cpt-wplf-form.php:166 classes/class-cpt-wplf-form.php:169
    9498msgid "(required)"
    9599msgstr "(pakollinen)"
    96100
    97 #: classes/class-cpt-wplf-form.php:152
     101#: classes/class-cpt-wplf-form.php:167
    98102msgctxt "Default placeholder email"
    99103msgid "example@email.com"
    100104msgstr "esimerkki@esimerkki.fi"
    101105
    102 #: classes/class-cpt-wplf-form.php:154
     106#: classes/class-cpt-wplf-form.php:169
    103107msgid "Write your message below"
    104108msgstr "Kirjoita viestisi alle"
    105109
    106 #: classes/class-cpt-wplf-form.php:155
     110#: classes/class-cpt-wplf-form.php:170
    107111msgctxt "Default placeholder message"
    108112msgid "I wanted to ask about..."
    109113msgstr "Halusin kysyä..."
    110114
    111 #: classes/class-cpt-wplf-form.php:157
     115#: classes/class-cpt-wplf-form.php:172
    112116msgid "Submit"
    113117msgstr "Lähetä"
    114118
    115 #: classes/class-cpt-wplf-form.php:159
     119#: classes/class-cpt-wplf-form.php:174
    116120msgctxt "The HTML comment at the end of the example form"
    117121msgid "Any valid HTML form can be used here!"
    118122msgstr "Tässä toimii mikä tahansa HTML-lomake!"
    119123
    120 #: classes/class-cpt-wplf-form.php:175 classes/class-cpt-wplf-form.php:212
     124#: classes/class-cpt-wplf-form.php:201 classes/class-cpt-wplf-form.php:240
    121125msgid "Shortcode"
    122126msgstr "Lyhytkoodi"
    123127
    124 #: classes/class-cpt-wplf-form.php:176 classes/class-cpt-wplf-submission.php:46
     128#: classes/class-cpt-wplf-form.php:202 classes/class-cpt-wplf-submission.php:46
    125129msgid "Submissions"
    126130msgstr "Vastaukset"
    127131
    128 #: classes/class-cpt-wplf-form.php:222
     132#: classes/class-cpt-wplf-form.php:250
    129133msgid "Success Message"
    130134msgstr "Onnistumisviesti"
    131135
    132 #: classes/class-cpt-wplf-form.php:232
     136#: classes/class-cpt-wplf-form.php:260
    133137msgid "Form Fields Detected"
    134138msgstr "Lomakekentät"
    135139
    136 #: classes/class-cpt-wplf-form.php:241
     140#: classes/class-cpt-wplf-form.php:269
    137141msgid "Emails"
    138142msgstr "Sähköpostit"
    139143
    140 #: classes/class-cpt-wplf-form.php:250
     144#: classes/class-cpt-wplf-form.php:278
    141145msgid "Submission Title Format"
    142146msgstr "Nimi lähetetylle lomakkeelle"
    143147
    144 #: classes/class-cpt-wplf-form.php:273
     148#: classes/class-cpt-wplf-form.php:301
    145149msgctxt "Default success message"
    146150msgid "Thank you! :)"
    147151msgstr "Kiitos! :)"
    148152
    149 #: classes/class-cpt-wplf-form.php:294
     153#: classes/class-cpt-wplf-form.php:322
    150154msgid "Fields marked with * are required"
    151155msgstr "Tähdelliset * kentät on pakollisia"
    152156
    153 #: classes/class-cpt-wplf-form.php:315
     157#: classes/class-cpt-wplf-form.php:343
    154158msgid "Send an email copy when a form is submitted?"
    155159msgstr "Lähetä kopio sähköpostiin kun lomake lähetetään?"
    156160
    157 #: classes/class-cpt-wplf-form.php:331
     161#: classes/class-cpt-wplf-form.php:359
    158162msgid "Submissions from this form will use this formatting in their title."
    159163msgstr ""
     
    161165"mukaisesti."
    162166
    163 #: classes/class-cpt-wplf-form.php:332
     167#: classes/class-cpt-wplf-form.php:360
    164168msgid "You may use any field values enclosed in \"%\" markers."
    165169msgstr ""
    166170"Voit käyttää otsikossa mitä tahansa kenttiä arvoja \"%\"-merkkien sisällä."
     171
     172#: classes/class-cpt-wplf-form.php:487
     173msgid "This form preview URL is not public and cannot be shared."
     174msgstr "Tämä esikatselusivu ei ole julkinen, eikä sitä voi jakaa."
     175
     176#: classes/class-cpt-wplf-form.php:488
     177msgid "Non-logged in visitors will see a 404 error page instead."
     178msgstr "Kirjautumattomille vierailijoille näytetään 404-sivu."
    167179
    168180#: classes/class-cpt-wplf-submission.php:37
     
    227239msgstr "Lomake"
    228240
    229 #: classes/class-cpt-wplf-submission.php:158
     241#: classes/class-cpt-wplf-submission.php:172
    230242msgid "Submission"
    231243msgstr "Vastaus"
    232244
    233 #: classes/class-cpt-wplf-submission.php:178
     245#: classes/class-cpt-wplf-submission.php:193
    234246msgid "Field"
    235247msgstr "Kenttä"
    236248
    237 #: classes/class-cpt-wplf-submission.php:179
     249#: classes/class-cpt-wplf-submission.php:194
    238250msgid "Value"
    239251msgstr "Arvo"
     
    267279
    268280#. Description of the plugin/theme
    269 msgid "HTML form builder for WordPress"
    270 msgstr "HTML form builder for WordPress"
     281msgid "A minimal HTML form builder for WordPress; made for developers"
     282msgstr "Minimalistinen HTML lomakerakentaja WordPressille; tehty kehittäjille."
    271283
    272284#. Author of the plugin/theme
     
    278290msgstr "https://github.com/anttiviljami/"
    279291
     292#~ msgid "Form is not publicly visible"
     293#~ msgstr "Lomake ei näy julkisesti"
     294
     295#~ msgid ", permalink will not work for visitors."
     296#~ msgstr ", eikä kestolinkki toimi käyttäjillä."
     297
     298#~ msgid "Visibility"
     299#~ msgstr "Näkyvyys"
     300
     301#~ msgid "Make this form publicly visible with permalink?"
     302#~ msgstr "Näytä lomake julkisesti kestolinkillä?"
     303
     304#~ msgid "Subscriber or visitor will see a 404 error page instead of form."
     305#~ msgstr "Tilaaja tai käyttäjä näkee lomakkeen sijaan 404-virhesivun."
     306
     307#~ msgid "Make this form publicly visible with direct link?"
     308#~ msgstr "Näytä lomake julkisesti suoralla linkillä?"
     309
     310#~ msgid "HTML form builder for WordPress"
     311#~ msgstr "HTML form builder for WordPress"
     312
    280313#~ msgid "referrer"
    281314#~ msgstr "lähde"
  • wp-libre-form/tags/1.1/lang/wp-libre-form-nb_NO.po

    r1359097 r1522309  
    22msgstr ""
    33"Project-Id-Version: WP Libre Form\n"
    4 "POT-Creation-Date: 2016-02-21 23:16+0100\n"
    5 "PO-Revision-Date: 2016-02-22 15:12+0100\n"
     4"POT-Creation-Date: 2016-10-26 10:29+0100\n"
     5"PO-Revision-Date: 2016-10-26 10:29+0100\n"
    66"Last-Translator: Antti Kuosmanen <antti@seravo.fi>\n"
    77"Language-Team: Antti Kuosmanen <antti@seravo.fi>\n"
     
    1111"Content-Transfer-Encoding: 8bit\n"
    1212"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    13 "X-Generator: Poedit 1.8.6\n"
     13"X-Generator: Poedit 1.8.8\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"X-Poedit-WPHeader: wp-libre-form.php\n"
     
    2121"X-Poedit-SearchPathExcluded-0: *.js\n"
    2222
    23 #: classes/class-cpt-wplf-form.php:53
     23#: classes/class-cpt-wplf-form.php:56
    2424msgctxt "post type general name"
    2525msgid "Forms"
    2626msgstr "Skjemaer"
    2727
    28 #: classes/class-cpt-wplf-form.php:54
     28#: classes/class-cpt-wplf-form.php:57
    2929msgctxt "post type singular name"
    3030msgid "Form"
    3131msgstr "Skjema"
    3232
    33 #: classes/class-cpt-wplf-form.php:55
     33#: classes/class-cpt-wplf-form.php:58
    3434msgctxt "admin menu"
    3535msgid "Forms"
    3636msgstr "Skjemaer"
    3737
    38 #: classes/class-cpt-wplf-form.php:56
     38#: classes/class-cpt-wplf-form.php:59
    3939msgctxt "add new on admin bar"
    4040msgid "Form"
    4141msgstr "Skjema"
    4242
    43 #: classes/class-cpt-wplf-form.php:57
     43#: classes/class-cpt-wplf-form.php:60
    4444msgctxt "form"
    4545msgid "New Form"
    4646msgstr "nytt skjema"
    4747
    48 #: classes/class-cpt-wplf-form.php:58
     48#: classes/class-cpt-wplf-form.php:61
    4949msgid "Add New Form"
    5050msgstr "Lag nytt skjema"
    5151
    52 #: classes/class-cpt-wplf-form.php:59
     52#: classes/class-cpt-wplf-form.php:62
    5353msgid "New Form"
    5454msgstr "nytt skjema"
    5555
    56 #: classes/class-cpt-wplf-form.php:60
     56#: classes/class-cpt-wplf-form.php:63
    5757msgid "Edit Form"
    5858msgstr "Rediger skjema"
    5959
    60 #: classes/class-cpt-wplf-form.php:61
     60#: classes/class-cpt-wplf-form.php:64
    6161msgid "View Form"
    6262msgstr "Vis skjema"
    6363
    64 #: classes/class-cpt-wplf-form.php:62 classes/class-cpt-wplf-submission.php:121
     64#: classes/class-cpt-wplf-form.php:65 classes/class-cpt-wplf-submission.php:135
    6565msgid "All Forms"
    6666msgstr "Alle skjemaer"
    6767
    68 #: classes/class-cpt-wplf-form.php:63
     68#: classes/class-cpt-wplf-form.php:66
    6969msgid "Search Forms"
    7070msgstr "Søk etter skjema"
    7171
    72 #: classes/class-cpt-wplf-form.php:64
     72#: classes/class-cpt-wplf-form.php:67
    7373msgid "No forms found."
    7474msgstr "Ingen skjemaer funnet."
    7575
    76 #: classes/class-cpt-wplf-form.php:65
     76#: classes/class-cpt-wplf-form.php:68
    7777msgid "No forms found in Trash."
    7878msgstr "Ingen skjema ble funnet i papirkurven"
    7979
    80 #: classes/class-cpt-wplf-form.php:148
     80#: classes/class-cpt-wplf-form.php:105
     81msgid "Permalink is for preview purposes only."
     82msgstr ""
     83
     84#: classes/class-cpt-wplf-form.php:163
    8185msgid "Please enter your name"
    8286msgstr "Vennligst skriv inn ditt navn"
    8387
    84 #: classes/class-cpt-wplf-form.php:149
     88#: classes/class-cpt-wplf-form.php:164
    8589msgctxt "Default placeholder name"
    8690msgid "John Doe"
    8791msgstr "Ola Nordmann"
    8892
    89 #: classes/class-cpt-wplf-form.php:151
     93#: classes/class-cpt-wplf-form.php:166
    9094msgid "Please enter your email address"
    9195msgstr "Vennligst skriv inn din e-postadresse"
    9296
    93 #: classes/class-cpt-wplf-form.php:151 classes/class-cpt-wplf-form.php:154
     97#: classes/class-cpt-wplf-form.php:166 classes/class-cpt-wplf-form.php:169
    9498msgid "(required)"
    9599msgstr "(påkrevd)"
    96100
    97 #: classes/class-cpt-wplf-form.php:152
     101#: classes/class-cpt-wplf-form.php:167
    98102msgctxt "Default placeholder email"
    99103msgid "example@email.com"
    100104msgstr "eksempel@e-mail.no"
    101105
    102 #: classes/class-cpt-wplf-form.php:154
     106#: classes/class-cpt-wplf-form.php:169
    103107msgid "Write your message below"
    104108msgstr "Skriv din melding nedenfor"
    105109
    106 #: classes/class-cpt-wplf-form.php:155
     110#: classes/class-cpt-wplf-form.php:170
    107111msgctxt "Default placeholder message"
    108112msgid "I wanted to ask about..."
    109113msgstr "Jeg ønsket å spørre om ..."
    110114
    111 #: classes/class-cpt-wplf-form.php:157
     115#: classes/class-cpt-wplf-form.php:172
    112116msgid "Submit"
    113117msgstr "Send"
    114118
    115 #: classes/class-cpt-wplf-form.php:159
     119#: classes/class-cpt-wplf-form.php:174
    116120msgctxt "The HTML comment at the end of the example form"
    117121msgid "Any valid HTML form can be used here!"
    118122msgstr "Alle gyldig skjema med HTML kan brukes her!"
    119123
    120 #: classes/class-cpt-wplf-form.php:175 classes/class-cpt-wplf-form.php:212
     124#: classes/class-cpt-wplf-form.php:201 classes/class-cpt-wplf-form.php:240
    121125msgid "Shortcode"
    122126msgstr "Shortcode"
    123127
    124 #: classes/class-cpt-wplf-form.php:176 classes/class-cpt-wplf-submission.php:46
     128#: classes/class-cpt-wplf-form.php:202 classes/class-cpt-wplf-submission.php:46
    125129msgid "Submissions"
    126130msgstr "Svar"
    127131
    128 #: classes/class-cpt-wplf-form.php:222
     132#: classes/class-cpt-wplf-form.php:250
    129133msgid "Success Message"
    130134msgstr "Suksessmelding"
    131135
    132 #: classes/class-cpt-wplf-form.php:232
     136#: classes/class-cpt-wplf-form.php:260
    133137msgid "Form Fields Detected"
    134138msgstr "Skjemafelt oppdaget"
    135139
    136 #: classes/class-cpt-wplf-form.php:241
     140#: classes/class-cpt-wplf-form.php:269
    137141msgid "Emails"
    138142msgstr "E-post"
    139143
    140 #: classes/class-cpt-wplf-form.php:250
     144#: classes/class-cpt-wplf-form.php:278
    141145msgid "Submission Title Format"
    142146msgstr "Tittel på svar"
    143147
    144 #: classes/class-cpt-wplf-form.php:273
     148#: classes/class-cpt-wplf-form.php:301
    145149msgctxt "Default success message"
    146150msgid "Thank you! :)"
    147151msgstr "Tusen takk! :)"
    148152
    149 #: classes/class-cpt-wplf-form.php:294
     153#: classes/class-cpt-wplf-form.php:322
    150154msgid "Fields marked with * are required"
    151155msgstr "Feltene merket med * er obligatoriske"
    152156
    153 #: classes/class-cpt-wplf-form.php:315
     157#: classes/class-cpt-wplf-form.php:343
    154158msgid "Send an email copy when a form is submitted?"
    155159msgstr "Send en e-post når et skjema er sendt?"
    156160
    157 #: classes/class-cpt-wplf-form.php:331
     161#: classes/class-cpt-wplf-form.php:359
    158162msgid "Submissions from this form will use this formatting in their title."
    159163msgstr "Svar fra dette skjemaet vil bruke denne formateringen i tittelen."
    160164
    161 #: classes/class-cpt-wplf-form.php:332
     165#: classes/class-cpt-wplf-form.php:360
    162166msgid "You may use any field values enclosed in \"%\" markers."
    163167msgstr "Du kan bruke feltverdier i \"%\" markører."
     168
     169#: classes/class-cpt-wplf-form.php:487
     170msgid "This form preview URL is not public and cannot be shared."
     171msgstr ""
     172
     173#: classes/class-cpt-wplf-form.php:488
     174msgid "Non-logged in visitors will see a 404 error page instead."
     175msgstr ""
    164176
    165177#: classes/class-cpt-wplf-submission.php:37
     
    224236msgstr "Skjema"
    225237
    226 #: classes/class-cpt-wplf-submission.php:158
     238#: classes/class-cpt-wplf-submission.php:172
    227239msgid "Submission"
    228240msgstr "Svar"
    229241
    230 #: classes/class-cpt-wplf-submission.php:178
     242#: classes/class-cpt-wplf-submission.php:193
    231243msgid "Field"
    232244msgstr "Felt"
    233245
    234 #: classes/class-cpt-wplf-submission.php:179
     246#: classes/class-cpt-wplf-submission.php:194
    235247msgid "Value"
    236248msgstr "Verdi"
     
    264276
    265277#. Description of the plugin/theme
    266 msgid "HTML form builder for WordPress"
     278msgid "A minimal HTML form builder for WordPress; made for developers"
    267279msgstr ""
    268280
  • wp-libre-form/tags/1.1/lang/wp-libre-form.pot

    r1359097 r1522309  
    44"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
    55"Project-Id-Version: WP Libre Form\n"
    6 "POT-Creation-Date: 2016-02-21 23:16+0100\n"
     6"POT-Creation-Date: 2016-10-26 10:29+0100\n"
    77"PO-Revision-Date: 2016-02-21 14:22+0100\n"
    88"Last-Translator: Antti Kuosmanen <antti@seravo.fi>\n"
     
    1111"Content-Type: text/plain; charset=UTF-8\n"
    1212"Content-Transfer-Encoding: 8bit\n"
    13 "X-Generator: Poedit 1.8.6\n"
     13"X-Generator: Poedit 1.8.8\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"X-Poedit-WPHeader: wp-libre-form.php\n"
     
    2121"X-Poedit-SearchPathExcluded-0: *.js\n"
    2222
    23 #: classes/class-cpt-wplf-form.php:53
     23#: classes/class-cpt-wplf-form.php:56
    2424msgctxt "post type general name"
    2525msgid "Forms"
    2626msgstr ""
    2727
    28 #: classes/class-cpt-wplf-form.php:54
     28#: classes/class-cpt-wplf-form.php:57
    2929msgctxt "post type singular name"
    3030msgid "Form"
    3131msgstr ""
    3232
    33 #: classes/class-cpt-wplf-form.php:55
     33#: classes/class-cpt-wplf-form.php:58
    3434msgctxt "admin menu"
    3535msgid "Forms"
    3636msgstr ""
    3737
    38 #: classes/class-cpt-wplf-form.php:56
     38#: classes/class-cpt-wplf-form.php:59
    3939msgctxt "add new on admin bar"
    4040msgid "Form"
    4141msgstr ""
    4242
    43 #: classes/class-cpt-wplf-form.php:57
     43#: classes/class-cpt-wplf-form.php:60
    4444msgctxt "form"
    4545msgid "New Form"
    4646msgstr ""
    4747
    48 #: classes/class-cpt-wplf-form.php:58
     48#: classes/class-cpt-wplf-form.php:61
    4949msgid "Add New Form"
    5050msgstr ""
    5151
    52 #: classes/class-cpt-wplf-form.php:59
     52#: classes/class-cpt-wplf-form.php:62
    5353msgid "New Form"
    5454msgstr ""
    5555
    56 #: classes/class-cpt-wplf-form.php:60
     56#: classes/class-cpt-wplf-form.php:63
    5757msgid "Edit Form"
    5858msgstr ""
    5959
    60 #: classes/class-cpt-wplf-form.php:61
     60#: classes/class-cpt-wplf-form.php:64
    6161msgid "View Form"
    6262msgstr ""
    6363
    64 #: classes/class-cpt-wplf-form.php:62
    65 #: classes/class-cpt-wplf-submission.php:121
     64#: classes/class-cpt-wplf-form.php:65
     65#: classes/class-cpt-wplf-submission.php:135
    6666msgid "All Forms"
    6767msgstr ""
    6868
    69 #: classes/class-cpt-wplf-form.php:63
     69#: classes/class-cpt-wplf-form.php:66
    7070msgid "Search Forms"
    7171msgstr ""
    7272
    73 #: classes/class-cpt-wplf-form.php:64
     73#: classes/class-cpt-wplf-form.php:67
    7474msgid "No forms found."
    7575msgstr ""
    7676
    77 #: classes/class-cpt-wplf-form.php:65
     77#: classes/class-cpt-wplf-form.php:68
    7878msgid "No forms found in Trash."
    7979msgstr ""
    8080
    81 #: classes/class-cpt-wplf-form.php:148
     81#: classes/class-cpt-wplf-form.php:105
     82msgid "Permalink is for preview purposes only."
     83msgstr ""
     84
     85#: classes/class-cpt-wplf-form.php:163
    8286msgid "Please enter your name"
    8387msgstr ""
    8488
    85 #: classes/class-cpt-wplf-form.php:149
     89#: classes/class-cpt-wplf-form.php:164
    8690msgctxt "Default placeholder name"
    8791msgid "John Doe"
    8892msgstr ""
    8993
    90 #: classes/class-cpt-wplf-form.php:151
     94#: classes/class-cpt-wplf-form.php:166
    9195msgid "Please enter your email address"
    9296msgstr ""
    9397
    94 #: classes/class-cpt-wplf-form.php:151 classes/class-cpt-wplf-form.php:154
     98#: classes/class-cpt-wplf-form.php:166 classes/class-cpt-wplf-form.php:169
    9599msgid "(required)"
    96100msgstr ""
    97101
    98 #: classes/class-cpt-wplf-form.php:152
     102#: classes/class-cpt-wplf-form.php:167
    99103msgctxt "Default placeholder email"
    100104msgid "example@email.com"
    101105msgstr ""
    102106
    103 #: classes/class-cpt-wplf-form.php:154
     107#: classes/class-cpt-wplf-form.php:169
    104108msgid "Write your message below"
    105109msgstr ""
    106110
    107 #: classes/class-cpt-wplf-form.php:155
     111#: classes/class-cpt-wplf-form.php:170
    108112msgctxt "Default placeholder message"
    109113msgid "I wanted to ask about..."
    110114msgstr ""
    111115
    112 #: classes/class-cpt-wplf-form.php:157
     116#: classes/class-cpt-wplf-form.php:172
    113117msgid "Submit"
    114118msgstr ""
    115119
    116 #: classes/class-cpt-wplf-form.php:159
     120#: classes/class-cpt-wplf-form.php:174
    117121msgctxt "The HTML comment at the end of the example form"
    118122msgid "Any valid HTML form can be used here!"
    119123msgstr ""
    120124
    121 #: classes/class-cpt-wplf-form.php:175 classes/class-cpt-wplf-form.php:212
     125#: classes/class-cpt-wplf-form.php:201 classes/class-cpt-wplf-form.php:240
    122126msgid "Shortcode"
    123127msgstr ""
    124128
    125 #: classes/class-cpt-wplf-form.php:176
     129#: classes/class-cpt-wplf-form.php:202
    126130#: classes/class-cpt-wplf-submission.php:46
    127131msgid "Submissions"
    128132msgstr ""
    129133
    130 #: classes/class-cpt-wplf-form.php:222
     134#: classes/class-cpt-wplf-form.php:250
    131135msgid "Success Message"
    132136msgstr ""
    133137
    134 #: classes/class-cpt-wplf-form.php:232
     138#: classes/class-cpt-wplf-form.php:260
    135139msgid "Form Fields Detected"
    136140msgstr ""
    137141
    138 #: classes/class-cpt-wplf-form.php:241
     142#: classes/class-cpt-wplf-form.php:269
    139143msgid "Emails"
    140144msgstr ""
    141145
    142 #: classes/class-cpt-wplf-form.php:250
     146#: classes/class-cpt-wplf-form.php:278
    143147msgid "Submission Title Format"
    144148msgstr ""
    145149
    146 #: classes/class-cpt-wplf-form.php:273
     150#: classes/class-cpt-wplf-form.php:301
    147151msgctxt "Default success message"
    148152msgid "Thank you! :)"
    149153msgstr ""
    150154
    151 #: classes/class-cpt-wplf-form.php:294
     155#: classes/class-cpt-wplf-form.php:322
    152156msgid "Fields marked with * are required"
    153157msgstr ""
    154158
    155 #: classes/class-cpt-wplf-form.php:315
     159#: classes/class-cpt-wplf-form.php:343
    156160msgid "Send an email copy when a form is submitted?"
    157161msgstr ""
    158162
    159 #: classes/class-cpt-wplf-form.php:331
     163#: classes/class-cpt-wplf-form.php:359
    160164msgid "Submissions from this form will use this formatting in their title."
    161165msgstr ""
    162166
    163 #: classes/class-cpt-wplf-form.php:332
     167#: classes/class-cpt-wplf-form.php:360
    164168msgid "You may use any field values enclosed in \"%\" markers."
     169msgstr ""
     170
     171#: classes/class-cpt-wplf-form.php:487
     172msgid "This form preview URL is not public and cannot be shared."
     173msgstr ""
     174
     175#: classes/class-cpt-wplf-form.php:488
     176msgid "Non-logged in visitors will see a 404 error page instead."
    165177msgstr ""
    166178
     
    226238msgstr ""
    227239
    228 #: classes/class-cpt-wplf-submission.php:158
     240#: classes/class-cpt-wplf-submission.php:172
    229241msgid "Submission"
    230242msgstr ""
    231243
    232 #: classes/class-cpt-wplf-submission.php:178
     244#: classes/class-cpt-wplf-submission.php:193
    233245msgid "Field"
    234246msgstr ""
    235247
    236 #: classes/class-cpt-wplf-submission.php:179
     248#: classes/class-cpt-wplf-submission.php:194
    237249msgid "Value"
    238250msgstr ""
     
    266278
    267279#. Description of the plugin/theme
    268 msgid "HTML form builder for WordPress"
     280msgid "A minimal HTML form builder for WordPress; made for developers"
    269281msgstr ""
    270282
  • wp-libre-form/tags/1.1/readme.md

    r1450731 r1522309  
    9090```
    9191
    92 ### Add own css classes to form output
     92### Client side callbacks
    9393
    94 You can use the attribute xclass inside the shortcode to set own extra css classes.
     94WP Libre Form supports client side callbacks after form submission using window.wplf object. Example usage:
     95
     96```
     97window.wplf.successCallbacks.push(function(response){
     98  alert("You succesfully submitted form " + response.form_id);
     99});
     100
     101window.wplf.errorCallbacks.push(function(response){
     102  alert("Form submission failed!");
     103});
     104```
     105
     106These callbacks are executed in the order they appear.
     107
     108### Add CSS classes to form output
     109
     110You can use the xclass attribute inside the shortcode to add your own extra classes.
    95111
    96112```
     
    124140}
    125141```
     142
     143### wplf_validate_submission example: Google ReCaptcha integration
     144
     145```php
     146/**
     147 * ReCaptcha for WP Libre Form
     148 */
     149add_filter( 'wplf_validate_submission', 'wplf_recaptcha' );
     150function wplf_recaptcha( $return ) {
     151  // skip this validation if submission has already failed
     152  if( ! $return->ok ) {
     153    return $return;
     154  }
     155
     156  $form = get_post( (int) $_POST['_form_id'] );
     157  if( false === strpos( $form->post_content, 'g-recaptcha' ) ) {
     158    // this form doesn't have recaptcha
     159    return $return;
     160  }
     161
     162  $secret = 'XXXX'; // substitute with your own secret recaptcha key
     163
     164  $options = [
     165    'http' => [
     166      'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
     167      'method'  => 'POST',
     168      'content' => http_build_query([
     169        'secret' => $secret,
     170        'response' => $_POST['g-recaptcha-response'],
     171      ])
     172    ],
     173  ];
     174  $context  = stream_context_create( $options );
     175  $result = file_get_contents( 'https://www.google.com/recaptcha/api/siteverify', false, $context );
     176
     177  $captcha_obj = json_decode( $result );
     178
     179  if( false === $captcha_obj->success ) {
     180    $return->ok = 0;
     181    $return->error = sprintf( __("Please prove you're not a robot before submitting."), intval( $_POST['_form_id'] ) );
     182  }
     183
     184  return $return;
     185}
     186```
  • wp-libre-form/tags/1.1/readme.txt

    r1450731 r1522309  
    44Donate link: https://github.com/anttiviljami
    55Requires at least: 4.2
    6 Tested up to: 4.4.4
    7 Stable tag: 1.0.2
     6Tested up to: 4.6.1
     7Stable tag: 1.1
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
  • wp-libre-form/tags/1.1/wp-libre-form.php

    r1450731 r1522309  
    44 * Plugin URI: https://github.com/anttiviljami/wp-libre-form
    55 * Description: A minimal HTML form builder for WordPress; made for developers
    6  * Version: 1.0.2
     6 * Version: 1.1
    77 * Author: @anttiviljami
    88 * Author URI: https://github.com/anttiviljami/
     
    3131
    3232if ( ! class_exists( 'WP_Libre_Form' ) ) :
     33
     34define( 'WPLF_VERSION', '1.1' );
    3335
    3436class WP_Libre_Form {
     
    7577   */
    7678  public static function load_our_textdomain() {
    77     load_plugin_textdomain( 'wp-libre-form', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
     79    $loaded = load_plugin_textdomain( 'wp-libre-form', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
     80
     81    if( !$loaded ) {
     82      $loaded = load_muplugin_textdomain( 'wp-libre-form', dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
     83    }
    7884  }
    7985
  • wp-libre-form/trunk/assets/scripts/wplf-form.js

    r1359097 r1522309  
    33 */
    44
    5 (function($) {
     5// Fetch polyfill: https://github.com/github/fetch
     6!function(t){"use strict";function e(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t=String(t)),t}function o(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return y.iterable&&(e[Symbol.iterator]=function(){return e}),e}function n(t){this.map={},t instanceof n?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function s(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function i(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function a(t){var e=new FileReader;return e.readAsArrayBuffer(t),i(e)}function h(t){var e=new FileReader;return e.readAsText(t),i(e)}function u(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(y.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(y.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(y.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(t){if(!y.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw new Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):y.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},y.blob?(this.blob=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(a)},this.text=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return h(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var t=s(this);return t?t:Promise.resolve(this._bodyText)},y.formData&&(this.formData=function(){return this.text().then(p)}),this.json=function(){return this.text().then(JSON.parse)},this}function f(t){var e=t.toUpperCase();return b.indexOf(e)>-1?e:t}function d(t,e){e=e||{};var r=e.body;if(d.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new n(t.headers)),this.method=t.method,this.mode=t.mode,r||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=e.credentials||this.credentials||"omit",(e.headers||!this.headers)&&(this.headers=new n(e.headers)),this.method=f(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function p(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}}),e}function c(t){var e=new n,r=(t.getAllResponseHeaders()||"").trim().split("\n");return r.forEach(function(t){var r=t.trim().split(":"),o=r.shift().trim(),n=r.join(":").trim();e.append(o,n)}),e}function l(t,e){e||(e={}),this.type="default",this.status=e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText,this.headers=e.headers instanceof n?e.headers:new n(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var y={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};n.prototype.append=function(t,o){t=e(t),o=r(o);var n=this.map[t];n||(n=[],this.map[t]=n),n.push(o)},n.prototype["delete"]=function(t){delete this.map[e(t)]},n.prototype.get=function(t){var r=this.map[e(t)];return r?r[0]:null},n.prototype.getAll=function(t){return this.map[e(t)]||[]},n.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},n.prototype.set=function(t,o){this.map[e(t)]=[r(o)]},n.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(o){t.call(e,o,r,this)},this)},this)},n.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),o(t)},n.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),o(t)},n.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),o(t)},y.iterable&&(n.prototype[Symbol.iterator]=n.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];d.prototype.clone=function(){return new d(this)},u.call(d.prototype),u.call(l.prototype),l.prototype.clone=function(){return new l(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new n(this.headers),url:this.url})},l.error=function(){var t=new l(null,{status:0,statusText:""});return t.type="error",t};var m=[301,302,303,307,308];l.redirect=function(t,e){if(-1===m.indexOf(e))throw new RangeError("Invalid status code");return new l(null,{status:e,headers:{location:t}})},t.Headers=n,t.Request=d,t.Response=l,t.fetch=function(t,e){return new Promise(function(r,o){function n(){return"responseURL"in i?i.responseURL:/^X-Request-URL:/m.test(i.getAllResponseHeaders())?i.getResponseHeader("X-Request-URL"):void 0}var s;s=d.prototype.isPrototypeOf(t)&&!e?t:new d(t,e);var i=new XMLHttpRequest;i.onload=function(){var t={status:i.status,statusText:i.statusText,headers:c(i),url:n()},e="response"in i?i.response:i.responseText;r(new l(e,t))},i.onerror=function(){o(new TypeError("Network request failed"))},i.ontimeout=function(){o(new TypeError("Network request failed"))},i.open(s.method,s.url,!0),"include"===s.credentials&&(i.withCredentials=!0),"responseType"in i&&y.blob&&(i.responseType="blob"),s.headers.forEach(function(t,e){i.setRequestHeader(e,t)}),i.send("undefined"==typeof s._bodyInit?null:s._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this);
    67
    7 $(document).ready(function() {
     8// Promise polyfill: https://github.com/taylorhakes/promise-polyfill
     9!function(t){function e(){}function n(t,e){return function(){t.apply(e,arguments)}}function o(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(t,this)}function r(t,e){for(;3===t._state;)t=t._value;return 0===t._state?void t._deferreds.push(e):(t._handled=!0,void a(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._state?i:f)(e.promise,t._value);var o;try{o=n(t._value)}catch(r){return void f(e.promise,r)}i(e.promise,o)}))}function i(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var r=e.then;if(e instanceof o)return t._state=3,t._value=e,void u(t);if("function"==typeof r)return void s(n(r,e),t)}t._state=1,t._value=e,u(t)}catch(i){f(t,i)}}function f(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&a(function(){t._handled||d(t._value)});for(var e=0,n=t._deferreds.length;n>e;e++)r(t,t._deferreds[e]);t._deferreds=null}function c(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function s(t,e){var n=!1;try{t(function(t){n||(n=!0,i(e,t))},function(t){n||(n=!0,f(e,t))})}catch(o){if(n)return;n=!0,f(e,o)}}var l=setTimeout,a="function"==typeof setImmediate&&setImmediate||function(t){l(t,0)},d=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};o.prototype["catch"]=function(t){return this.then(null,t)},o.prototype.then=function(t,n){var o=new this.constructor(e);return r(this,new c(t,n,o)),o},o.all=function(t){var e=Array.prototype.slice.call(t);return new o(function(t,n){function o(i,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(t){o(i,t)},n)}e[i]=f,0===--r&&t(e)}catch(c){n(c)}}if(0===e.length)return t([]);for(var r=e.length,i=0;i<e.length;i++)o(i,e[i])})},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o(function(e){e(t)})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){for(var o=0,r=t.length;r>o;o++)t[o].then(e,n)})},o._setImmediateFn=function(t){a=t},o._setUnhandledRejectionFn=function(t){d=t},"undefined"!=typeof module&&module.exports?module.exports=o:t.Promise||(t.Promise=o)}(this);
    810
    9   // ajax form submissions
    10   $('.libre-form').submit(function(e) {
    1111
    12     var $form = $(this);
     12(function(){
    1313
    14     // add class to enable css changes to indicate ajax loading
    15     $form.addClass('sending');
     14window.wplf = {
     15  successCallbacks: [],
     16  errorCallbacks: []
     17};
    1618
    17     // reset errors
    18     $form.find('.wplf-error').remove();
     19document.addEventListener("DOMContentLoaded", function(){
     20  [].forEach.call(document.querySelectorAll(".libre-form"), function(form){
    1921
    20     // submit form to ajax handler in admin-ajax.php
    21     $.post( ajax_object.ajax_url + '?action=wplf_submit',
    22       $(this).serialize(),
    23       function(response) {
    24         console.log(response);
     22    form.addEventListener("submit", function(e){
     23
     24      // add class to enable css changes to indicate ajax loading
     25      form.classList.add("sending");
     26
     27      [].forEach.call(form.querySelectorAll(".wplf-error"), function(error){
     28        // reset errors
     29        error.parentNode.removeChild(error);
     30      });
     31
     32      var data = new FormData(form);
     33
     34      window.data = data;
     35
     36      fetch(ajax_object.ajax_url  + '?action=wplf_submit', {
     37        method: "POST",
     38        body: data
     39      }).then(function(response){
     40
     41        return response.text();
     42
     43      }).then(function(response){
     44
     45        response = JSON.parse(response);
     46
    2547        if( 'success' in response ) {
    2648          // show success message if one exists
    27           $form.after(response.success);
    28         }
     49
     50          var success = document.createElement("p");
     51          success.className = "wplf-success";
     52          success.innerHTML = response.success;
     53
     54          form.parentNode.insertBefore(success, form.nextSibling);
     55        }
     56
    2957        if( 'ok' in response && response.ok ) {
    3058          // submit succesful!
    31           $form.remove();
     59          form.parentNode.removeChild(form);
     60
     61          window.wplf.successCallbacks.forEach(function(func){
     62            func(response);
     63          });
    3264        }
     65
    3366        if( 'error' in response ) {
    3467          // show error message in form
    35           $form.append('<p class="wplf-error error">' + response.error + '</p>');
     68
     69          var error = document.createElement("p");
     70          error.className = "wplf-error error";
     71          error.textContent = response.error;
     72
     73          form.appendChild(error);
     74
     75          window.wplf.errorCallbacks.forEach(function(func){
     76            func(response);
     77          });
    3678        }
    37       }
    38     ).always(function() {
    39       // finished XHR request
    40       $form.removeClass('sending');
    41     });;
    4279
    43     // don't actually submit the form, causing a page reload
    44     e.preventDefault();
    45     return false;
     80        form.classList.remove('sending');
     81
     82      }).catch(function(error){
     83
     84        console.warn("Fetch error: ", error);
     85        form.classList.remove("sending");
     86
     87      });
     88
     89      // don't actually submit the form, causing a page reload
     90
     91      e.preventDefault();
     92    });
    4693
    4794  });
    4895});
    49 
    50 })(jQuery);
    51 
     96})();
  • wp-libre-form/trunk/classes/class-cpt-wplf-form.php

    r1450731 r1522309  
    2424
    2525    // post.php / post-new.php view
     26    add_filter( 'get_sample_permalink_html', array( $this, 'modify_permalink_html' ), 10, 2 );
    2627    add_action( 'save_post', array( $this, 'save_cpt' ) );
    2728    add_filter( 'content_save_pre' , array( $this, 'strip_form_tags' ), 10, 1 );
     
    3031
    3132    // edit.php view
     33    add_filter( 'post_row_actions', array( $this, 'remove_row_actions' ), 10, 2 );
    3234    add_filter( 'manage_edit-wplf-form_columns' , array( $this, 'custom_columns_cpt' ), 100, 1 );
    3335    add_action( 'manage_posts_custom_column' , array( $this, 'custom_columns_display_cpt' ), 10, 2 );
     
    3840    // front end
    3941    add_shortcode( 'libre-form', array( $this, 'shortcode' ) );
     42    add_action( 'wp', array( $this, 'maybe_set_404_for_single_form' ) );
    4043    add_filter( 'the_content', array( $this, 'use_shortcode_for_preview' ) );
    4144    add_action( 'wp_enqueue_scripts', array( $this, 'maybe_enqueue_frontend_script' ) );
     
    9396  }
    9497
     98  /**
     99   * Modify post.php permalink html to show notice if form isn't publicly visible.
     100   */
     101  function modify_permalink_html( $html, $post_id ) {
     102    $publicly_visible = $this->get_publicly_visible_state( $post_id );
     103
     104    if( get_post_type( $post_id ) === 'wplf-form' && !$publicly_visible ) {
     105      $html .= '<span>' . __( 'Permalink is for preview purposes only.', 'wp-libre-form' ) . '</span>';
     106    }
     107
     108    return $html;
     109  }
    95110
    96111  /**
     
    165180  }
    166181
     182  /**
     183   * Remove view action in edit.php for forms
     184   */
     185  function remove_row_actions( $actions, $post ) {
     186    $publicly_visible = $this->get_publicly_visible_state( $post->ID );
     187
     188    if( $post->post_type === 'wplf-form' && !$publicly_visible )
     189      unset( $actions['view'] );
     190
     191    return $actions;
     192  }
    167193
    168194  /**
     
    315341  <label for="wplf_email_copy_enabled">
    316342    <input type="checkbox" <?php echo $email_enabled ? 'checked="checked"' : ''; ?> id="wplf_email_copy_enabled" name="wplf_email_copy_enabled">
    317     <?php _e( 'Send an email copy when a form is submitted?' ); ?>
     343    <?php _e( 'Send an email copy when a form is submitted?', 'wp-libre-form' ); ?>
    318344  </label>
    319345</p>
     
    333359<p><?php _e('Submissions from this form will use this formatting in their title.', 'wp-libre-form'); ?></p>
    334360<p><?php _e('You may use any field values enclosed in "%" markers.', 'wp-libre-form');?></p>
    335 <p><input type="text" name="wplf_title_format" value="<?php echo esc_attr( $format ); ?>" placeholder="<?php echo esc_attr( $default ); ?>" class="code" style="width:100%"></p>
    336 <?php
    337   }
    338 
     361<p><input type="text" name="wplf_title_format" value="<?php echo esc_attr( $format ); ?>" placeholder="<?php echo esc_attr( $default ); ?>" class="code" style="width:100%" autocomplete="off"></p>
     362<?php
     363  }
    339364
    340365  /**
     
    385410    // save email copy
    386411    if ( isset( $_POST['wplf_email_copy_to'] ) ) {
    387       update_post_meta( $post_id, '_wplf_email_copy_to', sanitize_email( $_POST['wplf_email_copy_to'] ) );
     412      $emailField = $_POST['wplf_email_copy_to'];
     413      $to = '';
     414
     415      if( strpos( $emailField, "," ) > 0 ) {
     416        // Intentional. Makes no sense if the first character is a comma, so pass it along as a single address.
     417        // sanitize_email() should take care of the rest.
     418        $emailArray = explode( ",", $emailField );
     419        foreach($emailArray as $email){
     420          $email = trim($email);
     421          $email = sanitize_email( $email ) . ", ";
     422          $to .= $email;
     423        }
     424        $to = rtrim( $to, ", " );
     425      }
     426      else {
     427        $to = sanitize_email( $emailField );
     428      }
     429
     430      if( !empty( $to ) ) {
     431        update_post_meta( $post_id, '_wplf_email_copy_to', $to );
     432      } else {
     433        delete_post_meta( $post_id, '_wplf_email_copy_to' );
     434      }
    388435    }
    389436
     
    423470        $content = get_post( $id )->post_content;
    424471      }
     472
     473      $multipart = "";
     474      // check if form contains file inputs
     475      if(strpos($content, "type='file'") > -1 || strpos($content, "type=\"file\"") > -1){
     476        $multipart = "enctype='multipart/form-data'";
     477      }
     478
    425479      ob_start();
    426480?>
    427 <form class="libre-form libre-form-<?php echo $id . ' ' . $xclass; ?>">
     481<form class="libre-form libre-form-<?php echo $id . ' ' . $xclass; ?>" <?php echo $multipart; ?>>
     482  <?php if( is_singular( 'wplf-form' ) && current_user_can( 'edit_post', $id ) ) {
     483    $publicly_visible = $this->get_publicly_visible_state( $id );
     484    if( !$publicly_visible ) {
     485?>
     486      <p style="background:#f5f5f5;border-left:4px solid #dc3232;padding:6px 12px;">
     487        <b style="color:#dc3232;"><?php _e( 'This form preview URL is not public and cannot be shared.', 'wp-libre-form' ) ?>.</b><br />
     488        <?php _e( 'Non-logged in visitors will see a 404 error page instead.', 'wp-libre-form' ) ?>
     489      </p>
     490<?php
     491    }
     492  } ?>
    428493  <?php echo apply_filters( 'wplf_form', $content ); ?>
    429494  <input type="hidden" name="referrer" value="<?php the_permalink(); ?>">
     495  <input type="hidden" name="_referrer_id" value="<?php esc_attr_e( get_the_id() ) ?>">
    430496  <input type="hidden" name="_form_id" value="<?php esc_attr_e( $id ); ?>">
    431497</form>
     
    447513
    448514    // register the script, but only enqueue it if the current post contains a form in it
    449     wp_register_script( 'wplf-form-js', plugins_url( 'assets/scripts/wplf-form.js', dirname(__FILE__) ), array( 'jquery' ) );
     515    wp_register_script( 'wplf-form-js', plugins_url( 'assets/scripts/wplf-form.js', dirname(__FILE__) ), array(), WPLF_VERSION, true );
    450516
    451517    if( is_a( $post, 'WP_Post' ) && ( has_shortcode( $post->post_content, 'libre-form') || $post->post_type === 'wplf-form') ) {
     
    480546    return $content;
    481547  }
     548
     549  /**
     550   * Set and show 404 page for visitors trying to see single form.
     551   * And yes, it is a global $post. That's right.
     552   */
     553  function maybe_set_404_for_single_form() {
     554    global $post;
     555
     556    if( !is_singular( 'wplf-form' ) )
     557      return;
     558
     559    $publicly_visible = $this->get_publicly_visible_state( $post->ID );
     560    if( $publicly_visible )
     561      return;
     562
     563    if( !current_user_can( 'edit_post', $post->ID ) ) {
     564      global $wp_query;
     565      $wp_query->set_404();
     566    }
     567  }
     568
     569  /**
     570   * Wrapper function to check if form is publicly visible.
     571   */
     572  function get_publicly_visible_state( $id ) {
     573    return apply_filters( 'wplf-form-publicly-visible', false, $id );
     574  }
    482575}
    483576
  • wp-libre-form/trunk/classes/class-cpt-wplf-submission.php

    r1359097 r1522309  
    107107    global $pagenow;
    108108
    109     if( 'edit.php' != $pagenow ) {
     109    $allowed = array("wplf-submission"); // show filter on these post types (currently only one?)
     110    $allowed = apply_filters("wplf-dropdown-filter", $allowed);
     111    $post_type = get_query_var("post_type");
     112
     113    if( 'edit.php' != $pagenow || !in_array($post_type, $allowed)) {
    110114      return;
    111115    }
    112116
    113     // TODO: put this in a transient
    114     $forms = get_posts( array(
    115       'post_per_page' => '-1',
    116       'post_type' => 'wplf-form',
    117     ) );
     117    $transient = get_transient("wplf-form-filter");
     118
     119    if($transient){
     120      $forms = $transient;
     121    }
     122
     123    else{
     124      $forms = get_posts( array(
     125        'post_per_page' => '-1',
     126        'post_type' => 'wplf-form',
     127      ) );
     128
     129      set_transient("wplf-form-filter", $forms, 15 *  MINUTE_IN_SECONDS);
     130    }
     131
    118132?>
    119133<label for="filter-by-form" class="screen-reader-text">Filter by form</label>
     
    171185    $postmeta = get_post_meta( $post->ID );
    172186    $fields = array_keys( $postmeta );
     187    $home_path = get_home_path();
    173188?>
    174189<p>
     
    183198      <?php foreach( $fields as $field ) : ?>
    184199        <?php if( '_' != $field[0]  ) : ?>
    185         <?php $value = $postmeta[ $field ][0]; ?>
     200        <?php
     201        $value = $postmeta[ $field ][0];
     202        $possible_link = '';
     203        $attachment_url = wp_get_attachment_url( $value ); // get_edit_post_link returns something awkward.
     204
     205        // Maybe add a filter for target="_blank"? Wouldn't enable by default.
     206
     207        if ( $attachment_url ) {
     208          // If this is true, $value was a valid attachment_id.
     209          // Caveat: if user enters a numeric value here, it could be interpreted as attachment.
     210          $attachment_url = get_edit_post_link($value);
     211          $possible_link = "<a href='$attachment_url' style='float: right;'>Edit attachment</a>";
     212        } elseif ( file_exists( $home_path . substr( $value, 1 ) ) ) {
     213          // This is bit less ambiguous. Check if there's a file, and if there is, get link for it.
     214          $attachment_url = get_home_url() . $value;
     215          $possible_link = "<a href='$attachment_url' style='float: right;'>Open file</a>";
     216        }
     217        ?>
    186218        <tr>
    187           <th><strong><?php echo $field; ?></strong></th>
     219          <th><strong><?php echo $field; ?></strong> <?php echo $possible_link; ?></th>
    188220          <?php if( strlen( $value ) > 60 || strpos( $value, "\n" ) ) : ?>
    189221          <td><textarea style="width:100%" readonly><?php echo esc_textarea( $value ); ?></textarea></td>
     
    202234
    203235endif;
    204 
  • wp-libre-form/trunk/inc/wplf-ajax.php

    r1359097 r1522309  
    1919  if( $return->ok ) {
    2020    // form existence has already been validated via filters
     21
     22
    2123    $form = get_post( intval( $_POST['_form_id'] ) );
    2224
     
    5355    }
    5456
     57    // handle files
     58    foreach( $_FILES as $key => $file) {
     59      // Is this enough security wise?
     60      // Currenly only supports 1 file per input
     61      $attach_id = media_handle_upload( $key, 0, array(), array( "test_form" => false ) );
     62      add_post_meta( $post_id, $key, wp_get_attachment_url($attach_id) );
     63      add_post_meta( $post_id, $key . "_attachment", $attach_id );
     64    }
     65
     66
     67
    5568    $return->submission_id = $post_id;
    5669    $return->submission_title = $post_title;
     70    $return->form_id = $form->ID;
    5771
    5872    // return the success message for the form
     
    6983  wp_die();
    7084}
    71 
  • wp-libre-form/trunk/inc/wplf-form-actions.php

    r1365849 r1522309  
    1919    $to = isset($form_meta['_wplf_email_copy_to']) ? $form_meta['_wplf_email_copy_to'][0] : get_option( 'admin_email' );
    2020    $subject = wp_sprintf( __('New submission from %s', 'wp-libre-form'), $referrer );
    21     $content = wp_sprintf( __('Form "%s" (ID %d) was submitted with values below: ', 'wp-libre-form'), $form_title, $form_id ) . "\n\n";
     21    $content = wp_sprintf( __('Form "%s" (ID %d) was submitted with values below: ', 'wp-libre-form'), $form_title, $form_id );
     22    $content = apply_filters( 'wplf_email_copy_content_start', $content, $form_title, $form_id ). "\n\n";
     23
    2224    foreach( $_POST as $key => $value ) {
    2325      if( '_' === $key[0] ) {
     
    2628      $content .= esc_html( $key ) . ': ' . esc_html( print_r( $value, true ) ) . "\n";
    2729    }
    28     wp_mail( $to, $subject, $content );
     30
     31    wp_mail(
     32      apply_filters( 'wplf_email_copy_to', $to ),
     33      apply_filters( 'wplf_email_copy_subject', $subject ),
     34      apply_filters( 'wplf_email_copy_content', $content ),
     35      apply_filters( 'wplf_email_copy_headers', '' ),
     36      apply_filters( 'wplf_email_copy_attachments', array() )
     37    );
    2938  }
    3039}
    31 
  • wp-libre-form/trunk/lang/wp-libre-form-fi.po

    r1359097 r1522309  
    22msgstr ""
    33"Project-Id-Version: WP Libre Form\n"
    4 "POT-Creation-Date: 2016-02-21 23:16+0100\n"
    5 "PO-Revision-Date: 2016-02-21 23:16+0100\n"
     4"POT-Creation-Date: 2016-10-26 10:29+0100\n"
     5"PO-Revision-Date: 2016-10-26 10:30+0100\n"
    66"Last-Translator: Antti Kuosmanen <antti@seravo.fi>\n"
    77"Language-Team: Antti Kuosmanen <antti@seravo.fi>\n"
     
    1111"Content-Transfer-Encoding: 8bit\n"
    1212"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    13 "X-Generator: Poedit 1.8.6\n"
     13"X-Generator: Poedit 1.8.8\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"X-Poedit-WPHeader: wp-libre-form.php\n"
     
    2121"X-Poedit-SearchPathExcluded-0: *.js\n"
    2222
    23 #: classes/class-cpt-wplf-form.php:53
     23#: classes/class-cpt-wplf-form.php:56
    2424msgctxt "post type general name"
    2525msgid "Forms"
    2626msgstr "Lomakkeet"
    2727
    28 #: classes/class-cpt-wplf-form.php:54
     28#: classes/class-cpt-wplf-form.php:57
    2929msgctxt "post type singular name"
    3030msgid "Form"
    3131msgstr "Lomake"
    3232
    33 #: classes/class-cpt-wplf-form.php:55
     33#: classes/class-cpt-wplf-form.php:58
    3434msgctxt "admin menu"
    3535msgid "Forms"
    3636msgstr "Lomakkeet"
    3737
    38 #: classes/class-cpt-wplf-form.php:56
     38#: classes/class-cpt-wplf-form.php:59
    3939msgctxt "add new on admin bar"
    4040msgid "Form"
    4141msgstr "Lomake"
    4242
    43 #: classes/class-cpt-wplf-form.php:57
     43#: classes/class-cpt-wplf-form.php:60
    4444msgctxt "form"
    4545msgid "New Form"
    4646msgstr "Uusi lomake"
    4747
    48 #: classes/class-cpt-wplf-form.php:58
     48#: classes/class-cpt-wplf-form.php:61
    4949msgid "Add New Form"
    5050msgstr "Luo uusi lomake"
    5151
    52 #: classes/class-cpt-wplf-form.php:59
     52#: classes/class-cpt-wplf-form.php:62
    5353msgid "New Form"
    5454msgstr "Uusi lomake"
    5555
    56 #: classes/class-cpt-wplf-form.php:60
     56#: classes/class-cpt-wplf-form.php:63
    5757msgid "Edit Form"
    5858msgstr "Muokkaa lomaketta"
    5959
    60 #: classes/class-cpt-wplf-form.php:61
     60#: classes/class-cpt-wplf-form.php:64
    6161msgid "View Form"
    6262msgstr "Näytä lomake"
    6363
    64 #: classes/class-cpt-wplf-form.php:62 classes/class-cpt-wplf-submission.php:121
     64#: classes/class-cpt-wplf-form.php:65 classes/class-cpt-wplf-submission.php:135
    6565msgid "All Forms"
    6666msgstr "Kaikki lomakkeet"
    6767
    68 #: classes/class-cpt-wplf-form.php:63
     68#: classes/class-cpt-wplf-form.php:66
    6969msgid "Search Forms"
    7070msgstr "Etsi lomakkeita"
    7171
    72 #: classes/class-cpt-wplf-form.php:64
     72#: classes/class-cpt-wplf-form.php:67
    7373msgid "No forms found."
    7474msgstr "Lomakkeita ei löytynt."
    7575
    76 #: classes/class-cpt-wplf-form.php:65
     76#: classes/class-cpt-wplf-form.php:68
    7777msgid "No forms found in Trash."
    7878msgstr "Roskakorissa ei ole lomakkeita."
    7979
    80 #: classes/class-cpt-wplf-form.php:148
     80#: classes/class-cpt-wplf-form.php:105
     81msgid "Permalink is for preview purposes only."
     82msgstr "Kestolinkki toimii vain esikatseluna."
     83
     84#: classes/class-cpt-wplf-form.php:163
    8185msgid "Please enter your name"
    8286msgstr "Kirjoita nimesi"
    8387
    84 #: classes/class-cpt-wplf-form.php:149
     88#: classes/class-cpt-wplf-form.php:164
    8589msgctxt "Default placeholder name"
    8690msgid "John Doe"
    8791msgstr "Matti Meikäläinen"
    8892
    89 #: classes/class-cpt-wplf-form.php:151
     93#: classes/class-cpt-wplf-form.php:166
    9094msgid "Please enter your email address"
    9195msgstr "Kirjoita sähköpostiosoitteesi"
    9296
    93 #: classes/class-cpt-wplf-form.php:151 classes/class-cpt-wplf-form.php:154
     97#: classes/class-cpt-wplf-form.php:166 classes/class-cpt-wplf-form.php:169
    9498msgid "(required)"
    9599msgstr "(pakollinen)"
    96100
    97 #: classes/class-cpt-wplf-form.php:152
     101#: classes/class-cpt-wplf-form.php:167
    98102msgctxt "Default placeholder email"
    99103msgid "example@email.com"
    100104msgstr "esimerkki@esimerkki.fi"
    101105
    102 #: classes/class-cpt-wplf-form.php:154
     106#: classes/class-cpt-wplf-form.php:169
    103107msgid "Write your message below"
    104108msgstr "Kirjoita viestisi alle"
    105109
    106 #: classes/class-cpt-wplf-form.php:155
     110#: classes/class-cpt-wplf-form.php:170
    107111msgctxt "Default placeholder message"
    108112msgid "I wanted to ask about..."
    109113msgstr "Halusin kysyä..."
    110114
    111 #: classes/class-cpt-wplf-form.php:157
     115#: classes/class-cpt-wplf-form.php:172
    112116msgid "Submit"
    113117msgstr "Lähetä"
    114118
    115 #: classes/class-cpt-wplf-form.php:159
     119#: classes/class-cpt-wplf-form.php:174
    116120msgctxt "The HTML comment at the end of the example form"
    117121msgid "Any valid HTML form can be used here!"
    118122msgstr "Tässä toimii mikä tahansa HTML-lomake!"
    119123
    120 #: classes/class-cpt-wplf-form.php:175 classes/class-cpt-wplf-form.php:212
     124#: classes/class-cpt-wplf-form.php:201 classes/class-cpt-wplf-form.php:240
    121125msgid "Shortcode"
    122126msgstr "Lyhytkoodi"
    123127
    124 #: classes/class-cpt-wplf-form.php:176 classes/class-cpt-wplf-submission.php:46
     128#: classes/class-cpt-wplf-form.php:202 classes/class-cpt-wplf-submission.php:46
    125129msgid "Submissions"
    126130msgstr "Vastaukset"
    127131
    128 #: classes/class-cpt-wplf-form.php:222
     132#: classes/class-cpt-wplf-form.php:250
    129133msgid "Success Message"
    130134msgstr "Onnistumisviesti"
    131135
    132 #: classes/class-cpt-wplf-form.php:232
     136#: classes/class-cpt-wplf-form.php:260
    133137msgid "Form Fields Detected"
    134138msgstr "Lomakekentät"
    135139
    136 #: classes/class-cpt-wplf-form.php:241
     140#: classes/class-cpt-wplf-form.php:269
    137141msgid "Emails"
    138142msgstr "Sähköpostit"
    139143
    140 #: classes/class-cpt-wplf-form.php:250
     144#: classes/class-cpt-wplf-form.php:278
    141145msgid "Submission Title Format"
    142146msgstr "Nimi lähetetylle lomakkeelle"
    143147
    144 #: classes/class-cpt-wplf-form.php:273
     148#: classes/class-cpt-wplf-form.php:301
    145149msgctxt "Default success message"
    146150msgid "Thank you! :)"
    147151msgstr "Kiitos! :)"
    148152
    149 #: classes/class-cpt-wplf-form.php:294
     153#: classes/class-cpt-wplf-form.php:322
    150154msgid "Fields marked with * are required"
    151155msgstr "Tähdelliset * kentät on pakollisia"
    152156
    153 #: classes/class-cpt-wplf-form.php:315
     157#: classes/class-cpt-wplf-form.php:343
    154158msgid "Send an email copy when a form is submitted?"
    155159msgstr "Lähetä kopio sähköpostiin kun lomake lähetetään?"
    156160
    157 #: classes/class-cpt-wplf-form.php:331
     161#: classes/class-cpt-wplf-form.php:359
    158162msgid "Submissions from this form will use this formatting in their title."
    159163msgstr ""
     
    161165"mukaisesti."
    162166
    163 #: classes/class-cpt-wplf-form.php:332
     167#: classes/class-cpt-wplf-form.php:360
    164168msgid "You may use any field values enclosed in \"%\" markers."
    165169msgstr ""
    166170"Voit käyttää otsikossa mitä tahansa kenttiä arvoja \"%\"-merkkien sisällä."
     171
     172#: classes/class-cpt-wplf-form.php:487
     173msgid "This form preview URL is not public and cannot be shared."
     174msgstr "Tämä esikatselusivu ei ole julkinen, eikä sitä voi jakaa."
     175
     176#: classes/class-cpt-wplf-form.php:488
     177msgid "Non-logged in visitors will see a 404 error page instead."
     178msgstr "Kirjautumattomille vierailijoille näytetään 404-sivu."
    167179
    168180#: classes/class-cpt-wplf-submission.php:37
     
    227239msgstr "Lomake"
    228240
    229 #: classes/class-cpt-wplf-submission.php:158
     241#: classes/class-cpt-wplf-submission.php:172
    230242msgid "Submission"
    231243msgstr "Vastaus"
    232244
    233 #: classes/class-cpt-wplf-submission.php:178
     245#: classes/class-cpt-wplf-submission.php:193
    234246msgid "Field"
    235247msgstr "Kenttä"
    236248
    237 #: classes/class-cpt-wplf-submission.php:179
     249#: classes/class-cpt-wplf-submission.php:194
    238250msgid "Value"
    239251msgstr "Arvo"
     
    267279
    268280#. Description of the plugin/theme
    269 msgid "HTML form builder for WordPress"
    270 msgstr "HTML form builder for WordPress"
     281msgid "A minimal HTML form builder for WordPress; made for developers"
     282msgstr "Minimalistinen HTML lomakerakentaja WordPressille; tehty kehittäjille."
    271283
    272284#. Author of the plugin/theme
     
    278290msgstr "https://github.com/anttiviljami/"
    279291
     292#~ msgid "Form is not publicly visible"
     293#~ msgstr "Lomake ei näy julkisesti"
     294
     295#~ msgid ", permalink will not work for visitors."
     296#~ msgstr ", eikä kestolinkki toimi käyttäjillä."
     297
     298#~ msgid "Visibility"
     299#~ msgstr "Näkyvyys"
     300
     301#~ msgid "Make this form publicly visible with permalink?"
     302#~ msgstr "Näytä lomake julkisesti kestolinkillä?"
     303
     304#~ msgid "Subscriber or visitor will see a 404 error page instead of form."
     305#~ msgstr "Tilaaja tai käyttäjä näkee lomakkeen sijaan 404-virhesivun."
     306
     307#~ msgid "Make this form publicly visible with direct link?"
     308#~ msgstr "Näytä lomake julkisesti suoralla linkillä?"
     309
     310#~ msgid "HTML form builder for WordPress"
     311#~ msgstr "HTML form builder for WordPress"
     312
    280313#~ msgid "referrer"
    281314#~ msgstr "lähde"
  • wp-libre-form/trunk/lang/wp-libre-form-nb_NO.po

    r1359097 r1522309  
    22msgstr ""
    33"Project-Id-Version: WP Libre Form\n"
    4 "POT-Creation-Date: 2016-02-21 23:16+0100\n"
    5 "PO-Revision-Date: 2016-02-22 15:12+0100\n"
     4"POT-Creation-Date: 2016-10-26 10:29+0100\n"
     5"PO-Revision-Date: 2016-10-26 10:29+0100\n"
    66"Last-Translator: Antti Kuosmanen <antti@seravo.fi>\n"
    77"Language-Team: Antti Kuosmanen <antti@seravo.fi>\n"
     
    1111"Content-Transfer-Encoding: 8bit\n"
    1212"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    13 "X-Generator: Poedit 1.8.6\n"
     13"X-Generator: Poedit 1.8.8\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"X-Poedit-WPHeader: wp-libre-form.php\n"
     
    2121"X-Poedit-SearchPathExcluded-0: *.js\n"
    2222
    23 #: classes/class-cpt-wplf-form.php:53
     23#: classes/class-cpt-wplf-form.php:56
    2424msgctxt "post type general name"
    2525msgid "Forms"
    2626msgstr "Skjemaer"
    2727
    28 #: classes/class-cpt-wplf-form.php:54
     28#: classes/class-cpt-wplf-form.php:57
    2929msgctxt "post type singular name"
    3030msgid "Form"
    3131msgstr "Skjema"
    3232
    33 #: classes/class-cpt-wplf-form.php:55
     33#: classes/class-cpt-wplf-form.php:58
    3434msgctxt "admin menu"
    3535msgid "Forms"
    3636msgstr "Skjemaer"
    3737
    38 #: classes/class-cpt-wplf-form.php:56
     38#: classes/class-cpt-wplf-form.php:59
    3939msgctxt "add new on admin bar"
    4040msgid "Form"
    4141msgstr "Skjema"
    4242
    43 #: classes/class-cpt-wplf-form.php:57
     43#: classes/class-cpt-wplf-form.php:60
    4444msgctxt "form"
    4545msgid "New Form"
    4646msgstr "nytt skjema"
    4747
    48 #: classes/class-cpt-wplf-form.php:58
     48#: classes/class-cpt-wplf-form.php:61
    4949msgid "Add New Form"
    5050msgstr "Lag nytt skjema"
    5151
    52 #: classes/class-cpt-wplf-form.php:59
     52#: classes/class-cpt-wplf-form.php:62
    5353msgid "New Form"
    5454msgstr "nytt skjema"
    5555
    56 #: classes/class-cpt-wplf-form.php:60
     56#: classes/class-cpt-wplf-form.php:63
    5757msgid "Edit Form"
    5858msgstr "Rediger skjema"
    5959
    60 #: classes/class-cpt-wplf-form.php:61
     60#: classes/class-cpt-wplf-form.php:64
    6161msgid "View Form"
    6262msgstr "Vis skjema"
    6363
    64 #: classes/class-cpt-wplf-form.php:62 classes/class-cpt-wplf-submission.php:121
     64#: classes/class-cpt-wplf-form.php:65 classes/class-cpt-wplf-submission.php:135
    6565msgid "All Forms"
    6666msgstr "Alle skjemaer"
    6767
    68 #: classes/class-cpt-wplf-form.php:63
     68#: classes/class-cpt-wplf-form.php:66
    6969msgid "Search Forms"
    7070msgstr "Søk etter skjema"
    7171
    72 #: classes/class-cpt-wplf-form.php:64
     72#: classes/class-cpt-wplf-form.php:67
    7373msgid "No forms found."
    7474msgstr "Ingen skjemaer funnet."
    7575
    76 #: classes/class-cpt-wplf-form.php:65
     76#: classes/class-cpt-wplf-form.php:68
    7777msgid "No forms found in Trash."
    7878msgstr "Ingen skjema ble funnet i papirkurven"
    7979
    80 #: classes/class-cpt-wplf-form.php:148
     80#: classes/class-cpt-wplf-form.php:105
     81msgid "Permalink is for preview purposes only."
     82msgstr ""
     83
     84#: classes/class-cpt-wplf-form.php:163
    8185msgid "Please enter your name"
    8286msgstr "Vennligst skriv inn ditt navn"
    8387
    84 #: classes/class-cpt-wplf-form.php:149
     88#: classes/class-cpt-wplf-form.php:164
    8589msgctxt "Default placeholder name"
    8690msgid "John Doe"
    8791msgstr "Ola Nordmann"
    8892
    89 #: classes/class-cpt-wplf-form.php:151
     93#: classes/class-cpt-wplf-form.php:166
    9094msgid "Please enter your email address"
    9195msgstr "Vennligst skriv inn din e-postadresse"
    9296
    93 #: classes/class-cpt-wplf-form.php:151 classes/class-cpt-wplf-form.php:154
     97#: classes/class-cpt-wplf-form.php:166 classes/class-cpt-wplf-form.php:169
    9498msgid "(required)"
    9599msgstr "(påkrevd)"
    96100
    97 #: classes/class-cpt-wplf-form.php:152
     101#: classes/class-cpt-wplf-form.php:167
    98102msgctxt "Default placeholder email"
    99103msgid "example@email.com"
    100104msgstr "eksempel@e-mail.no"
    101105
    102 #: classes/class-cpt-wplf-form.php:154
     106#: classes/class-cpt-wplf-form.php:169
    103107msgid "Write your message below"
    104108msgstr "Skriv din melding nedenfor"
    105109
    106 #: classes/class-cpt-wplf-form.php:155
     110#: classes/class-cpt-wplf-form.php:170
    107111msgctxt "Default placeholder message"
    108112msgid "I wanted to ask about..."
    109113msgstr "Jeg ønsket å spørre om ..."
    110114
    111 #: classes/class-cpt-wplf-form.php:157
     115#: classes/class-cpt-wplf-form.php:172
    112116msgid "Submit"
    113117msgstr "Send"
    114118
    115 #: classes/class-cpt-wplf-form.php:159
     119#: classes/class-cpt-wplf-form.php:174
    116120msgctxt "The HTML comment at the end of the example form"
    117121msgid "Any valid HTML form can be used here!"
    118122msgstr "Alle gyldig skjema med HTML kan brukes her!"
    119123
    120 #: classes/class-cpt-wplf-form.php:175 classes/class-cpt-wplf-form.php:212
     124#: classes/class-cpt-wplf-form.php:201 classes/class-cpt-wplf-form.php:240
    121125msgid "Shortcode"
    122126msgstr "Shortcode"
    123127
    124 #: classes/class-cpt-wplf-form.php:176 classes/class-cpt-wplf-submission.php:46
     128#: classes/class-cpt-wplf-form.php:202 classes/class-cpt-wplf-submission.php:46
    125129msgid "Submissions"
    126130msgstr "Svar"
    127131
    128 #: classes/class-cpt-wplf-form.php:222
     132#: classes/class-cpt-wplf-form.php:250
    129133msgid "Success Message"
    130134msgstr "Suksessmelding"
    131135
    132 #: classes/class-cpt-wplf-form.php:232
     136#: classes/class-cpt-wplf-form.php:260
    133137msgid "Form Fields Detected"
    134138msgstr "Skjemafelt oppdaget"
    135139
    136 #: classes/class-cpt-wplf-form.php:241
     140#: classes/class-cpt-wplf-form.php:269
    137141msgid "Emails"
    138142msgstr "E-post"
    139143
    140 #: classes/class-cpt-wplf-form.php:250
     144#: classes/class-cpt-wplf-form.php:278
    141145msgid "Submission Title Format"
    142146msgstr "Tittel på svar"
    143147
    144 #: classes/class-cpt-wplf-form.php:273
     148#: classes/class-cpt-wplf-form.php:301
    145149msgctxt "Default success message"
    146150msgid "Thank you! :)"
    147151msgstr "Tusen takk! :)"
    148152
    149 #: classes/class-cpt-wplf-form.php:294
     153#: classes/class-cpt-wplf-form.php:322
    150154msgid "Fields marked with * are required"
    151155msgstr "Feltene merket med * er obligatoriske"
    152156
    153 #: classes/class-cpt-wplf-form.php:315
     157#: classes/class-cpt-wplf-form.php:343
    154158msgid "Send an email copy when a form is submitted?"
    155159msgstr "Send en e-post når et skjema er sendt?"
    156160
    157 #: classes/class-cpt-wplf-form.php:331
     161#: classes/class-cpt-wplf-form.php:359
    158162msgid "Submissions from this form will use this formatting in their title."
    159163msgstr "Svar fra dette skjemaet vil bruke denne formateringen i tittelen."
    160164
    161 #: classes/class-cpt-wplf-form.php:332
     165#: classes/class-cpt-wplf-form.php:360
    162166msgid "You may use any field values enclosed in \"%\" markers."
    163167msgstr "Du kan bruke feltverdier i \"%\" markører."
     168
     169#: classes/class-cpt-wplf-form.php:487
     170msgid "This form preview URL is not public and cannot be shared."
     171msgstr ""
     172
     173#: classes/class-cpt-wplf-form.php:488
     174msgid "Non-logged in visitors will see a 404 error page instead."
     175msgstr ""
    164176
    165177#: classes/class-cpt-wplf-submission.php:37
     
    224236msgstr "Skjema"
    225237
    226 #: classes/class-cpt-wplf-submission.php:158
     238#: classes/class-cpt-wplf-submission.php:172
    227239msgid "Submission"
    228240msgstr "Svar"
    229241
    230 #: classes/class-cpt-wplf-submission.php:178
     242#: classes/class-cpt-wplf-submission.php:193
    231243msgid "Field"
    232244msgstr "Felt"
    233245
    234 #: classes/class-cpt-wplf-submission.php:179
     246#: classes/class-cpt-wplf-submission.php:194
    235247msgid "Value"
    236248msgstr "Verdi"
     
    264276
    265277#. Description of the plugin/theme
    266 msgid "HTML form builder for WordPress"
     278msgid "A minimal HTML form builder for WordPress; made for developers"
    267279msgstr ""
    268280
  • wp-libre-form/trunk/lang/wp-libre-form.pot

    r1359097 r1522309  
    44"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
    55"Project-Id-Version: WP Libre Form\n"
    6 "POT-Creation-Date: 2016-02-21 23:16+0100\n"
     6"POT-Creation-Date: 2016-10-26 10:29+0100\n"
    77"PO-Revision-Date: 2016-02-21 14:22+0100\n"
    88"Last-Translator: Antti Kuosmanen <antti@seravo.fi>\n"
     
    1111"Content-Type: text/plain; charset=UTF-8\n"
    1212"Content-Transfer-Encoding: 8bit\n"
    13 "X-Generator: Poedit 1.8.6\n"
     13"X-Generator: Poedit 1.8.8\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"X-Poedit-WPHeader: wp-libre-form.php\n"
     
    2121"X-Poedit-SearchPathExcluded-0: *.js\n"
    2222
    23 #: classes/class-cpt-wplf-form.php:53
     23#: classes/class-cpt-wplf-form.php:56
    2424msgctxt "post type general name"
    2525msgid "Forms"
    2626msgstr ""
    2727
    28 #: classes/class-cpt-wplf-form.php:54
     28#: classes/class-cpt-wplf-form.php:57
    2929msgctxt "post type singular name"
    3030msgid "Form"
    3131msgstr ""
    3232
    33 #: classes/class-cpt-wplf-form.php:55
     33#: classes/class-cpt-wplf-form.php:58
    3434msgctxt "admin menu"
    3535msgid "Forms"
    3636msgstr ""
    3737
    38 #: classes/class-cpt-wplf-form.php:56
     38#: classes/class-cpt-wplf-form.php:59
    3939msgctxt "add new on admin bar"
    4040msgid "Form"
    4141msgstr ""
    4242
    43 #: classes/class-cpt-wplf-form.php:57
     43#: classes/class-cpt-wplf-form.php:60
    4444msgctxt "form"
    4545msgid "New Form"
    4646msgstr ""
    4747
    48 #: classes/class-cpt-wplf-form.php:58
     48#: classes/class-cpt-wplf-form.php:61
    4949msgid "Add New Form"
    5050msgstr ""
    5151
    52 #: classes/class-cpt-wplf-form.php:59
     52#: classes/class-cpt-wplf-form.php:62
    5353msgid "New Form"
    5454msgstr ""
    5555
    56 #: classes/class-cpt-wplf-form.php:60
     56#: classes/class-cpt-wplf-form.php:63
    5757msgid "Edit Form"
    5858msgstr ""
    5959
    60 #: classes/class-cpt-wplf-form.php:61
     60#: classes/class-cpt-wplf-form.php:64
    6161msgid "View Form"
    6262msgstr ""
    6363
    64 #: classes/class-cpt-wplf-form.php:62
    65 #: classes/class-cpt-wplf-submission.php:121
     64#: classes/class-cpt-wplf-form.php:65
     65#: classes/class-cpt-wplf-submission.php:135
    6666msgid "All Forms"
    6767msgstr ""
    6868
    69 #: classes/class-cpt-wplf-form.php:63
     69#: classes/class-cpt-wplf-form.php:66
    7070msgid "Search Forms"
    7171msgstr ""
    7272
    73 #: classes/class-cpt-wplf-form.php:64
     73#: classes/class-cpt-wplf-form.php:67
    7474msgid "No forms found."
    7575msgstr ""
    7676
    77 #: classes/class-cpt-wplf-form.php:65
     77#: classes/class-cpt-wplf-form.php:68
    7878msgid "No forms found in Trash."
    7979msgstr ""
    8080
    81 #: classes/class-cpt-wplf-form.php:148
     81#: classes/class-cpt-wplf-form.php:105
     82msgid "Permalink is for preview purposes only."
     83msgstr ""
     84
     85#: classes/class-cpt-wplf-form.php:163
    8286msgid "Please enter your name"
    8387msgstr ""
    8488
    85 #: classes/class-cpt-wplf-form.php:149
     89#: classes/class-cpt-wplf-form.php:164
    8690msgctxt "Default placeholder name"
    8791msgid "John Doe"
    8892msgstr ""
    8993
    90 #: classes/class-cpt-wplf-form.php:151
     94#: classes/class-cpt-wplf-form.php:166
    9195msgid "Please enter your email address"
    9296msgstr ""
    9397
    94 #: classes/class-cpt-wplf-form.php:151 classes/class-cpt-wplf-form.php:154
     98#: classes/class-cpt-wplf-form.php:166 classes/class-cpt-wplf-form.php:169
    9599msgid "(required)"
    96100msgstr ""
    97101
    98 #: classes/class-cpt-wplf-form.php:152
     102#: classes/class-cpt-wplf-form.php:167
    99103msgctxt "Default placeholder email"
    100104msgid "example@email.com"
    101105msgstr ""
    102106
    103 #: classes/class-cpt-wplf-form.php:154
     107#: classes/class-cpt-wplf-form.php:169
    104108msgid "Write your message below"
    105109msgstr ""
    106110
    107 #: classes/class-cpt-wplf-form.php:155
     111#: classes/class-cpt-wplf-form.php:170
    108112msgctxt "Default placeholder message"
    109113msgid "I wanted to ask about..."
    110114msgstr ""
    111115
    112 #: classes/class-cpt-wplf-form.php:157
     116#: classes/class-cpt-wplf-form.php:172
    113117msgid "Submit"
    114118msgstr ""
    115119
    116 #: classes/class-cpt-wplf-form.php:159
     120#: classes/class-cpt-wplf-form.php:174
    117121msgctxt "The HTML comment at the end of the example form"
    118122msgid "Any valid HTML form can be used here!"
    119123msgstr ""
    120124
    121 #: classes/class-cpt-wplf-form.php:175 classes/class-cpt-wplf-form.php:212
     125#: classes/class-cpt-wplf-form.php:201 classes/class-cpt-wplf-form.php:240
    122126msgid "Shortcode"
    123127msgstr ""
    124128
    125 #: classes/class-cpt-wplf-form.php:176
     129#: classes/class-cpt-wplf-form.php:202
    126130#: classes/class-cpt-wplf-submission.php:46
    127131msgid "Submissions"
    128132msgstr ""
    129133
    130 #: classes/class-cpt-wplf-form.php:222
     134#: classes/class-cpt-wplf-form.php:250
    131135msgid "Success Message"
    132136msgstr ""
    133137
    134 #: classes/class-cpt-wplf-form.php:232
     138#: classes/class-cpt-wplf-form.php:260
    135139msgid "Form Fields Detected"
    136140msgstr ""
    137141
    138 #: classes/class-cpt-wplf-form.php:241
     142#: classes/class-cpt-wplf-form.php:269
    139143msgid "Emails"
    140144msgstr ""
    141145
    142 #: classes/class-cpt-wplf-form.php:250
     146#: classes/class-cpt-wplf-form.php:278
    143147msgid "Submission Title Format"
    144148msgstr ""
    145149
    146 #: classes/class-cpt-wplf-form.php:273
     150#: classes/class-cpt-wplf-form.php:301
    147151msgctxt "Default success message"
    148152msgid "Thank you! :)"
    149153msgstr ""
    150154
    151 #: classes/class-cpt-wplf-form.php:294
     155#: classes/class-cpt-wplf-form.php:322
    152156msgid "Fields marked with * are required"
    153157msgstr ""
    154158
    155 #: classes/class-cpt-wplf-form.php:315
     159#: classes/class-cpt-wplf-form.php:343
    156160msgid "Send an email copy when a form is submitted?"
    157161msgstr ""
    158162
    159 #: classes/class-cpt-wplf-form.php:331
     163#: classes/class-cpt-wplf-form.php:359
    160164msgid "Submissions from this form will use this formatting in their title."
    161165msgstr ""
    162166
    163 #: classes/class-cpt-wplf-form.php:332
     167#: classes/class-cpt-wplf-form.php:360
    164168msgid "You may use any field values enclosed in \"%\" markers."
     169msgstr ""
     170
     171#: classes/class-cpt-wplf-form.php:487
     172msgid "This form preview URL is not public and cannot be shared."
     173msgstr ""
     174
     175#: classes/class-cpt-wplf-form.php:488
     176msgid "Non-logged in visitors will see a 404 error page instead."
    165177msgstr ""
    166178
     
    226238msgstr ""
    227239
    228 #: classes/class-cpt-wplf-submission.php:158
     240#: classes/class-cpt-wplf-submission.php:172
    229241msgid "Submission"
    230242msgstr ""
    231243
    232 #: classes/class-cpt-wplf-submission.php:178
     244#: classes/class-cpt-wplf-submission.php:193
    233245msgid "Field"
    234246msgstr ""
    235247
    236 #: classes/class-cpt-wplf-submission.php:179
     248#: classes/class-cpt-wplf-submission.php:194
    237249msgid "Value"
    238250msgstr ""
     
    266278
    267279#. Description of the plugin/theme
    268 msgid "HTML form builder for WordPress"
     280msgid "A minimal HTML form builder for WordPress; made for developers"
    269281msgstr ""
    270282
  • wp-libre-form/trunk/readme.md

    r1450731 r1522309  
    9090```
    9191
    92 ### Add own css classes to form output
     92### Client side callbacks
    9393
    94 You can use the attribute xclass inside the shortcode to set own extra css classes.
     94WP Libre Form supports client side callbacks after form submission using window.wplf object. Example usage:
     95
     96```
     97window.wplf.successCallbacks.push(function(response){
     98  alert("You succesfully submitted form " + response.form_id);
     99});
     100
     101window.wplf.errorCallbacks.push(function(response){
     102  alert("Form submission failed!");
     103});
     104```
     105
     106These callbacks are executed in the order they appear.
     107
     108### Add CSS classes to form output
     109
     110You can use the xclass attribute inside the shortcode to add your own extra classes.
    95111
    96112```
     
    124140}
    125141```
     142
     143### wplf_validate_submission example: Google ReCaptcha integration
     144
     145```php
     146/**
     147 * ReCaptcha for WP Libre Form
     148 */
     149add_filter( 'wplf_validate_submission', 'wplf_recaptcha' );
     150function wplf_recaptcha( $return ) {
     151  // skip this validation if submission has already failed
     152  if( ! $return->ok ) {
     153    return $return;
     154  }
     155
     156  $form = get_post( (int) $_POST['_form_id'] );
     157  if( false === strpos( $form->post_content, 'g-recaptcha' ) ) {
     158    // this form doesn't have recaptcha
     159    return $return;
     160  }
     161
     162  $secret = 'XXXX'; // substitute with your own secret recaptcha key
     163
     164  $options = [
     165    'http' => [
     166      'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
     167      'method'  => 'POST',
     168      'content' => http_build_query([
     169        'secret' => $secret,
     170        'response' => $_POST['g-recaptcha-response'],
     171      ])
     172    ],
     173  ];
     174  $context  = stream_context_create( $options );
     175  $result = file_get_contents( 'https://www.google.com/recaptcha/api/siteverify', false, $context );
     176
     177  $captcha_obj = json_decode( $result );
     178
     179  if( false === $captcha_obj->success ) {
     180    $return->ok = 0;
     181    $return->error = sprintf( __("Please prove you're not a robot before submitting."), intval( $_POST['_form_id'] ) );
     182  }
     183
     184  return $return;
     185}
     186```
  • wp-libre-form/trunk/readme.txt

    r1450731 r1522309  
    44Donate link: https://github.com/anttiviljami
    55Requires at least: 4.2
    6 Tested up to: 4.4.4
    7 Stable tag: 1.0.2
     6Tested up to: 4.6.1
     7Stable tag: 1.1
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
  • wp-libre-form/trunk/wp-libre-form.php

    r1450731 r1522309  
    44 * Plugin URI: https://github.com/anttiviljami/wp-libre-form
    55 * Description: A minimal HTML form builder for WordPress; made for developers
    6  * Version: 1.0.2
     6 * Version: 1.1
    77 * Author: @anttiviljami
    88 * Author URI: https://github.com/anttiviljami/
     
    3131
    3232if ( ! class_exists( 'WP_Libre_Form' ) ) :
     33
     34define( 'WPLF_VERSION', '1.1' );
    3335
    3436class WP_Libre_Form {
     
    7577   */
    7678  public static function load_our_textdomain() {
    77     load_plugin_textdomain( 'wp-libre-form', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
     79    $loaded = load_plugin_textdomain( 'wp-libre-form', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
     80
     81    if( !$loaded ) {
     82      $loaded = load_muplugin_textdomain( 'wp-libre-form', dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
     83    }
    7884  }
    7985
Note: See TracChangeset for help on using the changeset viewer.