Custom Contact Forms - Version 6.6

Version Description

  • Update WP-API to 1.2 (still have header method hack)
  • Form CSV download
Download this release

Release Info

Developer tlovett1
Plugin Icon 128x128 Custom Contact Forms
Version 6.6
Comparing to
See all releases

Code changes from version 6.5.1 to 6.6

README.md CHANGED
@@ -160,6 +160,13 @@ Scroll to the `Submissions` meta box. Click one the eye icon to view more inform
160
  In the `Submissions` meta box, you can add and remove columns. Click the cog icon at the top of the meta box to open
161
  the screen options panel. In this panel you can check which columns you would like to see in the table.
162
 
 
 
 
 
 
 
 
163
  ### Import/Export
164
 
165
  Custom Contact Forms allows you to import and export forms and form submissions using the default WordPress
160
  In the `Submissions` meta box, you can add and remove columns. Click the cog icon at the top of the meta box to open
161
  the screen options panel. In this panel you can check which columns you would like to see in the table.
162
 
163
+ #### Download Form Submissions as CSV
164
+
165
+ In addition to being able to import/export forms with all fields and submissions, you can export submissions for
166
+ individual forms as .CSV files. Click the icon within the form edit view like so:
167
+
168
+ ![Export Submissions as .CSV Files](https://tlovett1.files.wordpress.com/2015/03/submissions-csv.png)
169
+
170
  ### Import/Export
171
 
172
  Custom Contact Forms allows you to import and export forms and form submissions using the default WordPress
build/css/form-cpt.css CHANGED
@@ -78,7 +78,7 @@
78
  line-height: 1;
79
  cursor: pointer;
80
  -webkit-font-smoothing: antialiased; }
81
- #ccf-submissions .ccf-submission-settings {
82
  font: normal 20px/1;
83
  speak: none;
84
  display: inline-block;
@@ -88,7 +88,8 @@
88
  float: right;
89
  width: 23px;
90
  height: 30px;
91
- cursor: pointer; }
 
92
  #ccf-submissions .inside {
93
  padding: 0;
94
  margin: 0; }
78
  line-height: 1;
79
  cursor: pointer;
80
  -webkit-font-smoothing: antialiased; }
81
+ #ccf-submissions .ccf-submission-icon {
82
  font: normal 20px/1;
83
  speak: none;
84
  display: inline-block;
88
  float: right;
89
  width: 23px;
90
  height: 30px;
91
+ cursor: pointer;
92
+ color: inherit; }
93
  #ccf-submissions .inside {
94
  padding: 0;
95
  margin: 0; }
build/css/form-cpt.css.map CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "version": 3,
3
- "mappings": "AAAA,SAAU;EACT,OAAO,EAAE,IAAI;;AAGd,UAAW;EACV,OAAO,EAAE,IAAI;;AAGd,kBAAmB;EAClB,OAAO,EAAE,IAAI;;AAIb,aAAG;EACF,MAAM,EAAE,CAAC;EAET,qBAAQ;IACP,cAAc,EAAE,MAAM;IACtB,GAAG,EAAE,IAAI;IACT,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,GAAG;;AAKnB,yCAA0C;EACzC,OAAO,EAAE,IAAI;;AAGd,WAAY;EACX,OAAO,EAAE,IAAI;;AAIb,wBAAQ;EACP,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EAEV,8BAAM;IACL,OAAO,EAAE,KAAK;EAGf,kCAAU;IACT,OAAO,EAAE,KAAK;IAEd,yCAAS;MACR,IAAI,EAAE,yBAAyB;MAC/B,KAAK,EAAE,IAAI;MACX,OAAO,EAAE,YAAY;MACrB,OAAO,EAAE,SAAS;MAClB,IAAI,EAAE,IAAI;MACV,QAAQ,EAAE,QAAQ;MAClB,cAAc,EAAE,GAAG;MACnB,sBAAsB,EAAE,WAAW;MACnC,uBAAuB,EAAE,SAAS;MAClC,eAAe,EAAE,eAAe;MAChC,GAAG,EAAE,IAAI;MACT,KAAK,EAAE,IAAI;EAIb,+CAAuB;IACtB,OAAO,EAAE,OAAO;EAGjB,mDAA2B;IAC1B,OAAO,EAAE,OAAO;EAGjB,8CAAsB;IACrB,OAAO,EAAE,OAAO;EAGjB,kDAA0B;IACzB,QAAQ,EAAE,IAAI;IAEd,gEAAc;MACb,KAAK,EAAE,IAAI;MACX,eAAe,EAAE,IAAI;MACrB,OAAO,EAAE,OAAO;IAGjB,iEAAe;MACd,KAAK,EAAE,KAAK;;AAOf,uCAAkB;EACjB,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EACV,gBAAgB,EAAE,OAAO;AAG1B,8BAAS;EACR,OAAO,EAAE,KAAK;EACd,KAAK,EAAE,IAAI;;AAKZ,0CAAS;EACR,OAAO,EAAE,KAAK;EACd,KAAK,EAAE,IAAI;;AAKZ,mCAAmB;EAClB,WAAW,EAAE,cAAc;EAC3B,OAAO,EAAE,eAAe;EACxB,KAAK,EAAE,IAAI;EACX,WAAW,EAAE,MAAM;EACnB,YAAY,EAAE,MAAM;EACpB,cAAc,EAAE,IAAI;EACpB,WAAW,EAAE,CAAC;EACd,MAAM,EAAE,OAAO;EACf,sBAAsB,EAAE,WAAW;AAGpC,yCAAyB;EACxB,IAAI,EAAE,aAAa;EACnB,KAAK,EAAE,IAAI;EACX,OAAO,EAAE,YAAY;EACrB,OAAO,EAAE,iBAAiB;EAC1B,GAAG,EAAE,CAAC;EACN,QAAQ,EAAE,QAAQ;EAClB,KAAK,EAAE,KAAK;EACZ,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,MAAM,EAAE,OAAO;AAGhB,wBAAQ;EACP,OAAO,EAAE,CAAC;EACV,MAAM,EAAE,CAAC;EAIT,8BAAM;IACL,MAAM,EAAE,CAAC;IACT,eAAe,EAAE,QAAQ;IACzB,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE,IAAI;IAEX,oEAAO;MACN,OAAO,EAAE,QAAQ;IAGlB,uCAAS;MACR,MAAM,EAAE,CAAC;IAIT,uCAAG;MACF,gBAAgB,EAAE,OAAO;MAEzB,0CAAG;QACF,KAAK,EAAE,IAAI;MAGZ,gDAAS;QACR,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,KAAK;MAGf,gDAAS;QACR,UAAU,EAAE,KAAK;QAEjB,kDAAE;UACD,MAAM,EAAE,OAAO;UACf,KAAK,EAAE,OAAO;UACd,YAAY,EAAE,GAAG;MAInB,2DAAoB;QACnB,OAAO,EAAE,IAAI;MAGd,uDAAkB;QACjB,gBAAgB,EAAE,IAAI;MAGvB,yDAAkB;QACjB,UAAU,EAAE,MAAM;QAClB,KAAK,EAAE,IAAI;QACX,cAAc,EAAE,GAAG;EAMvB,wCAAgB;IACf,UAAU,EAAE,cAAc;IAC1B,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,GAAG;;AAMd,mCAAY;EACX,WAAW,EAAE,IAAI;EACjB,SAAS,EAAE,IAAI;EACf,OAAO,EAAE,GAAG;AAGb,sCAAe;EACd,OAAO,EAAE,GAAG;EACZ,gBAAgB,EAAE,OAAO;EAEzB,2CAAK;IACJ,UAAU,EAAE,MAAM",
4
  "sources": ["../../scss/form-cpt.scss"],
5
  "names": [],
6
  "file": "form-cpt.css"
1
  {
2
  "version": 3,
3
+ "mappings": "AAAA,SAAU;EACT,OAAO,EAAE,IAAI;;AAGd,UAAW;EACV,OAAO,EAAE,IAAI;;AAGd,kBAAmB;EAClB,OAAO,EAAE,IAAI;;AAIb,aAAG;EACF,MAAM,EAAE,CAAC;EAET,qBAAQ;IACP,cAAc,EAAE,MAAM;IACtB,GAAG,EAAE,IAAI;IACT,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,GAAG;;AAKnB,yCAA0C;EACzC,OAAO,EAAE,IAAI;;AAGd,WAAY;EACX,OAAO,EAAE,IAAI;;AAIb,wBAAQ;EACP,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EAEV,8BAAM;IACL,OAAO,EAAE,KAAK;EAGf,kCAAU;IACT,OAAO,EAAE,KAAK;IAEd,yCAAS;MACR,IAAI,EAAE,yBAAyB;MAC/B,KAAK,EAAE,IAAI;MACX,OAAO,EAAE,YAAY;MACrB,OAAO,EAAE,SAAS;MAClB,IAAI,EAAE,IAAI;MACV,QAAQ,EAAE,QAAQ;MAClB,cAAc,EAAE,GAAG;MACnB,sBAAsB,EAAE,WAAW;MACnC,uBAAuB,EAAE,SAAS;MAClC,eAAe,EAAE,eAAe;MAChC,GAAG,EAAE,IAAI;MACT,KAAK,EAAE,IAAI;EAIb,+CAAuB;IACtB,OAAO,EAAE,OAAO;EAGjB,mDAA2B;IAC1B,OAAO,EAAE,OAAO;EAGjB,8CAAsB;IACrB,OAAO,EAAE,OAAO;EAGjB,kDAA0B;IACzB,QAAQ,EAAE,IAAI;IAEd,gEAAc;MACb,KAAK,EAAE,IAAI;MACX,eAAe,EAAE,IAAI;MACrB,OAAO,EAAE,OAAO;IAGjB,iEAAe;MACd,KAAK,EAAE,KAAK;;AAOf,uCAAkB;EACjB,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EACV,gBAAgB,EAAE,OAAO;AAG1B,8BAAS;EACR,OAAO,EAAE,KAAK;EACd,KAAK,EAAE,IAAI;;AAKZ,0CAAS;EACR,OAAO,EAAE,KAAK;EACd,KAAK,EAAE,IAAI;;AAKZ,mCAAmB;EAClB,WAAW,EAAE,cAAc;EAC3B,OAAO,EAAE,eAAe;EACxB,KAAK,EAAE,IAAI;EACX,WAAW,EAAE,MAAM;EACnB,YAAY,EAAE,MAAM;EACpB,cAAc,EAAE,IAAI;EACpB,WAAW,EAAE,CAAC;EACd,MAAM,EAAE,OAAO;EACf,sBAAsB,EAAE,WAAW;AAGpC,qCAAqB;EACpB,IAAI,EAAE,aAAa;EACnB,KAAK,EAAE,IAAI;EACX,OAAO,EAAE,YAAY;EACrB,OAAO,EAAE,iBAAiB;EAC1B,GAAG,EAAE,CAAC;EACN,QAAQ,EAAE,QAAQ;EAClB,KAAK,EAAE,KAAK;EACZ,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,MAAM,EAAE,OAAO;EACf,KAAK,EAAE,OAAO;AAGf,wBAAQ;EACP,OAAO,EAAE,CAAC;EACV,MAAM,EAAE,CAAC;EAIT,8BAAM;IACL,MAAM,EAAE,CAAC;IACT,eAAe,EAAE,QAAQ;IACzB,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE,IAAI;IAEX,oEAAO;MACN,OAAO,EAAE,QAAQ;IAGlB,uCAAS;MACR,MAAM,EAAE,CAAC;IAIT,uCAAG;MACF,gBAAgB,EAAE,OAAO;MAEzB,0CAAG;QACF,KAAK,EAAE,IAAI;MAGZ,gDAAS;QACR,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,KAAK;MAGf,gDAAS;QACR,UAAU,EAAE,KAAK;QAEjB,kDAAE;UACD,MAAM,EAAE,OAAO;UACf,KAAK,EAAE,OAAO;UACd,YAAY,EAAE,GAAG;MAInB,2DAAoB;QACnB,OAAO,EAAE,IAAI;MAGd,uDAAkB;QACjB,gBAAgB,EAAE,IAAI;MAGvB,yDAAkB;QACjB,UAAU,EAAE,MAAM;QAClB,KAAK,EAAE,IAAI;QACX,cAAc,EAAE,GAAG;EAMvB,wCAAgB;IACf,UAAU,EAAE,cAAc;IAC1B,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,GAAG;;AAMd,mCAAY;EACX,WAAW,EAAE,IAAI;EACjB,SAAS,EAAE,IAAI;EACf,OAAO,EAAE,GAAG;AAGb,sCAAe;EACd,OAAO,EAAE,GAAG;EACZ,gBAAgB,EAAE,OAAO;EAEzB,2CAAK;IACJ,UAAU,EAAE,MAAM",
4
  "sources": ["../../scss/form-cpt.scss"],
5
  "names": [],
6
  "file": "form-cpt.css"
build/css/form-cpt.min.css CHANGED
@@ -1 +1 @@
1
- #submitdiv,#titlediv,#wp-admin-bar-view{display:none}.ccf-title h1{margin:0}.ccf-title h1 .button{vertical-align:middle;top:-2px;position:relative;margin-left:8px}#post-body-content .ccf-open-form-manager,.add-new-h2{display:none}#ccf-at-a-glance .inside{margin:0;padding:0}#ccf-at-a-glance .inside .has-icon,#ccf-at-a-glance .inside .line{display:block}#ccf-at-a-glance .inside .has-icon:before{font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 5px 0 0;left:-1px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;top:-1px;color:#888}#ccf-at-a-glance .inside #ccf-created-by:before{content:"\f110"}#ccf-at-a-glance .inside #ccf-submission-num:before{content:"\f226"}#ccf-at-a-glance .inside #ccf-field-num:before{content:"\f175"}#ccf-at-a-glance .inside #major-publishing-actions{overflow:auto}#ccf-at-a-glance .inside #major-publishing-actions .submitdelete{color:#a00;text-decoration:none;padding:1px 2px}#ccf-at-a-glance .inside #major-publishing-actions .export-button{float:right}.ccf-form-cpt-preview .ccf-form-preview{border:0;padding:0;background-color:inherit}.ccf-form-cpt-preview .spinner,.ccf-submission-column-controller .spinner{display:block;float:none}#ccf-submissions [data-icon]:before{font-family:form-manager;content:attr(data-icon);speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;cursor:pointer;-webkit-font-smoothing:antialiased}#ccf-submissions .ccf-submission-settings{font:400 20px/1;speak:none;display:inline-block;padding:12px 0 4px 10px;top:0;position:relative;float:right;width:23px;height:30px;cursor:pointer}#ccf-submissions .inside{padding:0;margin:0}#ccf-submissions .inside table{border:0;border-collapse:collapse;table-layout:auto;width:100%}#ccf-submissions .inside table td,#ccf-submissions .inside table th{padding:8px 10px}#ccf-submissions .inside table th input{margin:0}#ccf-submissions .inside table tbody tr{background-color:#f9f9f9}#ccf-submissions .inside table tbody tr td{width:auto}#ccf-submissions .inside table tbody tr .spinner{float:none;display:block}#ccf-submissions .inside table tbody tr .actions{text-align:right}#ccf-submissions .inside table tbody tr .actions a{cursor:pointer;color:inherit;padding-left:4px}#ccf-submissions .inside table tbody tr .submission-wrapper{display:none}#ccf-submissions .inside table tbody tr:nth-child(2n-1){background-color:#fff}#ccf-submissions .inside table tbody tr td.no-submissions{text-align:center;width:auto;padding-bottom:8px}#ccf-submissions .inside .ccf-pagination{border-top:1px solid #eee;margin-top:0;padding:8px}.ccf-submission-content .field-slug{font-weight:700;font-size:15px;padding:7px}.ccf-submission-content .field-content{padding:7px;background-color:#f9f9f9}.ccf-submission-content .field-content span{font-style:italic}
1
+ #submitdiv,#titlediv,#wp-admin-bar-view{display:none}.ccf-title h1{margin:0}.ccf-title h1 .button{vertical-align:middle;top:-2px;position:relative;margin-left:8px}#post-body-content .ccf-open-form-manager,.add-new-h2{display:none}#ccf-at-a-glance .inside{margin:0;padding:0}#ccf-at-a-glance .inside .has-icon,#ccf-at-a-glance .inside .line{display:block}#ccf-at-a-glance .inside .has-icon:before{font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 5px 0 0;left:-1px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;top:-1px;color:#888}#ccf-at-a-glance .inside #ccf-created-by:before{content:"\f110"}#ccf-at-a-glance .inside #ccf-submission-num:before{content:"\f226"}#ccf-at-a-glance .inside #ccf-field-num:before{content:"\f175"}#ccf-at-a-glance .inside #major-publishing-actions{overflow:auto}#ccf-at-a-glance .inside #major-publishing-actions .submitdelete{color:#a00;text-decoration:none;padding:1px 2px}#ccf-at-a-glance .inside #major-publishing-actions .export-button{float:right}.ccf-form-cpt-preview .ccf-form-preview{border:0;padding:0;background-color:inherit}.ccf-form-cpt-preview .spinner,.ccf-submission-column-controller .spinner{display:block;float:none}#ccf-submissions [data-icon]:before{font-family:form-manager;content:attr(data-icon);speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;cursor:pointer;-webkit-font-smoothing:antialiased}#ccf-submissions .ccf-submission-icon{font:400 20px/1;speak:none;display:inline-block;padding:12px 0 4px 10px;top:0;position:relative;float:right;width:23px;height:30px;cursor:pointer;color:inherit}#ccf-submissions .inside{padding:0;margin:0}#ccf-submissions .inside table{border:0;border-collapse:collapse;table-layout:auto;width:100%}#ccf-submissions .inside table td,#ccf-submissions .inside table th{padding:8px 10px}#ccf-submissions .inside table th input{margin:0}#ccf-submissions .inside table tbody tr{background-color:#f9f9f9}#ccf-submissions .inside table tbody tr td{width:auto}#ccf-submissions .inside table tbody tr .spinner{float:none;display:block}#ccf-submissions .inside table tbody tr .actions{text-align:right}#ccf-submissions .inside table tbody tr .actions a{cursor:pointer;color:inherit;padding-left:4px}#ccf-submissions .inside table tbody tr .submission-wrapper{display:none}#ccf-submissions .inside table tbody tr:nth-child(2n-1){background-color:#fff}#ccf-submissions .inside table tbody tr td.no-submissions{text-align:center;width:auto;padding-bottom:8px}#ccf-submissions .inside .ccf-pagination{border-top:1px solid #eee;margin-top:0;padding:8px}.ccf-submission-content .field-slug{font-weight:700;font-size:15px;padding:7px}.ccf-submission-content .field-content{padding:7px;background-color:#f9f9f9}.ccf-submission-content .field-content span{font-style:italic}
build/js/form-manager.js CHANGED
@@ -2881,15 +2881,21 @@
2881
  var container = metabox.querySelectorAll( '.inside' )[0];
2882
 
2883
  var settings = document.createElement( 'div' );
2884
- settings.className = 'ccf-submission-settings';
2885
  settings.setAttribute( 'data-icon', '' );
2886
 
 
 
 
 
 
2887
  var screenOptionsLink = document.getElementById( 'show-settings-link' );
2888
  settings.onclick = function() {
2889
  screenOptionsLink.click();
2890
  };
2891
 
2892
  metabox.insertBefore( settings, metabox.firstChild.nextSibling.nextSibling );
 
2893
 
2894
  wp.ccf.createSubmissionsTable( container );
2895
  }
2881
  var container = metabox.querySelectorAll( '.inside' )[0];
2882
 
2883
  var settings = document.createElement( 'div' );
2884
+ settings.className = 'ccf-submission-icon';
2885
  settings.setAttribute( 'data-icon', '' );
2886
 
2887
+ var download = document.createElement( 'a' );
2888
+ download.href = '?action=edit&post=' + parseInt( ccfSettings.postId ) + '&download_submissions=1&download_submissions_nonce=' + ccfSettings.downloadSubmissionsNonce;
2889
+ download.className = 'ccf-submission-icon';
2890
+ download.setAttribute( 'data-icon', '' );
2891
+
2892
  var screenOptionsLink = document.getElementById( 'show-settings-link' );
2893
  settings.onclick = function() {
2894
  screenOptionsLink.click();
2895
  };
2896
 
2897
  metabox.insertBefore( settings, metabox.firstChild.nextSibling.nextSibling );
2898
+ metabox.insertBefore( download, metabox.firstChild.nextSibling.nextSibling );
2899
 
2900
  wp.ccf.createSubmissionsTable( container );
2901
  }
build/js/form-manager.min.js CHANGED
@@ -1,2 +1,2 @@
1
  (function(e,t,i,l){"use strict";window.wp=window.wp||{},wp.ccf=wp.ccf||{},wp.ccf.utils=wp.ccf.utils||{},wp.ccf.utils.cleanDateFields=function(e){delete e.date,delete e.date_gmt,delete e.modified,delete e.modified_gmt,delete e.date_tz,delete e.modified_tz},wp.ccf.utils.template=i.memoize(function(e){var t={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g};return i.template(document.getElementById(e).innerHTML,null,t)}),wp.ccf.utils.insertFormShortcode=function(e){var t=wp.ccf.forms.findWhere({ID:e.get("ID")});t||wp.ccf.forms.add(e);var i=tinymce.get(wpActiveEditor),l='[ccf_form id="'+e.get("ID")+'"]';i&&!i.isHidden()?tinymce.activeEditor.execCommand("mceInsertContent",!1,l):document.getElementById(wpActiveEditor).value+=l},wp.ccf.utils.getPrettyPostDate=function(e){return e=moment.utc(e),l.gmtOffset&&(e=e.utcOffset(60*parseInt(l.gmtOffset))),e.format("h:mm a M/D/YYYY")},wp.ccf.utils.wordChop=function(e,t){var i=e.substr(0,t);return i.substr(0,Math.min(i.length,i.lastIndexOf(" "))),i.length<e.length&&(i+="..."),i},wp.ccf.utils.isFieldDate=function(e){return e.date!==void 0||e.hour!==void 0&&e.minute!==void 0&&e["am-pm"]!==void 0?!0:!1},wp.ccf.utils.isFieldName=function(e){return e.name!==void 0||e.last!==void 0?!0:!1},wp.ccf.utils.isFieldEmailConfirm=function(e){return e.email!==void 0||e.confirm!==void 0?!0:!1},wp.ccf.utils.isFieldAddress=function(e){return e.street!==void 0&&e.city!==void 0&&e.zipcode!==void 0&&e.line_two!==void 0?!0:!1},wp.ccf.utils.isFieldFile=function(e){return e.id!==void 0&&e.url!==void 0&&e.file_name!==void 0?!0:!1},wp.ccf.utils.getPrettyFieldEmailConfirm=function(e){return e.email?e.email:e.confirm?e.confirm:"-"},wp.ccf.utils.getPrettyFieldDate=function(e){var t="",i="";if(e.hour&&e.minute&&e["am-pm"]&&(t+=e.hour+":"+e.minute+" "+e["am-pm"]),e.date&&(t+=" "+e.date),!t)return"-";var s=moment.utc(t);return s.isValid()?(e.hour&&e.minute&&e["am-pm"]&&(i+=s.format("h:mm a")),e.date&&(i&&(i+=" "),i+=s.format("M/D/YYYY")),i):l.invalidDate},wp.ccf.utils.getPrettyFieldName=function(e){var t=e.first;return t.length>0&&(t+=" "),e.last&&(t+=e.last),t||(t="-"),t},wp.ccf.utils.getPrettyFieldAddress=function(e){if(!e.street||!e.city)return"-";var t=e.street;return e.line_two&&(t+=" "+e.line_two),t+=", "+e.city,e.state&&(t+=", "+e.state),e.zipcode&&(t+=" "+e.zipcode),e.country&&(t+=" "+e.country),t}})(jQuery,Backbone,_,ccfSettings),function(e,t,i){"use strict";wp.ccf.mixins=wp.ccf.mixins||{},wp.ccf.mixins.subViewable=wp.ccf.mixins.subViewable||{subViews:{},initRenderSubViews:function(e,t,l){this.renderedSubViews||(this.renderedSubViews={});for(var s in this.subViews){var c={el:this.$el.find(".ccf-"+s),parent:this};l&&i.extend(c,l),this.renderedSubViews[s]&&this.renderedSubViews[s].destroy&&this.renderedSubViews[s].destroy(),(t||!this.renderedSubViews[s])&&(this.renderedSubViews[s]=new this.subViews[s](c)),this.renderedSubViews[s].render(),e&&(this.renderedSubViews[s].el.style.display="block")}return this},showView:function(e,t,i){if(this.renderedSubViews!==void 0&&this.renderedSubViews[e]!==void 0){var l=this.renderedSubViews[e];i||l.render(t),l.el.style.display="block",this.currentView=e;for(var s in this.subViews)s!==e&&(this.renderedSubViews[s].el.style.display="none")}}}}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l,s){"use strict";wp.ccf.models=wp.ccf.models||{},wp.ccf.models.Fields=wp.ccf.models.Fields||{};var c=function(e,i,l){return"object"!=typeof i&&""===i&&(i=""),t.Model.prototype.set.call(this,e,i,l)},r=function(e,t,i){return i=i||{},i.emulateHTTP=!0,this.constructor.__super__.sync.call(this,e,t,i)},n=function(e){for(var t in this.attributes)if(-1===i.indexOf(e,t)){var l=this.get(t);"string"==typeof l&&""!==l&&(l=(l+"").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#8220;/g,"”").replace(/&#8221;/g,"”").replace(/&#8216;/g,"‘").replace(/&#038;/g,"&").replace(/&#039;/g,"'"),this.set(t,l))}return this};wp.ccf.models.FieldChoice=wp.ccf.models.FieldChoice||t.Model.extend({defaults:{label:"",value:"",selected:!1},decode:function(){return n.call(this,[])},set:c}),wp.ccf.models.Form=wp.ccf.models.Form||wp.api.models.Post.extend({urlRoot:s.root+"/ccf/forms",set:c,sync:r,initialize:function(){this.on("sync",this.decode,this)},defaults:function(){var e={fields:new wp.ccf.collections.Fields,type:"ccf_form",status:"publish",description:"",buttonText:"Submit Form",completionActionType:"text",completionRedirectUrl:"",completionMessage:"",sendEmailNotifications:!1,emailNotificationAddresses:l.adminEmail,emailNotificationFromType:"default",emailNotificationFromAddress:"",emailNotificationFromField:""};return e=i.defaults(e,this.constructor.__super__.defaults),wp.ccf.utils.cleanDateFields(e),e},decode:function(){var e=i.keys(wp.api.models.Post.prototype.defaults);return e=i.without(e,"title"),n.call(this,e)},getFieldSlugs:function(e){var t=wp.ccf.currentForm.get("fields"),i=[];return t.each(function(t){e&&t.isImmutable||i.push(t.get("slug"))}),i},parse:function(e){var t=this;if(e.fields){var l=t.get("fields");if(l&&l.length>0){for(var s=0;e.fields.length>s;s++){var c=e.fields[s],r=l.findWhere({slug:c.slug});if(r){if(c.choices!==void 0){var n=t.get("choices");if(n&&n.length>0)for(var o=0;c.choices>o;o++){var a=n.at(o);a.set(c.choices[o]),a.decode()}delete e.fields[s].choices}r.set(c),r.decode()}}delete e.fields}else{var d=[];i.each(e.fields,function(e){var t=new wp.ccf.models.Fields[e.type](e);t.decode(),d.push(t)}),e.fields=new wp.ccf.collections.Fields(d,{formId:e.ID})}}return this.constructor.__super__.parse.call(this,e)},toJSON:function(){var e=this.constructor.__super__.toJSON.call(this);return e.fields&&(e.fields=e.fields.toJSON()),e.author&&(e.author=e.author.toJSON()),e}}),wp.ccf.models.Submission=wp.api.models.Submission||wp.api.models.Post.extend({idAttribute:"ID",defaults:{ID:null,data:{}},sync:r}),wp.ccf.models.Field=wp.api.models.Field||wp.api.models.Post.extend({idAttribute:"ID",defaults:{ID:null},set:c,required:function(){return["slug"]},decode:function(){return n.call(this,i.keys(wp.api.models.Post.prototype.defaults))},hasRequiredAttributes:function(){var e=this,t=!0;return i.each(this.required(),function(i){(e.get(i)===void 0||""===e.get(i))&&(t=!1)}),t},sync:r}),wp.ccf.models.StandardField=wp.ccf.models.StandardField||wp.ccf.models.Field.extend({idAttribute:"ID",defaults:function(){var e={label:"Field Label",value:"",placeholder:"",slug:"",type:"",required:!1,className:"",description:""};return i.defaults(e,this.constructor.__super__.defaults)}}),wp.ccf.models.Fields["single-line-text"]=wp.ccf.models.Fields["single-line-text"]||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"single-line-text"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.file=wp.ccf.models.Fields.file||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"file",fileExtensions:"",maxFileSize:l.maxFileSize};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields["paragraph-text"]=wp.ccf.models.Fields["paragraph-text"]||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"paragraph-text"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.hidden=wp.ccf.models.Fields.hidden||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"hidden"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.email=wp.ccf.models.Fields.email||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"email",emailConfirmation:!1};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.website=wp.ccf.models.Fields.website||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"website",placeholder:"http://"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.phone=wp.ccf.models.Fields.phone||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"phone",phoneFormat:"us"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.date=wp.ccf.models.Fields.date||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"date",showDate:!0,showTime:!0};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.name=wp.ccf.models.Fields.name||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"name"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.recaptcha=wp.ccf.models.Fields.recaptcha||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"recaptcha",siteKey:"",secretKey:""};return i.defaults(e,this.constructor.__super__.defaults())},required:function(){return["siteKey","secretKey"]},isImmutable:!0}),wp.ccf.models.Fields.address=wp.ccf.models.Fields.address||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"address",addressType:"us"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields["section-header"]=wp.ccf.models.Fields["section-header"]||wp.ccf.models.Field.extend({defaults:function(){var e={type:"section-header",slug:"",heading:"",subheading:"",className:""};return i.defaults(e,this.constructor.__super__.defaults)},required:function(){return[]},isImmutable:!0}),wp.ccf.models.Fields.html=wp.ccf.models.Fields.html||wp.ccf.models.Field.extend({defaults:function(){var e={type:"html",slug:"",html:"",className:""};return i.defaults(e,this.constructor.__super__.defaults)},required:function(){return[]},isImmutable:!0}),wp.ccf.models.ChoiceableField=wp.ccf.models.ChoiceableField||wp.ccf.models.StandardField.extend({defaults:function(){var e={choices:new wp.ccf.collections.FieldChoices};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(e){if("object"==typeof e&&e.choices){var t=[];i.each(e.choices,function(e){var i=new wp.ccf.models.FieldChoice(e);i.decode(),t.push(i)}),this.set("choices",new wp.ccf.collections.FieldChoices(t))}}}),wp.ccf.models.Fields.radio=wp.ccf.models.Fields.radio||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"radio"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}}),wp.ccf.models.Fields.checkboxes=wp.ccf.models.Fields.checkboxes||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"checkboxes"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}}),wp.ccf.models.Fields.dropdown=wp.ccf.models.Fields.dropdown||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"dropdown"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}})}(jQuery,Backbone,_,ccfSettings,WP_API_Settings),function(e,t,i){"use strict";var l=function(e,t,i){return i=i||{},i.emulateHTTP=!0,this.constructor.__super__.sync.call(this,e,t,i)};wp.ccf.collections=wp.ccf.collections||{},wp.ccf.collections.Forms=wp.ccf.collections.Forms||wp.api.collections.Posts.extend({model:wp.ccf.models.Form,url:WP_API_Settings.root+"/ccf/forms",formsFetching:{},initialize:function(){this.constructor.__super__.initialize(),this.formsFetching={}},sync:l,remove:function(e,t){t=t||{};var l=this.constructor.__super__.remove.call(this,e,t);return t.destroy&&(e instanceof Array?i.each(e,function(e){e.destroy()}):e.destroy()),l}}),wp.ccf.collections.Fields=wp.ccf.collections.Fields||wp.api.collections.Posts.extend({model:wp.ccf.models.Field,url:function(){return WP_API_Settings.root+"/ccf/forms/"+this.formId+"/fields"},initialize:function(e,t){t&&t.formId&&(this.formId=t.formId)},sync:l}),wp.ccf.collections.Submissions=wp.ccf.collections.Submissions||wp.api.collections.Posts.extend({model:wp.ccf.models.Submission,url:function(){return WP_API_Settings.root+"/ccf/forms/"+this.formId+"/submissions"},initialize:function(e,t){this.constructor.__super__.initialize.apply(this,arguments),t&&t.formId&&(this.formId=t.formId)},sync:l}),wp.ccf.collections.FieldChoices=wp.ccf.collections.FieldChoices||t.Collection.extend({model:wp.ccf.models.FieldChoice})}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l){"use strict";wp.ccf.views=wp.ccf.views||{},wp.ccf.views.Fields=wp.ccf.views.Fields||{},wp.ccf.views.FieldChoice=t.View.extend({template:wp.ccf.utils.template("ccf-field-choice-template"),className:"choice",events:{"click .add":"triggerAdd","click .delete":"triggerDelete","blur input":"saveChoice",saveChoice:"saveChoice",sorted:"triggerUpdateSort"},initialize:function(e){this.field=e.field},destroy:function(){wp.ccf.dispatcher.off("mainViewChange",this.saveChoice),this.unbind()},triggerUpdateSort:function(e,t){this.field.get("choices").remove(this.model,{silent:!0}),this.field.get("choices").add(this.model,{at:t,silent:!0})},saveChoice:function(){if(""!==this.el.innerHTML){var e=this.el.querySelectorAll(".choice-label")[0].value,t=this.el.querySelectorAll(".choice-value")[0].value;this.model.set("label",e),this.model.set("value",t);var i=this.el.querySelectorAll(".choice-selected")[0],l=i.checked?!0:!1;return this.model.set("selected",l),this}},render:function(){var e={};return this.model&&(e.choice=this.model.toJSON()),this.el.innerHTML=this.template(e),wp.ccf.dispatcher.on("mainViewChange",this.saveChoice,this),this},triggerAdd:function(){this.field.get("choices").add(new wp.ccf.models.FieldChoice)},triggerDelete:function(){var e=this.field.get("choices");if(e.length>1)e.remove(this.model),this.destroy(),this.remove();else{for(var t=this.el.querySelectorAll(".choice-label, .choice-value"),i=this.el.querySelectorAll(".choice-selected"),l=0;t.length>l;l++)t[l].value="";i[0].checked=!1}}}),wp.ccf.views.FieldBase=wp.ccf.views.FieldBase||t.View.extend({events:{"blur input":"saveField","blur input.field-slug":"checkSlug","blur textarea":"saveField","change select":"saveField",'change input[type="checkbox"]':"saveField"},checkSlug:function(){var e=this.el.querySelectorAll(".field-slug");if(e.length>0){var t=e[0],i=!1;t.parentNode.className=t.value&&!t.value.match(/^[a-zA-Z0-9\-_]+$/)?t.parentNode.className.replace(/ field-error/i,"")+" field-error":t.parentNode.className.replace(/ field-error/i,""),this.collection.length>0&&""!==t.value?(this.collection.each(function(e){e!==this.model&&t.value===e.get("slug")&&(i=!0)},this),t.parentNode.className=i?t.parentNode.className.replace(/ field-duplicate-slug/i,"")+" field-duplicate-slug":t.parentNode.className.replace(/ field-duplicate-slug/i,"")):t.parentNode.className=t.parentNode.className.replace(/ field-duplicate-slug/i,"")}},destroy:function(){this.unbind()},render:function(){return this.el.innerHTML=this.template({field:this.model.toJSON()}),this.checkSlug(),this}}),wp.ccf.views.Fields["single-line-text"]=wp.ccf.views.Fields["single-line-text"]||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-single-line-text-template"),initialize:function(){},saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.file=wp.ccf.views.Fields.file||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-file-template"),initialize:function(){},saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this.model.set("fileExtensions",this.el.querySelectorAll(".field-file-extensions")[0].value),this.model.set("maxFileSize",this.el.querySelectorAll(".field-max-file-size")[0].value),this):void 0}}),wp.ccf.views.Fields.recaptcha=wp.ccf.views.Fields.recaptcha||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-recaptcha-template"),initialize:function(){},saveField:function(){return""!==this.el.innerHTML?(this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("siteKey",this.el.querySelectorAll(".field-site-key")[0].value),this.model.set("secretKey",this.el.querySelectorAll(".field-secret-key")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this):void 0}}),wp.ccf.views.Fields["section-header"]=wp.ccf.views.Fields["section-header"]||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-section-header-template"),initialize:function(){},saveField:function(){return""!==this.el.innerHTML?(this.model.set("heading",this.el.querySelectorAll(".field-heading")[0].value),this.model.set("subheading",this.el.querySelectorAll(".field-subheading")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this):void 0}}),wp.ccf.views.Fields.html=wp.ccf.views.Fields.html||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-html-template"),initialize:function(){},saveField:function(){return""!==this.el.innerHTML?(this.model.set("html",this.el.querySelectorAll(".field-html")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this):void 0}}),wp.ccf.views.Fields["paragraph-text"]=wp.ccf.views.Fields["paragraph-text"]||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-paragraph-text-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.hidden=wp.ccf.views.Fields.hidden||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-hidden-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this):void 0}}),wp.ccf.views.Fields.date=wp.ccf.views.Fields.date||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-date-template"),saveField:function(){if(""!==this.el.innerHTML){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value);var e=this.el.querySelectorAll(".field-value");e.length>0&&this.model.set("value",e[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("showDate",this.el.querySelectorAll(".field-show-date")[0].checked?!0:!1);var t=this.model.get("showTime"),i=this.el.querySelectorAll(".field-show-time")[0].checked?!0:!1;return this.model.set("showTime",i),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),i!=t&&this.render(),this}}}),wp.ccf.views.Fields.name=wp.ccf.views.Fields.name||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-name-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.website=wp.ccf.views.Fields.website||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-website-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.phone=wp.ccf.views.Fields.phone||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-phone-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("phoneFormat",this.el.querySelectorAll(".field-phone-format")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.address=wp.ccf.views.Fields.address||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-address-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("addressType",this.el.querySelectorAll(".field-address-type")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.email=wp.ccf.views.Fields.email||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-email-template"),saveField:function(){if(""!==this.el.innerHTML){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value);var e=this.el.querySelectorAll(".field-value");e.length&&this.model.set("value",e[0].value);var t=this.el.querySelectorAll(".field-placeholder");t.length&&this.model.set("placeholder",t[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1);var i=1==this.el.querySelectorAll(".field-email-confirmation")[0].value?!0:!1,l=this.model.get("emailConfirmation");return this.model.set("emailConfirmation",i),l!=i&&this.render(),this}}}),wp.ccf.views.ChoiceableField=wp.ccf.views.ChoiceableField||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-dropdown-template"),initialize:function(){var e=this.model.get("choices");this.listenTo(e,"add",this.addChoice)},addChoice:function(e){var t=new wp.ccf.views.FieldChoice({model:e,field:this.model}).render(),i=this.el.querySelectorAll(".repeatable-choices")[0];i.appendChild(t.el)},saveField:function(){if(""!==this.el.innerHTML){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1);var t=this.el.querySelectorAll(".repeatable-choices")[0].querySelectorAll(".choice");return i.each(t,function(t){e(t).trigger("saveChoice")}),this}},render:function(){var t=this;t.el.innerHTML=t.template({field:t.model.toJSON()}),t.checkSlug();var i=t.model.get("choices"),l=this.el.querySelectorAll(".repeatable-choices")[0];if(i.length>=1)i.each(function(e){var i=new wp.ccf.views.FieldChoice({model:e,field:t.model}).render();l.appendChild(i.el)});else{var s=new wp.ccf.models.FieldChoice;i.add(s)}return l=this.el.querySelectorAll(".repeatable-choices")[0],e(l).sortable({handle:".move",axis:"y",stop:function(e,t){t.item.trigger("sorted",t.item.index())}}),t}}),wp.ccf.views.Fields.dropdown=wp.ccf.views.Fields.dropdown||wp.ccf.views.ChoiceableField.extend({template:wp.ccf.utils.template("ccf-dropdown-template"),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.Fields.radio=wp.ccf.views.Fields.radio||wp.ccf.views.ChoiceableField.extend({template:wp.ccf.utils.template("ccf-radio-template"),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.Fields.checkboxes=wp.ccf.views.Fields.checkboxes||wp.ccf.views.ChoiceableField.extend({template:wp.ccf.utils.template("ccf-checkboxes-template"),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.FieldSidebar=wp.ccf.views.FieldSidebar||t.View.extend({initialize:function(e){this.currentFieldView=null,this.form=e.form},save:function(e){this.currentFieldView&&""!==this.currentFieldView.el.innerHTML&&this.currentFieldView.saveField(),e&&e instanceof Object&&e.resolve()},fieldRemoved:function(){this.currentFieldView&&(this.form.get("fields").get(this.currentFieldView.model)||this.render())},destroy:function(){wp.ccf.dispatcher.off("saveField",this.save),wp.ccf.dispatcher.off("mainViewChange",this.save),this.unbind()},render:function(e){var t={};if(e){var i=e.get("type");this.currentFieldView&&(this.currentFieldView.saveField(),this.currentFieldView.destroy&&this.currentFieldView.destroy()),this.currentFieldView=new wp.ccf.views.Fields[i]({model:e,collection:this.form.get("fields")}),this.currentFieldView.render(),this.el.innerHTML="",this.el.appendChild(this.currentFieldView.el);var l=this.form.get("fields");this.listenTo(l,"remove",this.fieldRemoved)}else{var s=wp.ccf.utils.template("ccf-empty-field-template");this.el.innerHTML=s(t)}return wp.ccf.dispatcher.on("saveField",this.save,this),wp.ccf.dispatcher.on("mainViewChange",this.save,this),this}}),wp.ccf.views.FieldRowPlaceholder=wp.ccf.views.FieldRowPlaceholder||t.View.extend({template:wp.ccf.utils.template("ccf-field-row-template"),tagName:"div",className:"field",initialize:function(e){this.type=e.type},render:function(){return this.el.innerHTML=this.template({label:l.allLabels[this.type]}),this.el.setAttribute("data-field-type",this.type),this.el.className+=" "+this.type,this}}),wp.ccf.views.FieldRow=wp.ccf.views.FieldRow||t.View.extend({template:wp.ccf.utils.template("ccf-field-row-template"),tagName:"div",className:"field",events:{"click .delete":"triggerDelete","click h4":"triggerEdit",sorted:"triggerUpdateSort"},initialize:function(e){i.bindAll(this,"triggerDelete"),this.form=e.form,this.listenTo(this.model,"change",this.handleChange,this),this.listenTo(this.model,"requirementsNotMet",this.requirementsNotMet,this),this.listenTo(this.model,"requirementsMet",this.requirementsMet,this),this.listenTo(this.model,"duplicateSlug",this.duplicateSlug,this),this.model.attributes.choices&&this.listenTo(this.model.attributes.choices,"change",this.handleChange,this)},duplicateSlug:function(){this.requirementsMet(),this.el.className+=" field-duplicate-slug"},requirementsNotMet:function(){this.requirementsMet(),this.el.className+=" field-incomplete"},requirementsMet:function(){this.el.className=this.el.className.replace(/(field-incomplete|field-duplicate-slug)/i,"")},triggerUpdateSort:function(e,t){this.form.get("fields").remove(this.model),this.form.get("fields").add(this.model,{at:t})},handleChange:function(){this.render()},triggerDelete:function(e){e.stopPropagation(),this.form.get("fields").remove(this.model),this.undelegateEvents(),this.remove()},triggerEdit:function(){var e=this.el.parentNode.querySelectorAll(".ccf-editing");i.each(e,function(e){e.className=e.className.replace(/ccf-editing/i,"")}),this.el.className=this.el.className.replace(/ccf-editing/i,"")+" ccf-editing",wp.ccf.dispatcher.trigger("openEditField",this.model)},render:function(e){this.el.innerHTML=this.template({label:l.allLabels[this.model.get("type")]}),this.el.setAttribute("data-field-type",this.model.get("type"));var t=RegExp(" "+this.model.get("type"),"i");this.el.className=this.el.className.replace(t,"")+" "+this.model.get("type"),e&&(this.el.className=this.el.className.replace(/ instantiated/i,"")+" instantiated");var i=document.getElementById("ccf-"+this.model.get("type")+"-preview-template");if(i){var s=this.el.querySelectorAll(".preview")[0];s.style.display="block",s.innerHTML=wp.ccf.utils.template("ccf-"+this.model.get("type")+"-preview-template")({field:this.model.toJSON()})}return this}}),wp.ccf.views.FormSettings=wp.ccf.views.FormSettings||t.View.extend({template:wp.ccf.utils.template("ccf-form-settings-template"),events:{"blur input":"save","change select":"save","change select.form-completion-action-type":"toggleCompletionFields","change select.form-send-email-notifications":"toggleNotificationFields"},initialize:function(e){this.model=e.form},destroy:function(){wp.ccf.dispatcher.off("saveFormSettings",this.save),wp.ccf.dispatcher.off("mainViewChange",this.save)},toggleCompletionFields:function(){var e=this.el.querySelectorAll(".form-completion-action-type")[0].value,t=this.el.querySelectorAll(".completion-message")[0],i=this.el.querySelectorAll(".completion-redirect-url")[0];"text"===e?(t.style.display="block",i.style.display="none"):(t.style.display="none",i.style.display="block")},save:function(e){if(""!==this.el.innerHTML){var t=this.el.querySelectorAll(".form-title")[0].value;this.model.set("title",t);var i=this.el.querySelectorAll(".form-description")[0].value;this.model.set("description",i);var l=this.el.querySelectorAll(".form-button-text")[0].value;this.model.set("buttonText",l);var s=this.el.querySelectorAll(".form-completion-message")[0].value;this.model.set("completionMessage",s);var c=this.el.querySelectorAll(".form-completion-redirect-url")[0].value;this.model.set("completionRedirectUrl",c);var r=this.el.querySelectorAll(".form-completion-action-type")[0].value;this.model.set("completionActionType",r),e!==void 0&&e.promise!==void 0&&e.resolve()}},render:function(){var e={form:this.model.toJSON()};return this.el.innerHTML=this.template(e),this.toggleCompletionFields(),wp.ccf.dispatcher.on("saveFormSettings",this.save,this),wp.ccf.dispatcher.on("mainViewChange",this.save,this),this}}),wp.ccf.views.FormNotifications=wp.ccf.views.FormNotifications||t.View.extend({template:wp.ccf.utils.template("ccf-form-notifications-template"),events:{"blur input":"save","change select":"save","change select.form-send-email-notifications":"toggleNotificationFields","change select.form-email-notification-from-type":"toggleNotificationFields"},initialize:function(e){this.model=e.form
2
- },destroy:function(){wp.ccf.dispatcher.off("saveFormNotifications",this.save),wp.ccf.dispatcher.off("mainViewChange",this.save),this.undelegateEvents(),this.unbind()},updateFromAddressFieldField:function(){var e=this.el.querySelectorAll(".form-email-notification-from-field")[0];e.innerHTML="",e.disabled=!1;var t=this.model.get("fields"),i=0,s=this.model.get("emailNotificationFromField");if(t.length>=1&&t.each(function(t){if("email"===t.get("type")){var l=document.createElement("option");l.innerHTML=t.get("slug"),l.value=t.get("slug"),t.get("slug")===s&&(l.selected=!0),e.appendChild(l),i++}}),0===i){var c=document.createElement("option");c.innerHTML=l.noEmailFields,e.appendChild(c),e.disabled=!0}},toggleNotificationFields:function(){var e,t=this.el.querySelectorAll(".form-send-email-notifications")[0].value,i=this.el.querySelectorAll(".email-notification-setting"),l=this.el.querySelectorAll(".email-notification-from-address")[0],s=this.el.querySelectorAll(".email-notification-from-field")[0],c=this.el.querySelectorAll(".form-email-notification-from-type")[0];if(parseInt(t)){for(e=0;i.length>e;e++)i[e].style.display="block";l.style.display="none",s.style.display="none","custom"===c.value?l.style.display="block":"field"===c.value&&(s.style.display="block")}else{for(e=0;i.length>e;e++)i[e].style.display="none";l.style.display="none",s.style.display="none"}},save:function(e){if(""!==this.el.innerHTML){var t=this.el.querySelectorAll(".form-send-email-notifications")[0].value;this.model.set("sendEmailNotifications",parseInt(t)?!0:!1);var i=this.el.querySelectorAll(".form-email-notification-addresses")[0].value;this.model.set("emailNotificationAddresses",i);var l=this.el.querySelectorAll(".form-email-notification-from-type")[0].value;this.model.set("emailNotificationFromType",l);var s=this.el.querySelectorAll(".form-email-notification-from-address")[0].value;this.model.set("emailNotificationFromAddress",s);var c=this.el.querySelectorAll(".form-email-notification-from-field")[0].value;this.model.set("emailNotificationFromField",c),e!==void 0&&e.promise!==void 0&&e.resolve()}},render:function(){var e={form:this.model.toJSON()},t=this.model.get("fields");return this.el.innerHTML=this.template(e),this.toggleNotificationFields(),this.updateFromAddressFieldField(),wp.ccf.dispatcher.on("saveFormNotifications",this.save,this),wp.ccf.dispatcher.on("mainViewChange",this.save,this),this.listenTo(t,"add",this.updateFromAddressFieldField,this),this.listenTo(t,"remove",this.updateFromAddressFieldField,this),this}}),wp.ccf.views.FormPane=wp.ccf.views.FormPane||t.View.extend(i.defaults({template:wp.ccf.utils.template("ccf-form-pane-template"),subViews:{"field-sidebar":wp.ccf.views.FieldSidebar,"form-settings":wp.ccf.views.FormSettings,"form-notifications":wp.ccf.views.FormNotifications},events:{"click .save-button":"sync","click h2":"accordionClick","click .insert-form-button":"insertForm"},initialize:function(){wp.ccf.dispatcher.on("openEditField",this.openEditField,this)},insertForm:function(){wp.ccf.utils.insertFormShortcode(this.model),wp.ccf.toggle()},accordionClick:function(t){var l=e(t.currentTarget).parents(".accordion-container")[0],s=l.querySelectorAll(".accordion-section");t.currentTarget.parentNode.className.match(/expanded/i)?t.currentTarget.parentNode.className=t.currentTarget.parentNode.className.replace(/expanded/i,""):t.currentTarget.parentNode.className+=" expanded",i.each(s,function(e){e!=t.currentTarget.parentNode&&e.className.match(/expanded/i)&&(e.className=e.className.replace(/expanded/i,""))})},openEditField:function(e){this.renderedSubViews["field-sidebar"].render(e).el.style.display="block"},disable:function(){this.el.querySelectorAll(".save-button")[0].setAttribute("disabled","disabled"),this.el.querySelectorAll(".disabled-overlay")[0].style.display="block"},enable:function(){this.el.querySelectorAll(".save-button")[0].removeAttribute("disabled"),this.el.querySelectorAll(".disabled-overlay")[0].style.display="none"},sync:function(){var t=this,i=e(this.el.querySelectorAll(".spinner")[0]);i.fadeIn(),t.disable();var s=e.Deferred(),c=e.Deferred(),r=e.Deferred();wp.ccf.dispatcher.trigger("saveFormSettings",s),wp.ccf.dispatcher.trigger("saveFormNotifications",r),wp.ccf.dispatcher.trigger("saveField",c),e.when(s,c,r).then(function(){var e=t.model.get("fields"),s=!0,c={};e.each(function(e){var t=e.get("slug");e.hasRequiredAttributes()?t&&!t.match(/^[a-zA-Z0-9\-_]+$/)?(s=!1,e.trigger("requirementsNotMet")):c[e.get("slug")]!==void 0?(s=!1,e.trigger("duplicateSlug"),c[e.get("slug")].trigger("duplicateSlug")):e.trigger("requirementsMet"):(s=!1,e.trigger("requirementsNotMet")),e.get("slug")&&(c[e.get("slug")]=e)}),s?t.model.save({},{context:"edit"}).error(function(){var e="sync";wp.ccf.errorModal.render(e).show()}).done(function(){l.single&&!l.postId&&(window.location=l.adminUrl+"post.php?post="+t.model.get("ID")+"&action=edit#ccf-form/"+t.model.get("ID"))}).complete(function(){i.fadeOut(),t.enable(),wp.ccf.dispatcher.trigger("saveFormComplete",t.model)}):(t.enable(),i.fadeOut())})},enableDisableInsert:function(){var e=this.el.querySelectorAll(".insert-form-button")[0];this.model.get("ID")?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled")},getNextFieldOrd:function(){var e=this.model.get("fields"),t=e.length+1;return e.each(function(e){var i=e.get("slug"),l=/\-([0-9]+)$/g,s=l.exec(i);if(s&&s[1]){var c=parseInt(s[1]);c>=t&&(t=c+1)}}),t},render:function(t){var s=this;s.model=t?t:new wp.ccf.models.Form,this.listenTo(s.model,"change",this.enableDisableInsert,this);var c={labels:l.fieldLabels,form:s.model.toJSON()};window.form=s.model,s.el.innerHTML=this.template(c);var r=s.el.querySelectorAll(".fields")[0];i.each(l.fieldLabels,function(e,t){r.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)});var n=s.el.querySelectorAll(".structure-fields")[0];i.each(l.structureFieldLabels,function(e,t){n.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)});var o=s.el.querySelectorAll(".special-fields")[0];i.each(l.specialFieldLabels,function(e,t){o.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)});var a=s.model.get("fields"),d=s.el.querySelectorAll(".form-content")[0],u=e(d);return e(s.el.querySelectorAll(".left-sidebar")[0].querySelectorAll(".field")).draggable({cursor:"move",distance:2,zIndex:160001,scroll:!1,containment:"document",appendTo:".ccf-main-modal",snap:!1,connectToSortable:".form-content",helper:function(t){var i=e(t.currentTarget),l=e('<div class="field" data-field-type="'+i.attr("data-field-type")+'"><h4>'+i.find(".label").html()+"</h4></div>");return l.css({width:u.width(),opacity:".75",height:i.height()})}}),a.length>=1&&(d.innerHTML="",a.each(function(e){var t=new wp.ccf.views.FieldRow({model:e,form:s.model}).render(!0).el;d.appendChild(t)})),e(d).sortable({axis:"y",distance:2,handle:"h4",placeholder:"field-placeholder",stop:function(e,t){if(!t.item.hasClass("instantiated")){var i=t.item.attr("data-field-type"),l={};wp.ccf.models.Fields[i].prototype.defaults().slug!==void 0&&(l.slug=i+"-"+s.getNextFieldOrd());var c=new wp.ccf.models.Fields[i](l),r=s.model.get("fields");r.add(c),new wp.ccf.views.FieldRow({model:c,el:t.item,form:s.model}).render(!0),t.item.attr("style","")}t.item.trigger("sorted",t.item.index())}}),s.initRenderSubViews(!0,!0,{form:s.model}),s.enableDisableInsert(),s}},wp.ccf.mixins.subViewable)),wp.ccf.views.ExistingFormTableRow=wp.ccf.views.ExistingFormTableRow||t.View.extend({tagName:"tr",template:wp.ccf.utils.template("ccf-existing-form-table-row-template"),events:{"click .edit":"triggerMainViewChange","click .delete":"triggerDelete","click .insert-form-button":"insertForm"},initialize:function(e){this.parent=e.parent},insertForm:function(){wp.ccf.utils.insertFormShortcode(this.model),wp.ccf.toggle()},triggerMainViewChange:function(){wp.ccf.switchToForm(this.model)},triggerDelete:function(){var e,t=this,i=t.parent.collection.state.currentPage;t.model.destroy().done(function(){e=i,e===t.parent.collection.state.totalPages&&e-1===(t.parent.collection.state.totalObjects-1)/l.postsPerPage&&e--,t.parent.showPage(e).done(function(){t.parent.renderPagination()})})},render:function(){return this.$el.html(this.template({form:this.model.toJSON(),utils:{getPrettyPostDate:wp.ccf.utils.getPrettyPostDate}})),this}}),wp.ccf.views.EmptyFormTableRow=wp.ccf.views.EmptyFormTableRow||t.View.extend({tagName:"tr",template:wp.ccf.utils.template("ccf-empty-form-table-row-template"),render:function(){return this.$el.html(this.template()),this}}),wp.ccf.views.ExistingFormTable=wp.ccf.views.ExistingFormTable||t.View.extend({template:wp.ccf.utils.template("ccf-existing-form-table-template"),initialize:function(){this.parent=arguments.parent,this.collection=new wp.ccf.collections.Forms,wp.ccf.dispatcher.on("changeFormTablePage",this.showPage,this),wp.ccf.dispatcher.on("saveFormComplete",this.render,this)},showPage:function(e){var t=this,i=this.collection.fetch({data:{page:e}});return i.error(function(){var e="sync";wp.ccf.errorModal.render(e).show()}),i.done(function(){var e=t.el.querySelectorAll(".rows")[0],i=document.createElement("tbody");i.className="rows",t.collection.length>=1?t.collection.each(function(e){var l=new wp.ccf.views.ExistingFormTableRow({model:e,parent:t}).render();i.appendChild(l.el)},t):i.appendChild((new wp.ccf.views.EmptyFormTableRow).render().el),e.parentNode.replaceChild(i,e)}),i},renderPagination:function(){var e=this.el.querySelectorAll(".ccf-pagination")[0];e.innerHTML="",this.collection.state.totalPages>1&&e.appendChild(new wp.ccf.views.Pagination({parent:this}).render(this.collection.state.totalPages,this.collection.state.currentPage).el)},render:function(){var e=this;return this.el.innerHTML=this.template(),this.el.querySelectorAll(".ccf-pagination")[0],this.showPage(1).done(function(){e.renderPagination()}),this}}),wp.ccf.views.ExistingFormPane=wp.ccf.views.ExistingFormPane||t.View.extend(i.defaults({template:wp.ccf.utils.template("ccf-existing-form-pane-template"),subViews:{"existing-form-table":wp.ccf.views.ExistingFormTable},render:function(){return this.rendered?this:(this.rendered=!0,this.el.innerHTML=this.template(),this.initRenderSubViews(!0),this)}},wp.ccf.mixins.subViewable)),wp.ccf.views.MainModal=wp.ccf.views.MainModal||t.View.extend(i.defaults({tagName:"div",className:"ccf-main-modal",template:wp.ccf.utils.template("ccf-main-modal-template"),events:{"click .close-icon":"hide","click .main-menu a":"menuClick"},subViews:{"form-pane":wp.ccf.views.FormPane},initialize:function(){l.single||(this.subViews["existing-form-pane"]=wp.ccf.views.ExistingFormPane),wp.ccf.dispatcher.on("mainViewChange",this.toggleView,this)},toggleView:function(e){this.showView(e,wp.ccf.currentForm);var t=e;"form-pane"===e&&wp.ccf.currentForm&&(t="existing-form-pane");var l=this.el.querySelectorAll(".menu-item");i.each(l,function(e){var i=e.getAttribute("data-view");e.className=i===t?e.className.replace("selected","")+" selected":e.className.replace("selected","")})},menuClick:function(e){var t=e.target.getAttribute("data-view");"form-pane"===t&&(wp.ccf.currentForm=null),wp.ccf.dispatcher.trigger("mainViewChange",t),e.preventDefault()},render:function(e){return e=e||!1,this.overlay(),this.el.innerHTML=this.template({single:e}),this.initRenderSubViews(),this.showView("form-pane",wp.ccf.currentForm,!0),this},overlay:function(){return this.overlayEl===void 0&&(this.overlayEl=document.createElement("div"),this.overlayEl.className="ccf-main-modal-overlay",document.body.appendChild(this.overlayEl)),this.overlayEl},remove:function(){return document.body.removeChild(this.overlay()),this},show:function(){e(this.overlay()).show(),this.$el.show()},hide:function(){e(this.overlay()).hide(),this.$el.hide()}},wp.ccf.mixins.subViewable)),wp.ccf.views.SubmissionRow=wp.ccf.views.SubmissionRow||t.View.extend({tagName:"tr",template:wp.ccf.utils.template("ccf-submission-row-template"),events:{"click .view":"view","click .delete":"delete"},initialize:function(e){this.parent=e.parent},"delete":function(){var e,t=this,i=t.parent.collection.state.currentPage;t.model.destroy().done(function(){e=i,e===t.parent.collection.state.totalPages&&e-1===(t.parent.collection.state.totalObjects-1)/l.postsPerPage&&e--,t.parent.showPage(e).done(function(){t.parent.renderPagination()})})},view:function(e){var t=e.currentTarget.getAttribute("data-submission-id"),i=e.currentTarget.getAttribute("data-submission-date");tb_show(l.thickboxTitle+" - "+wp.ccf.utils.getPrettyPostDate(i),"#TB_inline?height=500&amp;width=700&amp;inlineId=ccf-submission-content-"+parseInt(t),null)},render:function(){return this.$el.html(this.template({submission:this.model.toJSON(),currentColumns:this.parent.columns,columns:wp.ccf.currentForm.getFieldSlugs(!0),utils:{getPrettyPostDate:wp.ccf.utils.getPrettyPostDate,wordChop:wp.ccf.utils.wordChop,isFieldDate:wp.ccf.utils.isFieldDate,isFieldName:wp.ccf.utils.isFieldName,isFieldFile:wp.ccf.utils.isFieldFile,isFieldAddress:wp.ccf.utils.isFieldAddress,isFieldEmailConfirm:wp.ccf.utils.isFieldEmailConfirm,getPrettyFieldDate:wp.ccf.utils.getPrettyFieldDate,getPrettyFieldAddress:wp.ccf.utils.getPrettyFieldAddress,getPrettyFieldName:wp.ccf.utils.getPrettyFieldName,getPrettyFieldEmailConfirm:wp.ccf.utils.getPrettyFieldEmailConfirm}})),this}}),wp.ccf.views.SubmissionsTable=wp.ccf.views.SubmissionsTable||t.View.extend({template:wp.ccf.utils.template("ccf-submission-table-template"),events:{"click .prev:not(.disabled)":"previousPage","click .next:not(.disabled)":"nextPage","click .first:not(.disabled)":"firstPage","click .last:not(.disabled)":"lastPage"},initialize:function(){this.collection=new wp.ccf.collections.Submissions({},{formId:l.postId}),wp.ccf.dispatcher.on("submissionTableRebuild",this.render,this)},showPage:function(e){var t=this,i=this.collection.fetch({data:{page:e}});return i.error(function(){var e="sync";wp.ccf.errorModal.render(e).show()}),i.done(function(){var e=t.el.querySelectorAll(".submission-rows")[0],i=document.createElement("tbody");i.className="submission-rows",t.collection.length>=1?t.collection.each(function(e){var l=new wp.ccf.views.SubmissionRow({model:e,parent:t}).render();i.appendChild(l.el)},t):i.appendChild(new wp.ccf.views.EmptySubmissionTableRow({parent:t}).render(wp.ccf.currentForm.getFieldSlugs(!0).concat("date")).el),e.parentNode.replaceChild(i,e)}),i},renderPagination:function(){var e=this.el.querySelectorAll(".ccf-pagination")[0];e.innerHTML="",this.collection.state.totalPages>1&&e.appendChild(new wp.ccf.views.Pagination({parent:this}).render(this.collection.state.totalPages,this.collection.state.currentPage).el)},render:function(e){var t=this;return t.columns=e?e:wp.ccf.currentForm.getFieldSlugs(!0).slice(0,4).concat("date"),1>t.columns.length?t.el.innerHTML="":(t.el.innerHTML=t.template({columns:t.columns}),t.el.querySelectorAll(".ccf-pagination")[0],t.showPage(1).done(function(){t.renderPagination()})),t}}),wp.ccf.views.ErrorModal=wp.ccf.views.ErrorModal||t.View.extend({template:wp.ccf.utils.template("ccf-error-modal-template"),tagName:"div",className:"ccf-error-modal",events:{"click .close":"hide"},hide:function(){this.el.className=this.el.className.replace(" show","")},show:function(){this.el.className=this.el.className.replace(" show","")+" show"},toggle:function(){this.el.className.match(" show")?this.hide():this.show()},render:function(e){var t={messageType:""};return e&&(t.messageType=e),this.el.innerHTML=this.template(t),this}}),wp.ccf.views.Pagination=wp.ccf.views.Pagination||t.View.extend({template:wp.ccf.utils.template("ccf-pagination-template"),events:{"click .prev:not(.disabled)":"previousPage","click .next:not(.disabled)":"nextPage","click .first:not(.disabled)":"firstPage","click .last:not(.disabled)":"lastPage"},initialize:function(e){this.parent=e.parent},previousPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.currentPage-1).done(function(){e.render()})},nextPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.currentPage+1).done(function(){e.render()})},firstPage:function(){var e=this;e.parent.showPage(1).done(function(){e.render()})},lastPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.totalPages).done(function(){e.render()})},render:function(){return this.el.innerHTML=this.template({totalPages:this.parent.collection.state.totalPages,currentPage:this.parent.collection.state.currentPage,totalObjects:this.parent.collection.state.totalObjects}),this}}),wp.ccf.views.EmptySubmissionTableRow=wp.ccf.views.EmptySubmissionTableRow||t.View.extend({tagName:"tr",template:wp.ccf.utils.template("ccf-no-submissions-row-template"),initialize:function(e){this.parent=e.parent},render:function(){return this.el.innerHTML=this.template({columns:this.parent.columns}),this}}),wp.ccf.views.SubmissionColumnController=wp.ccf.views.SubmissionColumnController||t.View.extend({template:wp.ccf.utils.template("ccf-submissions-controller-template"),events:{"click input[type=checkbox]":"triggerTableRebuild"},render:function(){this.el.innerHTML=this.template({columns:wp.ccf.currentForm.getFieldSlugs(!0).concat("date")})},triggerTableRebuild:function(){var e=[],t=document.querySelectorAll(".submission-column-checkbox");if(t.length>=1)for(var i=0;t.length>i;i++)t[i].checked&&e.push(t[i].value);wp.ccf.dispatcher.trigger("submissionTableRebuild",e)}})}(jQuery,Backbone,_,ccfSettings),function(e,t){"use strict";wp.ccf.router=wp.ccf.router||t.Router.extend({routes:{"ccf-form":"open","ccf-form/:formId":"open"},open:function(e){wp.ccf.show(e)}})}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l){"use strict";wp.ccf=i.defaults(wp.ccf,{forms:new wp.ccf.collections.Forms,currentForm:null,errorModal:null,_currentFormDeferred:null,dispatcher:{},show:function(e){return this.switchToForm(e),this.instance.show(),this.instance},initErrorModal:function(){this.errorModal=(new wp.ccf.views.ErrorModal).render();var e=document.getElementsByTagName("body")[0];e.appendChild(this.errorModal.el)},switchToForm:function(e){var t=this;if(+e===parseInt(e)){var i=parseInt(e);if(e=t.forms.findWhere({ID:parseInt(i)}),!e){var l;return t.forms.formsFetching[i]!==void 0?(l=t.forms.formsFetching[i],e=null):(e=new wp.ccf.models.Form({ID:i}),l=e.fetch(),t.forms.formsFetching[i]=l),l.done(function(){e?(delete t.forms.formsFetching[i],t.forms.add(e)):e=t.forms.findWhere({ID:i}),t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane")}),l}t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane")}else t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane");return!0},hide:function(){return this.instance.hide(),this.instance},toggle:function(e){return this.switchToForm(e),this.instance.$el.is(":visible")?this.instance.hide():this.instance.show(),this.instance},createSubmissionsTable:function(e){var t=document.querySelectorAll(".ccf-submission-column-controller"),i=new wp.ccf.views.SubmissionsTable({el:e});i.render(),t&&new wp.ccf.views.SubmissionColumnController({el:t}).render()},_setupMainModal:function(e){return this.instance=(new wp.ccf.views.MainModal).render(e),document.getElementsByTagName("body")[0].appendChild(this.instance.el),t.history.start(),this.instance},createManager:function(){var s=this,c=document.querySelectorAll(".ccf-open-form-manager")[0];if(!c)return!1;i.extend(this.dispatcher,t.Events),new wp.ccf.router,s.initErrorModal();var r=!1;if(l.single)if(r=!0,l.postId){var n=parseInt(l.postId);if(s.forms.formsFetching[n]===void 0){var o=new wp.ccf.models.Form({ID:n}),a=o.fetch();s.forms.formsFetching[n]=a,s._currentFormDeferred=a,a.done(function(){delete s.forms.formsFetching[n],s.forms.add(o),s.currentForm=o})}else s._currentFormDeferred=s.forms.formsFetching[n],s._currentFormDeferred.done(function(){s.currentForm=s.forms.findWhere({ID:n})});e.when(s._currentFormDeferred).then(function(){s._setupMainModal(!0),c.style.display="inline-block";var e=document.getElementById("ccf-submissions");if(e){var t=e.querySelectorAll(".inside")[0],i=document.createElement("div");i.className="ccf-submission-settings",i.setAttribute("data-icon","");var l=document.getElementById("show-settings-link");i.onclick=function(){l.click()},e.insertBefore(i,e.firstChild.nextSibling.nextSibling),wp.ccf.createSubmissionsTable(t)}})}else s._setupMainModal(!0),c.style.display="inline-block";else s._setupMainModal();var d=function(e){e=e||window.event;var t=e.currentTarget?e.currentTarget:e.srcElement,i=t.getAttribute("data-form-id");wp.ccf.toggle(i)};c.addEventListener?c.addEventListener("click",d,!1):c.attachEvent("onclick",d)}}),wp.ccf.createManager()}(jQuery,Backbone,_,ccfSettings);
1
  (function(e,t,i,l){"use strict";window.wp=window.wp||{},wp.ccf=wp.ccf||{},wp.ccf.utils=wp.ccf.utils||{},wp.ccf.utils.cleanDateFields=function(e){delete e.date,delete e.date_gmt,delete e.modified,delete e.modified_gmt,delete e.date_tz,delete e.modified_tz},wp.ccf.utils.template=i.memoize(function(e){var t={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g};return i.template(document.getElementById(e).innerHTML,null,t)}),wp.ccf.utils.insertFormShortcode=function(e){var t=wp.ccf.forms.findWhere({ID:e.get("ID")});t||wp.ccf.forms.add(e);var i=tinymce.get(wpActiveEditor),l='[ccf_form id="'+e.get("ID")+'"]';i&&!i.isHidden()?tinymce.activeEditor.execCommand("mceInsertContent",!1,l):document.getElementById(wpActiveEditor).value+=l},wp.ccf.utils.getPrettyPostDate=function(e){return e=moment.utc(e),l.gmtOffset&&(e=e.utcOffset(60*parseInt(l.gmtOffset))),e.format("h:mm a M/D/YYYY")},wp.ccf.utils.wordChop=function(e,t){var i=e.substr(0,t);return i.substr(0,Math.min(i.length,i.lastIndexOf(" "))),i.length<e.length&&(i+="..."),i},wp.ccf.utils.isFieldDate=function(e){return e.date!==void 0||e.hour!==void 0&&e.minute!==void 0&&e["am-pm"]!==void 0?!0:!1},wp.ccf.utils.isFieldName=function(e){return e.name!==void 0||e.last!==void 0?!0:!1},wp.ccf.utils.isFieldEmailConfirm=function(e){return e.email!==void 0||e.confirm!==void 0?!0:!1},wp.ccf.utils.isFieldAddress=function(e){return e.street!==void 0&&e.city!==void 0&&e.zipcode!==void 0&&e.line_two!==void 0?!0:!1},wp.ccf.utils.isFieldFile=function(e){return e.id!==void 0&&e.url!==void 0&&e.file_name!==void 0?!0:!1},wp.ccf.utils.getPrettyFieldEmailConfirm=function(e){return e.email?e.email:e.confirm?e.confirm:"-"},wp.ccf.utils.getPrettyFieldDate=function(e){var t="",i="";if(e.hour&&e.minute&&e["am-pm"]&&(t+=e.hour+":"+e.minute+" "+e["am-pm"]),e.date&&(t+=" "+e.date),!t)return"-";var s=moment.utc(t);return s.isValid()?(e.hour&&e.minute&&e["am-pm"]&&(i+=s.format("h:mm a")),e.date&&(i&&(i+=" "),i+=s.format("M/D/YYYY")),i):l.invalidDate},wp.ccf.utils.getPrettyFieldName=function(e){var t=e.first;return t.length>0&&(t+=" "),e.last&&(t+=e.last),t||(t="-"),t},wp.ccf.utils.getPrettyFieldAddress=function(e){if(!e.street||!e.city)return"-";var t=e.street;return e.line_two&&(t+=" "+e.line_two),t+=", "+e.city,e.state&&(t+=", "+e.state),e.zipcode&&(t+=" "+e.zipcode),e.country&&(t+=" "+e.country),t}})(jQuery,Backbone,_,ccfSettings),function(e,t,i){"use strict";wp.ccf.mixins=wp.ccf.mixins||{},wp.ccf.mixins.subViewable=wp.ccf.mixins.subViewable||{subViews:{},initRenderSubViews:function(e,t,l){this.renderedSubViews||(this.renderedSubViews={});for(var s in this.subViews){var c={el:this.$el.find(".ccf-"+s),parent:this};l&&i.extend(c,l),this.renderedSubViews[s]&&this.renderedSubViews[s].destroy&&this.renderedSubViews[s].destroy(),(t||!this.renderedSubViews[s])&&(this.renderedSubViews[s]=new this.subViews[s](c)),this.renderedSubViews[s].render(),e&&(this.renderedSubViews[s].el.style.display="block")}return this},showView:function(e,t,i){if(this.renderedSubViews!==void 0&&this.renderedSubViews[e]!==void 0){var l=this.renderedSubViews[e];i||l.render(t),l.el.style.display="block",this.currentView=e;for(var s in this.subViews)s!==e&&(this.renderedSubViews[s].el.style.display="none")}}}}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l,s){"use strict";wp.ccf.models=wp.ccf.models||{},wp.ccf.models.Fields=wp.ccf.models.Fields||{};var c=function(e,i,l){return"object"!=typeof i&&""===i&&(i=""),t.Model.prototype.set.call(this,e,i,l)},r=function(e,t,i){return i=i||{},i.emulateHTTP=!0,this.constructor.__super__.sync.call(this,e,t,i)},n=function(e){for(var t in this.attributes)if(-1===i.indexOf(e,t)){var l=this.get(t);"string"==typeof l&&""!==l&&(l=(l+"").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#8220;/g,"”").replace(/&#8221;/g,"”").replace(/&#8216;/g,"‘").replace(/&#038;/g,"&").replace(/&#039;/g,"'"),this.set(t,l))}return this};wp.ccf.models.FieldChoice=wp.ccf.models.FieldChoice||t.Model.extend({defaults:{label:"",value:"",selected:!1},decode:function(){return n.call(this,[])},set:c}),wp.ccf.models.Form=wp.ccf.models.Form||wp.api.models.Post.extend({urlRoot:s.root+"/ccf/forms",set:c,sync:r,initialize:function(){this.on("sync",this.decode,this)},defaults:function(){var e={fields:new wp.ccf.collections.Fields,type:"ccf_form",status:"publish",description:"",buttonText:"Submit Form",completionActionType:"text",completionRedirectUrl:"",completionMessage:"",sendEmailNotifications:!1,emailNotificationAddresses:l.adminEmail,emailNotificationFromType:"default",emailNotificationFromAddress:"",emailNotificationFromField:""};return e=i.defaults(e,this.constructor.__super__.defaults),wp.ccf.utils.cleanDateFields(e),e},decode:function(){var e=i.keys(wp.api.models.Post.prototype.defaults);return e=i.without(e,"title"),n.call(this,e)},getFieldSlugs:function(e){var t=wp.ccf.currentForm.get("fields"),i=[];return t.each(function(t){e&&t.isImmutable||i.push(t.get("slug"))}),i},parse:function(e){var t=this;if(e.fields){var l=t.get("fields");if(l&&l.length>0){for(var s=0;e.fields.length>s;s++){var c=e.fields[s],r=l.findWhere({slug:c.slug});if(r){if(c.choices!==void 0){var n=t.get("choices");if(n&&n.length>0)for(var o=0;c.choices>o;o++){var a=n.at(o);a.set(c.choices[o]),a.decode()}delete e.fields[s].choices}r.set(c),r.decode()}}delete e.fields}else{var d=[];i.each(e.fields,function(e){var t=new wp.ccf.models.Fields[e.type](e);t.decode(),d.push(t)}),e.fields=new wp.ccf.collections.Fields(d,{formId:e.ID})}}return this.constructor.__super__.parse.call(this,e)},toJSON:function(){var e=this.constructor.__super__.toJSON.call(this);return e.fields&&(e.fields=e.fields.toJSON()),e.author&&(e.author=e.author.toJSON()),e}}),wp.ccf.models.Submission=wp.api.models.Submission||wp.api.models.Post.extend({idAttribute:"ID",defaults:{ID:null,data:{}},sync:r}),wp.ccf.models.Field=wp.api.models.Field||wp.api.models.Post.extend({idAttribute:"ID",defaults:{ID:null},set:c,required:function(){return["slug"]},decode:function(){return n.call(this,i.keys(wp.api.models.Post.prototype.defaults))},hasRequiredAttributes:function(){var e=this,t=!0;return i.each(this.required(),function(i){(e.get(i)===void 0||""===e.get(i))&&(t=!1)}),t},sync:r}),wp.ccf.models.StandardField=wp.ccf.models.StandardField||wp.ccf.models.Field.extend({idAttribute:"ID",defaults:function(){var e={label:"Field Label",value:"",placeholder:"",slug:"",type:"",required:!1,className:"",description:""};return i.defaults(e,this.constructor.__super__.defaults)}}),wp.ccf.models.Fields["single-line-text"]=wp.ccf.models.Fields["single-line-text"]||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"single-line-text"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.file=wp.ccf.models.Fields.file||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"file",fileExtensions:"",maxFileSize:l.maxFileSize};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields["paragraph-text"]=wp.ccf.models.Fields["paragraph-text"]||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"paragraph-text"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.hidden=wp.ccf.models.Fields.hidden||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"hidden"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.email=wp.ccf.models.Fields.email||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"email",emailConfirmation:!1};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.website=wp.ccf.models.Fields.website||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"website",placeholder:"http://"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.phone=wp.ccf.models.Fields.phone||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"phone",phoneFormat:"us"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.date=wp.ccf.models.Fields.date||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"date",showDate:!0,showTime:!0};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.name=wp.ccf.models.Fields.name||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"name"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields.recaptcha=wp.ccf.models.Fields.recaptcha||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"recaptcha",siteKey:"",secretKey:""};return i.defaults(e,this.constructor.__super__.defaults())},required:function(){return["siteKey","secretKey"]},isImmutable:!0}),wp.ccf.models.Fields.address=wp.ccf.models.Fields.address||wp.ccf.models.StandardField.extend({defaults:function(){var e={type:"address",addressType:"us"};return i.defaults(e,this.constructor.__super__.defaults())}}),wp.ccf.models.Fields["section-header"]=wp.ccf.models.Fields["section-header"]||wp.ccf.models.Field.extend({defaults:function(){var e={type:"section-header",slug:"",heading:"",subheading:"",className:""};return i.defaults(e,this.constructor.__super__.defaults)},required:function(){return[]},isImmutable:!0}),wp.ccf.models.Fields.html=wp.ccf.models.Fields.html||wp.ccf.models.Field.extend({defaults:function(){var e={type:"html",slug:"",html:"",className:""};return i.defaults(e,this.constructor.__super__.defaults)},required:function(){return[]},isImmutable:!0}),wp.ccf.models.ChoiceableField=wp.ccf.models.ChoiceableField||wp.ccf.models.StandardField.extend({defaults:function(){var e={choices:new wp.ccf.collections.FieldChoices};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(e){if("object"==typeof e&&e.choices){var t=[];i.each(e.choices,function(e){var i=new wp.ccf.models.FieldChoice(e);i.decode(),t.push(i)}),this.set("choices",new wp.ccf.collections.FieldChoices(t))}}}),wp.ccf.models.Fields.radio=wp.ccf.models.Fields.radio||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"radio"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}}),wp.ccf.models.Fields.checkboxes=wp.ccf.models.Fields.checkboxes||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"checkboxes"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}}),wp.ccf.models.Fields.dropdown=wp.ccf.models.Fields.dropdown||wp.ccf.models.ChoiceableField.extend({defaults:function(){var e={type:"dropdown"};return i.defaults(e,this.constructor.__super__.defaults())},initialize:function(){return this.constructor.__super__.initialize.apply(this,arguments)}})}(jQuery,Backbone,_,ccfSettings,WP_API_Settings),function(e,t,i){"use strict";var l=function(e,t,i){return i=i||{},i.emulateHTTP=!0,this.constructor.__super__.sync.call(this,e,t,i)};wp.ccf.collections=wp.ccf.collections||{},wp.ccf.collections.Forms=wp.ccf.collections.Forms||wp.api.collections.Posts.extend({model:wp.ccf.models.Form,url:WP_API_Settings.root+"/ccf/forms",formsFetching:{},initialize:function(){this.constructor.__super__.initialize(),this.formsFetching={}},sync:l,remove:function(e,t){t=t||{};var l=this.constructor.__super__.remove.call(this,e,t);return t.destroy&&(e instanceof Array?i.each(e,function(e){e.destroy()}):e.destroy()),l}}),wp.ccf.collections.Fields=wp.ccf.collections.Fields||wp.api.collections.Posts.extend({model:wp.ccf.models.Field,url:function(){return WP_API_Settings.root+"/ccf/forms/"+this.formId+"/fields"},initialize:function(e,t){t&&t.formId&&(this.formId=t.formId)},sync:l}),wp.ccf.collections.Submissions=wp.ccf.collections.Submissions||wp.api.collections.Posts.extend({model:wp.ccf.models.Submission,url:function(){return WP_API_Settings.root+"/ccf/forms/"+this.formId+"/submissions"},initialize:function(e,t){this.constructor.__super__.initialize.apply(this,arguments),t&&t.formId&&(this.formId=t.formId)},sync:l}),wp.ccf.collections.FieldChoices=wp.ccf.collections.FieldChoices||t.Collection.extend({model:wp.ccf.models.FieldChoice})}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l){"use strict";wp.ccf.views=wp.ccf.views||{},wp.ccf.views.Fields=wp.ccf.views.Fields||{},wp.ccf.views.FieldChoice=t.View.extend({template:wp.ccf.utils.template("ccf-field-choice-template"),className:"choice",events:{"click .add":"triggerAdd","click .delete":"triggerDelete","blur input":"saveChoice",saveChoice:"saveChoice",sorted:"triggerUpdateSort"},initialize:function(e){this.field=e.field},destroy:function(){wp.ccf.dispatcher.off("mainViewChange",this.saveChoice),this.unbind()},triggerUpdateSort:function(e,t){this.field.get("choices").remove(this.model,{silent:!0}),this.field.get("choices").add(this.model,{at:t,silent:!0})},saveChoice:function(){if(""!==this.el.innerHTML){var e=this.el.querySelectorAll(".choice-label")[0].value,t=this.el.querySelectorAll(".choice-value")[0].value;this.model.set("label",e),this.model.set("value",t);var i=this.el.querySelectorAll(".choice-selected")[0],l=i.checked?!0:!1;return this.model.set("selected",l),this}},render:function(){var e={};return this.model&&(e.choice=this.model.toJSON()),this.el.innerHTML=this.template(e),wp.ccf.dispatcher.on("mainViewChange",this.saveChoice,this),this},triggerAdd:function(){this.field.get("choices").add(new wp.ccf.models.FieldChoice)},triggerDelete:function(){var e=this.field.get("choices");if(e.length>1)e.remove(this.model),this.destroy(),this.remove();else{for(var t=this.el.querySelectorAll(".choice-label, .choice-value"),i=this.el.querySelectorAll(".choice-selected"),l=0;t.length>l;l++)t[l].value="";i[0].checked=!1}}}),wp.ccf.views.FieldBase=wp.ccf.views.FieldBase||t.View.extend({events:{"blur input":"saveField","blur input.field-slug":"checkSlug","blur textarea":"saveField","change select":"saveField",'change input[type="checkbox"]':"saveField"},checkSlug:function(){var e=this.el.querySelectorAll(".field-slug");if(e.length>0){var t=e[0],i=!1;t.parentNode.className=t.value&&!t.value.match(/^[a-zA-Z0-9\-_]+$/)?t.parentNode.className.replace(/ field-error/i,"")+" field-error":t.parentNode.className.replace(/ field-error/i,""),this.collection.length>0&&""!==t.value?(this.collection.each(function(e){e!==this.model&&t.value===e.get("slug")&&(i=!0)},this),t.parentNode.className=i?t.parentNode.className.replace(/ field-duplicate-slug/i,"")+" field-duplicate-slug":t.parentNode.className.replace(/ field-duplicate-slug/i,"")):t.parentNode.className=t.parentNode.className.replace(/ field-duplicate-slug/i,"")}},destroy:function(){this.unbind()},render:function(){return this.el.innerHTML=this.template({field:this.model.toJSON()}),this.checkSlug(),this}}),wp.ccf.views.Fields["single-line-text"]=wp.ccf.views.Fields["single-line-text"]||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-single-line-text-template"),initialize:function(){},saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.file=wp.ccf.views.Fields.file||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-file-template"),initialize:function(){},saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this.model.set("fileExtensions",this.el.querySelectorAll(".field-file-extensions")[0].value),this.model.set("maxFileSize",this.el.querySelectorAll(".field-max-file-size")[0].value),this):void 0}}),wp.ccf.views.Fields.recaptcha=wp.ccf.views.Fields.recaptcha||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-recaptcha-template"),initialize:function(){},saveField:function(){return""!==this.el.innerHTML?(this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("siteKey",this.el.querySelectorAll(".field-site-key")[0].value),this.model.set("secretKey",this.el.querySelectorAll(".field-secret-key")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this):void 0}}),wp.ccf.views.Fields["section-header"]=wp.ccf.views.Fields["section-header"]||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-section-header-template"),initialize:function(){},saveField:function(){return""!==this.el.innerHTML?(this.model.set("heading",this.el.querySelectorAll(".field-heading")[0].value),this.model.set("subheading",this.el.querySelectorAll(".field-subheading")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this):void 0}}),wp.ccf.views.Fields.html=wp.ccf.views.Fields.html||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-html-template"),initialize:function(){},saveField:function(){return""!==this.el.innerHTML?(this.model.set("html",this.el.querySelectorAll(".field-html")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this):void 0}}),wp.ccf.views.Fields["paragraph-text"]=wp.ccf.views.Fields["paragraph-text"]||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-paragraph-text-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.hidden=wp.ccf.views.Fields.hidden||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-hidden-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this):void 0}}),wp.ccf.views.Fields.date=wp.ccf.views.Fields.date||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-date-template"),saveField:function(){if(""!==this.el.innerHTML){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value);var e=this.el.querySelectorAll(".field-value");e.length>0&&this.model.set("value",e[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("showDate",this.el.querySelectorAll(".field-show-date")[0].checked?!0:!1);var t=this.model.get("showTime"),i=this.el.querySelectorAll(".field-show-time")[0].checked?!0:!1;return this.model.set("showTime",i),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),i!=t&&this.render(),this}}}),wp.ccf.views.Fields.name=wp.ccf.views.Fields.name||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-name-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.website=wp.ccf.views.Fields.website||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-website-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.phone=wp.ccf.views.Fields.phone||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-phone-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("value",this.el.querySelectorAll(".field-value")[0].value),this.model.set("placeholder",this.el.querySelectorAll(".field-placeholder")[0].value),this.model.set("phoneFormat",this.el.querySelectorAll(".field-phone-format")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.address=wp.ccf.views.Fields.address||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-address-template"),saveField:function(){return""!==this.el.innerHTML?(this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("addressType",this.el.querySelectorAll(".field-address-type")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1),this):void 0}}),wp.ccf.views.Fields.email=wp.ccf.views.Fields.email||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-email-template"),saveField:function(){if(""!==this.el.innerHTML){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value);var e=this.el.querySelectorAll(".field-value");e.length&&this.model.set("value",e[0].value);var t=this.el.querySelectorAll(".field-placeholder");t.length&&this.model.set("placeholder",t[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1);var i=1==this.el.querySelectorAll(".field-email-confirmation")[0].value?!0:!1,l=this.model.get("emailConfirmation");return this.model.set("emailConfirmation",i),l!=i&&this.render(),this}}}),wp.ccf.views.ChoiceableField=wp.ccf.views.ChoiceableField||wp.ccf.views.FieldBase.extend({template:wp.ccf.utils.template("ccf-dropdown-template"),initialize:function(){var e=this.model.get("choices");this.listenTo(e,"add",this.addChoice)},addChoice:function(e){var t=new wp.ccf.views.FieldChoice({model:e,field:this.model}).render(),i=this.el.querySelectorAll(".repeatable-choices")[0];i.appendChild(t.el)},saveField:function(){if(""!==this.el.innerHTML){this.model.set("slug",this.el.querySelectorAll(".field-slug")[0].value),this.model.set("label",this.el.querySelectorAll(".field-label")[0].value),this.model.set("description",this.el.querySelectorAll(".field-description")[0].value),this.model.set("className",this.el.querySelectorAll(".field-class-name")[0].value),this.model.set("required",1==this.el.querySelectorAll(".field-required")[0].value?!0:!1);var t=this.el.querySelectorAll(".repeatable-choices")[0].querySelectorAll(".choice");return i.each(t,function(t){e(t).trigger("saveChoice")}),this}},render:function(){var t=this;t.el.innerHTML=t.template({field:t.model.toJSON()}),t.checkSlug();var i=t.model.get("choices"),l=this.el.querySelectorAll(".repeatable-choices")[0];if(i.length>=1)i.each(function(e){var i=new wp.ccf.views.FieldChoice({model:e,field:t.model}).render();l.appendChild(i.el)});else{var s=new wp.ccf.models.FieldChoice;i.add(s)}return l=this.el.querySelectorAll(".repeatable-choices")[0],e(l).sortable({handle:".move",axis:"y",stop:function(e,t){t.item.trigger("sorted",t.item.index())}}),t}}),wp.ccf.views.Fields.dropdown=wp.ccf.views.Fields.dropdown||wp.ccf.views.ChoiceableField.extend({template:wp.ccf.utils.template("ccf-dropdown-template"),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.Fields.radio=wp.ccf.views.Fields.radio||wp.ccf.views.ChoiceableField.extend({template:wp.ccf.utils.template("ccf-radio-template"),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.Fields.checkboxes=wp.ccf.views.Fields.checkboxes||wp.ccf.views.ChoiceableField.extend({template:wp.ccf.utils.template("ccf-checkboxes-template"),events:function(){return this.constructor.__super__.events}}),wp.ccf.views.FieldSidebar=wp.ccf.views.FieldSidebar||t.View.extend({initialize:function(e){this.currentFieldView=null,this.form=e.form},save:function(e){this.currentFieldView&&""!==this.currentFieldView.el.innerHTML&&this.currentFieldView.saveField(),e&&e instanceof Object&&e.resolve()},fieldRemoved:function(){this.currentFieldView&&(this.form.get("fields").get(this.currentFieldView.model)||this.render())},destroy:function(){wp.ccf.dispatcher.off("saveField",this.save),wp.ccf.dispatcher.off("mainViewChange",this.save),this.unbind()},render:function(e){var t={};if(e){var i=e.get("type");this.currentFieldView&&(this.currentFieldView.saveField(),this.currentFieldView.destroy&&this.currentFieldView.destroy()),this.currentFieldView=new wp.ccf.views.Fields[i]({model:e,collection:this.form.get("fields")}),this.currentFieldView.render(),this.el.innerHTML="",this.el.appendChild(this.currentFieldView.el);var l=this.form.get("fields");this.listenTo(l,"remove",this.fieldRemoved)}else{var s=wp.ccf.utils.template("ccf-empty-field-template");this.el.innerHTML=s(t)}return wp.ccf.dispatcher.on("saveField",this.save,this),wp.ccf.dispatcher.on("mainViewChange",this.save,this),this}}),wp.ccf.views.FieldRowPlaceholder=wp.ccf.views.FieldRowPlaceholder||t.View.extend({template:wp.ccf.utils.template("ccf-field-row-template"),tagName:"div",className:"field",initialize:function(e){this.type=e.type},render:function(){return this.el.innerHTML=this.template({label:l.allLabels[this.type]}),this.el.setAttribute("data-field-type",this.type),this.el.className+=" "+this.type,this}}),wp.ccf.views.FieldRow=wp.ccf.views.FieldRow||t.View.extend({template:wp.ccf.utils.template("ccf-field-row-template"),tagName:"div",className:"field",events:{"click .delete":"triggerDelete","click h4":"triggerEdit",sorted:"triggerUpdateSort"},initialize:function(e){i.bindAll(this,"triggerDelete"),this.form=e.form,this.listenTo(this.model,"change",this.handleChange,this),this.listenTo(this.model,"requirementsNotMet",this.requirementsNotMet,this),this.listenTo(this.model,"requirementsMet",this.requirementsMet,this),this.listenTo(this.model,"duplicateSlug",this.duplicateSlug,this),this.model.attributes.choices&&this.listenTo(this.model.attributes.choices,"change",this.handleChange,this)},duplicateSlug:function(){this.requirementsMet(),this.el.className+=" field-duplicate-slug"},requirementsNotMet:function(){this.requirementsMet(),this.el.className+=" field-incomplete"},requirementsMet:function(){this.el.className=this.el.className.replace(/(field-incomplete|field-duplicate-slug)/i,"")},triggerUpdateSort:function(e,t){this.form.get("fields").remove(this.model),this.form.get("fields").add(this.model,{at:t})},handleChange:function(){this.render()},triggerDelete:function(e){e.stopPropagation(),this.form.get("fields").remove(this.model),this.undelegateEvents(),this.remove()},triggerEdit:function(){var e=this.el.parentNode.querySelectorAll(".ccf-editing");i.each(e,function(e){e.className=e.className.replace(/ccf-editing/i,"")}),this.el.className=this.el.className.replace(/ccf-editing/i,"")+" ccf-editing",wp.ccf.dispatcher.trigger("openEditField",this.model)},render:function(e){this.el.innerHTML=this.template({label:l.allLabels[this.model.get("type")]}),this.el.setAttribute("data-field-type",this.model.get("type"));var t=RegExp(" "+this.model.get("type"),"i");this.el.className=this.el.className.replace(t,"")+" "+this.model.get("type"),e&&(this.el.className=this.el.className.replace(/ instantiated/i,"")+" instantiated");var i=document.getElementById("ccf-"+this.model.get("type")+"-preview-template");if(i){var s=this.el.querySelectorAll(".preview")[0];s.style.display="block",s.innerHTML=wp.ccf.utils.template("ccf-"+this.model.get("type")+"-preview-template")({field:this.model.toJSON()})}return this}}),wp.ccf.views.FormSettings=wp.ccf.views.FormSettings||t.View.extend({template:wp.ccf.utils.template("ccf-form-settings-template"),events:{"blur input":"save","change select":"save","change select.form-completion-action-type":"toggleCompletionFields","change select.form-send-email-notifications":"toggleNotificationFields"},initialize:function(e){this.model=e.form},destroy:function(){wp.ccf.dispatcher.off("saveFormSettings",this.save),wp.ccf.dispatcher.off("mainViewChange",this.save)},toggleCompletionFields:function(){var e=this.el.querySelectorAll(".form-completion-action-type")[0].value,t=this.el.querySelectorAll(".completion-message")[0],i=this.el.querySelectorAll(".completion-redirect-url")[0];"text"===e?(t.style.display="block",i.style.display="none"):(t.style.display="none",i.style.display="block")},save:function(e){if(""!==this.el.innerHTML){var t=this.el.querySelectorAll(".form-title")[0].value;this.model.set("title",t);var i=this.el.querySelectorAll(".form-description")[0].value;this.model.set("description",i);var l=this.el.querySelectorAll(".form-button-text")[0].value;this.model.set("buttonText",l);var s=this.el.querySelectorAll(".form-completion-message")[0].value;this.model.set("completionMessage",s);var c=this.el.querySelectorAll(".form-completion-redirect-url")[0].value;this.model.set("completionRedirectUrl",c);var r=this.el.querySelectorAll(".form-completion-action-type")[0].value;this.model.set("completionActionType",r),e!==void 0&&e.promise!==void 0&&e.resolve()}},render:function(){var e={form:this.model.toJSON()};return this.el.innerHTML=this.template(e),this.toggleCompletionFields(),wp.ccf.dispatcher.on("saveFormSettings",this.save,this),wp.ccf.dispatcher.on("mainViewChange",this.save,this),this}}),wp.ccf.views.FormNotifications=wp.ccf.views.FormNotifications||t.View.extend({template:wp.ccf.utils.template("ccf-form-notifications-template"),events:{"blur input":"save","change select":"save","change select.form-send-email-notifications":"toggleNotificationFields","change select.form-email-notification-from-type":"toggleNotificationFields"},initialize:function(e){this.model=e.form
2
+ },destroy:function(){wp.ccf.dispatcher.off("saveFormNotifications",this.save),wp.ccf.dispatcher.off("mainViewChange",this.save),this.undelegateEvents(),this.unbind()},updateFromAddressFieldField:function(){var e=this.el.querySelectorAll(".form-email-notification-from-field")[0];e.innerHTML="",e.disabled=!1;var t=this.model.get("fields"),i=0,s=this.model.get("emailNotificationFromField");if(t.length>=1&&t.each(function(t){if("email"===t.get("type")){var l=document.createElement("option");l.innerHTML=t.get("slug"),l.value=t.get("slug"),t.get("slug")===s&&(l.selected=!0),e.appendChild(l),i++}}),0===i){var c=document.createElement("option");c.innerHTML=l.noEmailFields,e.appendChild(c),e.disabled=!0}},toggleNotificationFields:function(){var e,t=this.el.querySelectorAll(".form-send-email-notifications")[0].value,i=this.el.querySelectorAll(".email-notification-setting"),l=this.el.querySelectorAll(".email-notification-from-address")[0],s=this.el.querySelectorAll(".email-notification-from-field")[0],c=this.el.querySelectorAll(".form-email-notification-from-type")[0];if(parseInt(t)){for(e=0;i.length>e;e++)i[e].style.display="block";l.style.display="none",s.style.display="none","custom"===c.value?l.style.display="block":"field"===c.value&&(s.style.display="block")}else{for(e=0;i.length>e;e++)i[e].style.display="none";l.style.display="none",s.style.display="none"}},save:function(e){if(""!==this.el.innerHTML){var t=this.el.querySelectorAll(".form-send-email-notifications")[0].value;this.model.set("sendEmailNotifications",parseInt(t)?!0:!1);var i=this.el.querySelectorAll(".form-email-notification-addresses")[0].value;this.model.set("emailNotificationAddresses",i);var l=this.el.querySelectorAll(".form-email-notification-from-type")[0].value;this.model.set("emailNotificationFromType",l);var s=this.el.querySelectorAll(".form-email-notification-from-address")[0].value;this.model.set("emailNotificationFromAddress",s);var c=this.el.querySelectorAll(".form-email-notification-from-field")[0].value;this.model.set("emailNotificationFromField",c),e!==void 0&&e.promise!==void 0&&e.resolve()}},render:function(){var e={form:this.model.toJSON()},t=this.model.get("fields");return this.el.innerHTML=this.template(e),this.toggleNotificationFields(),this.updateFromAddressFieldField(),wp.ccf.dispatcher.on("saveFormNotifications",this.save,this),wp.ccf.dispatcher.on("mainViewChange",this.save,this),this.listenTo(t,"add",this.updateFromAddressFieldField,this),this.listenTo(t,"remove",this.updateFromAddressFieldField,this),this}}),wp.ccf.views.FormPane=wp.ccf.views.FormPane||t.View.extend(i.defaults({template:wp.ccf.utils.template("ccf-form-pane-template"),subViews:{"field-sidebar":wp.ccf.views.FieldSidebar,"form-settings":wp.ccf.views.FormSettings,"form-notifications":wp.ccf.views.FormNotifications},events:{"click .save-button":"sync","click h2":"accordionClick","click .insert-form-button":"insertForm"},initialize:function(){wp.ccf.dispatcher.on("openEditField",this.openEditField,this)},insertForm:function(){wp.ccf.utils.insertFormShortcode(this.model),wp.ccf.toggle()},accordionClick:function(t){var l=e(t.currentTarget).parents(".accordion-container")[0],s=l.querySelectorAll(".accordion-section");t.currentTarget.parentNode.className.match(/expanded/i)?t.currentTarget.parentNode.className=t.currentTarget.parentNode.className.replace(/expanded/i,""):t.currentTarget.parentNode.className+=" expanded",i.each(s,function(e){e!=t.currentTarget.parentNode&&e.className.match(/expanded/i)&&(e.className=e.className.replace(/expanded/i,""))})},openEditField:function(e){this.renderedSubViews["field-sidebar"].render(e).el.style.display="block"},disable:function(){this.el.querySelectorAll(".save-button")[0].setAttribute("disabled","disabled"),this.el.querySelectorAll(".disabled-overlay")[0].style.display="block"},enable:function(){this.el.querySelectorAll(".save-button")[0].removeAttribute("disabled"),this.el.querySelectorAll(".disabled-overlay")[0].style.display="none"},sync:function(){var t=this,i=e(this.el.querySelectorAll(".spinner")[0]);i.fadeIn(),t.disable();var s=e.Deferred(),c=e.Deferred(),r=e.Deferred();wp.ccf.dispatcher.trigger("saveFormSettings",s),wp.ccf.dispatcher.trigger("saveFormNotifications",r),wp.ccf.dispatcher.trigger("saveField",c),e.when(s,c,r).then(function(){var e=t.model.get("fields"),s=!0,c={};e.each(function(e){var t=e.get("slug");e.hasRequiredAttributes()?t&&!t.match(/^[a-zA-Z0-9\-_]+$/)?(s=!1,e.trigger("requirementsNotMet")):c[e.get("slug")]!==void 0?(s=!1,e.trigger("duplicateSlug"),c[e.get("slug")].trigger("duplicateSlug")):e.trigger("requirementsMet"):(s=!1,e.trigger("requirementsNotMet")),e.get("slug")&&(c[e.get("slug")]=e)}),s?t.model.save({},{context:"edit"}).error(function(){var e="sync";wp.ccf.errorModal.render(e).show()}).done(function(){l.single&&!l.postId&&(window.location=l.adminUrl+"post.php?post="+t.model.get("ID")+"&action=edit#ccf-form/"+t.model.get("ID"))}).complete(function(){i.fadeOut(),t.enable(),wp.ccf.dispatcher.trigger("saveFormComplete",t.model)}):(t.enable(),i.fadeOut())})},enableDisableInsert:function(){var e=this.el.querySelectorAll(".insert-form-button")[0];this.model.get("ID")?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled")},getNextFieldOrd:function(){var e=this.model.get("fields"),t=e.length+1;return e.each(function(e){var i=e.get("slug"),l=/\-([0-9]+)$/g,s=l.exec(i);if(s&&s[1]){var c=parseInt(s[1]);c>=t&&(t=c+1)}}),t},render:function(t){var s=this;s.model=t?t:new wp.ccf.models.Form,this.listenTo(s.model,"change",this.enableDisableInsert,this);var c={labels:l.fieldLabels,form:s.model.toJSON()};window.form=s.model,s.el.innerHTML=this.template(c);var r=s.el.querySelectorAll(".fields")[0];i.each(l.fieldLabels,function(e,t){r.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)});var n=s.el.querySelectorAll(".structure-fields")[0];i.each(l.structureFieldLabels,function(e,t){n.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)});var o=s.el.querySelectorAll(".special-fields")[0];i.each(l.specialFieldLabels,function(e,t){o.appendChild(new wp.ccf.views.FieldRowPlaceholder({type:t}).render().el)});var a=s.model.get("fields"),d=s.el.querySelectorAll(".form-content")[0],u=e(d);return e(s.el.querySelectorAll(".left-sidebar")[0].querySelectorAll(".field")).draggable({cursor:"move",distance:2,zIndex:160001,scroll:!1,containment:"document",appendTo:".ccf-main-modal",snap:!1,connectToSortable:".form-content",helper:function(t){var i=e(t.currentTarget),l=e('<div class="field" data-field-type="'+i.attr("data-field-type")+'"><h4>'+i.find(".label").html()+"</h4></div>");return l.css({width:u.width(),opacity:".75",height:i.height()})}}),a.length>=1&&(d.innerHTML="",a.each(function(e){var t=new wp.ccf.views.FieldRow({model:e,form:s.model}).render(!0).el;d.appendChild(t)})),e(d).sortable({axis:"y",distance:2,handle:"h4",placeholder:"field-placeholder",stop:function(e,t){if(!t.item.hasClass("instantiated")){var i=t.item.attr("data-field-type"),l={};wp.ccf.models.Fields[i].prototype.defaults().slug!==void 0&&(l.slug=i+"-"+s.getNextFieldOrd());var c=new wp.ccf.models.Fields[i](l),r=s.model.get("fields");r.add(c),new wp.ccf.views.FieldRow({model:c,el:t.item,form:s.model}).render(!0),t.item.attr("style","")}t.item.trigger("sorted",t.item.index())}}),s.initRenderSubViews(!0,!0,{form:s.model}),s.enableDisableInsert(),s}},wp.ccf.mixins.subViewable)),wp.ccf.views.ExistingFormTableRow=wp.ccf.views.ExistingFormTableRow||t.View.extend({tagName:"tr",template:wp.ccf.utils.template("ccf-existing-form-table-row-template"),events:{"click .edit":"triggerMainViewChange","click .delete":"triggerDelete","click .insert-form-button":"insertForm"},initialize:function(e){this.parent=e.parent},insertForm:function(){wp.ccf.utils.insertFormShortcode(this.model),wp.ccf.toggle()},triggerMainViewChange:function(){wp.ccf.switchToForm(this.model)},triggerDelete:function(){var e,t=this,i=t.parent.collection.state.currentPage;t.model.destroy().done(function(){e=i,e===t.parent.collection.state.totalPages&&e-1===(t.parent.collection.state.totalObjects-1)/l.postsPerPage&&e--,t.parent.showPage(e).done(function(){t.parent.renderPagination()})})},render:function(){return this.$el.html(this.template({form:this.model.toJSON(),utils:{getPrettyPostDate:wp.ccf.utils.getPrettyPostDate}})),this}}),wp.ccf.views.EmptyFormTableRow=wp.ccf.views.EmptyFormTableRow||t.View.extend({tagName:"tr",template:wp.ccf.utils.template("ccf-empty-form-table-row-template"),render:function(){return this.$el.html(this.template()),this}}),wp.ccf.views.ExistingFormTable=wp.ccf.views.ExistingFormTable||t.View.extend({template:wp.ccf.utils.template("ccf-existing-form-table-template"),initialize:function(){this.parent=arguments.parent,this.collection=new wp.ccf.collections.Forms,wp.ccf.dispatcher.on("changeFormTablePage",this.showPage,this),wp.ccf.dispatcher.on("saveFormComplete",this.render,this)},showPage:function(e){var t=this,i=this.collection.fetch({data:{page:e}});return i.error(function(){var e="sync";wp.ccf.errorModal.render(e).show()}),i.done(function(){var e=t.el.querySelectorAll(".rows")[0],i=document.createElement("tbody");i.className="rows",t.collection.length>=1?t.collection.each(function(e){var l=new wp.ccf.views.ExistingFormTableRow({model:e,parent:t}).render();i.appendChild(l.el)},t):i.appendChild((new wp.ccf.views.EmptyFormTableRow).render().el),e.parentNode.replaceChild(i,e)}),i},renderPagination:function(){var e=this.el.querySelectorAll(".ccf-pagination")[0];e.innerHTML="",this.collection.state.totalPages>1&&e.appendChild(new wp.ccf.views.Pagination({parent:this}).render(this.collection.state.totalPages,this.collection.state.currentPage).el)},render:function(){var e=this;return this.el.innerHTML=this.template(),this.el.querySelectorAll(".ccf-pagination")[0],this.showPage(1).done(function(){e.renderPagination()}),this}}),wp.ccf.views.ExistingFormPane=wp.ccf.views.ExistingFormPane||t.View.extend(i.defaults({template:wp.ccf.utils.template("ccf-existing-form-pane-template"),subViews:{"existing-form-table":wp.ccf.views.ExistingFormTable},render:function(){return this.rendered?this:(this.rendered=!0,this.el.innerHTML=this.template(),this.initRenderSubViews(!0),this)}},wp.ccf.mixins.subViewable)),wp.ccf.views.MainModal=wp.ccf.views.MainModal||t.View.extend(i.defaults({tagName:"div",className:"ccf-main-modal",template:wp.ccf.utils.template("ccf-main-modal-template"),events:{"click .close-icon":"hide","click .main-menu a":"menuClick"},subViews:{"form-pane":wp.ccf.views.FormPane},initialize:function(){l.single||(this.subViews["existing-form-pane"]=wp.ccf.views.ExistingFormPane),wp.ccf.dispatcher.on("mainViewChange",this.toggleView,this)},toggleView:function(e){this.showView(e,wp.ccf.currentForm);var t=e;"form-pane"===e&&wp.ccf.currentForm&&(t="existing-form-pane");var l=this.el.querySelectorAll(".menu-item");i.each(l,function(e){var i=e.getAttribute("data-view");e.className=i===t?e.className.replace("selected","")+" selected":e.className.replace("selected","")})},menuClick:function(e){var t=e.target.getAttribute("data-view");"form-pane"===t&&(wp.ccf.currentForm=null),wp.ccf.dispatcher.trigger("mainViewChange",t),e.preventDefault()},render:function(e){return e=e||!1,this.overlay(),this.el.innerHTML=this.template({single:e}),this.initRenderSubViews(),this.showView("form-pane",wp.ccf.currentForm,!0),this},overlay:function(){return this.overlayEl===void 0&&(this.overlayEl=document.createElement("div"),this.overlayEl.className="ccf-main-modal-overlay",document.body.appendChild(this.overlayEl)),this.overlayEl},remove:function(){return document.body.removeChild(this.overlay()),this},show:function(){e(this.overlay()).show(),this.$el.show()},hide:function(){e(this.overlay()).hide(),this.$el.hide()}},wp.ccf.mixins.subViewable)),wp.ccf.views.SubmissionRow=wp.ccf.views.SubmissionRow||t.View.extend({tagName:"tr",template:wp.ccf.utils.template("ccf-submission-row-template"),events:{"click .view":"view","click .delete":"delete"},initialize:function(e){this.parent=e.parent},"delete":function(){var e,t=this,i=t.parent.collection.state.currentPage;t.model.destroy().done(function(){e=i,e===t.parent.collection.state.totalPages&&e-1===(t.parent.collection.state.totalObjects-1)/l.postsPerPage&&e--,t.parent.showPage(e).done(function(){t.parent.renderPagination()})})},view:function(e){var t=e.currentTarget.getAttribute("data-submission-id"),i=e.currentTarget.getAttribute("data-submission-date");tb_show(l.thickboxTitle+" - "+wp.ccf.utils.getPrettyPostDate(i),"#TB_inline?height=500&amp;width=700&amp;inlineId=ccf-submission-content-"+parseInt(t),null)},render:function(){return this.$el.html(this.template({submission:this.model.toJSON(),currentColumns:this.parent.columns,columns:wp.ccf.currentForm.getFieldSlugs(!0),utils:{getPrettyPostDate:wp.ccf.utils.getPrettyPostDate,wordChop:wp.ccf.utils.wordChop,isFieldDate:wp.ccf.utils.isFieldDate,isFieldName:wp.ccf.utils.isFieldName,isFieldFile:wp.ccf.utils.isFieldFile,isFieldAddress:wp.ccf.utils.isFieldAddress,isFieldEmailConfirm:wp.ccf.utils.isFieldEmailConfirm,getPrettyFieldDate:wp.ccf.utils.getPrettyFieldDate,getPrettyFieldAddress:wp.ccf.utils.getPrettyFieldAddress,getPrettyFieldName:wp.ccf.utils.getPrettyFieldName,getPrettyFieldEmailConfirm:wp.ccf.utils.getPrettyFieldEmailConfirm}})),this}}),wp.ccf.views.SubmissionsTable=wp.ccf.views.SubmissionsTable||t.View.extend({template:wp.ccf.utils.template("ccf-submission-table-template"),events:{"click .prev:not(.disabled)":"previousPage","click .next:not(.disabled)":"nextPage","click .first:not(.disabled)":"firstPage","click .last:not(.disabled)":"lastPage"},initialize:function(){this.collection=new wp.ccf.collections.Submissions({},{formId:l.postId}),wp.ccf.dispatcher.on("submissionTableRebuild",this.render,this)},showPage:function(e){var t=this,i=this.collection.fetch({data:{page:e}});return i.error(function(){var e="sync";wp.ccf.errorModal.render(e).show()}),i.done(function(){var e=t.el.querySelectorAll(".submission-rows")[0],i=document.createElement("tbody");i.className="submission-rows",t.collection.length>=1?t.collection.each(function(e){var l=new wp.ccf.views.SubmissionRow({model:e,parent:t}).render();i.appendChild(l.el)},t):i.appendChild(new wp.ccf.views.EmptySubmissionTableRow({parent:t}).render(wp.ccf.currentForm.getFieldSlugs(!0).concat("date")).el),e.parentNode.replaceChild(i,e)}),i},renderPagination:function(){var e=this.el.querySelectorAll(".ccf-pagination")[0];e.innerHTML="",this.collection.state.totalPages>1&&e.appendChild(new wp.ccf.views.Pagination({parent:this}).render(this.collection.state.totalPages,this.collection.state.currentPage).el)},render:function(e){var t=this;return t.columns=e?e:wp.ccf.currentForm.getFieldSlugs(!0).slice(0,4).concat("date"),1>t.columns.length?t.el.innerHTML="":(t.el.innerHTML=t.template({columns:t.columns}),t.el.querySelectorAll(".ccf-pagination")[0],t.showPage(1).done(function(){t.renderPagination()})),t}}),wp.ccf.views.ErrorModal=wp.ccf.views.ErrorModal||t.View.extend({template:wp.ccf.utils.template("ccf-error-modal-template"),tagName:"div",className:"ccf-error-modal",events:{"click .close":"hide"},hide:function(){this.el.className=this.el.className.replace(" show","")},show:function(){this.el.className=this.el.className.replace(" show","")+" show"},toggle:function(){this.el.className.match(" show")?this.hide():this.show()},render:function(e){var t={messageType:""};return e&&(t.messageType=e),this.el.innerHTML=this.template(t),this}}),wp.ccf.views.Pagination=wp.ccf.views.Pagination||t.View.extend({template:wp.ccf.utils.template("ccf-pagination-template"),events:{"click .prev:not(.disabled)":"previousPage","click .next:not(.disabled)":"nextPage","click .first:not(.disabled)":"firstPage","click .last:not(.disabled)":"lastPage"},initialize:function(e){this.parent=e.parent},previousPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.currentPage-1).done(function(){e.render()})},nextPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.currentPage+1).done(function(){e.render()})},firstPage:function(){var e=this;e.parent.showPage(1).done(function(){e.render()})},lastPage:function(){var e=this;e.parent.showPage(e.parent.collection.state.totalPages).done(function(){e.render()})},render:function(){return this.el.innerHTML=this.template({totalPages:this.parent.collection.state.totalPages,currentPage:this.parent.collection.state.currentPage,totalObjects:this.parent.collection.state.totalObjects}),this}}),wp.ccf.views.EmptySubmissionTableRow=wp.ccf.views.EmptySubmissionTableRow||t.View.extend({tagName:"tr",template:wp.ccf.utils.template("ccf-no-submissions-row-template"),initialize:function(e){this.parent=e.parent},render:function(){return this.el.innerHTML=this.template({columns:this.parent.columns}),this}}),wp.ccf.views.SubmissionColumnController=wp.ccf.views.SubmissionColumnController||t.View.extend({template:wp.ccf.utils.template("ccf-submissions-controller-template"),events:{"click input[type=checkbox]":"triggerTableRebuild"},render:function(){this.el.innerHTML=this.template({columns:wp.ccf.currentForm.getFieldSlugs(!0).concat("date")})},triggerTableRebuild:function(){var e=[],t=document.querySelectorAll(".submission-column-checkbox");if(t.length>=1)for(var i=0;t.length>i;i++)t[i].checked&&e.push(t[i].value);wp.ccf.dispatcher.trigger("submissionTableRebuild",e)}})}(jQuery,Backbone,_,ccfSettings),function(e,t){"use strict";wp.ccf.router=wp.ccf.router||t.Router.extend({routes:{"ccf-form":"open","ccf-form/:formId":"open"},open:function(e){wp.ccf.show(e)}})}(jQuery,Backbone,_,ccfSettings),function(e,t,i,l){"use strict";wp.ccf=i.defaults(wp.ccf,{forms:new wp.ccf.collections.Forms,currentForm:null,errorModal:null,_currentFormDeferred:null,dispatcher:{},show:function(e){return this.switchToForm(e),this.instance.show(),this.instance},initErrorModal:function(){this.errorModal=(new wp.ccf.views.ErrorModal).render();var e=document.getElementsByTagName("body")[0];e.appendChild(this.errorModal.el)},switchToForm:function(e){var t=this;if(+e===parseInt(e)){var i=parseInt(e);if(e=t.forms.findWhere({ID:parseInt(i)}),!e){var l;return t.forms.formsFetching[i]!==void 0?(l=t.forms.formsFetching[i],e=null):(e=new wp.ccf.models.Form({ID:i}),l=e.fetch(),t.forms.formsFetching[i]=l),l.done(function(){e?(delete t.forms.formsFetching[i],t.forms.add(e)):e=t.forms.findWhere({ID:i}),t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane")}),l}t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane")}else t.currentForm=e,wp.ccf.dispatcher.trigger("mainViewChange","form-pane");return!0},hide:function(){return this.instance.hide(),this.instance},toggle:function(e){return this.switchToForm(e),this.instance.$el.is(":visible")?this.instance.hide():this.instance.show(),this.instance},createSubmissionsTable:function(e){var t=document.querySelectorAll(".ccf-submission-column-controller"),i=new wp.ccf.views.SubmissionsTable({el:e});i.render(),t&&new wp.ccf.views.SubmissionColumnController({el:t}).render()},_setupMainModal:function(e){return this.instance=(new wp.ccf.views.MainModal).render(e),document.getElementsByTagName("body")[0].appendChild(this.instance.el),t.history.start(),this.instance},createManager:function(){var s=this,c=document.querySelectorAll(".ccf-open-form-manager")[0];if(!c)return!1;i.extend(this.dispatcher,t.Events),new wp.ccf.router,s.initErrorModal();var r=!1;if(l.single)if(r=!0,l.postId){var n=parseInt(l.postId);if(s.forms.formsFetching[n]===void 0){var o=new wp.ccf.models.Form({ID:n}),a=o.fetch();s.forms.formsFetching[n]=a,s._currentFormDeferred=a,a.done(function(){delete s.forms.formsFetching[n],s.forms.add(o),s.currentForm=o})}else s._currentFormDeferred=s.forms.formsFetching[n],s._currentFormDeferred.done(function(){s.currentForm=s.forms.findWhere({ID:n})});e.when(s._currentFormDeferred).then(function(){s._setupMainModal(!0),c.style.display="inline-block";var e=document.getElementById("ccf-submissions");if(e){var t=e.querySelectorAll(".inside")[0],i=document.createElement("div");i.className="ccf-submission-icon",i.setAttribute("data-icon","");var r=document.createElement("a");r.href="?action=edit&post="+parseInt(l.postId)+"&download_submissions=1&download_submissions_nonce="+l.downloadSubmissionsNonce,r.className="ccf-submission-icon",r.setAttribute("data-icon","");var n=document.getElementById("show-settings-link");i.onclick=function(){n.click()},e.insertBefore(i,e.firstChild.nextSibling.nextSibling),e.insertBefore(r,e.firstChild.nextSibling.nextSibling),wp.ccf.createSubmissionsTable(t)}})}else s._setupMainModal(!0),c.style.display="inline-block";else s._setupMainModal();var d=function(e){e=e||window.event;var t=e.currentTarget?e.currentTarget:e.srcElement,i=t.getAttribute("data-form-id");wp.ccf.toggle(i)};c.addEventListener?c.addEventListener("click",d,!1):c.attachEvent("onclick",d)}}),wp.ccf.createManager()}(jQuery,Backbone,_,ccfSettings);
classes/class-ccf-form-cpt.php CHANGED
@@ -33,6 +33,193 @@ class CCF_Form_CPT {
33
  add_filter( 'get_the_excerpt', array( $this, 'filter_get_the_excerpt' ) );
34
  add_filter( 'screen_settings', array( $this, 'filter_screen_options' ), 10, 2 );
35
  add_action( 'before_delete_post', array( $this, 'action_before_delete_post' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
 
38
  /**
33
  add_filter( 'get_the_excerpt', array( $this, 'filter_get_the_excerpt' ) );
34
  add_filter( 'screen_settings', array( $this, 'filter_screen_options' ), 10, 2 );
35
  add_action( 'before_delete_post', array( $this, 'action_before_delete_post' ) );
36
+ add_filter( 'wp_link_query_args', array( $this, 'filter_wp_link_query_args' ) );
37
+ add_action( 'admin_init', array( $this, 'action_parse_request' ) );
38
+ }
39
+
40
+ /**
41
+ * Handle submissions csv download
42
+ *
43
+ * @since 6.6
44
+ */
45
+ public function action_parse_request() {
46
+ if ( empty( $_GET['download_submissions'] ) ) {
47
+ return;
48
+ }
49
+
50
+ if ( ! current_user_can( 'manage_options ') ) {
51
+ return;
52
+ }
53
+
54
+ if ( empty( $_GET['post'] ) || 'ccf_form' !== get_post_type( $_GET['post']) ) {
55
+ return;
56
+ }
57
+
58
+ if ( empty( $_GET['download_submissions_nonce'] ) || ! wp_verify_nonce( $_GET['download_submissions_nonce'], 'ccf_download_submissions_nonce' ) ) {
59
+ return;
60
+ }
61
+
62
+ $post_id = (int) $_GET['post'];
63
+
64
+ $submissions = new WP_Query( array(
65
+ 'post_type' => 'ccf_submission',
66
+ 'posts_per_page' => apply_filters( 'ccf_max_submissions', 5000, $post_id ),
67
+ 'no_found_rows' => true,
68
+ 'cache_results' => false,
69
+ 'fields' => 'ids',
70
+ 'order' => 'DESC',
71
+ 'orderby' => 'date',
72
+ 'post_parent' => $post_id,
73
+ ) );
74
+
75
+ // Todo: Unit tests
76
+
77
+ header( 'Content-Type: text/csv' );
78
+ header( 'Content-Disposition: attachment; filename=form-' . $post_id . '-submission-' . date( 'Y-m-d' ) . '.csv' );
79
+ header( 'Cache-Control: no-cache, no-store, must-revalidate' );
80
+ header( 'Pragma: no-cache' );
81
+ header( 'Expires: 0' );
82
+
83
+ $output = fopen( 'php://output', 'w' );
84
+ if ( $submissions->have_posts() ) {
85
+ $last_submission_id = $submissions->posts[0];
86
+
87
+ $fields = get_post_meta( $last_submission_id, 'ccf_submission_data_map', true );
88
+
89
+ if ( empty( $fields ) ) {
90
+
91
+ $slugs = array_keys( get_post_meta( $last_submission_id, 'ccf_submission_data', true ) );
92
+
93
+ $fields = array();
94
+
95
+ $attached_fields = get_post_meta( $post_id, 'ccf_attached_fields', true );
96
+ $attached_field_slugs = array();
97
+
98
+ foreach ( $attached_fields as $field_id ) {
99
+ $slug = get_post_meta( $field_id, 'ccf_field_slug', true );
100
+
101
+ if ( ! empty( $slug ) ) {
102
+ $attached_field_slugs[$slug] = $field_id;
103
+ }
104
+ }
105
+
106
+ foreach ( $slugs as $slug ) {
107
+ if ( ! empty( $attached_field_slugs[$slug] ) ) {
108
+ $fields[$slug] = array( 'id' => $attached_field_slugs[$slug], 'type' => get_post_meta( $attached_field_slugs[$slug], 'ccf_field_type', true ) );
109
+ }
110
+ }
111
+ }
112
+
113
+ $headers = array_merge( array( 'date', 'ip', ), array_keys( $fields ) );
114
+
115
+ fputcsv( $output, $headers );
116
+
117
+ foreach ( $submissions->posts as $submission_id ) {
118
+ $submission_data = get_post_meta( $submission_id, 'ccf_submission_data', true );
119
+ $submission_ip = get_post_meta( $submission_id, 'ccf_submission_ip', true );
120
+
121
+ $row = array(
122
+ get_the_time( 'Y-m-d H:i:s', $submission_id ),
123
+ sanitize_text_field( $submission_ip ),
124
+ );
125
+
126
+ foreach ( $fields as $slug => $field_array ) {
127
+ $type = $field_array['type'];
128
+
129
+ if ( ! empty( $submission_data[$slug] ) ) {
130
+ $field = $submission_data[$slug];
131
+
132
+ if ( 'date' === $type ) {
133
+
134
+ $row[] = stripslashes( CCF_Submission_CPT::factory()->get_pretty_field_date( $field ) );
135
+
136
+ } elseif ( 'name' === $type ) {
137
+
138
+ $row[] = stripslashes( CCF_Submission_CPT::factory()->get_pretty_field_name( $field ) );
139
+
140
+ } elseif ( 'file' === $type ) {
141
+
142
+ $row[] = $field['url'];
143
+
144
+ } elseif ( 'address' === $type ) {
145
+
146
+ $row[] = stripslashes( CCF_Submission_CPT::factory()->get_pretty_field_address( $field ) );
147
+
148
+ } elseif ( 'email' === $type ) {
149
+
150
+ if ( is_array( $field ) ) {
151
+ $row[] = stripslashes( $field['email'] );
152
+ } else {
153
+ $row[] = stripslashes( $field );
154
+ }
155
+
156
+ } elseif ( 'dropdown' === $type || 'radio' === $type || 'checkboxes' === $type ) {
157
+ if ( is_array( $field ) ) {
158
+ $i = 0;
159
+ $output = '';
160
+
161
+ foreach ( $field as $value ) {
162
+ if ( ! empty( $value ) ) {
163
+ if ( $i !== 0 ) {
164
+ $output .= ', ';
165
+ }
166
+
167
+ $output .= stripslashes( $value );
168
+
169
+ $i++;
170
+ }
171
+ }
172
+
173
+ if ( 0 === $i ) {
174
+ $row[] = '';
175
+ } else {
176
+ $row[] = $output;
177
+ }
178
+
179
+ } else {
180
+ $row[] = stripslashes( $field );
181
+ }
182
+
183
+ } else {
184
+ $row[] = stripslashes( $field );
185
+ }
186
+ } else {
187
+ $row[] = '';
188
+ }
189
+ }
190
+
191
+ fputcsv( $output, $row );
192
+ }
193
+
194
+ fclose( $output );
195
+ }
196
+
197
+ exit;
198
+ }
199
+
200
+ /**
201
+ * Remove CCF post types from links query
202
+ *
203
+ * @param array $query
204
+ * @since 6.5.1
205
+ * @return array
206
+ */
207
+ public function filter_wp_link_query_args( $query ) {
208
+ if ( is_array( $query ) && ! empty( $query['post_type'] ) ) {
209
+
210
+ $post_types = array();
211
+ $ccf_post_types = array( 'ccf_submission', 'ccf_form', 'ccf_field', 'ccf_choice' );
212
+
213
+ foreach ( $query['post_type'] as $post_type ) {
214
+ if ( ! in_array( $post_type, $ccf_post_types ) ) {
215
+ $post_types[] = $post_type;
216
+ }
217
+ }
218
+
219
+ $query['post_type'] = $post_types;
220
+ }
221
+
222
+ return $query;
223
  }
224
 
225
  /**
classes/class-ccf-form-handler.php CHANGED
@@ -620,8 +620,8 @@ class CCF_Form_Handler {
620
 
621
  $slug = get_post_meta( $field_id, 'ccf_field_slug', true );
622
 
623
- // We will use this later when emailing a submission
624
- $field_slug_to_id[$slug] = $field_id;
625
 
626
  $custom_value_mapping = array( 'recaptcha' => 'g-recaptcha-response' );
627
 
@@ -659,6 +659,12 @@ class CCF_Form_Handler {
659
 
660
  if ( ! is_wp_error( $submission_id ) ) {
661
  update_post_meta( $submission_id, 'ccf_submission_data', $submission );
 
 
 
 
 
 
662
  update_post_meta( $submission_id, 'ccf_submission_ip', sanitize_text_field( $_SERVER['REMOTE_ADDR'] ) );
663
 
664
  foreach ( $file_ids as $file_id ) {
@@ -690,7 +696,7 @@ class CCF_Form_Handler {
690
  ob_start();
691
 
692
  foreach ( $submission as $slug => $field ) {
693
- $field_id = $field_slug_to_id[$slug];
694
  $label = get_post_meta( $field_id, 'ccf_field_label', true );
695
  $type = get_post_meta( $field_id, 'ccf_field_type', true );
696
 
620
 
621
  $slug = get_post_meta( $field_id, 'ccf_field_slug', true );
622
 
623
+ // We save this to reference later
624
+ $field_slug_to_id[$slug] = array( 'id' => $field_id, 'type' => sanitize_text_field( $type ) );
625
 
626
  $custom_value_mapping = array( 'recaptcha' => 'g-recaptcha-response' );
627
 
659
 
660
  if ( ! is_wp_error( $submission_id ) ) {
661
  update_post_meta( $submission_id, 'ccf_submission_data', $submission );
662
+
663
+ /**
664
+ * @since 6.6
665
+ */
666
+ update_post_meta( $submission_id, 'ccf_submission_data_map', $field_slug_to_id );
667
+
668
  update_post_meta( $submission_id, 'ccf_submission_ip', sanitize_text_field( $_SERVER['REMOTE_ADDR'] ) );
669
 
670
  foreach ( $file_ids as $file_id ) {
696
  ob_start();
697
 
698
  foreach ( $submission as $slug => $field ) {
699
+ $field_id = $field_slug_to_id[$slug]['id'];
700
  $label = get_post_meta( $field_id, 'ccf_field_label', true );
701
  $type = get_post_meta( $field_id, 'ccf_field_type', true );
702
 
classes/class-ccf-form-manager.php CHANGED
@@ -1494,6 +1494,7 @@ class CCF_Form_Manager {
1494
  wp_enqueue_script( 'ccf-form-manager', plugins_url( $js_manager_path, dirname( __FILE__ ) ), array( 'json2', 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'underscore', 'backbone', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-api', 'moment' ), '1.0', true );
1495
  wp_localize_script( 'ccf-form-manager', 'ccfSettings', array(
1496
  'nonce' => wp_create_nonce( 'ccf_nonce' ),
 
1497
  'adminUrl' => esc_url_raw( admin_url() ),
1498
  'fieldLabels' => $field_labels,
1499
  'gmtOffset' => get_option( 'gmt_offset' ),
1494
  wp_enqueue_script( 'ccf-form-manager', plugins_url( $js_manager_path, dirname( __FILE__ ) ), array( 'json2', 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'underscore', 'backbone', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-api', 'moment' ), '1.0', true );
1495
  wp_localize_script( 'ccf-form-manager', 'ccfSettings', array(
1496
  'nonce' => wp_create_nonce( 'ccf_nonce' ),
1497
+ 'downloadSubmissionsNonce' => wp_create_nonce( 'ccf_download_submissions_nonce' ),
1498
  'adminUrl' => esc_url_raw( admin_url() ),
1499
  'fieldLabels' => $field_labels,
1500
  'gmtOffset' => get_option( 'gmt_offset' ),
composer.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "tlovett1/custom-contact-forms",
3
  "require": {
4
- "wp-api/wp-api": "dev-master#ad9688f450a813fd23d5c008d7d7c9fb58e76b2b"
5
  },
6
  "repositories": [
7
  {
1
  {
2
  "name": "tlovett1/custom-contact-forms",
3
  "require": {
4
+ "wp-api/wp-api": "dev-master#4e2d780432d934a912721748bcc70d89025c625c"
5
  },
6
  "repositories": [
7
  {
composer.lock CHANGED
@@ -4,7 +4,7 @@
4
  "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5
  "This file is @generated automatically"
6
  ],
7
- "hash": "1d93aaeab916629d2e1b6fd76199eb35",
8
  "packages": [
9
  {
10
  "name": "wp-api/wp-api",
@@ -12,10 +12,10 @@
12
  "source": {
13
  "type": "git",
14
  "url": "https://github.com/wp-api/wp-api",
15
- "reference": "ad9688f450a813fd23d5c008d7d7c9fb58e76b2b"
16
  },
17
  "type": "library",
18
- "time": "2014-12-19 22:28:49"
19
  }
20
  ],
21
  "packages-dev": [],
4
  "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5
  "This file is @generated automatically"
6
  ],
7
+ "hash": "976360f57efd5dd53b0f99e3cd2fca0d",
8
  "packages": [
9
  {
10
  "name": "wp-api/wp-api",
12
  "source": {
13
  "type": "git",
14
  "url": "https://github.com/wp-api/wp-api",
15
+ "reference": "4e2d780432d934a912721748bcc70d89025c625c"
16
  },
17
  "type": "library",
18
+ "time": "2015-03-21 17:03:04"
19
  }
20
  ],
21
  "packages-dev": [],
custom-contact-forms.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://www.taylorlovett.com
5
  * Description: Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
6
  * Author: Taylor Lovett
7
- * Version: 6.5.1
8
  * Author URI: http://www.taylorlovett.com
9
  */
10
 
4
  * Plugin URI: http://www.taylorlovett.com
5
  * Description: Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
6
  * Author: Taylor Lovett
7
+ * Version: 6.6
8
  * Author URI: http://www.taylorlovett.com
9
  */
10
 
fonts/form-manager.eot CHANGED
Binary file
fonts/form-manager.svg CHANGED
@@ -17,4 +17,5 @@
17
  <glyph unicode="&#xe607;" d="M747.52 665.549l-471.040 0.051 235.52-409.6z" />
18
  <glyph unicode="&#xe608;" d="M307.251 696.32l-0.051-471.040 409.6 235.52z" />
19
  <glyph unicode="&#xe994;" d="M933.79 349.75c-53.726 93.054-21.416 212.304 72.152 266.488l-100.626 174.292c-28.75-16.854-62.176-26.518-97.846-26.518-107.536 0-194.708 87.746-194.708 195.99h-201.258c0.266-33.41-8.074-67.282-25.958-98.252-53.724-93.056-173.156-124.702-266.862-70.758l-100.624-174.292c28.97-16.472 54.050-40.588 71.886-71.478 53.638-92.908 21.512-211.92-71.708-266.224l100.626-174.292c28.65 16.696 61.916 26.254 97.4 26.254 107.196 0 194.144-87.192 194.7-194.958h201.254c-0.086 33.074 8.272 66.57 25.966 97.218 53.636 92.906 172.776 124.594 266.414 71.012l100.626 174.29c-28.78 16.466-53.692 40.498-71.434 71.228zM512 240.668c-114.508 0-207.336 92.824-207.336 207.334 0 114.508 92.826 207.334 207.336 207.334 114.508 0 207.332-92.826 207.332-207.334-0.002-114.51-92.824-207.334-207.332-207.334z" />
 
20
  </font></defs></svg>
17
  <glyph unicode="&#xe607;" d="M747.52 665.549l-471.040 0.051 235.52-409.6z" />
18
  <glyph unicode="&#xe608;" d="M307.251 696.32l-0.051-471.040 409.6 235.52z" />
19
  <glyph unicode="&#xe994;" d="M933.79 349.75c-53.726 93.054-21.416 212.304 72.152 266.488l-100.626 174.292c-28.75-16.854-62.176-26.518-97.846-26.518-107.536 0-194.708 87.746-194.708 195.99h-201.258c0.266-33.41-8.074-67.282-25.958-98.252-53.724-93.056-173.156-124.702-266.862-70.758l-100.624-174.292c28.97-16.472 54.050-40.588 71.886-71.478 53.638-92.908 21.512-211.92-71.708-266.224l100.626-174.292c28.65 16.696 61.916 26.254 97.4 26.254 107.196 0 194.144-87.192 194.7-194.958h201.254c-0.086 33.074 8.272 66.57 25.966 97.218 53.636 92.906 172.776 124.594 266.414 71.012l100.626 174.29c-28.78 16.466-53.692 40.498-71.434 71.228zM512 240.668c-114.508 0-207.336 92.824-207.336 207.334 0 114.508 92.826 207.334 207.336 207.334 114.508 0 207.332-92.826 207.332-207.334-0.002-114.51-92.824-207.334-207.332-207.334z" />
20
+ <glyph unicode="&#xe9c7;" d="M736 512l-256-256-256 256h160v384h192v-384zM480 256h-480v-256h960v256h-480zM896 128h-128v64h128v-64z" />
21
  </font></defs></svg>
fonts/form-manager.ttf CHANGED
Binary file
fonts/form-manager.woff CHANGED
Binary file
fonts/icomoon.json ADDED
@@ -0,0 +1,325 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "IcoMoonType": "selection",
3
+ "icons": [
4
+ {
5
+ "icon": {
6
+ "paths": [
7
+ "M736 448l-256 256-256-256h160v-384h192v384zM480 704h-480v256h960v-256h-480zM896 832h-128v-64h128v64z"
8
+ ],
9
+ "attrs": [],
10
+ "isMulticolor": false,
11
+ "tags": [
12
+ "download",
13
+ "save",
14
+ "store"
15
+ ],
16
+ "defaultCode": 58048,
17
+ "grid": 16
18
+ },
19
+ "attrs": [],
20
+ "properties": {
21
+ "id": 798,
22
+ "order": 11,
23
+ "prevSize": 32,
24
+ "code": 59847,
25
+ "ligatures": "download3, save5",
26
+ "name": "download3"
27
+ },
28
+ "setIdx": 0,
29
+ "setId": 2,
30
+ "iconIdx": 199
31
+ },
32
+ {
33
+ "icon": {
34
+ "paths": [
35
+ "M933.79 610.25c-53.726-93.054-21.416-212.304 72.152-266.488l-100.626-174.292c-28.75 16.854-62.176 26.518-97.846 26.518-107.536 0-194.708-87.746-194.708-195.99h-201.258c0.266 33.41-8.074 67.282-25.958 98.252-53.724 93.056-173.156 124.702-266.862 70.758l-100.624 174.292c28.97 16.472 54.050 40.588 71.886 71.478 53.638 92.908 21.512 211.92-71.708 266.224l100.626 174.292c28.65-16.696 61.916-26.254 97.4-26.254 107.196 0 194.144 87.192 194.7 194.958h201.254c-0.086-33.074 8.272-66.57 25.966-97.218 53.636-92.906 172.776-124.594 266.414-71.012l100.626-174.29c-28.78-16.466-53.692-40.498-71.434-71.228zM512 719.332c-114.508 0-207.336-92.824-207.336-207.334 0-114.508 92.826-207.334 207.336-207.334 114.508 0 207.332 92.826 207.332 207.334-0.002 114.51-92.824 207.334-207.332 207.334z"
36
+ ],
37
+ "attrs": [],
38
+ "tags": [
39
+ "cog",
40
+ "gear",
41
+ "preferences",
42
+ "settings",
43
+ "generate",
44
+ "control",
45
+ "options"
46
+ ],
47
+ "defaultCode": 57823,
48
+ "grid": 16
49
+ },
50
+ "attrs": [],
51
+ "properties": {
52
+ "id": 569,
53
+ "order": 10,
54
+ "prevSize": 32,
55
+ "code": 59796,
56
+ "ligatures": "cog, gear",
57
+ "name": "cog"
58
+ },
59
+ "setIdx": 1,
60
+ "setId": 1,
61
+ "iconIdx": 0
62
+ },
63
+ {
64
+ "icon": {
65
+ "paths": [
66
+ "M864 0c88.364 0 160 71.634 160 160 0 36.020-11.91 69.258-32 96l-64 64-224-224 64-64c26.742-20.090 59.978-32 96-32zM64 736l-64 288 288-64 592-592-224-224-592 592zM715.578 363.578l-448 448-55.156-55.156 448-448 55.156 55.156z"
67
+ ],
68
+ "tags": [
69
+ "pencil",
70
+ "write",
71
+ "edit",
72
+ "blog",
73
+ "note"
74
+ ],
75
+ "grid": 16
76
+ },
77
+ "properties": {
78
+ "id": 5,
79
+ "order": 5,
80
+ "prevSize": 32,
81
+ "name": "pencil",
82
+ "code": 58880
83
+ },
84
+ "setIdx": 1,
85
+ "setId": 1,
86
+ "iconIdx": 1
87
+ },
88
+ {
89
+ "icon": {
90
+ "paths": [
91
+ "M512 192c-223.318 0-416.882 130.042-512 320 95.118 189.958 288.682 320 512 320 223.314 0 416.878-130.042 512-320-95.116-189.958-288.686-320-512-320zM764.45 361.704c60.162 38.374 111.142 89.774 149.434 150.296-38.292 60.522-89.274 111.922-149.436 150.298-75.594 48.216-162.89 73.702-252.448 73.702-89.56 0-176.856-25.486-252.45-73.704-60.16-38.372-111.14-89.772-149.434-150.296 38.292-60.524 89.274-111.924 149.434-150.296 3.918-2.5 7.876-4.922 11.858-7.3-9.958 27.328-15.408 56.822-15.408 87.596 0 141.384 114.616 256 256 256s256-114.616 256-256c0-30.774-5.45-60.268-15.408-87.598 3.98 2.378 7.938 4.802 11.858 7.302zM512 410c0 53.020-42.98 96-96 96s-96-42.98-96-96 42.98-96 96-96 96 42.98 96 96z"
92
+ ],
93
+ "tags": [
94
+ "eye",
95
+ "views",
96
+ "vision",
97
+ "visit"
98
+ ],
99
+ "grid": 16
100
+ },
101
+ "properties": {
102
+ "id": 198,
103
+ "order": 9,
104
+ "prevSize": 32,
105
+ "code": 58881,
106
+ "name": "eye"
107
+ },
108
+ "setIdx": 1,
109
+ "setId": 1,
110
+ "iconIdx": 2
111
+ },
112
+ {
113
+ "icon": {
114
+ "paths": [
115
+ "M1014.662 822.66c-0.004-0.004-0.008-0.008-0.012-0.010l-310.644-310.65 310.644-310.65c0.004-0.004 0.008-0.006 0.012-0.010 3.344-3.346 5.762-7.254 7.312-11.416 4.246-11.376 1.824-24.682-7.324-33.83l-146.746-146.746c-9.148-9.146-22.45-11.566-33.828-7.32-4.16 1.55-8.070 3.968-11.418 7.31 0 0.004-0.004 0.006-0.008 0.010l-310.648 310.652-310.648-310.65c-0.004-0.004-0.006-0.006-0.010-0.010-3.346-3.342-7.254-5.76-11.414-7.31-11.38-4.248-24.682-1.826-33.83 7.32l-146.748 146.748c-9.148 9.148-11.568 22.452-7.322 33.828 1.552 4.16 3.97 8.072 7.312 11.416 0.004 0.002 0.006 0.006 0.010 0.010l310.65 310.648-310.65 310.652c-0.002 0.004-0.006 0.006-0.008 0.010-3.342 3.346-5.76 7.254-7.314 11.414-4.248 11.376-1.826 24.682 7.322 33.83l146.748 146.746c9.15 9.148 22.452 11.568 33.83 7.322 4.16-1.552 8.070-3.97 11.416-7.312 0.002-0.004 0.006-0.006 0.010-0.010l310.648-310.65 310.648 310.65c0.004 0.002 0.008 0.006 0.012 0.008 3.348 3.344 7.254 5.762 11.414 7.314 11.378 4.246 24.684 1.826 33.828-7.322l146.746-146.748c9.148-9.148 11.57-22.454 7.324-33.83-1.552-4.16-3.97-8.068-7.314-11.414z"
116
+ ],
117
+ "tags": [
118
+ "close",
119
+ "cancel",
120
+ "quit",
121
+ "remove",
122
+ "cross"
123
+ ],
124
+ "grid": 16
125
+ },
126
+ "properties": {
127
+ "id": 253,
128
+ "order": 4,
129
+ "prevSize": 32,
130
+ "name": "close",
131
+ "code": 58882
132
+ },
133
+ "setIdx": 1,
134
+ "setId": 1,
135
+ "iconIdx": 3
136
+ },
137
+ {
138
+ "icon": {
139
+ "paths": [
140
+ "M864 128l-480 480-224-224-160 160 384 384 640-640z"
141
+ ],
142
+ "tags": [
143
+ "checkmark",
144
+ "tick",
145
+ "correct",
146
+ "accept",
147
+ "ok"
148
+ ],
149
+ "grid": 16
150
+ },
151
+ "properties": {
152
+ "id": 254,
153
+ "order": 3,
154
+ "prevSize": 32,
155
+ "name": "checkmark",
156
+ "code": 58883
157
+ },
158
+ "setIdx": 1,
159
+ "setId": 1,
160
+ "iconIdx": 4
161
+ },
162
+ {
163
+ "icon": {
164
+ "paths": [
165
+ "M0 416v192c0 17.672 14.328 32 32 32h960c17.672 0 32-14.328 32-32v-192c0-17.672-14.328-32-32-32h-960c-17.672 0-32 14.328-32 32z"
166
+ ],
167
+ "tags": [
168
+ "minus",
169
+ "minimize",
170
+ "subtract"
171
+ ],
172
+ "grid": 16
173
+ },
174
+ "properties": {
175
+ "id": 257,
176
+ "order": 2,
177
+ "prevSize": 32,
178
+ "name": "minus",
179
+ "code": 58884
180
+ },
181
+ "setIdx": 1,
182
+ "setId": 1,
183
+ "iconIdx": 5
184
+ },
185
+ {
186
+ "icon": {
187
+ "paths": [
188
+ "M992 384h-352v-352c0-17.672-14.328-32-32-32h-192c-17.672 0-32 14.328-32 32v352h-352c-17.672 0-32 14.328-32 32v192c0 17.672 14.328 32 32 32h352v352c0 17.672 14.328 32 32 32h192c17.672 0 32-14.328 32-32v-352h352c17.672 0 32-14.328 32-32v-192c0-17.672-14.328-32-32-32z"
189
+ ],
190
+ "tags": [
191
+ "plus",
192
+ "add",
193
+ "sum"
194
+ ],
195
+ "grid": 16
196
+ },
197
+ "properties": {
198
+ "id": 258,
199
+ "order": 1,
200
+ "prevSize": 32,
201
+ "name": "plus",
202
+ "code": 58885
203
+ },
204
+ "setIdx": 1,
205
+ "setId": 1,
206
+ "iconIdx": 6
207
+ },
208
+ {
209
+ "icon": {
210
+ "paths": [
211
+ "M747.52 307.251l-471.040-0.051 235.52 409.6z"
212
+ ],
213
+ "tags": [
214
+ "arrow-down",
215
+ "triangle",
216
+ "down",
217
+ "bottom"
218
+ ],
219
+ "grid": 20
220
+ },
221
+ "properties": {
222
+ "id": 202,
223
+ "order": 8,
224
+ "prevSize": 20,
225
+ "code": 58887,
226
+ "name": "arrow-down"
227
+ },
228
+ "setIdx": 1,
229
+ "setId": 1,
230
+ "iconIdx": 7
231
+ },
232
+ {
233
+ "icon": {
234
+ "paths": [
235
+ "M307.251 276.48l-0.051 471.040 409.6-235.52z"
236
+ ],
237
+ "tags": [
238
+ "arrow-right",
239
+ "triangle",
240
+ "right",
241
+ "next"
242
+ ],
243
+ "grid": 20
244
+ },
245
+ "properties": {
246
+ "id": 204,
247
+ "order": 7,
248
+ "prevSize": 20,
249
+ "code": 58888,
250
+ "name": "arrow-right"
251
+ },
252
+ "setIdx": 1,
253
+ "setId": 1,
254
+ "iconIdx": 8
255
+ },
256
+ {
257
+ "icon": {
258
+ "paths": [
259
+ "M512 0l-235.52 373.76h470.989l-235.469-373.76zM512.051 1024l235.469-373.76-471.040-0.051 235.571 373.811z"
260
+ ],
261
+ "tags": [
262
+ "menu",
263
+ "arrows",
264
+ "up-down",
265
+ "dropdown"
266
+ ],
267
+ "grid": 20
268
+ },
269
+ "properties": {
270
+ "id": 221,
271
+ "order": 6,
272
+ "prevSize": 20,
273
+ "name": "menu",
274
+ "code": 58886
275
+ },
276
+ "setIdx": 1,
277
+ "setId": 1,
278
+ "iconIdx": 9
279
+ }
280
+ ],
281
+ "height": 1024,
282
+ "metadata": {
283
+ "name": "form-manager"
284
+ },
285
+ "preferences": {
286
+ "fontPref": {
287
+ "prefix": "icon-",
288
+ "metadata": {
289
+ "fontFamily": "form-manager",
290
+ "majorVersion": 1,
291
+ "minorVersion": 0
292
+ },
293
+ "showGlyphs": true,
294
+ "metrics": {
295
+ "emSize": 1024,
296
+ "baseline": 6.25,
297
+ "whitespace": 50
298
+ },
299
+ "resetPoint": 58880,
300
+ "showQuickUse": true,
301
+ "quickUsageToken": false,
302
+ "showMetrics": true,
303
+ "showMetadata": false
304
+ },
305
+ "imagePref": {
306
+ "color": 0,
307
+ "height": 32,
308
+ "columns": 16,
309
+ "margin": 16,
310
+ "png": false,
311
+ "sprites": true,
312
+ "prefix": "icon-"
313
+ },
314
+ "historySize": 100,
315
+ "showCodes": true,
316
+ "gridSize": 16,
317
+ "showLiga": false,
318
+ "showGrid": true,
319
+ "showGlyphs": true,
320
+ "showQuickUse": true,
321
+ "showQuickUse2": true,
322
+ "showSVGs": true,
323
+ "search": ""
324
+ }
325
+ }
js/manager/app.js CHANGED
@@ -172,15 +172,21 @@
172
  var container = metabox.querySelectorAll( '.inside' )[0];
173
 
174
  var settings = document.createElement( 'div' );
175
- settings.className = 'ccf-submission-settings';
176
  settings.setAttribute( 'data-icon', '' );
177
 
 
 
 
 
 
178
  var screenOptionsLink = document.getElementById( 'show-settings-link' );
179
  settings.onclick = function() {
180
  screenOptionsLink.click();
181
  };
182
 
183
  metabox.insertBefore( settings, metabox.firstChild.nextSibling.nextSibling );
 
184
 
185
  wp.ccf.createSubmissionsTable( container );
186
  }
172
  var container = metabox.querySelectorAll( '.inside' )[0];
173
 
174
  var settings = document.createElement( 'div' );
175
+ settings.className = 'ccf-submission-icon';
176
  settings.setAttribute( 'data-icon', '' );
177
 
178
+ var download = document.createElement( 'a' );
179
+ download.href = '?action=edit&post=' + parseInt( ccfSettings.postId ) + '&download_submissions=1&download_submissions_nonce=' + ccfSettings.downloadSubmissionsNonce;
180
+ download.className = 'ccf-submission-icon';
181
+ download.setAttribute( 'data-icon', '' );
182
+
183
  var screenOptionsLink = document.getElementById( 'show-settings-link' );
184
  settings.onclick = function() {
185
  screenOptionsLink.click();
186
  };
187
 
188
  metabox.insertBefore( settings, metabox.firstChild.nextSibling.nextSibling );
189
+ metabox.insertBefore( download, metabox.firstChild.nextSibling.nextSibling );
190
 
191
  wp.ccf.createSubmissionsTable( container );
192
  }
languages/custom-contact-forms.mo CHANGED
Binary file
languages/custom-contact-forms.po CHANGED
@@ -5,8 +5,8 @@ msgstr ""
5
  "Project-Id-Version: Custom Contact Forms\n"
6
  "Report-Msgid-Bugs-To: https://github.com/tlovett1/custom-contact-forms/"
7
  "issues\n"
8
- "POT-Creation-Date: 2015-03-27 10:30-0500\n"
9
- "PO-Revision-Date: 2015-03-27 10:30-0500\n"
10
  "Last-Translator: Taylor Lovett <tlovett88@gmail.com>\n"
11
  "Language-Team: LANGUAGE <LL@li.org>\n"
12
  "Language: en\n"
@@ -41,8 +41,8 @@ msgstr ""
41
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:271
42
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:319
43
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:364
44
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:730
45
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:758
46
  msgid "Invalid post ID."
47
  msgstr ""
48
 
@@ -108,7 +108,7 @@ msgstr ""
108
  msgid "<a href=\"%s\">Forms and Submissions</a>"
109
  msgstr ""
110
 
111
- #: ../classes/class-ccf-export.php:58 ../classes/class-ccf-form-cpt.php:389
112
  msgid "Forms and Submissions"
113
  msgstr ""
114
 
@@ -223,7 +223,7 @@ msgid "PM"
223
  msgstr ""
224
 
225
  #: ../classes/class-ccf-field-renderer.php:971
226
- #: ../classes/class-ccf-form-cpt.php:323
227
  #: ../classes/class-ccf-form-manager.php:241
228
  #: ../classes/class-ccf-form-manager.php:254
229
  #: ../classes/class-ccf-form-manager.php:1089
@@ -233,129 +233,129 @@ msgstr ""
233
  msgid "Date"
234
  msgstr ""
235
 
236
- #: ../classes/class-ccf-form-cpt.php:90
237
  msgid "Form Submission Columns"
238
  msgstr ""
239
 
240
- #: ../classes/class-ccf-form-cpt.php:139 ../classes/class-ccf-form-cpt.php:157
241
- #: ../classes/class-ccf-form-cpt.php:321
242
  #: ../classes/class-ccf-form-manager.php:244
243
  #: ../classes/class-ccf-form-manager.php:257
244
  msgid "Submissions"
245
  msgstr ""
246
 
247
- #: ../classes/class-ccf-form-cpt.php:153
248
  msgid "At a Glance"
249
  msgstr ""
250
 
251
- #: ../classes/class-ccf-form-cpt.php:154
252
  msgid "Preview"
253
  msgstr ""
254
 
255
- #: ../classes/class-ccf-form-cpt.php:174
256
  msgid "Save your new form to see a preview."
257
  msgstr ""
258
 
259
- #: ../classes/class-ccf-form-cpt.php:211
260
  msgid "Created on:"
261
  msgstr ""
262
 
263
- #: ../classes/class-ccf-form-cpt.php:214
264
  msgid "Author:"
265
  msgstr ""
266
 
267
- #: ../classes/class-ccf-form-cpt.php:217
268
  msgid "Number of fields:"
269
  msgstr ""
270
 
271
- #: ../classes/class-ccf-form-cpt.php:220
272
  msgid "Number of submissions:"
273
  msgstr ""
274
 
275
- #: ../classes/class-ccf-form-cpt.php:226
276
  msgid "Move to Trash"
277
  msgstr ""
278
 
279
- #: ../classes/class-ccf-form-cpt.php:230
280
  msgid "Export"
281
  msgstr ""
282
 
283
- #: ../classes/class-ccf-form-cpt.php:259
284
  #: ../classes/class-ccf-form-manager.php:1214
285
  msgid "(No title)"
286
  msgstr ""
287
 
288
- #: ../classes/class-ccf-form-cpt.php:264
289
  msgid "Manage Form"
290
  msgstr ""
291
 
292
- #: ../classes/class-ccf-form-cpt.php:319
293
  msgid "Form Title"
294
  msgstr ""
295
 
296
- #: ../classes/class-ccf-form-cpt.php:320
297
  #: ../classes/class-ccf-form-manager.php:242
298
  #: ../classes/class-ccf-form-manager.php:255
299
  msgid "Author"
300
  msgstr ""
301
 
302
- #: ../classes/class-ccf-form-cpt.php:322
303
  #: ../classes/class-ccf-form-manager.php:243
304
  #: ../classes/class-ccf-form-manager.php:256
305
  msgid "Number of Fields"
306
  msgstr ""
307
 
308
- #: ../classes/class-ccf-form-cpt.php:356
309
  msgid "Unpublished"
310
  msgstr ""
311
 
312
- #: ../classes/class-ccf-form-cpt.php:358
313
  msgid "Y/m/d g:i:s A"
314
  msgstr ""
315
 
316
- #: ../classes/class-ccf-form-cpt.php:365
317
  #, php-format
318
  msgid "%s ago"
319
  msgstr ""
320
 
321
- #: ../classes/class-ccf-form-cpt.php:367
322
  msgid "Y/m/d"
323
  msgstr ""
324
 
325
- #: ../classes/class-ccf-form-cpt.php:383 ../classes/class-ccf-form-cpt.php:395
326
  msgid "Forms"
327
  msgstr ""
328
 
329
- #: ../classes/class-ccf-form-cpt.php:384
330
  msgid "Form"
331
  msgstr ""
332
 
333
- #: ../classes/class-ccf-form-cpt.php:385 ../classes/class-ccf-form-cpt.php:388
334
  #: ../classes/class-ccf-form-manager.php:81
335
  msgid "New Form"
336
  msgstr ""
337
 
338
- #: ../classes/class-ccf-form-cpt.php:386
339
  msgid "Add New Form"
340
  msgstr ""
341
 
342
- #: ../classes/class-ccf-form-cpt.php:387
343
  msgid "Edit Form"
344
  msgstr ""
345
 
346
- #: ../classes/class-ccf-form-cpt.php:390
347
  msgid "View Form"
348
  msgstr ""
349
 
350
- #: ../classes/class-ccf-form-cpt.php:391
351
  msgid "Search Forms"
352
  msgstr ""
353
 
354
- #: ../classes/class-ccf-form-cpt.php:392
355
  msgid "No forms found."
356
  msgstr ""
357
 
358
- #: ../classes/class-ccf-form-cpt.php:393
359
  msgid "No forms found in trash."
360
  msgstr ""
361
 
@@ -478,29 +478,29 @@ msgstr ""
478
  msgid "AM/PM is required."
479
  msgstr ""
480
 
481
- #: ../classes/class-ccf-form-handler.php:698
482
  msgid "*Hidden Field*"
483
  msgstr ""
484
 
485
- #: ../classes/class-ccf-form-handler.php:772
486
  msgid "Form submitted from"
487
  msgstr ""
488
 
489
- #: ../classes/class-ccf-form-handler.php:781
490
  msgid "Form submitter IP"
491
  msgstr ""
492
 
493
- #: ../classes/class-ccf-form-handler.php:815
494
  #, php-format
495
  msgid "%s: Form Submission"
496
  msgstr ""
497
 
498
- #: ../classes/class-ccf-form-handler.php:817
499
  #, php-format
500
  msgid " to \"%s\""
501
  msgstr ""
502
 
503
- #: ../classes/class-ccf-form-handler.php:832
504
  #: ../classes/class-ccf-form-renderer.php:119
505
  msgid "Thank you for your submission."
506
  msgstr ""
@@ -1042,15 +1042,15 @@ msgstr ""
1042
  msgid "reCAPTCHA"
1043
  msgstr ""
1044
 
1045
- #: ../classes/class-ccf-form-manager.php:1507
1046
  msgid "You have no email fields"
1047
  msgstr ""
1048
 
1049
- #: ../classes/class-ccf-form-manager.php:1508
1050
  msgid "Invalid date"
1051
  msgstr ""
1052
 
1053
- #: ../classes/class-ccf-form-manager.php:1510
1054
  msgid "Form Submission"
1055
  msgstr ""
1056
 
@@ -1161,18 +1161,18 @@ msgstr ""
1161
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-media.php:153
1162
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-media.php:174
1163
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-media.php:205
1164
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:749
1165
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:769
1166
  msgid "Invalid post type"
1167
  msgstr ""
1168
 
1169
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-media.php:210
1170
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:784
1171
  msgid "Sorry, you are not allowed to post on this site."
1172
  msgstr ""
1173
 
1174
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-media.php:215
1175
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:776
1176
  msgid "Sorry, you are not allowed to edit this post."
1177
  msgstr ""
1178
 
@@ -1207,7 +1207,7 @@ msgid "Invalid featured image."
1207
  msgstr ""
1208
 
1209
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-meta-posts.php:34
1210
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:636
1211
  msgid "Sorry, you cannot edit this post"
1212
  msgstr ""
1213
 
@@ -1304,49 +1304,49 @@ msgstr ""
1304
  msgid "Cannot view post type"
1305
  msgstr ""
1306
 
1307
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:646
1308
  msgid "Sorry, you cannot view this revision"
1309
  msgstr ""
1310
 
1311
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:682
1312
  msgid "There is no excerpt because this is a protected post."
1313
  msgstr ""
1314
 
1315
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:780
1316
  msgid "The post type may not be changed."
1317
  msgstr ""
1318
 
1319
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:798
1320
  msgid "Sorry, you are not allowed to create private posts in this post type"
1321
  msgstr ""
1322
 
1323
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:804
1324
  msgid "Sorry, you are not allowed to publish posts in this post type"
1325
  msgstr ""
1326
 
1327
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:845
1328
  msgid "Invalid author object."
1329
  msgstr ""
1330
 
1331
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:855
1332
  msgid "You are not allowed to edit posts as this user."
1333
  msgstr ""
1334
 
1335
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:861
1336
  msgid "Invalid author ID."
1337
  msgstr ""
1338
 
1339
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:873
1340
  msgid ""
1341
  "Sorry, you are not allowed to create password protected posts in this post "
1342
  "type"
1343
  msgstr ""
1344
 
1345
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:890
1346
  msgid "Invalid post parent ID."
1347
  msgstr ""
1348
 
1349
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:916
1350
  msgid "Invalid post format."
1351
  msgstr ""
1352
 
@@ -1362,19 +1362,19 @@ msgstr ""
1362
  msgid "The JSONP callback function is invalid."
1363
  msgstr ""
1364
 
1365
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-server.php:374
1366
  msgid "Unsupported request method"
1367
  msgstr ""
1368
 
1369
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-server.php:393
1370
  msgid "The handler for the route is invalid"
1371
  msgstr ""
1372
 
1373
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-server.php:453
1374
  msgid "No route was found matching the URL and request method"
1375
  msgstr ""
1376
 
1377
- #: ../vendor/wp-api/wp-api/lib/class-wp-json-server.php:505
1378
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-users.php:252
1379
  #, php-format
1380
  msgid "Missing parameter %s"
5
  "Project-Id-Version: Custom Contact Forms\n"
6
  "Report-Msgid-Bugs-To: https://github.com/tlovett1/custom-contact-forms/"
7
  "issues\n"
8
+ "POT-Creation-Date: 2015-03-29 23:51-0500\n"
9
+ "PO-Revision-Date: 2015-03-29 23:51-0500\n"
10
  "Last-Translator: Taylor Lovett <tlovett88@gmail.com>\n"
11
  "Language-Team: LANGUAGE <LL@li.org>\n"
12
  "Language: en\n"
41
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:271
42
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:319
43
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:364
44
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:739
45
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:767
46
  msgid "Invalid post ID."
47
  msgstr ""
48
 
108
  msgid "<a href=\"%s\">Forms and Submissions</a>"
109
  msgstr ""
110
 
111
+ #: ../classes/class-ccf-export.php:58 ../classes/class-ccf-form-cpt.php:576
112
  msgid "Forms and Submissions"
113
  msgstr ""
114
 
223
  msgstr ""
224
 
225
  #: ../classes/class-ccf-field-renderer.php:971
226
+ #: ../classes/class-ccf-form-cpt.php:510
227
  #: ../classes/class-ccf-form-manager.php:241
228
  #: ../classes/class-ccf-form-manager.php:254
229
  #: ../classes/class-ccf-form-manager.php:1089
233
  msgid "Date"
234
  msgstr ""
235
 
236
+ #: ../classes/class-ccf-form-cpt.php:277
237
  msgid "Form Submission Columns"
238
  msgstr ""
239
 
240
+ #: ../classes/class-ccf-form-cpt.php:326 ../classes/class-ccf-form-cpt.php:344
241
+ #: ../classes/class-ccf-form-cpt.php:508
242
  #: ../classes/class-ccf-form-manager.php:244
243
  #: ../classes/class-ccf-form-manager.php:257
244
  msgid "Submissions"
245
  msgstr ""
246
 
247
+ #: ../classes/class-ccf-form-cpt.php:340
248
  msgid "At a Glance"
249
  msgstr ""
250
 
251
+ #: ../classes/class-ccf-form-cpt.php:341
252
  msgid "Preview"
253
  msgstr ""
254
 
255
+ #: ../classes/class-ccf-form-cpt.php:361
256
  msgid "Save your new form to see a preview."
257
  msgstr ""
258
 
259
+ #: ../classes/class-ccf-form-cpt.php:398
260
  msgid "Created on:"
261
  msgstr ""
262
 
263
+ #: ../classes/class-ccf-form-cpt.php:401
264
  msgid "Author:"
265
  msgstr ""
266
 
267
+ #: ../classes/class-ccf-form-cpt.php:404
268
  msgid "Number of fields:"
269
  msgstr ""
270
 
271
+ #: ../classes/class-ccf-form-cpt.php:407
272
  msgid "Number of submissions:"
273
  msgstr ""
274
 
275
+ #: ../classes/class-ccf-form-cpt.php:413
276
  msgid "Move to Trash"
277
  msgstr ""
278
 
279
+ #: ../classes/class-ccf-form-cpt.php:417
280
  msgid "Export"
281
  msgstr ""
282
 
283
+ #: ../classes/class-ccf-form-cpt.php:446
284
  #: ../classes/class-ccf-form-manager.php:1214
285
  msgid "(No title)"
286
  msgstr ""
287
 
288
+ #: ../classes/class-ccf-form-cpt.php:451
289
  msgid "Manage Form"
290
  msgstr ""
291
 
292
+ #: ../classes/class-ccf-form-cpt.php:506
293
  msgid "Form Title"
294
  msgstr ""
295
 
296
+ #: ../classes/class-ccf-form-cpt.php:507
297
  #: ../classes/class-ccf-form-manager.php:242
298
  #: ../classes/class-ccf-form-manager.php:255
299
  msgid "Author"
300
  msgstr ""
301
 
302
+ #: ../classes/class-ccf-form-cpt.php:509
303
  #: ../classes/class-ccf-form-manager.php:243
304
  #: ../classes/class-ccf-form-manager.php:256
305
  msgid "Number of Fields"
306
  msgstr ""
307
 
308
+ #: ../classes/class-ccf-form-cpt.php:543
309
  msgid "Unpublished"
310
  msgstr ""
311
 
312
+ #: ../classes/class-ccf-form-cpt.php:545
313
  msgid "Y/m/d g:i:s A"
314
  msgstr ""
315
 
316
+ #: ../classes/class-ccf-form-cpt.php:552
317
  #, php-format
318
  msgid "%s ago"
319
  msgstr ""
320
 
321
+ #: ../classes/class-ccf-form-cpt.php:554
322
  msgid "Y/m/d"
323
  msgstr ""
324
 
325
+ #: ../classes/class-ccf-form-cpt.php:570 ../classes/class-ccf-form-cpt.php:582
326
  msgid "Forms"
327
  msgstr ""
328
 
329
+ #: ../classes/class-ccf-form-cpt.php:571
330
  msgid "Form"
331
  msgstr ""
332
 
333
+ #: ../classes/class-ccf-form-cpt.php:572 ../classes/class-ccf-form-cpt.php:575
334
  #: ../classes/class-ccf-form-manager.php:81
335
  msgid "New Form"
336
  msgstr ""
337
 
338
+ #: ../classes/class-ccf-form-cpt.php:573
339
  msgid "Add New Form"
340
  msgstr ""
341
 
342
+ #: ../classes/class-ccf-form-cpt.php:574
343
  msgid "Edit Form"
344
  msgstr ""
345
 
346
+ #: ../classes/class-ccf-form-cpt.php:577
347
  msgid "View Form"
348
  msgstr ""
349
 
350
+ #: ../classes/class-ccf-form-cpt.php:578
351
  msgid "Search Forms"
352
  msgstr ""
353
 
354
+ #: ../classes/class-ccf-form-cpt.php:579
355
  msgid "No forms found."
356
  msgstr ""
357
 
358
+ #: ../classes/class-ccf-form-cpt.php:580
359
  msgid "No forms found in trash."
360
  msgstr ""
361
 
478
  msgid "AM/PM is required."
479
  msgstr ""
480
 
481
+ #: ../classes/class-ccf-form-handler.php:704
482
  msgid "*Hidden Field*"
483
  msgstr ""
484
 
485
+ #: ../classes/class-ccf-form-handler.php:778
486
  msgid "Form submitted from"
487
  msgstr ""
488
 
489
+ #: ../classes/class-ccf-form-handler.php:787
490
  msgid "Form submitter IP"
491
  msgstr ""
492
 
493
+ #: ../classes/class-ccf-form-handler.php:821
494
  #, php-format
495
  msgid "%s: Form Submission"
496
  msgstr ""
497
 
498
+ #: ../classes/class-ccf-form-handler.php:823
499
  #, php-format
500
  msgid " to \"%s\""
501
  msgstr ""
502
 
503
+ #: ../classes/class-ccf-form-handler.php:838
504
  #: ../classes/class-ccf-form-renderer.php:119
505
  msgid "Thank you for your submission."
506
  msgstr ""
1042
  msgid "reCAPTCHA"
1043
  msgstr ""
1044
 
1045
+ #: ../classes/class-ccf-form-manager.php:1508
1046
  msgid "You have no email fields"
1047
  msgstr ""
1048
 
1049
+ #: ../classes/class-ccf-form-manager.php:1509
1050
  msgid "Invalid date"
1051
  msgstr ""
1052
 
1053
+ #: ../classes/class-ccf-form-manager.php:1511
1054
  msgid "Form Submission"
1055
  msgstr ""
1056
 
1161
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-media.php:153
1162
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-media.php:174
1163
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-media.php:205
1164
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:758
1165
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:778
1166
  msgid "Invalid post type"
1167
  msgstr ""
1168
 
1169
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-media.php:210
1170
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:793
1171
  msgid "Sorry, you are not allowed to post on this site."
1172
  msgstr ""
1173
 
1174
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-media.php:215
1175
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:785
1176
  msgid "Sorry, you are not allowed to edit this post."
1177
  msgstr ""
1178
 
1207
  msgstr ""
1208
 
1209
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-meta-posts.php:34
1210
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:645
1211
  msgid "Sorry, you cannot edit this post"
1212
  msgstr ""
1213
 
1304
  msgid "Cannot view post type"
1305
  msgstr ""
1306
 
1307
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:655
1308
  msgid "Sorry, you cannot view this revision"
1309
  msgstr ""
1310
 
1311
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:691
1312
  msgid "There is no excerpt because this is a protected post."
1313
  msgstr ""
1314
 
1315
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:789
1316
  msgid "The post type may not be changed."
1317
  msgstr ""
1318
 
1319
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:807
1320
  msgid "Sorry, you are not allowed to create private posts in this post type"
1321
  msgstr ""
1322
 
1323
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:813
1324
  msgid "Sorry, you are not allowed to publish posts in this post type"
1325
  msgstr ""
1326
 
1327
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:854
1328
  msgid "Invalid author object."
1329
  msgstr ""
1330
 
1331
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:864
1332
  msgid "You are not allowed to edit posts as this user."
1333
  msgstr ""
1334
 
1335
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:870
1336
  msgid "Invalid author ID."
1337
  msgstr ""
1338
 
1339
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:882
1340
  msgid ""
1341
  "Sorry, you are not allowed to create password protected posts in this post "
1342
  "type"
1343
  msgstr ""
1344
 
1345
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:899
1346
  msgid "Invalid post parent ID."
1347
  msgstr ""
1348
 
1349
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-posts.php:925
1350
  msgid "Invalid post format."
1351
  msgstr ""
1352
 
1362
  msgid "The JSONP callback function is invalid."
1363
  msgstr ""
1364
 
1365
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-server.php:375
1366
  msgid "Unsupported request method"
1367
  msgstr ""
1368
 
1369
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-server.php:394
1370
  msgid "The handler for the route is invalid"
1371
  msgstr ""
1372
 
1373
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-server.php:454
1374
  msgid "No route was found matching the URL and request method"
1375
  msgstr ""
1376
 
1377
+ #: ../vendor/wp-api/wp-api/lib/class-wp-json-server.php:506
1378
  #: ../vendor/wp-api/wp-api/lib/class-wp-json-users.php:252
1379
  #, php-format
1380
  msgid "Missing parameter %s"
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
5
  Requires at least: 3.9
6
  Tested up to: 4.2
7
- Stable tag: 6.5.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -35,6 +35,10 @@ For questions, feature requests, and support concerning the Custom Contact Forms
35
 
36
  == Changelog ==
37
 
 
 
 
 
38
  = 6.5.1 =
39
  * Fix translatable field strings.
40
 
4
  Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
5
  Requires at least: 3.9
6
  Tested up to: 4.2
7
+ Stable tag: 6.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
35
 
36
  == Changelog ==
37
 
38
+ = 6.6 =
39
+ * Update WP-API to 1.2 (still have header method hack)
40
+ * Form CSV download
41
+
42
  = 6.5.1 =
43
  * Fix translatable field strings.
44
 
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit39462c84ad13b61335b8c477812ac9fc::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit5cd081e950d9eb38890c4cbb592fde30::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit39462c84ad13b61335b8c477812ac9fc
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit39462c84ad13b61335b8c477812ac9fc
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit39462c84ad13b61335b8c477812ac9fc', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit39462c84ad13b61335b8c477812ac9fc', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -44,7 +44,7 @@ class ComposerAutoloaderInit39462c84ad13b61335b8c477812ac9fc
44
  }
45
  }
46
 
47
- function composerRequire39462c84ad13b61335b8c477812ac9fc($file)
48
  {
49
  require $file;
50
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit5cd081e950d9eb38890c4cbb592fde30
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit5cd081e950d9eb38890c4cbb592fde30', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit5cd081e950d9eb38890c4cbb592fde30', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
44
  }
45
  }
46
 
47
+ function composerRequire5cd081e950d9eb38890c4cbb592fde30($file)
48
  {
49
  require $file;
50
  }
vendor/composer/installed.json CHANGED
@@ -6,7 +6,7 @@
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/wp-api/wp-api",
9
- "reference": "ad9688f450a813fd23d5c008d7d7c9fb58e76b2b"
10
  },
11
  "type": "library",
12
  "installation-source": "source"
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/wp-api/wp-api",
9
+ "reference": "4e2d780432d934a912721748bcc70d89025c625c"
10
  },
11
  "type": "library",
12
  "installation-source": "source"
vendor/wp-api/wp-api/.scrutinizer.yml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Scrutinizer Configuration File
2
+
3
+ tools:
4
+ php_sim:
5
+ enabled: true
6
+ min_mass: 50
7
+
8
+ php_pdepend:
9
+ enabled: true
10
+ configuration_file: null
11
+ suffixes:
12
+ - php
13
+ excluded_dirs: { }
14
+
15
+ php_analyzer:
16
+ enabled: true
17
+ extensions:
18
+ - php
19
+ dependency_paths: { }
20
+ path_configs: { }
21
+
22
+ php_changetracking:
23
+ enabled: true
24
+ bug_patterns:
25
+ - '\bfix(?:es|ed)?\b'
26
+ feature_patterns:
27
+ - '\badd(?:s|ed)?\b'
28
+ - '\bimplement(?:s|ed)?\b'
29
+
30
+ php_hhvm:
31
+ enabled: true
32
+ command: hhvm
33
+ extensions:
34
+ - php
35
+
36
+ path_configs: { }
37
+ before_commands: { }
38
+ after_commands: { }
39
+ artifacts: { }
40
+ build_failure_conditions: { }
vendor/wp-api/wp-api/CHANGELOG.md CHANGED
@@ -1,5 +1,325 @@
1
  # Changelog
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ## 1.1.1
4
 
5
  - Mitigate Flash CSRF exploit
1
  # Changelog
2
 
3
+ ## 1.2.0
4
+
5
+ - Add handling for Cross-Origin Resource Sharing (CORS) OPTIONS requests.
6
+
7
+ Preflighted requests (using the OPTIONS method) include the headers
8
+ `Access-Control-Allow-Origin`, `Access-Control-Allow-Methods`, and
9
+ `Access-Control-Allow-Credentials` in the response, if the HTTP origin is
10
+ set.
11
+
12
+ (props @rmccue, [#281][gh-281])
13
+
14
+ - Allow overriding full requests.
15
+
16
+ The `json_pre_dispatch` filter allows a request to be hijacked before it is
17
+ dispatched. Hijacked requests can be anything a normal endpoint can return.
18
+
19
+ (props @rmccue, [#281][gh-281])
20
+
21
+ - Check for JSON encoding/decoding errors.
22
+
23
+ Returns the last error (if any) occurred during the last JSON encoding or
24
+ decoding operation.
25
+
26
+ (props @joshkadis, @rmccue, [#461][gh-461])
27
+
28
+ - Add filtering to the terms collection endpoint.
29
+
30
+ Available filter arguments are based on the `get_terms()` function. Example:
31
+ `/taxonomies/category/terms?filter[number]=10` would limit the response to 10
32
+ category terms.
33
+
34
+ (props @mauteri, [#401][gh-401], [#347][gh-347])
35
+
36
+ - Add handling for the `role` parameter when creating or updating a user.
37
+
38
+ Allow users to be created or updated with a provided `role`.
39
+
40
+ (props @pippinsplugins, [#392][gh-392], [#335][gh-335])
41
+
42
+ - Add handling for the `post_id` parameter when creating media.
43
+
44
+ Allow passing the `post_id` parameter to associate a new media item with
45
+ a post.
46
+
47
+ (props @pkevan, [#294][gh-294])
48
+
49
+ - Handle route matching for `-` in taxonomy and terms.
50
+
51
+ Previously the regular expression used to match taxonomy and term names did
52
+ not support names with dashes.
53
+
54
+ (props @EdHurtig, @evansobkowicz, [#410][gh-410])
55
+
56
+ - Handle JSONP callback matching for `.` in the function name.
57
+
58
+ Previously the regular expression used to match JSONP callback functions did
59
+ not support names with periods.
60
+
61
+ (props @codonnell822, [#455][gh-455])
62
+
63
+ - Fix the Content-Type header for JSONP requests.
64
+
65
+ Previously JSONP requests sent the incorrect `application/json` Content-Type
66
+ header with the response. This would result in an error if strict MIME
67
+ checking was enabled. The Content-Type header was corrected to
68
+ `application/javascript` for JSONP responses.
69
+
70
+ (props @simonlampen, [#380][gh-380])
71
+
72
+ - Add `$context` parameter to `json_prepare_term` filter.
73
+
74
+ Terms responses can now be modified based on the `context` parameter of the
75
+ request.
76
+
77
+ (props @traversal, [#316][gh-316])
78
+
79
+ - Move the JavaScript client library into the plugin.
80
+
81
+ Previously, the `wp-api.js` file was a separate repository. The JavaScript
82
+ client has moved back into the plugin to coordinate code changes.
83
+
84
+ (props @tlovett1, [#730][gh-730])
85
+
86
+ - Always return an object for media sizes
87
+
88
+ The media sizes value should always be an object even when empty. Previously,
89
+ if a media item did not have any sizes set, an empty array was returned.
90
+
91
+ **Compatibility warning**: Clients should be prepared to accept an empty
92
+ object as a value for media sizes.
93
+
94
+ (props @maxcutler, [#300][gh-300])
95
+
96
+ - Give top-level posts a `null` parent value.
97
+
98
+ For date type consistency, post parent property should be `null`. Previously,
99
+ parent-less posts returned `0` for parent.
100
+
101
+ **Compatibility warning**: Clients should be prepared to accept `null` as a
102
+ value for post parent.
103
+
104
+ (props @maxcutler, [#391][gh-391])
105
+
106
+ - Move permission checks out of `WP_JSON_Posts`.
107
+
108
+ Introduce `json_check_post_permission()` function to allow post object
109
+ capability checks to be used outside the `WP_JSON_Posts` class.
110
+
111
+ **Deprecation warning:** Calling `WP_JSON_Posts::check_read_permission` and
112
+ `WP_JSON_Posts::check_edit_permission` is now deprecated.
113
+
114
+ (props @rachelbaker, [#486][gh-486], [#378][gh-378])
115
+
116
+ - Split comment endpoints into separate class.
117
+
118
+ All comment handling has moved to the `WP_JSON_Comments` class.
119
+
120
+ **Deprecation warning:** Calling `WP_JSON_Posts::get_comments`,
121
+ `WP_JSON_Posts::get_comment`, `WP_JSON_Posts::delete_comment`, and
122
+ `WP_JSON_Posts::prepare_comment` is now deprecated.
123
+
124
+ (props @whyisjake, @rmccue, @rachelbaker, [#378][gh-378])
125
+
126
+ - Split meta endpoints into separate class.
127
+
128
+ All post meta handling has moved to the new `WP_JSON_Meta_Posts` class.
129
+
130
+ **Deprecation warning:** Calling `WP_JSON_Posts::get_all_meta`,
131
+ `WP_JSON_Posts::get_meta`, `WP_JSON_Posts::update_meta`,
132
+ `WP_JSON_Posts::add_meta`, `WP_JSON_Posts::delete_meta`,
133
+ `WP_JSON_Posts::prepare_meta`, and `WP_JSON_Posts::is_valid_meta_data` is
134
+ now deprecated.
135
+
136
+ (props @rmccue, @rachelbaker, [#358][gh-358], [#474][gh-474])
137
+
138
+ - Rename internal create methods.
139
+
140
+ **Deprecation warning:** Calling `WP_JSON_Posts::new_post`,
141
+ `WP_JSON_CustomPostType::new_post` and `WP_JSON_Posts::new_post`
142
+ is now deprecated.
143
+
144
+ (props @rachelbaker, @rmccue, [#374][gh-374], [#377][gh-377], [#376][gh-376])
145
+
146
+ - Fix discrepancies in edit and create posts documentation examples.
147
+
148
+ Corrected the edit and create posts code examples in the Getting Started
149
+ section. The new post example was updated to include the required
150
+ `content_raw` parameter. The new and edit posts examples were updated to use
151
+ a correct date parameter.
152
+
153
+ (props @rachelbaker, [#305][gh-305])
154
+
155
+ - Update the cookie authentication documentation examples.
156
+
157
+ With 1.1 the localized JavaScript object for `wp-api.js` changed to
158
+ `WP_API_Settings`. This updates the Authentication section documentation
159
+ nonce example to use the updated object name.
160
+
161
+ (props @rachelbaker, [#321][gh-321])
162
+
163
+ - Add flexibility and multisite support to unit tests.
164
+
165
+ Tests can be run from any WordPress install, and are not limited to only as
166
+ a plugin installed within a WordPress.org develop checkout. Unit tests are
167
+ now run against a multisite installation.
168
+
169
+ (props @danielbachhuber, [#397][gh-397])
170
+
171
+ - Add `taxonomy` slug to the term response.
172
+
173
+ (props @kalenjohnson, [#481][gh-481])
174
+
175
+ - Fix error when getting child comment.
176
+
177
+ Previously an error occurred when a requested comment had a parent.
178
+
179
+ (props @EdHurtig, [#413][gh-413], [#411][gh-411])
180
+
181
+ - Parse query strings before returning a JSON decode error.
182
+
183
+ (props @jtsternberg, [#499][gh-499])
184
+
185
+ - Typecast the user ID parameter to be an integer for the `/users/{ID}` route.
186
+
187
+ (props @dimadin, [#333][gh-333])
188
+
189
+ - Confirm a given JSONP callback is a string.
190
+
191
+ (props @ircrash, @rmccue, [#405][gh-405])
192
+
193
+ - Register the JavaScript client in the admin.
194
+
195
+ (props @tlovett1, [#473][gh-473])
196
+
197
+ - Remove duplicate error checks on post ids.
198
+
199
+ (props @danielbachhuber, [#271][gh-271])
200
+
201
+ - Update documentation link references to wp-api.org.
202
+
203
+ (props @pollyplummer, [#320][gh-320])
204
+
205
+ - Update documentation to note routes needing authentication.
206
+
207
+ (props @kellbot, [#402][gh-402], [#309][gh-309])
208
+
209
+ - Correct Post route documentation filter parameters.
210
+
211
+ (props @modemlooper, @rachelbaker, @rmccue, [#357][gh-357], [#462][gh-462])
212
+
213
+ - Update taxonomy route documentation with correct paths.
214
+
215
+ (props @davidbhayes, [#364][gh-364], [#355][gh-355])
216
+
217
+ - Remove references to legacy `$fields` parameter.
218
+
219
+ (props @JDGrimes, [#326][gh-326])
220
+
221
+ - Alter readme installation steps to use wp-cli for plugin and permalink setup.
222
+
223
+ (props @kadamwhite, [#390][gh-390])
224
+
225
+ - Add steps to readme for executing tests with `vagrant ssh -c`.
226
+
227
+ (props @kadamwhite, [#416][gh-416])
228
+
229
+ - Update readme to include provision step for testing suite.
230
+
231
+ (props @ironpaperweight, [#396][gh-396])
232
+
233
+ - Update readme Getting Started link.
234
+
235
+ (props @NikV, [#519][gh-519])
236
+
237
+ - Update readme Chassis repository links.
238
+
239
+ (props @Japh, [#505][gh-505])
240
+
241
+ - Clean-up of `docs` folder.
242
+
243
+ (props @pollyplummer, [#441][gh-441])
244
+
245
+ - Documentation audit for plugin.php file.
246
+
247
+ (props @DrewAPicture, [#293][gh-293])
248
+
249
+ - Rename tests to match class file naming.
250
+
251
+ (props @danielbachhuber, @rmccue, [#359][gh-359])
252
+
253
+ - Add license.txt file with license terms.
254
+
255
+ (props @rachelbaker, [#393][gh-393], [#384][gh-384])
256
+
257
+ - Fix test_root when using WordPress.org developer checkout.
258
+
259
+ (props @markoheijnen, [#437][gh-437])
260
+
261
+ [View all changes](https://github.com/rmccue/WP-API/compare/1.1.1...1.2)
262
+
263
+ [gh-271]: https://github.com/WP-API/WP-API/issues/271
264
+ [gh-281]: https://github.com/WP-API/WP-API/issues/281
265
+ [gh-293]: https://github.com/WP-API/WP-API/issues/293
266
+ [gh-294]: https://github.com/WP-API/WP-API/issues/294
267
+ [gh-300]: https://github.com/WP-API/WP-API/issues/300
268
+ [gh-305]: https://github.com/WP-API/WP-API/issues/305
269
+ [gh-309]: https://github.com/WP-API/WP-API/issues/309
270
+ [gh-316]: https://github.com/WP-API/WP-API/issues/316
271
+ [gh-320]: https://github.com/WP-API/WP-API/issues/320
272
+ [gh-321]: https://github.com/WP-API/WP-API/issues/321
273
+ [gh-326]: https://github.com/WP-API/WP-API/issues/326
274
+ [gh-333]: https://github.com/WP-API/WP-API/issues/333
275
+ [gh-333]: https://github.com/WP-API/WP-API/issues/333
276
+ [gh-335]: https://github.com/WP-API/WP-API/issues/335
277
+ [gh-347]: https://github.com/WP-API/WP-API/issues/347
278
+ [gh-355]: https://github.com/WP-API/WP-API/issues/355
279
+ [gh-357]: https://github.com/WP-API/WP-API/issues/357
280
+ [gh-358]: https://github.com/WP-API/WP-API/issues/358
281
+ [gh-359]: https://github.com/WP-API/WP-API/issues/359
282
+ [gh-364]: https://github.com/WP-API/WP-API/issues/364
283
+ [gh-374]: https://github.com/WP-API/WP-API/issues/374
284
+ [gh-376]: https://github.com/WP-API/WP-API/issues/376
285
+ [gh-377]: https://github.com/WP-API/WP-API/issues/377
286
+ [gh-378]: https://github.com/WP-API/WP-API/issues/378
287
+ [gh-380]: https://github.com/WP-API/WP-API/issues/380
288
+ [gh-384]: https://github.com/WP-API/WP-API/issues/384
289
+ [gh-390]: https://github.com/WP-API/WP-API/issues/390
290
+ [gh-391]: https://github.com/WP-API/WP-API/issues/391
291
+ [gh-392]: https://github.com/WP-API/WP-API/issues/392
292
+ [gh-393]: https://github.com/WP-API/WP-API/issues/393
293
+ [gh-396]: https://github.com/WP-API/WP-API/issues/396
294
+ [gh-397]: https://github.com/WP-API/WP-API/issues/397
295
+ [gh-401]: https://github.com/WP-API/WP-API/issues/401
296
+ [gh-402]: https://github.com/WP-API/WP-API/issues/402
297
+ [gh-405]: https://github.com/WP-API/WP-API/issues/405
298
+ [gh-410]: https://github.com/WP-API/WP-API/issues/410
299
+ [gh-411]: https://github.com/WP-API/WP-API/issues/411
300
+ [gh-413]: https://github.com/WP-API/WP-API/issues/413
301
+ [gh-416]: https://github.com/WP-API/WP-API/issues/416
302
+ [gh-437]: https://github.com/WP-API/WP-API/issues/437
303
+ [gh-438]: https://github.com/WP-API/WP-API/issues/438
304
+ [gh-441]: https://github.com/WP-API/WP-API/issues/441
305
+ [gh-455]: https://github.com/WP-API/WP-API/issues/455
306
+ [gh-458]: https://github.com/WP-API/WP-API/issues/458
307
+ [gh-461]: https://github.com/WP-API/WP-API/issues/461
308
+ [gh-462]: https://github.com/WP-API/WP-API/issues/462
309
+ [gh-473]: https://github.com/WP-API/WP-API/issues/473
310
+ [gh-474]: https://github.com/WP-API/WP-API/issues/474
311
+ [gh-481]: https://github.com/WP-API/WP-API/issues/481
312
+ [gh-486]: https://github.com/WP-API/WP-API/issues/486
313
+ [gh-499]: https://github.com/WP-API/WP-API/issues/499
314
+ [gh-505]: https://github.com/WP-API/WP-API/issues/505
315
+ [gh-519]: https://github.com/WP-API/WP-API/issues/519
316
+ [gh-524]: https://github.com/WP-API/WP-API/issues/524
317
+ [gh-528]: https://github.com/WP-API/WP-API/issues/528
318
+ [gh-595]: https://github.com/WP-API/WP-API/issues/595
319
+ [gh-730]: https://github.com/WP-API/WP-API/issues/730
320
+ [gh-933]: https://github.com/WP-API/WP-API/issues/933
321
+ [gh-985]: https://github.com/WP-API/WP-API/issues/985
322
+
323
  ## 1.1.1
324
 
325
  - Mitigate Flash CSRF exploit
vendor/wp-api/wp-api/lib/class-wp-json-comments.php CHANGED
@@ -187,7 +187,11 @@ class WP_JSON_Comments {
187
  }
188
 
189
  // Date
 
 
 
190
  $fields['date'] = json_mysql_to_rfc3339( $comment->comment_date );
 
191
  $fields['date_gmt'] = json_mysql_to_rfc3339( $comment->comment_date_gmt );
192
 
193
  // Meta
187
  }
188
 
189
  // Date
190
+ $timezone = json_get_timezone();
191
+ $comment_date = WP_JSON_DateTime::createFromFormat( 'Y-m-d H:i:s', $comment->comment_date, $timezone );
192
+
193
  $fields['date'] = json_mysql_to_rfc3339( $comment->comment_date );
194
+ $fields['date_tz'] = $comment_date->format( 'e' );
195
  $fields['date_gmt'] = json_mysql_to_rfc3339( $comment->comment_date_gmt );
196
 
197
  // Meta
vendor/wp-api/wp-api/lib/class-wp-json-posts.php CHANGED
@@ -232,7 +232,7 @@ class WP_JSON_Posts {
232
  return $result;
233
  }
234
 
235
- $response = json_ensure_response( $this->get_post( $result ) );
236
  $response->set_status( 201 );
237
  $response->header( 'Location', json_url( '/posts/' . $result ) );
238
 
@@ -345,7 +345,7 @@ class WP_JSON_Posts {
345
  return $retval;
346
  }
347
 
348
- return $this->get_post( $id );
349
  }
350
 
351
  /**
@@ -567,24 +567,33 @@ class WP_JSON_Posts {
567
  'content_raw' => $post['post_content'],
568
  'excerpt_raw' => $post['post_excerpt'],
569
  'guid_raw' => $post['guid'],
 
570
  );
571
 
572
  // Dates
 
 
573
  if ( $post['post_date_gmt'] === '0000-00-00 00:00:00' ) {
574
- $post_fields['date'] = null;
 
575
  $post_fields_extended['date_gmt'] = null;
576
  }
577
  else {
 
578
  $post_fields['date'] = json_mysql_to_rfc3339( $post['post_date'] );
 
579
  $post_fields_extended['date_gmt'] = json_mysql_to_rfc3339( $post['post_date_gmt'] );
580
  }
581
 
582
  if ( $post['post_modified_gmt'] === '0000-00-00 00:00:00' ) {
583
- $post_fields['modified'] = null;
 
584
  $post_fields_extended['modified_gmt'] = null;
585
  }
586
  else {
 
587
  $post_fields['modified'] = json_mysql_to_rfc3339( $post['post_modified'] );
 
588
  $post_fields_extended['modified_gmt'] = json_mysql_to_rfc3339( $post['post_modified_gmt'] );
589
  }
590
 
@@ -938,6 +947,14 @@ class WP_JSON_Posts {
938
  $post['ID'] = $post_ID;
939
  }
940
 
 
 
 
 
 
 
 
 
941
  // Sticky
942
  if ( isset( $data['sticky'] ) ) {
943
  if ( $data['sticky'] ) {
@@ -1010,6 +1027,31 @@ class WP_JSON_Posts {
1010
  return $this->comments->_deprecated_call( 'prepare_comment', array( $comment, $requested_fields, $context ) );
1011
  }
1012
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1013
  /**
1014
  * Retrieve custom fields for object
1015
  *
@@ -1114,22 +1156,6 @@ class WP_JSON_Posts {
1114
  return $handler->_deprecated_call( 'prepare_meta', array( $post, $data, $is_raw ) );
1115
  }
1116
 
1117
- /**
1118
- * Update/add/delete meta for an object
1119
- *
1120
- * @deprecated WPAPI-1.2
1121
- *
1122
- * @param array $data
1123
- * @param int $parent_id
1124
- * @return bool|WP_Error
1125
- */
1126
- protected function handle_post_meta_action( $post_id, $data ) {
1127
- _deprecated_function( 'WP_JSON_Posts::handle_post_meta_action', 'WPAPI-1.2', 'WP_JSON_Meta_Posts::handle_inline_meta' );
1128
-
1129
- $handler = new WP_JSON_Meta_Posts( $this->server );
1130
- return $handler->_deprecated_call( 'handle_inline_meta', array( $post, $data, $is_raw ) );
1131
- }
1132
-
1133
  /**
1134
  * Check if the data provided is valid data
1135
  *
232
  return $result;
233
  }
234
 
235
+ $response = json_ensure_response( $this->get_post( $result, 'edit' ) );
236
  $response->set_status( 201 );
237
  $response->header( 'Location', json_url( '/posts/' . $result ) );
238
 
345
  return $retval;
346
  }
347
 
348
+ return $this->get_post( $id, 'edit' );
349
  }
350
 
351
  /**
567
  'content_raw' => $post['post_content'],
568
  'excerpt_raw' => $post['post_excerpt'],
569
  'guid_raw' => $post['guid'],
570
+ 'post_meta' => $this->handle_get_post_meta( $post['ID'] ),
571
  );
572
 
573
  // Dates
574
+ $timezone = json_get_timezone();
575
+
576
  if ( $post['post_date_gmt'] === '0000-00-00 00:00:00' ) {
577
+ $post_fields['date'] = null;
578
+ $post_fields_extended['date_tz'] = null;
579
  $post_fields_extended['date_gmt'] = null;
580
  }
581
  else {
582
+ $post_date = WP_JSON_DateTime::createFromFormat( 'Y-m-d H:i:s', $post['post_date'], $timezone );
583
  $post_fields['date'] = json_mysql_to_rfc3339( $post['post_date'] );
584
+ $post_fields_extended['date_tz'] = $post_date->format( 'e' );
585
  $post_fields_extended['date_gmt'] = json_mysql_to_rfc3339( $post['post_date_gmt'] );
586
  }
587
 
588
  if ( $post['post_modified_gmt'] === '0000-00-00 00:00:00' ) {
589
+ $post_fields['modified'] = null;
590
+ $post_fields_extended['modified_tz'] = null;
591
  $post_fields_extended['modified_gmt'] = null;
592
  }
593
  else {
594
+ $modified_date = WP_JSON_DateTime::createFromFormat( 'Y-m-d H:i:s', $post['post_modified'], $timezone );
595
  $post_fields['modified'] = json_mysql_to_rfc3339( $post['post_modified'] );
596
+ $post_fields_extended['modified_tz'] = $modified_date->format( 'e' );
597
  $post_fields_extended['modified_gmt'] = json_mysql_to_rfc3339( $post['post_modified_gmt'] );
598
  }
599
 
947
  $post['ID'] = $post_ID;
948
  }
949
 
950
+ // Post meta
951
+ if ( ! empty( $data['post_meta'] ) ) {
952
+ $result = $this->handle_post_meta_action( $post_ID, $data );
953
+ if ( is_wp_error( $result ) ) {
954
+ return $result;
955
+ }
956
+ }
957
+
958
  // Sticky
959
  if ( isset( $data['sticky'] ) ) {
960
  if ( $data['sticky'] ) {
1027
  return $this->comments->_deprecated_call( 'prepare_comment', array( $comment, $requested_fields, $context ) );
1028
  }
1029
 
1030
+ /**
1031
+ * Update/add/delete meta for a post.
1032
+ *
1033
+ * @param int $post_id
1034
+ * @param array $data
1035
+ * @return bool|WP_Error
1036
+ */
1037
+ protected function handle_post_meta_action( $post_id, $data ) {
1038
+ $handler = new WP_JSON_Meta_Posts( $this->server );
1039
+
1040
+ return $handler->handle_inline_meta( $post_id, $data['post_meta'] );
1041
+ }
1042
+
1043
+ /**
1044
+ * Retrieve all meta for a post.
1045
+ *
1046
+ * @param int $post_id Post ID
1047
+ * @return (array[]|WP_Error) List of meta object data on success, WP_Error otherwise
1048
+ */
1049
+ protected function handle_get_post_meta( $post_id ) {
1050
+ $handler = new WP_JSON_Meta_Posts( $this->server );
1051
+
1052
+ return $handler->get_all_meta( $post_id );
1053
+ }
1054
+
1055
  /**
1056
  * Retrieve custom fields for object
1057
  *
1156
  return $handler->_deprecated_call( 'prepare_meta', array( $post, $data, $is_raw ) );
1157
  }
1158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1159
  /**
1160
  * Check if the data provided is valid data
1161
  *
vendor/wp-api/wp-api/lib/class-wp-json-server.php CHANGED
@@ -218,20 +218,21 @@ class WP_JSON_Server implements WP_JSON_ResponseHandler {
218
  }
219
 
220
  $this->path = $path;
221
-
222
- $this->method = $_SERVER['REQUEST_METHOD'];
223
- if ( ! empty( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
224
- $this->method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'];
225
- }
226
-
227
  $this->params['GET'] = $_GET;
228
  $this->params['POST'] = $_POST;
229
  $this->headers = $this->get_headers( $_SERVER );
230
  $this->files = $_FILES;
231
 
232
- // Compatibility for clients that can't use PUT/PATCH/DELETE
 
 
 
 
233
  if ( isset( $_GET['_method'] ) ) {
234
  $this->method = strtoupper( $_GET['_method'] );
 
 
235
  }
236
 
237
  $result = $this->check_authentication();
@@ -699,7 +700,7 @@ class WP_JSON_Server implements WP_JSON_ResponseHandler {
699
  * @deprecated
700
  * @param string $email Email address
701
  * @return string url for the user's avatar
702
- */
703
  public function get_avatar_url( $email ) {
704
  _deprecated_function( __CLASS__ . '::' . __METHOD__, 'WPAPI-1.1', 'json_get_avatar_url' );
705
 
@@ -740,4 +741,4 @@ class WP_JSON_Server implements WP_JSON_ResponseHandler {
740
 
741
  return $headers;
742
  }
743
- }
218
  }
219
 
220
  $this->path = $path;
221
+ $this->method = $_SERVER['REQUEST_METHOD'];
 
 
 
 
 
222
  $this->params['GET'] = $_GET;
223
  $this->params['POST'] = $_POST;
224
  $this->headers = $this->get_headers( $_SERVER );
225
  $this->files = $_FILES;
226
 
227
+ /**
228
+ * HTTP method override for clients that can't use PUT/PATCH/DELETE. First, we check
229
+ * $_GET['_method']. If that is not set, we check for the HTTP_X_HTTP_METHOD_OVERRIDE
230
+ * header.
231
+ */
232
  if ( isset( $_GET['_method'] ) ) {
233
  $this->method = strtoupper( $_GET['_method'] );
234
+ } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
235
+ $this->method = strtoupper( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] );
236
  }
237
 
238
  $result = $this->check_authentication();
700
  * @deprecated
701
  * @param string $email Email address
702
  * @return string url for the user's avatar
703
+ */
704
  public function get_avatar_url( $email ) {
705
  _deprecated_function( __CLASS__ . '::' . __METHOD__, 'WPAPI-1.1', 'json_get_avatar_url' );
706
 
741
 
742
  return $headers;
743
  }
744
+ }
vendor/wp-api/wp-api/lib/class-wp-json-taxonomies.php CHANGED
@@ -348,6 +348,7 @@ class WP_JSON_Taxonomies {
348
  'name' => $term->name,
349
  'slug' => $term->slug,
350
  'description' => $term->description,
 
351
  'parent' => (int) $term->parent,
352
  'count' => (int) $term->count,
353
  'link' => get_term_link( $term, $term->taxonomy ),
348
  'name' => $term->name,
349
  'slug' => $term->slug,
350
  'description' => $term->description,
351
+ 'taxonomy' => $term->taxonomy,
352
  'parent' => (int) $term->parent,
353
  'count' => (int) $term->count,
354
  'link' => get_term_link( $term, $term->taxonomy ),
vendor/wp-api/wp-api/plugin.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
- * Plugin Name: JSON REST API
4
  * Description: JSON-based REST API for WordPress, developed as part of GSoC 2013.
5
- * Author: Ryan McCue
6
- * Author URI: http://ryanmccue.info/
7
- * Version: 1.1.1
8
- * Plugin URI: https://github.com/rmccue/WP-API
9
  */
10
 
11
  /**
@@ -13,7 +13,7 @@
13
  *
14
  * @var string
15
  */
16
- define( 'JSON_API_VERSION', '1.1.1' );
17
 
18
  /**
19
  * Include our files for the API.
1
  <?php
2
  /**
3
+ * Plugin Name: WP REST API
4
  * Description: JSON-based REST API for WordPress, developed as part of GSoC 2013.
5
+ * Version: 1.2.0
6
+ * Author: WP REST API Team
7
+ * Author URI: http://wp-api.org/
8
+ * Plugin URI: https://github.com/WP-API/WP-API
9
  */
10
 
11
  /**
13
  *
14
  * @var string
15
  */
16
+ define( 'JSON_API_VERSION', '1.2.0' );
17
 
18
  /**
19
  * Include our files for the API.
vendor/wp-api/wp-api/tests/test-json-posts.php CHANGED
@@ -528,6 +528,52 @@ class WP_Test_JSON_Posts extends WP_Test_JSON_TestCase {
528
  $this->assertFalse( is_sticky( $response_data['ID'] ) );
529
  }
530
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
531
  function test_get_post() {
532
  $response = $this->endpoint->get_post( $this->post_id );
533
 
@@ -542,6 +588,24 @@ class WP_Test_JSON_Posts extends WP_Test_JSON_TestCase {
542
  $this->check_get_post_response( $response, $this->post_obj );
543
  }
544
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
545
  function test_get_revisions() {
546
  wp_update_post( array( 'post_content' => 'This content is better.', 'ID' => $this->post_id ) );
547
  wp_update_post( array( 'post_content' => 'This content is marvelous.', 'ID' => $this->post_id ) );
528
  $this->assertFalse( is_sticky( $response_data['ID'] ) );
529
  }
530
 
531
+ function test_create_post_with_meta() {
532
+ $data = $this->set_data( array(
533
+ 'post_meta' => array(
534
+ array(
535
+ 'key' => 'testkey',
536
+ 'value' => 'testvalue',
537
+ ),
538
+ ) ) );
539
+
540
+ $response = $this->endpoint->create_post( $data );
541
+ $response = json_ensure_response( $response );
542
+ $this->check_create_response( $response );
543
+
544
+ $response_data = $response->get_data();
545
+ $this->assertEquals( 1, count( $response_data['post_meta'] ) );
546
+
547
+ $post_meta_value = get_post_meta( $response_data['ID'], 'testkey', true );
548
+ $this->assertEquals( 'testvalue', $post_meta_value );
549
+ }
550
+
551
+ function test_create_post_with_multiple_meta() {
552
+ $data = $this->set_data( array(
553
+ 'post_meta' => array(
554
+ array(
555
+ 'key' => 'some_meta',
556
+ 'value' => 'some_value',
557
+ ),
558
+ array(
559
+ 'key' => 'some_other_meta',
560
+ 'value' => 'some_other_value',
561
+ ),
562
+ ) ) );
563
+
564
+ $response = $this->endpoint->create_post( $data );
565
+ $response = json_ensure_response( $response );
566
+ $this->check_create_response( $response );
567
+
568
+ $response_data = $response->get_data();
569
+ $this->assertEquals( 2, count( $response_data['post_meta'] ) );
570
+
571
+ $post_meta_first_value = get_post_meta( $response_data['ID'], 'some_meta', true );
572
+ $post_meta_second_value = get_post_meta( $response_data['ID'], 'some_other_meta', true );
573
+ $this->assertEquals( 'some_value', $post_meta_first_value );
574
+ $this->assertEquals( 'some_other_value', $post_meta_second_value );
575
+ }
576
+
577
  function test_get_post() {
578
  $response = $this->endpoint->get_post( $this->post_id );
579
 
588
  $this->check_get_post_response( $response, $this->post_obj );
589
  }
590
 
591
+ function test_get_post_edit_context() {
592
+ add_post_meta( $this->post_id, 'some_meta', 'some_value', true );
593
+ add_post_meta( $this->post_id, 'some_other_meta', 'some_other_value', true );
594
+
595
+ $response = $this->endpoint->get_post( $this->post_id, 'edit' );
596
+
597
+ $this->assertNotInstanceOf( 'WP_Error', $response );
598
+ $response = json_ensure_response( $response );
599
+ $this->check_get_post_response( $response, $this->post_obj );
600
+
601
+ $headers = $response->get_headers();
602
+ $this->assertEquals( 200, $response->get_status() );
603
+ $this->assertArrayHasKey( 'Last-Modified', $headers );
604
+
605
+ $response_data = $response->get_data();
606
+ $this->assertEquals( 2, count( $response_data['post_meta'] ) );
607
+ }
608
+
609
  function test_get_revisions() {
610
  wp_update_post( array( 'post_content' => 'This content is better.', 'ID' => $this->post_id ) );
611
  wp_update_post( array( 'post_content' => 'This content is marvelous.', 'ID' => $this->post_id ) );