Caldera Forms – More Than Contact Forms - Version 1.1.0

Version Description

(* August, 2014) =

Download this release

Release Info

Developer Desertsnowman
Plugin Icon 128x128 Caldera Forms – More Than Contact Forms
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.91 to 1.1.0

assets/css/admin.css CHANGED
@@ -448,6 +448,7 @@ textarea.block-input.field-config {
448
}
449
.block-input.field-config {
450
width: 100%;
451
}
452
.field-config.field-checkbox {
453
margin-top: 4px;
@@ -469,7 +470,7 @@ h3.caldera-editor-field-title {
469
color: #3f3f3f;
470
}
471
.caldera-editor-body.caldera-config-editor-panel.caldera-config-has-side {
472
- margin-right: 370px;
473
}
474
.caldera-config-editor-main-panel {
475
float: left;
@@ -477,22 +478,20 @@ h3.caldera-editor-field-title {
477
}
478
.caldera-config-editor-side-panel {
479
bottom: 30px;
480
- overflow: auto;
481
padding-right: 15px;
482
position: fixed;
483
right: 0;
484
top: 172px;
485
- width: 350px;
486
}
487
.caldera-config-editor-panel-group {
488
border-bottom: 1px solid #DFDFDF;
489
margin-bottom: 30px;
490
padding-bottom: 20px;
491
}
492
- .add-new-h2.caldera-add-page,
493
- .add-new-h2.caldera-add-row,
494
- .add-new-h2.caldera-add-row:active,
495
- .add-new-h2.caldera-add-page:active {
496
font-size: 10px;
497
margin: 4px 10px 4px 10px;
498
}
@@ -529,6 +528,50 @@ h3.caldera-editor-field-title {
529
display: inline-block;
530
margin-bottom: 12px;
531
width: 100%;
532
}
533
.caldera-config-field-break {
534
clear: both;
@@ -1494,3 +1537,9 @@ input.disabled-input {
1494
.form-panel .affix {
1495
position: fixed;
1496
}
448
}
449
.block-input.field-config {
450
width: 100%;
451
+ line-height: 20px;
452
}
453
.field-config.field-checkbox {
454
margin-top: 4px;
470
color: #3f3f3f;
471
}
472
.caldera-editor-body.caldera-config-editor-panel.caldera-config-has-side {
473
+ margin-right: 420px;
474
}
475
.caldera-config-editor-main-panel {
476
float: left;
478
}
479
.caldera-config-editor-side-panel {
480
bottom: 30px;
481
+ overflow-y: scroll;
482
padding-right: 15px;
483
position: fixed;
484
right: 0;
485
top: 172px;
486
+ width: 400px;
487
}
488
.caldera-config-editor-panel-group {
489
border-bottom: 1px solid #DFDFDF;
490
margin-bottom: 30px;
491
padding-bottom: 20px;
492
}
493
+ .caldera-config-editor-panel .add-new-h2 ,
494
+ .caldera-config-editor-panel .add-new-h2:active{
495
font-size: 10px;
496
margin: 4px 10px 4px 10px;
497
}
528
display: inline-block;
529
margin-bottom: 12px;
530
width: 100%;
531
+ position: relative;
532
+ }
533
+ .magic-tags-autocomplete {
534
+ background-color: #fff;
535
+ border: 1px solid #ddd;
536
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07);
537
+ box-sizing: border-box;
538
+ margin: 1px;
539
+ max-height: 160px;
540
+ overflow: auto;
541
+ padding: 0;
542
+ position: absolute;
543
+ top: auto;
544
+ width: 100%;
545
+ z-index: 999999;
546
+ }
547
+ .toggle_option_row .magic-tags-autocomplete {
548
+ width: 279px;
549
+ }
550
+ .magic-tags-autocomplete > ul {
551
+ margin: 0;
552
+ padding: 0;
553
+ }
554
+ .magic-tags-autocomplete > ul > li {
555
+ border-bottom: 1px solid #dfdfdf;
556
+ margin: 0;
557
+ padding: 5px 6px 6px 12px;
558
+ white-space: nowrap;
559
+ }
560
+ .magic-tags-autocomplete > ul > li.header {
561
+ border-bottom: 1px solid #dfdfdf;
562
+ font-style: italic;
563
+ font-weight: bold;
564
+ margin: 0;
565
+ padding: 5px 6px 6px;
566
+ }
567
+ .magic-tags-autocomplete > ul > li.tag {
568
+ cursor: pointer;
569
+ }
570
+ .magic-tags-autocomplete > ul > li.tag:hover {
571
+ background: none repeat scroll 0 0 #f5f5f5;
572
+ }
573
+ .magic-tags-autocomplete > ul > li.tag > strong {
574
+ color: #df2020;
575
}
576
.caldera-config-field-break {
577
clear: both;
1537
.form-panel .affix {
1538
position: fixed;
1539
}
1540
+ #extend_cf_baldrickModalBody h2 {
1541
+ font-size: 1.1em;
1542
+ margin: 0;
1543
+ padding: 4px 6px 6px;
1544
+ color: inherit;
1545
+ }
assets/css/caldera-form.css CHANGED
@@ -25,7 +25,6 @@
25
box-shadow: none;
26
-webkit-transition: none;
27
transition: none;
28
- -webkit-appearance: none;
29
}
30
.caldera-grid .form-control:hover {
31
border: 1px solid #b9b9b9;
@@ -1176,7 +1175,7 @@
1176
1177
.caldera-grid .breadcrumb {
1178
padding: 6px 12px;
1179
- margin-bottom: 20px;
1180
list-style: none;
1181
background-color: #f5f5f5;
1182
border-radius: 4px;
25
box-shadow: none;
26
-webkit-transition: none;
27
transition: none;
28
}
29
.caldera-grid .form-control:hover {
30
border: 1px solid #b9b9b9;
1175
1176
.caldera-grid .breadcrumb {
1177
padding: 6px 12px;
1178
+ margin: 0 0 20px;
1179
list-style: none;
1180
background-color: #f5f5f5;
1181
border-radius: 4px;
assets/css/editor-grid.css CHANGED
@@ -132,13 +132,15 @@
132
padding: 12px 0;
133
position: relative;
134
}
135
- .column-fieldinsert .dashicons.dashicons-plus-alt {
136
background: none repeat scroll 0 0 #EFEFEF;
137
color: #6C6C6C;
138
font-size: 13px;
139
margin-top: -3px;
140
padding: 2px;
141
}
142
.column-fieldinsert.column-tools {
143
bottom: -10px;
144
left: 50%;
@@ -308,14 +310,39 @@
308
.caldera-condition-line:first-child .caldera-condition-line-label{
309
display: none;
310
}
311
.caldera-editor-field-config-wrapper .caldera-conditional-value-field {
312
- margin: 12px;
313
max-width: 263px !important;
314
width: 263px !important;
315
}
316
.caldera-editor-field-config-wrapper .button.remove-conditional-line.pull-right {
317
margin-top: -12px;
318
}
319
.settings-panel.settings-core{ display: block;}
320
321
.layout-new-form-field .drag-handle,
132
padding: 12px 0;
133
position: relative;
134
}
135
+ .column-fieldinsert .dashicons.dashicons-admin-generic,
136
+ .column-fieldinsert .dashicons.dashicons-plus-alt {
137
background: none repeat scroll 0 0 #EFEFEF;
138
color: #6C6C6C;
139
font-size: 13px;
140
margin-top: -3px;
141
padding: 2px;
142
}
143
+ .column-fieldinsert.column-tools ,
144
.column-fieldinsert.column-tools {
145
bottom: -10px;
146
left: 50%;
310
.caldera-condition-line:first-child .caldera-condition-line-label{
311
display: none;
312
}
313
+ .caldera-editor-field-config-wrapper .caldera-conditional-field-value {
314
+ display: inline-block;
315
+ margin: 12px 12px 0 0;
316
+ position: relative;
317
+ }
318
.caldera-editor-field-config-wrapper .caldera-conditional-value-field {
319
max-width: 263px !important;
320
width: 263px !important;
321
}
322
.caldera-editor-field-config-wrapper .button.remove-conditional-line.pull-right {
323
margin-top: -12px;
324
}
325
+ .icn-code.magic-tag-init {
326
+ background: none repeat scroll 0 0 #f9f9f9;
327
+ border-bottom: 1px solid #ddd;
328
+ border-left: 1px solid #ddd;
329
+ cursor: pointer;
330
+ opacity: 0.5;
331
+ padding: 7px 6px 6px;
332
+ position: absolute;
333
+ right: 1px;
334
+ top: 2px;
335
+ }
336
+ .icn-code.magic-tag-init:hover {
337
+ color: #404040;
338
+ opacity: 1;
339
+ }
340
+ .field-config.magic-tag-enabled {
341
+ padding-right: 26px;
342
+ }
343
+ textarea.field-config.magic-tag-enabled {
344
+ resize: vertical;
345
+ }
346
.settings-panel.settings-core{ display: block;}
347
348
.layout-new-form-field .drag-handle,
assets/css/modals.css CHANGED
@@ -26,9 +26,17 @@
26
width: 500px;
27
z-index: 100105;
28
}
29
.caldera-modal-title {
30
border-bottom: 1px solid #EFEFEF;
31
}
32
.caldera-modal-closer {
33
color: #808080;
34
float: right;
@@ -36,6 +44,17 @@
36
padding: 12px;
37
text-decoration: none;
38
}
39
.caldera-modal-title > h3 {
40
font-weight: 400;
41
margin: 0;
@@ -54,7 +73,15 @@
54
padding: 12px 12px 8.9px;
55
position: absolute;
56
right: 0;
57
- top: 43px;
58
}
59
.caldera-modal-body .import-warning{
60
margin: 0;
@@ -238,4 +265,18 @@ input.disabled-input {
238
239
.modal-tab-panel {
240
margin-left: 150px;
241
}
26
width: 500px;
27
z-index: 100105;
28
}
29
+ .caldera-modal-wrap.caldera-front-modal-wrap{
30
+ position: absolute;
31
+ bottom: auto;
32
+ width: 600px;
33
+ margin-left: -300px;
34
+ margin-top: 0;
35
+ }
36
.caldera-modal-title {
37
border-bottom: 1px solid #EFEFEF;
38
}
39
+
40
.caldera-modal-closer {
41
color: #808080;
42
float: right;
44
padding: 12px;
45
text-decoration: none;
46
}
47
+ .caldera-modal-closer.caldera-front-modal-closer{
48
+ position: absolute;
49
+ right: 0;
50
+ text-decoration: none;
51
+ color: inherit;
52
+ }
53
+ .caldera-modal-closer.caldera-front-modal-closer:hover,
54
+ .caldera-modal-closer.caldera-front-modal-closer:active{
55
+ text-decoration: none;
56
+ color: inherit;
57
+ }
58
.caldera-modal-title > h3 {
59
font-weight: 400;
60
margin: 0;
73
padding: 12px 12px 8.9px;
74
position: absolute;
75
right: 0;
76
+ top: 43px;
77
+ }
78
+ #extend_cf_baldrickModalBody{
79
+ overflow: auto;
80
+ }
81
+ .caldera-modal-body.caldera-front-modal-body {
82
+ bottom: auto;
83
+ position: relative;
84
+ top: auto;
85
}
86
.caldera-modal-body .import-warning{
87
margin: 0;
265
266
.modal-tab-panel {
267
margin-left: 150px;
268
+ }
269
+
270
+ @media (max-width: 600px) {
271
+ /* Small Screens */
272
+ .caldera-modal-wrap.caldera-front-modal-wrap{
273
+ bottom: 0;
274
+ display: block;
275
+ left: 0;
276
+ margin: 0 !important;
277
+ overflow: auto;
278
+ padding: 0 !important;
279
+ top: 0;
280
+ width: 100% !important;
281
+ }
282
}
assets/js/admin.js CHANGED
@@ -1,7 +1,7 @@
1
var baldrickTriggers, loop_loader;
2
3
jQuery(function($){
4
-
5
// admin stuff!
6
// Baldrick Bindings
7
baldrickTriggers = function(){
@@ -42,7 +42,6 @@ jQuery(function($){
42
43
panels.hide();
44
panel.show();
45
-
46
});
47
48
// Profile Repeatable Group Remove
@@ -73,4 +72,4 @@ jQuery(function($){
73
74
75
76
- });
1
var baldrickTriggers, loop_loader;
2
3
jQuery(function($){
4
+
5
// admin stuff!
6
// Baldrick Bindings
7
baldrickTriggers = function(){
42
43
panels.hide();
44
panel.show();
45
});
46
47
// Profile Repeatable Group Remove
72
73
74
75
+ });
assets/js/edit.js CHANGED
@@ -182,7 +182,6 @@ jQuery(function($){
182
// seup options
183
parent.find('.toggle_show_values').trigger('change');
184
185
-
186
}
187
188
function build_field_preview(id){
@@ -760,14 +759,14 @@ jQuery(function($){
760
lineid = field.data('line'),
761
target = $('#' + lineid + "_value"),
762
curval = target.find('.caldera-conditional-value-field').first();
763
- //console.log(lineid + "_value");
764
765
// check if a value is present
766
767
if(curval.length){
768
if(curval.val().length){
769
target.data('value', curval.val());
770
- console.log(curval.val());
771
}
772
}
773
@@ -782,7 +781,6 @@ jQuery(function($){
782
783
if(target.data('value')){
784
if(target.data('value').toString() === value){
785
- console.log('YES');
786
sel = ' selected="selected"';
787
}
788
}
@@ -794,7 +792,7 @@ jQuery(function($){
794
795
}else{
796
797
- out = '<input name="' + name + '[value]" type="text" class="caldera-conditional-value-field" value="' + (target.data('value') ? target.data('value') : '') + '" style="max-width: 165px;">';
798
}
799
800
@@ -843,11 +841,11 @@ jQuery(function($){
843
field_lables = wrap.find('.caldera-config-group-option-labels');
844
845
if(!clicked.prop('checked')){
846
- values.prop('disabled', true).hide();
847
lables.css('width', 245);
848
field_lables.hide();
849
}else{
850
- values.prop('disabled', false).show();
851
lables.css('width', '');
852
field_lables.show();
853
}
@@ -855,5 +853,215 @@ jQuery(function($){
855
lables.trigger('toggle.values');
856
857
});
858
});//
859
182
// seup options
183
parent.find('.toggle_show_values').trigger('change');
184
185
}
186
187
function build_field_preview(id){
759
lineid = field.data('line'),
760
target = $('#' + lineid + "_value"),
761
curval = target.find('.caldera-conditional-value-field').first();
762
+
763
764
// check if a value is present
765
766
if(curval.length){
767
if(curval.val().length){
768
target.data('value', curval.val());
769
+
770
}
771
}
772
781
782
if(target.data('value')){
783
if(target.data('value').toString() === value){
784
sel = ' selected="selected"';
785
}
786
}
792
793
}else{
794
795
+ out = '<input name="' + name + '[value]" type="text" class="caldera-conditional-value-field magic-tag-enabled" value="' + (target.data('value') ? target.data('value') : '') + '" style="max-width: 165px;">';
796
}
797
798
841
field_lables = wrap.find('.caldera-config-group-option-labels');
842
843
if(!clicked.prop('checked')){
844
+ values.prop('disabled', true).hide().parent().hide();
845
lables.css('width', 245);
846
field_lables.hide();
847
}else{
848
+ values.prop('disabled', false).show().parent().show();
849
lables.css('width', '');
850
field_lables.show();
851
}
853
lables.trigger('toggle.values');
854
855
});
856
+
857
+ // autopopulate
858
+ $('.caldera-editor-body').on('change', '.auto-populate-type', function(){
859
+ $(this).closest('.wrapper-instance-pane').find('.auto-populate-options').trigger('change');
860
+ });
861
+ $('.caldera-editor-body').on('change', '.auto-populate-options', function(){
862
+ var clicked = $(this),
863
+ wrap = clicked.closest('.wrapper-instance-pane'),
864
+ manual = wrap.find('.caldera-config-group-toggle-options'),
865
+ autotype_wrap = wrap.find('.caldera-config-group-auto-options'),
866
+ autotype = autotype_wrap.find('.auto-populate-type');
867
+
868
+ autotype_wrap.find('.auto-populate-type-panel').hide();
869
+
870
+ if(clicked.prop('checked')){
871
+ manual.hide();
872
+ autotype_wrap.show();
873
+ }else{
874
+ manual.show();
875
+ autotype_wrap.hide();
876
+ }
877
+
878
+ autotype_wrap.find('.caldera-config-group-auto-' + autotype.val()).show();
879
+
880
+ });
881
+
882
+
883
+ $('body').on('click', '.magic-tag-init', function(e){
884
+ var clicked = $(this),
885
+ input = clicked.prev();
886
+
887
+ input.focus().trigger('init.magic');
888
+
889
+ });
890
+ // show magic tag autocompletes
891
+ $('body').on('keyup blur focus select click init.magic', '.magic-tag-enabled', function(e){
892
+ var input = $(this),
893
+ wrap = input.parent(),
894
+ fieldtype = ( wrap.closest('.wrapper-instance-pane').find('.caldera-select-field-type').val() ? wrap.closest('.wrapper-instance-pane').find('.caldera-select-field-type').val() : 'hidden' ),
895
+ tags = wrap.find('.magic-tags-autocomplete'),
896
+ list = tags.find('ul'),
897
+ //basevalue = this.value.substr( this.selectionEnd ),
898
+ stream = this.value,//.substr(0, this.selectionStart ),
899
+ tag = [],
900
+ type_instances = [],
901
+ current_tag = '',
902
+ start = this.selectionStart,
903
+ end = this.selectionEnd;
904
+
905
+ //reset typed tag
906
+ input.data('tag','');
907
+ if(this.selectionEnd > this.selectionStart){
908
+ current_tag = this.value.substr(this.selectionStart, ( this.selectionEnd - this.selectionStart) );
909
+ }else{
910
+
911
+ if( ( e.type === 'select' || e.type === 'keyup' ) && ( e.which !== 40 && e.which !== 38 && e.which !== 39 && e.which !== 37 ) ){
912
+
913
+ for( start=this.selectionStart; start > 0; start--){
914
+
915
+ var ch = stream.substr(start-1,1);
916
+
917
+ if(ch === ' ' || ch === "\n" || ( ( ch === '%' || ch === '}' ) && this.selectionStart === start ) ){
918
+ break;
919
+ }
920
+ }
921
+ for( end=this.selectionStart; end < stream.length; end++){
922
+
923
+ var ch = stream.substr(end,1);
924
+
925
+ if(ch === ' ' || ch === "\n" || ( ( ch === '%' || ch === '{' ) && this.selectionStart === end ) ){
926
+ break;
927
+ }
928
+ }
929
+ //if(end > this.selectionEnd){
930
+ current_tag = stream.substr(start, ( end - start ) );
931
+ }
932
+ //}
933
+ }
934
+
935
+ // start matching
936
+ if( e.type !== 'focusout' ){
937
+
938
+ if( e.type !== 'init' && current_tag.length < 3 ){
939
+ if(tags.length){
940
+ tags.remove();
941
+ }
942
+ return;
943
+ }
944
+ if(!tags.length){
945
+ tags = $('<div class="magic-tags-autocomplete"></div>');
946
+ list = $('<ul></ul>');
947
+ list.appendTo(tags);
948
+ tags.insertAfter(input);
949
+ }
950
+
951
+ //populate
952
+ list.empty();
953
+ // compatibility
954
+ var tagtypes = 'system';
955
+ var is_static = false;
956
+ if(fieldtype === 'hidden' || fieldtype === 'dropdown' || fieldtype === 'radio' || fieldtype === 'toggle_switch' || fieldtype === 'checkbox'){
957
+ is_static = true;
958
+ fieldtype = 'text';
959
+ tagtypes = 'all';
960
+ }else if(fieldtype === 'paragraph' || fieldtype === 'html'){
961
+ fieldtype = 'text';
962
+ }
963
+ // type set
964
+ if(input.data('type')){
965
+ fieldtype = input.data('type');
966
+ }
967
+ // search em!
968
+ fieldtype = fieldtype.split(',');
969
+ fieldtype.push('vars');
970
+ for( var ft = 0; ft < fieldtype.length; ft++){
971
+ for( var tp in system_values ){
972
+ if(typeof system_values[tp].tags[fieldtype[ft]] === 'undefined'){
973
+ continue;
974
+ }
975
+
976
+ type_instances = [tp];
977
+ if(tp !== 'system' && tp !== 'variable' && tp !== 'field'){
978
+ var type_instance_confs = jQuery(".processor-" + tp),
979
+ wrapper = input.closest('.caldera-editor-processor-config-wrapper'),
980
+ wrapper_id = wrapper.prop('id');
981
+ type_instances = [];
982
+ // processor based - orderd
983
+ for(var c = 0; c<type_instance_confs.length; c++){
984
+ if(!wrapper.length && is_static === true ){
985
+ // static non processor - can be used
986
+ type_instances.push(type_instance_confs[c].id);
987
+ }else{
988
+ if(wrapper_id === type_instance_confs[c].id){
989
+ continue;
990
+ }
991
+
992
+ // check index order is valid
993
+ if(jQuery('li.'+type_instance_confs[c].id).index() < jQuery('li.'+wrapper_id).index()){
994
+ type_instances.push(type_instance_confs[c].id);
995
+ }
996
+ }
997
+
998
+ }
999
+
1000
+ }
1001
+ // all instances of tag
1002
+ for( var instance = 0; instance < type_instances.length; instance++){
1003
+ if(tagtypes === 'all' || tagtypes === tp || tp === 'variable'){
1004
+
1005
+ var heading = $('<li class="header">' + system_values[tp].type + ( instance > 0 ? ' ['+(instance+1)+']' : '' ) +'</li>'),
1006
+ matches = 0;
1007
+ heading.appendTo(list);
1008
+
1009
+ for( var i = 0; i < system_values[tp].tags[fieldtype[ft]].length; i++){
1010
+
1011
+ if(input.data('parent')){
1012
+ if('variable:'+input.data('parent') === system_values[tp].tags[fieldtype[ft]][i]){
1013
+ continue;
1014
+ }
1015
+ }
1016
+
1017
+ var this_tag = system_values[tp].wrap[0] + system_values[tp].tags[fieldtype[ft]][i]+system_values[tp].wrap[1];
1018
+ if(type_instances[instance] !== tp && type_instances.length > 1){
1019
+ this_tag = system_values[tp].wrap[0] + system_values[tp].tags[fieldtype[ft]][i]+':'+type_instances[instance]+system_values[tp].wrap[1];
1020
+ }
1021
+ if( this_tag.indexOf(current_tag) >= 0 || e.type === 'init'){
1022
+
1023
+ matches += 1;
1024
+ var view_tag = this_tag.replace(current_tag, '<strong>' + current_tag + '</strong>');
1025
+
1026
+ var linetag = $('<li class="tag" data-tag="'+this_tag+'">' + view_tag + '</li>');
1027
+
1028
+
1029
+ linetag.on('click', function(){
1030
+ var selected = $(this).data('tag');
1031
+
1032
+
1033
+ input.val( stream.substr(0, start ) + selected + stream.substr( end ) ).trigger('change').focus();
1034
+ input[0].selectionStart = start + selected.length - ( selected.indexOf('*') > 0 ? 2 : 0 );
1035
+ input[0].selectionEnd = start + selected.length - ( selected.indexOf('*') > 0 ? 1 : 0 );
1036
+
1037
+ });
1038
+
1039
+ linetag.appendTo(list);
1040
+ }
1041
+ }
1042
+ if(matches === 0){
1043
+ heading.remove();
1044
+ }
1045
+ }
1046
+ }
1047
+ }
1048
+ }
1049
+ }
1050
+ // count results found
1051
+ if(!list.children().length){
1052
+ tags.remove();
1053
+ }
1054
+
1055
+ // focus out - remove
1056
+ if(e.type === 'focusout'){
1057
+ setTimeout(function(){
1058
+
1059
+ tags.remove();
1060
+ }, 200);
1061
+ }
1062
+
1063
+
1064
+ })
1065
+
1066
});//
1067
assets/js/frontend-script-init.js CHANGED
@@ -8,7 +8,17 @@
8
}
9
});
10
});
11
-
12
// Page navigation
13
$(document).on('click', '[data-page]', function(e){
14
var clicked = $(this),
@@ -23,7 +33,7 @@
23
if(breadcrumb){
24
breadcrumb.find('li.active').removeClass('active');
25
}
26
- next = $('.caldera-form-page[data-formpage="'+ ( page + 1 ) +'"]');
27
if(next.length){
28
page_box.hide();
29
next.show();
@@ -35,7 +45,7 @@
35
if(breadcrumb){
36
breadcrumb.find('li.active').removeClass('active');
37
}
38
- prev = $('.caldera-form-page[data-formpage="'+ ( page - 1 ) +'"]');
39
if(prev.length){
40
page_box.hide();
41
prev.show();
@@ -48,7 +58,7 @@
48
e.preventDefault();
49
clicked.closest('.breadcrumb').find('li.active').removeClass('active');
50
$('#' + clicked.data('pagenav') + ' .caldera-form-page').hide();
51
- $('.caldera-form-page[data-formpage="'+ ( clicked.data('page') ) +'"]').show();
52
clicked.parent().addClass('active');
53
}
54
@@ -63,7 +73,7 @@
63
$(v).find('a[data-pagenav]').each(function(i,e){
64
var tab = $(e),
65
form = tab.data('pagenav'),
66
- page = $('.caldera-form-page[data-formpage="' + tab.data('page') + '"]');
67
68
if(page.find('.has-error').length){
69
tab.parent().addClass('error');
8
}
9
});
10
});
11
+ // modals activation
12
+ $(document).on('click', '.cf_modal_button', function(e){
13
+ e.preventDefault();
14
+ var clicked = $(this);
15
+ $(clicked.attr('href')).show();
16
+ });
17
+ $(document).on('click', '.caldera-front-modal-closer', function(e){
18
+ e.preventDefault();
19
+ var clicked = $(this);
20
+ clicked.closest('.caldera-front-modal-container').hide();
21
+ });
22
// Page navigation
23
$(document).on('click', '[data-page]', function(e){
24
var clicked = $(this),
33
if(breadcrumb){
34
breadcrumb.find('li.active').removeClass('active');
35
}
36
+ next = form.find('.caldera-form-page[data-formpage="'+ ( page + 1 ) +'"]');
37
if(next.length){
38
page_box.hide();
39
next.show();
45
if(breadcrumb){
46
breadcrumb.find('li.active').removeClass('active');
47
}
48
+ prev = form.find('.caldera-form-page[data-formpage="'+ ( page - 1 ) +'"]');
49
if(prev.length){
50
page_box.hide();
51
prev.show();
58
e.preventDefault();
59
clicked.closest('.breadcrumb').find('li.active').removeClass('active');
60
$('#' + clicked.data('pagenav') + ' .caldera-form-page').hide();
61
+ $('#' + clicked.data('pagenav') + ' .caldera-form-page[data-formpage="'+ ( clicked.data('page') ) +'"]').show();
62
clicked.parent().addClass('active');
63
}
64
73
$(v).find('a[data-pagenav]').each(function(i,e){
74
var tab = $(e),
75
form = tab.data('pagenav'),
76
+ page = $('#'+ form +' .caldera-form-page[data-formpage="' + tab.data('page') + '"]');
77
78
if(page.find('.has-error').length){
79
tab.parent().addClass('error');
assets/js/handlebars.js CHANGED
@@ -2744,3 +2744,31 @@ var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, _
2744
2745
return __module0__;
2746
})();
2744
2745
return __module0__;
2746
})();
2747
+
2748
+
2749
+ /* custom helpers */
2750
+ Handlebars.registerHelper("is_single", function(value, options) {
2751
+ if(Object.keys(value).length !== 1){
2752
+ return false;
2753
+ }else{
2754
+ return options.fn(this);
2755
+ }
2756
+ });
2757
+ Handlebars.registerHelper("script", function(options) {
2758
+ if(options.hash.src){
2759
+ return '<script type="text/javascript" src="' + options.fn(this) + '"></script>';
2760
+ }else{
2761
+ return '<script type="text/javascript">' + options.fn(this) + '</script>';
2762
+ }
2763
+ });
2764
+ Handlebars.registerHelper("is", function(value, options) {
2765
+
2766
+ if(options.hash.value === '@key'){
2767
+ options.hash.value = options.data.key;
2768
+ }
2769
+ if(options.hash.value === value){
2770
+ return options.fn(this);
2771
+ }else{
2772
+ return false;
2773
+ }
2774
+ });
assets/js/layout-grid.js CHANGED
@@ -1,11 +1,41 @@
1
- var rebuild_field_binding, rebind_field_bindings, current_form_fields = {}, required_errors = {}, add_new_grid_page, add_page_grid;
2
3
rebuild_field_binding = function(){
4
5
var fields = jQuery('.caldera-editor-field-config-wrapper');
6
-
7
// clear list
8
current_form_fields = {};
9
10
fields.each(function(fk,fv){
11
var field_id = jQuery(fv).prop('id'),
@@ -13,6 +43,15 @@ rebuild_field_binding = function(){
13
slug = jQuery('#' + field_id + '_slug').val(),
14
type = jQuery('#' + field_id + '_type').val();
15
16
current_form_fields[field_id] = {
17
label: label,
18
slug: slug,
@@ -20,13 +59,15 @@ rebuild_field_binding = function(){
20
};
21
22
});
23
-
24
rebind_field_bindings();
25
26
};
27
28
rebind_field_bindings = function(){
29
30
var bindings = jQuery('.caldera-field-bind'),
31
type_instances,
32
processor_li;
@@ -40,63 +81,69 @@ rebind_field_bindings = function(){
40
count = 0,
41
wrapper = field.closest('.caldera-editor-processor-config-wrapper'),
42
wrapper_id = wrapper.prop('id'),
43
- valid;
44
45
if(default_sel){
46
current = default_sel;
47
}
48
49
- field.empty();
50
51
- var optgroup = jQuery('<optgroup label="Fields">');
52
- for(var fid in current_form_fields){
53
- if(field.data('type')){
54
- if(field.data('type').split(',').indexOf(current_form_fields[fid].type) < 0){
55
- continue;
56
- }
57
58
- }
59
- optgroup.append('<option value="' + fid + '"' + ( current === fid ? 'selected="selected"' : '' ) + '>' + current_form_fields[fid].label + ' [' + current_form_fields[fid].slug + ']</option>');
60
- count += 1;
61
- }
62
- optgroup.appendTo(field);
63
- // system values
64
- if(count === 0){
65
- field.empty();
66
- }
67
-
68
- for(var type in system_values){
69
- type_instances = [];
70
-
71
- if(excludes){
72
- if( excludes.split(',').indexOf(type) >= 0 ){
73
- continue;
74
}
75
}
76
-
77
- if(type !== 'system' ){
78
- type_instance_confs = jQuery(".processor-" + type);
79
-
80
- for(var c = 0; c<type_instance_confs.length; c++){
81
- if(wrapper_id === type_instance_confs[c].id){
82
continue;
83
}
84
85
- type_instances.push(type_instance_confs[c].id);
86
- if(type_instance_confs.length > 1){
87
- if(processor_li = jQuery('li.'+type_instance_confs[c].id + ' .processor-line-number')){
88
- processor_li.html('[' + ( c + 1 ) + ']');
89
}
90
- }
91
92
- }
93
- }else{
94
- type_instances.push('__system__');
95
- }
96
-
97
- if(field.data('type')){
98
99
- var types = field.data('type').split(',');
100
101
for(var t = 0; t<types.length; t++){
102
if(system_values[type].tags[types[t]]){
@@ -105,8 +152,9 @@ rebind_field_bindings = function(){
105
106
// check index order is valid
107
if(jQuery('li.'+type_instances[instance]).index() > jQuery('li.'+wrapper_id).index() && type_instances[instance] !== '__system__'){
108
- //console.log('lower');
109
- valid = ' disabled="disabled"';
110
}else{
111
valid = '';
112
}
@@ -139,64 +187,31 @@ rebind_field_bindings = function(){
139
140
}
141
}
142
- }else{
143
-
144
- if(system_values[type].tags.text){
145
-
146
- for( var instance = 0; instance < type_instances.length; instance++){
147
-
148
- // check index order is valid
149
- if(jQuery('li.'+type_instances[instance]).index() > jQuery('li.'+wrapper_id).index() && type_instances[instance] !== '__system__'){
150
- //console.log('lower');
151
- valid = ' disabled="disabled"';
152
- }else{
153
- valid = '';
154
- }
155
-
156
- var optgroup = jQuery('<optgroup label="' + system_values[type].type + ( type_instances[instance] !== '__system__' ? ' ' + ( jQuery('li.'+type_instances[instance]).find('.processor-line-number').html() ) : '' ) + '"' + valid + '>');
157
-
158
-
159
- for( var i = 0; i < system_values[type].tags.text.length; i++){
160
-
161
- var bind_value = system_values[type].tags.text[i];
162
- // update labels on multiple
163
- if(type_instances[instance] !== '__system__'){
164
- bind_value = bind_value.replace(type ,type_instances[instance]);
165
- }
166
-
167
- optgroup.append('<option value="{' + bind_value + '}"' + ( current === '{'+bind_value+'}' ? 'selected="selected"' : '' ) + valid + '>' + system_values[type].tags.text[i] + '</option>');
168
- count += 1;
169
-
170
- }
171
-
172
- if(optgroup.children().length){
173
- optgroup.appendTo(field);
174
- }
175
-
176
- }
177
-
178
- }
179
180
}
181
-
182
- }
183
- if(count === 0){
184
- field.empty();
185
- if(field.data('type')){
186
- field.append('<option value="">No ' + field.data('type').split(',').join(' or ') + ' in form</option>').prop('disabled', true);
187
- var no_options = true;
188
}
189
}else{
190
- field.prop('disabled', false);
191
}
192
-
193
- if(!field.hasClass('required') && typeof no_options === 'undefined'){
194
- field.prepend('<option value=""></option>');
195
- }
196
- field.val(current);
197
});
198
199
check_required_bindings();
200
};
201
202
function setup_field_type(obj){
@@ -224,15 +239,17 @@ function check_required_bindings(){
224
required_errors = {};
225
226
fields.each(function(k,v){
227
- if(!v.value.length){
228
- var field = jQuery(v),
229
- panel = field.closest('.caldera-config-editor-panel'),
230
- is_field = field.closest('.caldera-editor-field-config-wrapper'),
231
- is_process = field.closest('.caldera-editor-processor-config-wrapper');
232
233
if(!required_errors[panel.prop('id')]){
234
required_errors[panel.prop('id')] = 0;
235
}
236
if(is_field.length){
237
jQuery('.layout-form-field[data-config="'+is_field.prop('id')+'"]').addClass('has-error');
238
}
@@ -244,6 +261,33 @@ function check_required_bindings(){
244
245
//tab.append('<span class="error-tag">' + required_errors[panel.prop('id')] + '</span>');
246
247
}
248
});
249
@@ -456,13 +500,16 @@ jQuery(function($) {
456
};
457
buildSortables();
458
459
- $('#grid-pages-panel').on('click','.column-fieldinsert', function(e){
460
//newfield-tool
461
var target = $(this).closest('.column-container'),
462
newfield = $('#newfield-tool').clone();
463
464
insert_new_field(newfield, target);
465
466
});
467
/*
468
$('#grid-pages-panel').on('click','.icon-filter', function(e){
@@ -686,6 +733,8 @@ jQuery(function($) {
686
}
687
688
$(document).trigger('show.' + panel.data('config'));
689
});
690
$('body').on('click', '.layout-modal-edit-closer,.layout-modal-save-action', function(e){
691
@@ -895,31 +944,7 @@ jQuery(function($) {
895
896
897
898
- Handlebars.registerHelper("is_single", function(value, options) {
899
- if(Object.keys(value).length !== 1){
900
- return false;
901
- }else{
902
- return options.fn(this);
903
- }
904
- });
905
- Handlebars.registerHelper("script", function(options) {
906
- if(options.hash.src){
907
- return '<script type="text/javascript" src="' + options.fn(this) + '"></script>';
908
- }else{
909
- return '<script type="text/javascript">' + options.fn(this) + '</script>';
910
- }
911
- });
912
- Handlebars.registerHelper("is", function(value, options) {
913
- //console.log(value);
914
- if(options.hash.value === '@key'){
915
- options.hash.value = options.data.key;
916
- }
917
- if(options.hash.value === value){
918
- return options.fn(this);
919
- }else{
920
- return false;
921
- }
922
- });
923
Handlebars.registerHelper("_options_config", function() {
924
//console.log(this);
925
});
1
+ var rebuild_field_binding, rebind_field_bindings, current_form_fields = {}, required_errors = {}, add_new_grid_page, add_page_grid, init_magic_tags;
2
+
3
+ init_magic_tags = function(){
4
+ //init magic tags
5
+ var magicfields = jQuery('.magic-tag-enabled').not('.magic-tag-init-bound');
6
+
7
+ magicfields.each(function(k,v){
8
+ var input = jQuery(v);
9
+
10
+ /*if(input.hasClass('magic-tag-init-bound')){
11
+ return;
12
+ }*/
13
+ var magictag = jQuery('<span class="icn-code magic-tag-init"></span>'),
14
+ wrapper = jQuery('<span style="position:relative;display:inline-block; width:100%;"></span>');
15
+
16
+ if(input.is('input')){
17
+ magictag.css('borderBottom', 'none');
18
+ }
19
+ input.wrap(wrapper);
20
+ magictag.insertAfter(input);
21
+ input.addClass('magic-tag-init-bound');
22
+ });
23
+ }
24
25
rebuild_field_binding = function(){
26
27
var fields = jQuery('.caldera-editor-field-config-wrapper');
28
+
29
// clear list
30
current_form_fields = {};
31
+ // set object
32
+ system_values.field = {
33
+ tags : {
34
+ text : []
35
+ },
36
+ type : "Fields",
37
+ wrap : ['%','%']
38
+ };
39
40
fields.each(function(fk,fv){
41
var field_id = jQuery(fv).prop('id'),
43
slug = jQuery('#' + field_id + '_slug').val(),
44
type = jQuery('#' + field_id + '_type').val();
45
46
+
47
+ if(typeof system_values.field.tags[type] === 'undefined'){
48
+ system_values.field.tags[type] = [];
49
+ }
50
+ system_values.field.tags[type].push( slug );
51
+ if(type !== 'text'){
52
+ system_values.field.tags.text.push( slug );
53
+ }
54
+
55
current_form_fields[field_id] = {
56
label: label,
57
slug: slug,
59
};
60
61
});
62
rebind_field_bindings();
63
64
};
65
66
rebind_field_bindings = function(){
67
68
+ //check_required_bindings();
69
+
70
+ //return;
71
var bindings = jQuery('.caldera-field-bind'),
72
type_instances,
73
processor_li;
81
count = 0,
82
wrapper = field.closest('.caldera-editor-processor-config-wrapper'),
83
wrapper_id = wrapper.prop('id'),
84
+ valid = '';
85
86
if(default_sel){
87
current = default_sel;
88
}
89
90
+ if(field.is('select')){
91
+ field.empty();
92
93
+ var optgroup = jQuery('<optgroup label="Fields">');
94
+ for(var fid in current_form_fields){
95
+ if(field.data('type')){
96
+ if(field.data('type').split(',').indexOf(current_form_fields[fid].type) < 0){
97
+ continue;
98
+ }
99
100
}
101
+ optgroup.append('<option value="' + fid + '"' + ( current === fid ? 'selected="selected"' : '' ) + '>' + current_form_fields[fid].label + ' [' + current_form_fields[fid].slug + ']</option>');
102
+ count += 1;
103
}
104
+ optgroup.appendTo(field);
105
+ // system values
106
+ if(count === 0){
107
+ field.empty();
108
+ }
109
+
110
+ for(var type in system_values){
111
+ type_instances = [];
112
+
113
+ if(excludes){
114
+ if( excludes.split(',').indexOf(type) >= 0 ){
115
continue;
116
}
117
+ }
118
+
119
+ if(type !== 'system' && type !== 'variable'){
120
121
+ var type_instance_confs = jQuery(".processor-" + type);
122
+
123
+ for(var c = 0; c<type_instance_confs.length; c++){
124
+ if(wrapper_id === type_instance_confs[c].id){
125
+ continue;
126
}
127
128
+ type_instances.push(type_instance_confs[c].id);
129
+ if(type_instance_confs.length > 1){
130
+ if(processor_li = jQuery('li.'+type_instance_confs[c].id + ' .processor-line-number')){
131
+ processor_li.html('[' + ( c + 1 ) + ']');
132
+ }
133
+ }
134
135
+ }
136
+ }else{
137
+ type_instances.push('__system__');
138
+ }
139
+
140
+ var types = [];
141
+ if(field.data('type')){
142
+ types = field.data('type').split(',');
143
+ types.push('vars');
144
+ }else{
145
+ types = ['text','vars'];
146
+ }
147
148
for(var t = 0; t<types.length; t++){
149
if(system_values[type].tags[types[t]]){
152
153
// check index order is valid
154
if(jQuery('li.'+type_instances[instance]).index() > jQuery('li.'+wrapper_id).index() && type_instances[instance] !== '__system__'){
155
+ if( field.closest('.caldera-editor-processors-panel-wrap').length ){
156
+ valid = ' disabled="disabled"';
157
+ }
158
}else{
159
valid = '';
160
}
187
188
}
189
}
190
191
}
192
+ if(count === 0){
193
+ field.empty();
194
+ if(field.data('type')){
195
+ field.append('<option value="">No ' + field.data('type').split(',').join(' or ') + ' in form</option>').prop('disabled', true);
196
+ var no_options = true;
197
+ }
198
+ }else{
199
+ field.prop('disabled', false);
200
}
201
+
202
+ if(!field.hasClass('required') && typeof no_options === 'undefined'){
203
+ field.prepend('<option value=""></option>');
204
+ }
205
+ field.val(current);
206
}else{
207
+ // text types
208
+ //console.log(field.val())
209
}
210
});
211
212
check_required_bindings();
213
+ init_magic_tags();
214
+ jQuery(document).trigger('bound.fields');
215
};
216
217
function setup_field_type(obj){
239
required_errors = {};
240
241
fields.each(function(k,v){
242
+ var field = jQuery(v),
243
+ panel = field.closest('.caldera-config-editor-panel');
244
245
+ if(!v.value.length){
246
if(!required_errors[panel.prop('id')]){
247
required_errors[panel.prop('id')] = 0;
248
}
249
+
250
+ var is_field = field.closest('.caldera-editor-field-config-wrapper'),
251
+ is_process = field.closest('.caldera-editor-processor-config-wrapper');
252
+
253
if(is_field.length){
254
jQuery('.layout-form-field[data-config="'+is_field.prop('id')+'"]').addClass('has-error');
255
}
261
262
//tab.append('<span class="error-tag">' + required_errors[panel.prop('id')] + '</span>');
263
264
+ }else{
265
+ //unique
266
+ if( field.hasClass('field-slug') ){
267
+ var slugs = jQuery('.field-slug').not(field);
268
+
269
+ for(var s = 0; s < slugs.length; s++){
270
+ if( slugs[s].value === v.value ){
271
+ var field = jQuery(slugs[s]);
272
+
273
+ if(!required_errors[panel.prop('id')]){
274
+ required_errors[panel.prop('id')] = 0;
275
+ }
276
+ var is_field = field.closest('.caldera-editor-field-config-wrapper'),
277
+ is_process = field.closest('.caldera-editor-processor-config-wrapper');
278
+
279
+ if(is_field.length){
280
+ jQuery('.layout-form-field[data-config="'+is_field.prop('id')+'"]').addClass('has-error');
281
+ }
282
+ if(is_process.length){
283
+ jQuery('.'+is_process.prop('id')).addClass('has-error');
284
+ }
285
+ required_errors[panel.prop('id')] += 1;
286
+ field.addClass('has-error');
287
+ break;
288
+ }
289
+ };
290
+ }
291
}
292
});
293
500
};
501
buildSortables();
502
503
+ $('#grid-pages-panel').on('click','.column-fieldinsert .dashicons-plus-alt', function(e){
504
//newfield-tool
505
var target = $(this).closest('.column-container'),
506
newfield = $('#newfield-tool').clone();
507
508
insert_new_field(newfield, target);
509
510
+ });
511
+ $('#grid-pages-panel').on('click','.column-fieldinsert .dashicons-admin-generic', function(e){
512
+
513
});
514
/*
515
$('#grid-pages-panel').on('click','.icon-filter', function(e){
733
}
734
735
$(document).trigger('show.' + panel.data('config'));
736
+
737
+ $('#' + panel.data('config')).find('.auto-populate-options').trigger('change');
738
});
739
$('body').on('click', '.layout-modal-edit-closer,.layout-modal-save-action', function(e){
740
944
945
946
947
+
948
Handlebars.registerHelper("_options_config", function() {
949
//console.log(this);
950
});
assets/js/processors-edit.js CHANGED
@@ -6,7 +6,7 @@ jQuery(function($){
6
// set sortable groups
7
$( ".caldera-editor-processors-panel ul" ).sortable({
8
update: function(){
9
- rebind_field_bindings();
10
}
11
});
12
@@ -46,12 +46,12 @@ jQuery(function($){
46
// place config
47
process_conf.append( new_conf_templ( new_proc ) );
48
49
- // reset sortable
50
- build_sortables()
51
$('#form_processor_baldrickModalCloser').trigger('click');
52
$('.caldera-processor-nav a').last().trigger('click');
53
- $('#fp_' + processid + '_type').val(clicked.data('type')).trigger('change');
54
- rebuild_field_binding();
55
56
baldrickTriggers();
57
});
@@ -182,11 +182,12 @@ Handlebars.registerHelper('_field', function(args) {
182
if(args.hash.array){
183
is_array = "[]";
184
if(args.hash.array !== 'true'){
185
- default_val = 'data-default="' + args.hash.array + '"';
186
}
187
}
188
189
out = '<select ' + ( args.hash.type ? 'data-type="' + args.hash.type + '"' : '' ) + default_val +' ' + exclude + ' name="' + this._name + '[' + args.hash.slug + ']' + is_array + '" id="' + this._id + '_' + args.hash.slug + '" class="block-input field-config caldera-field-bind' + required + '">';
190
191
if(!args.hash.required){
192
out += '<option value=""></option>';
6
// set sortable groups
7
$( ".caldera-editor-processors-panel ul" ).sortable({
8
update: function(){
9
+ rebuild_field_binding();
10
}
11
});
12
46
// place config
47
process_conf.append( new_conf_templ( new_proc ) );
48
49
+ // reset sortable
50
$('#form_processor_baldrickModalCloser').trigger('click');
51
$('.caldera-processor-nav a').last().trigger('click');
52
+ $('#fp_' + processid + '_type').val(clicked.data('type')).trigger('change');
53
+ build_sortables();
54
+ //rebuild_field_binding();
55
56
baldrickTriggers();
57
});
182
if(args.hash.array){
183
is_array = "[]";
184
if(args.hash.array !== 'true'){
185
+ default_val = 'value="' + args.hash.array + '"';
186
}
187
}
188
189
out = '<select ' + ( args.hash.type ? 'data-type="' + args.hash.type + '"' : '' ) + default_val +' ' + exclude + ' name="' + this._name + '[' + args.hash.slug + ']' + is_array + '" id="' + this._id + '_' + args.hash.slug + '" class="block-input field-config caldera-field-bind' + required + '">';
190
+ //out = '<input type="text" ' + ( args.hash.type ? 'data-type="' + args.hash.type + '"' : '' ) + default_val +' ' + exclude + ' name="' + this._name + '[' + args.hash.slug + ']' + is_array + '" id="' + this._id + '_' + args.hash.slug + '" class="block-input field-config magic-tag-enabled caldera-field-bind' + required + '">';
191
192
if(!args.hash.required){
193
out += '<option value=""></option>';
caldera-core.php CHANGED
@@ -4,7 +4,7 @@
4
Plugin URI: http://digilab.co.za
5
Description: Create simple to complex grid based, responsive forms quickly and easily.
6
Author: David Cramer
7
- Version: 1.0.91
8
Author URI: http://digilab.co.za
9
*/
10
@@ -17,8 +17,8 @@ if ( ! defined( 'WPINC' ) ) {
17
18
define('CFCORE_PATH', plugin_dir_path(__FILE__));
19
define('CFCORE_URL', plugin_dir_url(__FILE__));
20
- define('CFCORE_VER', '1.0.91');
21
- define('CFCORE_EXTEND_URL', 'http://digilab.co.za');
22
23
include_once CFCORE_PATH . 'classes/core.php';
24
include_once CFCORE_PATH . 'classes/widget.php';
4
Plugin URI: http://digilab.co.za
5
Description: Create simple to complex grid based, responsive forms quickly and easily.
6
Author: David Cramer
7
+ Version: 1.1.0
8
Author URI: http://digilab.co.za
9
*/
10
17
18
define('CFCORE_PATH', plugin_dir_path(__FILE__));
19
define('CFCORE_URL', plugin_dir_url(__FILE__));
20
+ define('CFCORE_VER', '1.1.0');
21
+ define('CFCORE_EXTEND_URL', 'http://api.calderaforms.com/1.0/');
22
23
include_once CFCORE_PATH . 'classes/core.php';
24
include_once CFCORE_PATH . 'classes/widget.php';
classes/admin.php CHANGED
@@ -172,6 +172,7 @@ class Caldera_Forms_Admin {
172
}
173
174
public static function get_admin_templates(){
175
include CFCORE_PATH . 'ui/admin_templates.php';
176
}
177
public static function get_admin_meta_templates(){
@@ -873,6 +874,11 @@ class Caldera_Forms_Admin {
873
unset($forms[$data['ID']]['settings']);
874
}
875
876
// combine structure pages
877
$data['layout_grid']['structure'] = implode('#', $data['layout_grid']['structure']);
878
@@ -977,6 +983,15 @@ class Caldera_Forms_Admin {
977
"label" => __("Form Processors", 'caldera-forms'),
978
"canvas" => $path . "processors.php",
979
),
980
"responsive" => array(
981
"name" => __("Responsive", 'caldera-forms'),
982
"location" => "lower",
172
}
173
174
public static function get_admin_templates(){
175
+ include CFCORE_PATH . 'ui/news_templates.php';
176
include CFCORE_PATH . 'ui/admin_templates.php';
177
}
178
public static function get_admin_meta_templates(){
874
unset($forms[$data['ID']]['settings']);
875
}
876
877
+ foreach($forms as $form_id=>$form_config){
878
+ if(empty($form_config)){
879
+ unset( $forms[$form_id] );
880
+ }
881
+ }
882
// combine structure pages
883
$data['layout_grid']['structure'] = implode('#', $data['layout_grid']['structure']);
884
983
"label" => __("Form Processors", 'caldera-forms'),
984
"canvas" => $path . "processors.php",
985
),
986
+ "variables" => array(
987
+ "name" => __("Variables", 'caldera-forms'),
988
+ "location" => "lower",
989
+ "label" => __("Variables", 'caldera-forms'),
990
+ "canvas" => $path . "variables.php",
991
+ "actions" => array(
992
+ $path . "variable_add.php"
993
+ )
994
+ ),
995
"responsive" => array(
996
"name" => __("Responsive", 'caldera-forms'),
997
"location" => "lower",
classes/core.php CHANGED
@@ -48,6 +48,10 @@ class Caldera_Forms {
48
add_filter('caldera_forms_get_form_processors', array( $this, 'get_form_processors'));
49
add_filter('caldera_forms_submit_redirect_complete', array( $this, 'do_redirect'),10, 4);
50
add_action('caldera_forms_edit_end', array($this, 'calculations_templates') );
51
52
// magic tags
53
//add_filter('caldera_forms_render_magic_tag', array( $this, 'do_magic_tags'));
@@ -64,6 +68,9 @@ class Caldera_Forms {
64
65
// render shortcode
66
add_shortcode( 'caldera_form', array( $this, 'render_form') );
67
68
// check update version
69
$version = get_option('_calderaforms_lastupdate');
@@ -256,22 +263,44 @@ class Caldera_Forms {
256
257
public static function update_field_data($field, $entry_id, $form){
258
global $wpdb, $form;
259
-
260
- $data = self::get_field_data($field['ID'], $form);
261
-
262
- if(empty($data)){
263
return;
264
}
265
266
if( has_filter( 'caldera_forms_save_field' ) ){
267
- $data = apply_filters( 'caldera_forms_update_field', $data, $field, $form );
268
}
269
270
if( has_filter( 'caldera_forms_save_field_' . $field['type'] ) ){
271
- $data = apply_filters( 'caldera_forms_update_field_' . $field['type'], $data, $field, $form );
272
- }
273
274
- $wpdb->update($wpdb->prefix . 'cf_form_entry_values', array('value' => $data), array('entry_id' => $entry_id, 'field_id' => $field['ID']));
275
276
}
277
@@ -298,7 +327,7 @@ class Caldera_Forms {
298
'entry_id' => $entry_id,
299
'field_id' => $field['ID'],
300
'slug' => $field['slug'],
301
- 'value' => $entry
302
);
303
// named key kets .key to slug
304
if(!is_int($key)){
@@ -348,7 +377,8 @@ class Caldera_Forms {
348
349
}
350
351
- }
352
353
if(!empty($form['db_support'])){
354
// new entry or update
@@ -557,20 +587,23 @@ class Caldera_Forms {
557
}
558
559
$key = $form['fields'][$field_id]['slug'];
560
-
561
if(is_array($row)){
562
- $keys = array_keys($row);
563
- if(is_int($keys[0])){
564
- $row = implode(', ', $row);
565
- }else{
566
- $tmp = array();
567
- foreach($row as $linekey=>$item){
568
- if(is_array($item)){
569
- $item = '( ' . implode(', ', $item).' )';
570
}
571
- $tmp[] = $linekey.': '.$item;
572
}
573
- $row = implode(', ', $tmp);
574
}
575
}
576
$mail['message'] = str_replace('%'.$key.'%', $row, $mail['message']);
@@ -656,9 +689,32 @@ class Caldera_Forms {
656
continue;
657
}
658
}
659
-
660
if(!empty($processor['config']['url'])){
661
- return $processor['config']['url'];
662
}
663
}
664
}
@@ -679,43 +735,16 @@ class Caldera_Forms {
679
$value = self::do_magic_tags( $value );
680
}
681
}
682
// set header
683
$headers = 'From: ' . $config['sender_name'] . ' <' . $config['sender_email'] . '>' . "\r\n";
684
-
685
- $regex = "/%(.*?)%/";
686
- preg_match_all($regex, $message, $matches);
687
- if(!empty($matches[1])){
688
- foreach($matches[1] as $key=>$tag){
689
- $entry = self::get_slug_data($tag, $form);
690
- if(!empty($entry)){
691
- if(is_array($entry)){
692
- if(count($entry) === 1){
693
- $entry = array_shift($entry);
694
- }elseif(count($entry) === 2){
695
- $entry = implode(' & ', $entry);
696
- }elseif(count($entry) > 2){
697
- $last = array_pop($entry);
698
- $entry = implode(', ', $entry).' & '.$last;
699
- }else{
700
- continue;
701
- }
702
- }
703
- }else{
704
- $entry = '';
705
- }
706
707
- $message = str_replace($matches[0][$key], $entry, $message);
708
- }
709
- }
710
$message = self::do_magic_tags( $message );
711
712
// setup mailer
713
- $recipient_name = self::get_field_data($config['recipient_name'], $form);
714
- $recipient_email = self::get_field_data($config['recipient_email'], $form);
715
$subject = $config['subject'];
716
do_action( 'caldera_forms_do_autoresponse', $config, $form);
717
-
718
- wp_mail($recipient_name.' <'.$recipient_email.'>', $subject, $message, $headers );
719
720
}
721
@@ -807,7 +836,7 @@ class Caldera_Forms {
807
"file" => CFCORE_PATH . "fields/calculation/field.php",
808
"handler" => array($this, "run_calculation"),
809
"category" => __("Special,Math", "cladera-forms"),
810
- "description" => __('Calculate values', "cladera-forms"),
811
"setup" => array(
812
"template" => CFCORE_PATH . "fields/calculation/config.php",
813
"preview" => CFCORE_PATH . "fields/calculation/preview.php",
@@ -981,7 +1010,8 @@ class Caldera_Forms {
981
"not_supported" => array(
982
'hide_label',
983
'caption',
984
- 'required'
985
)
986
)
987
),
@@ -998,7 +1028,6 @@ class Caldera_Forms {
998
'hide_label',
999
'caption',
1000
'required',
1001
-
1002
)
1003
)
1004
),
@@ -1186,6 +1215,43 @@ class Caldera_Forms {
1186
1187
}
1188
1189
static public function check_condition($conditions, $form){
1190
1191
$trues = array();
@@ -1347,6 +1413,10 @@ class Caldera_Forms {
1347
'text',
1348
'email'
1349
),
1350
'embed_post:ID',
1351
'embed_post:post_title',
1352
'embed_post:permalink',
@@ -1365,19 +1435,21 @@ class Caldera_Forms {
1365
1366
$tags['system'] = array(
1367
'type' => __('System Tags', 'caldera-forms'),
1368
- 'tags' => $system_tags
1369
);
1370
// get processor tags
1371
$processors = apply_filters('caldera_forms_get_form_processors', array() );
1372
if(!empty($processors)){
1373
foreach($processors as $processor_key=>$processor){
1374
- if(isset($processor['magic_tags'])){
1375
foreach($processor['magic_tags'] as $key_tag=>$value_tag){
1376
1377
if(!isset($tags[$processor_key])){
1378
$tags[$processor_key] = array(
1379
'type' => $processor['name'],
1380
- 'tags' => array()
1381
);
1382
}
1383
if(is_array($value_tag)){
@@ -1406,7 +1478,7 @@ class Caldera_Forms {
1406
return $tags;
1407
}
1408
1409
- static public function do_magic_tags($value){
1410
1411
global $processed_meta, $form;
1412
/// get meta entry for magic tags defined.
@@ -1441,6 +1513,20 @@ class Caldera_Forms {
1441
$magic_tag = null;
1442
}
1443
break;
1444
case 'date':
1445
$magic_tag = date($magic[1]);
1446
break;
@@ -1541,6 +1627,13 @@ class Caldera_Forms {
1541
if(!empty($form['ID']) ){
1542
//dump($processed_meta[$form['ID']]);
1543
1544
// check if its a process id or processor slug
1545
if( empty($processed_meta[$form['ID']][$magic[0]]) && !empty($form['processors']) ){
1546
@@ -1578,6 +1671,31 @@ class Caldera_Forms {
1578
}
1579
}
1580
}
1581
return $value;
1582
}
1583
@@ -1674,20 +1792,19 @@ class Caldera_Forms {
1674
//dump($processed_data[$form['ID']],0);
1675
//echo $field_id.'<br>';
1676
if(is_string($form)){
1677
- // get processed cached item using the form id
1678
- if(isset($processed_data[$form][$field_id])){
1679
- return $processed_data[$form][$field_id];
1680
- }
1681
-
1682
$form = get_option( $form );
1683
if(!isset($form['ID']) || $form['ID'] !== $form){
1684
-
1685
return null;
1686
}
1687
}
1688
// get processed cached item
1689
- if(isset($processed_data[$form['ID']][$field_id])){
1690
- return $processed_data[$form['ID']][$field_id];
1691
}
1692
// entry fetch
1693
if(!empty($entry_id) && isset($form['fields'][$field_id])){
@@ -1697,21 +1814,24 @@ class Caldera_Forms {
1697
$entry = $wpdb->get_results($wpdb->prepare("
1698
SELECT `value` FROM `" . $wpdb->prefix ."cf_form_entry_values` WHERE `entry_id` = %d AND `field_id` = %s AND `slug` = %s", $entry_id, $field_id, $form['fields'][$field_id]['slug']), ARRAY_A);
1699
1700
if(!empty($entry)){
1701
if( count( $entry ) > 1){
1702
$out = array();
1703
foreach($entry as $item){
1704
$out[] = $item['value'];
1705
}
1706
- $processed_data[$form['ID']][$field_id] = $out;
1707
}else{
1708
- $processed_data[$form['ID']][$field_id] = $entry[0]['value'];
1709
}
1710
}else{
1711
- $processed_data[$form['ID']][$field_id] = null;
1712
}
1713
- return $processed_data[$form['ID']][$field_id];
1714
- //return $processed_data[$form['ID']][$field_id] = ;
1715
}
1716
1717
if(isset($form['fields'][$field_id])){
@@ -1731,7 +1851,7 @@ class Caldera_Forms {
1731
// dont bother if conditions say it shouldnt be here.
1732
if(!empty($field['conditions']['type'])){
1733
if(!self::check_condition($field['conditions'], $form)){
1734
- $processed_data[$form['ID']][$field_id] = $entry;
1735
return $entry;
1736
}
1737
}
@@ -1745,7 +1865,7 @@ class Caldera_Forms {
1745
if(has_filter('caldera_forms_process_field_' . $field['type'])){
1746
$entry = apply_filters( 'caldera_forms_process_field_' . $field['type'] , $entry, $field, $form );
1747
if( is_wp_error( $entry ) ) {
1748
- $processed_data[$form['ID']][$field_id] = $entry;
1749
return $entry;
1750
}
1751
}
@@ -1772,33 +1892,33 @@ class Caldera_Forms {
1772
$out[] = self::do_magic_tags($field['config']['option'][$option_id]['value']);
1773
}
1774
}
1775
- $processed_data[$form['ID']][$field_id] = $out;
1776
}else{
1777
if(!empty($field['config']['option'])){
1778
foreach($field['config']['option'] as $option){
1779
if($option['value'] == $entry){
1780
- $processed_data[$form['ID']][$field_id] = self::do_magic_tags($entry);
1781
break;
1782
}
1783
}
1784
}
1785
}
1786
}else{
1787
- $processed_data[$form['ID']][$field_id] = self::do_magic_tags($field['config']['default']);
1788
}
1789
}else{
1790
// dynamic
1791
- $processed_data[$form['ID']][$field_id] = $entry;
1792
}
1793
}else{
1794
$is_tag = self::do_magic_tags($field_id);
1795
if($is_tag !== $field_id){
1796
- $processed_data[$form['ID']][$field_id] = $is_tag;
1797
}
1798
}
1799
1800
- if(isset($processed_data[$form['ID']][$field_id])){
1801
- return $processed_data[$form['ID']][$field_id];
1802
}
1803
1804
@@ -1819,57 +1939,11 @@ class Caldera_Forms {
1819
1820
if($field['slug'] == $slug){
1821
1822
- if(isset($_POST[$field_id])){
1823
- if(!empty($slug_parts)){
1824
- // just the part
1825
- $line = stripslashes_deep( $_POST[$field_id] );
1826
- foreach($slug_parts as $part){
1827
- if(isset($line[$part])){
1828
- $line = $line[$part];
1829
- }
1830
- }
1831
- $out[] = $line;
1832
- }else{
1833
- //the whole thing
1834
- $entry = stripslashes_deep( $_POST[$field_id] );
1835
-
1836
- //$entry = apply_filters('caldera_forms_view_field_' . $field['type'], $entry, $field, $form);
1837
1838
- /*if(isset($field_types[$field['type']]['viewer'])){
1839
-
1840
- if(is_array($field_types[$field['type']]['viewer'])){
1841
- $entry = call_user_func_array($field_types[$field['type']]['viewer'],array($entry, $field, $form));
1842
- }else{
1843
- if(function_exists($field_types[$field['type']]['viewer'])){
1844
- $func = $field_types[$field['type']]['viewer'];
1845
- $entry = $func($entry, $field, $form);
1846
- }
1847
- }
1848
- }*/
1849
- if(is_array($entry)){
1850
- if(isset($entry[0])){
1851
- // list
1852
- $entry = $field['label'].': '. implode(',' , $entry);
1853
- }else{
1854
- // named
1855
- foreach($entry as $item_key=>$item){
1856
- if(is_array($item)){
1857
- $item = $item_key.' ('.implode(', ', $item).')';
1858
- }
1859
- $out[] = $item;
1860
- }
1861
- }
1862
- }else{
1863
- $out[] = $entry;
1864
- }
1865
- }
1866
- }
1867
}
1868
}
1869
- if(count($out) === 1){
1870
- $out = array_shift($out);
1871
- }
1872
- return $out;
1873
}
1874
static public function get_entry_detail($entry_id, $form){
1875
global $wpdb;
@@ -1877,90 +1951,109 @@ class Caldera_Forms {
1877
$entry = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . $wpdb->prefix ."cf_form_entries` WHERE `id` = %d", $entry_id), ARRAY_A);
1878
if(!empty($entry)){
1879
// get meta if any
1880
- $entry_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . $wpdb->prefix ."cf_form_entry_meta` WHERE `entry_id` = %d", $entry_id), ARRAY_A);
1881
- if(!empty($entry_meta)){
1882
- $processors = apply_filters('caldera_forms_get_form_processors', array() );
1883
- $entry['meta'] = array();
1884
- foreach($entry_meta as $meta_index=>$meta){
1885
- // is json?
1886
- if( false !== strpos($meta['meta_value'], '{') || false !== strpos($meta['meta_value'], '[') ){
1887
- $meta['meta_value'] = json_decode($meta['meta_value'], ARRAY_A);
1888
- }else{
1889
- $meta['meta_value'] = $meta['meta_value'];
1890
- }
1891
1892
- $group = 'meta';
1893
- $meta = apply_filters('caldera_forms_get_entry_meta', $meta, $form);
1894
1895
- if(isset($form['processors'][$meta['process_id']])){
1896
1897
- $process_config = array();
1898
- if(isset($form['processors'][$meta['process_id']]['config'])){
1899
- $process_config = $form['processors'][$meta['process_id']]['config'];
1900
- }
1901
1902
- $group = $form['processors'][$meta['process_id']]['type'];
1903
- $meta = apply_filters('caldera_forms_get_entry_meta_' . $form['processors'][$meta['process_id']]['type'], $meta, $process_config , $form);
1904
1905
-
1906
- // allows plugins to remove it.
1907
- if(!empty($meta)){
1908
- if(!isset($entry['meta'][$group])){
1909
- // is processor
1910
- if(isset($form['processors'][$meta['process_id']]['type'])){
1911
- $meta_name = $processors[$form['processors'][$meta['process_id']]['type']]['name'];
1912
- }else{
1913
- $meta_name = $meta['process_id'];
1914
- }
1915
- $entry['meta'][$group] = array(
1916
- 'name' => $meta_name,
1917
- 'data' => array()
1918
- );
1919
- // custom template
1920
- if( isset( $processors[$form['processors'][$meta['process_id']]['type']]['meta_template'] ) && file_exists( $processors[$form['processors'][$meta['process_id']]['type']]['meta_template'] ) ){
1921
- $entry['meta'][$group][$group.'_template'] = $entry['meta'][$group]['template'] = true;
1922
- }
1923
}
1924
1925
- //if(!empty($meta['meta_title'])){
1926
- // $entry['meta'][$group]['data'][$meta['process_id']]['title'] = $meta['meta_title'];
1927
- //}
1928
1929
- $entry['meta'][$group]['data'][$meta['process_id']]['entry'][] = $meta;
1930
1931
-
1932
- /*if(is_array($meta['meta_value'])){
1933
- foreach($meta['meta_value'] as $mkey=>$mval){
1934
- $entry['meta'][$group]['data'][$meta['process_id']]['title'] = $meta['meta_key'];
1935
- $entry['meta'][$group]['data'][$meta['process_id']]['entry'][] = array(
1936
- 'meta_key' => $mkey,
1937
- 'meta_value' => $mval
1938
- );
1939
- }
1940
- }else{
1941
$entry['meta'][$group]['data'][$meta['process_id']]['entry'][] = array(
1942
- 'meta_key' => $meta['meta_key'],
1943
- 'meta_value' => $meta['meta_value']
1944
- );
1945
- }*/
1946
1947
- }
1948
}
1949
}
1950
}
1951
}
1952
- $entry = apply_filters( 'caldera_forms_get_entry_detail', $entry, $entry_id, $form );
1953
- return $entry;
1954
}
1955
1956
static public function get_submission_data($form, $entry_id = false){
1957
global $processed_data;
1958
1959
if(is_string($form)){
1960
- // get processed cached item using the form id
1961
- if(isset($processed_data[$form])){
1962
- return $processed_data[$form];
1963
- }
1964
$form_id = $form;
1965
$form = get_option( $form );
1966
if(!isset($form['ID']) || $form['ID'] !== $form_id){
@@ -1968,13 +2061,22 @@ class Caldera_Forms {
1968
}
1969
}
1970
1971
1972
// initialize process data
1973
foreach($form['fields'] as $field_id=>$field){
1974
self::get_field_data( $field_id, $form, $entry_id);
1975
}
1976
1977
- return $processed_data[$form['ID']];
1978
}
1979
1980
static public function process_submission(){
@@ -2012,6 +2114,12 @@ class Caldera_Forms {
2012
// init filter
2013
$form = apply_filters('caldera_forms_submit_get_form', $form);
2014
2015
// instance number
2016
$form_instance_number = 1;
2017
if(isset($_POST['_cf_frm_ct'])){
@@ -2127,6 +2235,7 @@ class Caldera_Forms {
2127
if(isset($_POST['_cf_frm_edt'])){
2128
// is edit
2129
//check user can edit this item.
2130
$user_id = get_current_user_id();
2131
if(empty($user_id)){
2132
$transdata['error'] = true;
@@ -2248,11 +2357,11 @@ class Caldera_Forms {
2248
$config = array_merge($config, $processor['config']);
2249
}
2250
if(is_array($process['pre_processor'])){
2251
- $process_line_data = call_user_func_array($process['pre_processor'],array($config, $form, $processid));
2252
}else{
2253
if(function_exists($process['pre_processor'])){
2254
$func = $process['pre_processor'];
2255
- $process_line_data = $func($config, $form);
2256
}
2257
}
2258
// pre processors should not return unless a break in action for further
@@ -2318,6 +2427,7 @@ class Caldera_Forms {
2318
$hasmeta = null;
2319
// set default config
2320
$config = array();
2321
if(isset($process['default'])){
2322
$config = $process['default'];
2323
}
@@ -2326,11 +2436,11 @@ class Caldera_Forms {
2326
$config = array_merge($config, $processor['config']);
2327
}
2328
if(is_array($process['processor'])){
2329
- $hasmeta = call_user_func_array($process['processor'],array($config, $form));
2330
}else{
2331
if(function_exists($process['processor'])){
2332
$func = $process['processor'];
2333
- $hasmeta = $func($config, $form);
2334
}
2335
}
2336
if($hasmeta !== null){
@@ -2392,6 +2502,7 @@ class Caldera_Forms {
2392
}
2393
// set default config
2394
$config = array();
2395
if(isset($process['default'])){
2396
$config = $process['default'];
2397
}
@@ -2400,11 +2511,11 @@ class Caldera_Forms {
2400
$config = array_merge($config, $processor['config']);
2401
}
2402
if(is_array($process['post_processor'])){
2403
- $hasmeta = call_user_func_array($process['post_processor'],array($config, $form));
2404
}else{
2405
if(function_exists($process['post_processor'])){
2406
$func = $process['post_processor'];
2407
- $hasmeta = $func($config, $form);
2408
}
2409
}
2410
if($hasmeta !== null){
@@ -2423,6 +2534,14 @@ class Caldera_Forms {
2423
2424
// redirect back or to result page
2425
$referrer['query']['cf_su'] = $form_instance_number;
2426
$referrer = $referrer['path'] . '?' . http_build_query($referrer['query']);
2427
2428
// filter refer
@@ -2635,6 +2754,11 @@ class Caldera_Forms {
2635
}
2636
}
2637
}
2638
}
2639
}
2640
}
@@ -2654,7 +2778,7 @@ class Caldera_Forms {
2654
return $found;
2655
}
2656
2657
- static public function get_entry($entry_id = null){
2658
2659
if(empty($entry_id)){
2660
if(!empty($_POST['form'])){
@@ -2663,9 +2787,6 @@ class Caldera_Forms {
2663
if(empty($form)){
2664
return;
2665
}
2666
-
2667
- $field_types = self::get_field_types();
2668
-
2669
$fields = array();
2670
foreach ($form['fields'] as $field_id => $field) {
2671
$fields[$field['slug']] = $field;
@@ -2676,124 +2797,53 @@ class Caldera_Forms {
2676
}
2677
2678
}
2679
-
2680
- global $wpdb;
2681
-
2682
- $rawdata = $wpdb->get_results($wpdb->prepare("
2683
- SELECT
2684
- `entry`.`form_id` AS `_form_id`,
2685
- `entry`.`datestamp` AS `_date_submitted`,
2686
- `entry`.`user_id` AS `_user_id`,
2687
- `value`.*
2688
-
2689
- FROM `" . $wpdb->prefix ."cf_form_entries` AS `entry`
2690
- LEFT JOIN `" . $wpdb->prefix ."cf_form_entry_values` AS `value` ON (`entry`.`id` = `value`.`entry_id`)
2691
- WHERE `entry`.`id` = %d;", $entry_id ));
2692
-
2693
- if(empty($rawdata)){
2694
- return array();
2695
}
2696
- $data = array();
2697
- $dateformat = get_option('date_format');
2698
- $timeformat = get_option('time_format');
2699
- $gmt_offset = get_option( 'gmt_offset' );
2700
-
2701
- foreach($rawdata as $row){
2702
- if(empty($form)){
2703
- $form = get_option($row->_form_id);
2704
- if(empty($form)){
2705
- return array();
2706
- }
2707
}
2708
2709
- if(isset($fields[$row->slug])){
2710
- $field = $fields[$row->slug];
2711
-
2712
- if(isset($field_types[$field['type']]['viewer'])){
2713
- // is json?
2714
- if(substr($row->value, 0,2) === '{"' && substr($row->value, strlen($row->value)-2 ) === '"}'){
2715
- $is_value = json_decode($row->value, ARRAY_A);
2716
- if(!empty($is_value)){
2717
- $row->value = $is_value;
2718
- }
2719
- }
2720
-
2721
- $row->value = apply_filters('caldera_forms_view_field_' . $field['type'], $row->value, $field, $form);
2722
- //$row->value = apply_filters( $tag, $value );
2723
- /*
2724
- if(is_array($field_types[$field['type']]['viewer'])){
2725
- $row->value = call_user_func_array($field_types[$field['type']]['viewer'],array($row->value, $field, $form));
2726
- }elseif(is_object($field_types[$field['type']]['viewer'])){
2727
-
2728
- $row->value = call_user_func_array($field_types[$field['type']]['viewer'],array($row->value, $field, $form));
2729
-
2730
- }elseif(function_exists($field_types[$field['type']]['viewer'])){
2731
- $func = $field_types[$field['type']]['viewer'];
2732
- $row->value = $func($row->value, $field, $form);
2733
- }*/
2734
- }
2735
-
2736
-
2737
- if(substr($row->value, 0,2) === '{"' && substr($row->value, strlen($row->value)-2 ) === '"}'){
2738
- $line = json_decode($row->value, true);
2739
- if(!empty($line)){
2740
- $keys = array_keys($line);
2741
- if(is_int($keys[0])){
2742
- $line = implode(', ', $line);
2743
- }else{
2744
- $tmp = array();
2745
- foreach($line as $key=>$item){
2746
- if(is_array($item)){
2747
- $item = '( ' . implode(', ', $item).' )';
2748
- }
2749
- $tmp[] = $key.': '.$item;
2750
- }
2751
- $line = implode(', ', $tmp);
2752
- }
2753
- $row->value = $line;
2754
- }
2755
- }
2756
- if(is_array($row->value)){
2757
- $keys = array_keys($line);
2758
- if(is_int($keys[0])){
2759
- $line = implode(', ', $line);
2760
- }else{
2761
- $tmp = array();
2762
- foreach($line as $key=>$item){
2763
- if(is_array($item)){
2764
- $item = '( ' . implode(', ', $item).' )';
2765
- }
2766
- $tmp[] = $key.': '.$item;
2767
- }
2768
- $line = implode(', ', $tmp);
2769
- }
2770
- $row->value = $line;
2771
}
2772
2773
- $data['date'] = date_i18n( $dateformat.' '.$timeformat, strtotime($row->_date_submitted), $gmt_offset);
2774
- $data['user'] = $row->_user_id;
2775
-
2776
- $data['data'][$row->slug]['label'] = $field['label'];
2777
- if(isset($data['data'][$row->slug]['value'])){
2778
- $data['data'][$row->slug]['value'] = implode(', ', array($data['data'][$row->slug]['value'], $row->value));
2779
- }else{
2780
- $data['data'][$row->slug]['value'] = $row->value;
2781
- }
2782
2783
- }else{
2784
- // front end for editing. no filtering just values to array.
2785
- $data[$row->slug] = $row->value;
2786
- }
2787
}
2788
// get meta
2789
$entry_detail = self::get_entry_detail($entry_id, $form);
2790
if(!empty($entry_detail['meta'])){
2791
$data['meta'] = $entry_detail['meta'];
2792
}
2793
2794
2795
- if(!empty($data['user'])){
2796
- $user = get_userdata( $data['user'] );
2797
if(!empty($user)){
2798
$data['user'] = array(
2799
'ID' => $user->ID,
@@ -2822,6 +2872,70 @@ class Caldera_Forms {
2822
return $data;
2823
}
2824
2825
static public function render_form($atts, $entry_id = null){
2826
2827
global $current_form_count;
@@ -2862,6 +2976,14 @@ class Caldera_Forms {
2862
2863
}
2864
2865
// set entry edit
2866
if(!empty($atts['entry'])){
2867
$entry_id = self::do_magic_tags( $atts['entry'] );
@@ -2996,7 +3118,11 @@ class Caldera_Forms {
2996
2997
// load requested data
2998
if(!empty($entry_id)){
2999
- $prev_data = self::get_entry($entry_id);
3000
$prev_data = apply_filters('caldera_forms_render_get_entry', $prev_data, $form, $entry_id);
3001
}
3002
@@ -3013,7 +3139,7 @@ class Caldera_Forms {
3013
}
3014
3015
if(!is_wp_error( $field_entry )){
3016
- $prev_data[$form['fields'][$field_id]['slug']] = $field_entry;
3017
}
3018
}
3019
}
@@ -3108,7 +3234,7 @@ class Caldera_Forms {
3108
if(!empty($form['layout_grid']['fields'])){
3109
3110
foreach($form['layout_grid']['fields'] as $field_base_id=>$location){
3111
- //
3112
if(isset($form['fields'][$field_base_id])){
3113
3114
$field = apply_filters('caldera_forms_render_setup_field', $form['fields'][$field_base_id], $form);
@@ -3152,9 +3278,9 @@ class Caldera_Forms {
3152
$field_input_class = $field_classes['field_wrapper'];
3153
$field_class = $field_classes['field'];
3154
3155
- if(!empty($field_errors[$field['slug']])){
3156
$field_input_class .= " " . $field_classes['field_error'];
3157
- $field_structure['field_caption'] = "<span class=\"" . $field_classes['field_caption'] . "\">" . $field_errors[$field['slug']] . "</span>\r\n";
3158
}
3159
3160
// value
@@ -3164,8 +3290,8 @@ class Caldera_Forms {
3164
}
3165
3166
// transient data
3167
- if(isset($prev_data[$field['slug']])){
3168
- $field_structure['field_value'] = $prev_data[$field['slug']];
3169
}
3170
3171
$field_structure = apply_filters('caldera_forms_render_field_structure', $field_structure, $form);
@@ -3173,13 +3299,15 @@ class Caldera_Forms {
3173
$field_structure = apply_filters('caldera_forms_render_field_structure_slug-' . $field['slug'], $field_structure, $form);
3174
3175
$field_name = $field_structure['name'];
3176
- $field_id = $field_structure['id'];
3177
$field_label = $field_structure['label_before'] . $field_structure['label'] . $field_structure['label_required'] . $field_structure['label_after']."\r\n";
3178
$field_placeholder = $field_structure['field_placeholder'];
3179
$field_required = $field_structure['field_required'];
3180
$field_caption = $field_structure['field_caption'];
3181
// blank default
3182
$field_value = $field_structure['field_value'];
3183
3184
ob_start();
3185
include $field_types[$field['type']]['file'];
@@ -3263,7 +3391,7 @@ class Caldera_Forms {
3263
$out .= "<input type=\"hidden\" name=\"_cf_frm_tr\" value=\"" . $prev_post['transient'] . "\">\r\n";
3264
}
3265
// is edit?
3266
- if(!empty($entry_id)){
3267
$out .= "<input type=\"hidden\" name=\"_cf_frm_edt\" value=\"" . $entry_id . "\">\r\n";
3268
}
3269
@@ -3273,7 +3401,7 @@ class Caldera_Forms {
3273
// retain query string
3274
$qurystr = array();
3275
parse_str( $_SERVER['QUERY_STRING'], $qurystr );
3276
- echo "<span class=\"caldera-grid\"><ol class=\"breadcrumb\" data-form=\"caldera_form_" . $current_form_count ."\">\r\n";
3277
$current_page = 1;
3278
if(!empty($_GET['cf_pg'])){
3279
$current_page = $_GET['cf_pg'];
@@ -3287,9 +3415,9 @@ class Caldera_Forms {
3287
3288
$qurystr['cf_pg'] = $page_key + 1;
3289
$qurystr['_rdm_'] = rand(100000, 999999);
3290
- echo "<li" . $tabclass . "><a href=\"?". http_build_query($qurystr) . "\" data-page=\"" . ( $page_key + 1 ) ."\" data-pagenav=\"caldera_form_" . $current_form_count ."\">". $page_name . "</a></li>\r\n";
3291
}
3292
- echo "</ol></span>\r\n";
3293
}
3294
3295
$out .= $grid->renderLayout();
48
add_filter('caldera_forms_get_form_processors', array( $this, 'get_form_processors'));
49
add_filter('caldera_forms_submit_redirect_complete', array( $this, 'do_redirect'),10, 4);
50
add_action('caldera_forms_edit_end', array($this, 'calculations_templates') );
51
+ add_filter('caldera_forms_render_get_field_type-radio', array( $this, 'auto_populate_options_field' ), 10, 2);
52
+ add_filter('caldera_forms_render_get_field_type-checkbox', array( $this, 'auto_populate_options_field' ), 10, 2);
53
+ add_filter('caldera_forms_render_get_field_type-dropdown', array( $this, 'auto_populate_options_field' ), 10, 2);
54
+ add_filter('caldera_forms_render_get_field_type-toggle_switch', array( $this, 'auto_populate_options_field' ), 10, 2);
55
56
// magic tags
57
//add_filter('caldera_forms_render_magic_tag', array( $this, 'do_magic_tags'));
68
69
// render shortcode
70
add_shortcode( 'caldera_form', array( $this, 'render_form') );
71
+ // modal shortcode
72
+ add_shortcode( 'caldera_form_modal', array( $this, 'render_modal_form') );
73
+ add_action( 'wp_footer', array( $this, 'render_footer_modals') );
74
75
// check update version
76
$version = get_option('_calderaforms_lastupdate');
263
264
public static function update_field_data($field, $entry_id, $form){
265
global $wpdb, $form;
266
+
267
+ $field_types = self::get_field_types();
268
+ // is capture?
269
+ if(isset($field_types[$form['fields'][$field['ID']]['type']]['setup']['not_supported'])){
270
+ if(in_array('entry_list', $field_types[$form['fields'][$field['ID']]['type']]['setup']['not_supported'])){
271
+ return;
272
+ }
273
+ }
274
+
275
+ $new_data = self::get_field_data($field['ID'], $form);
276
+ $original_data = self::get_field_data($field['ID'], $form, $entry_id);
277
+
278
+ if($original_data === $new_data){
279
+ // no change
280
return;
281
}
282
283
if( has_filter( 'caldera_forms_save_field' ) ){
284
+ $new_data = apply_filters( 'caldera_forms_update_field', $new_data, $field, $form );
285
}
286
287
if( has_filter( 'caldera_forms_save_field_' . $field['type'] ) ){
288
+ $new_data = apply_filters( 'caldera_forms_update_field_' . $field['type'], $new_data, $field, $form );
289
+ }
290
+ if($original_data === null){
291
+ // no entry - add first
292
+ $new_entry = array(
293
+ 'entry_id' => $entry_id,
294
+ 'field_id' => $field['ID'],
295
+ 'slug' => $field['slug'],
296
+ 'value' => $new_data,
297
+ );
298
+ $wpdb->insert($wpdb->prefix . 'cf_form_entry_values', $new_entry);
299
+
300
+ }else{
301
302
+ $wpdb->update($wpdb->prefix . 'cf_form_entry_values', array('value' => $new_data), array('entry_id' => $entry_id, 'field_id' => $field['ID']));
303
+ }
304
305
}
306
327
'entry_id' => $entry_id,
328
'field_id' => $field['ID'],
329
'slug' => $field['slug'],
330
+ 'value' => self::do_magic_tags( $entry )
331
);
332
// named key kets .key to slug
333
if(!is_int($key)){
377
378
}
379
380
+ }
381
+
382
383
if(!empty($form['db_support'])){
384
// new entry or update
587
}
588
589
$key = $form['fields'][$field_id]['slug'];
590
if(is_array($row)){
591
+ if(!empty($row)){
592
+ $keys = array_keys($row);
593
+ if(is_int($keys[0])){
594
+ $row = implode(', ', $row);
595
+ }else{
596
+ $tmp = array();
597
+ foreach($row as $linekey=>$item){
598
+ if(is_array($item)){
599
+ $item = '( ' . implode(', ', $item).' )';
600
+ }
601
+ $tmp[] = $linekey.': '.$item;
602
}
603
+ $row = implode(', ', $tmp);
604
}
605
+ }else{
606
+ $row = null;
607
}
608
}
609
$mail['message'] = str_replace('%'.$key.'%', $row, $mail['message']);
689
continue;
690
}
691
}
692
if(!empty($processor['config']['url'])){
693
+
694
+ //passback urls
695
+ $referrer = parse_url( $referrer );
696
+ $query_vars = array();
697
+ if(!empty($referrer['query'])){
698
+ parse_str($referrer['query'], $referrer['query']);
699
+ if(isset($referrer['query']['cf_su'])){
700
+ unset($referrer['query']['cf_su']);
701
+ }
702
+ $query_vars = array_merge($query_vars, $referrer['query']);
703
+ }
704
+ // get vars in url
705
+ $base_redirect = self::do_magic_tags( $processor['config']['url'] );
706
+ $redirect = parse_url( $base_redirect );
707
+
708
+ if(!empty($redirect['query'])){
709
+ parse_str($redirect['query'], $redirect['query']);
710
+ $base_redirect = explode('?', $base_redirect, 2);
711
+ $query_vars = array_merge($redirect['query'], $query_vars);
712
+ $redirect = $base_redirect[0] . '?' . http_build_query($query_vars);
713
+ }else{
714
+ $redirect = $base_redirect . '?' . http_build_query($query_vars);
715
+ }
716
+
717
+ return $redirect;
718
}
719
}
720
}
735
$value = self::do_magic_tags( $value );
736
}
737
}
738
+
739
// set header
740
$headers = 'From: ' . $config['sender_name'] . ' <' . $config['sender_email'] . '>' . "\r\n";
741
742
$message = self::do_magic_tags( $message );
743
744
// setup mailer
745
$subject = $config['subject'];
746
do_action( 'caldera_forms_do_autoresponse', $config, $form);
747
+ wp_mail($config['recipient_name'].' <'.$config['recipient_email'].'>', $subject, $message, $headers );
748
749
}
750
836
"file" => CFCORE_PATH . "fields/calculation/field.php",
837
"handler" => array($this, "run_calculation"),
838
"category" => __("Special,Math", "cladera-forms"),
839
+ "description" => __('Calculate values', "cladera-forms"),
840
"setup" => array(
841
"template" => CFCORE_PATH . "fields/calculation/config.php",
842
"preview" => CFCORE_PATH . "fields/calculation/preview.php",
1010
"not_supported" => array(
1011
'hide_label',
1012
'caption',
1013
+ 'required',
1014
+ 'entry_list'
1015
)
1016
)
1017
),
1028
'hide_label',
1029
'caption',
1030
'required',
1031
)
1032
)
1033
),
1215
1216
}
1217
1218
+ public function auto_populate_options_field($field, $form){
1219
+
1220
+ if(!empty($field['config']['auto'])){
1221
+ $field['config']['option'] = array();
1222
+ switch($field['config']['auto_type']){
1223
+ case 'post_type':
1224
+ $posts = get_posts( array('post_type' => $field['config']['post_type'], 'post_status' => 'publish') );
1225
+ if($field['type'] === 'dropdown'){
1226
+ $field['config']['option'] = array(
1227
+ array(
1228
+ 'value' => '',
1229
+ 'label' => ''
1230
+ )
1231
+ );
1232
+ }
1233
+ foreach($posts as $post_item){
1234
+ $field['config']['option'][$post_item->ID] = array(
1235
+ 'value' => $post_item->ID,
1236
+ 'label' => $post_item->post_title
1237
+ );
1238
+ }
1239
+ break;
1240
+ case 'taxonomy':
1241
+ $taxos = get_terms( $field['config']['taxonomy'], 'orderby=count&hide_empty=0' );
1242
+
1243
+ foreach( $taxos as $term){
1244
+ $field['config']['option'][$term->term_id] = array(
1245
+ 'value' => $term->term_id,
1246
+ 'label' => $term->name
1247
+ );
1248
+ }
1249
+ break;
1250
+ }
1251
+ }
1252
+ return $field;
1253
+ }
1254
+
1255
static public function check_condition($conditions, $form){
1256
1257
$trues = array();
1413
'text',
1414
'email'
1415
),
1416
+ 'get:*',
1417
+ 'post:*',
1418
+ 'request:*',
1419
+ 'post_meta:*',
1420
'embed_post:ID',
1421
'embed_post:post_title',
1422
'embed_post:permalink',
1435
1436
$tags['system'] = array(
1437
'type' => __('System Tags', 'caldera-forms'),
1438
+ 'tags' =>