Visual Form Builder - Version 2.6

Version Description

VFB now in its own menu, new All Forms UI, other bug fixes

Download this release

Release Info

Developer mmuro
Plugin Icon 128x128 Visual Form Builder
Version 2.6
Comparing to
See all releases

Code changes from version 2.5 to 2.6

css/nav-menu.css DELETED
@@ -1 +0,0 @@
1
- html,body{min-width:950px}#nav-menus-frame{margin-left:300px}#wpbody-content #menu-settings-column{display:inline;width:281px;margin-left:-300px;clear:both;float:left;padding-top:24px}.no-js #wpbody-content #menu-settings-column{padding-top:31px}#menu-settings-column .inside{clear:both}.metabox-holder-disabled .postbox{opacity:.5;filter:alpha(opacity=50)}.metabox-holder-disabled .button-controls .select-all{display:none}#wpbody{position:relative}.sub-navigation{float:none;font-size:12px;list-style:none;margin:8px 0 5px;padding:0;white-space:nowrap}.sub-navigation li{display:inline;margin:0;padding:0}.sub-navigation a{line-height:2;padding:.2em;text-decoration:none}.sub-navigation a.current{background:0;border:medium none;font-weight:bold;color:black}.sub-navigation a:hover{color:#d54e21}#menu-management-liquid{float:left;min-width:100%}#menu-management{position:relative;margin-right:20px;margin-top:-3px;width:100%}#menu-management .menu-edit{border:1px solid;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;margin-bottom:20px}#post-body{padding:10px;border-width:1px 0;border-style:solid}#nav-menu-header,#nav-menu-footer{padding:0 10px}#nav-menu-header{border-bottom:1px solid}#nav-menu-footer{border-top:1px solid}#post-body div.updated,#post-body div.error{margin:0}#vfb-entries-body-content{position:relative;float:none}#menu-management .menu-add-new abbr{font-weight:bold}#menu-management .nav-tabs-nav{margin:0 20px}#menu-management .nav-tabs-arrow{width:10px;padding:0 5px 4px;cursor:pointer;position:absolute;top:0;line-height:22px;font-size:18px;text-shadow:0 1px 0 #fff}#menu-management .nav-tabs-arrow-left{left:0}#menu-management .nav-tabs-arrow-right{right:0;text-align:right}#menu-management .nav-tabs-wrapper{width:100%;height:28px;margin-bottom:-1px;overflow:hidden}#menu-management .nav-tabs{padding-left:20px;padding-right:10px}.js #menu-management .nav-tabs{float:left;margin-left:0;margin-right:-400px}#menu-management .nav-tab{margin-bottom:0;font-size:14px;font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif}#select-nav-menu-container{text-align:right;padding:0 10px 3px 10px;margin-bottom:5px}#select-nav-menu{width:100px;display:inline}#menu-name-label{margin-top:-2px}#wpbody .open-label{display:block;float:left}#wpbody .open-label span{padding-right:10px}.js .input-with-default-title{font-style:italic}#menu-management .inside{padding:0 10px}.postbox .howto input{width:180px;float:right}.customlinkdiv .howto input{width:200px}#nav-menu-theme-locations .howto select{width:100%}#nav-menu-theme-locations .button-controls{text-align:right}.add-menu-item-view-all{height:400px}#menu-container .submit{margin:0 0 10px;padding:0}.meta-sep,.submitdelete,.submitcancel{display:block;float:left;font-size:12px;margin:4px 0;line-height:15px}.meta-sep{padding:0 2px}#cancel-save{text-decoration:underline;font-size:12px;margin-left:20px;margin-top:5px}.list-controls{float:left;margin-top:5px}.add-to-menu{float:right}.postbox img.waiting{display:none;vertical-align:middle}.button-controls{clear:both;margin:10px 0}.show-all,.hide-all{cursor:pointer}.hide-all{display:none}#menu-name{width:270px}#manage-menu .inside{padding:0}#available-links dt{display:block}#add-custom-link .howto{font-size:12px}#add-custom-link label span{display:block;float:left;margin-top:5px;padding-right:5px}.menu-item-textbox{width:180px}.howto span{margin-top:4px;display:block;float:left}.quick-search{width:190px}.list-wrap{display:none;clear:both;margin-bottom:10px}.list-container{max-height:200px;overflow-y:auto;padding:10px 10px 5px;border:1px solid;-moz-border-radius:3px}.postbox p.submit{margin-bottom:0}.list li{display:none;margin:0;margin-bottom:5px}.list li .menu-item-title{cursor:pointer;display:block}.list li .menu-item-title input{margin-right:3px;margin-top:-3px}#menu-container .inside{padding-bottom:10px}.menu{padding-top:1em}#menu-to-edit{padding:1em 0;width:465px}.menu ul{width:100%}.menu li{margin-bottom:0;position:relative;opacity:1.0}.menu-item-bar{clear:both;line-height:1.5em;position:relative;margin-top:13px}.menu-item-handle{border:1px solid #dfdfdf;position:relative;padding-left:10px;height:auto;width:400px;line-height:35px;text-shadow:0 1px 0 #fff;overflow:hidden;word-wrap:break-word;border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-khtml-border-radius:3px}#menu-to-edit .menu-item-invalid .menu-item-handle{background-color:#f6c9cc;background-image:-ms-linear-gradient(bottom,#f6c9cc,#fdf8ff);background-image:-moz-linear-gradient(bottom,#f6c9cc,#fdf8ff);background-image:-o-linear-gradient(bottom,#f6c9cc,#fdf8ff);background-image:-webkit-gradient(linear,left bottom,left top,from(#f6c9cc),to(#fdf8ff));background-image:-webkit-linear-gradient(bottom,#f6c9cc,#fdf8ff);background-image:linear-gradient(bottom,#f6c9cc,#fdf8ff)}.menu-item-edit-active .menu-item-handle{-moz-border-radius:3px 3px 0 0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-khtml-border-bottom-right-radius:0;-khtml-border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.no-js .menu-item-edit-active .item-edit{display:none}.js .menu-item-handle{cursor:move}.menu li.deleting .menu-item-handle{background-image:none;text-shadow:0}.menu-item-handle .item-title{font-size:12px;font-weight:bold;padding:7px 0;line-height:20px;display:block;margin-right:13em}li.menu-item.ui-sortable-helper dl{margin-top:0}li.menu-item.ui-sortable-helper .menu-item-transport dl{margin-top:13px}.menu .sortable-placeholder{height:35px;min-height:35px;width:410px;margin-top:13px}.menu-item-depth-0{margin-left:0}.menu-item-depth-1{margin-left:30px}.menu-item-depth-2{margin-left:60px}.menu-item-depth-3{margin-left:90px}.menu-item-depth-4{margin-left:120px}.menu-item-depth-5{margin-left:150px}.menu-item-depth-6{margin-left:180px}.menu-item-depth-7{margin-left:210px}.menu-item-depth-8{margin-left:240px}.menu-item-depth-9{margin-left:270px}.menu-item-depth-10{margin-left:300px}.menu-item-depth-11{margin-left:330px}.menu-item-depth-0 .menu-item-transport{margin-left:0}.menu-item-depth-1 .menu-item-transport{margin-left:-30px}.menu-item-depth-2 .menu-item-transport{margin-left:-60px}.menu-item-depth-3 .menu-item-transport{margin-left:-90px}.menu-item-depth-4 .menu-item-transport{margin-left:-120px}.menu-item-depth-5 .menu-item-transport{margin-left:-150px}.menu-item-depth-6 .menu-item-transport{margin-left:-180px}.menu-item-depth-7 .menu-item-transport{margin-left:-210px}.menu-item-depth-8 .menu-item-transport{margin-left:-240px}.menu-item-depth-9 .menu-item-transport{margin-left:-270px}.menu-item-depth-10 .menu-item-transport{margin-left:-300px}.menu-item-depth-11 .menu-item-transport{margin-left:-330px}body.menu-max-depth-0{min-width:950px!important}body.menu-max-depth-1{min-width:980px!important}body.menu-max-depth-2{min-width:1010px!important}body.menu-max-depth-3{min-width:1040px!important}body.menu-max-depth-4{min-width:1070px!important}body.menu-max-depth-5{min-width:1100px!important}body.menu-max-depth-6{min-width:1130px!important}body.menu-max-depth-7{min-width:1160px!important}body.menu-max-depth-8{min-width:1190px!important}body.menu-max-depth-9{min-width:1220px!important}body.menu-max-depth-10{min-width:1250px!important}body.menu-max-depth-11{min-width:1280px!important}.item-type{font-size:12px;padding-right:10px}.item-controls{font-size:12px;position:absolute;right:20px;top:0}.item-controls a{text-decoration:none}.item-controls a:hover{cursor:pointer}.item-controls .item-order{padding-right:10px}.item-controls .item-order a{font-weight:bold}body.js .item-order{display:none}.item-edit{position:absolute;right:-20px;top:0;display:block;width:30px;height:36px;overflow:hidden;text-indent:-999em;background:url("arrows.png") no-repeat scroll 8px 10px transparent}.item-edit:hover{background:url("arrows.png") no-repeat scroll 8px 10px transparent}.item-edit.opened{background:url("arrows.png") no-repeat scroll 8px -25px transparent}.item-edit.opened:hover{background:url("arrows.png") no-repeat scroll 8px -149px transparent}.menu-instructions-inactive{display:none}.menu-item-settings{display:block;width:400px;padding:10px 0 10px 10px;border:solid;border-width:0 1px 1px 1px;-moz-border-radius:0 0 3px 3px;-webkit-border-bottom-right-radius:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-bottom-right-radius:3px;-khtml-border-bottom-left-radius:3px}.menu-item-edit-active .menu-item-settings{display:block}.menu-item-edit-inactive .menu-item-settings{display:none}.add-menu-item-pagelinks{margin:.5em auto;text-align:center}.link-to-original{display:block;margin:0 0 10px;padding:3px 5px 5px;font-size:12px;font-style:italic;border:1px solid;border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-khtml-border-radius:3px}.link-to-original a{padding-left:4px;font-style:normal}.hidden-field{display:none}#form-settings .description-thin{margin:12px 10px 12px 0}.description-thin,.description-wide{margin-right:10px;float:left}.description-thin{width:190px;height:40px}.description-wide{width:390px}.menu-item-actions{padding-top:15px}#cancel-save{cursor:pointer}.major-publishing-actions{clear:both;padding:3px 0 5px}.major-publishing-actions .publishing-action{text-align:right;float:right;line-height:23px;margin:10px 0 1px}.major-publishing-actions .delete-action{vertical-align:middle;text-align:left;float:left;padding-right:15px;margin-top:5px}.menu-name-label span,.auto-add-pages label{font-size:12px;font-style:normal}.menu-name-label{margin-right:15px}.auto-add-pages input{margin-top:0}.auto-add-pages{margin-top:4px;float:left}.submitbox .submitcancel{border-bottom:1px solid;padding:1px 2px;text-decoration:none}.major-publishing-actions .form-invalid{padding-left:4px;margin-left:-4px;border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-khtml-border-radius:3px}.has-right-sidebar .inner-sidebar{display:block}.inner-sidebar{clear:right;float:right;position:relative;width:281px}.has-right-sidebar #vfb-entries-body-content{margin-right:300px}.inner-side #side-sortables{min-height:300px;padding:0;width:280px}#menu-item-name-wrap:after,#menu-item-url-wrap:after,#menu-name-label:after,#menu-settings-column .inside:after,#nav-menus-frame:after,#vfb-entries-body-content:after,.button-controls:after,.major-publishing-actions:after,.menu-item-settings:after{clear:both;content:".";display:block;height:0;visibility:hidden}#nav-menus-frame,.button-controls,#menu-item-url-wrap,#menu-item-name-wrap{display:block}.option .widefat{width:325px;margin:0 6px 7px 0}.addOption,.deleteOption,.addEmail,.deleteEmail{background:url('sprite.png') -12px -650px no-repeat transparent;text-indent:-9999px;width:16px;height:16px;display:inline-block}.deleteOption,.deleteEmail{background-position:-12px -677px}.addEmail,.deleteEmail{margin-top:5px}.ui-state-disabled .menu-item-handle{cursor:default}.ui-state-disabled .menu-item-handle{background-image:-moz-linear-gradient(top,#fff 0,#bbb 100%);background-image:-o-linear-gradient(top,#fff 0,#bbb 100%);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#fff),color-stop(1,#bbb));background-image:linear-gradient(top,#fff 0,#bbb 100%)}
 
css/visual-form-builder-admin.css CHANGED
@@ -1 +1 @@
1
- label.error{color:red;display:block}#visual-form-builder-update input.error,#visual-form-builder-update textarea.error,#visual-form-builder-update select.error{border:1px solid red}.menu-item-handle.fieldset,#form-element-fieldset{background-image:-moz-linear-gradient(top,#e3e3e3 0,#ccc 100%);background-image:-o-linear-gradient(top,#e3e3e3 0,#ccc 100%);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#e3e3e3),color-stop(1,#ccc));background-image:linear-gradient(top,#e3e3e3 0,#ccc 100%);box-shadow:0 1px 0 #e3e3e3 inset}.sender-labels{width:80px}.is-field-required{color:#bc1212;vertical-align:middle}.visual-form-builder-inline-edit{width:100%}.visual-form-builder-inline-edit-col{padding:0 .5em}.visual-form-builder-inline-edit label{display:block;margin:.2em 0}.visual-form-builder-inline-edit .title{display:block;float:left;width:5em;font-style:italic}.visual-form-builder-inline-edit .input-text-wrap{display:block;margin-left:5em}.visual-form-builder-inline-edit .input-text-wrap input[type="text"]{width:100%;border:#DDD solid 1px;border-radius:3px}.subsubsub{float:none}.nav-tabs-arrow-left{display:none}#form-items input{width:104px;float:left;margin:0 5px 10px 0}#form-element-text{background:url(sprite.png) 0 -89px no-repeat transparent}#form-element-textarea{background:url(sprite.png) 0 -173px no-repeat transparent}#form-element-checkbox{background:url(sprite.png) 0 -259px no-repeat transparent}#form-element-radio{background:url(sprite.png) 0 -51px no-repeat transparent}#form-element-select{background:url(sprite.png) 0 -7px no-repeat transparent}#form-element-address{background:url(sprite.png) 0 -129px no-repeat transparent}#form-element-datepicker{background:url(sprite.png) 0 -215px no-repeat transparent}#form-element-email{background:url(sprite.png) 0 -304px no-repeat transparent}#form-element-url{background:url(sprite.png) 0 -356px no-repeat transparent}#form-element-currency{background:url(sprite.png) 0 -405px no-repeat transparent}#form-element-digits{background:url(sprite.png) 0 -452px no-repeat transparent}#form-element-time{background:url(sprite.png) 0 -489px no-repeat transparent}#form-element-phone{background:url(sprite.png) 0 -529px no-repeat transparent}#form-element-html{background:url(sprite.png) 0 -559px no-repeat transparent}#form-element-file{background:url(sprite.png) 0 -587px no-repeat transparent}#form-element-instructions{background:url(sprite.png) 0 -621px no-repeat transparent}#form-element-section{background:url(sprite.png) 0 -809px no-repeat transparent}#form-details-nav{font-size:1.0em;font-weight:bold;padding-top:10px}#form-details-nav a{padding:5px 10px;text-decoration:none}#form-details-nav a.current{background-color:#777;background-image:-ms-linear-gradient(bottom,#6d6d6d,#808080);background-image:-moz-linear-gradient(bottom,#6d6d6d,#808080);background-image:-o-linear-gradient(bottom,#6d6d6d,#808080);background-image:-webkit-gradient(linear,left bottom,left top,from(#6d6d6d),to(#808080));background-image:-webkit-linear-gradient(bottom,#6d6d6d,#808080);background-image:linear-gradient(bottom,#6d6d6d,#808080);color:white;border-radius:5px;height:40px;text-shadow:0 -1px 0 #333;border-color:#dfdfdf}.form-details,#form-success-message-text,#form-success-message-page,#form-success-message-redirect{display:none}.form-details-current,.active{display:block}#confirmation-message textarea,#notification textarea{font-family:Consolas,Monaco,monospace;width:75%;height:10em;margin-top:10px}#form-success-message-page,#form-success-message-redirect{margin-top:10px}.post-body-plain ol li{list-style:decimal}#promote-vfb li{padding-left:20px}#promote-vfb #twitter{background:url(sprite.png) -10px -746px no-repeat transparent}#promote-vfb #star{background:url(sprite.png) -10px -710px no-repeat transparent}#promote-vfb #paypal{background:url(sprite.png) -10px -777px no-repeat transparent}.menu .ui-nestedSortable-error{background-color:#fbe3e4;border-color:red;color:#8a1f11}ul#menu-to-edit ul{margin:0 0 0 25px;padding:0;list-style-type:none;width:98%}.vfb-details{padding:0 10px;border:1px solid #ccc;margin-bottom:10px;border-radius:3px;width:95%}.vfb-details.section{background-color:#efefef;width:97.55%}.vfb-details .postbox{min-height:60px}#poststuff .vfb-details h2{margin-top:0}#poststuff h3.section-heading{padding-left:0}.vfb-pro-call-to-action a{text-decoration:none}.vfb-pro-call-to-action:hover{border-color:#dbf1ff}.vfb-pro-call-to-action{background-color:#3d93cd;border:5px solid #b0d2e8;border-radius:7px;box-shadow:inset 1px 1px 5px #398cc3,inset -1px -25px 5px #398cc3,0px 0 0 #fff;height:37px;margin:0 auto;padding:5px 30px 10px 30px;text-shadow:0 1px #2b658c;width:115px;line-height:22px}.vfb-pro-call-to-action .cta-sign-up{color:#fff;display:block;font-size:24px;font-weight:bold;text-align:center;text-decoration:none;text-shadow:1px 1px 1px #2b658c;width:100%;line-height:22px}.vfb-pro-call-to-action .cta-price{color:#ace7ff;display:block;font-size:12px;font-weight:normal;line-height:20px;text-align:center;text-decoration:none;width:100%;line-height:20px}.vfb-pro-upgrade{width:350px;float:left;padding:10px;background-color:#d3e7ee;border:1px solid #21759b;border-radius:5px}.vfb-pro-upgrade ul{list-style:outside;margin-left:10px}.post-body-plain{width:430px;float:left}#menu-instructions.post-body-plain{width:auto;float:none}.vfb-button{position:relative;overflow:visible;display:inline-block;border:1px solid #d4d4d4;margin:0;padding:.5em 2.5em .5em 1em;text-decoration:none;text-shadow:1px 1px 0 #fff;font:12px/normal sans-serif;color:#333;white-space:nowrap;cursor:pointer;outline:0;background-color:#ececec;background-image:-webkit-gradient(linear,0 0,0 100%,from(#f4f4f4),to(#ececec));background-image:-moz-linear-gradient(#f4f4f4,#ececec);background-image:-o-linear-gradient(#f4f4f4,#ececec);background-image:linear-gradient(#f4f4f4,#ececec);-webkit-background-clip:padding;-moz-background-clip:padding;-o-background-clip:padding-box;-webkit-border-radius:.2em;-moz-border-radius:.2em;border-radius:.2em;zoom:1;*display:inline}.vfb-button:hover,.vfb-button:active,.vfb-button.current{border-color:#3072b3;border-bottom-color:#2a65a0;text-decoration:none;text-shadow:-1px -1px 0 rgba(0,0,0,0.3);color:#fff;background-color:#3072b3;background-image:-webkit-gradient(linear,0 0,0 100%,from(#599bdc),to(#3072b3));background-image:-moz-linear-gradient(#599bdc,#3072b3);background-image:-o-linear-gradient(#599bdc,#3072b3);background-image:linear-gradient(#599bdc,#3072b3)}.vfb-button.current{font-weight:bold}.vfb-button::-moz-focus-inner{padding:0;border:0}.vfb-button.vfb-delete{color:#900}.vfb-button.vfb-delete:hover,.vfb-button.vfb-delete:focus,.vfb-button.vfb-delete:active{border-color:#b53f3a;border-bottom-color:#a0302a;color:#fff;background-color:#dc5f59;background-image:-webkit-gradient(linear,0 0,0 100%,from(#dc5f59),to(#b33630));background-image:-moz-linear-gradient(#dc5f59,#b33630);background-image:-o-linear-gradient(#dc5f59,#b33630);background-image:linear-gradient(#dc5f59,#b33630)}.vfb-button.vfb-delete:active,.vfb-button.vfb-delete.active{border-color:#a0302a;border-bottom-color:#bf4843;background-color:#b33630;background-image:-webkit-gradient(linear,0 0,0 100%,from(#b33630),to(#dc5f59));background-image:-moz-linear-gradient(#b33630,#dc5f59);background-image:-o-linear-gradient(#b33630,#dc5f59);background-image:linear-gradient(#b33630,#dc5f59)}.vfb-button.vfb-duplicate:hover,.vfb-button.vfb-duplicate:focus,.vfb-button.vfb-duplicate:active{border-color:#8gfc400;border-bottom-color:#8gfc400;color:#fff;background-color:#82ba0b;background-image:-webkit-gradient(linear,0 0,0 100%,from(#7cbc0a),to(#82ba0b));background-image:-moz-linear-gradient(#7cbc0a,#82ba0b);background-image:-o-linear-gradient(#7cbc0a,#82ba0b);background-image:linear-gradient(#7cbc0a,#82ba0b)}.button-group{display:inline-block;list-style:none;margin-top:10px}.button-group .vfb-button{float:left;margin-left:-1px}.vfb-button.vfb-first{border-bottom-right-radius:0;border-top-right-radius:0}.vfb-button.vfb-last{border-bottom-left-radius:0;border-top-left-radius:0}.button-icon{width:18px;height:24px;position:absolute;top:0;right:0}.button-icon.arrow{background:url("arrows.png") no-repeat scroll 0 -118px transparent}.current .button-icon.arrow{background:url("arrows.png") no-repeat scroll 0 -30px transparent}.button-icon.plus{background:url("sprite.png") no-repeat scroll -12px -644px transparent}.button-icon.delete{background:url("sprite.png") no-repeat scroll -12px -671px transparent}#form-settings{width:460px;display:none}#form-settings.current{display:block}.form-details{padding:20px;background:rgba(255,255,255,0.5);box-shadow:0 0 0 1px rgba(155,155,155,0.3)}.form-details.on{display:block}.settings-links{background:none repeat scroll 0 0 #f5f5f5;box-shadow:0 0 0 1px rgba(155,155,155,0.3),1px 0 0 0 rgba(255,255,255,0.9) inset,0px 2px 2px rgba(0,0,0,0.1);color:#777;cursor:pointer;display:block;font-family:Arial,Helvetica,sans-serif;font-size:15px;font-weight:bold;height:25px;line-height:28px;padding:5px 15px;position:relative;text-shadow:1px 1px 1px rgba(255,255,255,0.8);text-decoration:none;text-transform:uppercase;z-index:20}.settings-links .arrow{position:absolute;width:24px;height:24px;right:13px;top:7px;background:url("arrows.png") no-repeat scroll 8px -278px transparent}.settings-links.on .arrow{background:url("arrows.png") no-repeat scroll 8px -252px transparent}.settings-links:hover,.settings-links.on{background:#c6e1ec;color:#3d7489;text-shadow:0 1px 1px rgba(255,255,255,0.6);box-shadow:0 0 0 1px rgba(155,155,155,0.3),0px 2px 2px rgba(0,0,0,0.1)}.vfb-tooltip{position:relative;float:right;cursor:pointer;width:16px;height:16px;margin-right:2px}.tooltip{text-indent:0;z-index:200;width:175px;padding:5px 20px;border-radius:5px;border:2px solid white;box-shadow:0 0 7px black;background:rgba(0,0,0,0.6);position:absolute;top:-40px;display:none;font-style:normal;color:white}.tooltip h3{font-weight:bold;font-size:16px;padding-bottom:6px;margin:5px 0;border-bottom:1px solid white}.tooltip p{font-size:12px;margin-top:10px}
1
+ .vfb-pro-call-to-action a{text-decoration:none}.vfb-pro-call-to-action:hover{border-color:#dbf1ff}.vfb-pro-call-to-action{background-color:#3d93cd;border:5px solid #b0d2e8;border-radius:7px;box-shadow:inset 1px 1px 5px #398cc3,inset -1px -25px 5px #398cc3,0px 0 0 #fff;height:37px;margin:0 auto;padding:5px 30px 10px 30px;text-shadow:0 1px #2b658c;width:115px;line-height:22px}.vfb-pro-call-to-action .cta-sign-up{color:#fff;display:block;font-size:24px;font-weight:bold;text-align:center;text-decoration:none;text-shadow:1px 1px 1px #2b658c;width:100%;line-height:22px}.vfb-pro-call-to-action .cta-price{color:#ace7ff;display:block;font-size:12px;font-weight:normal;line-height:20px;text-align:center;text-decoration:none;width:100%;line-height:20px}.vfb-pro-upgrade{display:inline;float:left;padding:10px;margin-bottom:20px;background-color:#d3e7ee;border:1px solid #21759b;border-radius:5px}.vfb-pro-upgrade ul{list-style:outside;margin-left:10px}#vfb-form-builder-frame{display:block;margin:0 -8px 0 290px}#vfb-form-builder-frame:after,#form-editor-header .vfb-major-publishing-actions:after,#form-editor-footer .vfb-major-publishing-actions:after,#vfb-form-builder-frame .menu-item-settings:after,#vfb-form-list:after{clear:both;content:".";display:block;height:0;visibility:hidden}#vfb-form-builder-sidebar{clear:both;width:281px}#vfb-form-builder-management{margin-right:20px;position:relative}#vfb-form-builder-management .form-edit{border:1px solid #dfdfdf;border-radius:3px;margin-bottom:20px}#form-editor-header,#form-editor-footer{padding:0 10px;border-bottom:1px solid #dfdfdf;background-color:#f1f1f1;background-image:-ms-linear-gradient(top,#f9f9f9,#ececec);background-image:-moz-linear-gradient(top,#f9f9f9,#ececec);background-image:-o-linear-gradient(top,#f9f9f9,#ececec);background-image:-webkit-gradient(linear,left top,left bottom,from(#f9f9f9),to(#ececec));background-image:-webkit-linear-gradient(top,#f9f9f9,#ececec);background-image:linear-gradient(top,#f9f9f9,#ececec)}#form-editor-footer{border-top:1px solid #dfdfdf}.vfb-major-publishing-actions{clear:both;padding:3px 0 5px}.vfb-major-publishing-actions .publishing-action{float:right;line-height:23px;margin:5px 0 1px;text-align:right}#form-editor-header .publishing-action{margin-top:12px}.sub-navigation{float:none;font-size:12px;list-style:none;margin:8px 0 5px;padding:0;white-space:nowrap}.sub-navigation li{display:inline;margin:0;padding:0}.sub-navigation a{line-height:2;padding:.2em;text-decoration:none}.sub-navigation a.current{background:0;border:medium none;font-weight:bold;color:black}.sub-navigation a:hover{color:#d54e21}#vfb-sidebar,#vfb-main{float:left;width:100px;margin:10px 0}#vfb-main{width:auto}#vfb-main.vfb-order-type-list{width:100%}#vfb-main p a,#vfb-main h3 a{text-decoration:none}#vfb-main .submitdelete{color:#bc0b0b;text-decoration:none}#vfb-main .submitdelete:hover{color:red}#vfb-sidebar{margin-left:-150px}#vfb-form-list{display:block;margin-left:150px}.vfb-box{border:1px solid #dfdfdf;border-radius:3px 3px 3px 3px;box-shadow:0 1px 0 #fff inset;background-color:#f5f5f5;background-image:-moz-linear-gradient(center top,#f9f9f9,#f5f5f5);position:relative;padding:0 10px;line-height:1.4em;float:left}.vfb-box .button-primary{float:right}.vfb-box .vfb-form-meta-actions{min-height:160px}.vfb-box .vfb-publishing-actions{height:35px;text-align:center}.form-boxes,.vfb-empty-container,#vfb-main .sortable-placeholder{float:left;width:210px;min-height:200px;margin:8px}#vfb-main .sortable-placeholder{border:1px dashed #bbb;background-color:#f5f5f5;height:200px}.sortable-placeholder{display:block;height:400px}.vfb-empty-container{border:3px dashed #ccc}.wrap .form-boxes h2{cursor:move;font-size:18px;font-weight:bold;word-wrap:break-word;border-bottom:1px solid #ccc;color:#464646}.wrap .form-boxes h2:hover{color:black}a.form-boxes-title{display:block;width:auto;text-decoration:none}.vfb-form-alpha-list{display:inline;margin-right:20px;float:left;width:70%}.vfb-form-alpha-list hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0}#vfb-no-forms{font-family:"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;font-size:32px;font-weight:normal;line-height:1.2;text-shadow:1px 1px 1px #fff}.vfb-form-alpha-group .letter,.wrap h2.letter{float:left;font-size:14px;line-height:17px;padding:0;color:#666}.vfb-form-alpha-form{display:block;margin:10px 0;padding-left:85px;width:auto}.vfb-form-alpha-form h3{float:left;width:60%;margin:0;font-size:17px;word-wrap:break-word}.vfb-form-alpha-form .vfb-publishing-actions,.vfb-form-alpha-form .vfb-form-meta{float:right;text-align:center;width:25%}.vfb-form-alpha-form .vfb-publishing-actions p,.vfb-form-alpha-form .vfb-form-meta p{margin:0}.vfb-form-alpha-form .vfb-form-meta,.vfb-form-alpha-form .paypal{float:left;text-align:left;margin:0}#new-form{width:75px;height:105px;text-align:center;margin:8px 0;padding-top:10px}#new-form a{display:block;width:auto;text-decoration:none}#vfb-form-order-type{clear:left;text-align:center}#vfb-form-order-type li{display:inline;list-style:none;margin-bottom:0}#vfb-form-order-type a{text-decoration:none;text-indent:-9999px;width:18px;height:18px;overflow:hidden;display:inline-block}#vfb-form-order-type a.order.on,#vfb-form-order-type a.order:hover{background:url('../images/sprite.png?d=20120921') -10px -1323px no-repeat transparent}#vfb-form-order-type a.order{background:url('../images/sprite.png?d=20120921') -10px -1353px no-repeat transparent}#vfb-form-order-type a.list.on,#vfb-form-order-type a.list:hover{background:url('../images/sprite.png?d=20120921') -10px -1389px no-repeat transparent}#vfb-form-order-type a.list{background:url('../images/sprite.png?d=20120921') -10px -1421px no-repeat transparent}#post-body{padding:10px}.vfb-postbox-container{float:left;margin:0 8px;width:100%}#vfb-postbox-container-1 .postbox{min-width:281px}#vfb-postbox-container-2{min-width:485px}#vfb-form-builder-frame.columns-1{margin-left:-8px}#vfb-form-builder-frame.columns-1 #vfb-postbox-container-1{float:none}#vfb-form-builder-frame.columns-1 #vfb-postbox-container-2{width:99%}#vfb-form-builder-frame.columns-2 #vfb-postbox-container-3{display:none}#vfb-form-builder-frame.columns-2 #vfb-postbox-container-1,#vfb-form-builder-frame.columns-3 #vfb-postbox-container-1{width:281px;margin-left:-290px}#vfb-form-builder-frame.columns-3 #vfb-form-builder-management{margin-right:0}#vfb-form-builder-frame.columns-3 #vfb-postbox-container-2{width:30%}#vfb-form-builder-frame.columns-3 #vfb-postbox-container-3{display:inline;margin-right:0;width:46.5%}#vfb-form-meta-preview iframe{width:100%;height:100%}@media only screen and (max-width:799px){#vfb-form-builder-frame .vfb-postbox-container{width:100%}.columns-prefs .columns-prefs-3{display:none}}@media only screen and (min-width:800px) and (max-width:1200px){#vfb-form-builder-frame .vfb-postbox-container{width:49.5%}#vfb-form-builder-frame.columns-3 #vfb-postbox-container-2,#vfb-form-builder-frame.columns-3 #vfb-postbox-container-3{width:50.5%}#vfb-form-builder-frame.columns-1 .vfb-postbox-container{width:100%}}@media only screen and (min-width:1600px){#vfb-form-builder-frame.columns-3 #vfb-postbox-container-3{width:58%}}.item-edit{position:absolute;right:-20px;top:0;display:block;width:30px;height:36px;overflow:hidden;text-indent:-999em;background:url('../images/arrows.png?d=20120921') no-repeat scroll 8px 10px transparent}.item-edit:hover{background:url('../images/arrows.png?d=20120921') no-repeat scroll 8px 10px transparent}.item-edit.opened{background:url('../images/arrows.png?d=20120921') no-repeat scroll 8px -25px transparent}.item-edit.opened:hover{background:url('../images/arrows.png?d=20120921') no-repeat scroll 8px -148px transparent}.option .widefat{width:325px;margin:0 6px 7px 0}#form-settings .description-thin{margin:12px 10px 12px 0}.description-thin,.description-wide{margin-right:10px;float:left}.description-thin{width:190px;height:40px}.description-wide{width:390px}.addOption,.deleteOption,.addEmail,.deleteEmail,.addCondition,.deleteCondition{background:url('../images/sprite.png?d=20120921') -12px -650px no-repeat transparent;text-indent:-9999px;width:16px;height:16px;display:inline-block}.deleteOption,.deleteEmail,.deleteCondition{background-position:-12px -677px}.addEmail,.deleteEmail{margin-top:5px}.ui-state-disabled .menu-item-handle{cursor:default;background:#bbb;background-image:-moz-linear-gradient(top,#fff 0,#bbb 100%);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#fff),color-stop(100%,#bbb));background-image:-webkit-linear-gradient(top,#fff 0,#bbb 100%);background-image:-o-linear-gradient(top,#fff 0,#bbb 100%);background-image:-ms-linear-gradient(top,#fff 0,#bbb 100%);background-image:linear-gradient(to bottom,#fff 0,#bbb 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff',endColorstr='#bbb',GradientType=0)}.item-conditional-icon{background:url('../images/sprite.png?d=20120921') -10px -1449px no-repeat transparent;width:16px;height:16px;position:absolute;top:9px;left:-25px}.vfb-conditional-fields{float:right}.vfb-conditional-fields-data{vertical-align:middle}.vfb-conditional-fields-data select{width:40%;margin-bottom:3px}.vfb-conditional-fields-data select.vfb-conditional-condition{width:auto}#vfb-poststuff{display:block;margin-right:300px}#vfb-entries-body-content{float:left;width:100%}.metabox-holder #vfb-entries-body-content h3{font-family:sans-serif;font-weight:bold}#entry-edit #side-info-column{margin-right:-300px}label.error{color:red;display:block}#visual-form-builder-update input.error,#visual-form-builder-update textarea.error,#visual-form-builder-update select.error{border:1px solid red}.menu-item-handle.fieldset,#form-element-fieldset{background:#e3e3e3;background-image:-moz-linear-gradient(top,#e3e3e3 0,#ccc 100%);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#e3e3e3),color-stop(100%,#ccc));background-image:-webkit-linear-gradient(top,#e3e3e3 0,#ccc 100%);background-image:-o-linear-gradient(top,#e3e3e3 0,#ccc 100%);background-image:-ms-linear-gradient(top,#e3e3e3 0,#ccc 100%);background-image:linear-gradient(to bottom,#e3e3e3 0,#ccc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e3e3e3',endColorstr='#cccccc',GradientType=0);box-shadow:0 1px 0 #e3e3e3 inset}.menu-item-handle .item-title{min-height:20px}.sender-labels{width:80px}.is-field-required{color:#bc1212;vertical-align:middle}#form-details-nav{font-size:1.0em;padding-top:10px}#form-details-nav a,.charts-nav a{padding:5px 10px;font-weight:bold;text-decoration:none}#form-details-nav a.current,.charts-nav a.current{background-color:#777;background-image:-ms-linear-gradient(bottom,#6d6d6d,#808080);background-image:-moz-linear-gradient(bottom,#6d6d6d,#808080);background-image:-o-linear-gradient(bottom,#6d6d6d,#808080);background-image:-webkit-gradient(linear,left bottom,left top,from(#6d6d6d),to(#808080));background-image:-webkit-linear-gradient(bottom,#6d6d6d,#808080);background-image:linear-gradient(bottom,#6d6d6d,#808080);color:white;border-radius:5px;height:40px;text-shadow:0 -1px 0 #333;border-color:#dfdfdf}.form-details,#form-success-message-text,#form-success-message-page,#form-success-message-redirect{display:none}.form-details-current,.active{display:block}#confirmation-message textarea,#notification textarea{font-family:Consolas,Monaco,monospace;width:100%;height:10em}#form-success-message-page,#form-success-message-redirect{width:100%;margin-top:10px}.post-body-plain ol li{list-style:decimal}#vfb-upgrade-column{display:inline;float:left;width:25%}#promote-vfb li{padding-left:20px}#promote-vfb #twitter{background:url('../images/sprite.png?d=20120921') -10px -746px no-repeat transparent}#promote-vfb #star{background:url('../images/sprite.png?d=20120921') -10px -710px no-repeat transparent}#promote-vfb #paypal,.paypal{background:url('../images/sprite.png?d=20120921') -10px -777px no-repeat transparent}.paypal{padding-top:3px;padding-left:20px;height:20px}.menu .ui-nestedSortable-error{background-color:#fbe3e4;border-color:red;color:#8a1f11}ul#menu-to-edit ul{margin:0 0 0 25px;padding:0;list-style-type:none;width:98%}.vfb-details{padding:0 10px;border:1px solid #ccc;margin-bottom:10px;border-radius:3px}.vfb-details.section{background-color:#efefef;width:97.55%}.vfb-details .postbox{min-height:60px}#poststuff .vfb-details h2{margin-top:0}#poststuff h3.section-heading{padding-left:0}#switcher_form{width:100%}#form-items .tabs-panel{padding:.5em 0 .5em 4px;overflow:visible;height:auto;min-height:300px}ul.vfb-fields-col-1,ul.vfb-fields-col-2{float:left;list-style:none;width:50%}#vfb-form-builder-frame.columns-1 #vfb-postbox-container-1 #form-items .tabs-panel{height:auto}.vfb-draggable-form-items{display:block;text-align:left;text-decoration:none;padding:4px 0 4px 34px;margin-right:8px;position:relative;border-radius:3px;color:#464646;border:1px solid #bbb;position:relative}.vfb-draggable-form-items:hover{border-color:#aaa}.vfb-draggable-form-items b{background-image:url('../images/sprite.png?d=20120921');background-repeat:no-repeat;background-color:transparent;display:inline-block;position:absolute;left:8px;width:18px;height:16px;line-height:16px}#form-element-address b{background-position:-10px -132px}#form-element-autocomplete b{background-position:-10px -1029px}#form-element-checkbox b{background-position:-10px -261px}#form-element-color b{background-position:-10px -885px}#form-element-creditcard b{background-position:-10px -847px}#form-element-currency b{background-position:-10px -408px}#form-element-datepicker b{background-position:-10px -218px}#form-element-digits b{background-position:-10px -454px}#form-element-email b{background-position:-10px -306px}#form-element-file b{background-position:-10px -590px}#form-element-hidden b{background-position:-10px -999px}#form-element-html b{background-position:-10px -562px}#form-element-instructions b{background-position:-10px -623px}#form-element-ip b{background-position:-10px -923px}#form-element-matrix b{background-position:-10px -1216px}#form-element-max b{background-position:-10px -1062px}#form-element-min b{background-position:-10px -1094px}#form-element-pagebreak b{background-position:-10px -1292px}#form-element-password b{background-position:-10px -964px}#form-element-phone b{background-position:-10px -532px}#form-element-radio b{background-position:-10px -53px}#form-element-range b{background-position:-10px -1186px}#form-element-section b{background-position:-10px -812px}#form-element-select b{background-position:-10px -10px}#form-element-slider b{background-position:-10px -1126px}#form-element-spinner b{background-position:-10px -1154px}#form-element-text b{background-position:-10px -91px}#form-element-textarea b{background-position:-10px -176px}#form-element-time b{background-position:-10px -493px}#form-element-username b{background-position:-10px -1255px}#form-element-url b{background-position:-10px -360px}.static-vars-inactive{display:none}.static-vars-active{display:block}#design-switcher{margin:10px 0}.charts-container{margin-top:23px}#chart_div{width:100%;height:300px;display:inline;float:left;margin-bottom:25px;overflow:hidden}.charts-nav{margin:1em 0}.charts-nav a{padding:5px 10px;text-decoration:none;font-weight:bold}.charts-nav a.current{background-color:#777;background-image:-ms-linear-gradient(bottom,#6d6d6d,#808080);background-image:-moz-linear-gradient(bottom,#6d6d6d,#808080);background-image:-o-linear-gradient(bottom,#6d6d6d,#808080);background-image:-webkit-gradient(linear,left bottom,left top,from(#6d6d6d),to(#808080));background-image:-webkit-linear-gradient(bottom,#6d6d6d,#808080);background-image:linear-gradient(bottom,#6d6d6d,#808080);color:white;border-radius:5px;height:40px;text-shadow:0 -1px 0 #333;border-color:#dfdfdf}.chart-loading{margin:0 auto;border:1px solid #ccc;border-radius:4px;width:100px;padding:10px}.chart-loading img{vertical-align:middle}.analytics-meta-boxes{border-radius:4px;text-align:center;border:1px solid #ccc;padding:0 10px 25px;margin:10px 10px 10px 0;width:200px}.analytics-meta-boxes h1{font-size:15px;background-color:#e7e7e7;border-bottom:1px solid #ccc;border-top-left-radius:4px;border-top-right-radius:4px;box-shadow:0 1px 0 rgba(255,255,255,0.7);display:block;margin:0 -10px;padding:10px 0}.analytics-meta-boxes h2{padding:0;margin-top:20px}.theader{background-image:-moz-linear-gradient(top,#f9f9f9 0,#ececec 100%);background-image:-o-linear-gradient(top,#e3e3e3 0,#ececec 100%);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#e3e3e3),color-stop(1,#ececec));background-image:linear-gradient(top,#e3e3e3 0,#ececec 100%);box-shadow:0 1px 0 #e3e3e3 inset;text-shadow:0 1px 0 #fff;font-weight:bold;font-size:14px;color:#464646}.table-row{border-color:#dfdfdf;background-color:white}.table-row td,.odd-row td,.hover-row td,.selected-row td{padding:10px 5px}.odd-row{background-color:#f9f9f9}.hover-row{background-color:#a9bad3;cursor:pointer}.selected-row{background-color:#d54e21}#paypal-price-switch{display:none;position:relative;top:6px}.vfb-button{position:relative;overflow:visible;display:inline-block;border:1px solid #d4d4d4;margin:0;padding:.5em 2.5em .5em 1em;text-decoration:none;text-shadow:1px 1px 0 #fff;font:12px/normal sans-serif;color:#333;white-space:nowrap;cursor:pointer;outline:0;background-color:#ececec;background-image:-webkit-gradient(linear,0 0,0 100%,from(#f4f4f4),to(#ececec));background-image:-moz-linear-gradient(#f4f4f4,#ececec);background-image:-o-linear-gradient(#f4f4f4,#ececec);background-image:linear-gradient(#f4f4f4,#ececec);-webkit-background-clip:padding;-moz-background-clip:padding;-o-background-clip:padding-box;-webkit-border-radius:.2em;-moz-border-radius:.2em;border-radius:.2em;zoom:1;*display:inline}.vfb-button:hover,.vfb-button:active,.vfb-button.current{border-color:#3072b3;border-bottom-color:#2a65a0;text-decoration:none;text-shadow:-1px -1px 0 rgba(0,0,0,0.3);color:#fff;background-color:#3072b3;background-image:-webkit-gradient(linear,0 0,0 100%,from(#599bdc),to(#3072b3));background-image:-moz-linear-gradient(#599bdc,#3072b3);background-image:-o-linear-gradient(#599bdc,#3072b3);background-image:linear-gradient(#599bdc,#3072b3)}.vfb-button.current{font-weight:bold}.vfb-button::-moz-focus-inner{padding:0;border:0}.vfb-button.vfb-delete{color:#900}.vfb-button.vfb-delete:hover,.vfb-button.vfb-delete:focus,.vfb-button.vfb-delete:active{border-color:#b53f3a;border-bottom-color:#a0302a;color:#fff;background-color:#dc5f59;background-image:-webkit-gradient(linear,0 0,0 100%,from(#dc5f59),to(#b33630));background-image:-moz-linear-gradient(#dc5f59,#b33630);background-image:-o-linear-gradient(#dc5f59,#b33630);background-image:linear-gradient(#dc5f59,#b33630)}.vfb-button.vfb-delete:active,.vfb-button.vfb-delete.active{border-color:#a0302a;border-bottom-color:#bf4843;background-color:#b33630;background-image:-webkit-gradient(linear,0 0,0 100%,from(#b33630),to(#dc5f59));background-image:-moz-linear-gradient(#b33630,#dc5f59);background-image:-o-linear-gradient(#b33630,#dc5f59);background-image:linear-gradient(#b33630,#dc5f59)}.vfb-button.vfb-duplicate:hover,.vfb-button.vfb-duplicate:focus,.vfb-button.vfb-duplicate:active{border-color:#8gfc400;border-bottom-color:#8gfc400;color:#fff;background-color:#82ba0b;background-image:-webkit-gradient(linear,0 0,0 100%,from(#7cbc0a),to(#82ba0b));background-image:-moz-linear-gradient(#7cbc0a,#82ba0b);background-image:-o-linear-gradient(#7cbc0a,#82ba0b);background-image:linear-gradient(#7cbc0a,#82ba0b)}.button-group{display:inline-block;list-style:none;margin-top:10px}.button-group .vfb-button{float:left;margin-left:-1px}.vfb-button.vfb-first{border-bottom-right-radius:0;border-top-right-radius:0}.vfb-button.vfb-last{border-bottom-left-radius:0;border-top-left-radius:0}.button-icon{width:18px;height:24px;position:absolute;top:0;right:0}.button-icon.arrow{background:url('../images/arrows.png?d=20120921') no-repeat scroll 0 -118px transparent}.current .button-icon.arrow{background:url('../images/arrows.png?d=20120921') no-repeat scroll 0 -30px transparent}.button-icon.plus{background:url('../images/sprite.png?d=20120921') no-repeat scroll -12px -644px transparent}.button-icon.delete{background:url('../images/sprite.png?d=20120921') no-repeat scroll -12px -671px transparent}#form-settings{width:460px;display:none}#form-settings.current{display:block}.form-details{padding:20px;background:rgba(255,255,255,0.5);box-shadow:0 0 0 1px rgba(155,155,155,0.3)}.form-details.on{display:block}.settings-links{background:none repeat scroll 0 0 #f5f5f5;box-shadow:0 0 0 1px rgba(155,155,155,0.3),1px 0 0 0 rgba(255,255,255,0.9) inset,0px 2px 2px rgba(0,0,0,0.1);color:#777;cursor:pointer;display:block;font-family:Arial,Helvetica,sans-serif;font-size:15px;font-weight:bold;height:25px;line-height:28px;padding:5px 15px;position:relative;text-shadow:1px 1px 1px rgba(255,255,255,0.8);text-decoration:none;text-transform:uppercase;z-index:20}.settings-links .arrow{position:absolute;width:24px;height:24px;right:13px;top:7px;background:url('../images/arrows.png?d=20120921') no-repeat scroll 8px -278px transparent}.settings-links.on .arrow{background:url('../images/arrows.png?d=20120921') no-repeat scroll 8px -252px transparent}.settings-links:hover,.settings-links.on{background:#c6e1ec;color:#3d7489;text-shadow:0 1px 1px rgba(255,255,255,0.6);box-shadow:0 0 0 1px rgba(155,155,155,0.3),0px 2px 2px rgba(0,0,0,0.1)}.vfb-tooltip{position:relative;float:right;cursor:pointer;width:16px;height:16px;margin-right:2px}.tooltip{text-indent:0;z-index:200;width:175px;padding:5px 20px;border-radius:5px;border:2px solid white;box-shadow:0 0 7px black;background:rgba(0,0,0,0.6);position:absolute;top:-40px;display:none;font-style:normal;color:white}.tooltip h3,.vfb-tooltip .tooltip h3{font-family:sans-serif;font-weight:bold;font-size:16px;padding:0 0 6px 0;margin:5px 0;border-bottom:1px solid white}.tooltip p{font-size:12px;margin-top:10px}#TB_window #vfb-conditional-fields a{color:#21759b;text-decoration:none}#TB_window #vfb-conditional-fields a:hover{text-decoration:underline}#vfb-build-conditional-fields-container{display:none}#vfb-build-conditional-fields-container.show-fields{display:block}.vfb-bulking{display:block;text-align:center;margin:0 auto;padding:3px;width:150px;border-radius:3px;border:1px solid #999;text-decoration:none;color:#666}.vfb-bulking:hover{border-color:#333}#bulk-options-left,#bulk-options-right{float:left;width:50%;height:200px;overflow:auto}#bulk-options-right{float:right;overflow:hidden;height:250px}#choicesText{width:99%;height:199px}#bulk-options-left ul{margin:0;border-top:1px solid #dfdfdf}#bulk-options-left ul li{display:block;border-bottom:1px solid #dfdfdf;border-top:1px solid white;font-size:15px;font-weight:normal;margin:0;text-shadow:0 1px 0 white;cursor:pointer;background-color:#eee;background-image:-webkit-gradient(linear,0 0,0 100%,from(#f5f5f5),to(#eee));background-image:-moz-linear-gradient(#f5f5f5,#eee);background-image:-o-linear-gradient(#f5f5f5,#eee);background-image:linear-gradient(#f5f5f5,#eee)}.vfb-bulk-options{text-decoration:none;display:block;padding:10px 20px;width:264px;position:relative}.vfb-bulk-options:after{border-bottom:6px solid transparent;border-left:6px solid #ccc;border-top:6px solid transparent;content:"";height:0;position:absolute;right:20px;top:13px;width:0;z-index:1}.vfb-bulk-options:hover:after{border-left-color:#aaa}#bulk-options-left ul li:hover{background-color:#f9f9f9;background-image:-webkit-gradient(linear,0 0,0 100%,from(#f9f9f9),to(#f1f1f1));background-image:-moz-linear-gradient(#f9f9f9,#f1f1f1);background-image:-o-linear-gradient(#f9f9f9,#f1f1f1);background-image:linear-gradient(#f9f9f9,#f1f1f1)}.vfb-export-filters{display:none}
css/visual-form-builder.css CHANGED
@@ -2,37 +2,61 @@ form.visual-form-builder{
2
  font-family:inherit;
3
  margin:20px 0;
4
  }
5
- form.visual-form-builder li{width:auto !important;}
6
- .visual-form-builder ul li{list-style:none;}
 
 
 
7
  .visual-form-builder ul{
8
  list-style:none;
9
  margin:0 14px;
10
  padding:0;
11
  font-size:12px;
12
  }
13
- .visual-form-builder li{
14
- list-style:none;
15
- clear:both;
16
- margin:0;
17
- padding:6px 1% 9px;
18
- width:64%;
19
- }
20
- .visual-form-builder li div span, span.full input, span.full select{
 
 
 
 
21
  display:block;
22
  float:left;
23
  width:100%;
24
  }
25
- .visual-form-builder span.left{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  float:left;
27
- width:48%;
28
  }
29
- .visual-form-builder span.right{
30
- float:right;
31
- width:48%;
 
32
  }
33
- .visual-form-builder span.right input, .visual-form-builder span.right select, .visual-form-builder span.left input, .visual-form-builder span.left select{width:100%;}
34
- .visual-form-builder span.time{float:left;margin:0 0.3em 0 0;}
35
- .visual-form-builder li div label, .visual-form-builder li span label{font-size:90%;}
36
  .visual-form-builder fieldset{
37
  background-color:#eeeeee;
38
  border-radius:3px;
@@ -40,6 +64,7 @@ form.visual-form-builder li{width:auto !important;}
40
  margin:15px 0;
41
  clear:both;
42
  }
 
43
  .visual-form-builder .legend{
44
  margin:5px 14px;
45
  padding:0 6px;
@@ -47,28 +72,35 @@ form.visual-form-builder li{width:auto !important;}
47
  border-bottom:1px solid #CCCCCC;
48
  font-size:inherit;
49
  }
50
- .visual-form-builder .legend h3{font-size:20px;}
51
- .visual-form-builder label, label.desc{
 
 
 
 
 
52
  display:block;
53
  margin:0;
54
  padding-bottom:3px;
55
  color:#000;
56
  }
57
- .visual-form-builder.left-label .desc, .visual-form-builder.right-label .desc{
58
- float:left;
59
- margin:0 15px 0 0;
60
- width:31%;
61
- /*width:20%;*/
62
- }
63
- .visual-form-builder.right-label .desc{
64
- padding-top:2px;
65
- text-align:right;
66
- }
67
- .visual-form-builder.left-label li div, .visual-form-builder.right-label li div{
68
- float:left;
69
- width:65%;
 
 
70
  }
71
- label.desc{font-weight:bold;}
72
  .visual-form-builder label.choice{
73
  font-size:100%;
74
  line-height:150%;
@@ -76,44 +108,111 @@ label.desc{font-weight:bold;}
76
  padding:0 0 5px;
77
  width:88%;
78
  }
 
79
  .visual-form-builder label span{
80
  color:#BC1212;
81
  vertical-align:middle;
82
  }
83
- input.text, textarea.textarea, select.select{
 
 
 
84
  font-size:100%;
85
  font-family:inherit;
86
  margin:0;
87
  padding:2px 0;
88
  }
89
- input.small, select.small{width:25%;}
90
- input.medium, select.medium{width:50%;}
91
- input.large, select.large, textarea.textarea{width:100%;}
92
- .visual-form-builder.left-label .textarea, .visual-form-builder.right-label .textarea{float:left;width:65%;}
93
- textarea.medium{height:5.5em;}
94
- textarea.medium{height:10em;}
95
- textarea.large{height:20em;}
96
- .submit{font-size:1.1em;}
97
- input.checkbox, input.radio{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  font-size:1.1em;
99
  display:block;
100
  height:13px;
101
  width:13px;
102
  margin:4px 0 0;
103
  }
104
- .visual-form-builder li.two-column div span, .visual-form-builder li.three-column div span, .visual-form-builder li.auto-column div span{
 
 
105
  margin:0 5px 0 0;
106
  width:48%;
107
  }
108
- .visual-form-builder li.three-column div span{width:30%;}
109
- .visual-form-builder li.auto-column div span{width:auto;}
110
- .visual-form-builder li.left-half, .visual-form-builder li.left-third, .visual-form-builder li.left-two-thirds{clear:left;float:left;}
111
- .visual-form-builder li.right-half, .visual-form-builder li.right-third, .visual-form-builder li.right-two-thirds{clear:none;float:right;}
112
- .visual-form-builder li.middle-third{clear:none;float:left;margin-left:2%;}
113
 
114
- .visual-form-builder li.left-half, .visual-form-builder li.right-half{width:47% !important;}
115
- .visual-form-builder li.left-third, .visual-form-builder li.middle-third, .visual-form-builder li.right-third{width:30% !important;}
116
- .visual-form-builder li.left-two-thirds, .visual-form-builder li.right-two-thirds{width:64% !important;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
  li.left-half .small, li.left-half .medium, li.left-half .large,
119
  li.right-half .small, li.right-half .medium, li.right-half .large,
@@ -121,18 +220,27 @@ li.left-third .small, li.left-third .medium, li.left-third .large,
121
  li.middle-third .small, li.middle-third .medium, li.middle-third .large,
122
  li.right-third .small, li.right-third .medium, li.right-third .large,
123
  .visual-form-builder li.left-two-thirds .small, .visual-form-builder li.left-two-thirds .medium, .visual-form-builder li.left-two-thirds .large,
124
- .visual-form-builder li.right-two-thirds .small, .visual-form-builder li.right-two-thirds .medium, .visual-form-builder li.right-two-thirds .large{width:100%;}
 
 
125
 
126
  label.error{
127
  color:red;
128
  font-weight:bold;
129
  font-size:90%;
130
  }
131
- input.error, select.error, textarea.error{border:1px solid red;}
 
 
 
 
 
 
132
  p#form_success{
133
  color:green;
134
  font-weight:bold;
135
  }
 
136
  #ui-datepicker-div {
137
  display: none;
138
  font-size:12px;
@@ -152,16 +260,30 @@ p#form_success{
152
  border:#C3C3C3 1px solid;
153
  text-transform:lowercase;
154
  }
155
- .ed_button:hover{
156
- background:none repeat scroll 0 0 #dddddd;
157
- border-color:#aaaaaa;
158
- cursor:pointer;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  }
160
- .ed_button.ed_bold{font-weight:bold;}
161
- .ed_button.ed_italic{font-style:italic;}
162
- .ed_button.ed_link{color:#0000FF;text-decoration:underline;}
163
- .ed_button.ed_del{text-decoration:line-through;}
164
- .item-instructions{background-color:#e3e3e3;border-radius:3px;}
165
  .section-div{
166
  background-color:#D4D4D4;
167
  border-radius:3px;
@@ -170,7 +292,11 @@ p#form_success{
170
  float:left;
171
  width:97%;
172
  }
173
- .section-div h4{font-size:16px;border-bottom:1px solid #BABABA;}
 
 
 
 
174
  .vfb-clear{
175
  clear:both;
176
  display:block;
2
  font-family:inherit;
3
  margin:20px 0;
4
  }
5
+
6
+ form.visual-form-builder li{
7
+ width:auto !important;
8
+ }
9
+
10
  .visual-form-builder ul{
11
  list-style:none;
12
  margin:0 14px;
13
  padding:0;
14
  font-size:12px;
15
  }
16
+
17
+ .visual-form-builder li{
18
+ list-style:none;
19
+ clear:both;
20
+ margin:0;
21
+ padding:6px 1% 9px;
22
+ width:64%;
23
+ }
24
+
25
+ .visual-form-builder li div span,
26
+ span.full input,
27
+ span.full select{
28
  display:block;
29
  float:left;
30
  width:100%;
31
  }
32
+
33
+ .visual-form-builder span.left{
34
+ float:left;
35
+ width:48%;
36
+ }
37
+
38
+ .visual-form-builder span.right{
39
+ float:right;
40
+ width:48%;
41
+ }
42
+
43
+ .visual-form-builder span.right input,
44
+ .visual-form-builder span.right select,
45
+ .visual-form-builder span.left input,
46
+ .visual-form-builder span.left select{
47
+ width:100%;
48
+ }
49
+
50
+ .visual-form-builder span.time{
51
  float:left;
52
+ margin:0 0.3em 0 0;
53
  }
54
+
55
+ .visual-form-builder li div label,
56
+ .visual-form-builder li span label{
57
+ font-size:90%;
58
  }
59
+
 
 
60
  .visual-form-builder fieldset{
61
  background-color:#eeeeee;
62
  border-radius:3px;
64
  margin:15px 0;
65
  clear:both;
66
  }
67
+
68
  .visual-form-builder .legend{
69
  margin:5px 14px;
70
  padding:0 6px;
72
  border-bottom:1px solid #CCCCCC;
73
  font-size:inherit;
74
  }
75
+
76
+ .visual-form-builder .legend h3{
77
+ font-size:20px;
78
+ }
79
+
80
+ .visual-form-builder label,
81
+ label.desc{
82
  display:block;
83
  margin:0;
84
  padding-bottom:3px;
85
  color:#000;
86
  }
87
+
88
+ .visual-form-builder.left-label .desc,
89
+ .visual-form-builder.right-label .desc{
90
+ float:left;
91
+ margin:0 15px 0 0;
92
+ width:20%;
93
+ }
94
+
95
+ .visual-form-builder.right-label .desc{
96
+ padding-top:2px;
97
+ text-align:right;
98
+ }
99
+
100
+ label.desc{
101
+ font-weight:bold;
102
  }
103
+
104
  .visual-form-builder label.choice{
105
  font-size:100%;
106
  line-height:150%;
108
  padding:0 0 5px;
109
  width:88%;
110
  }
111
+
112
  .visual-form-builder label span{
113
  color:#BC1212;
114
  vertical-align:middle;
115
  }
116
+
117
+ input.text,
118
+ textarea.textarea,
119
+ select.select{
120
  font-size:100%;
121
  font-family:inherit;
122
  margin:0;
123
  padding:2px 0;
124
  }
125
+
126
+ input.small,
127
+ select.small{
128
+ width:25%;
129
+ }
130
+
131
+ input.medium,
132
+ select.medium{
133
+ width:50%;
134
+ }
135
+
136
+ input.large,
137
+ select.large,
138
+ textarea.textarea{
139
+ width:100%;
140
+ }
141
+
142
+ textarea.medium{
143
+ height:5.5em;
144
+ }
145
+
146
+ textarea.medium{
147
+ height:10em;
148
+ }
149
+
150
+ textarea.large{
151
+ height:20em;
152
+ }
153
+
154
+ .submit{
155
+ font-size:1.1em;
156
+ }
157
+
158
+ input.checkbox,
159
+ input.radio{
160
  font-size:1.1em;
161
  display:block;
162
  height:13px;
163
  width:13px;
164
  margin:4px 0 0;
165
  }
166
+ .visual-form-builder li.two-column div span,
167
+ .visual-form-builder li.three-column div span,
168
+ .visual-form-builder li.auto-column div span{
169
  margin:0 5px 0 0;
170
  width:48%;
171
  }
 
 
 
 
 
172
 
173
+ .visual-form-builder li.three-column div span{
174
+ width:30%;
175
+ }
176
+
177
+ .visual-form-builder li.auto-column div span{
178
+ width:auto;
179
+ }
180
+
181
+ .visual-form-builder li.left-half,
182
+ .visual-form-builder li.left-third,
183
+ .visual-form-builder li.left-two-thirds{
184
+ clear:left;
185
+ float:left;
186
+ }
187
+
188
+ .visual-form-builder li.right-half,
189
+ .visual-form-builder li.right-third,
190
+ .visual-form-builder li.right-two-thirds{
191
+ clear:none;
192
+ float:right;
193
+ }
194
+
195
+ .visual-form-builder li.middle-third{
196
+ clear:none;
197
+ float:left;
198
+ margin-left:2%;
199
+ }
200
+
201
+ .visual-form-builder li.left-half,
202
+ .visual-form-builder li.right-half{
203
+ width:47% !important;
204
+ }
205
+
206
+ .visual-form-builder li.left-third,
207
+ .visual-form-builder li.middle-third,
208
+ .visual-form-builder li.right-third{
209
+ width:30% !important;
210
+ }
211
+
212
+ .visual-form-builder li.left-two-thirds,
213
+ .visual-form-builder li.right-two-thirds{
214
+ width:64% !important;
215
+ }
216
 
217
  li.left-half .small, li.left-half .medium, li.left-half .large,
218
  li.right-half .small, li.right-half .medium, li.right-half .large,
220
  li.middle-third .small, li.middle-third .medium, li.middle-third .large,
221
  li.right-third .small, li.right-third .medium, li.right-third .large,
222
  .visual-form-builder li.left-two-thirds .small, .visual-form-builder li.left-two-thirds .medium, .visual-form-builder li.left-two-thirds .large,
223
+ .visual-form-builder li.right-two-thirds .small, .visual-form-builder li.right-two-thirds .medium, .visual-form-builder li.right-two-thirds .large{
224
+ width:100%;
225
+ }
226
 
227
  label.error{
228
  color:red;
229
  font-weight:bold;
230
  font-size:90%;
231
  }
232
+
233
+ input.error,
234
+ select.error,
235
+ textarea.error{
236
+ border:1px solid red;
237
+ }
238
+
239
  p#form_success{
240
  color:green;
241
  font-weight:bold;
242
  }
243
+
244
  #ui-datepicker-div {
245
  display: none;
246
  font-size:12px;
260
  border:#C3C3C3 1px solid;
261
  text-transform:lowercase;
262
  }
263
+ .ed_button:hover{
264
+ background:none repeat scroll 0 0 #dddddd;
265
+ border-color:#aaaaaa;
266
+ cursor:pointer;
267
+ }
268
+ .ed_button.ed_bold{
269
+ font-weight:bold;
270
+ }
271
+ .ed_button.ed_italic{
272
+ font-style:italic;
273
+ }
274
+ .ed_button.ed_link{
275
+ color:#0000FF;
276
+ text-decoration:underline;
277
+ }
278
+ .ed_button.ed_del{
279
+ text-decoration:line-through;
280
+ }
281
+
282
+ .item-instructions{
283
+ background-color:#e3e3e3;
284
+ border-radius:3px;
285
  }
286
+
 
 
 
 
287
  .section-div{
288
  background-color:#D4D4D4;
289
  border-radius:3px;
292
  float:left;
293
  width:97%;
294
  }
295
+ .section-div h4{
296
+ font-size:16px;
297
+ border-bottom:1px solid #BABABA;
298
+ }
299
+
300
  .vfb-clear{
301
  clear:both;
302
  display:block;
{css → images}/arrows.png RENAMED
File without changes
images/media-button-help.png ADDED
Binary file
images/plus-sign.png ADDED
Binary file
{css → images}/sprite.png RENAMED
File without changes
{css → images}/vfb_icon.png RENAMED
File without changes
includes/admin-form-creator.php ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $action = ( isset( $_REQUEST['form'] ) && $_REQUEST['form'] !== '0' ) ? 'update_form' : 'create_form';
4
+
5
+ $order = sanitize_sql_orderby( 'form_id DESC' );
6
+ $forms = $wpdb->get_results( "SELECT * FROM $this->form_table_name ORDER BY $order" );
7
+
8
+ // Loop through each for and build the tabs
9
+ foreach ( $forms as $form ) {
10
+
11
+ // Control selected tab
12
+ if ( $form_nav_selected_id == $form->form_id ) :
13
+ $form_id = $form->form_id;
14
+ $form_title = stripslashes( $form->form_title );
15
+ $form_subject = stripslashes( $form->form_email_subject );
16
+ $form_email_from_name = stripslashes( $form->form_email_from_name );
17
+ $form_email_from = stripslashes( $form->form_email_from);
18
+ $form_email_from_override = stripslashes( $form->form_email_from_override);
19
+ $form_email_from_name_override = stripslashes( $form->form_email_from_name_override);
20
+ $form_email_to = ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) );
21
+ $form_success_type = stripslashes( $form->form_success_type );
22
+ $form_success_message = stripslashes( $form->form_success_message );
23
+ $form_notification_setting = stripslashes( $form->form_notification_setting );
24
+ $form_notification_email_name = stripslashes( $form->form_notification_email_name );
25
+ $form_notification_email_from = stripslashes( $form->form_notification_email_from );
26
+ $form_notification_email = stripslashes( $form->form_notification_email );
27
+ $form_notification_subject = stripslashes( $form->form_notification_subject );
28
+ $form_notification_message = stripslashes( $form->form_notification_message );
29
+ $form_notification_entry = stripslashes( $form->form_notification_entry );
30
+
31
+ $form_label_alignment = stripslashes( $form->form_label_alignment );
32
+
33
+ // Only show required text fields for the sender name override
34
+ $senders = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d AND field_type='text' AND field_validation = '' AND field_required = 'yes'", $form_nav_selected_id ) );
35
+
36
+ // Only show required email fields for the email override
37
+ $emails = $wpdb->get_results( "SELECT * FROM $this->field_table_name WHERE (form_id = $form_nav_selected_id AND field_type='text' AND field_validation = 'email' AND field_required = 'yes') OR (form_id = $form_nav_selected_id AND field_type='email' AND field_validation = 'email' AND field_required = 'yes')" );
38
+
39
+ endif;
40
+ }
41
+
42
+ $screen = get_current_screen();
43
+ $class = 'columns-' . get_current_screen()->get_columns();
44
+ ?>
45
+ <div id="vfb-form-builder-frame" class="metabox-holder <?php echo $class; ?>">
46
+ <div id="vfb-postbox-container-1" class='vfb-postbox-container'>
47
+ <form id="form-items" class="nav-menu-meta" method="post" action="">
48
+ <input name="action" type="hidden" value="create_field" />
49
+ <input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
50
+ <?php
51
+ wp_nonce_field( 'create-field-' . $form_nav_selected_id );
52
+ do_meta_boxes( 'toplevel_page_visual-form-builder', 'side', null );
53
+ ?>
54
+ </form>
55
+ </div> <!-- .vfb-postbox-container -->
56
+
57
+ <div id="vfb-postbox-container-2" class='vfb-postbox-container'>
58
+ <div id="vfb-form-builder-main">
59
+ <div id="vfb-form-builder-management">
60
+ <div class="form-edit">
61
+ <form method="post" id="visual-form-builder-update" action="">
62
+ <input name="action" type="hidden" value="<?php echo $action; ?>" />
63
+ <input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
64
+ <?php wp_nonce_field( "$action-$form_nav_selected_id" ); ?>
65
+ <div id="form-editor-header">
66
+ <div id="submitpost" class="submitbox">
67
+ <div class="vfb-major-publishing-actions">
68
+ <label for="form-name" class="menu-name-label howto open-label">
69
+ <span class="sender-labels"><?php _e( 'Form Name' , 'visual-form-builder'); ?></span>
70
+ <input type="text" value="<?php echo ( isset( $form_title ) ) ? $form_title : ''; ?>" placeholder="Enter form name here" class="menu-name regular-text menu-item-textbox required" id="form-name" name="form_title" />
71
+ </label>
72
+ <?php
73
+ // Display sender details and confirmation message if we're on a form, otherwise just the form name
74
+ if ( $form_nav_selected_id !== '0' ) :
75
+ ?>
76
+ <br class="clear" />
77
+
78
+ <?php
79
+ // Get the Form Setting drop down and accordion settings, if any
80
+ $user_form_settings = get_user_meta( $user_id, 'vfb-form-settings' );
81
+
82
+ // Setup defaults for the Form Setting tab and accordion
83
+ $settings_tab = 'closed';
84
+ $settings_accordion = 'general-settings';
85
+
86
+ // Loop through the user_meta array
87
+ foreach( $user_form_settings as $set ) {
88
+ // If form settings exist for this form, use them instead of the defaults
89
+ if ( isset( $set[ $form_id ] ) ) {
90
+ $settings_tab = $set[ $form_id ]['form_setting_tab'];
91
+ $settings_accordion = $set[ $form_id ]['setting_accordion'];
92
+ }
93
+ }
94
+
95
+ // If tab is opened, set current class
96
+ $opened_tab = ( $settings_tab == 'opened' ) ? 'current' : '';
97
+ ?>
98
+
99
+ <div class="button-group">
100
+ <a href="#form-settings" id="form-settings-button" class="vfb-button vfb-first <?php echo $opened_tab; ?>"><?php _e( 'Form Settings' , 'visual-form-builder'); ?><span class="button-icon arrow"></span></a>
101
+ <a href="<?php echo esc_url( wp_nonce_url( admin_url('options-general.php?page=visual-form-builder&amp;action=copy_form&amp;form=' . $form_nav_selected_id ), 'copy-form-' . $form_nav_selected_id ) ); ?>" class="vfb-button vfb-duplicate"><?php _e( 'Duplicate Form' , 'visual-form-builder'); ?><span class="button-icon plus"></span></a>
102
+ <a href="<?php echo esc_url( wp_nonce_url( admin_url('options-general.php?page=visual-form-builder&amp;action=delete_form&amp;form=' . $form_nav_selected_id ), 'delete-form-' . $form_nav_selected_id ) ); ?>" class="vfb-button vfb-delete vfb-last menu-delete"><?php _e( 'Delete Form' , 'visual-form-builder'); ?><span class="button-icon delete"></span></a>
103
+ </div>
104
+
105
+ <div id="form-settings" class="<?php echo $opened_tab; ?>">
106
+ <!-- General settings section -->
107
+ <a href="#general-settings" class="settings-links<?php echo ( $settings_accordion == 'general-settings' ) ? ' on' : ''; ?>">1. General<span class="arrow"></span></a>
108
+ <div id="general-settings" class="form-details<?php echo ( $settings_accordion == 'general-settings' ) ? ' on' : ''; ?>">
109
+ <!-- Label Alignment -->
110
+ <p class="description description-wide">
111
+ <label for="form-label-alignment">
112
+ <?php _e( 'Label Alignment' , 'visual-form-builder'); ?>
113
+ <span class="vfb-tooltip" title="About Label Alignment" rel="Set the field labels for this form to be aligned either on top, to the left, or to the right. By default, all labels are aligned on top of the inputs.">(?)</span>
114
+ <br />
115
+ </label>
116
+ <select name="form_label_alignment" id="form-label-alignment" class="widefat">
117
+ <option value="" <?php selected( $form_label_alignment, '' ); ?>><?php _e( 'Top Aligned' , 'visual-form-builder'); ?></option>
118
+ <option value="left-label" <?php selected( $form_label_alignment, 'left-label' ); ?>><?php _e( 'Left Aligned' , 'visual-form-builder'); ?></option>
119
+ <option value="right-label" <?php selected( $form_label_alignment, 'right-label' ); ?>><?php _e( 'Right Aligned' , 'visual-form-builder'); ?></option>
120
+ </select>
121
+ </p>
122
+ <br class="clear" />
123
+ </div> <!-- #general-settings -->
124
+
125
+
126
+ <!-- Email section -->
127
+ <a href="#email-details" class="settings-links<?php echo ( $settings_accordion == 'email-details' ) ? ' on' : ''; ?>">2. Email<span class="arrow"></span></a>
128
+ <div id="email-details" class="form-details<?php echo ( $settings_accordion == 'email-details' ) ? ' on' : ''; ?>">
129
+
130
+ <p><em><?php _e( 'The forms you build here will send information to one or more email addresses when submitted by a user on your site. Use the fields below to customize the details of that email.' , 'visual-form-builder'); ?></em></p>
131
+
132
+ <!-- E-mail Subject -->
133
+ <p class="description description-wide">
134
+ <label for="form-email-subject">
135
+ <?php _e( 'E-mail Subject' , 'visual-form-builder'); ?>
136
+ <span class="vfb-tooltip" title="About E-mail Subject" rel="This option sets the subject of the email that is sent to the emails you have set in the E-mail(s) To field.">(?)</span>
137
+ <br />
138
+ <input type="text" value="<?php echo stripslashes( $form_subject ); ?>" class="widefat" id="form-email-subject" name="form_email_subject" />
139
+ </label>
140
+ </p>
141
+ <br class="clear" />
142
+
143
+ <!-- Sender Name -->
144
+ <p class="description description-thin">
145
+ <label for="form-email-sender-name">
146
+ <?php _e( 'Your Name or Company' , 'visual-form-builder'); ?>
147
+ <span class="vfb-tooltip" title="About Your Name or Company" rel="This option sets the From display name of the email that is sent to the emails you have set in the E-mail(s) To field.">(?)</span>
148
+ <br />
149
+ <input type="text" value="<?php echo $form_email_from_name; ?>" class="widefat" id="form-email-sender-name" name="form_email_from_name"<?php echo ( $form_email_from_name_override != '' ) ? ' readonly="readonly"' : ''; ?> />
150
+ </label>
151
+ </p>
152
+ <p class="description description-thin">
153
+ <label for="form_email_from_name_override">
154
+ <?php _e( "User's Name (optional)" , 'visual-form-builder'); ?>
155
+ <span class="vfb-tooltip" title="About User's Name" rel="Select a required text field from your form to use as the From display name in the email.">(?)</span>
156
+ <br />
157
+ <select name="form_email_from_name_override" id="form_email_from_name_override" class="widefat">
158
+ <option value="" <?php selected( $form_email_from_name_override, '' ); ?>><?php _e( 'Select a required text field' , 'visual-form-builder'); ?></option>
159
+ <?php
160
+ foreach( $senders as $sender ) {
161
+ echo '<option value="' . $sender->field_id . '"' . selected( $form_email_from_name_override, $sender->field_id ) . '>' . stripslashes( $sender->field_name ) . '</option>';
162
+ }
163
+ ?>
164
+ </select>
165
+ </label>
166
+ </p>
167
+ <br class="clear" />
168
+
169
+ <!-- Sender E-mail -->
170
+ <p class="description description-thin">
171
+ <label for="form-email-sender">
172
+ <?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?>
173
+ <span class="vfb-tooltip" title="About Reply-To Email" rel="Manually set the email address that users will reply to.">(?)</span>
174
+ <br />
175
+ <input type="text" value="<?php echo $form_email_from; ?>" class="widefat" id="form-email-sender" name="form_email_from"<?php echo ( $form_email_from_override != '' ) ? ' readonly="readonly"' : ''; ?> />
176
+ </label>
177
+ </p>
178
+ <p class="description description-thin">
179
+ <label for="form_email_from_override">
180
+ <?php _e( "User's E-mail (optional)" , 'visual-form-builder'); ?>
181
+ <span class="vfb-tooltip" title="About User's Email" rel="Select a required email field from your form to use as the Reply-To email.">(?)</span>
182
+ <br />
183
+ <select name="form_email_from_override" id="form_email_from_override" class="widefat">
184
+ <option value="" <?php selected( $form_email_from_override, '' ); ?>><?php _e( 'Select a required email field' , 'visual-form-builder'); ?></option>
185
+ <?php
186
+ foreach( $emails as $email ) {
187
+ echo '<option value="' . $email->field_id . '"' . selected( $form_email_from_override, $email->field_id ) . '>' . stripslashes( $email->field_name ) . '</option>';
188
+ }
189
+ ?>
190
+ </select>
191
+ </label>
192
+ </p>
193
+ <br class="clear" />
194
+
195
+ <!-- E-mail(s) To -->
196
+ <?php
197
+ /* Basic count to keep track of multiple options */
198
+ $count = 1;
199
+
200
+ /* Loop through the options */
201
+ foreach ( $form_email_to as $email_to ) {
202
+ ?>
203
+ <div id="clone-email-<?php echo $count; ?>" class="option">
204
+ <p class="description description-wide">
205
+ <label for="form-email-to-<?php echo "$count"; ?>" class="clonedOption">
206
+ <?php _e( 'E-mail(s) To' , 'visual-form-builder'); ?>
207
+ <span class="vfb-tooltip" title="About E-mail(s) To" rel="This option sets single or multiple emails to send the submitted form data to. At least one email is required.">(?)</span>
208
+ <br />
209
+ <input type="text" value="<?php echo stripslashes( $email_to ); ?>" name="form_email_to[]" class="widefat" id="form-email-to-<?php echo "$count"; ?>" />
210
+ </label>
211
+
212
+ <a href="#" class="addEmail" title="Add an Email">Add</a> <a href="#" class="deleteEmail" title="Delete Email">Delete</a>
213
+
214
+ </p>
215
+ <br class="clear" />
216
+ </div>
217
+ <?php
218
+ $count++;
219
+ }
220
+ ?>
221
+ </div>
222
+
223
+ <!-- Confirmation section -->
224
+ <a href="#confirmation" class="settings-links<?php echo ( $settings_accordion == 'confirmation' ) ? ' on' : ''; ?>">3. Confirmation<span class="arrow"></span></a>
225
+ <div id="confirmation-message" class="form-details<?php echo ( $settings_accordion == 'confirmation' ) ? ' on' : ''; ?>">
226
+ <p><em><?php _e( "After someone submits a form, you can control what is displayed. By default, it's a message but you can send them to another WordPress Page or a custom URL." , 'visual-form-builder'); ?></em></p>
227
+ <label for="form-success-type-text" class="menu-name-label open-label">
228
+ <input type="radio" value="text" id="form-success-type-text" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'text' ); ?> />
229
+ <span><?php _e( 'Text' , 'visual-form-builder'); ?></span>
230
+ </label>
231
+ <label for="form-success-type-page" class="menu-name-label open-label">
232
+ <input type="radio" value="page" id="form-success-type-page" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'page' ); ?>/>
233
+ <span><?php _e( 'Page' , 'visual-form-builder'); ?></span>
234
+ </label>
235
+ <label for="form-success-type-redirect" class="menu-name-label open-label">
236
+ <input type="radio" value="redirect" id="form-success-type-redirect" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'redirect' ); ?>/>
237
+ <span><?php _e( 'Redirect' , 'visual-form-builder'); ?></span>
238
+ </label>
239
+ <br class="clear" />
240
+ <p class="description description-wide">
241
+ <?php
242
+ $default_text = '';
243
+
244
+ /* If there's no text message, make sure there is something displayed by setting a default */
245
+ if ( $form_success_message === '' )
246
+ $default_text = sprintf( '<p id="form_success">%s</p>', __( 'Your form was successfully submitted. Thank you for contacting us.' , 'visual-form-builder') );
247
+ ?>
248
+ <textarea id="form-success-message-text" class="form-success-message<?php echo ( 'text' == $form_success_type ) ? ' active' : ''; ?>" name="form_success_message_text"><?php echo $default_text; ?><?php echo ( 'text' == $form_success_type ) ? $form_success_message : ''; ?></textarea>
249
+
250
+ <?php
251
+ /* Display all Pages */
252
+ wp_dropdown_pages( array(
253
+ 'name' => 'form_success_message_page',
254
+ 'id' => 'form-success-message-page',
255
+ 'class' => 'widefat',
256
+ 'show_option_none' => __( 'Select a Page' , 'visual-form-builder'),
257
+ 'selected' => $form_success_message
258
+ ));
259
+ ?>
260
+ <input type="text" value="<?php echo ( 'redirect' == $form_success_type ) ? $form_success_message : ''; ?>" id="form-success-message-redirect" class="form-success-message regular-text<?php echo ( 'redirect' == $form_success_type ) ? ' active' : ''; ?>" name="form_success_message_redirect" placeholder="http://" />
261
+ </p>
262
+ <br class="clear" />
263
+
264
+ </div>
265
+
266
+ <!-- Notification section -->
267
+ <a href="#notification" class="settings-links<?php echo ( $settings_accordion == 'notification' ) ? ' on' : ''; ?>">4. Notification<span class="arrow"></span></a>
268
+ <div id="notification" class="form-details<?php echo ( $settings_accordion == 'notification' ) ? ' on' : ''; ?>">
269
+ <p><em><?php _e( "When a user submits their entry, you can send a customizable notification email." , 'visual-form-builder'); ?></em></p>
270
+ <label for="form-notification-setting">
271
+ <input type="checkbox" value="1" id="form-notification-setting" class="form-notification" name="form_notification_setting" <?php checked( $form_notification_setting, '1' ); ?> style="margin-top:-1px;margin-left:0;"/>
272
+ <?php _e( 'Send Confirmation Email to User' , 'visual-form-builder'); ?>
273
+ </label>
274
+ <br class="clear" />
275
+ <div id="notification-email">
276
+ <p class="description description-wide">
277
+ <label for="form-notification-email-name">
278
+ <?php _e( 'Sender Name or Company' , 'visual-form-builder'); ?>
279
+ <span class="vfb-tooltip" title="About Sender Name or Company" rel="Enter the name you would like to use for the email notification.">(?)</span>
280
+ <br />
281
+ <input type="text" value="<?php echo $form_notification_email_name; ?>" class="widefat" id="form-notification-email-name" name="form_notification_email_name" />
282
+ </label>
283
+ </p>
284
+ <br class="clear" />
285
+ <p class="description description-wide">
286
+ <label for="form-notification-email-from">
287
+ <?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?>
288
+ <span class="vfb-tooltip" title="About Reply-To Email" rel="Manually set the email address that users will reply to.">(?)</span>
289
+ <br />
290
+ <input type="text" value="<?php echo $form_notification_email_from; ?>" class="widefat" id="form-notification-email-from" name="form_notification_email_from" />
291
+ </label>
292
+ </p>
293
+ <br class="clear" />
294
+ <p class="description description-wide">
295
+ <label for="form-notification-email">
296
+ <?php _e( 'E-mail To' , 'visual-form-builder'); ?>
297
+ <span class="vfb-tooltip" title="About E-mail To" rel="Select a required email field from your form to send the notification email to.">(?)</span>
298
+ <br />
299
+ <select name="form_notification_email" id="form-notification-email" class="widefat">
300
+ <option value="" <?php selected( $form_notification_email, '' ); ?>><?php _e( 'Select a required email field' , 'visual-form-builder'); ?></option>
301
+ <?php
302
+ foreach( $emails as $email ) {
303
+ echo '<option value="' . $email->field_id . '"' . selected( $form_notification_email, $email->field_id ) . '>' . $email->field_name . '</option>';
304
+ }
305
+ ?>
306
+ </select>
307
+ </label>
308
+ </p>
309
+ <br class="clear" />
310
+ <p class="description description-wide">
311
+ <label for="form-notification-subject">
312
+ <?php _e( 'E-mail Subject' , 'visual-form-builder'); ?>
313
+ <span class="vfb-tooltip" title="About E-mail Subject" rel="This option sets the subject of the email that is sent to the emails you have set in the E-mail To field.">(?)</span>
314
+ <br />
315
+ <input type="text" value="<?php echo $form_notification_subject; ?>" class="widefat" id="form-notification-subject" name="form_notification_subject" />
316
+ </label>
317
+ </p>
318
+ <br class="clear" />
319
+ <p class="description description-wide">
320
+ <label for="form-notification-message"><?php _e( 'Message' , 'visual-form-builder'); ?></label>
321
+ <span class="vfb-tooltip" title="About Message" rel="Insert a message to the user. This will be inserted into the beginning of the email body.">(?)</span>
322
+ <br />
323
+ <textarea id="form-notification-message" class="form-notification-message widefat" name="form_notification_message"><?php echo $form_notification_message; ?></textarea>
324
+ </p>
325
+ <br class="clear" />
326
+ <label for="form-notification-entry">
327
+ <input type="checkbox" value="1" id="form-notification-entry" class="form-notification" name="form_notification_entry" <?php checked( $form_notification_entry, '1' ); ?> style="margin-top:-1px;margin-left:0;"/>
328
+ <?php _e( "Include a Copy of the User's Entry" , 'visual-form-builder'); ?>
329
+ </label>
330
+ <br class="clear" />
331
+ </div>
332
+ </div>
333
+ </div>
334
+ <?php endif; ?>
335
+
336
+ <div class="publishing-action">
337
+ <?php if ( current_user_can( 'vfb_create_forms' ) ) : ?>
338
+ <input type="submit" value="Save Form" class="button-primary menu-save" id="save_form" name="save_form" />
339
+ <?php elseif ( $form_nav_selected_id !== '0' && !current_user_can( 'vfb_create_forms' ) && current_user_can( 'vfb_edit_forms' ) ) : ?>
340
+ <input type="submit" value="<?php echo __( 'Save Form' , 'visual-form-builder'); ?>" class="button-primary menu-save" id="save_form" name="save_form" />
341
+ <?php endif; ?>
342
+ </div>
343
+ </div>
344
+ </div>
345
+ </div>
346
+ <div id="post-body">
347
+ <div id="post-body-content">
348
+ <?php
349
+ if ( !empty( $form_nav_selected_id ) && $form_nav_selected_id !== '0' ) :
350
+ // Display help text for adding fields
351
+ printf( '<p>%s</p>', __( 'Note: to ensure your form displays and functions correctly, be sure a Fieldset is the first field.' , 'visual-form-builder') );
352
+
353
+ // Output the fields for each form
354
+ echo '<ul id="menu-to-edit" class="menu ui-sortable droppable">';
355
+
356
+ echo $this->field_output( $form_nav_selected_id );
357
+
358
+ echo '</ul>';
359
+
360
+ endif;
361
+ ?>
362
+ </div>
363
+ <br class="clear" />
364
+ </div>
365
+ <br class="clear" />
366
+ <div id="form-editor-footer">
367
+ <div class="vfb-major-publishing-actions">
368
+ <div class="publishing-action">
369
+ <input type="submit" value="Save Form" class="button-primary menu-save" id="save_form" name="save_form" />
370
+ </div> <!-- .publishing-action -->
371
+ </div> <!-- .vfb-major-publishing-actions -->
372
+ </div> <!-- #form-editor-footer -->
373
+ </form>
374
+ </div> <!-- .form-edit -->
375
+ </div> <!-- #vfb-form-builder-management -->
376
+ </div> <!-- vfb-form-builder-main -->
377
+ </div> <!-- .vfb-postbox-container -->
378
+ </div> <!-- #vfb-form-builder-frame -->
379
+ <?php
380
+ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
381
+ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
382
+ ?>
includes/admin-new-form.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form method="post" id="visual-form-builder-new-form" action="">
2
+ <input name="action" type="hidden" value="create_form" />
3
+ <?php wp_nonce_field( "create_form" ); ?>
4
+ <?php if ( current_user_can( 'manage_options' ) ) : ?>
5
+ <h3>Create a form</h3>
6
+
7
+ <table class="form-table">
8
+ <tbody>
9
+ <tr valign="top">
10
+ <th scope="row"><label for="form-name"><?php _e( 'Name the form' , 'visual-form-builder'); ?></label></th>
11
+ <td>
12
+ <input type="text" value="Enter form name here" placeholder="Enter form name here" autofocus="autofocus" onfocus="this.select();" class="regular-text required" id="form-name" name="form_title" />
13
+ <p class="description">Required. This name is used for admin purposes.</p>
14
+ </td>
15
+ </tr>
16
+ <tr valign="top">
17
+ <th scope="row"><label for="form-email-sender-name"><?php _e( 'Your Name or Company' , 'visual-form-builder'); ?></label></th>
18
+ <td>
19
+ <input type="text" value="" placeholder="" class="regular-text" id="form-email-sender-name" name="form_email_from_name" />
20
+ <p class="description">Optional - you can change this later</p>
21
+ </td>
22
+ </tr>
23
+ <tr valign="top">
24
+ <th scope="row"><label for="form-email-subject"><?php _e( 'E-mail Subject' , 'visual-form-builder'); ?></label></th>
25
+ <td>
26
+ <input type="text" value="" placeholder="" class="regular-text" id="form-email-subject" name="form_email_subject" />
27
+ <p class="description">Optional - you can change this later</p>
28
+ </td>
29
+ </tr>
30
+ <tr valign="top">
31
+ <th scope="row"><label for="form-email-from"><?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?></label></th>
32
+ <td>
33
+ <input type="text" value="" placeholder="" class="regular-text" id="form-email-from" name="form_email_from" />
34
+ <p class="description">Optional - you can change this later</p>
35
+ </td>
36
+ </tr>
37
+ <tr valign="top">
38
+ <th scope="row"><label for="form-email-to"><?php _e( 'E-mail To' , 'visual-form-builder'); ?></label></th>
39
+ <td>
40
+ <input type="text" value="" placeholder="" class="regular-text" id="form-email-to" name="form_email_to[]" />
41
+ <p class="description">Optional - you can change this later</p>
42
+ </td>
43
+ </tr>
44
+ </tbody>
45
+ </table>
46
+ <?php
47
+ submit_button( __( 'Create Form', 'visual-form-builder' ) );
48
+ endif;
49
+ ?>
50
+ </form>
class-entries-detail.php → includes/class-entries-detail.php RENAMED
@@ -8,10 +8,10 @@ class VisualFormBuilder_Entries_Detail{
8
  public function __construct(){
9
  global $wpdb;
10
 
11
- /* Setup global database table names */
12
- $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
13
- $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
14
- $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
15
 
16
  add_action( 'admin_init', array( &$this, 'entries_detail' ) );
17
  }
@@ -21,22 +21,21 @@ class VisualFormBuilder_Entries_Detail{
21
 
22
  $entry_id = absint( $_REQUEST['entry'] );
23
 
24
- $query = "SELECT forms.form_title, entries.* FROM $this->form_table_name AS forms INNER JOIN $this->entries_table_name AS entries ON entries.form_id = forms.form_id WHERE entries.entries_id = $entry_id;";
25
 
26
- $entries = $wpdb->get_results( $query );
27
 
28
- echo '<p>' . sprintf( '<a href="?page=%s&view=%s" class="view-entry">&laquo; Back to Entries</a>', $_REQUEST['page'], $_REQUEST['view'] ) . '</p>';
29
-
30
- /* Get the date/time format that is saved in the options table */
31
  $date_format = get_option('date_format');
32
  $time_format = get_option('time_format');
33
 
34
- /* Loop trough the entries and setup the data to be displayed for each row */
35
  foreach ( $entries as $entry ) {
36
  $data = unserialize( $entry->data );
37
  ?>
38
- <h3><span><?php echo stripslashes( $entry->form_title ); ?> : <?php echo __( 'Entry' , 'visual-form-builder'); ?> # <?php echo $entry->entries_id; ?></span></h3>
39
- <div id="poststuff" class="metabox-holder has-right-sidebar">
 
40
  <div id="side-info-column" class="inner-sidebar">
41
  <div id="side-sortables">
42
  <div id="submitdiv" class="postbox">
@@ -63,25 +62,26 @@ class VisualFormBuilder_Entries_Detail{
63
  <div class="misc-pub-section">
64
  <span><strong><?php echo __( 'Sender Email' , 'visual-form-builder'); ?>: </strong><a href="mailto:<?php echo stripslashes( $entry->sender_email ); ?>"><?php echo stripslashes( $entry->sender_email ); ?></a></span>
65
  </div>
66
- <div class="misc-pub-section misc-pub-section-last">
67
  <span><strong><?php echo __( 'Emailed To' , 'visual-form-builder'); ?>: </strong><?php echo preg_replace('/\b([A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4})\b/i', '<a href="mailto:$1">$1</a>', implode( ',', unserialize( stripslashes( $entry->emails_to ) ) ) ); ?></span>
68
  </div>
69
  <div class="clear"></div>
70
- </div>
71
- </div>
72
 
73
  <div id="major-publishing-actions">
74
- <div id="delete-action"><?php echo sprintf( '<a class="submitdelete deletion entry-delete" href="?page=%s&view=%s&action=%s&entry=%s">Delete</a>', $_REQUEST['page'], $_REQUEST['view'], 'delete', $entry_id ); ?></div>
75
  <div class="clear"></div>
76
- </div>
77
- </div>
78
- </div>
79
- </div>
80
- </div>
81
- </div>
82
- <div id="vfb-entries-body-content">
 
83
  <?php
84
- $count = 0;
85
  $open_fieldset = $open_section = false;
86
 
87
  foreach ( $data as $k => $v ) {
@@ -94,58 +94,42 @@ class VisualFormBuilder_Entries_Detail{
94
 
95
  echo '<h4>' . ucwords( $k ) . '</h4>';
96
  echo $v;
97
- //echo '</div></div>';
98
  $count++;
99
  }
100
  else {
101
- /* Cast each array as an object */
102
  $obj = (object) $v;
103
-
104
- /* Close each section */
105
- if ( $open_section == true ) {
106
- /* If this field's parent does NOT equal our section ID */
107
- if ( $sec_id && $sec_id !== $obj->parent_id ) {
108
- echo '</div>';
109
- $open_section = false;
110
- }
111
- }
112
 
113
  if ( $obj->type == 'fieldset' ) {
114
- /* Close each fieldset */
115
  if ( $open_fieldset == true )
116
- echo '</div>';
117
-
118
- echo '<div class="vfb-details"><h2>' . $obj->name . '</h2>';
119
-
120
- $open_fieldset = true;
121
- }
122
- elseif ( $obj->type == 'section' ) {
123
- /* Close each fieldset */
124
- if ( $open_section == true )
125
- echo '</div>';
126
 
127
- echo '<div class="vfb-details section"><h3 class="section-heading">' . $obj->name . '</h3>';
128
 
129
- /* Save section ID for future comparison */
130
- $sec_id = $obj->id;
131
- $open_section = true;
132
  }
133
 
 
134
  switch ( $obj->type ) {
135
  case 'fieldset' :
136
  case 'section' :
137
  case 'submit' :
 
138
  case 'verification' :
139
  case 'secret' :
 
140
  break;
141
 
142
  default :
143
- echo '<div class="postbox">
144
- <h3><span>' . $obj->name . '</span></h3>
145
- <div class="inside">' .
146
- $obj->value .
147
- '</div></div>';
 
148
  break;
 
149
  }
150
  }
151
  }
@@ -153,10 +137,12 @@ class VisualFormBuilder_Entries_Detail{
153
  if ( $count > 0 )
154
  echo '</div></div>';
155
 
156
- echo '</div></div></div>';
157
  }
158
-
159
  echo '<br class="clear"></div>';
 
 
 
160
  }
161
  }
162
  ?>
8
  public function __construct(){
9
  global $wpdb;
10
 
11
+ // Setup global database table names
12
+ $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
13
+ $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
14
+ $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
15
 
16
  add_action( 'admin_init', array( &$this, 'entries_detail' ) );
17
  }
21
 
22
  $entry_id = absint( $_REQUEST['entry'] );
23
 
24
+ $entries = $wpdb->get_results( $wpdb->prepare( "SELECT forms.form_title, entries.* FROM $this->form_table_name AS forms INNER JOIN $this->entries_table_name AS entries ON entries.form_id = forms.form_id WHERE entries.entries_id = %d", $entry_id ) );
25
 
26
+ echo '<p>' . sprintf( '<a href="?page=%s" class="view-entry">&laquo; Back to Entries</a>', $_REQUEST['page'] ) . '</p>';
27
 
28
+ // Get the date/time format that is saved in the options table
 
 
29
  $date_format = get_option('date_format');
30
  $time_format = get_option('time_format');
31
 
32
+ // Loop trough the entries and setup the data to be displayed for each row
33
  foreach ( $entries as $entry ) {
34
  $data = unserialize( $entry->data );
35
  ?>
36
+ <form id="entry-edit" method="post" action="">
37
+ <h3><span><?php echo stripslashes( $entry->form_title ); ?> : <?php echo __( 'Entry' , 'visual-form-builder'); ?> # <?php echo $entry->entries_id; ?></span></h3>
38
+ <div id="vfb-poststuff" class="metabox-holder has-right-sidebar">
39
  <div id="side-info-column" class="inner-sidebar">
40
  <div id="side-sortables">
41
  <div id="submitdiv" class="postbox">
62
  <div class="misc-pub-section">
63
  <span><strong><?php echo __( 'Sender Email' , 'visual-form-builder'); ?>: </strong><a href="mailto:<?php echo stripslashes( $entry->sender_email ); ?>"><?php echo stripslashes( $entry->sender_email ); ?></a></span>
64
  </div>
65
+ <div class="misc-pub-section">
66
  <span><strong><?php echo __( 'Emailed To' , 'visual-form-builder'); ?>: </strong><?php echo preg_replace('/\b([A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4})\b/i', '<a href="mailto:$1">$1</a>', implode( ',', unserialize( stripslashes( $entry->emails_to ) ) ) ); ?></span>
67
  </div>
68
  <div class="clear"></div>
69
+ </div> <!--#misc-publishing-actions -->
70
+ </div> <!-- #minor-publishing -->
71
 
72
  <div id="major-publishing-actions">
73
+ <div id="delete-action"><?php echo sprintf( '<a class="submitdelete deletion entry-delete" href="?page=%s&action=%s&entry=%s">Delete</a>', $_REQUEST['page'], 'delete', $entry_id ); ?></div>
74
  <div class="clear"></div>
75
+ </div> <!-- #major-publishing-actions -->
76
+ </div> <!-- #submitbox -->
77
+ </div> <!-- .inside -->
78
+ </div> <!-- #submitdiv -->
79
+ </div> <!-- #side-sortables -->
80
+ </div> <!-- #side-info-column -->
81
+ <!--</div> #poststuff -->
82
+ <div id="vfb-entries-body-content">
83
  <?php
84
+ $count = 0;
85
  $open_fieldset = $open_section = false;
86
 
87
  foreach ( $data as $k => $v ) {
94
 
95
  echo '<h4>' . ucwords( $k ) . '</h4>';
96
  echo $v;
 
97
  $count++;
98
  }
99
  else {
100
+ // Cast each array as an object
101
  $obj = (object) $v;
 
 
 
 
 
 
 
 
 
102
 
103
  if ( $obj->type == 'fieldset' ) {
104
+ // Close each fieldset
105
  if ( $open_fieldset == true )
106
+ echo '</table>';
 
 
 
 
 
 
 
 
 
107
 
108
+ echo '<h3>' . stripslashes( $obj->name ) . '</h3><table class="form-table">';
109
 
110
+ $open_fieldset = true;
 
 
111
  }
112
 
113
+
114
  switch ( $obj->type ) {
115
  case 'fieldset' :
116
  case 'section' :
117
  case 'submit' :
118
+ case 'page-break' :
119
  case 'verification' :
120
  case 'secret' :
121
+
122
  break;
123
 
124
  default :
125
+ ?>
126
+ <tr valign="top">
127
+ <th scope="row"><label for="field[<?php echo $obj->id; ?>]"><?php echo stripslashes( $obj->name ); ?></label></th>
128
+ <td style="background:#eee;border:1px solid #ddd"><?php echo stripslashes( esc_attr( $obj->value ) ); ?></td>
129
+ </tr>
130
+ <?php
131
  break;
132
+
133
  }
134
  }
135
  }
137
  if ( $count > 0 )
138
  echo '</div></div>';
139
 
 
140
  }
141
+ echo '</table></div>';
142
  echo '<br class="clear"></div>';
143
+
144
+
145
+ echo '</form>';
146
  }
147
  }
148
  ?>
class-entries-list.php → includes/class-entries-list.php RENAMED
@@ -15,19 +15,19 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
15
  function __construct(){
16
  global $status, $page, $wpdb;
17
 
18
- /* Setup global database table names */
19
  $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
20
  $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
21
  $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
22
 
23
- /* Set parent defaults */
24
  parent::__construct( array(
25
  'singular' => 'entry',
26
  'plural' => 'entries',
27
  'ajax' => false
28
  ) );
29
 
30
- /* Handle our bulk actions */
31
  $this->process_bulk_action();
32
  }
33
 
@@ -56,10 +56,10 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
56
  */
57
  function column_form( $item ){
58
 
59
- /* Build row actions */
60
  $actions = array(
61
- 'view' => sprintf( '<a href="?page=%s&view=%s&action=%s&entry=%s" id="%4$s" class="view-entry">View</a>', $_REQUEST['page'], $_REQUEST['view'], 'view', $item['entry_id'] ),
62
- 'delete' => sprintf( '<a href="?page=%s&view=%s&action=%s&entry=%s">Delete</a>', $_REQUEST['page'], $_REQUEST['view'], 'delete', $item['entry_id'] ),
63
  );
64
 
65
  return sprintf( '%1$s %2$s', $item['form'], $this->row_actions( $actions ) );
@@ -103,7 +103,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
103
  function get_entries( $orderby = 'date', $order = 'ASC', $per_page, $offset = 0, $search = '' ){
104
  global $wpdb;
105
 
106
- /* Set OFFSET for pagination */
107
  $offset = ( $offset > 0 ) ? "OFFSET $offset" : '';
108
 
109
  switch ( $orderby ) {
@@ -123,17 +123,17 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
123
 
124
  $where = '';
125
 
126
- /* If the form filter dropdown is used */
127
  if ( $this->current_filter_action() )
128
  $where .= 'AND forms.form_id = ' . $this->current_filter_action();
129
 
130
- /* Get the month and year from the dropdown */
131
  $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
132
 
133
- /* If a month/year has been selected, parse out the month/year and build the clause */
134
  if ( $m > 0 ) {
135
- $year = substr( $m, 0, 4 );
136
- $month = substr( $m, -2 );
137
 
138
  $where .= " AND YEAR(date_submitted) = $year AND MONTH(date_submitted) = $month";
139
  }
@@ -387,7 +387,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
387
 
388
  $cols = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT forms.form_title, forms.form_id FROM $this->form_table_name AS forms ORDER BY forms.form_title ASC" ) );
389
 
390
- /* Only display the dropdown on the top of the table */
391
  if ( 'top' == $which ) {
392
  echo '<div class="alignleft actions">';
393
  $this->months_dropdown();
@@ -477,36 +477,36 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
477
  function prepare_items() {
478
  global $wpdb;
479
 
480
- /* Get screen options from the wp_options table */
481
  $options = get_option( 'visual-form-builder-screen-options' );
482
 
483
- /* Get the date/time format that is saved in the options table */
484
  $date_format = get_option('date_format');
485
  $time_format = get_option('time_format');
486
 
487
- /* How many to show per page */
488
  $per_page = $options['per_page'];
489
 
490
- /* What page are we looking at? */
491
  $current_page = $this->get_pagenum();
492
 
493
- /* Use offset for pagination */
494
  $offset = ( $current_page - 1 ) * $per_page;
495
 
496
- /* Get column headers */
497
  $columns = $this->get_columns();
498
  $hidden = array();
499
 
500
- /* Get sortable columns */
501
  $sortable = $this->get_sortable_columns();
502
 
503
- /* Build the column headers */
504
  $this->_column_headers = array($columns, $hidden, $sortable);
505
 
506
- /* Get entries search terms */
507
  $search_terms = ( !empty( $_REQUEST['s'] ) ) ? explode( ' ', $_REQUEST['s'] ) : array();
508
 
509
- /* Loop through search terms and build query */
510
  foreach( $search_terms as $term ) {
511
  $term = esc_sql( like_escape( $term ) );
512
 
@@ -516,16 +516,16 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
516
 
517
  $search = ( !empty($search) ) ? " AND ({$search}) " : '';
518
 
519
- /* Set our ORDER BY and ASC/DESC to sort the entries */
520
  $orderby = ( !empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'date';
521
  $order = ( !empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'desc';
522
 
523
- /* Get the sorted entries */
524
  $entries = $this->get_entries( $orderby, $order, $per_page, $offset, $search );
525
 
526
  $data = array();
527
 
528
- /* Loop trough the entries and setup the data to be displayed for each row */
529
  foreach ( $entries as $entry ) {
530
  $data[] =
531
  array(
@@ -542,14 +542,14 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
542
 
543
  $where = '';
544
 
545
- /* If the form filter dropdown is used */
546
  if ( $this->current_filter_action() )
547
  $where .= 'AND form_id = ' . $this->current_filter_action();
548
 
549
- /* Get the month/year from the dropdown */
550
  $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
551
 
552
- /* Parse month/year and build the clause */
553
  if ( $m > 0 ) {
554
  $year = substr( $m, 0, 4 );
555
  $month = substr( $m, -2 );
@@ -557,13 +557,13 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
557
  $where .= " AND YEAR(date_submitted) = $year AND MONTH(date_submitted) = $month";
558
  }
559
 
560
- /* How many entries do we have? */
561
  $total_items = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $this->entries_table_name WHERE 1=1 $where" ) );
562
 
563
- /* Add sorted data to the items property */
564
  $this->items = $data;
565
 
566
- /* Register our pagination */
567
  $this->set_pagination_args( array(
568
  'total_items' => $total_items,
569
  'per_page' => $per_page,
@@ -594,7 +594,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
594
 
595
  $page_links = array();
596
 
597
- /* Added to pick up the months dropdown */
598
  $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
599
 
600
  $disable_first = $disable_last = '';
@@ -610,7 +610,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
610
  '&laquo;'
611
  );
612
 
613
- /* Modified the add_query_args to include my custom dropdowns */
614
  $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
615
  'prev-page' . $disable_first,
616
  esc_attr__( 'Go to the previous page' ),
@@ -637,7 +637,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
637
  '&rsaquo;'
638
  );
639
 
640
- /* Modified the add_query_args to include my custom dropdowns */
641
  $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
642
  'last-page' . $disable_last,
643
  esc_attr__( 'Go to the last page' ),
15
  function __construct(){
16
  global $status, $page, $wpdb;
17
 
18
+ // Setup global database table names
19
  $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
20
  $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
21
  $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
22
 
23
+ // Set parent defaults
24
  parent::__construct( array(
25
  'singular' => 'entry',
26
  'plural' => 'entries',
27
  'ajax' => false
28
  ) );
29
 
30
+ // Handle our bulk actions
31
  $this->process_bulk_action();
32
  }
33
 
56
  */
57
  function column_form( $item ){
58
 
59
+ // Build row actions
60
  $actions = array(
61
+ 'view' => sprintf( '<a href="?page=%s&action=%s&entry=%s" id="%3$s" class="view-entry">View</a>', $_REQUEST['page'], 'view', $item['entry_id'] ),
62
+ 'delete' => sprintf( '<a href="?page=%s&action=%s&entry=%s">Delete</a>', $_REQUEST['page'], 'delete', $item['entry_id'] ),
63
  );
64
 
65
  return sprintf( '%1$s %2$s', $item['form'], $this->row_actions( $actions ) );
103
  function get_entries( $orderby = 'date', $order = 'ASC', $per_page, $offset = 0, $search = '' ){
104
  global $wpdb;
105
 
106
+ // Set OFFSET for pagination
107
  $offset = ( $offset > 0 ) ? "OFFSET $offset" : '';
108
 
109
  switch ( $orderby ) {
123
 
124
  $where = '';
125
 
126
+ // If the form filter dropdown is used
127
  if ( $this->current_filter_action() )
128
  $where .= 'AND forms.form_id = ' . $this->current_filter_action();
129
 
130
+ // Get the month and year from the dropdown
131
  $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
132
 
133
+ // If a month/year has been selected, parse out the month/year and build the clause
134
  if ( $m > 0 ) {
135
+ $year = substr( $m, 0, 4 );
136
+ $month = substr( $m, -2 );
137
 
138
  $where .= " AND YEAR(date_submitted) = $year AND MONTH(date_submitted) = $month";
139
  }
387
 
388
  $cols = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT forms.form_title, forms.form_id FROM $this->form_table_name AS forms ORDER BY forms.form_title ASC" ) );
389
 
390
+ // Only display the dropdown on the top of the table
391
  if ( 'top' == $which ) {
392
  echo '<div class="alignleft actions">';
393
  $this->months_dropdown();
477
  function prepare_items() {
478
  global $wpdb;
479
 
480
+ // Get screen options from the wp_options table
481
  $options = get_option( 'visual-form-builder-screen-options' );
482
 
483
+ // Get the date/time format that is saved in the options table
484
  $date_format = get_option('date_format');
485
  $time_format = get_option('time_format');
486
 
487
+ // How many to show per page
488
  $per_page = $options['per_page'];
489
 
490
+ // What page are we looking at?
491
  $current_page = $this->get_pagenum();
492
 
493
+ // Use offset for pagination
494
  $offset = ( $current_page - 1 ) * $per_page;
495
 
496
+ // Get column headers
497
  $columns = $this->get_columns();
498
  $hidden = array();
499
 
500
+ // Get sortable columns
501
  $sortable = $this->get_sortable_columns();
502
 
503
+ // Build the column headers
504
  $this->_column_headers = array($columns, $hidden, $sortable);
505
 
506
+ // Get entries search terms
507
  $search_terms = ( !empty( $_REQUEST['s'] ) ) ? explode( ' ', $_REQUEST['s'] ) : array();
508
 
509
+ // Loop through search terms and build query
510
  foreach( $search_terms as $term ) {
511
  $term = esc_sql( like_escape( $term ) );
512
 
516
 
517
  $search = ( !empty($search) ) ? " AND ({$search}) " : '';
518
 
519
+ // Set our ORDER BY and ASC/DESC to sort the entries
520
  $orderby = ( !empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'date';
521
  $order = ( !empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'desc';
522
 
523
+ // Get the sorted entries
524
  $entries = $this->get_entries( $orderby, $order, $per_page, $offset, $search );
525
 
526
  $data = array();
527
 
528
+ // Loop trough the entries and setup the data to be displayed for each row
529
  foreach ( $entries as $entry ) {
530
  $data[] =
531
  array(
542
 
543
  $where = '';
544
 
545
+ // If the form filter dropdown is used
546
  if ( $this->current_filter_action() )
547
  $where .= 'AND form_id = ' . $this->current_filter_action();
548
 
549
+ // Get the month/year from the dropdown
550
  $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
551
 
552
+ // Parse month/year and build the clause
553
  if ( $m > 0 ) {
554
  $year = substr( $m, 0, 4 );
555
  $month = substr( $m, -2 );
557
  $where .= " AND YEAR(date_submitted) = $year AND MONTH(date_submitted) = $month";
558
  }
559
 
560
+ // How many entries do we have?
561
  $total_items = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $this->entries_table_name WHERE 1=1 $where" ) );
562
 
563
+ // Add sorted data to the items property
564
  $this->items = $data;
565
 
566
+ // Register our pagination
567
  $this->set_pagination_args( array(
568
  'total_items' => $total_items,
569
  'per_page' => $per_page,
594
 
595
  $page_links = array();
596
 
597
+ // Added to pick up the months dropdown
598
  $m = isset( $_REQUEST['m'] ) ? (int) $_REQUEST['m'] : 0;
599
 
600
  $disable_first = $disable_last = '';
610
  '&laquo;'
611
  );
612
 
613
+ // Modified the add_query_args to include my custom dropdowns
614
  $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
615
  'prev-page' . $disable_first,
616
  esc_attr__( 'Go to the previous page' ),
637
  '&rsaquo;'
638
  );
639
 
640
+ // Modified the add_query_args to include my custom dropdowns
641
  $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
642
  'last-page' . $disable_last,
643
  esc_attr__( 'Go to the last page' ),
class-export.php → includes/class-export.php RENAMED
@@ -6,15 +6,13 @@
6
  */
7
  class VisualFormBuilder_Export {
8
 
9
- protected $export_version = 2.5;
10
-
11
  public function __construct(){
12
  global $wpdb;
13
 
14
  // Setup global database table names
15
- $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
16
- $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
17
- $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
18
 
19
  add_action( 'admin_init', array( &$this, 'display' ) );
20
 
@@ -41,21 +39,21 @@ class VisualFormBuilder_Export {
41
  <p>Once you've saved the file, you will be able to import Visual Form Builder data from this site into another site.</p>
42
  <h3>Choose what to export</h3>
43
 
44
- <p><label><input type="radio" name="content" value="all" disabled="disabled" /> <?php _e( 'All data', 'visual-form-builder-pro' ); ?></label></p>
45
  <p class="description">This will contain all of your forms, fields, entries, and email design settings.<br><strong>*Only available in Visual Form Builder Pro*</strong></p>
46
 
47
- <p><label><input type="radio" name="content" value="forms" disabled="disabled" /> <?php _e( 'Forms', 'visual-form-builder-pro' ); ?></label></p>
48
  <p class="description">This will contain all of your forms, fields, and email design settings.<br><strong>*Only available in Visual Form Builder Pro*</strong></p>
49
 
50
- <p><label><input type="radio" name="content" value="entries" checked="checked" /> <?php _e( 'Entries', 'visual-form-builder-pro' ); ?></label></p>
51
 
52
  <ul id="entries-filters" class="vfb-export-filters">
53
  <li><p class="description">This will export entries in either a .csv or .xls and cannot be used with the Import. If you need to import entries on another site, please use the All data option above.</p></li>
54
  <li>
55
  <label for="format">Format:</label>
56
  <select name="format">
57
- <option value="csv" selected="selected"><?php _e( 'Comma Separated (.csv)', 'visual-form-builder-pro' ); ?></option>
58
- <option value="xls" disabled="disabled"><?php _e( 'Excel (.xls) - Pro only', 'visual-form-builder-pro' ); ?></option>
59
  </select>
60
  </li>
61
  <li>
6
  */
7
  class VisualFormBuilder_Export {
8
 
 
 
9
  public function __construct(){
10
  global $wpdb;
11
 
12
  // Setup global database table names
13
+ $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
14
+ $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
15
+ $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
16
 
17
  add_action( 'admin_init', array( &$this, 'display' ) );
18
 
39
  <p>Once you've saved the file, you will be able to import Visual Form Builder data from this site into another site.</p>
40
  <h3>Choose what to export</h3>
41
 
42
+ <p><label><input type="radio" name="content" value="all" disabled="disabled" /> <?php _e( 'All data', 'visual-form-builder' ); ?></label></p>
43
  <p class="description">This will contain all of your forms, fields, entries, and email design settings.<br><strong>*Only available in Visual Form Builder Pro*</strong></p>
44
 
45
+ <p><label><input type="radio" name="content" value="forms" disabled="disabled" /> <?php _e( 'Forms', 'visual-form-builder' ); ?></label></p>
46
  <p class="description">This will contain all of your forms, fields, and email design settings.<br><strong>*Only available in Visual Form Builder Pro*</strong></p>
47
 
48
+ <p><label><input type="radio" name="content" value="entries" checked="checked" /> <?php _e( 'Entries', 'visual-form-builder' ); ?></label></p>
49
 
50
  <ul id="entries-filters" class="vfb-export-filters">
51
  <li><p class="description">This will export entries in either a .csv or .xls and cannot be used with the Import. If you need to import entries on another site, please use the All data option above.</p></li>
52
  <li>
53
  <label for="format">Format:</label>
54
  <select name="format">
55
+ <option value="csv" selected="selected"><?php _e( 'Comma Separated (.csv)', 'visual-form-builder' ); ?></option>
56
+ <option value="xls" disabled="disabled"><?php _e( 'Excel (.xls) - Pro only', 'visual-form-builder' ); ?></option>
57
  </select>
58
  </li>
59
  <li>
js/visual-form-builder.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(g){var b=null;g(document).on("mouseenter mouseleave",".vfb-tooltip",function(t){if(t.type=="mouseenter"){if(b){clearTimeout(b);b=null}var q=g(this).attr("title"),s=g(this).attr("rel"),r=g(this).width();g(this).append('<div class="tooltip"><h3>'+q+'</h3><p class="text">'+s+"</p></div>");g.data(this,"title",q);this.title="";g(this).find(".tooltip").css({left:r+22});b=setTimeout(function(){g(".tooltip").fadeIn(300)},500)}else{this.title=g.data(this,"title");g(".tooltip").fadeOut(500);g(this).children().remove()}});g(document).on("click","a.addOption",function(w){w.preventDefault();var r=g(this).parent().parent().find(".clonedOption").length;var v=r+1;var x=g(this).closest("div").attr("id");var u=g(this).closest("div").children("label").attr("for");var q=u.replace(new RegExp(/(\d+)$/g),"");var t=x.replace(new RegExp(/(\d+)$/g),"");var s=g("#"+x).clone().attr("id",t+v);s.children("label").attr("for",q+v);s.find('input[type="text"]').attr("id",q+v);s.find('input[type="radio"]').attr("value",v);g("#"+t+r).after(s)});g(document).on("click","a.deleteOption",function(r){r.preventDefault();var q=g(this).parent().parent().find(".clonedOption").length;if(q-1==0){alert("You must have at least one option.")}else{g(this).closest("div").remove()}});g(document).on("click","a.addEmail",function(w){w.preventDefault();var r=g(this).closest("#email-details").find(".clonedOption").length;var v=r+1;var x=g(this).closest("div").attr("id");var u=g(this).closest("div").find("label").attr("for");var q=u.replace(new RegExp(/(\d+)$/g),"");var t=x.replace(new RegExp(/(\d+)$/g),"");var s=g("#"+x).clone().attr("id",t+v);s.find("label").attr("for",q+v);s.find("input").attr("id",q+v);g("#"+t+r).after(s)});g(document).on("click","a.deleteEmail",function(r){r.preventDefault();var q=g(this).closest("#email-details").find(".clonedOption").length;if(q-1==0){alert("You must have at least one option.")}else{g(this).closest("div").remove()}});g(".menu-delete, .entry-delete").click(function(){var q=(g(this).hasClass("entry-delete"))?"entry":"form";var r=confirm("You are about to permanently delete this "+q+" and all of its data.\n'Cancel' to stop, 'OK' to delete.");if(r){return true}return false});g(document).on("click","a.item-edit",function(q){q.preventDefault();g(q.target).closest("li").children(".menu-item-settings").slideToggle("fast");g(this).toggleClass("opened")});g("#form-copy-to-clipboard").focus(function(){this.select()});var f=g(".nav-tabs-wrapper"),j=f.children(".nav-tabs"),e=j.children(".nav-tab-active"),l=j.children(".nav-tab"),c=0,n,d,i={},k,a="margin-left",p="margin-right",m=2;l.each(function(){c+=g(this).outerWidth(true)});i.padding=0;i[p]=(-1*c)+"px";j.css(i);h();function h(){if(f.length){var s=f.width(),r=0,q={};d=f.offset().left;n=d+s;e.makeTabVisible(d,n,j,a,m);if(l.last().isTabVisible(d,n)){r=f.width()-c;r=r>0?0:r;q[a]=r+"px";j.animate(q,100,"linear")}if(s>c){g(".nav-tabs-arrow-right, .nav-tabs-arrow-left").hide()}else{g(".nav-tabs-arrow-right, .nav-tabs-arrow-left").show()}}}g(window).resize(function(){if(k){clearTimeout(k)}k=setTimeout(h,200)});g(".nav-tabs-arrow-right").mousedown(function(){var s=Math.abs(parseInt(j.css(a))),q=s,r={};q=Math.abs(c-f.width())-s;if(!q){return}r[a]="-="+q+"px";j.animate(r,q*m,"linear")}).mouseup(function(){j.stop(true)});g(".nav-tabs-arrow-left").mousedown(function(){var s=Math.abs(parseInt(j.css(a))),q=s,r={};if(!q){return}r[a]="+="+q+"px";j.animate(r,q*m,"linear")}).mouseup(function(){j.stop(true)});g("#menu-to-edit").nestedSortable({listType:"ul",maxLevels:3,handle:".menu-item-handle",placeholder:"sortable-placeholder",tolerance:"pointer",toleranceElement:"> dl",items:"li:not(.ui-state-disabled)",create:function(q,r){g(this).css("min-height",g(this).height())},start:function(q,r){r.placeholder.height(r.item.height())},stop:function(q,r){opts={url:ajaxurl,type:"POST",async:true,cache:false,dataType:"json",data:{action:"visual_form_builder_process_sort",order:g(this).nestedSortable("toArray")},success:function(s){g("#loading-animation").hide();return}};g.ajax(opts)}});g('#form-items input[type="submit"]').click(function(){g(this).closest("form").data("submit_value",g(this))});g(document).on("submit","#form-items",function(r){r.preventDefault();var s=g(this).serializeArray(),q=g(this).data("submit_value").attr("value");g("img.waiting").show();g.ajax({url:ajaxurl,type:"POST",async:true,cache:false,dataType:"html",data:{action:"visual_form_builder_create_field",data:s,field_type:q,page:pagenow,nonce:g("#_wpnonce").val()},success:function(t){g("img.waiting").hide();g(t).hide().insertBefore("#menu-to-edit li.ui-state-disabled:first").fadeIn();return},error:function(u,v,t){alert(u+" "+v+" "+t);return}})});g(document).on("click","a.item-delete",function(x){x.preventDefault();var v=childs=new Array(),B=0,r=g(this).attr("href"),q=r.split("&");for(var w=0;w<q.length;w++){var z=q[w].indexOf("=");var y=q[w].substring(0,z);var A=q[w].substring(z+1);v[y]=A}var s=g(this).closest(".form-item").find("ul").children();var u=s.parent().html();s.each(function(t){childs[t]=g(this).attr("id").match(new RegExp(/(\d+)$/g))[0]});var C=g(this).closest("li.form-item").parents("li.form-item");if(C.length){B=C.attr("id").match(new RegExp(/(\d+)$/g))[0]}g.ajax({url:ajaxurl,type:"POST",async:true,cache:false,dataType:"html",data:{action:"visual_form_builder_delete_field",form:v.form,field:v.field,child_ids:childs,parent_id:B,page:pagenow,nonce:v._wpnonce},success:function(t){g("#form_item_"+v.field).addClass("deleting").animate({opacity:0,height:0},350,function(){g(this).before(u).remove()});return},error:function(D,E,t){alert("There was an error loading the content");return}})});g("#form-settings-button").click(function(s){s.preventDefault();g(this).toggleClass("current");g("#form-settings").slideToggle();var q=g('input[name="form_id"]').val(),r=(g(this).hasClass("current"))?"opened":"closed";g.ajax({url:ajaxurl,type:"POST",async:true,cache:false,data:{action:"visual_form_builder_form_settings",form:q,status:r,page:pagenow},success:function(t){if(r=="closed"){g(".settings-links").removeClass("on");g(".settings-links:first").addClass("on");g(".form-details").slideUp("normal");g(".form-details:first").show("normal")}},error:function(u,v,t){alert("There was an error loading the content");return}})});g(".settings-links").click(function(s){s.preventDefault();g(".settings-links").removeClass("on");g(".form-details").slideUp("normal");if(g(this).next("div").is(":hidden")==true){g(this).addClass("on");g(this).next().slideDown("normal")}var r=g('input[name="form_id"]').val(),q=this.hash.replace(/#/g,"");g.ajax({url:ajaxurl,type:"POST",async:true,cache:false,data:{action:"visual_form_builder_form_settings",form:r,accordion:q,page:pagenow},success:function(t){},error:function(u,v,t){alert("There was an error loading the content");return}})});var o=g(".form-success-type:checked").val();g("#form-success-message-"+o).show();g(".form-success-type").change(function(){var q=g(this).val();if("text"==q){g("#form-success-message-text").show();g("#form-success-message-page, #form-success-message-redirect").hide()}else{if("page"==q){g("#form-success-message-page").show();g("#form-success-message-text, #form-success-message-redirect").hide()}else{if("redirect"==q){g("#form-success-message-redirect").show();g("#form-success-message-text, #form-success-message-page").hide()}}}});g(".vfb-field-types").click(function(r){r.preventDefault();g("#vfb-field-tabs li").removeClass("tabs");g(this).parent().addClass("tabs");g(".tabs-panel-active").removeClass("tabs-panel-active").addClass("tabs-panel-inactive");var q=this.hash;g(q).removeClass("tabs-panel-inactive").addClass("tabs-panel-active")});g("#visual-form-builder-update").validate({rules:{"form_email_to[]":{email:true},form_email_from:{email:true},form_success_message_redirect:{url:true},form_notification_email_name:{required:function(q){return g("#form-notification-setting").is(":checked")}},form_notification_email_from:{required:function(q){return g("#form-notification-setting").is(":checked")},email:true},form_notification_email:{required:function(q){return g("#form-notification-setting").is(":checked")}}},errorPlacement:function(q,r){q.insertAfter(r.parent())}});g("#form_email_from_name_override").change(function(){if(g("#form_email_from_name_override").val()==""){g("#form-email-sender-name").attr("readonly",false)}else{g("#form-email-sender-name").attr("readonly","readonly")}});g("#form_email_from_override").change(function(){if(g("#form_email_from_override").val()==""){g("#form-email-sender").attr("readonly",false)}else{g("#form-email-sender").attr("readonly","readonly")}});if(g("#form-notification-setting").is(":checked")){g("#notification-email").show()}else{g("#notification-email").hide()}g("#form-notification-setting").change(function(){var q=g(this).is(":checked");if(q){g("#notification-email").show();g("#form-notification-email-name, #form-notification-email-from, #form-notification-email, #form-notification-subject, #form-notification-message, #form-notification-entry").attr("disabled",false)}else{g("#notification-email").hide();g("#form-notification-email-name, #form-notification-email-from, #form-notification-email, #form-notification-subject, #form-notification-message, #form-notification-entry").attr("disabled","disabled")}});g.validator.addMethod("multiemail",function(s,r){if(this.optional(r)){return true}var t=s.split(new RegExp("\\s*[,|;]\\s*","gi"));valid=true;for(var q in t){s=t[q];valid=valid&&jQuery.validator.methods.email.call(this,s,r)}return valid},"One or more email addresses are invalid")});jQuery.fn.extend({makeTabVisible:function(d,h,f,b,g){var j=this.eq(0),c,i,e={},a=0;if(!j.length){return this}c=j.offset().left;i=c+j.outerWidth();if(i>h){a=h-i}else{if(c<d){a=d-c}}if(!a){return this}e[b]="+="+1*a+"px";f.animate(e,Math.abs(a)*g,"linear");return this},isTabVisible:function(e,d){var b=this.eq(0),c=b.offset().left,a=c+b.outerWidth();return(a<=d&&c>=e)?true:false}});
1
+ jQuery(document).ready(function(e){if(pagenow=="toplevel_page_visual-form-builder"){e(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles("toplevel_page_visual-form-builder")}var a=null;e(document).on("mouseenter mouseleave",".vfb-tooltip",function(j){if(j.type=="mouseenter"){if(a){clearTimeout(a);a=null}var g=e(this).attr("title"),i=e(this).attr("rel"),h=e(this).width();e(this).append('<div class="tooltip"><h3>'+g+'</h3><p class="text">'+i+"</p></div>");e.data(this,"title",g);this.title="";e(this).find(".tooltip").css({left:h+22});a=setTimeout(function(){e(".tooltip").fadeIn(300)},500)}else{this.title=e.data(this,"title");e(".tooltip").fadeOut(500);e(this).children().remove()}});e(document).on("click","a.addOption",function(m){m.preventDefault();var h=e(this).parent().parent().find(".clonedOption").length;var l=h+1;var n=e(this).closest("div").attr("id");var k=e(this).closest("div").children("label").attr("for");var g=k.replace(new RegExp(/(\d+)$/g),"");var j=n.replace(new RegExp(/(\d+)$/g),"");var i=e("#"+n).clone().attr("id",j+l);i.children("label").attr("for",g+l);i.find('input[type="text"]').attr("id",g+l);i.find('input[type="radio"]').attr("value",l);e("#"+j+h).after(i)});e(document).on("click","a.deleteOption",function(h){h.preventDefault();var g=e(this).parent().parent().find(".clonedOption").length;if(g-1==0){alert("You must have at least one option.")}else{e(this).closest("div").remove()}});e(document).on("click","a.addEmail",function(m){m.preventDefault();var h=e(this).closest("#email-details").find(".clonedOption").length;var l=h+1;var n=e(this).closest("div").attr("id");var k=e(this).closest("div").find("label").attr("for");var g=k.replace(new RegExp(/(\d+)$/g),"");var j=n.replace(new RegExp(/(\d+)$/g),"");var i=e("#"+n).clone().attr("id",j+l);i.find("label").attr("for",g+l);i.find("input").attr("id",g+l);e("#"+j+h).after(i)});e(document).on("click","a.deleteEmail",function(h){h.preventDefault();var g=e(this).closest("#email-details").find(".clonedOption").length;if(g-1==0){alert("You must have at least one option.")}else{e(this).closest("div").remove()}});e(".menu-delete, .entry-delete").click(function(){var g=(e(this).hasClass("entry-delete"))?"entry":"form";var h=confirm("You are about to permanently delete this "+g+" and all of its data.\n'Cancel' to stop, 'OK' to delete.");if(h){return true}return false});e(document).on("click","a.item-edit",function(g){g.preventDefault();e(g.target).closest("li").children(".menu-item-settings").slideToggle("fast");e(this).toggleClass("opened")});e("#menu-to-edit").nestedSortable({listType:"ul",maxLevels:3,handle:".menu-item-handle",placeholder:"sortable-placeholder",tolerance:"pointer",toleranceElement:"> dl",items:"li:not(.ui-state-disabled)",create:function(g,h){e(this).css("min-height",e(this).height())},start:function(g,h){h.placeholder.height(h.item.height())},stop:function(g,h){opts={url:ajaxurl,type:"POST",async:true,cache:false,dataType:"json",data:{action:"visual_form_builder_process_sort",order:e(this).nestedSortable("toArray")},success:function(i){e("#loading-animation").hide();return}};e.ajax(opts)}});e("#form-items .vfb-draggable-form-items").click(function(g){g.preventDefault();e(this).data("submit_value",e(this).text())});e(document).on("click","#form-items .vfb-draggable-form-items",function(i){i.preventDefault();var j=e(this).closest("form").serializeArray(),h=e(this).data("submit_value"),g=e("#menu-to-edit li.ui-state-disabled:first").attr("id").match(new RegExp(/(\d+)$/g))[0];e("img.waiting").show();e.ajax({url:ajaxurl,type:"POST",async:true,cache:false,dataType:"html",data:{action:"visual_form_builder_create_field",data:j,field_type:h,previous:g,page:pagenow,nonce:e("#_wpnonce").val()},success:function(k){e("img.waiting").hide();e(k).hide().insertBefore("#menu-to-edit li.ui-state-disabled:first").fadeIn();return},error:function(l,m,k){alert(l+" "+m+" "+k);return}})});e(document).on("click","a.item-delete",function(n){n.preventDefault();var l=childs=new Array(),r=0,h=e(this).attr("href"),g=h.split("&");for(var m=0;m<g.length;m++){var p=g[m].indexOf("=");var o=g[m].substring(0,p);var q=g[m].substring(p+1);l[o]=q}var j=e(this).closest(".form-item").find("ul").children();var k=j.parent().html();j.each(function(t){childs[t]=e(this).attr("id").match(new RegExp(/(\d+)$/g))[0]});var s=e(this).closest("li.form-item").parents("li.form-item");if(s.length){r=s.attr("id").match(new RegExp(/(\d+)$/g))[0]}e.ajax({url:ajaxurl,type:"POST",async:true,cache:false,dataType:"html",data:{action:"visual_form_builder_delete_field",form:l.form,field:l.field,child_ids:childs,parent_id:r,page:pagenow,nonce:l._wpnonce},success:function(i){e("#form_item_"+l.field).addClass("deleting").animate({opacity:0,height:0},350,function(){e(this).before(k).remove()});return},error:function(t,u,i){alert("There was an error loading the content");return}})});e("#form-settings-button").click(function(i){i.preventDefault();e(this).toggleClass("current");e("#form-settings").slideToggle();var g=e('input[name="form_id"]').val(),h=(e(this).hasClass("current"))?"opened":"closed";e.ajax({url:ajaxurl,type:"POST",async:true,cache:false,data:{action:"visual_form_builder_form_settings",form:g,status:h,page:pagenow},success:function(j){if(h=="closed"){e(".settings-links").removeClass("on");e(".settings-links:first").addClass("on");e(".form-details").slideUp("normal");e(".form-details:first").show("normal")}},error:function(k,l,j){alert("There was an error loading the content");return}})});e(".settings-links").click(function(i){i.preventDefault();e(".settings-links").removeClass("on");e(".form-details").slideUp("normal");if(e(this).next("div").is(":hidden")==true){e(this).addClass("on");e(this).next().slideDown("normal")}var h=e('input[name="form_id"]').val(),g=this.hash.replace(/#/g,"");e.ajax({url:ajaxurl,type:"POST",async:true,cache:false,data:{action:"visual_form_builder_form_settings",form:h,accordion:g,page:pagenow},success:function(j){},error:function(k,l,j){alert("There was an error loading the content");return}})});if(e(".columns-2 #side-sortables").length>0){var d=e("#vfb_form_items_meta_box"),f=d.offset(),b=55;e(window).on("scroll",function(){if(e(window).scrollTop()>f.top){d.stop().css({marginTop:e(window).scrollTop()-f.top+b})}else{d.stop().css({marginTop:0})}})}var c=e(".form-success-type:checked").val();e("#form-success-message-"+c).show();e(".form-success-type").change(function(){var g=e(this).val();if("text"==g){e("#form-success-message-text").show();e("#form-success-message-page, #form-success-message-redirect").hide()}else{if("page"==g){e("#form-success-message-page").show();e("#form-success-message-text, #form-success-message-redirect").hide()}else{if("redirect"==g){e("#form-success-message-redirect").show();e("#form-success-message-text, #form-success-message-page").hide()}}}});e(".vfb-field-types").click(function(h){h.preventDefault();e("#vfb-field-tabs li").removeClass("tabs");e(this).parent().addClass("tabs");e(".tabs-panel-active").removeClass("tabs-panel-active").addClass("tabs-panel-inactive");var g=this.hash;e(g).removeClass("tabs-panel-inactive").addClass("tabs-panel-active")});e("#visual-form-builder-update").validate({rules:{"form_email_to[]":{email:true},form_email_from:{email:true},form_success_message_redirect:{url:true},form_notification_email_name:{required:function(g){return e("#form-notification-setting").is(":checked")}},form_notification_email_from:{required:function(g){return e("#form-notification-setting").is(":checked")},email:true},form_notification_email:{required:function(g){return e("#form-notification-setting").is(":checked")}}},errorPlacement:function(g,h){g.insertAfter(h.parent())}});e("#form_email_from_name_override").change(function(){if(e("#form_email_from_name_override").val()==""){e("#form-email-sender-name").attr("readonly",false)}else{e("#form-email-sender-name").attr("readonly","readonly")}});e("#form_email_from_override").change(function(){if(e("#form_email_from_override").val()==""){e("#form-email-sender").attr("readonly",false)}else{e("#form-email-sender").attr("readonly","readonly")}});if(e("#form-notification-setting").is(":checked")){e("#notification-email").show()}else{e("#notification-email").hide()}e("#form-notification-setting").change(function(){var g=e(this).is(":checked");if(g){e("#notification-email").show();e("#form-notification-email-name, #form-notification-email-from, #form-notification-email, #form-notification-subject, #form-notification-message, #form-notification-entry").attr("disabled",false)}else{e("#notification-email").hide();e("#form-notification-email-name, #form-notification-email-from, #form-notification-email, #form-notification-subject, #form-notification-message, #form-notification-entry").attr("disabled","disabled")}})});
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: mmuro
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9UN9CLPH4&lc=US&item_name=Visual%20Form%20Builder&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
5
- Requires at least: 3.3
6
- Tested up to: 3.4.1
7
- Stable tag: 2.5
8
  License: GPLv2 or later
9
 
10
  Build beautiful, fully functional forms in only a few minutes without writing PHP, CSS, or HTML.
@@ -86,18 +86,17 @@ Build beautiful, fully functional forms in only a few minutes without writing PH
86
 
87
  == Installation ==
88
 
89
- 1. Upload `visual-form-builder` to the `/wp-content/plugins/` directory
90
- 1. Activate the plugin through the 'Plugins' menu in WordPress
91
- 1. Go to <em>Settings > Visual Form Builder</em>
92
- 1. Create and configure a form (for help, refer to the FAQ or the Help on the plugin page)
93
- 1. Copy the form shortcode from the Shortcode box on the plugin page
94
- 1. Create a new page and add the shortcode to the content.
95
 
96
  == Frequently Asked Questions ==
97
 
98
  = How do I build my form? =
99
 
100
- 1. Click on the + tab, give your form a name and click Create Form.
101
  1. Click the form fields from the box on the left to add it to your form.
102
  1. Edit the information for each form field by clicking on the down arrow.
103
  1. Drag and drop the elements to put them in order.
@@ -211,6 +210,18 @@ To Export Selected:
211
 
212
  == Changelog ==
213
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  **Version 2.5**
215
 
216
  * Add new Export page for exporting all entries
@@ -391,6 +402,9 @@ To Export Selected:
391
 
392
  == Upgrade Notice ==
393
 
 
 
 
394
  = 2.5 =
395
  Improved Export entries page, improved server side validation
396
 
2
  Contributors: mmuro
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9UN9CLPH4&lc=US&item_name=Visual%20Form%20Builder&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
5
+ Requires at least: 3.4.1
6
+ Tested up to: 3.5
7
+ Stable tag: 2.6
8
  License: GPLv2 or later
9
 
10
  Build beautiful, fully functional forms in only a few minutes without writing PHP, CSS, or HTML.
86
 
87
  == Installation ==
88
 
89
+ 1. Go to Plugins > Add New
90
+ 1. Click the Upload link
91
+ 1. Click Browse and locate the `visual-form-builder.x.x.zip` file
92
+ 1. Click Install Now
93
+ 1. After WordPress installs, click on the Activate Plugin link
 
94
 
95
  == Frequently Asked Questions ==
96
 
97
  = How do I build my form? =
98
 
99
+ 1. Click on the New Form button and enter a few form details
100
  1. Click the form fields from the box on the left to add it to your form.
101
  1. Edit the information for each form field by clicking on the down arrow.
102
  1. Drag and drop the elements to put them in order.
210
 
211
  == Changelog ==
212
 
213
+ **Version 2.6**
214
+
215
+ * Move plugin into its own menu
216
+ * Add new 'All Forms' view with an alphabetical group list
217
+ * Add new New Form screen
218
+ * Add customizable columns to admin form builder (see Screen Options tab)
219
+ * Update meta boxes to be reordered or hidden (see Screen Options tab)
220
+ * Update and clean up entry form design
221
+ * Update email headers to send from admin email for servers having trouble with sending
222
+ * Fix bug where form rendering would behave erratically in Internet Explorer 9
223
+ * Fix bug where sender emails would be cut off after 25 characters in the entries database
224
+
225
  **Version 2.5**
226
 
227
  * Add new Export page for exporting all entries
402
 
403
  == Upgrade Notice ==
404
 
405
+ = 2.6 =
406
+ VFB now in its own menu, new All Forms UI, other bug fixes
407
+
408
  = 2.5 =
409
  Improved Export entries page, improved server side validation
410
 
uninstall.php CHANGED
@@ -4,9 +4,9 @@
4
 
5
  global $wpdb;
6
 
7
- $form_table = $wpdb->prefix . 'visual_form_builder_fields';
8
- $fields_table = $wpdb->prefix . 'visual_form_builder_forms';
9
- $entries_table = $wpdb->prefix . 'visual_form_builder_entries';
10
 
11
  $wpdb->query( "DROP TABLE IF EXISTS $form_table" );
12
  $wpdb->query( "DROP TABLE IF EXISTS $fields_table" );
@@ -15,5 +15,5 @@
15
  delete_option( 'vfb_db_version' );
16
  delete_option( 'visual-form-builder-screen-options' );
17
 
18
- $wpdb->query( $wpdb->prepare( "DELETE FROM " . $wpdb->prefix . "usermeta WHERE meta_key IN ( 'vfb-form-settings' )" ) );
19
  ?>
4
 
5
  global $wpdb;
6
 
7
+ $form_table = $wpdb->prefix . 'visual_form_builder_fields';
8
+ $fields_table = $wpdb->prefix . 'visual_form_builder_forms';
9
+ $entries_table = $wpdb->prefix . 'visual_form_builder_entries';
10
 
11
  $wpdb->query( "DROP TABLE IF EXISTS $form_table" );
12
  $wpdb->query( "DROP TABLE IF EXISTS $fields_table" );
15
  delete_option( 'vfb_db_version' );
16
  delete_option( 'visual-form-builder-screen-options' );
17
 
18
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . $wpdb->prefix . "usermeta WHERE meta_key IN ( 'vfb-form-settings', 'vfb_entries_per_page', 'managevisual-form-builder_page_vfb-entriescolumnshidden' )" ) );
19
  ?>
visual-form-builder.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Visual Form Builder
4
  Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
5
  Author: Matthew Muro
6
  Author URI: http://matthewmuro.com
7
- Version: 2.5
8
  */
9
 
10
  /*
@@ -25,13 +25,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  // Set to true to load uncompressed and unminified scripts and stylesheets
26
  define( 'VFB_SCRIPT_DEBUG', false );
27
 
28
- /* Instantiate new class */
29
  $visual_form_builder = new Visual_Form_Builder();
30
 
31
- /* Restrict Categories class */
32
  class Visual_Form_Builder{
33
 
34
- protected $vfb_db_version = '2.5',
35
  $add_scripts = false;
36
 
37
  public $countries = array( "", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States of America", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe" );
@@ -39,17 +39,17 @@ class Visual_Form_Builder{
39
  public function __construct(){
40
  global $wpdb;
41
 
42
- /* Setup global database table names */
43
- $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
44
- $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
45
- $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
46
 
47
  // Add suffix to load dev files
48
  $this->load_dev_files = ( defined( 'VFB_SCRIPT_DEBUG' ) && VFB_SCRIPT_DEBUG ) ? '.dev' : '';
49
 
50
- /* Make sure we are in the admin before proceeding. */
51
  if ( is_admin() ) {
52
- /* Build options and settings pages. */
53
  add_action( 'admin_menu', array( &$this, 'add_admin' ) );
54
  add_action( 'admin_menu', array( &$this, 'save' ) );
55
 
@@ -58,43 +58,52 @@ class Visual_Form_Builder{
58
  add_action( 'wp_ajax_visual_form_builder_delete_field', array( &$this, 'delete_field_callback' ) );
59
  add_action( 'wp_ajax_visual_form_builder_form_settings', array( &$this, 'form_settings_callback' ) );
60
 
61
- add_action( 'load-settings_page_visual-form-builder', array( &$this, 'help' ) );
62
 
63
- /* Adds additional media button to insert form shortcode */
64
  add_action( 'media_buttons_context', array( &$this, 'add_media_button' ) );
65
  add_action( 'admin_footer', array( &$this, 'display_media_button' ) );
66
 
67
- /* Load the includes files */
68
- add_action( 'load-settings_page_visual-form-builder', array( &$this, 'includes' ) );
 
69
 
70
- /* Adds a Screen Options tab to the Entries screen */
71
- add_action( 'admin_init', array( &$this, 'save_screen_options' ) );
72
- add_filter( 'screen_settings', array( &$this, 'entries_screen_options' ) );
 
73
 
74
- /* Adds a Settings link to the Plugins page */
 
 
 
75
  add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
76
 
77
- /* Add a database version to help with upgrades and run SQL install */
78
  if ( !get_option( 'vfb_db_version' ) ) {
79
  update_option( 'vfb_db_version', $this->vfb_db_version );
80
  $this->install_db();
81
  }
82
 
83
- /* If database version doesn't match, update and run SQL install */
84
  if ( get_option( 'vfb_db_version' ) != $this->vfb_db_version ) {
85
  update_option( 'vfb_db_version', $this->vfb_db_version );
86
  $this->install_db();
87
  }
 
 
 
88
 
89
- /* Load the jQuery and CSS we need if we're on our plugin page */
90
- add_action( 'load-settings_page_visual-form-builder', array( &$this, 'admin_scripts' ) );
91
- add_action( 'load-settings_page_visual-form-builder', array( &$this, 'admin_css' ) );
 
92
 
93
- /* Display update messages */
94
  add_action('admin_notices', array( &$this, 'admin_notices' ) );
95
  }
96
 
97
- /* Load i18n */
98
  load_plugin_textdomain( 'visual-form-builder', false , basename( dirname( __FILE__ ) ) . '/languages' );
99
 
100
  add_shortcode( 'vfb', array( &$this, 'form_code' ) );
@@ -111,19 +120,28 @@ class Visual_Form_Builder{
111
  * @since 1.2
112
  */
113
  public function includes(){
114
- global $entries_list, $entries_detail, $export;
115
 
116
- /* Load the Entries List class */
117
- require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'class-entries-list.php' );
118
  $entries_list = new VisualFormBuilder_Entries_List();
119
 
120
- /* Load the Entries Details class */
121
- require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'class-entries-detail.php' );
122
- $entries_detail = new VisualFormBuilder_Entries_Detail();
123
-
124
- /* Load the Entries Details class */
125
- require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'class-export.php' );
126
- $export = new VisualFormBuilder_Export();
 
 
 
 
 
 
 
 
 
127
  }
128
 
129
  /**
@@ -134,7 +152,7 @@ class Visual_Form_Builder{
134
  */
135
  public function plugin_action_links( $links, $file ) {
136
  if ( $file == plugin_basename( __FILE__ ) )
137
- $links[] = '<a href="options-general.php?page=visual-form-builder">' . __( 'Settings' , 'visual-form-builder') . '</a>';
138
 
139
  return $links;
140
  }
@@ -146,7 +164,7 @@ class Visual_Form_Builder{
146
  */
147
  public function add_media_button( $context ){
148
  if ( current_user_can( 'manage_options' ) )
149
- $context .= '<a href="#TB_inline?width=450&inlineId=vfb_form" class="thickbox" title="Add Visual Form Builder form"><img src="'. plugins_url( 'visual-form-builder/css/vfb_icon.png' ) . '" alt="Add Visual Form Builder form" /></a>';
150
 
151
  return $context;
152
  }
@@ -161,10 +179,10 @@ class Visual_Form_Builder{
161
  public function display_media_button(){
162
  global $wpdb;
163
 
164
- /* Sanitize the sql orderby */
165
  $order = sanitize_sql_orderby( 'form_id ASC' );
166
 
167
- /* Build our forms as an object */
168
  $forms = $wpdb->get_results( $wpdb->prepare( "SELECT form_id, form_title FROM $this->form_table_name ORDER BY $order" ) );
169
  ?>
170
  <script type="text/javascript">
@@ -173,6 +191,8 @@ class Visual_Form_Builder{
173
  e.preventDefault();
174
 
175
  window.send_to_editor( '[vfb id=' + $( '#vfb_forms' ).val() + ']' );
 
 
176
  });
177
  });
178
  </script>
@@ -185,7 +205,7 @@ class Visual_Form_Builder{
185
  <option value="<?php echo $form->form_id; ?>"><?php echo $form->form_title; ?></option>
186
  <?php endforeach; ?>
187
  </select>
188
- <p><input type="submit" class="button" value="Insert Form" /></p>
189
  </form>
190
  </div>
191
  <?php
@@ -210,7 +230,7 @@ class Visual_Form_Builder{
210
  <li>Click Save Form to save your changes.</li>
211
  </ul>'
212
  ) );
213
-
214
  $screen->add_help_tab( array(
215
  'id' => 'vfb-help-tab-item-config',
216
  'title' => 'Form Item Configuration',
@@ -265,7 +285,7 @@ class Visual_Form_Builder{
265
  <li><em>Include a Copy of the User's Entry</em>: appends a copy of the user's submitted entry to the notification email.</li>
266
  </ul>"
267
  ) );
268
-
269
  $screen->add_help_tab( array(
270
  'id' => 'vfb-help-tab-tips',
271
  'title' => 'Tips',
@@ -298,32 +318,115 @@ class Visual_Form_Builder{
298
  }
299
 
300
  /**
301
- * Saves the Screen Options
302
  *
303
- * @since 1.2
304
  */
305
- public function save_screen_options(){
306
- $options = get_option( 'visual-form-builder-screen-options' );
307
 
308
- /* Default is 20 per page */
309
- $defaults = array(
310
- 'per_page' => 20
311
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
 
313
- /* If the option doesn't exist, add it with defaults */
314
- if ( !$options )
315
- update_option( 'visual-form-builder-screen-options', $defaults );
 
 
 
 
 
 
 
 
316
 
317
- /* If the user has saved the Screen Options, update */
318
- if ( isset( $_REQUEST['visual-form-builder-screen-options-apply'] ) && in_array( $_REQUEST['visual-form-builder-screen-options-apply'], array( 'Apply', 'apply' ) ) ) {
319
- $per_page = absint( $_REQUEST['visual-form-builder-screen-options']['per_page'] );
320
- $updated_options = array(
321
- 'per_page' => $per_page
322
- );
323
- update_option( 'visual-form-builder-screen-options', $updated_options );
324
  }
325
  }
326
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  /**
328
  * Install database tables
329
  *
@@ -336,7 +439,7 @@ class Visual_Form_Builder{
336
  $form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
337
  $entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
338
 
339
- /* Explicitly set the character set and collation when creating the tables */
340
  $charset = ( defined( 'DB_CHARSET' && '' !== DB_CHARSET ) ) ? DB_CHARSET : 'utf8';
341
  $collate = ( defined( 'DB_COLLATE' && '' !== DB_COLLATE ) ) ? DB_COLLATE : 'utf8_general_ci';
342
 
@@ -390,14 +493,14 @@ class Visual_Form_Builder{
390
  data TEXT NOT NULL,
391
  subject TEXT,
392
  sender_name VARCHAR(255),
393
- sender_email VARCHAR(25),
394
  emails_to TEXT,
395
  date_submitted DATETIME,
396
  ip_address VARCHAR(25),
397
  UNIQUE KEY (entries_id)
398
  ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
399
 
400
- /* Create or Update database tables */
401
  dbDelta( $field_sql );
402
  dbDelta( $form_sql );
403
  dbDelta( $entries_sql );
@@ -410,7 +513,6 @@ class Visual_Form_Builder{
410
  */
411
  public function admin_css() {
412
  wp_enqueue_style( 'visual-form-builder-style', plugins_url( "visual-form-builder/css/visual-form-builder-admin$this->load_dev_files.css" ) );
413
- wp_enqueue_style( 'visual-form-builder-main', plugins_url( "visual-form-builder/css/nav-menu$this->load_dev_files.css" ) );
414
  }
415
 
416
  /**
@@ -420,6 +522,7 @@ class Visual_Form_Builder{
420
  */
421
  public function admin_scripts() {
422
  wp_enqueue_script( 'jquery-ui-sortable' );
 
423
  wp_enqueue_script( 'jquery-form-validation', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js', array( 'jquery' ), '', true );
424
  wp_enqueue_script( 'form-elements-add', plugins_url( "visual-form-builder/js/visual-form-builder$this->load_dev_files.js" ) , array( 'jquery', 'jquery-form-validation' ), '', true );
425
  wp_enqueue_script( 'nested-sortable', plugins_url( 'visual-form-builder/js/jquery.ui.nestedSortable.js' ) , array( 'jquery', 'jquery-ui-sortable' ), '', true );
@@ -461,86 +564,90 @@ class Visual_Form_Builder{
461
  public function save() {
462
  global $wpdb;
463
 
464
- if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'visual-form-builder' && isset( $_REQUEST['action'] ) ) {
465
 
466
  switch ( $_REQUEST['action'] ) {
467
  case 'create_form' :
468
 
469
- $form_id = absint( $_REQUEST['form_id'] );
470
- $form_key = sanitize_title( $_REQUEST['form_title'] );
471
- $form_title = esc_html( $_REQUEST['form_title'] );
 
 
 
472
 
473
- check_admin_referer( 'create_form-' . $form_id );
474
 
475
  $newdata = array(
476
- 'form_key' => $form_key,
477
- 'form_title' => $form_title
478
- );
 
 
 
 
479
 
480
- /* Set message to display */
481
- $this->message = sprintf( __( '<div id="message" class="updated"><p>The <strong>%s</strong> form has been created.</p></div>' , 'visual-form-builder'), $form_title );
482
-
483
- /* Create the form */
484
  $wpdb->insert( $this->form_table_name, $newdata );
485
 
486
- /* Get form ID to add our first field */
487
  $new_form_selected = $wpdb->insert_id;
488
 
489
- /* Setup the initial fieldset */
490
  $initial_fieldset = array(
491
- 'form_id' => $wpdb->insert_id,
492
- 'field_key' => 'fieldset',
493
- 'field_type' => 'fieldset',
494
- 'field_name' => 'Fieldset',
495
- 'field_sequence' => 0
496
  );
497
 
498
- /* Add the first fieldset to get things started */
499
  $wpdb->insert( $this->field_table_name, $initial_fieldset );
500
 
501
  $verification_fieldset = array(
502
- 'form_id' => $new_form_selected,
503
- 'field_key' => 'verification',
504
- 'field_type' => 'verification',
505
- 'field_name' => 'Verification',
506
  'field_description' => '(This is for preventing spam)',
507
- 'field_sequence' => 1
508
  );
509
 
510
- /* Insert the submit field */
511
  $wpdb->insert( $this->field_table_name, $verification_fieldset );
512
 
513
  $verify_fieldset_parent_id = $wpdb->insert_id;
514
 
515
  $secret = array(
516
- 'form_id' => $new_form_selected,
517
- 'field_key' => 'secret',
518
- 'field_type' => 'secret',
519
- 'field_name' => 'Please enter any two digits with no spaces (Example: 12)',
520
- 'field_size' => 'medium',
521
- 'field_required' => 'yes',
522
- 'field_parent' => $verify_fieldset_parent_id,
523
- 'field_sequence' => 2
524
  );
525
 
526
- /* Insert the submit field */
527
  $wpdb->insert( $this->field_table_name, $secret );
528
 
529
- /* Make the submit last in the sequence */
530
  $submit = array(
531
- 'form_id' => $new_form_selected,
532
- 'field_key' => 'submit',
533
- 'field_type' => 'submit',
534
- 'field_name' => 'Submit',
535
- 'field_parent' => $verify_fieldset_parent_id,
536
- 'field_sequence' => 3
537
  );
538
 
539
- /* Insert the submit field */
540
  $wpdb->insert( $this->field_table_name, $submit );
541
 
542
- /* Redirect to keep the URL clean (use AJAX in the future?) */
543
- wp_redirect( 'options-general.php?page=visual-form-builder&form=' . $new_form_selected );
544
  exit();
545
 
546
  break;
@@ -558,15 +665,15 @@ class Visual_Form_Builder{
558
  $form_from_name_override = esc_html( $_REQUEST['form_email_from_name_override'] );
559
  $form_success_type = esc_html( $_REQUEST['form_success_type'] );
560
  $form_notification_setting = isset( $_REQUEST['form_notification_setting'] ) ? esc_html( $_REQUEST['form_notification_setting'] ) : '';
561
- $form_notification_email_name = esc_html( $_REQUEST['form_notification_email_name'] );
562
- $form_notification_email_from = esc_html( $_REQUEST['form_notification_email_from'] );
563
- $form_notification_email = esc_html( $_REQUEST['form_notification_email'] );
564
- $form_notification_subject = esc_html( $_REQUEST['form_notification_subject'] );
565
- $form_notification_message = wp_richedit_pre( $_REQUEST['form_notification_message'] );
566
  $form_notification_entry = isset( $_REQUEST['form_notification_entry'] ) ? esc_html( $_REQUEST['form_notification_entry'] ) : '';
567
  $form_label_alignment = esc_html( $_REQUEST['form_label_alignment'] );
568
 
569
- /* Add confirmation based on which type was selected */
570
  switch ( $form_success_type ) {
571
  case 'text' :
572
  $form_success_message = wp_richedit_pre( $_REQUEST['form_success_message_text'] );
@@ -582,70 +689,70 @@ class Visual_Form_Builder{
582
  check_admin_referer( 'update_form-' . $form_id );
583
 
584
  $newdata = array(
585
- 'form_key' => $form_key,
586
- 'form_title' => $form_title,
587
- 'form_email_subject' => $form_subject,
588
- 'form_email_to' => $form_to,
589
- 'form_email_from' => $form_from,
590
- 'form_email_from_name' => $form_from_name,
591
- 'form_email_from_override' => $form_from_override,
592
  'form_email_from_name_override' => $form_from_name_override,
593
- 'form_success_type' => $form_success_type,
594
- 'form_success_message' => $form_success_message,
595
- 'form_notification_setting' => $form_notification_setting,
596
- 'form_notification_email_name' => $form_notification_email_name,
597
- 'form_notification_email_from' => $form_notification_email_from,
598
- 'form_notification_email' => $form_notification_email,
599
- 'form_notification_subject' => $form_notification_subject,
600
- 'form_notification_message' => $form_notification_message,
601
- 'form_notification_entry' => $form_notification_entry,
602
- 'form_label_alignment' => $form_label_alignment
603
  );
604
 
605
  $where = array(
606
  'form_id' => $form_id
607
  );
608
 
609
- /* Update form details */
610
  $wpdb->update( $this->form_table_name, $newdata, $where );
611
 
612
- /* Initialize field sequence */
613
  $field_sequence = 0;
614
 
615
- /* Loop through each field and update all at once */
616
  if ( !empty( $_REQUEST['field_id'] ) ) {
617
  foreach ( $_REQUEST['field_id'] as $id ) {
618
- $field_name = ( isset( $_REQUEST['field_name-' . $id] ) ) ? esc_html( $_REQUEST['field_name-' . $id] ) : '';
619
- $field_key = sanitize_title( $field_name, $id );
620
- $field_desc = ( isset( $_REQUEST['field_description-' . $id] ) ) ? esc_html( $_REQUEST['field_description-' . $id] ) : '';
621
- $field_options = ( isset( $_REQUEST['field_options-' . $id] ) ) ? serialize( array_map( 'esc_html', $_REQUEST['field_options-' . $id] ) ) : '';
622
- $field_validation = ( isset( $_REQUEST['field_validation-' . $id] ) ) ? esc_html( $_REQUEST['field_validation-' . $id] ) : '';
623
- $field_required = ( isset( $_REQUEST['field_required-' . $id] ) ) ? esc_html( $_REQUEST['field_required-' . $id] ) : '';
624
- $field_size = ( isset( $_REQUEST['field_size-' . $id] ) ) ? esc_html( $_REQUEST['field_size-' . $id] ) : '';
625
- $field_css = ( isset( $_REQUEST['field_css-' . $id] ) ) ? esc_html( $_REQUEST['field_css-' . $id] ) : '';
626
- $field_layout = ( isset( $_REQUEST['field_layout-' . $id] ) ) ? esc_html( $_REQUEST['field_layout-' . $id] ) : '';
627
- $field_default = ( isset( $_REQUEST['field_default-' . $id] ) ) ? esc_html( $_REQUEST['field_default-' . $id] ) : '';
628
 
629
  $field_data = array(
630
- 'field_key' => $field_key,
631
- 'field_name' => $field_name,
632
  'field_description' => $field_desc,
633
- 'field_options' => $field_options,
634
- 'field_validation' => $field_validation,
635
- 'field_required' => $field_required,
636
- 'field_size' => $field_size,
637
- 'field_css' => $field_css,
638
- 'field_layout' => $field_layout,
639
- 'field_sequence' => $field_sequence,
640
- 'field_default' => $field_default
641
  );
642
 
643
  $where = array(
644
- 'form_id' => $_REQUEST['form_id'],
645
- 'field_id' => $id
646
  );
647
 
648
- /* Update all fields */
649
  $wpdb->update( $this->field_table_name, $field_data, $where );
650
 
651
  $field_sequence++;
@@ -656,75 +763,75 @@ class Visual_Form_Builder{
656
  $is_secret = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'secret' AND form_id = %d", $form_id ) );
657
  $is_submit = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'submit' AND form_id = %d", $form_id ) );
658
 
659
- /* Decrement sequence */
660
  $field_sequence--;
661
 
662
  $verification_id = '';
663
 
664
- /* If this form doesn't have a verification field, add one */
665
  if ( $is_verification == NULL ) {
666
- /* Adjust the sequence */
667
  $verification_fieldset = array(
668
- 'form_id' => $form_id,
669
- 'field_key' => 'verification',
670
- 'field_type' => 'verification',
671
- 'field_name' => 'Verification',
672
- 'field_sequence' => $field_sequence
673
  );
674
 
675
- /* Insert the verification fieldset */
676
  $wpdb->insert( $this->field_table_name, $verification_fieldset );
677
 
678
  $verification_id = $wpdb->insert_id;
679
  }
680
 
681
- /* If the verification field was inserted, use that ID as a parent otherwise set no parent */
682
  $verify_fieldset_parent_id = ( $verification_id !== false ) ? $verification_id : 0;
683
 
684
- /* If this form doesn't have a secret field, add one */
685
  if ( $is_secret == NULL ) {
686
 
687
- /* Adjust the sequence */
688
  $secret = array(
689
- 'form_id' => $form_id,
690
- 'field_key' => 'secret',
691
- 'field_type' => 'secret',
692
- 'field_name' => 'Please enter any two digits with no spaces (Example: 12)',
693
- 'field_size' => 'medium',
694
- 'field_required' => 'yes',
695
- 'field_parent' => $verify_fieldset_parent_id,
696
- 'field_sequence' => ++$field_sequence
697
  );
698
 
699
- /* Insert the submit field */
700
  $wpdb->insert( $this->field_table_name, $secret );
701
  }
702
 
703
- /* If this form doesn't have a submit field, add one */
704
  if ( $is_submit == NULL ) {
705
 
706
- /* Make the submit last in the sequence */
707
  $submit = array(
708
- 'form_id' => $form_id,
709
- 'field_key' => 'submit',
710
- 'field_type' => 'submit',
711
- 'field_name' => 'Submit',
712
- 'field_parent' => $verify_fieldset_parent_id,
713
- 'field_sequence' => ++$field_sequence
714
  );
715
 
716
- /* Insert the submit field */
717
  $wpdb->insert( $this->field_table_name, $submit );
718
  }
719
  else {
720
- /* Only update the Submit's parent ID if the Verification field is new */
721
  $data = ( $is_verification == NULL ) ? array( 'field_parent' => $verify_fieldset_parent_id, 'field_sequence' => ++$field_sequence ) : array( 'field_sequence' => $field_sequence );
722
  $where = array(
723
- 'form_id' => $form_id,
724
- 'field_id' => $is_submit
725
  );
726
 
727
- /* Update the submit field */
728
  $wpdb->update( $this->field_table_name, $data, $where );
729
  }
730
  }
@@ -740,8 +847,8 @@ class Visual_Form_Builder{
740
  $wpdb->query( $wpdb->prepare( "DELETE FROM $this->form_table_name WHERE form_id = %d", $id ) );
741
  $wpdb->query( $wpdb->prepare( "DELETE FROM $this->field_table_name WHERE form_id = %d", $id ) );
742
 
743
- /* Redirect to keep the URL clean (use AJAX in the future?) */
744
- wp_redirect( add_query_arg( 'action', 'deleted', 'options-general.php?page=visual-form-builder' ) );
745
  exit();
746
 
747
  break;
@@ -758,7 +865,7 @@ class Visual_Form_Builder{
758
  $from_name = $wpdb->get_var( null, 1 );
759
  $notify = $wpdb->get_var( null, 2 );
760
 
761
- /* Copy this form and force the initial title to denote a copy */
762
  foreach ( $forms as $form ) {
763
  $data = array(
764
  'form_key' => sanitize_title( $form->form_key . ' copy' ),
@@ -784,30 +891,30 @@ class Visual_Form_Builder{
784
  $wpdb->insert( $this->form_table_name, $data );
785
  }
786
 
787
- /* Get form ID to add our first field */
788
  $new_form_selected = $wpdb->insert_id;
789
 
790
- /* Copy each field and data */
791
  foreach ( $fields as $field ) {
792
  $data = array(
793
- 'form_id' => $new_form_selected,
794
- 'field_key' => $field->field_key,
795
- 'field_type' => $field->field_type,
796
- 'field_name' => $field->field_name,
797
  'field_description' => $field->field_description,
798
- 'field_options' => $field->field_options,
799
- 'field_sequence' => $field->field_sequence,
800
- 'field_validation' => $field->field_validation,
801
- 'field_required' => $field->field_required,
802
- 'field_size' => $field->field_size,
803
- 'field_css' => $field->field_css,
804
- 'field_layout' => $field->field_layout,
805
- 'field_parent' => $field->field_parent
806
  );
807
 
808
  $wpdb->insert( $this->field_table_name, $data );
809
 
810
- /* If a parent field, save the old ID and the new ID to update new parent ID */
811
  if ( in_array( $field->field_type, array( 'fieldset', 'section', 'verification' ) ) )
812
  $parents[ $field->field_id ] = $wpdb->insert_id;
813
 
@@ -821,7 +928,7 @@ class Visual_Form_Builder{
821
  $wpdb->update( $this->form_table_name, array( 'form_notification_email' => $wpdb->insert_id ), array( 'form_id' => $new_form_selected ) );
822
  }
823
 
824
- /* Loop through our parents and update them to their new IDs */
825
  foreach ( $parents as $k => $v ) {
826
  $wpdb->update( $this->field_table_name, array( 'field_parent' => $v ), array( 'form_id' => $new_form_selected, 'field_parent' => $k ) );
827
  }
@@ -844,14 +951,14 @@ class Visual_Form_Builder{
844
  foreach ( $_REQUEST['order'] as $k ) {
845
  if ( 'root' !== $k['item_id'] ) {
846
  $data[] = array(
847
- 'field_id' => $k['item_id'],
848
- 'parent' => $k['parent_id']
849
- );
850
  }
851
  }
852
 
853
  foreach ( $data as $k => $v ) {
854
- /* Update each field with it's new sequence and parent ID */
855
  $wpdb->update( $this->field_table_name, array( 'field_sequence' => $k, 'field_parent' => $v['parent'] ), array( 'field_id' => $v['field_id'] ) );
856
  }
857
 
@@ -873,13 +980,14 @@ class Visual_Form_Builder{
873
  $data[ $k['name'] ] = $k['value'];
874
  }
875
 
876
- if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'settings_page_visual-form-builder' && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'visual_form_builder_create_field' ) {
877
- $form_id = absint( $data['form_id'] );
878
- $field_key = sanitize_title( $_REQUEST['field_type'] );
 
879
  $field_name = esc_html( $_REQUEST['field_type'] );
880
  $field_type = strtolower( sanitize_title( $_REQUEST['field_type'] ) );
881
 
882
- /* Set defaults for validation */
883
  switch ( $field_type ) {
884
  case 'select' :
885
  case 'radio' :
@@ -912,31 +1020,32 @@ class Visual_Form_Builder{
912
 
913
  check_ajax_referer( 'create-field-' . $data['form_id'], 'nonce' );
914
 
915
- /* Get the last row's sequence that isn't a Verification */
916
- $sequence_last_row = $wpdb->get_row( $wpdb->prepare( "SELECT field_sequence FROM $this->field_table_name WHERE form_id = %d AND field_type = 'verification' ORDER BY field_sequence DESC LIMIT 1". $form_id ) );
917
 
918
- /* If it's not the first for this form, add 1 */
919
- $field_sequence = ( !empty( $sequence_last_row ) ) ? $sequence_last_row->field_sequence : 0;
920
 
921
  $newdata = array(
922
- 'form_id' => absint( $data['form_id'] ),
923
- 'field_key' => $field_key,
924
- 'field_name' => $field_name,
925
- 'field_type' => $field_type,
926
- 'field_options' => $field_options,
927
- 'field_sequence' => $field_sequence,
928
- 'field_validation' => $field_validation
929
  );
930
 
931
- /* Create the field */
932
  $wpdb->insert( $this->field_table_name, $newdata );
 
933
  $insert_id = $wpdb->insert_id;
934
  $update_these = array( 'verification', 'secret', 'submit' );
935
 
936
  foreach ( $update_these as $update ) {
937
  $where = array(
938
- 'form_id' => absint( $data['form_id'] ),
939
- 'field_type' => $update
940
  );
941
 
942
  $wpdb->update( $this->field_table_name, array( 'field_sequence' => $field_sequence + 1 ), $where );
@@ -958,7 +1067,7 @@ class Visual_Form_Builder{
958
  public function delete_field_callback() {
959
  global $wpdb;
960
 
961
- if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'settings_page_visual-form-builder' && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'visual_form_builder_delete_field' ) {
962
  $form_id = absint( $_REQUEST['form'] );
963
  $field_id = absint( $_REQUEST['field'] );
964
 
@@ -968,12 +1077,12 @@ class Visual_Form_Builder{
968
  foreach ( $_REQUEST['child_ids'] as $children ) {
969
  $parent = absint( $_REQUEST['parent_id'] );
970
 
971
- /* Update each child item with the new parent ID */
972
  $wpdb->update( $this->field_table_name, array( 'field_parent' => $parent ), array( 'field_id' => $children ) );
973
  }
974
  }
975
 
976
- /* Delete the field */
977
  $wpdb->query( $wpdb->prepare( "DELETE FROM $this->field_table_name WHERE field_id = %d", $field_id ) );
978
  }
979
 
@@ -990,19 +1099,19 @@ class Visual_Form_Builder{
990
  get_currentuserinfo();
991
 
992
  if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'visual_form_builder_form_settings' ) {
993
- $form_id = absint( $_REQUEST['form'] );
994
- $status = isset( $_REQUEST['status'] ) ? $_REQUEST['status'] : 'opened';
995
- $accordion = isset( $_REQUEST['accordion'] ) ? $_REQUEST['accordion'] : 'general-settings';
996
- $user_id = $current_user->ID;
997
 
998
  $form_settings = get_user_meta( $user_id, 'vfb-form-settings', true );
999
 
1000
  $array = array(
1001
- 'form_setting_tab' => $status,
1002
  'setting_accordion' => $accordion
1003
  );
1004
 
1005
- /* Set defaults if meta key doesn't exist */
1006
  if ( !$form_settings || $form_settings == '' ) {
1007
  $meta_value[ $form_id ] = $array;
1008
 
@@ -1017,6 +1126,118 @@ class Visual_Form_Builder{
1017
 
1018
  die(1);
1019
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1020
 
1021
  /**
1022
  * Build field output in admin
@@ -1027,43 +1248,43 @@ class Visual_Form_Builder{
1027
  global $wpdb;
1028
 
1029
  $field_where = ( isset( $field_id ) && !is_null( $field_id ) ) ? "AND field_id = $field_id" : '';
1030
- /* Display all fields for the selected form */
1031
  $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d $field_where ORDER BY field_sequence ASC", $form_nav_selected_id ) );
1032
 
1033
  $depth = 1;
1034
  $parent = $last = 0;
1035
 
1036
- /* Loop through each field and display */
1037
  foreach ( $fields as $field ) :
1038
- /* If we are at the root level */
1039
  if ( !$field->field_parent && $depth > 1 ) {
1040
- /* If we've been down a level, close out the list */
1041
  while ( $depth > 1 ) {
1042
  echo '</li>
1043
  </ul>';
1044
  $depth--;
1045
  }
1046
 
1047
- /* Close out the root item */
1048
  echo '</li>';
1049
  }
1050
- /* first item of <ul>, so move down a level */
1051
  elseif ( $field->field_parent && $field->field_parent == $last ) {
1052
  echo '<ul class="parent">';
1053
  $depth++;
1054
  }
1055
- /* Close up a <ul> and move up a level */
1056
  elseif ( $field->field_parent && $field->field_parent != $parent ) {
1057
  echo '</li>
1058
  </ul>
1059
  </li>';
1060
  $depth--;
1061
  }
1062
- /* Same level so close list item */
1063
  elseif ( $field->field_parent && $field->field_parent == $parent )
1064
  echo '</li>';
1065
 
1066
- /* Store item ID and parent ID to test for nesting */
1067
  $last = $field->field_id;
1068
  $parent = $field->field_parent;
1069
  ?>
@@ -1139,7 +1360,7 @@ class Visual_Form_Builder{
1139
  </p>
1140
 
1141
  <?php
1142
- /* Display the Options input only for radio, checkbox, and select fields */
1143
  if ( in_array( $field->field_type, array( 'radio', 'checkbox', 'select' ) ) ) : ?>
1144
  <!-- Options -->
1145
  <p class="description description-wide">
@@ -1147,19 +1368,19 @@ class Visual_Form_Builder{
1147
  <span class="vfb-tooltip" title="About Options" rel="This property allows you to set predefined options to be selected by the user. Use the plus and minus buttons to add and delete options. At least one option must exist.">(?)</span>
1148
  <br />
1149
  <?php
1150
- /* If the options field isn't empty, unserialize and build array */
1151
  if ( !empty( $field->field_options ) ) {
1152
  if ( is_serialized( $field->field_options ) )
1153
  $opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
1154
  }
1155
- /* Otherwise, present some default options */
1156
  else
1157
  $opts_vals = array( 'Option 1', 'Option 2', 'Option 3' );
1158
 
1159
- /* Basic count to keep track of multiple options */
1160
  $count = 1;
1161
 
1162
- /* Loop through the options */
1163
  foreach ( $opts_vals as $options ) {
1164
  ?>
1165
  <div id="clone-<?php echo $field->field_id . '-' . $count; ?>" class="option">
@@ -1176,13 +1397,13 @@ class Visual_Form_Builder{
1176
  ?>
1177
  </p>
1178
  <?php
1179
- /* Unset the options for any following radio, checkboxes, or selects */
1180
  unset( $opts_vals );
1181
  endif;
1182
  ?>
1183
 
1184
  <?php
1185
- /* Display the Options input only for radio, checkbox, select, and autocomplete fields */
1186
  if ( in_array( $field->field_type, array( 'file-upload' ) ) ) :
1187
  ?>
1188
  <!-- File Upload Accepts -->
@@ -1190,13 +1411,13 @@ class Visual_Form_Builder{
1190
  <?php
1191
  $opts_vals = array( '' );
1192
 
1193
- /* If the options field isn't empty, unserialize and build array */
1194
  if ( !empty( $field->field_options ) ) {
1195
  if ( is_serialized( $field->field_options ) )
1196
  $opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : unserialize( $field->field_options );
1197
  }
1198
 
1199
- /* Loop through the options */
1200
  foreach ( $opts_vals as $options ) {
1201
  ?>
1202
  <label for="edit-form-item-options-<?php echo $field->field_id; ?>">
@@ -1208,7 +1429,7 @@ class Visual_Form_Builder{
1208
  </p>
1209
  <?php
1210
  }
1211
- /* Unset the options for any following radio, checkboxes, or selects */
1212
  unset( $opts_vals );
1213
  endif;
1214
  ?>
@@ -1347,7 +1568,7 @@ class Visual_Form_Builder{
1347
 
1348
  <?php if ( !in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) : ?>
1349
  <div class="menu-item-actions description-wide submitbox">
1350
- <a href="<?php echo esc_url( wp_nonce_url( admin_url('options-general.php?page=visual-form-builder&amp;action=delete_field&amp;form=' . $form_nav_selected_id . '&amp;field=' . $field->field_id ), 'delete-field-' . $form_nav_selected_id ) ); ?>" class="item-delete submitdelete deletion"><?php _e( 'Remove' , 'visual-form-builder'); ?></a>
1351
  </div>
1352
  <?php endif; ?>
1353
 
@@ -1356,7 +1577,7 @@ class Visual_Form_Builder{
1356
  <?php
1357
  endforeach;
1358
 
1359
- /* This assures all of the <ul> and <li> are closed */
1360
  if ( $depth > 1 ) {
1361
  while( $depth > 1 ) {
1362
  echo '</li>
@@ -1365,7 +1586,7 @@ class Visual_Form_Builder{
1365
  }
1366
  }
1367
 
1368
- /* Close out last item */
1369
  echo '</li>';
1370
  }
1371
 
@@ -1402,7 +1623,12 @@ class Visual_Form_Builder{
1402
  * @uses add_options_page() Creates a menu item under the Settings menu.
1403
  */
1404
  public function add_admin() {
1405
- add_options_page( __( 'Visual Form Builder', 'visual-form-builder' ), __( 'Visual Form Builder', 'visual-form-builder' ), 'manage_options', 'visual-form-builder', array( &$this, 'admin' ) );
 
 
 
 
 
1406
  }
1407
 
1408
  /**
@@ -1411,560 +1637,94 @@ class Visual_Form_Builder{
1411
  * @since 1.0
1412
  */
1413
  public function admin() {
1414
- global $wpdb, $entries_list, $entries_detail, $export;
1415
-
1416
- /* Set variables depending on which tab is selected */
1417
- $form_nav_selected_id = ( isset( $_REQUEST['form'] ) ) ? $_REQUEST['form'] : '0';
1418
- $action = ( isset( $_REQUEST['form'] ) && $_REQUEST['form'] !== '0' ) ? 'update_form' : 'create_form';
1419
- $details_meta = ( isset( $_REQUEST['details'] ) ) ? $_REQUEST['details'] : 'email';
1420
 
1421
- /* Query to get all forms */
1422
- $order = sanitize_sql_orderby( 'form_id DESC' );
1423
- $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name ORDER BY $order" ) );
1424
 
1425
- /* Loop through each form and assign a form id, if any */
1426
- foreach ( $forms as $form ) {
1427
- $form_id = ( $form_nav_selected_id == $form->form_id ) ? $form->form_id : '';
1428
-
1429
- /* If we are on a form, set the form name for the shortcode box */
1430
- if ( $form_nav_selected_id == $form->form_id )
1431
- $form_name = stripslashes( $form->form_title );
1432
- }
1433
 
 
 
1434
  ?>
1435
-
1436
- <div class="wrap">
1437
- <?php screen_icon( 'options-general' ); ?>
1438
- <h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1439
  <?php
1440
- _e('Visual Form Builder', 'visual-form-builder');
1441
- echo ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) && in_array( $_REQUEST['page'], array( 'visual-form-builder' ) ) ) ? '<span class="subtitle">' . sprintf( __( 'Search results for "%s"' , 'visual-form-builder'), $_REQUEST['s'] ) : '';
1442
  ?>
1443
- </h2>
1444
- <ul class="sub-navigation">
1445
- <li><a<?php echo ( !isset( $_REQUEST['view'] ) ) ? ' class="current"' : ''; ?> href="<?php echo admin_url( 'options-general.php?page=visual-form-builder' ); ?>"><?php _e( 'Forms' , 'visual-form-builder'); ?></a> |</li>
1446
- <li><a<?php echo ( isset( $_REQUEST['view'] ) && in_array( $_REQUEST['view'], array( 'entries' ) ) ) ? ' class="current"' : ''; ?> href="<?php echo add_query_arg( 'view', 'entries', admin_url( 'options-general.php?page=visual-form-builder' ) ); ?>"><?php _e( 'Entries' , 'visual-form-builder'); ?></a> |</li>
1447
- <li><a<?php echo ( isset( $_REQUEST['view'] ) && in_array( $_REQUEST['view'], array( 'export' ) ) ) ? ' class="current"' : ''; ?> href="<?php echo add_query_arg( 'view', 'export', admin_url( 'options-general.php?page=visual-form-builder' ) ); ?>"><?php _e( 'Export' , 'visual-form-builder'); ?></a></li>
1448
- </ul>
1449
-
1450
- <?php
1451
- /* Display the Entries */
1452
- if ( isset( $_REQUEST['view'] ) && in_array( $_REQUEST['view'], array( 'entries' ) ) ) :
1453
-
1454
- if ( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], array( 'view' ) ) ) :
1455
- $entries_detail->entries_detail();
1456
- else :
1457
- $entries_list->prepare_items();
1458
  ?>
1459
- <form id="entries-filter" method="post" action="">
1460
- <?php
1461
- $entries_list->search_box( 'search', 'search_id' );
1462
- $entries_list->display();
1463
- ?>
1464
- </form>
1465
- <?php
1466
- endif;
1467
- elseif ( isset( $_REQUEST['view'] ) && in_array( $_REQUEST['view'], array( 'export' ) ) ) :
1468
- $export->display();
1469
- /* Display the Forms */
1470
- else:
1471
- echo ( isset( $this->message ) ) ? $this->message : ''; ?>
1472
- <div id="nav-menus-frame">
1473
- <div id="menu-settings-column" class="metabox-holder<?php echo ( empty( $form_nav_selected_id ) ) ? ' metabox-holder-disabled' : ''; ?>">
1474
- <div id="side-sortables" class="metabox-holder">
1475
-
1476
- <form id="form-items" class="nav-menu-meta" method="post" action="">
1477
- <input name="action" type="hidden" value="create_field" />
1478
- <input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
1479
- <?php
1480
- /* Security nonce */
1481
- wp_nonce_field( 'create-field-' . $form_nav_selected_id );
1482
-
1483
- /* Disable the left box if there's no active form selected */
1484
- $disabled = ( empty( $form_nav_selected_id ) ) ? ' disabled="disabled"' : '';
1485
- ?>
1486
- <div class="postbox"><!-- Form Items -->
1487
- <h3 class="hndle"><span><?php _e( 'Form Items' , 'visual-form-builder'); ?></span></h3>
1488
- <div class="inside" >
1489
- <div class="taxonomydiv">
1490
- <p><strong><?php _e( 'Click' , 'visual-form-builder'); ?></strong> <?php _e( 'to Add a Field' , 'visual-form-builder'); ?> <img id="add-to-form" alt="" src="<?php echo admin_url( '/images/wpspin_light.gif' ); ?>" class="waiting" /></p>
1491
- <ul>
1492
- <li><input type="submit" id="form-element-fieldset" class="button-secondary" name="field_type" value="Fieldset"<?php echo $disabled; ?> /></li>
1493
- <li><input type="submit" id="form-element-section" class="button-secondary" name="field_type" value="Section"<?php echo $disabled; ?> /></li>
1494
- <li><input type="submit" id="form-element-text" class="button-secondary" name="field_type" value="Text"<?php echo $disabled; ?> /></li>
1495
- <li><input type="submit" id="form-element-textarea" class="button-secondary" name="field_type" value="Textarea"<?php echo $disabled; ?> /></li>
1496
- <li><input type="submit" id="form-element-checkbox" class="button-secondary" name="field_type" value="Checkbox"<?php echo $disabled; ?> /></li>
1497
- <li><input type="submit" id="form-element-radio" class="button-secondary" name="field_type" value="Radio"<?php echo $disabled; ?> /></li>
1498
- <li><input type="submit" id="form-element-select" class="button-secondary" name="field_type" value="Select"<?php echo $disabled; ?> /></li>
1499
- <li><input type="submit" id="form-element-address" class="button-secondary" name="field_type" value="Address"<?php echo $disabled; ?> /></li>
1500
- <li><input type="submit" id="form-element-datepicker" class="button-secondary" name="field_type" value="Date"<?php echo $disabled; ?> /></li>
1501
- <li><input type="submit" id="form-element-email" class="button-secondary" name="field_type" value="Email"<?php echo $disabled; ?> /></li>
1502
- <li><input type="submit" id="form-element-url" class="button-secondary" name="field_type" value="URL"<?php echo $disabled; ?> /></li>
1503
- <li><input type="submit" id="form-element-currency" class="button-secondary" name="field_type" value="Currency"<?php echo $disabled; ?> /></li>
1504
- <li><input type="submit" id="form-element-digits" class="button-secondary" name="field_type" value="Number"<?php echo $disabled; ?> /></li>
1505
- <li><input type="submit" id="form-element-time" class="button-secondary" name="field_type" value="Time"<?php echo $disabled; ?> /></li>
1506
- <li><input type="submit" id="form-element-phone" class="button-secondary" name="field_type" value="Phone"<?php echo $disabled; ?> /></li>
1507
- <li><input type="submit" id="form-element-html" class="button-secondary" name="field_type" value="HTML"<?php echo $disabled; ?> /></li>
1508
- <li><input type="submit" id="form-element-file" class="button-secondary" name="field_type" value="File Upload"<?php echo $disabled; ?> /></li>
1509
- <li><input type="submit" id="form-element-instructions" class="button-secondary" name="field_type" value="Instructions"<?php echo $disabled; ?> /></li>
1510
- </ul>
1511
- </div>
1512
- </div>
1513
- </div>
1514
- </form>
1515
- <div class="postbox"><!-- Form Output -->
1516
- <h3 class="hndle"><span><?php _e( 'Form Output' , 'visual-form-builder'); ?></span></h3>
1517
- <div class="inside">
1518
- <div id="customlinkdiv" class="customlinkdiv">
1519
- <p><?php _e( 'Copy this shortcode and paste into any Post or Page.' , 'visual-form-builder'); ?> <?php echo ( $form_nav_selected_id !== '0') ? "This will display the <strong>$form_name</strong> form." : ''; ?></p>
1520
- <p id="menu-item-url-wrap">
1521
- <form action="">
1522
- <label class="howto">
1523
- <span>Shortcode</span>
1524
- <input id="form-copy-to-clipboard" type="text" class="code menu-item-textbox" value="<?php echo ( $form_nav_selected_id !== '0') ? "[vfb id=$form_nav_selected_id]" : ''; ?>"<?php echo $disabled; ?> style="width:75%;" />
1525
- </label>
1526
- </form>
1527
- </p>
1528
- </div>
1529
- </div>
1530
- </div>
1531
- </div>
1532
- </div>
1533
-
1534
- <div id="menu-management-liquid">
1535
- <div id="menu-management">
1536
- <div class="nav-tabs-nav">
1537
- <div class="nav-tabs-arrow nav-tabs-arrow-left"><a>&laquo;</a></div><!-- Form Tab Nav - Left Arrow -->
1538
- <div class="nav-tabs-wrapper">
1539
- <div class="nav-tabs"><!-- Form Tabs -->
1540
- <?php
1541
- /* Loop through each for and build the tabs */
1542
- foreach ( $forms as $form ) {
1543
-
1544
- /* Control selected tab */
1545
- if ( $form_nav_selected_id == $form->form_id ) :
1546
- echo '<span class="nav-tab nav-tab-active">' . stripslashes( $form->form_title ) . '</span>';
1547
- $form_id = $form->form_id;
1548
- $form_title = stripslashes( $form->form_title );
1549
- $form_subject = stripslashes( $form->form_email_subject );
1550
- $form_email_from_name = stripslashes( $form->form_email_from_name );
1551
- $form_email_from = stripslashes( $form->form_email_from);
1552
- $form_email_from_override = stripslashes( $form->form_email_from_override);
1553
- $form_email_from_name_override = stripslashes( $form->form_email_from_name_override);
1554
- $form_email_to = ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) );
1555
- $form_success_type = stripslashes( $form->form_success_type );
1556
- $form_success_message = stripslashes( $form->form_success_message );
1557
- $form_notification_setting = stripslashes( $form->form_notification_setting );
1558
- $form_notification_email_name = stripslashes( $form->form_notification_email_name );
1559
- $form_notification_email_from = stripslashes( $form->form_notification_email_from );
1560
- $form_notification_email = stripslashes( $form->form_notification_email );
1561
- $form_notification_subject = stripslashes( $form->form_notification_subject );
1562
- $form_notification_message = stripslashes( $form->form_notification_message );
1563
- $form_notification_entry = stripslashes( $form->form_notification_entry );
1564
-
1565
- $form_label_alignment = stripslashes( $form->form_label_alignment );
1566
-
1567
- /* Only show required text fields for the sender name override */
1568
- $senders = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d AND field_type='text' AND field_validation = '' AND field_required = 'yes'", $form_nav_selected_id ) );
1569
-
1570
- /* Only show required email fields for the email override */
1571
- $emails = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE (form_id = $form_nav_selected_id AND field_type='text' AND field_validation = 'email' AND field_required = 'yes') OR (form_id = $form_nav_selected_id AND field_type='email' AND field_validation = 'email' AND field_required = 'yes')" ) );
1572
-
1573
- else :
1574
- echo '<a href="' . esc_url( add_query_arg( array( 'form' => $form->form_id ), admin_url( 'options-general.php?page=visual-form-builder' ) ) ) . '" class="nav-tab" id="' . $form->form_key . '">' . stripslashes( $form->form_title ) . '</a>';
1575
- endif;
1576
-
1577
- }
1578
-
1579
- /* Displays the build new form tab */
1580
- if ( '0' == $form_nav_selected_id ) :
1581
- ?>
1582
- <span class="nav-tab menu-add-new nav-tab-active"><?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add form' , 'visual-form-builder') ); ?></span>
1583
- <?php else : ?>
1584
- <a href="<?php echo esc_url( add_query_arg( array( 'form' => 0 ), admin_url( 'options-general.php?page=visual-form-builder' ) ) ); ?>" class="nav-tab menu-add-new"><?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add form' , 'visual-form-builder') ); ?></a>
1585
- <?php endif; ?>
1586
- </div>
1587
- </div>
1588
- <div class="nav-tabs-arrow nav-tabs-arrow-right"><a>&raquo;</a></div><!-- Form Tab Nav - Right Arrow -->
1589
- </div>
1590
-
1591
- <div class="menu-edit">
1592
- <form method="post" id="visual-form-builder-update" action="">
1593
- <input name="action" type="hidden" value="<?php echo $action; ?>" />
1594
- <input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
1595
- <?php wp_nonce_field( "$action-$form_nav_selected_id" ); ?>
1596
- <div id="nav-menu-header">
1597
- <div id="submitpost" class="submitbox">
1598
- <div class="major-publishing-actions">
1599
- <label for="form-name" class="menu-name-label howto open-label">
1600
- <span class="sender-labels"><?php _e( 'Form Name' , 'visual-form-builder'); ?></span>
1601
- <input type="text" value="<?php echo ( isset( $form_title ) ) ? $form_title : ''; ?>" placeholder="Enter form name here" class="menu-name regular-text menu-item-textbox required" id="form-name" name="form_title" />
1602
- </label>
1603
- <?php
1604
- /* Display sender details and confirmation message if we're on a form, otherwise just the form name */
1605
- if ( $form_nav_selected_id !== '0' ) :
1606
- ?>
1607
- <br class="clear" />
1608
-
1609
- <?php
1610
- /* Get the current user */
1611
- global $current_user;
1612
- get_currentuserinfo();
1613
-
1614
- /* Save current user ID */
1615
- $user_id = $current_user->ID;
1616
-
1617
- /* Get the Form Setting drop down and accordion settings, if any */
1618
- $user_form_settings = get_user_meta( $user_id, 'vfb-form-settings' );
1619
-
1620
- /* Setup defaults for the Form Setting tab and accordion */
1621
- $settings_tab = 'closed';
1622
- $settings_accordion = 'general-settings';
1623
-
1624
- /* Loop through the user_meta array */
1625
- foreach( $user_form_settings as $set ) {
1626
- /* If form settings exist for this form, use them instead of the defaults */
1627
- if ( isset( $set[ $form_id ] ) ) {
1628
- $settings_tab = $set[ $form_id ]['form_setting_tab'];
1629
- $settings_accordion = $set[ $form_id ]['setting_accordion'];
1630
- }
1631
- }
1632
-
1633
- /* If tab is opened, set current class */
1634
- $opened_tab = ( $settings_tab == 'opened' ) ? 'current' : '';
1635
- ?>
1636
-
1637
- <div class="button-group">
1638
- <a href="#form-settings" id="form-settings-button" class="vfb-button vfb-first <?php echo $opened_tab; ?>"><?php _e( 'Form Settings' , 'visual-form-builder'); ?><span class="button-icon arrow"></span></a>
1639
- <a href="<?php echo esc_url( wp_nonce_url( admin_url('options-general.php?page=visual-form-builder&amp;action=copy_form&amp;form=' . $form_nav_selected_id ), 'copy-form-' . $form_nav_selected_id ) ); ?>" class="vfb-button vfb-duplicate"><?php _e( 'Duplicate Form' , 'visual-form-builder'); ?><span class="button-icon plus"></span></a>
1640
- <a href="<?php echo esc_url( wp_nonce_url( admin_url('options-general.php?page=visual-form-builder&amp;action=delete_form&amp;form=' . $form_nav_selected_id ), 'delete-form-' . $form_nav_selected_id ) ); ?>" class="vfb-button vfb-delete vfb-last menu-delete"><?php _e( 'Delete Form' , 'visual-form-builder'); ?><span class="button-icon delete"></span></a>
1641
- </div>
1642
-
1643
- <div id="form-settings" class="<?php echo $opened_tab; ?>">
1644
- <!-- General settings section -->
1645
- <a href="#general-settings" class="settings-links<?php echo ( $settings_accordion == 'general-settings' ) ? ' on' : ''; ?>">1. General<span class="arrow"></span></a>
1646
- <div id="general-settings" class="form-details<?php echo ( $settings_accordion == 'general-settings' ) ? ' on' : ''; ?>">
1647
- <!-- Label Alignment -->
1648
- <p class="description description-wide">
1649
- <label for="form-label-alignment">
1650
- <?php _e( 'Label Alignment' , 'visual-form-builder'); ?>
1651
- <span class="vfb-tooltip" title="About Label Alignment" rel="Set the field labels for this form to be aligned either on top, to the left, or to the right. By default, all labels are aligned on top of the inputs.">(?)</span>
1652
- <br />
1653
- </label>
1654
- <select name="form_label_alignment" id="form-label-alignment" class="widefat">
1655
- <option value="" <?php selected( $form_label_alignment, '' ); ?>><?php _e( 'Top Aligned' , 'visual-form-builder'); ?></option>
1656
- <option value="left-label" <?php selected( $form_label_alignment, 'left-label' ); ?>><?php _e( 'Left Aligned' , 'visual-form-builder'); ?></option>
1657
- <option value="right-label" <?php selected( $form_label_alignment, 'right-label' ); ?>><?php _e( 'Right Aligned' , 'visual-form-builder'); ?></option>
1658
- </select>
1659
- </p>
1660
- <br class="clear" />
1661
- </div>
1662
-
1663
-
1664
- <!-- Email section -->
1665
- <a href="#email-details" class="settings-links<?php echo ( $settings_accordion == 'email-details' ) ? ' on' : ''; ?>">2. Email<span class="arrow"></span></a>
1666
- <div id="email-details" class="form-details<?php echo ( $settings_accordion == 'email-details' ) ? ' on' : ''; ?>">
1667
-
1668
- <p><em><?php _e( 'The forms you build here will send information to one or more email addresses when submitted by a user on your site. Use the fields below to customize the details of that email.' , 'visual-form-builder'); ?></em></p>
1669
-
1670
- <!-- E-mail Subject -->
1671
- <p class="description description-wide">
1672
- <label for="form-email-subject">
1673
- <?php _e( 'E-mail Subject' , 'visual-form-builder'); ?>
1674
- <span class="vfb-tooltip" title="About E-mail Subject" rel="This option sets the subject of the email that is sent to the emails you have set in the E-mail(s) To field.">(?)</span>
1675
- <br />
1676
- <input type="text" value="<?php echo stripslashes( $form_subject ); ?>" class="widefat" id="form-email-subject" name="form_email_subject" />
1677
- </label>
1678
- </p>
1679
- <br class="clear" />
1680
-
1681
- <!-- Sender Name -->
1682
- <p class="description description-thin">
1683
- <label for="form-email-sender-name">
1684
- <?php _e( 'Your Name or Company' , 'visual-form-builder'); ?>
1685
- <span class="vfb-tooltip" title="About Your Name or Company" rel="This option sets the From display name of the email that is sent to the emails you have set in the E-mail(s) To field.">(?)</span>
1686
- <br />
1687
- <input type="text" value="<?php echo $form_email_from_name; ?>" class="widefat" id="form-email-sender-name" name="form_email_from_name"<?php echo ( $form_email_from_name_override != '' ) ? ' readonly="readonly"' : ''; ?> />
1688
- </label>
1689
- </p>
1690
- <p class="description description-thin">
1691
- <label for="form_email_from_name_override">
1692
- <?php _e( "User's Name (optional)" , 'visual-form-builder'); ?>
1693
- <span class="vfb-tooltip" title="About User's Name" rel="Select a required text field from your form to use as the From display name in the email.">(?)</span>
1694
- <br />
1695
- <select name="form_email_from_name_override" id="form_email_from_name_override" class="widefat">
1696
- <option value="" <?php selected( $form_email_from_name_override, '' ); ?>><?php _e( 'Select a required text field' , 'visual-form-builder'); ?></option>
1697
- <?php
1698
- foreach( $senders as $sender ) {
1699
- echo '<option value="' . $sender->field_id . '"' . selected( $form_email_from_name_override, $sender->field_id ) . '>' . stripslashes( $sender->field_name ) . '</option>';
1700
- }
1701
- ?>
1702
- </select>
1703
- </label>
1704
- </p>
1705
- <br class="clear" />
1706
-
1707
- <!-- Sender E-mail -->
1708
- <p class="description description-thin">
1709
- <label for="form-email-sender">
1710
- <?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?>
1711
- <span class="vfb-tooltip" title="About Reply-To Email" rel="Manually set the email address that users will reply to.">(?)</span>
1712
- <br />
1713
- <input type="text" value="<?php echo $form_email_from; ?>" class="widefat" id="form-email-sender" name="form_email_from"<?php echo ( $form_email_from_override != '' ) ? ' readonly="readonly"' : ''; ?> />
1714
- </label>
1715
- </p>
1716
- <p class="description description-thin">
1717
- <label for="form_email_from_override">
1718
- <?php _e( "User's E-mail (optional)" , 'visual-form-builder'); ?>
1719
- <span class="vfb-tooltip" title="About User's Email" rel="Select a required email field from your form to use as the Reply-To email.">(?)</span>
1720
- <br />
1721
- <select name="form_email_from_override" id="form_email_from_override" class="widefat">
1722
- <option value="" <?php selected( $form_email_from_override, '' ); ?>><?php _e( 'Select a required email field' , 'visual-form-builder'); ?></option>
1723
- <?php
1724
- foreach( $emails as $email ) {
1725
- echo '<option value="' . $email->field_id . '"' . selected( $form_email_from_override, $email->field_id ) . '>' . stripslashes( $email->field_name ) . '</option>';
1726
- }
1727
- ?>
1728
- </select>
1729
- </label>
1730
- </p>
1731
- <br class="clear" />
1732
-
1733
- <!-- E-mail(s) To -->
1734
- <?php
1735
- /* Basic count to keep track of multiple options */
1736
- $count = 1;
1737
-
1738
- /* Loop through the options */
1739
- foreach ( $form_email_to as $email_to ) {
1740
- ?>
1741
- <div id="clone-email-<?php echo $count; ?>" class="option">
1742
- <p class="description description-wide">
1743
- <label for="form-email-to-<?php echo "$count"; ?>" class="clonedOption">
1744
- <?php _e( 'E-mail(s) To' , 'visual-form-builder'); ?>
1745
- <span class="vfb-tooltip" title="About E-mail(s) To" rel="This option sets single or multiple emails to send the submitted form data to. At least one email is required.">(?)</span>
1746
- <br />
1747
- <input type="text" value="<?php echo stripslashes( $email_to ); ?>" name="form_email_to[]" class="widefat" id="form-email-to-<?php echo "$count"; ?>" />
1748
- </label>
1749
-
1750
- <a href="#" class="addEmail" title="Add an Email">Add</a> <a href="#" class="deleteEmail" title="Delete Email">Delete</a>
1751
-
1752
- </p>
1753
- <br class="clear" />
1754
- </div>
1755
- <?php
1756
- $count++;
1757
- }
1758
- ?>
1759
- </div>
1760
-
1761
- <!-- Confirmation section -->
1762
- <a href="#confirmation" class="settings-links<?php echo ( $settings_accordion == 'confirmation' ) ? ' on' : ''; ?>">3. Confirmation<span class="arrow"></span></a>
1763
- <div id="confirmation-message" class="form-details<?php echo ( $settings_accordion == 'confirmation' ) ? ' on' : ''; ?>">
1764
- <p><em><?php _e( "After someone submits a form, you can control what is displayed. By default, it's a message but you can send them to another WordPress Page or a custom URL." , 'visual-form-builder'); ?></em></p>
1765
- <label for="form-success-type-text" class="menu-name-label open-label">
1766
- <input type="radio" value="text" id="form-success-type-text" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'text' ); ?> />
1767
- <span><?php _e( 'Text' , 'visual-form-builder'); ?></span>
1768
- </label>
1769
- <label for="form-success-type-page" class="menu-name-label open-label">
1770
- <input type="radio" value="page" id="form-success-type-page" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'page' ); ?>/>
1771
- <span><?php _e( 'Page' , 'visual-form-builder'); ?></span>
1772
- </label>
1773
- <label for="form-success-type-redirect" class="menu-name-label open-label">
1774
- <input type="radio" value="redirect" id="form-success-type-redirect" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'redirect' ); ?>/>
1775
- <span><?php _e( 'Redirect' , 'visual-form-builder'); ?></span>
1776
- </label>
1777
- <br class="clear" />
1778
- <p class="description description-wide">
1779
- <?php
1780
- $default_text = '';
1781
-
1782
- /* If there's no text message, make sure there is something displayed by setting a default */
1783
- if ( $form_success_message === '' )
1784
- $default_text = sprintf( '<p id="form_success">%s</p>', __( 'Your form was successfully submitted. Thank you for contacting us.' , 'visual-form-builder') );
1785
- ?>
1786
- <textarea id="form-success-message-text" class="form-success-message<?php echo ( 'text' == $form_success_type ) ? ' active' : ''; ?>" name="form_success_message_text"><?php echo $default_text; ?><?php echo ( 'text' == $form_success_type ) ? $form_success_message : ''; ?></textarea>
1787
-
1788
- <?php
1789
- /* Display all Pages */
1790
- wp_dropdown_pages( array(
1791
- 'name' => 'form_success_message_page',
1792
- 'id' => 'form-success-message-page',
1793
- 'class' => 'widefat',
1794
- 'show_option_none' => __( 'Select a Page' , 'visual-form-builder'),
1795
- 'selected' => $form_success_message
1796
- ));
1797
- ?>
1798
- <input type="text" value="<?php echo ( 'redirect' == $form_success_type ) ? $form_success_message : ''; ?>" id="form-success-message-redirect" class="form-success-message regular-text<?php echo ( 'redirect' == $form_success_type ) ? ' active' : ''; ?>" name="form_success_message_redirect" placeholder="http://" />
1799
- </p>
1800
- <br class="clear" />
1801
-
1802
- </div>
1803
-
1804
- <!-- Notification section -->
1805
- <a href="#notification" class="settings-links<?php echo ( $settings_accordion == 'notification' ) ? ' on' : ''; ?>">4. Notification<span class="arrow"></span></a>
1806
- <div id="notification" class="form-details<?php echo ( $settings_accordion == 'notification' ) ? ' on' : ''; ?>">
1807
- <p><em><?php _e( "When a user submits their entry, you can send a customizable notification email." , 'visual-form-builder'); ?></em></p>
1808
- <label for="form-notification-setting">
1809
- <input type="checkbox" value="1" id="form-notification-setting" class="form-notification" name="form_notification_setting" <?php checked( $form_notification_setting, '1' ); ?> style="margin-top:-1px;margin-left:0;"/>
1810
- <?php _e( 'Send Confirmation Email to User' , 'visual-form-builder'); ?>
1811
- </label>
1812
- <br class="clear" />
1813
- <div id="notification-email">
1814
- <p class="description description-wide">
1815
- <label for="form-notification-email-name">
1816
- <?php _e( 'Sender Name or Company' , 'visual-form-builder'); ?>
1817
- <span class="vfb-tooltip" title="About Sender Name or Company" rel="Enter the name you would like to use for the email notification.">(?)</span>
1818
- <br />
1819
- <input type="text" value="<?php echo $form_notification_email_name; ?>" class="widefat" id="form-notification-email-name" name="form_notification_email_name" />
1820
- </label>
1821
- </p>
1822
- <br class="clear" />
1823
- <p class="description description-wide">
1824
- <label for="form-notification-email-from">
1825
- <?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?>
1826
- <span class="vfb-tooltip" title="About Reply-To Email" rel="Manually set the email address that users will reply to.">(?)</span>
1827
- <br />
1828
- <input type="text" value="<?php echo $form_notification_email_from; ?>" class="widefat" id="form-notification-email-from" name="form_notification_email_from" />
1829
- </label>
1830
- </p>
1831
- <br class="clear" />
1832
- <p class="description description-wide">
1833
- <label for="form-notification-email">
1834
- <?php _e( 'E-mail To' , 'visual-form-builder'); ?>
1835
- <span class="vfb-tooltip" title="About E-mail To" rel="Select a required email field from your form to send the notification email to.">(?)</span>
1836
- <br />
1837
- <select name="form_notification_email" id="form-notification-email" class="widefat">
1838
- <option value="" <?php selected( $form_notification_email, '' ); ?>><?php _e( 'Select a required email field' , 'visual-form-builder'); ?></option>
1839
- <?php
1840
- foreach( $emails as $email ) {
1841
- echo '<option value="' . $email->field_id . '"' . selected( $form_notification_email, $email->field_id ) . '>' . $email->field_name . '</option>';
1842
- }
1843
- ?>
1844
- </select>
1845
- </label>
1846
- </p>
1847
- <br class="clear" />
1848
- <p class="description description-wide">
1849
- <label for="form-notification-subject">
1850
- <?php _e( 'E-mail Subject' , 'visual-form-builder'); ?>
1851
- <span class="vfb-tooltip" title="About E-mail Subject" rel="This option sets the subject of the email that is sent to the emails you have set in the E-mail To field.">(?)</span>
1852
- <br />
1853
- <input type="text" value="<?php echo $form_notification_subject; ?>" class="widefat" id="form-notification-subject" name="form_notification_subject" />
1854
- </label>
1855
- </p>
1856
- <br class="clear" />
1857
- <p class="description description-wide">
1858
- <label for="form-notification-message"><?php _e( 'Message' , 'visual-form-builder'); ?></label>
1859
- <span class="vfb-tooltip" title="About Message" rel="Insert a message to the user. This will be inserted into the beginning of the email body.">(?)</span>
1860
- <br />
1861
- <textarea id="form-notification-message" class="form-notification-message widefat" name="form_notification_message"><?php echo $form_notification_message; ?></textarea>
1862
- </p>
1863
- <br class="clear" />
1864
- <label for="form-notification-entry">
1865
- <input type="checkbox" value="1" id="form-notification-entry" class="form-notification" name="form_notification_entry" <?php checked( $form_notification_entry, '1' ); ?> style="margin-top:-1px;margin-left:0;"/>
1866
- <?php _e( "Include a Copy of the User's Entry" , 'visual-form-builder'); ?>
1867
- </label>
1868
- </div>
1869
- </div>
1870
- </div>
1871
- <?php endif; ?>
1872
-
1873
- <div class="publishing-action">
1874
- <input type="submit" value="<?php echo ( $action == 'create_form' ) ? __( 'Create Form' , 'visual-form-builder') : __( 'Save Form' , 'visual-form-builder'); ?>" class="button-primary menu-save" id="save_form" name="save_form" />
1875
- </div>
1876
- </div>
1877
- </div>
1878
- </div>
1879
- <div id="post-body">
1880
- <div id="post-body-content">
1881
- <?php if ( '0' == $form_nav_selected_id ) : ?>
1882
- <div class="post-body-plain">
1883
- <h3><?php _e( 'Getting Started' , 'visual-form-builder'); ?></h3>
1884
- <ol>
1885
- <li><?php _e( 'Enter a name in the Form Name input above and click Create Form.' , 'visual-form-builder'); ?></li>
1886
- <li><?php _e( 'Click form items from the Form Item box on the left to add to your form.' , 'visual-form-builder'); ?></li>
1887
- <li><?php _e( 'After adding an item, drag and drop to put them in the order you want.' , 'visual-form-builder'); ?></li>
1888
- <li><?php _e( 'Click the down arrow on each item to reveal configuration options.' , 'visual-form-builder'); ?></li>
1889
- <li><?php _e( 'Configure the Email Details section.' , 'visual-form-builder'); ?></li>
1890
- <li><?php _e( 'When you have finished building your form, click the Save Form button.' , 'visual-form-builder'); ?></li>
1891
- </ol>
1892
-
1893
- <h3><?php _e( 'Need more help?' , 'visual-form-builder'); ?></h3>
1894
- <ol>
1895
- <li><?php _e( 'Click on the Help tab at the top of this page.' , 'visual-form-builder'); ?></li>
1896
- <li><a href="http://wordpress.org/extend/plugins/visual-form-builder/faq/">Visual Form Builder FAQ</a></li>
1897
- <li><a href="http://wordpress.org/tags/visual-form-builder?forum_id=10">Visual Form Builder Support Forums</a></li>
1898
- </ol>
1899
-
1900
- <h3><?php _e( 'Help Promote Visual Form Builder' , 'visual-form-builder'); ?></h3>
1901
- <ul id="promote-vfb">
1902
- <li id="twitter"><?php _e( 'Follow me on Twitter' , 'visual-form-builder'); ?>: <a href="http://twitter.com/#!/matthewmuro">@matthewmuro</a></li>
1903
- <li id="star"><a href="http://wordpress.org/extend/plugins/visual-form-builder/"><?php _e( 'Rate Visual Form Builder on WordPress.org' , 'visual-form-builder'); ?></a></li>
1904
- <li id="paypal">
1905
- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9UN9CLPH4&lc=US&item_name=Visual%20Form%20Builder&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" width="74" height="21"></a>
1906
- </li>
1907
- </ul>
1908
- </div>
1909
- <div class="vfb-pro-upgrade"><!-- VFB Pro Upgrade -->
1910
- <h3>Upgrade to <a href="http://vfb.matthewmuro.com">Visual Form Builder Pro</a> for only $10</h3>
1911
- <p>Attention Visual Form Builder users! I am happy to announce <a href="http://vfb.matthewmuro.com">Visual Form Builder Pro</a>, available now for only <strong>$10</strong>.</p>
1912
- <h3><?php _e( 'New Features of Visual Form Builder Pro' , 'visual-form-builder'); ?></h3>
1913
- <ul>
1914
- <li><?php _e( 'Optional SPAM Verification' , 'visual-form-builder'); ?></li>
1915
- <li><?php _e( 'Drag and Drop to add new form fields' , 'visual-form-builder'); ?></li>
1916
- <li><?php _e( '10 new Form Fields (Username, Password, Color Picker, Autocomplete, Hidden, and more)' , 'visual-form-builder'); ?></li>
1917
- <li><?php _e( 'Edit and Update Entries' , 'visual-form-builder'); ?></li>
1918
- <li><?php _e( 'Import/Export forms, settings, and entries' , 'visual-form-builder'); ?></li>
1919
- <li><?php _e( 'Quality HTML Email Template' , 'visual-form-builder'); ?></li>
1920
- <li><?php _e( 'Plain Text Email Option' , 'visual-form-builder'); ?></li>
1921
- <li><?php _e( 'Email Designer' , 'visual-form-builder'); ?></li>
1922
- <li><?php _e( 'Analytics' , 'visual-form-builder'); ?></li>
1923
- <li><?php _e( 'Data &amp; Form Migration' , 'visual-form-builder'); ?></li>
1924
- <li><?php _e( 'PayPal Integration' , 'visual-form-builder'); ?></li>
1925
- <li><?php _e( 'Form Paging' , 'visual-form-builder'); ?></li>
1926
- <li><?php _e( 'Custom Capabilities' , 'visual-form-builder'); ?></li>
1927
- <li><?php _e( 'No License Key' , 'visual-form-builder'); ?></li>
1928
- <li><?php _e( 'Unlimited Use' , 'visual-form-builder'); ?></li>
1929
- <li><?php _e( 'Automatic Updates' , 'visual-form-builder'); ?></li>
1930
- </ul>
1931
-
1932
- <p><a href="http://matthewmuro.com/2012/02/07/introducing-visual-form-builder-pro/"><?php _e( 'Learn more about some of these features' , 'visual-form-builder'); ?></a>.</p>
1933
- <p class="vfb-pro-call-to-action"><a href="http://visualformbuilder.fetchapp.com/sell/dahdaeng"><span class="cta-sign-up"><?php _e( 'Buy Now' , 'visual-form-builder'); ?></span><span class="cta-price"><?php _e( 'Only $10' , 'visual-form-builder'); ?></span></a></p>
1934
- </div>
1935
- <?php else :
1936
-
1937
- if ( !empty( $form_nav_selected_id ) && $form_nav_selected_id !== '0' ) :
1938
- /* Display help text for adding fields */
1939
- printf( '<div class="post-body-plain" id="menu-instructions"><p>%s</p></div>', __( 'Note: to ensure your form displays and functions correctly, be sure a Fieldset is the first field.' , 'visual-form-builder') );
1940
-
1941
- /* Output the fields for each form */
1942
- echo '<ul id="menu-to-edit" class="menu ui-sortable droppable">';
1943
-
1944
- echo $this->field_output( $form_nav_selected_id );
1945
-
1946
- echo '</ul>';
1947
-
1948
- endif;
1949
- ?>
1950
-
1951
- <?php endif; ?>
1952
- </div>
1953
- <br class="clear" />
1954
- </div>
1955
- <div id="nav-menu-footer">
1956
- <div class="major-publishing-actions">
1957
- <div class="publishing-action">
1958
- <input type="submit" value="<?php echo ( $action == 'create_form' ) ? __( 'Create Form' , 'visual-form-builder') : __( 'Save Form' , 'visual-form-builder'); ?>" class="button-primary menu-save" id="save_form" name="save_form" />
1959
- </div>
1960
- </div>
1961
- </div>
1962
- </form>
1963
- </div>
1964
- </div>
1965
- </div>
1966
- </div>
1967
- </div>
1968
  <?php
1969
  endif;
1970
  }
@@ -1980,21 +1740,21 @@ class Visual_Form_Builder{
1980
  $form_id = ( isset( $_REQUEST['form_id'] ) ) ? $_REQUEST['form_id'] : '';
1981
 
1982
  if ( isset( $_REQUEST['visual-form-builder-submit'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'visual-form-builder-nonce' ) ) {
1983
- /* Get forms */
1984
  $order = sanitize_sql_orderby( 'form_id DESC' );
1985
  $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
1986
 
1987
  foreach ( $forms as $form ) {
1988
- /* If text, return output and format the HTML for display */
1989
  if ( 'text' == $form->form_success_type )
1990
  return stripslashes( html_entity_decode( wp_kses_stripslashes( $form->form_success_message ) ) );
1991
- /* If page, redirect to the permalink */
1992
  elseif ( 'page' == $form->form_success_type ) {
1993
  $page = get_permalink( $form->form_success_message );
1994
  wp_redirect( $page );
1995
  exit();
1996
  }
1997
- /* If redirect, redirect to the URL */
1998
  elseif ( 'redirect' == $form->form_success_type ) {
1999
  wp_redirect( $form->form_success_message );
2000
  exit();
@@ -2011,7 +1771,7 @@ class Visual_Form_Builder{
2011
  public function form_code( $atts ) {
2012
  global $wpdb;
2013
 
2014
- /* Extract shortcode attributes, set defaults */
2015
  extract( shortcode_atts( array(
2016
  'id' => ''
2017
  ), $atts )
@@ -2021,16 +1781,16 @@ class Visual_Form_Builder{
2021
  if ( !$this->add_scripts )
2022
  $this->scripts();
2023
 
2024
- /* Get form id. Allows use of [vfb id=1] or [vfb 1] */
2025
- $form_id = ( isset( $id ) && !empty( $id ) ) ? $id : $atts[0];
2026
 
2027
  $open_fieldset = $open_section = false;
2028
  $output = '';
2029
 
2030
- /* Default the submit value */
2031
  $submit = 'Submit';
2032
 
2033
- /* If form is submitted, show success message, otherwise the form */
2034
  if ( isset( $_REQUEST['visual-form-builder-submit'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'visual-form-builder-nonce' ) && isset( $_REQUEST['form_id'] ) && $_REQUEST['form_id'] == $form_id ) {
2035
  $output = $this->confirmation();
2036
  }
@@ -2043,19 +1803,19 @@ class Visual_Form_Builder{
2043
  $order_fields = sanitize_sql_orderby( 'field_sequence ASC' );
2044
  $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d ORDER BY $order_fields", $form_id ) );
2045
 
2046
- /* Setup count for fieldset and ul/section class names */
2047
  $count = 1;
2048
 
2049
  $verification = '';
2050
 
2051
  foreach ( $forms as $form ) :
2052
  $label_alignment = ( $form->form_label_alignment !== '' ) ? " $form->form_label_alignment" : '';
2053
- $output = '<form id="' . $form->form_key . '" class="visual-form-builder' . $label_alignment . '" method="post" enctype="multipart/form-data">
2054
  <input type="hidden" name="form_id" value="' . $form->form_id . '" />';
2055
  $output .= wp_nonce_field( 'visual-form-builder-nonce', '_wpnonce', false, false );
2056
 
2057
  foreach ( $fields as $field ) {
2058
- /* If field is required, build the span and add setup the 'required' class */
2059
  $required_span = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' <span>*</span>' : '';
2060
  $required = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' required' : '';
2061
  $validation = ( !empty( $field->field_validation ) ) ? " $field->field_validation" : '';
@@ -2064,16 +1824,16 @@ class Visual_Form_Builder{
2064
  $layout = ( !empty( $field->field_layout ) ) ? " $field->field_layout" : '';
2065
  $default = ( !empty( $field->field_default ) ) ? html_entity_decode( stripslashes( $field->field_default ) ) : '';
2066
 
2067
- /* Close each section */
2068
  if ( $open_section == true ) {
2069
- /* If this field's parent does NOT equal our section ID */
2070
  if ( $sec_id && $sec_id !== $field->field_parent ) {
2071
  $output .= '</div><div class="vfb-clear"></div>';
2072
  $open_section = false;
2073
  }
2074
  }
2075
 
2076
- /* Force an initial fieldset and display an error message to strongly encourage user to add one */
2077
  if ( $count === 1 && $field->field_type !== 'fieldset' ) {
2078
  $output .= '<fieldset class="fieldset"><div class="legend" style="background-color:#FFEBE8;border:1px solid #CC0000;"><h3>Oops! Missing Fieldset</h3><p style="color:black;">If you are seeing this message, it means you need to <strong>add a Fieldset to the beginning of your form</strong>. Your form may not function or display properly without one.</p></div><ul class="section section-' . $count . '">';
2079
 
@@ -2081,7 +1841,7 @@ class Visual_Form_Builder{
2081
  }
2082
 
2083
  if ( $field->field_type == 'fieldset' ) {
2084
- /* Close each fieldset */
2085
  if ( $open_fieldset == true )
2086
  $output .= '</ul><br /></fieldset>';
2087
 
@@ -2092,7 +1852,7 @@ class Visual_Form_Builder{
2092
  elseif ( $field->field_type == 'section' ) {
2093
  $output .= '<div class="section-div vfb-' . esc_html( $field->field_key ) . '-' . $field->field_id . '"><h4>' . stripslashes( $field->field_name ) . '</h4>';
2094
 
2095
- /* Save section ID for future comparison */
2096
  $sec_id = $field->field_id;
2097
  $open_section = true;
2098
  }
@@ -2110,28 +1870,28 @@ class Visual_Form_Builder{
2110
  $verification .= '<fieldset class="fieldset fieldset-' . $count . ' ' . $field->field_key . $css . '"><div class="legend"><h3>' . stripslashes( $field->field_name ) . '</h3></div><ul class="section section-' . $count . '">';
2111
 
2112
  if ( $field->field_type == 'secret' ) {
2113
- /* Default logged in values */
2114
  $logged_in_display = '';
2115
  $logged_in_value = '';
2116
 
2117
- /* If the user is logged in, fill the field in for them */
2118
  if ( is_user_logged_in() ) {
2119
- /* Hide the secret field if logged in */
2120
  $logged_in_display = ' style="display:none;"';
2121
  $logged_in_value = 14;
2122
 
2123
- /* Get logged in user details */
2124
  $user = wp_get_current_user();
2125
  $user_identity = ! empty( $user->ID ) ? $user->display_name : '';
2126
 
2127
- /* Display a message for logged in users */
2128
  $verification .= '<li class="item">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. Verification not required.', 'visual-form-builder' ), admin_url( 'profile.php' ), $user_identity ) . '</li>';
2129
  }
2130
 
2131
  $validation = ' {digits:true,maxlength:2,minlength:2}';
2132
  $verification .= '<li class="item item-' . $field->field_type . '"' . $logged_in_display . '><label for="' . $id_attr . '" class="desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
2133
 
2134
- /* Set variable for testing if required is Yes/No */
2135
  if ( $required == '' )
2136
  $verification .= '<input type="hidden" name="_vfb-required-secret" value="0" />';
2137
 
@@ -2178,7 +1938,7 @@ class Visual_Form_Builder{
2178
 
2179
  $options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
2180
 
2181
- /* Loop through each option and output */
2182
  foreach ( $options as $option => $value ) {
2183
  $output .= '<option value="' . trim( stripslashes( $value ) ) . '"' . selected( $default, ++$option, 0 ) . '>'. trim( stripslashes( $value ) ) . '</option>';
2184
  }
@@ -2196,7 +1956,7 @@ class Visual_Form_Builder{
2196
 
2197
  $output .= '<div>';
2198
 
2199
- /* Loop through each option and output */
2200
  foreach ( $options as $option => $value ) {
2201
  // Increment the base index by one to match $default
2202
  $option++;
@@ -2220,7 +1980,7 @@ class Visual_Form_Builder{
2220
 
2221
  $output .= '<div>';
2222
 
2223
- /* Loop through each option and output */
2224
  foreach ( $options as $option => $value ) {
2225
  // Increment the base index by one to match $default
2226
  $option++;
@@ -2289,37 +2049,37 @@ class Visual_Form_Builder{
2289
  if ( !empty( $field->field_description ) )
2290
  $output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
2291
 
2292
- /* Get the time format (12 or 24) */
2293
  $time_format = str_replace( 'time-', '', $validation );
2294
  $time_format = apply_filters( 'vfb_time_format', $time_format );
2295
 
2296
- /* Set whether we start with 0 or 1 and how many total hours */
2297
  $hour_start = ( $time_format == '12' ) ? 1 : 0;
2298
  $hour_total = ( $time_format == '12' ) ? 12 : 23;
2299
 
2300
- /* Hour */
2301
  $output .= '<span class="time"><select name="vfb-' . $field->field_id . '[hour]" id="' . $id_attr . '-hour" class="select' . $required . $css . '">';
2302
  for ( $i = $hour_start; $i <= $hour_total; $i++ ) {
2303
- /* Add the leading zero */
2304
  $hour = ( $i < 10 ) ? "0$i" : $i;
2305
  $output .= "<option value='$hour'>$hour</option>";
2306
  }
2307
  $output .= '</select><label for="' . $id_attr . '-hour">HH</label></span>';
2308
 
2309
- /* Minute */
2310
  $output .= '<span class="time"><select name="vfb-' . $field->field_id . '[min]" id="' . $id_attr . '-min" class="select' . $required . $css . '">';
2311
 
2312
- $total_mins = apply_filters( 'vfb_time_min_total', 55 );
2313
- $min_interval = apply_filters( 'vfb_time_min_interval', 5 );
2314
 
2315
  for ( $i = 0; $i <= $total_mins; $i += $min_interval ) {
2316
- /* Add the leading zero */
2317
  $min = ( $i < 10 ) ? "0$i" : $i;
2318
  $output .= "<option value='$min'>$min</option>";
2319
  }
2320
  $output .= '</select><label for="' . $id_attr . '-min">MM</label></span>';
2321
 
2322
- /* AM/PM */
2323
  if ( $time_format == '12' )
2324
  $output .= '<span class="time"><select name="vfb-' . $field->field_id . '[ampm]" id="' . $id_attr . '-ampm" class="select' . $required . $css . '"><option value="AM">AM</option><option value="PM">PM</option></select><label for="' . $id_attr . '-ampm">AM/PM</label></span>';
2325
  $output .= '<div class="clear"></div>';
@@ -2364,15 +2124,15 @@ class Visual_Form_Builder{
2364
  echo '';
2365
  }
2366
 
2367
- /* Closing </li> */
2368
  $output .= ( !in_array( $field->field_type , array( 'verification', 'secret', 'submit', 'fieldset', 'section' ) ) ) ? '</li>' : '';
2369
  }
2370
 
2371
 
2372
- /* Close user-added fields */
2373
  $output .= '</ul><br /></fieldset>';
2374
 
2375
- /* Make sure the verification displays even if they have not updated their form */
2376
  if ( $verification == '' ) {
2377
  $verification = '<fieldset class="fieldset verification">
2378
  <div class="legend">
@@ -2387,7 +2147,7 @@ class Visual_Form_Builder{
2387
  </li>';
2388
  }
2389
 
2390
- /* Output our security test */
2391
  $output .= $verification . '<li style="display:none;">
2392
  <label for="vfb-spam">' . __( 'This box is for spam protection' , 'visual-form-builder') . ' - <strong>' . __( 'please leave it blank' , 'visual-form-builder') . '</strong>:</label>
2393
  <div>
@@ -2399,7 +2159,7 @@ class Visual_Form_Builder{
2399
  <input type="submit" name="visual-form-builder-submit" value="' . $submit . '" class="submit" id="sendmail" />
2400
  </li>
2401
  </ul>
2402
- </fieldset></form>';
2403
 
2404
  endforeach;
2405
  }
@@ -2416,9 +2176,9 @@ class Visual_Form_Builder{
2416
  public function email() {
2417
  global $wpdb, $post;
2418
 
2419
- $required = ( isset( $_REQUEST['_vfb-required-secret'] ) && $_REQUEST['_vfb-required-secret'] == '0' ) ? false : true;
2420
- $secret_field = ( isset( $_REQUEST['_vfb-secret'] ) ) ? $_REQUEST['_vfb-secret'] : '';
2421
- $honeypot = ( isset( $_REQUEST['vfb-spam'] ) ) ? $_REQUEST['vfb-spam'] : '';
2422
 
2423
  // If the verification is set to required, run validation check
2424
  if ( true == $required && !empty( $secret_field ) ) {
@@ -2478,7 +2238,7 @@ class Visual_Form_Builder{
2478
  // Notification send to email override query
2479
  $notification = $wpdb->get_results( $wpdb->prepare( "SELECT fields.field_id, fields.field_key FROM $this->form_table_name AS forms LEFT JOIN $this->field_table_name AS fields ON forms.form_notification_email = fields.field_id WHERE forms.form_id = %d", $form_id ) );
2480
 
2481
- $reply_to_name = $form_settings->form_from_name;
2482
  $reply_to_email = $form_settings->form_from;
2483
 
2484
  // Loop through name results and assign sender name to override, if needed
@@ -2503,17 +2263,17 @@ class Visual_Form_Builder{
2503
  $copy_email = $_POST[ 'vfb-' . $notify->field_id ];
2504
  }
2505
 
2506
- /* Query to get all forms */
2507
  $order = sanitize_sql_orderby( 'field_sequence ASC' );
2508
  $fields = $wpdb->get_results( $wpdb->prepare( "SELECT field_id, field_key, field_name, field_type, field_options, field_parent, field_required FROM $this->field_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
2509
 
2510
- /* Setup counter for alt rows */
2511
  $i = $points = 0;
2512
 
2513
- /* Setup HTML email vars */
2514
  $header = $body = $message = $footer = $html_email = $auto_response_email = $attachments = '';
2515
 
2516
- /* Prepare the beginning of the content */
2517
  $header = '<html>
2518
  <head>
2519
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
@@ -2521,68 +2281,68 @@ class Visual_Form_Builder{
2521
  </head>
2522
  <body><table rules="all" style="border-color: #666;" cellpadding="10">' . "\n";
2523
 
2524
- /* Loop through each form field and build the body of the message */
2525
  foreach ( $fields as $field ) {
2526
- /* Handle attachments */
2527
  if ( $field->field_type == 'file-upload' ) {
2528
  $value = ( isset( $_FILES[ 'vfb-' . $field->field_id ] ) ) ? $_FILES[ 'vfb-' . $field->field_id ] : '';
2529
 
2530
  if ( $value['size'] > 0 ) {
2531
- /* 25MB is the max size allowed */
2532
  $size = apply_filters( 'vfb_max_file_size', 25 );
2533
  $max_attach_size = $size * 1048576;
2534
 
2535
- /* Display error if file size has been exceeded */
2536
  if ( $value['size'] > $max_attach_size )
2537
  wp_die( __( 'File size exceeds 25MB. Most email providers will reject emails with attachments larger than 25MB. Please decrease the file size and try again.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
2538
 
2539
- /* Options array for the wp_handle_upload function. 'test_form' => false */
2540
  $upload_overrides = array( 'test_form' => false );
2541
 
2542
- /* We need to include the file that runs the wp_handle_upload function */
2543
  require_once( ABSPATH . 'wp-admin/includes/file.php' );
2544
 
2545
- /* Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array */
2546
  $uploaded_file = wp_handle_upload( $value, $upload_overrides );
2547
 
2548
- /* If the wp_handle_upload call returned a local path for the image */
2549
  if ( isset( $uploaded_file['file'] ) ) {
2550
- /* Retrieve the file type from the file name. Returns an array with extension and mime type */
2551
  $wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );
2552
 
2553
- /* Return the current upload directory location */
2554
  $wp_upload_dir = wp_upload_dir();
2555
 
2556
  $media_upload = array(
2557
- 'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $uploaded_file['file'] ),
2558
- 'post_mime_type' => $wp_filetype['type'],
2559
- 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $uploaded_file['file'] ) ),
2560
- 'post_content' => '',
2561
- 'post_status' => 'inherit'
2562
  );
2563
 
2564
- /* Insert attachment into Media Library and get attachment ID */
2565
  $attach_id = wp_insert_attachment( $media_upload, $uploaded_file['file'] );
2566
 
2567
- /* Include the file that runs wp_generate_attachment_metadata() */
2568
  require_once( ABSPATH . 'wp-admin/includes/image.php' );
2569
 
2570
- /* Setup attachment metadata */
2571
  $attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_file['file'] );
2572
 
2573
- /* Update the attachment metadata */
2574
  wp_update_attachment_metadata( $attach_id, $attach_data );
2575
 
2576
  $attachments[ 'vfb-' . $field->field_id ] = $uploaded_file['file'];
2577
 
2578
  $data[] = array(
2579
- 'id' => $field->field_id,
2580
- 'slug' => $field->field_key,
2581
- 'name' => $field->field_name,
2582
- 'type' => $field->field_type,
2583
- 'options' => $field->field_options,
2584
  'parent_id' => $field->field_parent,
2585
- 'value' => $uploaded_file['url']
2586
  );
2587
 
2588
  $body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td><a href="' . $uploaded_file['url'] . '">' . $uploaded_file['url'] . '</a></td></tr>' . "\n";
@@ -2593,14 +2353,14 @@ class Visual_Form_Builder{
2593
  $body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td>' . $value . '</td></tr>' . "\n";
2594
  }
2595
  }
2596
- /* Everything else */
2597
  else {
2598
  $value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
2599
 
2600
- /* If time field, build proper output */
2601
  if ( is_array( $value ) && array_key_exists( 'hour', $value ) && array_key_exists( 'min', $value ) )
2602
  $value = ( array_key_exists( 'ampm', $value ) ) ? substr_replace( implode( ':', $value ), ' ', 5, 1 ) : implode( ':', $value );
2603
- /* If address field, build proper output */
2604
  elseif ( is_array( $value ) && array_key_exists( 'address', $value ) && array_key_exists( 'address-2', $value ) ) {
2605
  $address = '';
2606
 
@@ -2640,19 +2400,19 @@ class Visual_Form_Builder{
2640
 
2641
  $value = html_entity_decode( stripslashes( esc_html( $address ) ), ENT_QUOTES, 'UTF-8' );
2642
  }
2643
- /* If multiple values, build the list */
2644
  elseif ( is_array( $value ) )
2645
- $value = implode( ', ', $value );
2646
- /* Lastly, handle single values */
2647
  else
2648
  $value = html_entity_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES, 'UTF-8' );
2649
 
2650
- /* Setup spam catcher RegEx */
2651
- $exploits = '/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i';
2652
- $profanity = '/(beastial|bestial|blowjob|clit|cock|cum|cunilingus|cunillingus|cunnilingus|cunt|ejaculate|fag|felatio|fellatio|fuck|fuk|fuks|gangbang|gangbanged|gangbangs|hotsex|jism|jiz|kock|kondum|kum|kunilingus|orgasim|orgasims|orgasm|orgasms|phonesex|phuk|phuq|porn|pussies|pussy|spunk|xxx)/i';
2653
- $spamwords = '/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i';
2654
 
2655
- /* Add up points for each spam hit */
2656
  if ( preg_match( $exploits, $value ) )
2657
  $points += 2;
2658
  elseif ( preg_match( $profanity, $value ) )
@@ -2660,10 +2420,12 @@ class Visual_Form_Builder{
2660
  elseif ( preg_match( $spamwords, $value ) )
2661
  $points += 1;
2662
 
 
 
 
2663
  // Validate input
2664
  $this->validate_input( $value, $field->field_name, $field->field_type, $field->field_required );
2665
 
2666
- //if ( $field->field_type !== 'submit' ) {
2667
  if ( !in_array( $field->field_type , array( 'verification', 'secret', 'submit' ) ) ) {
2668
  if ( $field->field_type == 'fieldset' )
2669
  $body .= '<tr style="background-color:#393E40;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
@@ -2674,97 +2436,77 @@ class Visual_Form_Builder{
2674
  }
2675
 
2676
  $data[] = array(
2677
- 'id' => $field->field_id,
2678
- 'slug' => $field->field_key,
2679
- 'name' => $field->field_name,
2680
- 'type' => $field->field_type,
2681
- 'options' => $field->field_options,
2682
  'parent_id' => $field->field_parent,
2683
- 'value' => $value
2684
  );
2685
  }
2686
  }
2687
 
2688
- /* Setup our entries data */
2689
  $entry = array(
2690
- 'form_id' => $form_id,
2691
- 'data' => serialize( $data ),
2692
- 'subject' => $form_settings->form_subject,
2693
- 'sender_name' => $form_settings->form_from_name,
2694
- 'sender_email' => $form_settings->form_from,
2695
- 'emails_to' => serialize( $form_settings->form_to ),
2696
- 'date_submitted' => date_i18n( 'Y-m-d G:i:s' ),
2697
- 'ip_address' => $_SERVER['REMOTE_ADDR']
2698
  );
2699
 
2700
- /* Insert this data into the entries table */
2701
  $wpdb->insert( $this->entries_table_name, $entry );
2702
 
2703
- /* Close out the content */
2704
  $footer .= '<tr><td class="footer" height="61" align="left" valign="middle" colspan="2"><p style="font-size: 12px; font-weight: normal; margin: 0; line-height: 16px; padding: 0;">This email was built and sent using <a href="http://wordpress.org/extend/plugins/visual-form-builder/" style="font-size: 12px;">Visual Form Builder</a>.</p></td></tr></table></body></html>' . "\n";
2705
 
2706
- /* Build complete HTML email */
2707
  $message = $header . $body . $footer;
2708
 
2709
- /* Initialize header filter vars */
2710
- $this->header_from_name = stripslashes( $form_settings->form_from_name );
2711
- $this->header_from = $form_settings->form_from;
2712
- $this->header_content_type = 'text/html';
2713
 
2714
- /* Set wp_mail header filters to send an HTML email */
2715
- add_filter( 'wp_mail_from_name', array( &$this, 'mail_header_from_name' ) );
2716
- add_filter( 'wp_mail_from', array( &$this, 'mail_header_from' ) );
2717
- add_filter( 'wp_mail_content_type', array( &$this, 'mail_header_content_type' ) );
2718
 
2719
- /* Setup headers */
2720
- $from_name = ( $this->header_from_name == '' ) ? 'WordPress' : $this->header_from_name;
2721
- $from_email = 'wordpress@' . $_SERVER['SERVER_NAME'];
2722
- $reply_to = "\"$this->header_from_name\" <$this->header_from>";
2723
- $headers = "From: \"$from_name\" <$from_email>\n" . "Reply-To: $reply_to\n" . "Content-Type: $this->header_content_type; charset=\"" . get_option('blog_charset') . "\"\n";
2724
 
2725
- /* Send the mail */
2726
- foreach ( $form_settings->form_to as $email ) {
2727
- wp_mail( $email, esc_html( $form_settings->form_subject ), $message, $headers, $attachments );
2728
- }
2729
 
2730
- /* Kill the values stored for header name and email */
2731
- unset( $this->header_from_name );
2732
- unset( $this->header_from );
 
 
2733
 
2734
- /* Remove wp_mail header filters in case we need to override for notifications */
2735
- remove_filter( 'wp_mail_from_name', array( &$this, 'mail_header_from_name' ) );
2736
- remove_filter( 'wp_mail_from', array( &$this, 'mail_header_from' ) );
 
2737
 
2738
- /* Send auto-responder email */
2739
  if ( $form_settings->form_notification_setting !== '' ) :
2740
 
2741
- /* Assign notify header filter vars */
2742
- $this->header_from_name = stripslashes( $form_settings->form_notification_email_name );
2743
- $this->header_from = $form_settings->form_notification_email_from;
2744
-
2745
- /* Set the wp_mail header filters for notification email */
2746
- add_filter( 'wp_mail_from_name', array( &$this, 'mail_header_from_name' ) );
2747
- add_filter( 'wp_mail_from', array( &$this, 'mail_header_from' ) );
2748
-
2749
  $attachments = ( $form_settings->form_notification_entry !== '' ) ? $attachments : '';
2750
 
2751
- /* Decode HTML for message so it outputs properly */
2752
- $notify_message = ( $form_settings->form_notification_message !== '' ) ? html_entity_decode( $form_settings->form_notification_message ) : '';
2753
-
2754
- /* Either prepend the notification message to the submitted entry, or send by itself */
2755
- if ( $form_settings->form_notification_entry !== '' )
2756
- $auto_response_email = $header . '<p style="font-size: 12px; font-weight: normal; margin: 14px 0 14px 0; color: black; padding: 0;">' . $notify_message . '</p>' . $body . $footer;
2757
- else
2758
- $auto_response_email = $header . '<table cellspacing="0" border="0" cellpadding="0" width="100%"><tr><td colspan="2" class="mainbar" align="left" valign="top" width="600"><p style="font-size: 12px; font-weight: normal; margin: 14px 0 14px 0; color: black; padding: 0;">' . $notify_message . '</p></td></tr>' . $footer;
2759
-
2760
  // Reset headers for notification email
2761
- $from_name = ( $this->header_from_name == '' ) ? 'WordPress' : $this->header_from_name;
2762
- $from_email = 'wordpress@' . $_SERVER['SERVER_NAME'];
2763
- $reply_to = "\"$this->header_from_name\" <$this->header_from>";
2764
- $headers = "From: \"$from_name\" <$from_email>\n" . "Reply-To: $reply_to\n" . "Content-Type: $this->header_content_type; charset=\"" . get_option('blog_charset') . "\"\n";
2765
 
2766
- /* Send the mail */
2767
- wp_mail( $copy_email, esc_html( $form_settings->form_notification_subject ), $auto_response_email, $headers, $attachments );
2768
  endif;
2769
 
2770
  endif;
@@ -2778,32 +2520,32 @@ class Visual_Form_Builder{
2778
  public function validate_input( $data, $name, $type, $required ) {
2779
 
2780
  if ( 'yes' == $required && strlen( $data ) == 0 )
2781
- wp_die( "<h1>$name</h1><br>" . __( 'This field is required and cannot be empty.', 'visual-form-builder-pro' ), $name, array( 'back_link' => true ) );
2782
 
2783
  if ( strlen( $data ) > 0 ) :
2784
  switch( $type ) {
2785
 
2786
  case 'email' :
2787
  if ( !is_email( $data ) )
2788
- wp_die( "<h1>$name</h1><br>" . __( 'Not a valid email address', 'visual-form-builder-pro' ), '', array( 'back_link' => true ) );
2789
  break;
2790
 
2791
  case 'number' :
2792
  case 'currency' :
2793
  if ( !is_numeric( $data ) )
2794
- wp_die( "<h1>$name</h1><br>" . __( 'Not a valid number', 'visual-form-builder-pro' ), '', array( 'back_link' => true ) );
2795
  break;
2796
 
2797
  case 'phone' :
2798
  if ( strlen( $data ) > 9 && preg_match( '/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/', $data ) )
2799
  return true;
2800
  else
2801
- wp_die( "<h1>$name</h1><br>" . __( 'Not a valid phone number. Most US/Canada and International formats accepted.', 'visual-form-builder-pro' ), '', array( 'back_link' => true ) );
2802
  break;
2803
 
2804
  case 'url' :
2805
  if ( !preg_match( '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $data ) )
2806
- wp_die( "<h1>$name</h1><br>" . __( 'Not a valid URL.', 'visual-form-builder-pro' ), '', array( 'back_link' => true ) );
2807
  break;
2808
 
2809
  default :
@@ -2812,6 +2554,37 @@ class Visual_Form_Builder{
2812
  }
2813
  endif;
2814
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2815
 
2816
  /**
2817
  * Make sure the User Agent string is not a SPAM bot
@@ -2832,36 +2605,9 @@ class Visual_Form_Builder{
2832
  $isBot = true;
2833
 
2834
  return $isBot;
2835
- }
2836
-
2837
- /**
2838
- * Set the wp_mail_from_name
2839
- *
2840
- * @since 1.7
2841
- */
2842
- public function mail_header_from_name() {
2843
- return $this->header_from_name;
2844
- }
2845
-
2846
- /**
2847
- * Set the wp_mail_from
2848
- *
2849
- * @since 1.7
2850
- */
2851
- public function mail_header_from() {
2852
- return $this->header_from;
2853
- }
2854
-
2855
- /**
2856
- * Set the wp_mail_content_type
2857
- *
2858
- * @since 1.7
2859
- */
2860
- public function mail_header_content_type() {
2861
- return $this->header_content_type;
2862
- }
2863
  }
2864
 
2865
- /* On plugin activation, install the databases and add/update the DB version */
2866
  register_activation_hook( __FILE__, array( 'Visual_Form_Builder', 'install_db' ) );
2867
  ?>
4
  Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
5
  Author: Matthew Muro
6
  Author URI: http://matthewmuro.com
7
+ Version: 2.6
8
  */
9
 
10
  /*
25
  // Set to true to load uncompressed and unminified scripts and stylesheets
26
  define( 'VFB_SCRIPT_DEBUG', false );
27
 
28
+ // Instantiate new class
29
  $visual_form_builder = new Visual_Form_Builder();
30
 
31
+ // Visual Form Builder class
32
  class Visual_Form_Builder{
33
 
34
+ protected $vfb_db_version = '2.6',
35
  $add_scripts = false;
36
 
37
  public $countries = array( "", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States of America", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe" );
39
  public function __construct(){
40
  global $wpdb;
41
 
42
+ // Setup global database table names
43
+ $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
44
+ $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
45
+ $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
46
 
47
  // Add suffix to load dev files
48
  $this->load_dev_files = ( defined( 'VFB_SCRIPT_DEBUG' ) && VFB_SCRIPT_DEBUG ) ? '.dev' : '';
49
 
50
+ // Make sure we are in the admin before proceeding.
51
  if ( is_admin() ) {
52
+ // Build options and settings pages.
53
  add_action( 'admin_menu', array( &$this, 'add_admin' ) );
54
  add_action( 'admin_menu', array( &$this, 'save' ) );
55
 
58
  add_action( 'wp_ajax_visual_form_builder_delete_field', array( &$this, 'delete_field_callback' ) );
59
  add_action( 'wp_ajax_visual_form_builder_form_settings', array( &$this, 'form_settings_callback' ) );
60
 
61
+ add_action( 'load-toplevel_page_visual-form-builder', array( &$this, 'help' ) );
62
 
63
+ // Adds additional media button to insert form shortcode
64
  add_action( 'media_buttons_context', array( &$this, 'add_media_button' ) );
65
  add_action( 'admin_footer', array( &$this, 'display_media_button' ) );
66
 
67
+ // Load the includes files
68
+ add_action( 'load-visual-form-builder_page_vfb-entries', array( &$this, 'includes' ) );
69
+ add_action( 'load-visual-form-builder_page_vfb-export', array( &$this, 'include_export' ) );
70
 
71
+ // Adds a Screen Options tab to the Entries screen
72
+ add_filter( 'set-screen-option', array( &$this, 'save_screen_options' ), 10, 3 );
73
+ add_filter( 'load-toplevel_page_visual-form-builder', array( &$this, 'screen_options' ) );
74
+ add_filter( 'load-visual-form-builder_page_vfb-entries', array( &$this, 'screen_options' ) );
75
 
76
+ // Add meta boxes to the form builder admin page
77
+ add_action( 'load-toplevel_page_visual-form-builder', array( &$this, 'add_meta_boxes' ) );
78
+
79
+ // Adds a Settings link to the Plugins page
80
  add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
81
 
82
+ // Add a database version to help with upgrades and run SQL install
83
  if ( !get_option( 'vfb_db_version' ) ) {
84
  update_option( 'vfb_db_version', $this->vfb_db_version );
85
  $this->install_db();
86
  }
87
 
88
+ // If database version doesn't match, update and run SQL install
89
  if ( get_option( 'vfb_db_version' ) != $this->vfb_db_version ) {
90
  update_option( 'vfb_db_version', $this->vfb_db_version );
91
  $this->install_db();
92
  }
93
+
94
+ // Load the jQuery and CSS we need if we're on our plugin page
95
+ $current_pages = array( 'toplevel_page_visual-form-builder', 'visual-form-builder_page_vfb-add-new', 'visual-form-builder_page_vfb-entries', 'visual-form-builder_page_vfb-export' );
96
 
97
+ foreach ( $current_pages as $page ) {
98
+ add_action( "load-$page", array( &$this, 'admin_scripts' ) );
99
+ add_action( "load-$page", array( &$this, 'admin_css' ) );
100
+ }
101
 
102
+ // Display update messages
103
  add_action('admin_notices', array( &$this, 'admin_notices' ) );
104
  }
105
 
106
+ // Load i18n
107
  load_plugin_textdomain( 'visual-form-builder', false , basename( dirname( __FILE__ ) ) . '/languages' );
108
 
109
  add_shortcode( 'vfb', array( &$this, 'form_code' ) );
120
  * @since 1.2
121
  */
122
  public function includes(){
123
+ global $entries_list, $entries_detail;
124
 
125
+ // Load the Entries List class
126
+ require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/class-entries-list.php' );
127
  $entries_list = new VisualFormBuilder_Entries_List();
128
 
129
+ // Load the Entries Details class
130
+ require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/class-entries-detail.php' );
131
+ $entries_detail = new VisualFormBuilder_Entries_Detail();
132
+ }
133
+
134
+ /**
135
+ * Include the Import/Export files later because current_screen isn't available yet
136
+ *
137
+ * @since 1.4
138
+ */
139
+ public function include_export(){
140
+ global $export;
141
+
142
+ // Load the Export class
143
+ require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/class-export.php' );
144
+ $export = new VisualFormBuilder_Export();
145
  }
146
 
147
  /**
152
  */
153
  public function plugin_action_links( $links, $file ) {
154
  if ( $file == plugin_basename( __FILE__ ) )
155
+ $links[] = '<a href="admin.php?page=visual-form-builder">' . __( 'Settings' , 'visual-form-builder') . '</a>';
156
 
157
  return $links;
158
  }
164
  */
165
  public function add_media_button( $context ){
166
  if ( current_user_can( 'manage_options' ) )
167
+ $context .= '<a href="#TB_inline?width=450&inlineId=vfb_form" class="thickbox" title="Add Visual Form Builder form"><img src="'. plugins_url( 'visual-form-builder/images/vfb_icon.png' ) . '" alt="Add Visual Form Builder form" /></a>';
168
 
169
  return $context;
170
  }
179
  public function display_media_button(){
180
  global $wpdb;
181
 
182
+ // Sanitize the sql orderby
183
  $order = sanitize_sql_orderby( 'form_id ASC' );
184
 
185
+ // Build our forms as an object
186
  $forms = $wpdb->get_results( $wpdb->prepare( "SELECT form_id, form_title FROM $this->form_table_name ORDER BY $order" ) );
187
  ?>
188
  <script type="text/javascript">
191
  e.preventDefault();
192
 
193
  window.send_to_editor( '[vfb id=' + $( '#vfb_forms' ).val() + ']' );
194
+
195
+ window.tb_remove();
196
  });
197
  });
198
  </script>
205
  <option value="<?php echo $form->form_id; ?>"><?php echo $form->form_title; ?></option>
206
  <?php endforeach; ?>
207
  </select>
208
+ <p><input type="submit" class="button-primary" value="Insert Form" /></p>
209
  </form>
210
  </div>
211
  <?php
230
  <li>Click Save Form to save your changes.</li>
231
  </ul>'
232
  ) );
233
+
234
  $screen->add_help_tab( array(
235
  'id' => 'vfb-help-tab-item-config',
236
  'title' => 'Form Item Configuration',
285
  <li><em>Include a Copy of the User's Entry</em>: appends a copy of the user's submitted entry to the notification email.</li>
286
  </ul>"
287
  ) );
288
+
289
  $screen->add_help_tab( array(
290
  'id' => 'vfb-help-tab-tips',
291
  'title' => 'Tips',
318
  }
319
 
320
  /**
321
+ * Adds the Screen Options tab to the Entries screen
322
  *
323
+ * @since 1.0
324
  */
325
+ public function screen_options(){
326
+ $screen = get_current_screen();
327
 
328
+ switch( $screen->id ) {
329
+ case 'visual-form-builder_page_vfb-entries' :
330
+ add_screen_option( 'per_page', array(
331
+ 'label' => __( 'Entries per page', 'visual-form-builder' ),
332
+ 'default' => 20,
333
+ 'option' => 'vfb_entries_per_page'
334
+ ) );
335
+ break;
336
+
337
+ case 'toplevel_page_visual-form-builder' :
338
+ if ( !isset( $_REQUEST['form'] ) )
339
+ break;
340
+
341
+ add_screen_option( 'layout_columns', array(
342
+ 'max' => 2,
343
+ 'default' => 2
344
+ ) );
345
+
346
+ break;
347
+ }
348
+ }
349
+
350
+ /**
351
+ * Saves the Screen Options
352
+ *
353
+ * @since 1.0
354
+ */
355
+ public function save_screen_options( $status, $option, $value ){
356
 
357
+ if ( $option == 'vfb_entries_per_page' )
358
+ return $value;
359
+ }
360
+
361
+ /**
362
+ * Add meta boxes to form builder screen
363
+ *
364
+ * @since 1.8
365
+ */
366
+ public function add_meta_boxes() {
367
+ global $current_screen;
368
 
369
+ if ( $current_screen->id == 'toplevel_page_visual-form-builder' && isset( $_REQUEST['form'] ) ) {
370
+ add_meta_box( 'vfb_form_items_meta_box', __( 'Form Items', 'visual-form-builder' ), array( &$this, 'meta_box_form_items' ), 'toplevel_page_visual-form-builder', 'side', 'high' );
371
+ add_meta_box( 'vfb_form_media_button_tip', __( 'Display Forms', 'visual-form-builder' ), array( &$this, 'meta_box_display_forms' ), 'toplevel_page_visual-form-builder', 'side', 'low' );
 
 
 
 
372
  }
373
  }
374
+ /**
375
+ * Output for Form Items meta box
376
+ *
377
+ * @since 1.8
378
+ */
379
+ public function meta_box_form_items() {
380
+ ?>
381
+ <div class="taxonomydiv">
382
+ <p><strong><?php _e( 'Click' , 'visual-form-builder'); ?></strong> <?php _e( 'to Add a Field' , 'visual-form-builder'); ?> <img id="add-to-form" alt="" src="<?php echo admin_url( '/images/wpspin_light.gif' ); ?>" class="waiting spinner" /></p>
383
+ <ul class="posttype-tabs add-menu-item-tabs" id="vfb-field-tabs">
384
+ <li class="tabs"><a href="#standard-fields" class="nav-tab-link vfb-field-types"><?php _e( 'Standard' , 'visual-form-builder'); ?></a></li>
385
+ </ul>
386
+ <div id="standard-fields" class="tabs-panel tabs-panel-active">
387
+ <ul class="vfb-fields-col-1">
388
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-fieldset">Fieldset</a></li>
389
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-text"><b></b>Text</a></li>
390
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-checkbox"><b></b>Checkbox</a></li>
391
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-select"><b></b>Select</a></li>
392
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-datepicker"><b></b>Date</a></li>
393
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-url"><b></b>URL</a></li>
394
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-digits"><b></b>Number</a></li>
395
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-phone"><b></b>Phone</a></li>
396
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-file"><b></b>File Upload</a></li>
397
+ </ul>
398
+ <ul class="vfb-fields-col-2">
399
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-section"><b></b>Section</a></li>
400
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-textarea"><b></b>Textarea</a></li>
401
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-radio"><b></b>Radio</a></li>
402
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-address"><b></b>Address</a></li>
403
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-email"><b></b>Email</a></li>
404
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-currency"><b></b>Currency</a></li>
405
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-time"><b></b>Time</a></li>
406
+
407
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-html"><b></b>HTML</a></li>
408
+
409
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-instructions"><b></b>Instructions</a></li>
410
+ </ul>
411
+ <div class="clear"></div>
412
+ </div> <!-- #standard-fields -->
413
+ </div> <!-- .taxonomydiv -->
414
+ <div class="clear"></div>
415
+ <?php
416
+ }
417
+
418
+ /**
419
+ * Output for the Display Forms meta box
420
+ *
421
+ * @since 1.8
422
+ */
423
+ public function meta_box_display_forms() {
424
+ ?>
425
+ <p><?php _e( 'Add forms to your Posts or Pages by locating the icon shown below in the area above your post/page editor.', 'visual-form-builder' ); ?><br>
426
+ <img src="<?php echo plugins_url( 'visual-form-builder/images/media-button-help.png' ); ?>">
427
+ </p>
428
+ <?php
429
+ }
430
  /**
431
  * Install database tables
432
  *
439
  $form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
440
  $entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
441
 
442
+ // Explicitly set the character set and collation when creating the tables
443
  $charset = ( defined( 'DB_CHARSET' && '' !== DB_CHARSET ) ) ? DB_CHARSET : 'utf8';
444
  $collate = ( defined( 'DB_COLLATE' && '' !== DB_COLLATE ) ) ? DB_COLLATE : 'utf8_general_ci';
445
 
493
  data TEXT NOT NULL,
494
  subject TEXT,
495
  sender_name VARCHAR(255),
496
+ sender_email VARCHAR(255),
497
  emails_to TEXT,
498
  date_submitted DATETIME,
499
  ip_address VARCHAR(25),
500
  UNIQUE KEY (entries_id)
501
  ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
502
 
503
+ // Create or Update database tables
504
  dbDelta( $field_sql );
505
  dbDelta( $form_sql );
506
  dbDelta( $entries_sql );
513
  */
514
  public function admin_css() {
515
  wp_enqueue_style( 'visual-form-builder-style', plugins_url( "visual-form-builder/css/visual-form-builder-admin$this->load_dev_files.css" ) );
 
516
  }
517
 
518
  /**
522
  */
523
  public function admin_scripts() {
524
  wp_enqueue_script( 'jquery-ui-sortable' );
525
+ wp_enqueue_script( 'postbox' );
526
  wp_enqueue_script( 'jquery-form-validation', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js', array( 'jquery' ), '', true );
527
  wp_enqueue_script( 'form-elements-add', plugins_url( "visual-form-builder/js/visual-form-builder$this->load_dev_files.js" ) , array( 'jquery', 'jquery-form-validation' ), '', true );
528
  wp_enqueue_script( 'nested-sortable', plugins_url( 'visual-form-builder/js/jquery.ui.nestedSortable.js' ) , array( 'jquery', 'jquery-ui-sortable' ), '', true );
564
  public function save() {
565
  global $wpdb;
566
 
567
+ if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], array( 'visual-form-builder', 'vfb-add-new' ) ) && isset( $_REQUEST['action'] ) ) {
568
 
569
  switch ( $_REQUEST['action'] ) {
570
  case 'create_form' :
571
 
572
+ $form_key = sanitize_title( $_REQUEST['form_title'] );
573
+ $form_title = esc_html( $_REQUEST['form_title'] );
574
+ $form_from_name = esc_html( $_REQUEST['form_email_from_name'] );
575
+ $form_subject = esc_html( $_REQUEST['form_email_subject'] );
576
+ $form_from = esc_html( $_REQUEST['form_email_from'] );
577
+ $form_to = serialize( array_map( 'esc_html', $_REQUEST['form_email_to'] ) );
578
 
579
+ check_admin_referer( 'create_form' );
580
 
581
  $newdata = array(
582
+ 'form_key' => $form_key,
583
+ 'form_title' => $form_title,
584
+ 'form_email_from_name' => $form_from_name,
585
+ 'form_email_subject' => $form_subject,
586
+ 'form_email_from' => $form_from,
587
+ 'form_email_to' => $form_to
588
+ );
589
 
590
+ // Create the form
 
 
 
591
  $wpdb->insert( $this->form_table_name, $newdata );
592
 
593
+ // Get form ID to add our first field
594
  $new_form_selected = $wpdb->insert_id;
595
 
596
+ // Setup the initial fieldset
597
  $initial_fieldset = array(
598
+ 'form_id' => $wpdb->insert_id,
599
+ 'field_key' => 'fieldset',
600
+ 'field_type' => 'fieldset',
601
+ 'field_name' => 'Fieldset',
602
+ 'field_sequence' => 0
603
  );
604
 
605
+ // Add the first fieldset to get things started
606
  $wpdb->insert( $this->field_table_name, $initial_fieldset );
607
 
608
  $verification_fieldset = array(
609
+ 'form_id' => $new_form_selected,
610
+ 'field_key' => 'verification',
611
+ 'field_type' => 'verification',
612
+ 'field_name' => 'Verification',
613
  'field_description' => '(This is for preventing spam)',
614
+ 'field_sequence' => 1
615
  );
616
 
617
+ // Insert the submit field
618
  $wpdb->insert( $this->field_table_name, $verification_fieldset );
619
 
620
  $verify_fieldset_parent_id = $wpdb->insert_id;
621
 
622
  $secret = array(
623
+ 'form_id' => $new_form_selected,
624
+ 'field_key' => 'secret',
625
+ 'field_type' => 'secret',
626
+ 'field_name' => 'Please enter any two digits with no spaces (Example: 12)',
627
+ 'field_size' => 'medium',
628
+ 'field_required' => 'yes',
629
+ 'field_parent' => $verify_fieldset_parent_id,
630
+ 'field_sequence' => 2
631
  );
632
 
633
+ // Insert the submit field
634
  $wpdb->insert( $this->field_table_name, $secret );
635
 
636
+ // Make the submit last in the sequence
637
  $submit = array(
638
+ 'form_id' => $new_form_selected,
639
+ 'field_key' => 'submit',
640
+ 'field_type' => 'submit',
641
+ 'field_name' => 'Submit',
642
+ 'field_parent' => $verify_fieldset_parent_id,
643
+ 'field_sequence' => 3
644
  );
645
 
646
+ // Insert the submit field
647
  $wpdb->insert( $this->field_table_name, $submit );
648
 
649
+ // Redirect to keep the URL clean (use AJAX in the future?)
650
+ wp_redirect( 'admin.php?page=visual-form-builder&form=' . $new_form_selected );
651
  exit();
652
 
653
  break;
665
  $form_from_name_override = esc_html( $_REQUEST['form_email_from_name_override'] );
666
  $form_success_type = esc_html( $_REQUEST['form_success_type'] );
667
  $form_notification_setting = isset( $_REQUEST['form_notification_setting'] ) ? esc_html( $_REQUEST['form_notification_setting'] ) : '';
668
+ $form_notification_email_name = isset( $_REQUEST['form_notification_email_name'] ) ? esc_html( $_REQUEST['form_notification_email_name'] ) : '';
669
+ $form_notification_email_from = isset( $_REQUEST['form_notification_email_from'] ) ? sanitize_email( $_REQUEST['form_notification_email_from'] ) : '';
670
+ $form_notification_email = isset( $_REQUEST['form_notification_email'] ) ? esc_html( $_REQUEST['form_notification_email'] ) : '';
671
+ $form_notification_subject = isset( $_REQUEST['form_notification_subject'] ) ? esc_html( $_REQUEST['form_notification_subject'] ) : '';
672
+ $form_notification_message = isset( $_REQUEST['form_notification_message'] ) ? wp_richedit_pre( $_REQUEST['form_notification_message'] ) : '';
673
  $form_notification_entry = isset( $_REQUEST['form_notification_entry'] ) ? esc_html( $_REQUEST['form_notification_entry'] ) : '';
674
  $form_label_alignment = esc_html( $_REQUEST['form_label_alignment'] );
675
 
676
+ // Add confirmation based on which type was selected
677
  switch ( $form_success_type ) {
678
  case 'text' :
679
  $form_success_message = wp_richedit_pre( $_REQUEST['form_success_message_text'] );
689
  check_admin_referer( 'update_form-' . $form_id );
690
 
691
  $newdata = array(
692
+ 'form_key' => $form_key,
693
+ 'form_title' => $form_title,
694
+ 'form_email_subject' => $form_subject,
695
+ 'form_email_to' => $form_to,
696
+ 'form_email_from' => $form_from,
697
+ 'form_email_from_name' => $form_from_name,
698
+ 'form_email_from_override' => $form_from_override,
699
  'form_email_from_name_override' => $form_from_name_override,
700
+ 'form_success_type' => $form_success_type,
701
+ 'form_success_message' => $form_success_message,
702
+ 'form_notification_setting' => $form_notification_setting,
703
+ 'form_notification_email_name' => $form_notification_email_name,
704
+ 'form_notification_email_from' => $form_notification_email_from,
705
+ 'form_notification_email' => $form_notification_email,
706
+ 'form_notification_subject' => $form_notification_subject,
707
+ 'form_notification_message' => $form_notification_message,
708
+ 'form_notification_entry' => $form_notification_entry,
709
+ 'form_label_alignment' => $form_label_alignment
710
  );
711
 
712
  $where = array(
713
  'form_id' => $form_id
714
  );
715
 
716
+ // Update form details
717
  $wpdb->update( $this->form_table_name, $newdata, $where );
718
 
719
+ // Initialize field sequence
720
  $field_sequence = 0;
721
 
722
+ // Loop through each field and update all at once
723
  if ( !empty( $_REQUEST['field_id'] ) ) {
724
  foreach ( $_REQUEST['field_id'] as $id ) {
725
+ $field_name = ( isset( $_REQUEST['field_name-' . $id] ) ) ? esc_html( $_REQUEST['field_name-' . $id] ) : '';
726
+ $field_key = sanitize_title( $field_name, $id );
727
+ $field_desc = ( isset( $_REQUEST['field_description-' . $id] ) ) ? esc_html( $_REQUEST['field_description-' . $id] ) : '';
728
+ $field_options = ( isset( $_REQUEST['field_options-' . $id] ) ) ? serialize( array_map( 'esc_html', $_REQUEST['field_options-' . $id] ) ) : '';
729
+ $field_validation = ( isset( $_REQUEST['field_validation-' . $id] ) ) ? esc_html( $_REQUEST['field_validation-' . $id] ) : '';
730
+ $field_required = ( isset( $_REQUEST['field_required-' . $id] ) ) ? esc_html( $_REQUEST['field_required-' . $id] ) : '';
731
+ $field_size = ( isset( $_REQUEST['field_size-' . $id] ) ) ? esc_html( $_REQUEST['field_size-' . $id] ) : '';
732
+ $field_css = ( isset( $_REQUEST['field_css-' . $id] ) ) ? esc_html( $_REQUEST['field_css-' . $id] ) : '';
733
+ $field_layout = ( isset( $_REQUEST['field_layout-' . $id] ) ) ? esc_html( $_REQUEST['field_layout-' . $id] ) : '';
734
+ $field_default = ( isset( $_REQUEST['field_default-' . $id] ) ) ? esc_html( $_REQUEST['field_default-' . $id] ) : '';
735
 
736
  $field_data = array(
737
+ 'field_key' => $field_key,
738
+ 'field_name' => $field_name,
739
  'field_description' => $field_desc,
740
+ 'field_options' => $field_options,
741
+ 'field_validation' => $field_validation,
742
+ 'field_required' => $field_required,
743
+ 'field_size' => $field_size,
744
+ 'field_css' => $field_css,
745
+ 'field_layout' => $field_layout,
746
+ 'field_sequence' => $field_sequence,
747
+ 'field_default' => $field_default
748
  );
749
 
750
  $where = array(
751
+ 'form_id' => $_REQUEST['form_id'],
752
+ 'field_id' => $id
753
  );
754
 
755
+ // Update all fields
756
  $wpdb->update( $this->field_table_name, $field_data, $where );
757
 
758
  $field_sequence++;
763
  $is_secret = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'secret' AND form_id = %d", $form_id ) );
764
  $is_submit = $wpdb->get_var( $wpdb->prepare( "SELECT field_id FROM $this->field_table_name WHERE field_type = 'submit' AND form_id = %d", $form_id ) );
765
 
766
+ // Decrement sequence
767
  $field_sequence--;
768
 
769
  $verification_id = '';
770
 
771
+ // If this form doesn't have a verification field, add one
772
  if ( $is_verification == NULL ) {
773
+ // Adjust the sequence
774
  $verification_fieldset = array(
775
+ 'form_id' => $form_id,
776
+ 'field_key' => 'verification',
777
+ 'field_type' => 'verification',
778
+ 'field_name' => 'Verification',
779
+ 'field_sequence' => $field_sequence
780
  );
781
 
782
+ // Insert the verification fieldset
783
  $wpdb->insert( $this->field_table_name, $verification_fieldset );
784
 
785
  $verification_id = $wpdb->insert_id;
786
  }
787
 
788
+ // If the verification field was inserted, use that ID as a parent otherwise set no parent
789
  $verify_fieldset_parent_id = ( $verification_id !== false ) ? $verification_id : 0;
790
 
791
+ // If this form doesn't have a secret field, add one
792
  if ( $is_secret == NULL ) {
793
 
794
+ // Adjust the sequence
795
  $secret = array(
796
+ 'form_id' => $form_id,
797
+ 'field_key' => 'secret',
798
+ 'field_type' => 'secret',
799
+ 'field_name' => 'Please enter any two digits with no spaces (Example: 12)',
800
+ 'field_size' => 'medium',
801
+ 'field_required' => 'yes',
802
+ 'field_parent' => $verify_fieldset_parent_id,
803
+ 'field_sequence' => ++$field_sequence
804
  );
805
 
806
+ // Insert the submit field
807
  $wpdb->insert( $this->field_table_name, $secret );
808
  }
809
 
810
+ // If this form doesn't have a submit field, add one
811
  if ( $is_submit == NULL ) {
812
 
813
+ // Make the submit last in the sequence
814
  $submit = array(
815
+ 'form_id' => $form_id,
816
+ 'field_key' => 'submit',
817
+ 'field_type' => 'submit',
818
+ 'field_name' => 'Submit',
819
+ 'field_parent' => $verify_fieldset_parent_id,
820
+ 'field_sequence' => ++$field_sequence
821
  );
822
 
823
+ // Insert the submit field
824
  $wpdb->insert( $this->field_table_name, $submit );
825
  }
826
  else {
827
+ // Only update the Submit's parent ID if the Verification field is new
828
  $data = ( $is_verification == NULL ) ? array( 'field_parent' => $verify_fieldset_parent_id, 'field_sequence' => ++$field_sequence ) : array( 'field_sequence' => $field_sequence );
829
  $where = array(
830
+ 'form_id' => $form_id,
831
+ 'field_id' => $is_submit
832
  );
833
 
834
+ // Update the submit field
835
  $wpdb->update( $this->field_table_name, $data, $where );
836
  }
837
  }
847
  $wpdb->query( $wpdb->prepare( "DELETE FROM $this->form_table_name WHERE form_id = %d", $id ) );
848
  $wpdb->query( $wpdb->prepare( "DELETE FROM $this->field_table_name WHERE form_id = %d", $id ) );
849
 
850
+ // Redirect to keep the URL clean (use AJAX in the future?)
851
+ wp_redirect( add_query_arg( 'action', 'deleted', 'admin.php?page=visual-form-builder' ) );
852
  exit();
853
 
854
  break;
865
  $from_name = $wpdb->get_var( null, 1 );
866
  $notify = $wpdb->get_var( null, 2 );
867
 
868
+ // Copy this form and force the initial title to denote a copy
869
  foreach ( $forms as $form ) {
870
  $data = array(
871
  'form_key' => sanitize_title( $form->form_key . ' copy' ),
891
  $wpdb->insert( $this->form_table_name, $data );
892
  }
893
 
894
+ // Get form ID to add our first field
895
  $new_form_selected = $wpdb->insert_id;
896
 
897
+ // Copy each field and data
898
  foreach ( $fields as $field ) {
899
  $data = array(
900
+ 'form_id' => $new_form_selected,
901
+ 'field_key' => $field->field_key,
902
+ 'field_type' => $field->field_type,
903
+ 'field_name' => $field->field_name,
904
  'field_description' => $field->field_description,
905
+ 'field_options' => $field->field_options,
906
+ 'field_sequence' => $field->field_sequence,
907
+ 'field_validation' => $field->field_validation,
908
+ 'field_required' => $field->field_required,
909
+ 'field_size' => $field->field_size,
910
+ 'field_css' => $field->field_css,
911
+ 'field_layout' => $field->field_layout,
912
+ 'field_parent' => $field->field_parent
913
  );
914
 
915
  $wpdb->insert( $this->field_table_name, $data );
916
 
917
+ // If a parent field, save the old ID and the new ID to update new parent ID
918
  if ( in_array( $field->field_type, array( 'fieldset', 'section', 'verification' ) ) )
919
  $parents[ $field->field_id ] = $wpdb->insert_id;
920
 
928
  $wpdb->update( $this->form_table_name, array( 'form_notification_email' => $wpdb->insert_id ), array( 'form_id' => $new_form_selected ) );
929
  }
930
 
931
+ // Loop through our parents and update them to their new IDs
932
  foreach ( $parents as $k => $v ) {
933
  $wpdb->update( $this->field_table_name, array( 'field_parent' => $v ), array( 'form_id' => $new_form_selected, 'field_parent' => $k ) );
934
  }
951
  foreach ( $_REQUEST['order'] as $k ) {
952
  if ( 'root' !== $k['item_id'] ) {
953
  $data[] = array(
954
+ 'field_id' => $k['item_id'],
955
+ 'parent' => $k['parent_id']
956
+ );
957
  }
958
  }
959
 
960
  foreach ( $data as $k => $v ) {
961
+ // Update each field with it's new sequence and parent ID
962
  $wpdb->update( $this->field_table_name, array( 'field_sequence' => $k, 'field_parent' => $v['parent'] ), array( 'field_id' => $v['field_id'] ) );
963
  }
964
 
980
  $data[ $k['name'] ] = $k['value'];
981
  }
982
 
983
+ if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'toplevel_page_visual-form-builder' && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'visual_form_builder_create_field' ) {
984
+
985
+ $form_id = absint( $data['form_id'] );
986
+ $field_key = sanitize_title( $_REQUEST['field_type'] );
987
  $field_name = esc_html( $_REQUEST['field_type'] );
988
  $field_type = strtolower( sanitize_title( $_REQUEST['field_type'] ) );
989
 
990
+ // Set defaults for validation
991
  switch ( $field_type ) {
992
  case 'select' :
993
  case 'radio' :
1020
 
1021
  check_ajax_referer( 'create-field-' . $data['form_id'], 'nonce' );
1022
 
1023
+ // Get the last row's sequence that isn't a Verification
1024
+ $sequence_last_row = $wpdb->get_var( $wpdb->prepare( "SELECT field_sequence FROM $this->field_table_name WHERE form_id = %d AND field_type = 'verification' ORDER BY field_sequence DESC LIMIT 1", $form_id ) );
1025
 
1026
+ // If it's not the first for this form, add 1
1027
+ $field_sequence = ( !empty( $sequence_last_row ) ) ? $sequence_last_row : 0;
1028
 
1029
  $newdata = array(
1030
+ 'form_id' => $form_id,
1031
+ 'field_key' => $field_key,
1032
+ 'field_name' => $field_name,
1033
+ 'field_type' => $field_type,
1034
+ 'field_options' => $field_options,
1035
+ 'field_sequence' => $field_sequence,
1036
+ 'field_validation' => $field_validation
1037
  );
1038
 
1039
+ // Create the field
1040
  $wpdb->insert( $this->field_table_name, $newdata );
1041
+
1042
  $insert_id = $wpdb->insert_id;
1043
  $update_these = array( 'verification', 'secret', 'submit' );
1044
 
1045
  foreach ( $update_these as $update ) {
1046
  $where = array(
1047
+ 'form_id' => absint( $data['form_id'] ),
1048
+ 'field_type' => $update
1049
  );
1050
 
1051
  $wpdb->update( $this->field_table_name, array( 'field_sequence' => $field_sequence + 1 ), $where );
1067
  public function delete_field_callback() {
1068
  global $wpdb;
1069
 
1070
+ if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'toplevel_page_visual-form-builder' && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'visual_form_builder_delete_field' ) {
1071
  $form_id = absint( $_REQUEST['form'] );
1072
  $field_id = absint( $_REQUEST['field'] );
1073
 
1077
  foreach ( $_REQUEST['child_ids'] as $children ) {
1078
  $parent = absint( $_REQUEST['parent_id'] );
1079
 
1080
+ // Update each child item with the new parent ID
1081
  $wpdb->update( $this->field_table_name, array( 'field_parent' => $parent ), array( 'field_id' => $children ) );
1082
  }
1083
  }
1084
 
1085
+ // Delete the field
1086
  $wpdb->query( $wpdb->prepare( "DELETE FROM $this->field_table_name WHERE field_id = %d", $field_id ) );
1087
  }
1088
 
1099
  get_currentuserinfo();
1100
 
1101
  if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'visual_form_builder_form_settings' ) {
1102
+ $form_id = absint( $_REQUEST['form'] );
1103
+ $status = isset( $_REQUEST['status'] ) ? $_REQUEST['status'] : 'opened';
1104
+ $accordion = isset( $_REQUEST['accordion'] ) ? $_REQUEST['accordion'] : 'general-settings';
1105
+ $user_id = $current_user->ID;
1106
 
1107
  $form_settings = get_user_meta( $user_id, 'vfb-form-settings', true );
1108
 
1109
  $array = array(
1110
+ 'form_setting_tab' => $status,
1111
  'setting_accordion' => $accordion
1112
  );
1113
 
1114
+ // Set defaults if meta key doesn't exist
1115
  if ( !$form_settings || $form_settings == '' ) {
1116
  $meta_value[ $form_id ] = $array;
1117
 
1126
 
1127
  die(1);
1128
  }
1129
+ /**
1130
+ * All Forms output in admin
1131
+ *
1132
+ * @since 2.5
1133
+ */
1134
+ public function all_forms() {
1135
+ global $wpdb;
1136
+
1137
+ $order = sanitize_sql_orderby( 'form_title ASC' );
1138
+
1139
+ $where = apply_filters( 'vfb_pre_get_forms', '' );
1140
+ $forms = $wpdb->get_results( "SELECT * FROM $this->form_table_name WHERE 1=1 $where ORDER BY $order" );
1141
+
1142
+ $a = array();
1143
+
1144
+ if ( $forms ) :
1145
+ // Loop through each for and build the tabs
1146
+ foreach ( $forms as $form ) {
1147
+ $form_id = $form->form_id;
1148
+ $form_title = stripslashes( $form->form_title );
1149
+ $entries_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $this->entries_table_name WHERE form_id = %d", $form_id ) );
1150
+ $sort = substr( strtoupper( $form_title ), 0, 1 );
1151
+
1152
+ if ( preg_match( '/[0-9]/i', $sort ) )
1153
+ $sort = '0-9';
1154
+
1155
+ $a[ $sort ][] = array(
1156
+ 'id' => $form_id,
1157
+ 'title' => $form_title,
1158
+ 'entries_count' => $entries_count
1159
+ );
1160
+
1161
+ }
1162
+ ?>
1163
+ <div class="vfb-form-alpha-list">
1164
+ <hr>
1165
+ <?php
1166
+ foreach ( $a as $alpha => $value ) :
1167
+ ?>
1168
+ <div class="vfb-form-alpha-group">
1169
+ <h2 class='letter'><?php echo $alpha; ?></h2>
1170
+ <?php
1171
+ foreach ( $value as $alphaForm ) {
1172
+ ?>
1173
+
1174
+ <div class="vfb-form-alpha-form">
1175
+ <h3><a class="" href="<?php echo esc_url( add_query_arg( array( 'form' => $alphaForm['id'] ), admin_url( 'admin.php?page=visual-form-builder' ) ) ); ?>"><?php echo $alphaForm['title']; ?></a></h3>
1176
+ <div class="vfb-publishing-actions">
1177
+ <p>
1178
+ <a class="" href="<?php echo esc_url( add_query_arg( array( 'form' => $alphaForm['id'] ), admin_url( 'admin.php?page=visual-form-builder' ) ) ); ?>">
1179
+ <strong><?php _e( 'Edit Form', 'visual-form-builder' ); ?></strong>
1180
+ </a> |
1181
+ <a class="submitdelete menu-delete" href="<?php echo esc_url( wp_nonce_url( admin_url('admin.php?page=visual-form-builder&amp;action=delete_form&amp;form=' . $alphaForm['id'] ), 'delete-form-' . $alphaForm['id'] ) ); ?>" class=""><?php _e( 'Delete' , 'visual-form-builder'); ?></a> |
1182
+ <a href="<?php echo esc_url( add_query_arg( array( 'form-filter' => $alphaForm['id'] ), admin_url( 'admin.php?page=vfb-entries' ) ) ); ?>"><?php echo $alphaForm['entries_count']; ?> Entries</a>
1183
+
1184
+ </p>
1185
+ </div> <!-- .vfb-publishing-actions -->
1186
+ </div>
1187
+ <div class="clear"></div>
1188
+ <?php
1189
+ }
1190
+ ?>
1191
+ </div> <!-- .vfb-form-alpha-group -->
1192
+ <hr>
1193
+ <?php endforeach; ?>
1194
+ </div> <!-- .vfb-form-alpha-list -->
1195
+
1196
+ <?php else : ?>
1197
+ <div class="vfb-form-alpha-list"><h3 id="vfb-no-forms">You currently don't have any forms. Click on the <a href="<?php echo esc_url( admin_url( 'admin.php?page=vfb-add-new' ) ); ?>">New Form</a> button to get started.</h3></div>
1198
+ <?php endif; ?>
1199
+
1200
+ <div id="vfb-upgrade-column">
1201
+ <div class="vfb-pro-upgrade"><!-- VFB Pro Upgrade -->
1202
+ <h3>Upgrade to <a href="http://vfb.matthewmuro.com">Visual Form Builder Pro</a> for only $10</h3>
1203
+ <p>Attention Visual Form Builder users! I am happy to announce <a href="http://vfb.matthewmuro.com">Visual Form Builder Pro</a>, available now for only <strong>$10</strong>.</p>
1204
+ <h3><?php _e( 'New Features of Visual Form Builder Pro' , 'visual-form-builder'); ?></h3>
1205
+ <ul>
1206
+ <li><?php _e( 'Optional SPAM Verification' , 'visual-form-builder'); ?></li>
1207
+ <li><?php _e( 'Drag and Drop to add new form fields' , 'visual-form-builder'); ?></li>
1208
+ <li><?php _e( 'Conditional Logic' , 'visual-form-builder'); ?></li>
1209
+ <li><?php _e( '10 new Form Fields (Username, Password, Color Picker, Autocomplete, Hidden, and more)' , 'visual-form-builder'); ?></li>
1210
+ <li><?php _e( 'Edit and Update Entries' , 'visual-form-builder'); ?></li>
1211
+ <li><?php _e( 'Import/Export forms, settings, and entries' , 'visual-form-builder'); ?></li>
1212
+ <li><?php _e( 'Quality HTML Email Template' , 'visual-form-builder'); ?></li>
1213
+ <li><?php _e( 'Plain Text Email Option' , 'visual-form-builder'); ?></li>
1214
+ <li><?php _e( 'Email Designer' , 'visual-form-builder'); ?></li>
1215
+ <li><?php _e( 'Analytics' , 'visual-form-builder'); ?></li>
1216
+ <li><?php _e( 'Data &amp; Form Migration' , 'visual-form-builder'); ?></li>
1217
+ <li><?php _e( 'PayPal Integration' , 'visual-form-builder'); ?></li>
1218
+ <li><?php _e( 'Form Paging' , 'visual-form-builder'); ?></li>
1219
+ <li><?php _e( 'Live Preview' , 'visual-form-builder'); ?></li>
1220
+ <li><?php _e( 'Custom Capabilities' , 'visual-form-builder'); ?></li>
1221
+ <li><?php _e( 'No License Key' , 'visual-form-builder'); ?></li>
1222
+ <li><?php _e( 'Unlimited Use' , 'visual-form-builder'); ?></li>
1223
+ <li><?php _e( 'Automatic Updates' , 'visual-form-builder'); ?></li>
1224
+ </ul>
1225
+
1226
+ <p><a href="http://matthewmuro.com/2012/02/07/introducing-visual-form-builder-pro/"><?php _e( 'Learn more about some of these features' , 'visual-form-builder'); ?></a>.</p>
1227
+ <p class="vfb-pro-call-to-action"><a href="http://visualformbuilder.fetchapp.com/sell/dahdaeng"><span class="cta-sign-up"><?php _e( 'Buy Now' , 'visual-form-builder'); ?></span><span class="cta-price"><?php _e( 'Only $10' , 'visual-form-builder'); ?></span></a></p>
1228
+ </div> <!-- .vfb-pro-upgrade -->
1229
+
1230
+ <h3><?php _e( 'Help Promote Visual Form Builder' , 'visual-form-builder'); ?></h3>
1231
+ <ul id="promote-vfb">
1232
+ <li id="twitter"><?php _e( 'Follow me on Twitter' , 'visual-form-builder'); ?>: <a href="http://twitter.com/#!/matthewmuro">@matthewmuro</a></li>
1233
+ <li id="star"><a href="http://wordpress.org/extend/plugins/visual-form-builder/"><?php _e( 'Rate Visual Form Builder on WordPress.org' , 'visual-form-builder'); ?></a></li>
1234
+ <li id="paypal">
1235
+ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9UN9CLPH4&lc=US&item_name=Visual%20Form%20Builder&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" width="74" height="21"></a>
1236
+ </li>
1237
+ </ul>
1238
+ </div>
1239
+ <?php
1240
+ }
1241
 
1242
  /**
1243
  * Build field output in admin
1248
  global $wpdb;
1249
 
1250
  $field_where = ( isset( $field_id ) && !is_null( $field_id ) ) ? "AND field_id = $field_id" : '';
1251
+ // Display all fields for the selected form
1252
  $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d $field_where ORDER BY field_sequence ASC", $form_nav_selected_id ) );
1253
 
1254
  $depth = 1;
1255
  $parent = $last = 0;
1256
 
1257
+ // Loop through each field and display
1258
  foreach ( $fields as $field ) :
1259
+ // If we are at the root level
1260
  if ( !$field->field_parent && $depth > 1 ) {
1261
+ // If we've been down a level, close out the list
1262
  while ( $depth > 1 ) {
1263
  echo '</li>
1264
  </ul>';
1265
  $depth--;
1266
  }
1267
 
1268
+ // Close out the root item
1269
  echo '</li>';
1270
  }
1271
+ // first item of <ul>, so move down a level
1272
  elseif ( $field->field_parent && $field->field_parent == $last ) {
1273
  echo '<ul class="parent">';
1274
  $depth++;
1275
  }
1276
+ // Close up a <ul> and move up a level
1277
  elseif ( $field->field_parent && $field->field_parent != $parent ) {
1278
  echo '</li>
1279
  </ul>
1280
  </li>';
1281
  $depth--;
1282
  }
1283
+ // Same level so close list item
1284
  elseif ( $field->field_parent && $field->field_parent == $parent )
1285
  echo '</li>';
1286
 
1287
+ // Store item ID and parent ID to test for nesting
1288
  $last = $field->field_id;
1289
  $parent = $field->field_parent;
1290
  ?>
1360
  </p>
1361
 
1362
  <?php
1363
+ // Display the Options input only for radio, checkbox, and select fields
1364
  if ( in_array( $field->field_type, array( 'radio', 'checkbox', 'select' ) ) ) : ?>
1365
  <!-- Options -->
1366
  <p class="description description-wide">
1368
  <span class="vfb-tooltip" title="About Options" rel="This property allows you to set predefined options to be selected by the user. Use the plus and minus buttons to add and delete options. At least one option must exist.">(?)</span>
1369
  <br />
1370
  <?php
1371
+ // If the options field isn't empty, unserialize and build array
1372
  if ( !empty( $field->field_options ) ) {
1373
  if ( is_serialized( $field->field_options ) )
1374
  $opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
1375
  }
1376
+ // Otherwise, present some default options
1377
  else
1378
  $opts_vals = array( 'Option 1', 'Option 2', 'Option 3' );
1379
 
1380
+ // Basic count to keep track of multiple options
1381
  $count = 1;
1382
 
1383
+ // Loop through the options
1384
  foreach ( $opts_vals as $options ) {
1385
  ?>
1386
  <div id="clone-<?php echo $field->field_id . '-' . $count; ?>" class="option">
1397
  ?>
1398
  </p>
1399
  <?php
1400
+ // Unset the options for any following radio, checkboxes, or selects
1401
  unset( $opts_vals );
1402
  endif;
1403
  ?>
1404
 
1405
  <?php
1406
+ // Display the Options input only for radio, checkbox, select, and autocomplete fields
1407
  if ( in_array( $field->field_type, array( 'file-upload' ) ) ) :
1408
  ?>
1409
  <!-- File Upload Accepts -->
1411
  <?php
1412
  $opts_vals = array( '' );
1413
 
1414
+ // If the options field isn't empty, unserialize and build array
1415
  if ( !empty( $field->field_options ) ) {
1416
  if ( is_serialized( $field->field_options ) )
1417
  $opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : unserialize( $field->field_options );
1418
  }
1419
 
1420
+ // Loop through the options
1421
  foreach ( $opts_vals as $options ) {
1422
  ?>
1423
  <label for="edit-form-item-options-<?php echo $field->field_id; ?>">
1429
  </p>
1430
  <?php
1431
  }
1432
+ // Unset the options for any following radio, checkboxes, or selects
1433
  unset( $opts_vals );
1434
  endif;
1435
  ?>
1568
 
1569
  <?php if ( !in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) : ?>
1570
  <div class="menu-item-actions description-wide submitbox">
1571
+ <a href="<?php echo esc_url( wp_nonce_url( admin_url('admin.php?page=visual-form-builder&amp;action=delete_field&amp;form=' . $form_nav_selected_id . '&amp;field=' . $field->field_id ), 'delete-field-' . $form_nav_selected_id ) ); ?>" class="item-delete submitdelete deletion"><?php _e( 'Remove' , 'visual-form-builder'); ?></a>
1572
  </div>
1573
  <?php endif; ?>
1574
 
1577
  <?php
1578
  endforeach;
1579
 
1580
+ // This assures all of the <ul> and <li> are closed
1581
  if ( $depth > 1 ) {
1582
  while( $depth > 1 ) {
1583
  echo '</li>
1586
  }
1587
  }
1588
 
1589
+ // Close out last item
1590
  echo '</li>';
1591
  }
1592
 
1623
  * @uses add_options_page() Creates a menu item under the Settings menu.
1624
  */
1625
  public function add_admin() {
1626
+ add_menu_page( __( 'Visual Form Builder', 'visual-form-builder' ), __( 'Visual Form Builder', 'visual-form-builder' ), 'manage_options', 'visual-form-builder', array( &$this, 'admin' ), plugins_url( 'visual-form-builder/images/vfb_icon.png' ) );
1627
+
1628
+ add_submenu_page( 'visual-form-builder', __( 'Visual Form Builder', 'visual-form-builder' ), __( 'All Forms', 'visual-form-builder' ), 'manage_options', 'visual-form-builder', array( &$this, 'admin' ) );
1629
+ add_submenu_page( 'visual-form-builder', __( 'Add New Form', 'visual-form-builder' ), __( 'Add New Forms', 'visual-form-builder' ), 'manage_options', 'vfb-add-new', array( &$this, 'admin' ) );
1630
+ add_submenu_page( 'visual-form-builder', __( 'Entries', 'visual-form-builder' ), __( 'Entries', 'visual-form-builder' ), 'manage_options', 'vfb-entries', array( &$this, 'admin' ) );
1631
+ add_submenu_page( 'visual-form-builder', __( 'Export', 'visual-form-builder' ), __( 'Export', 'visual-form-builder' ), 'manage_options', 'vfb-export', array( &$this, 'admin' ) );
1632
  }
1633
 
1634
  /**
1637
  * @since 1.0
1638
  */
1639
  public function admin() {
1640
+ global $wpdb, $current_user, $entries_list, $entries_detail, $export;
 
 
 
 
 
1641
 
1642
+ get_currentuserinfo();
 
 
1643
 
1644
+ // Save current user ID
1645
+ $user_id = $current_user->ID;
 
 
 
 
 
 
1646
 
1647
+ // Set variables depending on which tab is selected
1648
+ $form_nav_selected_id = ( isset( $_REQUEST['form'] ) ) ? $_REQUEST['form'] : '0';
1649
  ?>
1650
+ <div class="wrap">
1651
+ <?php screen_icon( 'options-general' ); ?>
1652
+ <h2>
1653
+ <?php
1654
+ _e('Visual Form Builder', 'visual-form-builder');
1655
+ echo ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) && in_array( $_REQUEST['page'], array( 'vfb-entries' ) ) ) ? '<span class="subtitle">' . sprintf( __( 'Search results for "%s"' , 'visual-form-builder'), $_REQUEST['s'] ) : '';
1656
+ ?>
1657
+ </h2>
1658
+ <ul class="sub-navigation">
1659
+ <?php
1660
+ $views = array();
1661
+ $pages = array(
1662
+ 'visual-form-builder' => array( 'page' => __( 'Forms', 'visual-form-builder' ) ),
1663
+ 'vfb-entries' => array( 'page' => __( 'Entries', 'visual-form-builder' ) ),
1664
+ 'vfb-export' => array( 'page' => __( 'Export', 'visual-form-builder' ) )
1665
+ );
1666
+
1667
+ foreach ( $pages as $page => $args ) {
1668
+ $class = ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], array( $page ) ) ) ? 'current' : '';
1669
+
1670
+ //if ( current_user_can( $args['cap'] ) )
1671
+ $views[ $args['page'] ] = "\t<li><a class='$class' href='" . admin_url( "admin.php?page=$page" ) . "'>{$args['page']}</a>";
1672
+ }
1673
+ echo implode( ' |</li>', $views ) . '</li>';
1674
+ ?>
1675
+ </ul>
1676
+
1677
+ <?php
1678
+ // Display the Entries
1679
+ if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], array( 'vfb-entries' ) ) ) :
1680
+
1681
+ if ( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], array( 'view' ) ) ) :
1682
+ $entries_detail->entries_detail();
1683
+ else :
1684
+ $entries_list->prepare_items();
1685
+ ?>
1686
+ <form id="entries-filter" method="post" action="">
1687
+ <?php
1688
+ $entries_list->search_box( 'search', 'search_id' );
1689
+ $entries_list->display();
1690
+ ?>
1691
+ </form>
1692
+ <?php
1693
+ endif;
1694
+ elseif ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], array( 'vfb-add-new' ) ) ) :
1695
+ include_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/admin-new-form.php' );
1696
+ elseif ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], array( 'vfb-export' ) ) ) :
1697
+ $export->display();
1698
+ // Display the Forms
1699
+ else:
1700
+ if ( empty( $form_nav_selected_id ) ) :
1701
+ ?>
1702
+ <div id="vfb-form-list">
1703
+ <div id="vfb-sidebar">
1704
+ <div id="new-form" class="vfb-box">
1705
+ <a href="<?php echo esc_url( admin_url( 'admin.php?page=vfb-add-new' ) ); ?>">
1706
+ <img src="<?php echo plugins_url( 'visual-form-builder/images/plus-sign.png' ); ?>" width="50" height="50" />
1707
+ <h3><?php _e( 'New Form', 'visual-form-builder' ); ?></h3>
1708
+ </a>
1709
+ </div> <!-- #new-form -->
1710
+ <div class="clear"></div>
1711
+ </div> <!-- #vfb-sidebar -->
1712
+ <div id="vfb-main" class="vfb-order-type-list">
1713
  <?php
1714
+ $this->all_forms();
 
1715
  ?>
1716
+ </div> <!-- #vfb-main -->
1717
+ </div> <!-- #vfb-form-list -->
1718
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
1719
  ?>
1720
+
1721
+ <?php
1722
+ elseif ( !empty( $form_nav_selected_id ) && $form_nav_selected_id !== '0' ) :
1723
+ include_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/admin-form-creator.php' );
1724
+ endif;
1725
+ ?>
1726
+
1727
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1728
  <?php
1729
  endif;
1730
  }
1740
  $form_id = ( isset( $_REQUEST['form_id'] ) ) ? $_REQUEST['form_id'] : '';
1741
 
1742
  if ( isset( $_REQUEST['visual-form-builder-submit'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'visual-form-builder-nonce' ) ) {
1743
+ // Get forms
1744
  $order = sanitize_sql_orderby( 'form_id DESC' );
1745
  $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
1746
 
1747
  foreach ( $forms as $form ) {
1748
+ // If text, return output and format the HTML for display
1749
  if ( 'text' == $form->form_success_type )
1750
  return stripslashes( html_entity_decode( wp_kses_stripslashes( $form->form_success_message ) ) );
1751
+ // If page, redirect to the permalink
1752
  elseif ( 'page' == $form->form_success_type ) {
1753
  $page = get_permalink( $form->form_success_message );
1754
  wp_redirect( $page );
1755
  exit();
1756
  }
1757
+ // If redirect, redirect to the URL
1758
  elseif ( 'redirect' == $form->form_success_type ) {
1759
  wp_redirect( $form->form_success_message );
1760
  exit();
1771
  public function form_code( $atts ) {
1772
  global $wpdb;
1773
 
1774
+ // Extract shortcode attributes, set defaults
1775
  extract( shortcode_atts( array(
1776
  'id' => ''
1777
  ), $atts )
1781
  if ( !$this->add_scripts )
1782
  $this->scripts();
1783
 
1784
+ // Get form id. Allows use of [vfb id=1] or [vfb 1]
1785
+ $form_id = ( isset( $id ) && !empty( $id ) ) ? $id : key( $atts );
1786
 
1787
  $open_fieldset = $open_section = false;
1788
  $output = '';
1789
 
1790
+ // Default the submit value
1791
  $submit = 'Submit';
1792
 
1793
+ // If form is submitted, show success message, otherwise the form
1794
  if ( isset( $_REQUEST['visual-form-builder-submit'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'visual-form-builder-nonce' ) && isset( $_REQUEST['form_id'] ) && $_REQUEST['form_id'] == $form_id ) {
1795
  $output = $this->confirmation();
1796
  }
1803
  $order_fields = sanitize_sql_orderby( 'field_sequence ASC' );
1804
  $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d ORDER BY $order_fields", $form_id ) );
1805
 
1806
+ // Setup count for fieldset and ul/section class names
1807
  $count = 1;
1808
 
1809
  $verification = '';
1810
 
1811
  foreach ( $forms as $form ) :
1812
  $label_alignment = ( $form->form_label_alignment !== '' ) ? " $form->form_label_alignment" : '';
1813
+ $output = '<div class="visual-form-builder-container"><form id="' . $form->form_key . '" class="visual-form-builder' . $label_alignment . '" method="post" enctype="multipart/form-data">
1814
  <input type="hidden" name="form_id" value="' . $form->form_id . '" />';
1815
  $output .= wp_nonce_field( 'visual-form-builder-nonce', '_wpnonce', false, false );
1816
 
1817
  foreach ( $fields as $field ) {
1818
+ // If field is required, build the span and add setup the 'required' class
1819
  $required_span = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' <span>*</span>' : '';
1820
  $required = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' required' : '';
1821
  $validation = ( !empty( $field->field_validation ) ) ? " $field->field_validation" : '';
1824
  $layout = ( !empty( $field->field_layout ) ) ? " $field->field_layout" : '';
1825
  $default = ( !empty( $field->field_default ) ) ? html_entity_decode( stripslashes( $field->field_default ) ) : '';
1826
 
1827
+ // Close each section
1828
  if ( $open_section == true ) {
1829
+ // If this field's parent does NOT equal our section ID
1830
  if ( $sec_id && $sec_id !== $field->field_parent ) {
1831
  $output .= '</div><div class="vfb-clear"></div>';
1832
  $open_section = false;
1833
  }
1834
  }
1835
 
1836
+ // Force an initial fieldset and display an error message to strongly encourage user to add one
1837
  if ( $count === 1 && $field->field_type !== 'fieldset' ) {
1838
  $output .= '<fieldset class="fieldset"><div class="legend" style="background-color:#FFEBE8;border:1px solid #CC0000;"><h3>Oops! Missing Fieldset</h3><p style="color:black;">If you are seeing this message, it means you need to <strong>add a Fieldset to the beginning of your form</strong>. Your form may not function or display properly without one.</p></div><ul class="section section-' . $count . '">';
1839
 
1841
  }
1842
 
1843
  if ( $field->field_type == 'fieldset' ) {
1844
+ // Close each fieldset
1845
  if ( $open_fieldset == true )
1846
  $output .= '</ul><br /></fieldset>';
1847
 
1852
  elseif ( $field->field_type == 'section' ) {
1853
  $output .= '<div class="section-div vfb-' . esc_html( $field->field_key ) . '-' . $field->field_id . '"><h4>' . stripslashes( $field->field_name ) . '</h4>';
1854
 
1855
+ // Save section ID for future comparison
1856
  $sec_id = $field->field_id;
1857
  $open_section = true;
1858
  }
1870
  $verification .= '<fieldset class="fieldset fieldset-' . $count . ' ' . $field->field_key . $css . '"><div class="legend"><h3>' . stripslashes( $field->field_name ) . '</h3></div><ul class="section section-' . $count . '">';
1871
 
1872
  if ( $field->field_type == 'secret' ) {
1873
+ // Default logged in values
1874
  $logged_in_display = '';
1875
  $logged_in_value = '';
1876
 
1877
+ // If the user is logged in, fill the field in for them
1878
  if ( is_user_logged_in() ) {
1879
+ // Hide the secret field if logged in
1880
  $logged_in_display = ' style="display:none;"';
1881
  $logged_in_value = 14;
1882
 
1883
+ // Get logged in user details
1884
  $user = wp_get_current_user();
1885
  $user_identity = ! empty( $user->ID ) ? $user->display_name : '';
1886
 
1887
+ // Display a message for logged in users
1888
  $verification .= '<li class="item">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. Verification not required.', 'visual-form-builder' ), admin_url( 'profile.php' ), $user_identity ) . '</li>';
1889
  }
1890
 
1891
  $validation = ' {digits:true,maxlength:2,minlength:2}';
1892
  $verification .= '<li class="item item-' . $field->field_type . '"' . $logged_in_display . '><label for="' . $id_attr . '" class="desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
1893
 
1894
+ // Set variable for testing if required is Yes/No
1895
  if ( $required == '' )
1896
  $verification .= '<input type="hidden" name="_vfb-required-secret" value="0" />';
1897
 
1938
 
1939
  $options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
1940
 
1941
+ // Loop through each option and output
1942
  foreach ( $options as $option => $value ) {
1943
  $output .= '<option value="' . trim( stripslashes( $value ) ) . '"' . selected( $default, ++$option, 0 ) . '>'. trim( stripslashes( $value ) ) . '</option>';
1944
  }
1956
 
1957
  $output .= '<div>';
1958
 
1959
+ // Loop through each option and output
1960
  foreach ( $options as $option => $value ) {
1961
  // Increment the base index by one to match $default
1962
  $option++;
1980
 
1981
  $output .= '<div>';
1982
 
1983
+ // Loop through each option and output
1984
  foreach ( $options as $option => $value ) {
1985
  // Increment the base index by one to match $default
1986
  $option++;
2049
  if ( !empty( $field->field_description ) )
2050
  $output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
2051
 
2052
+ // Get the time format (12 or 24)
2053
  $time_format = str_replace( 'time-', '', $validation );
2054
  $time_format = apply_filters( 'vfb_time_format', $time_format );
2055
 
2056
+ // Set whether we start with 0 or 1 and how many total hours
2057
  $hour_start = ( $time_format == '12' ) ? 1 : 0;
2058
  $hour_total = ( $time_format == '12' ) ? 12 : 23;
2059
 
2060
+ // Hour
2061
  $output .= '<span class="time"><select name="vfb-' . $field->field_id . '[hour]" id="' . $id_attr . '-hour" class="select' . $required . $css . '">';
2062
  for ( $i = $hour_start; $i <= $hour_total; $i++ ) {
2063
+ // Add the leading zero
2064
  $hour = ( $i < 10 ) ? "0$i" : $i;
2065
  $output .= "<option value='$hour'>$hour</option>";
2066
  }
2067
  $output .= '</select><label for="' . $id_attr . '-hour">HH</label></span>';
2068
 
2069
+ // Minute
2070
  $output .= '<span class="time"><select name="vfb-' . $field->field_id . '[min]" id="' . $id_attr . '-min" class="select' . $required . $css . '">';
2071
 
2072
+ $total_mins = apply_filters( 'vfb_time_min_total', 55 );
2073
+ $min_interval = apply_filters( 'vfb_time_min_interval', 5 );
2074
 
2075
  for ( $i = 0; $i <= $total_mins; $i += $min_interval ) {
2076
+ // Add the leading zero
2077
  $min = ( $i < 10 ) ? "0$i" : $i;
2078
  $output .= "<option value='$min'>$min</option>";
2079
  }
2080
  $output .= '</select><label for="' . $id_attr . '-min">MM</label></span>';
2081
 
2082
+ // AM/PM
2083
  if ( $time_format == '12' )
2084
  $output .= '<span class="time"><select name="vfb-' . $field->field_id . '[ampm]" id="' . $id_attr . '-ampm" class="select' . $required . $css . '"><option value="AM">AM</option><option value="PM">PM</option></select><label for="' . $id_attr . '-ampm">AM/PM</label></span>';
2085
  $output .= '<div class="clear"></div>';
2124
  echo '';
2125
  }
2126
 
2127
+ // Closing </li>
2128
  $output .= ( !in_array( $field->field_type , array( 'verification', 'secret', 'submit', 'fieldset', 'section' ) ) ) ? '</li>' : '';
2129
  }
2130
 
2131
 
2132
+ // Close user-added fields
2133
  $output .= '</ul><br /></fieldset>';
2134
 
2135
+ // Make sure the verification displays even if they have not updated their form
2136
  if ( $verification == '' ) {
2137
  $verification = '<fieldset class="fieldset verification">
2138
  <div class="legend">
2147
  </li>';
2148
  }
2149
 
2150
+ // Output our security test
2151
  $output .= $verification . '<li style="display:none;">
2152
  <label for="vfb-spam">' . __( 'This box is for spam protection' , 'visual-form-builder') . ' - <strong>' . __( 'please leave it blank' , 'visual-form-builder') . '</strong>:</label>
2153
  <div>
2159
  <input type="submit" name="visual-form-builder-submit" value="' . $submit . '" class="submit" id="sendmail" />
2160
  </li>
2161
  </ul>
2162
+ </fieldset></form></div>';
2163
 
2164
  endforeach;
2165
  }
2176
  public function email() {
2177
  global $wpdb, $post;
2178
 
2179
+ $required = ( isset( $_REQUEST['_vfb-required-secret'] ) && $_REQUEST['_vfb-required-secret'] == '0' ) ? false : true;
2180
+ $secret_field = ( isset( $_REQUEST['_vfb-secret'] ) ) ? $_REQUEST['_vfb-secret'] : '';
2181
+ $honeypot = ( isset( $_REQUEST['vfb-spam'] ) ) ? $_REQUEST['vfb-spam'] : '';
2182
 
2183
  // If the verification is set to required, run validation check
2184
  if ( true == $required && !empty( $secret_field ) ) {
2238
  // Notification send to email override query
2239
  $notification = $wpdb->get_results( $wpdb->prepare( "SELECT fields.field_id, fields.field_key FROM $this->form_table_name AS forms LEFT JOIN $this->field_table_name AS fields ON forms.form_notification_email = fields.field_id WHERE forms.form_id = %d", $form_id ) );
2240
 
2241
+ $reply_to_name = $form_settings->form_from_name;
2242
  $reply_to_email = $form_settings->form_from;
2243
 
2244
  // Loop through name results and assign sender name to override, if needed
2263
  $copy_email = $_POST[ 'vfb-' . $notify->field_id ];
2264
  }
2265
 
2266
+ // Query to get all forms
2267
  $order = sanitize_sql_orderby( 'field_sequence ASC' );
2268
  $fields = $wpdb->get_results( $wpdb->prepare( "SELECT field_id, field_key, field_name, field_type, field_options, field_parent, field_required FROM $this->field_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
2269
 
2270
+ // Setup counter for alt rows
2271
  $i = $points = 0;
2272
 
2273
+ // Setup HTML email vars
2274
  $header = $body = $message = $footer = $html_email = $auto_response_email = $attachments = '';
2275
 
2276
+ // Prepare the beginning of the content
2277
  $header = '<html>
2278
  <head>
2279
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
2281
  </head>
2282
  <body><table rules="all" style="border-color: #666;" cellpadding="10">' . "\n";
2283
 
2284
+ // Loop through each form field and build the body of the message
2285
  foreach ( $fields as $field ) {
2286
+ // Handle attachments
2287
  if ( $field->field_type == 'file-upload' ) {
2288
  $value = ( isset( $_FILES[ 'vfb-' . $field->field_id ] ) ) ? $_FILES[ 'vfb-' . $field->field_id ] : '';
2289
 
2290
  if ( $value['size'] > 0 ) {
2291
+ // 25MB is the max size allowed
2292
  $size = apply_filters( 'vfb_max_file_size', 25 );
2293
  $max_attach_size = $size * 1048576;
2294
 
2295
+ // Display error if file size has been exceeded
2296
  if ( $value['size'] > $max_attach_size )
2297
  wp_die( __( 'File size exceeds 25MB. Most email providers will reject emails with attachments larger than 25MB. Please decrease the file size and try again.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
2298
 
2299
+ // Options array for the wp_handle_upload function. 'test_form' => false
2300
  $upload_overrides = array( 'test_form' => false );
2301
 
2302
+ // We need to include the file that runs the wp_handle_upload function
2303
  require_once( ABSPATH . 'wp-admin/includes/file.php' );
2304
 
2305
+ // Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array
2306
  $uploaded_file = wp_handle_upload( $value, $upload_overrides );
2307
 
2308
+ // If the wp_handle_upload call returned a local path for the image
2309
  if ( isset( $uploaded_file['file'] ) ) {
2310
+ // Retrieve the file type from the file name. Returns an array with extension and mime type
2311
  $wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );
2312
 
2313
+ // Return the current upload directory location
2314
  $wp_upload_dir = wp_upload_dir();
2315
 
2316
  $media_upload = array(
2317
+ 'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $uploaded_file['file'] ),
2318
+ 'post_mime_type' => $wp_filetype['type'],
2319
+ 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $uploaded_file['file'] ) ),
2320
+ 'post_content' => '',
2321
+ 'post_status' => 'inherit'
2322
  );
2323
 
2324
+ // Insert attachment into Media Library and get attachment ID
2325
  $attach_id = wp_insert_attachment( $media_upload, $uploaded_file['file'] );
2326
 
2327
+ // Include the file that runs wp_generate_attachment_metadata()
2328
  require_once( ABSPATH . 'wp-admin/includes/image.php' );
2329
 
2330
+ // Setup attachment metadata
2331
  $attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_file['file'] );
2332
 
2333
+ // Update the attachment metadata
2334
  wp_update_attachment_metadata( $attach_id, $attach_data );
2335
 
2336
  $attachments[ 'vfb-' . $field->field_id ] = $uploaded_file['file'];
2337
 
2338
  $data[] = array(
2339
+ 'id' => $field->field_id,
2340
+ 'slug' => $field->field_key,
2341
+ 'name' => $field->field_name,
2342
+ 'type' => $field->field_type,
2343
+ 'options' => $field->field_options,
2344
  'parent_id' => $field->field_parent,
2345
+ 'value' => $uploaded_file['url']
2346
  );
2347
 
2348
  $body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td><a href="' . $uploaded_file['url'] . '">' . $uploaded_file['url'] . '</a></td></tr>' . "\n";
2353
  $body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td>' . $value . '</td></tr>' . "\n";
2354
  }
2355
  }
2356
+ // Everything else
2357
  else {
2358
  $value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
2359
 
2360
+ // If time field, build proper output
2361
  if ( is_array( $value ) && array_key_exists( 'hour', $value ) && array_key_exists( 'min', $value ) )
2362
  $value = ( array_key_exists( 'ampm', $value ) ) ? substr_replace( implode( ':', $value ), ' ', 5, 1 ) : implode( ':', $value );
2363
+ // If address field, build proper output
2364
  elseif ( is_array( $value ) && array_key_exists( 'address', $value ) && array_key_exists( 'address-2', $value ) ) {
2365
  $address = '';
2366
 
2400
 
2401
  $value = html_entity_decode( stripslashes( esc_html( $address ) ), ENT_QUOTES, 'UTF-8' );
2402
  }
2403
+ // If multiple values, build the list
2404
  elseif ( is_array( $value ) )
2405
+ $value = esc_html( implode( ', ', $value ) );
2406
+ // Lastly, handle single values
2407
  else
2408
  $value = html_entity_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES, 'UTF-8' );
2409
 
2410
+ // Setup spam catcher RegEx
2411
+ $exploits = '/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i';
2412
+ $profanity = '/(beastial|bestial|blowjob|clit|cock|cum|cunilingus|cunillingus|cunnilingus|cunt|ejaculate|fag|felatio|fellatio|fuck|fuk|fuks|gangbang|gangbanged|gangbangs|hotsex|jism|jiz|kock|kondum|kum|kunilingus|orgasim|orgasims|orgasm|orgasms|phonesex|phuk|phuq|porn|pussies|pussy|spunk|xxx)/i';
2413
+ $spamwords = '/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i';
2414
 
2415
+ // Add up points for each spam hit
2416
  if ( preg_match( $exploits, $value ) )
2417
  $points += 2;
2418
  elseif ( preg_match( $profanity, $value ) )
2420
  elseif ( preg_match( $spamwords, $value ) )
2421
  $points += 1;
2422
 
2423
+ //Sanitize input
2424
+ $value = $this->sanitize_input( $value, $field->field_type );
2425
+
2426
  // Validate input
2427
  $this->validate_input( $value, $field->field_name, $field->field_type, $field->field_required );
2428
 
 
2429
  if ( !in_array( $field->field_type , array( 'verification', 'secret', 'submit' ) ) ) {
2430
  if ( $field->field_type == 'fieldset' )
2431
  $body .= '<tr style="background-color:#393E40;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
2436
  }
2437
 
2438
  $data[] = array(
2439
+ 'id' => $field->field_id,
2440
+ 'slug' => $field->field_key,
2441
+ 'name' => $field->field_name,
2442
+ 'type' => $field->field_type,
2443
+ 'options' => $field->field_options,
2444
  'parent_id' => $field->field_parent,
2445
+ 'value' => esc_html( $value )
2446
  );
2447
  }
2448
  }
2449
 
2450
+ // Setup our entries data
2451
  $entry = array(
2452
+ 'form_id' => $form_id,
2453
+ 'data' => serialize( $data ),
2454
+ 'subject' => $form_settings->form_subject,
2455
+ 'sender_name' => $form_settings->form_from_name,
2456
+ 'sender_email' => $form_settings->form_from,
2457
+ 'emails_to' => serialize( $form_settings->form_to ),
2458
+ 'date_submitted' => date_i18n( 'Y-m-d G:i:s' ),
2459
+ 'ip_address' => $_SERVER['REMOTE_ADDR']
2460
  );
2461
 
2462
+ // Insert this data into the entries table
2463
  $wpdb->insert( $this->entries_table_name, $entry );
2464
 
2465
+ // Close out the content
2466
  $footer .= '<tr><td class="footer" height="61" align="left" valign="middle" colspan="2"><p style="font-size: 12px; font-weight: normal; margin: 0; line-height: 16px; padding: 0;">This email was built and sent using <a href="http://wordpress.org/extend/plugins/visual-form-builder/" style="font-size: 12px;">Visual Form Builder</a>.</p></td></tr></table></body></html>' . "\n";
2467
 
2468
+ // Build complete HTML email
2469
  $message = $header . $body . $footer;
2470
 
2471
+ // Decode HTML for message so it outputs properly
2472
+ $notify_message = ( $form_settings->form_notification_message !== '' ) ? html_entity_decode( $form_settings->form_notification_message ) : '';
 
 
2473
 
2474
+ // Initialize header filter vars
2475
+ $this->header_from_name = stripslashes( $reply_to_name );
2476
+ $this->header_from = $reply_to_email;
2477
+ $this->header_content_type = 'text/html';
2478
 
2479
+ // Either prepend the notification message to the submitted entry, or send by itself
2480
+ if ( $form_settings->form_notification_entry !== '' )
2481
+ $auto_response_email = $header . $notify_message . $body . $footer;
2482
+ else
2483
+ $auto_response_email = $header . '<table cellspacing="0" border="0" cellpadding="0" width="100%"><tr><td colspan="2" class="mainbar" align="left" valign="top" width="600">' . $notify_message . '</td></tr>' . $footer;
2484
 
 
 
 
 
2485
 
2486
+ // Build email headers
2487
+ $from_name = ( $this->header_from_name == '' ) ? 'WordPress' : $this->header_from_name;
2488
+ $from_email = get_site_option( 'admin_email' );
2489
+ $reply_to = "\"$this->header_from_name\" <$this->header_from>";
2490
+ $headers = "From: \"$from_name\" <$from_email>\n" . "Reply-To: $reply_to\n" . "Content-Type: $this->header_content_type; charset=\"" . get_option('blog_charset') . "\"\n";
2491
 
2492
+ // Send the mail
2493
+ foreach ( $form_settings->form_to as $email ) {
2494
+ wp_mail( $email, wp_specialchars_decode( $form_settings->form_subject, ENT_QUOTES ), $message, $headers, $attachments );
2495
+ }
2496
 
2497
+ // Send auto-responder email
2498
  if ( $form_settings->form_notification_setting !== '' ) :
2499
 
 
 
 
 
 
 
 
 
2500
  $attachments = ( $form_settings->form_notification_entry !== '' ) ? $attachments : '';
2501
 
 
 
 
 
 
 
 
 
 
2502
  // Reset headers for notification email
2503
+ $reply_name = stripslashes( $form_settings->form_notification_email_name );
2504
+ $reply_email = $form_settings->form_notification_email_from;
2505
+ $reply_to = "\"$reply_name\" <$reply_email>";
2506
+ $headers = "From: \"$reply_name\" <$from_email>\n" . "Reply-To: $reply_to\n" . "Content-Type: $this->header_content_type; charset=\"" . get_option('blog_charset') . "\"\n";
2507
 
2508
+ // Send the mail
2509
+ wp_mail( $copy_email, wp_specialchars_decode( $form_settings->form_notification_subject ), $auto_response_email, $headers, $attachments );
2510
  endif;
2511
 
2512
  endif;
2520
  public function validate_input( $data, $name, $type, $required ) {
2521
 
2522
  if ( 'yes' == $required && strlen( $data ) == 0 )
2523
+ wp_die( "<h1>$name</h1><br>" . __( 'This field is required and cannot be empty.', 'visual-form-builder' ), $name, array( 'back_link' => true ) );
2524
 
2525
  if ( strlen( $data ) > 0 ) :
2526
  switch( $type ) {
2527
 
2528
  case 'email' :
2529
  if ( !is_email( $data ) )
2530
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid email address', 'visual-form-builder' ), '', array( 'back_link' => true ) );
2531
  break;
2532
 
2533
  case 'number' :
2534
  case 'currency' :
2535
  if ( !is_numeric( $data ) )
2536
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid number', 'visual-form-builder' ), '', array( 'back_link' => true ) );
2537
  break;
2538
 
2539
  case 'phone' :
2540
  if ( strlen( $data ) > 9 && preg_match( '/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/', $data ) )
2541
  return true;
2542
  else
2543
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid phone number. Most US/Canada and International formats accepted.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
2544
  break;
2545
 
2546
  case 'url' :
2547
  if ( !preg_match( '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $data ) )
2548
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid URL.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
2549
  break;
2550
 
2551
  default :
2554
  }
2555
  endif;
2556
  }
2557
+
2558
+ /**
2559
+ * Sanitize the input
2560
+ *
2561
+ * @since 2.5
2562
+ */
2563
+ public function sanitize_input( $data, $type ) {
2564
+ if ( strlen( $data ) > 0 ) :
2565
+ switch( $type ) {
2566
+ case 'text' :
2567
+ return sanitize_text_field( $data );
2568
+ break;
2569
+
2570
+ case 'textarea' :
2571
+ return wpautop( $data );
2572
+ break;
2573
+
2574
+ case 'email' :
2575
+ return sanitize_email( $data );
2576
+ break;
2577
+
2578
+ case 'username' :
2579
+ return sanitize_user( $data );
2580
+ break;
2581
+
2582
+ default :
2583
+ return $data;
2584
+ break;
2585
+ }
2586
+ endif;
2587
+ }
2588
 
2589
  /**
2590
  * Make sure the User Agent string is not a SPAM bot
2605
  $isBot = true;
2606
 
2607
  return $isBot;
2608
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2609
  }
2610
 
2611
+ // On plugin activation, install the databases and add/update the DB version
2612
  register_activation_hook( __FILE__, array( 'Visual_Form_Builder', 'install_db' ) );
2613
  ?>