Visual Form Builder - Version 2.9.5

Version Description

Download this release

Release Info

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

Code changes from version 2.9.4 to 2.9.5

Files changed (182) hide show
  1. admin/assets/css/index.php +1 -0
  2. {css → admin/assets/css}/visual-form-builder-admin.css +25 -25
  3. admin/assets/css/visual-form-builder-admin.min.css +1 -0
  4. {images → admin/assets/img}/arrows-2x.png +0 -0
  5. {images → admin/assets/img}/arrows-dark-2x.png +0 -0
  6. {images → admin/assets/img}/arrows-dark-vs-2x.png +0 -0
  7. {images → admin/assets/img}/arrows-dark-vs.png +0 -0
  8. {images → admin/assets/img}/arrows-dark.png +0 -0
  9. {images → admin/assets/img}/arrows-vs-2x.png +0 -0
  10. {images → admin/assets/img}/arrows-vs.png +0 -0
  11. {images → admin/assets/img}/arrows.png +0 -0
  12. admin/assets/img/index.php +1 -0
  13. {images → admin/assets/img}/vfb-form-items-2x.png +0 -0
  14. {images → admin/assets/img}/vfb-form-items.png +0 -0
  15. {images → admin/assets/img}/vfb-interface-icons-2x.png +0 -0
  16. {images → admin/assets/img}/vfb-interface-icons.png +0 -0
  17. admin/assets/index.php +1 -0
  18. admin/assets/js/index.php +1 -0
  19. {js → admin/assets/js}/jquery.ui.nestedSortable.js +0 -0
  20. {js → admin/assets/js}/jquery.ui.nestedSortable.min.js +0 -0
  21. {js → admin/assets/js}/jquery.validate.min.js +0 -0
  22. {js → admin/assets/js}/vfb-admin.js +1 -12
  23. admin/assets/js/vfb-admin.min.js +1 -0
  24. {js → admin/assets/js}/vfb-validation.js +0 -0
  25. {js → admin/assets/js}/vfb-validation.min.js +0 -0
  26. admin/class-admin-menu.php +390 -0
  27. admin/class-admin-notices.php +124 -0
  28. admin/class-ajax.php +208 -0
  29. admin/class-dashboard-widgets.php +121 -0
  30. {includes → admin}/class-entries-detail.php +6 -34
  31. {includes → admin}/class-entries-list.php +16 -42
  32. {includes → admin}/class-export.php +35 -77
  33. admin/class-fields.php +455 -0
  34. admin/class-forms-edit.php +449 -0
  35. {includes → admin}/class-forms-list.php +27 -46
  36. admin/class-forms-metaboxes.php +71 -0
  37. admin/class-forms-new.php +76 -0
  38. admin/class-load-css-js.php +38 -0
  39. admin/class-media-button.php +96 -0
  40. admin/class-page-settings.php +115 -0
  41. admin/class-save.php +408 -0
  42. admin/class-screen-options.php +61 -0
  43. {includes → admin}/class-widget.php +22 -33
  44. admin/index.php +1 -0
  45. css/visual-form-builder-admin.min.css +0 -1
  46. inc/class-i18n.php +57 -0
  47. inc/class-install.php +103 -0
  48. inc/class-list-table.php +1365 -0
  49. inc/countries.php +213 -0
  50. inc/index.php +1 -0
  51. includes/admin-field-options.php +0 -448
  52. includes/admin-form-creator.php +0 -395
  53. includes/admin-new-form.php +0 -58
  54. includes/email.php +0 -406
  55. includes/form-output.php +0 -639
  56. js/vfb-admin.min.js +0 -1
  57. {languages → lang}/visual-form-builder-bg_BG.mo +0 -0
  58. {languages → lang}/visual-form-builder-bg_BG.po +0 -0
  59. {languages → lang}/visual-form-builder-es_ES.mo +0 -0
  60. {languages → lang}/visual-form-builder-es_ES.po +0 -0
  61. {languages → lang}/visual-form-builder-fr_FR.mo +0 -0
  62. {languages → lang}/visual-form-builder-fr_FR.po +0 -0
  63. {languages → lang}/visual-form-builder-hu_HU.mo +0 -0
  64. {languages → lang}/visual-form-builder-hu_HU.po +0 -0
  65. {languages → lang}/visual-form-builder-nl_NL.mo +0 -0
  66. {languages → lang}/visual-form-builder-nl_NL.po +0 -0
  67. {languages → lang}/visual-form-builder-pt_PT.mo +0 -0
  68. {languages → lang}/visual-form-builder-pt_PT.po +0 -0
  69. {languages → lang}/visual-form-builder.pot +0 -0
  70. public/assets/css/index.php +1 -0
  71. {css → public/assets/css}/smoothness/images/animated-overlay.gif +0 -0
  72. public/assets/css/smoothness/images/index.php +1 -0
  73. {css → public/assets/css}/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  74. {css → public/assets/css}/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  75. {css → public/assets/css}/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  76. {css → public/assets/css}/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  77. {css → public/assets/css}/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  78. {css → public/assets/css}/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  79. {css → public/assets/css}/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  80. {css → public/assets/css}/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  81. {css → public/assets/css}/smoothness/images/ui-icons_222222_256x240.png +0 -0
  82. {css → public/assets/css}/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  83. {css → public/assets/css}/smoothness/images/ui-icons_454545_256x240.png +0 -0
  84. {css → public/assets/css}/smoothness/images/ui-icons_888888_256x240.png +0 -0
  85. {css → public/assets/css}/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  86. public/assets/css/smoothness/index.php +1 -0
  87. {css → public/assets/css}/smoothness/jquery-ui-1.10.3.css +0 -0
  88. {css → public/assets/css}/smoothness/jquery-ui-1.10.3.min.css +0 -0
  89. {css → public/assets/css}/visual-form-builder.css +0 -0
  90. {css → public/assets/css}/visual-form-builder.min.css +0 -0
  91. public/assets/index.php +1 -0
  92. {js → public/assets/js}/ckeditor/ckeditor.js +0 -0
  93. {js → public/assets/js}/ckeditor/config.js +0 -0
  94. {js → public/assets/js}/ckeditor/contents.css +0 -0
  95. public/assets/js/ckeditor/index.php +1 -0
  96. {js → public/assets/js}/ckeditor/lang/en.js +0 -0
  97. {js → public/assets/js}/ckeditor/plugins/dialog/dialogDefinition.js +0 -0
  98. {js → public/assets/js}/ckeditor/plugins/icons.png +0 -0
  99. {js → public/assets/js}/ckeditor/plugins/link/dialogs/anchor.js +0 -0
  100. {js → public/assets/js}/ckeditor/plugins/link/dialogs/link.js +0 -0
  101. {js → public/assets/js}/ckeditor/plugins/link/images/anchor.png +0 -0
  102. {js → public/assets/js}/ckeditor/skins/moono/dialog.css +0 -0
  103. {js → public/assets/js}/ckeditor/skins/moono/dialog_ie.css +0 -0
  104. {js → public/assets/js}/ckeditor/skins/moono/dialog_ie7.css +0 -0
  105. {js → public/assets/js}/ckeditor/skins/moono/dialog_ie8.css +0 -0
  106. {js → public/assets/js}/ckeditor/skins/moono/dialog_iequirks.css +0 -0
  107. {js → public/assets/js}/ckeditor/skins/moono/dialog_opera.css +0 -0
  108. {js → public/assets/js}/ckeditor/skins/moono/editor.css +0 -0
  109. {js → public/assets/js}/ckeditor/skins/moono/editor_gecko.css +0 -0
  110. {js → public/assets/js}/ckeditor/skins/moono/editor_ie.css +0 -0
  111. {js → public/assets/js}/ckeditor/skins/moono/editor_ie7.css +0 -0
  112. {js → public/assets/js}/ckeditor/skins/moono/editor_ie8.css +0 -0
  113. {js → public/assets/js}/ckeditor/skins/moono/editor_iequirks.css +0 -0
  114. {js → public/assets/js}/ckeditor/skins/moono/icons.png +0 -0
  115. {js → public/assets/js}/ckeditor/skins/moono/images/arrow.png +0 -0
  116. {js → public/assets/js}/ckeditor/skins/moono/images/close.png +0 -0
  117. {js → public/assets/js}/ckeditor/skins/moono/images/mini.png +0 -0
  118. {js → public/assets/js}/ckeditor/skins/moono/readme.md +0 -0
  119. {js → public/assets/js}/i18n/datepicker/datepicker-cs_CS.js +0 -0
  120. {js → public/assets/js}/i18n/datepicker/datepicker-de_DE.js +0 -0
  121. {js → public/assets/js}/i18n/datepicker/datepicker-el_GR.js +0 -0
  122. {js → public/assets/js}/i18n/datepicker/datepicker-en_AU.js +0 -0
  123. {js → public/assets/js}/i18n/datepicker/datepicker-en_GB.js +0 -0
  124. {js → public/assets/js}/i18n/datepicker/datepicker-en_US.js +0 -0
  125. {js → public/assets/js}/i18n/datepicker/datepicker-es_ES.js +0 -0
  126. {js → public/assets/js}/i18n/datepicker/datepicker-fr_FR.js +0 -0
  127. {js → public/assets/js}/i18n/datepicker/datepicker-he_IL.js +0 -0
  128. {js → public/assets/js}/i18n/datepicker/datepicker-hu_HU.js +0 -0
  129. {js → public/assets/js}/i18n/datepicker/datepicker-id_ID.js +0 -0
  130. {js → public/assets/js}/i18n/datepicker/datepicker-it_IT.js +0 -0
  131. {js → public/assets/js}/i18n/datepicker/datepicker-ja_JP.js +0 -0
  132. {js → public/assets/js}/i18n/datepicker/datepicker-ko_KR.js +0 -0
  133. {js → public/assets/js}/i18n/datepicker/datepicker-nl_NL.js +0 -0
  134. {js → public/assets/js}/i18n/datepicker/datepicker-pl_PL.js +0 -0
  135. {js → public/assets/js}/i18n/datepicker/datepicker-pt_BR.js +0 -0
  136. {js → public/assets/js}/i18n/datepicker/datepicker-pt_PT.js +0 -0
  137. {js → public/assets/js}/i18n/datepicker/datepicker-ro_RO.js +0 -0
  138. {js → public/assets/js}/i18n/datepicker/datepicker-ru_RU.js +0 -0
  139. {js → public/assets/js}/i18n/datepicker/datepicker-sv_SE.js +0 -0
  140. {js → public/assets/js}/i18n/datepicker/datepicker-tr_TR.js +0 -0
  141. {js → public/assets/js}/i18n/datepicker/datepicker-zh_CN.js +0 -0
  142. {js → public/assets/js}/i18n/datepicker/datepicker-zh_TW.js +0 -0
  143. public/assets/js/i18n/datepicker/index.php +1 -0
  144. public/assets/js/i18n/index.php +1 -0
  145. public/assets/js/i18n/validate/index.php +1 -0
  146. {js → public/assets/js}/i18n/validate/messages-cs_CS.js +0 -0
  147. {js → public/assets/js}/i18n/validate/messages-de_DE.js +0 -0
  148. {js → public/assets/js}/i18n/validate/messages-el_GR.js +0 -0
  149. {js → public/assets/js}/i18n/validate/messages-en_AU.js +0 -0
  150. {js → public/assets/js}/i18n/validate/messages-en_GB.js +0 -0
  151. {js → public/assets/js}/i18n/validate/messages-en_US.js +0 -0
  152. {js → public/assets/js}/i18n/validate/messages-es_ES.js +0 -0
  153. {js → public/assets/js}/i18n/validate/messages-fr_FR.js +0 -0
  154. {js → public/assets/js}/i18n/validate/messages-he_IL.js +0 -0
  155. {js → public/assets/js}/i18n/validate/messages-hu_HU.js +0 -0
  156. {js → public/assets/js}/i18n/validate/messages-id_ID.js +0 -0
  157. {js → public/assets/js}/i18n/validate/messages-it_IT.js +0 -0
  158. {js → public/assets/js}/i18n/validate/messages-ja_JP.js +0 -0
  159. {js → public/assets/js}/i18n/validate/messages-ko_KR.js +0 -0
  160. {js → public/assets/js}/i18n/validate/messages-nl_NL.js +0 -0
  161. {js → public/assets/js}/i18n/validate/messages-pl_PL.js +0 -0
  162. {js → public/assets/js}/i18n/validate/messages-pt_BR.js +0 -0
  163. {js → public/assets/js}/i18n/validate/messages-pt_PT.js +0 -0
  164. {js → public/assets/js}/i18n/validate/messages-ro_RO.js +0 -0
  165. {js → public/assets/js}/i18n/validate/messages-ru_RU.js +0 -0
  166. {js → public/assets/js}/i18n/validate/messages-sv_SE.js +0 -0
  167. {js → public/assets/js}/i18n/validate/messages-tr_TR.js +0 -0
  168. {js → public/assets/js}/i18n/validate/messages-zh_CN.js +0 -0
  169. {js → public/assets/js}/i18n/validate/messages-zh_TW.js +0 -0
  170. public/assets/js/index.php +1 -0
  171. {js → public/assets/js}/jquery.metadata.js +0 -0
  172. public/assets/js/jquery.validate.min.js +51 -0
  173. public/assets/js/vfb-validation.js +48 -0
  174. public/assets/js/vfb-validation.min.js +1 -0
  175. public/class-confirmation.php +166 -0
  176. public/class-email.php +635 -0
  177. public/class-form-display.php +846 -0
  178. public/class-load-css-js.php +139 -0
  179. public/class-security.php +107 -0
  180. public/index.php +1 -0
  181. readme.txt +13 -16
  182. visual-form-builder.php +154 -2093
admin/assets/css/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
{css → admin/assets/css}/visual-form-builder-admin.css RENAMED
@@ -651,13 +651,13 @@ strong .vfb-meta-entries-total span {
651
  overflow: hidden;
652
  width:30px;
653
  height: 40px;
654
- background:url('../images/arrows.png?d=20130703') no-repeat scroll 8px 10px transparent;
655
  text-indent:-999em;
656
  }
657
 
658
  /* Blue Admin style */
659
  .admin-color-classic .item-edit {
660
- background: url('../images/arrows-vs.png?d=20130703') no-repeat scroll 8px 10px transparent;
661
  }
662
 
663
  .rtl .item-edit {
@@ -666,30 +666,30 @@ strong .vfb-meta-entries-total span {
666
  }
667
 
668
  .item-edit:hover{
669
- background:url('../images/arrows-dark.png?d=20130703') no-repeat scroll 8px 10px transparent;
670
  }
671
 
672
  /* Blue Admin style */
673
  .admin-color-classic .item-edit:hover {
674
- background: url('../images/arrows-dark-vs.png?d=20130703') no-repeat scroll 8px 10px transparent;
675
  }
676
 
677
  .item-edit.opened{
678
- background:url('../images/arrows.png?d=20130703') no-repeat scroll 8px -25px transparent;
679
  }
680
 
681
  /* Blue Admin style */
682
  .admin-color-classic .item-edit.opened {
683
- background: url('../images/arrows-vs.png?d=20130703') no-repeat scroll 8px -25px transparent;
684
  }
685
 
686
  .item-edit.opened:hover{
687
- background:url('../images/arrows-dark.png?d=20130703') no-repeat scroll 8px -25px transparent;
688
  }
689
 
690
  /* Blue Admin style */
691
  .admin-color-classic .item-edit.opened:hover {
692
- background: url('../images/arrows-dark-vs.png?d=20130703') no-repeat scroll 8px -25px transparent;
693
  }
694
 
695
  /* !Field Item attribute input styles */
@@ -745,7 +745,7 @@ strong .vfb-meta-entries-total span {
745
  width: 16px;
746
  height: 16px;
747
  background-color: transparent;
748
- background-image: url('../images/vfb-interface-icons.png?d=20130713');
749
  background-repeat: no-repeat;
750
  text-indent: -9999px;
751
  }
@@ -1156,7 +1156,7 @@ ul.vfb-fields-col-2{
1156
  width:16px;
1157
  height:16px;
1158
  background-color: transparent;
1159
- background-image: url('../images/vfb-form-items.png?d=20130712');
1160
  background-repeat: no-repeat;
1161
  line-height: 16px;
1162
  }
@@ -1616,13 +1616,13 @@ ul.vfb-fields-col-2{
1616
  /* Interface icons */
1617
  .vfb-interface-icon {
1618
  top: 5px;
1619
- background-image: url( '../images/vfb-interface-icons-2x.png?d=20130712' );
1620
  background-size: cover;
1621
  }
1622
 
1623
  /* Form items */
1624
  .vfb-draggable-form-items b {
1625
- background-image: url( '../images/vfb-form-items-2x.png?d=20130712' );
1626
  background-size: cover;
1627
  }
1628
 
@@ -1637,69 +1637,69 @@ ul.vfb-fields-col-2{
1637
 
1638
  /* Field Item arrows */
1639
  .item-edit {
1640
- background-image: url('../images/arrows-2x.png?d=20130611');
1641
  background-size: 15px 123px;
1642
  }
1643
 
1644
  /* Blue Admin style */
1645
  .admin-color-classic .item-edit {
1646
- background-image: url('../images/arrows-vs-2x.png?d=20130611');
1647
  background-size: 15px 123px;
1648
  }
1649
 
1650
  .item-edit:hover{
1651
- background-image: url('../images/arrows-dark-2x.png?d=20130611');
1652
  background-size: 15px 123px;
1653
  }
1654
 
1655
  /* Blue Admin style */
1656
  .admin-color-classic .item-edit:hover {
1657
- background-image: url('../images/arrows-dark-vs-2x.png?d=20130611');
1658
  background-size: 15px 123px;
1659
  }
1660
 
1661
  .item-edit.opened{
1662
- background-image: url('../images/arrows-2x.png?d=20130611');
1663
  background-size: 15px 123px;
1664
  }
1665
 
1666
  /* Blue Admin style */
1667
  .admin-color-classic .item-edit.opened {
1668
- background-image: url('../images/arrows-vs-2x.png?d=20130611');
1669
  background-size: 15px 123px;
1670
  }
1671
 
1672
  .item-edit.opened:hover{
1673
- background-image: url('../images/arrows-dark-2x.png?d=20130611');
1674
  background-size: 15px 123px;
1675
  }
1676
 
1677
  /* Blue Admin style */
1678
  .admin-color-classic .item-edit.opened:hover {
1679
- background-image: url('../images/arrows-dark-vs-2x.png?d=20130611');
1680
  background-size: 15px 123px;
1681
  }
1682
 
1683
  /* Form Settings arrow */
1684
  .button-icon.vfb-small-arrow{
1685
- background-image: url('../images/arrows-2x.png?d=20130611');
1686
  background-size: 15px 123px;
1687
  }
1688
 
1689
  /* Blue Admin style */
1690
  .admin-color-classic .button-icon.vfb-small-arrow {
1691
- background-image: url('../images/arrows-vs-2x.png?d=20130611');
1692
  background-size: 15px 123px;
1693
  }
1694
 
1695
  .current .button-icon.vfb-small-arrow{
1696
- background-image: url('../images/arrows-2x.png?d=20130611');
1697
  background-size: 15px 123px;
1698
  }
1699
 
1700
  /* Blue Admin style */
1701
  .admin-color-classic .current .button-icon.vfb-small-arrow {
1702
- background-image: url('../images/arrows-vs.png?d=20130611');
1703
  background-size: 15px 123px;
1704
  }
1705
- }
651
  overflow: hidden;
652
  width:30px;
653
  height: 40px;
654
+ background:url('../img/arrows.png?d=20130703') no-repeat scroll 8px 10px transparent;
655
  text-indent:-999em;
656
  }
657
 
658
  /* Blue Admin style */
659
  .admin-color-classic .item-edit {
660
+ background: url('../img/arrows-vs.png?d=20130703') no-repeat scroll 8px 10px transparent;
661
  }
662
 
663
  .rtl .item-edit {
666
  }
667
 
668
  .item-edit:hover{
669
+ background:url('../img/arrows-dark.png?d=20130703') no-repeat scroll 8px 10px transparent;
670
  }
671
 
672
  /* Blue Admin style */
673
  .admin-color-classic .item-edit:hover {
674
+ background: url('../img/arrows-dark-vs.png?d=20130703') no-repeat scroll 8px 10px transparent;
675
  }
676
 
677
  .item-edit.opened{
678
+ background:url('../img/arrows.png?d=20130703') no-repeat scroll 8px -25px transparent;
679
  }
680
 
681
  /* Blue Admin style */
682
  .admin-color-classic .item-edit.opened {
683
+ background: url('../img/arrows-vs.png?d=20130703') no-repeat scroll 8px -25px transparent;
684
  }
685
 
686
  .item-edit.opened:hover{
687
+ background:url('../img/arrows-dark.png?d=20130703') no-repeat scroll 8px -25px transparent;
688
  }
689
 
690
  /* Blue Admin style */
691
  .admin-color-classic .item-edit.opened:hover {
692
+ background: url('../img/arrows-dark-vs.png?d=20130703') no-repeat scroll 8px -25px transparent;
693
  }
694
 
695
  /* !Field Item attribute input styles */
745
  width: 16px;
746
  height: 16px;
747
  background-color: transparent;
748
+ background-image: url('../img/vfb-interface-icons.png?d=20130713');
749
  background-repeat: no-repeat;
750
  text-indent: -9999px;
751
  }
1156
  width:16px;
1157
  height:16px;
1158
  background-color: transparent;
1159
+ background-image: url('../img/vfb-form-items.png?d=20130712');
1160
  background-repeat: no-repeat;
1161
  line-height: 16px;
1162
  }
1616
  /* Interface icons */
1617
  .vfb-interface-icon {
1618
  top: 5px;
1619
+ background-image: url( '../img/vfb-interface-icons-2x.png?d=20130712' );
1620
  background-size: cover;
1621
  }
1622
 
1623
  /* Form items */
1624
  .vfb-draggable-form-items b {
1625
+ background-image: url( '../img/vfb-form-items-2x.png?d=20130712' );
1626
  background-size: cover;
1627
  }
1628
 
1637
 
1638
  /* Field Item arrows */
1639
  .item-edit {
1640
+ background-image: url('../img/arrows-2x.png?d=20130611');
1641
  background-size: 15px 123px;
1642
  }
1643
 
1644
  /* Blue Admin style */
1645
  .admin-color-classic .item-edit {
1646
+ background-image: url('../img/arrows-vs-2x.png?d=20130611');
1647
  background-size: 15px 123px;
1648
  }
1649
 
1650
  .item-edit:hover{
1651
+ background-image: url('../img/arrows-dark-2x.png?d=20130611');
1652
  background-size: 15px 123px;
1653
  }
1654
 
1655
  /* Blue Admin style */
1656
  .admin-color-classic .item-edit:hover {
1657
+ background-image: url('../img/arrows-dark-vs-2x.png?d=20130611');
1658
  background-size: 15px 123px;
1659
  }
1660
 
1661
  .item-edit.opened{
1662
+ background-image: url('../img/arrows-2x.png?d=20130611');
1663
  background-size: 15px 123px;
1664
  }
1665
 
1666
  /* Blue Admin style */
1667
  .admin-color-classic .item-edit.opened {
1668
+ background-image: url('../img/arrows-vs-2x.png?d=20130611');
1669
  background-size: 15px 123px;
1670
  }
1671
 
1672
  .item-edit.opened:hover{
1673
+ background-image: url('../img/arrows-dark-2x.png?d=20130611');
1674
  background-size: 15px 123px;
1675
  }
1676
 
1677
  /* Blue Admin style */
1678
  .admin-color-classic .item-edit.opened:hover {
1679
+ background-image: url('../img/arrows-dark-vs-2x.png?d=20130611');
1680
  background-size: 15px 123px;
1681
  }
1682
 
1683
  /* Form Settings arrow */
1684
  .button-icon.vfb-small-arrow{
1685
+ background-image: url('../img/arrows-2x.png?d=20130611');
1686
  background-size: 15px 123px;
1687
  }
1688
 
1689
  /* Blue Admin style */
1690
  .admin-color-classic .button-icon.vfb-small-arrow {
1691
+ background-image: url('../img/arrows-vs-2x.png?d=20130611');
1692
  background-size: 15px 123px;
1693
  }
1694
 
1695
  .current .button-icon.vfb-small-arrow{
1696
+ background-image: url('../img/arrows-2x.png?d=20130611');
1697
  background-size: 15px 123px;
1698
  }
1699
 
1700
  /* Blue Admin style */
1701
  .admin-color-classic .current .button-icon.vfb-small-arrow {
1702
+ background-image: url('../img/arrows-vs.png?d=20130611');
1703
  background-size: 15px 123px;
1704
  }
1705
+ }
admin/assets/css/visual-form-builder-admin.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .vfb-btn,.vfb-btn-primary{filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.vfb-btn,.vfb-interface-sort:hover{cursor:pointer}.vfb-pro-call-to-action{padding:5px 0;text-align:center}.vfb-btn{display:inline-block;padding:15px 10px;margin-bottom:0;line-height:20px;text-align:center;vertical-align:middle;color:#333;font-size:21px;font-weight:500;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-repeat:repeat-x;border:1px solid #ccc;border-bottom-color:#b3b3b3;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);text-decoration:none}.vfb-btn-inverse,.vfb-btn-primary{background-repeat:repeat-x;text-shadow:0 -1px 0 rgba(0,0,0,.25)}.vfb-btn:focus,.vfb-btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.vfb-btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.vfb-btn.active,.vfb-btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.vfb-btn-primary{color:#fff;background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25)}.vfb-btn-primary.active,.vfb-btn-primary.disabled,.vfb-btn-primary:active,.vfb-btn-primary:focus,.vfb-btn-primary:hover,.vfb-btn-primary[disabled]{color:#fff;background-color:#04c}.vfb-btn-primary.active,.vfb-btn-primary:active{background-color:#039\9}.vfb-btn-inverse{background-color:#363636;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);color:#FFF}.vfb-btn-inverse.active,.vfb-btn-inverse.disabled,.vfb-btn-inverse:active,.vfb-btn-inverse:focus,.vfb-btn-inverse:hover,.vfb-btn-inverse[disabled]{background-color:#222;color:#FFF}.vfb-pro-call-to-action .cta-sign-up{color:#fff;display:block;font-size:24px;font-weight:700;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:400;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}.rtl .vfb-pro-upgrade{float:right}.vfb-pro-upgrade h2,.wrap .vfb-pro-upgrade h2{font-size:23px;font-weight:500;padding:5px 0;text-align:center}.vfb-pro-upgrade h2 a{text-decoration:none}.vfb-pro-upgrade ul{list-style:outside;margin-left:10px}.rtl .vfb-pro-upgrade ul{margin-left:0;margin-right:10px}#vfb-form-builder-frame{display:block;margin:0 -8px 0 290px}.rtl #vfb-form-builder-frame{margin:0 290px 0 -8px}#form-editor-footer .vfb-major-publishing-actions:after,#form-editor-header .vfb-major-publishing-actions:after,#vfb-form-builder-frame .menu-item-settings:after,#vfb-form-builder-frame:after,#vfb-form-list:after,.option:after{display:block;visibility:hidden;clear:both;height:0;content:"."}#vfb-form-builder-sidebar{clear:both;width:281px}#vfb-form-builder-management{position:relative;margin-right:10px}.rtl #vfb-form-builder-management{margin-right:0;margin-left:10px}#vfb-form-builder-management .form-edit{margin-bottom:20px;border:1px solid #dfdfdf;border-radius:3px}.admin-color-classic #vfb-form-builder-management .form-edit{border-color:#D0DFE9}#form-editor-footer,#form-editor-header{padding:0 10px;background-color:#f1f1f1}#form-editor-footer{border-top:1px solid #dfdfdf}.admin-color-classic #form-editor-footer,.admin-color-classic #form-editor-header{background-color:#F5FAFD}.admin-color-class #form-editor-footer{border-top-color:#D0DFE9}.vfb-major-publishing-actions{clear:both;padding:3px 0 5px}.vfb-major-publishing-actions .publishing-action{float:right;margin:5px 0 1px;text-align:right;line-height:23px}#form-editor-header .publishing-action{margin-top:12px}.sub-navigation{float:none;margin:8px 0 5px;padding:0;list-style:none;white-space:nowrap;font-size:12px}.sub-navigation li{display:inline;margin:0;padding:0}.sub-navigation a{padding:.2em;text-decoration:none;line-height:2}.sub-navigation a.current{border:none;background:0 0;color:#000;font-weight:700}.sub-navigation a:hover{color:#d54e21}#vfb-main,#vfb-sidebar{float:left;margin:10px 0;width:280px}.rtl #vfb-main,.rtl #vfb-sidebar{float:right}#vfb-main{width:auto}#vfb-main.vfb-order-type-list{width:100%}#vfb-main h3 a,#vfb-main p a{text-decoration:none}#vfb-main .submitdelete{color:#BC0B0B;text-decoration:none}#vfb-main .submitdelete:hover{color:red}#vfb-sidebar{margin-left:-300px}.rtl #vfb-sidebar{margin-left:0;margin-right:-300px}#vfb-form-list{display:block;margin-left:300px}.rtl #vfb-form-list{margin-left:0;margin-right:300px}.vfb-box{position:relative;float:left;padding:0 10px;border:1px solid #DFDFDF;border-radius:3px;background-color:#F5F5F5;background:-moz-linear-gradient(top,#fff 0,#f5f5f5 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#fff),color-stop(100%,#f5f5f5));background:-webkit-linear-gradient(top,#fff 0,#f5f5f5 100%);background:-o-linear-gradient(top,#fff 0,#f5f5f5 100%);background:-ms-linear-gradient(top,#fff 0,#f5f5f5 100%);background:linear-gradient(to bottom,#fff 0,#f5f5f5 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f5f5f5', GradientType=0 );box-shadow:0 1px 0 #FFF inset;line-height:1.4em}.vfb-form-alpha-list{width:70%;float:left;padding-right:20px}.rtl .vfb-form-alpha-list{float:right;padding-right:0;padding-left:20px}.vfb-form-alpha-list hr{display:block;margin:1em 0;padding:0;height:1px;border:0;border-top:1px solid #ccc}.vfb-form-alpha-group .letter,.wrap h2.letter{float:left;padding:0;color:#666;font-size:14px;line-height:17px}.vfb-form-alpha-form{display:block;margin:10px 0;padding-left:150px;width:auto}.vfb-form-alpha-form h3{float:left;margin:0;width:50%;word-wrap:break-word;font-size:17px}.vfb-form-alpha-form .vfb-form-meta,.vfb-form-alpha-form .vfb-publishing-actions{float:left;width:20%;text-align:center}.vfb-form-alpha-form .vfb-form-meta{width:30%}.vfb-form-alpha-form .vfb-form-meta p,.vfb-form-alpha-form .vfb-publishing-actions p{margin:0}.vfb-form-alpha-form .paypal,.vfb-form-alpha-form .vfb-form-meta{float:left;margin:0;text-align:left}.rtl .vfb-form-alpha-form .paypal,.rtl .vfb-form-alpha-form .vfb-form-meta{float:right;text-align:right}.vfb-sortable-placeholder{display:block;height:35px;width:400px;margin:8px;border:1px dashed #bbb;background-color:#f5f5f5}#vfb-main .vfb-sortable-placeholder{float:left;margin:8px;height:200px;width:210px}.rtl #vfb-main .vfb-sortable-placeholder{float:right}#vfb-menu-to-edit .mjs-nestedSortable-error{border-color:red;background-color:#fbe3e4;color:#8a1f11}.vfb-meta-entries-total span,.vfb-meta-entries-total-today span{font-size:11px;font-weight:700;height:1.4em;line-height:1.4em;min-width:.7em;padding:0 6px;display:inline-block;border-radius:5px;background-color:#bbb;color:#fff;text-align:center}.vfb-meta-entries-total-today:hover span,.vfb-meta-entries-total:hover span{background-color:#d54e21}.fixed .column-entries,.fixed .column-form_id{width:8em}strong .vfb-meta-entries-total span{background-color:#21759B}.entries-count-wrapper{font-family:sans-serif;min-width:22px;padding-bottom:1px}#new-form{margin:8px 0;padding-top:10px;width:75px;height:105px;text-align:center}#new-form a{display:block;width:auto;text-decoration:none}#post-body{padding:10px;background:#fff}.vfb-postbox-container{float:left;margin:0 8px;width:100%}.rtl .vfb-postbox-container{float:right}#vfb-postbox-container-1 .postbox{min-width:281px}#vfb-postbox-container-2{min-width:485px}#vfb-form-builder-frame.columns-1{margin-left:-8px}.rtl #vfb-form-builder-frame.columns-1{margin-left:0;margin-right:-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{margin-left:-290px;width:281px}.rtl #vfb-form-builder-frame.columns-2 #vfb-postbox-container-1,.rtl #vfb-form-builder-frame.columns-3 #vfb-postbox-container-1{margin-left:0;margin-right:-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%}.rtl #vfb-form-builder-frame.columns-3 #vfb-postbox-container-3{margin-right:0;margin-left:0}#vfb-form-meta-preview iframe{width:100%;height:100%}#vfb_form_media_button_tip input{width:100%;border:0;padding:6px;font-family:Consolas,Monaco,monospace;font-size:12px}@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;top:3px;right:-20px;display:block;overflow:hidden;width:30px;height:40px;background:url(../img/arrows.png?d=20130703) 8px 10px no-repeat;text-indent:-999em}.admin-color-classic .item-edit{background:url(../img/arrows-vs.png?d=20130703) 8px 10px no-repeat}.rtl .item-edit{right:auto;left:-20px}.item-edit:hover{background:url(../img/arrows-dark.png?d=20130703) 8px 10px no-repeat}.admin-color-classic .item-edit:hover{background:url(../img/arrows-dark-vs.png?d=20130703) 8px 10px no-repeat}.item-edit.opened{background:url(../img/arrows.png?d=20130703) 8px -25px no-repeat}.admin-color-classic .item-edit.opened{background:url(../img/arrows-vs.png?d=20130703) 8px -25px no-repeat}.item-edit.opened:hover{background:url(../img/arrows-dark.png?d=20130703) 8px -25px no-repeat}.admin-color-classic .item-edit.opened:hover{background:url(../img/arrows-dark-vs.png?d=20130703) 8px -25px no-repeat}.option .widefat,.options-other-hide .widefat,.options-other-show .widefat{margin:0 6px 7px 0;width:320px}.rtl .option .widefat,.rtl .options-other-hide .widefat,.rtl .options-other-show .widefat{margin:0 0 7px 6px}#form-settings .description-thin{margin:12px 10px 12px 0}.rtl #form-settings .description-thin{margin:12px 0 12px 10px}.description-thin,.description-wide{float:left;margin-right:10px}.rtl .description-thin,.rtl .description-wide{float:right;margin-right:0;margin-left:10px}.description-thin{width:190px;height:40px}.description-wide{width:390px}.vfb-interface-icon{position:absolute;top:4px;right:4px;display:inline-block;width:16px;height:16px;background-color:transparent;background-image:url(../img/vfb-interface-icons.png?d=20130713);background-repeat:no-repeat;text-indent:-9999px}.vfb-interface-settings{background-position:-32px 0}.vfb-interface-duplicate{background-position:0 0}.vfb-interface-trash{background-position:-64px 0}.vfb-interface-conditional{background-position:-224px 0}.vfb-interface-sort{background-position:-128px 0}.vfb-interface-plus{background-position:-160px 0}.vfb-interface-minus{background-position:-192px 0}.vfb-interface-bulk-add{background-position:-96px 0}.vfb-interface-minus,.vfb-interface-plus{top:0}.addEmail,.deleteEmail{top:28px}.addEmail{right:55px}.rtl .addEmail{right:auto;left:55px}.deleteEmail{right:30px}.rtl .deleteEmail{right:auto;left:30px}.addCondition,.deleteCondition,.deleteOption,.vfb-interface-sort{top:3px}.addCondition,.deleteOption{right:25px}.rtl .addCondition,.rtl .deleteOption{right:auto;left:25px}.deleteCondition,.vfb-interface-sort{right:0}.rtl .deleteCondition,.rtl .vfb-interface-sort{right:auto;left:0}.option{float:left;width:97%;position:relative}.rtl .option{float:right}#vfb-poststuff{display:block;margin-right:300px}.rtl #vfb-poststuff{margin-right:0;margin-left:300px}#vfb-entries-body-content{float:left;width:100%}.rtl #vfb-entries-body-content{float:right}.metabox-holder #vfb-entries-body-content h3{font-weight:700;font-family:sans-serif}#entry-edit #side-info-column{margin-right:-300px}.rtl #entry-edit #side-info-column{margin-right:0;margin-left:-300px}label.error{display:block;color:red}#visual-form-builder-update input.error,#visual-form-builder-update select.error,#visual-form-builder-update textarea.error{border:1px solid red}#vfb-menu-to-edit .menu-item-settings{width:402px}.vfb-menu-item-handle{background:#fff;border:1px solid #DFDFDF;border-radius:3px;height:auto;line-height:35px;overflow:hidden;padding:10px 15px;position:relative;text-shadow:0 1px 0 #FFF;width:382px;word-wrap:break-word;cursor:move}.vfb-menu-item-handle:hover{border-color:#999}.admin-color-classic .vfb-menu-item-handle{background:#F5FAFD;box-shadow:0 1px 0 #FFF inset;border-color:#D0DFE9}.rtl .vfb-menu-item-handle{padding-left:0;padding-right:10px}#form-element-fieldset,.vfb-menu-item-type-fieldset,.vfb-menu-item-type-verification{background:#e3e3e3;box-shadow:0 1px 0 #e3e3e3 inset}.admin-color-classic #form-element-fieldset,.admin-color-classic .vfb-menu-item-type-fieldset,.admin-color-classic .vfb-menu-item-type-verification{background:#e2f3ff;box-shadow:0 1px 0 #FFF inset}.vfb-menu-item-handle .item-title{min-height:20px;display:block;font-size:12px;font-weight:700;line-height:20px;margin-right:13em}.rtl .vfb-menu-item-handle .item-title{margin-right:0;margin-left:13em}.vfb-menu-item-active .vfb-menu-item-handle{border-bottom-left-radius:0;border-bottom-right-radius:0}.sender-labels{width:80px}.is-field-required{color:#BC1212}#form-details-nav{padding-top:10px;font-size:1em}#form-details-nav a,.charts-nav a{padding:5px 10px;text-decoration:none;font-weight:700}#form-details-nav a.current,.charts-nav a.current{height:40px;border-color:#dfdfdf;border-radius:5px;background-color:#777;background-image:-ms-linear-gradient(bottom,#6d6d6d,grey);background-image:-moz-linear-gradient(bottom,#6d6d6d,grey);background-image:-o-linear-gradient(bottom,#6d6d6d,grey);background-image:-webkit-gradient(linear,left bottom,left top,from(#6d6d6d),to(grey));background-image:-webkit-linear-gradient(bottom,#6d6d6d,grey);background-image:linear-gradient(bottom,#6d6d6d,grey);color:#fff;text-shadow:0 -1px 0 #333}#form-success-message-page,#form-success-message-redirect,#form-success-message-text,.form-details{display:none}.active,.form-details-current{display:block}#confirmation-message textarea,#notification textarea{width:100%;height:10em;font-family:Consolas,Monaco,monospace}#form-success-message-page,#form-success-message-redirect{margin-top:10px;width:100%}.post-body-plain ol li{list-style:decimal}#vfb-upgrade-column{display:inline;float:left;width:auto}.rtl #vfb-upgrade-column{float:right}ul#promote-vfb{margin-left:20px;list-style:disc}.rtl ul#promote-vfb{margin-left:auto;margin-right:20px}#promote-vfb li{text-align:left}.rtl #promote-vfb li{text-align:right}.menu .ui-nestedSortable-error{background-color:#fbe3e4;border-color:red;color:#8a1f11}ul#vfb-menu-to-edit ul{margin:0 0 0 25px;padding:0;width:98%;list-style-type:none}#vfb-menu-to-edit{margin-top:0;padding:1em 0}#vfb-fieldset-first-warning{display:none}.form-item.ui-state-disabled,.ui-state-disabled,.ui-state-disabled dl,.ui-state-disabled dt{opacity:100;filter:alpha(Opacity=100);background-image:none}.ui-state-disabled .menu-item-handle,.ui-state-disabled .vfb-menu-item-handle{background:#dfdfdf;box-shadow:none;cursor:default}.vfb-details{margin-bottom:10px;padding:0 10px;border:1px solid #ccc;border-radius:3px}.vfb-details.section{width:97.55%;background-color:#efefef}.vfb-details .postbox{min-height:60px}#poststuff .vfb-details h2{margin-top:0}#poststuff h3.section-heading{padding-left:0}#form-items .tabs-panel{overflow:visible;padding:.5em 0 .5em 4px;min-height:325px;height:auto}.rtl #form-items .tabs-panel{padding:.5em 4px .5em 0}ul.vfb-fields-col-1,ul.vfb-fields-col-2{float:left;width:50%;list-style:none}.rtl ul.vfb-fields-col-1,.rtl ul.vfb-fields-col-2{float:right}#vfb-form-builder-frame.columns-1 #vfb-postbox-container-1 #form-items .tabs-panel{height:auto}.vfb-draggable-form-items{position:relative;display:block;margin-right:8px;padding:4px 0 4px 34px;border:1px solid #bbb;border-radius:3px;color:#464646;text-align:left;text-decoration:none;font-size:12px}.rtl .vfb-draggable-form-items{margin-right:0;margin-left:8px;padding:4px 34px 4px 10px}.vfb-draggable-form-items:hover{border-color:#aaa}.vfb-draggable-form-items b{position:absolute;left:8px;display:inline-block;width:16px;height:16px;background-color:transparent;background-image:url(../img/vfb-form-items.png?d=20130712);background-repeat:no-repeat;line-height:16px}.settings-links,.vfb-button{position:relative;text-decoration:none;cursor:pointer}.rtl .vfb-draggable-form-items b{left:auto;right:8px}#form-element-address b{background-position:-128px 0}#form-element-autocomplete b{background-position:-384px 0}#form-element-checkbox b{background-position:-672px 0}#form-element-color b{background-position:0 0}#form-element-currency b{background-position:-64px 0}#form-element-datepicker b{background-position:-224px 0}#form-element-digits b{background-position:-832px 0}#form-element-email b{background-position:-160px 0}#form-element-file b{background-position:-512px 0}#form-element-hidden b{background-position:-544px 0}#form-element-html b{background-position:-800px 0}#form-element-instructions b{background-position:-256px 0}#form-element-ip b{background-position:-448px 0}#form-element-max b{background-position:-576px 0}#form-element-min b{background-position:-608px 0}#form-element-name b{background-position:-320px 0}#form-element-pagebreak b{background-position:-768px 0}#form-element-password b{background-position:-352px 0}#form-element-phone b{background-position:-96px 0}#form-element-radio b{background-position:-704px 0}#form-element-range b{background-position:-640px 0}#form-element-select b{background-position:-416px 0}#form-element-text b{background-position:-736px 0}#form-element-textarea b{background-position:-32px 0}#form-element-time b{background-position:-192px 0}#form-element-username b{background-position:-288px 0}#form-element-url b{background-position:-480px 0}.static-vars-inactive{display:none}.static-vars-active{display:block}.vfb-button{display:inline-block;overflow:visible;margin:0;padding:.5em 2.5em .5em 1em;outline:0;border:1px solid #d4d4d4;border-radius:.2em;background-color:#f5f5f5;color:#333;white-space:nowrap;font:12px/normal sans-serif;zoom:1;-webkit-background-clip:padding;-moz-background-clip:padding;-o-background-clip:padding-box}.vfb-button.current,.vfb-button:active,.vfb-button:hover{border-color:#929292;background-color:#eee;background-image:-webkit-gradient(linear,0 0,0 100%,from(#eee),to(#ccc));background-image:-moz-linear-gradient(#eee,#ccc);background-image:-o-linear-gradient(#eee,#ccc);background-image:linear-gradient(#eee,#ccc);color:#000}.vfb-button.current{font-weight:700}.vfb-button::-moz-focus-inner{padding:0;border:0}.vfb-button.vfb-settings:active,.vfb-button.vfb-settings:focus,.vfb-button.vfb-settings:hover{color:#3072b3}.vfb-button.vfb-delete:active,.vfb-button.vfb-delete:focus,.vfb-button.vfb-delete:hover{color:#900}.vfb-button.vfb-duplicate:active,.vfb-button.vfb-duplicate:focus,.vfb-button.vfb-duplicate:hover{color:#008e0d}.vfb-button-group{display:inline-block;margin:10px 0;list-style:none}.rtl .vfb-button-group{margin-left:-2px}.vfb-button-group .vfb-button{float:left;margin-right:5px}.rtl .vfb-button-group .vfb-button{float:right;margin-right:0;margin-left:5px}.vfb-button-group .button-primary{margin-top:2px}.vfb-item-actions{margin-right:10px;margin-bottom:10px;text-align:center}.rtl .vfb-item-actions{margin-right:0;margin-left:10px}.vfb-item-actions .vfb-delete{float:left}.rtl .vfb-item-actions .vfb-delete,.vfb-item-actions .vfb-conditional-fields{float:right}.rtl .vfb-item-actions .vfb-conditional-fields{float:left}.vfb-item-actions .vfb-conditional-fields,.vfb-item-actions .vfb-delete,.vfb-item-actions .vfb-duplicate{margin-top:10px}#form-settings{display:none;width:100%;max-width:460px;margin-bottom:15px;border-bottom:1px solid #D6D6D6}#form-settings.current,.form-details.on{display:block}.form-details{padding:20px;background:#fff;background:rgba(255,255,255,.5);border-left:1px solid #D6D6D6;border-right:1px solid #D6D6D6}.settings-links{z-index:1;display:block;padding:5px 15px;height:25px;background:#f5f5f5;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;color:#333;text-transform:uppercase;text-shadow:0 1px 0 #FFF;font-weight:400;font-size:15px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:25px}.settings-links .vfb-large-arrow{position:absolute;top:16px;right:25px;width:5px;height:0;z-index:1}.settings-links .vfb-large-arrow:after{content:'';width:0;height:0;border-color:#ccc transparent;border-style:solid;border-width:6px 6px 0;position:absolute;z-index:1}.rtl .settings-links .vfb-large-arrow{right:auto;left:13px}.settings-links.on{border-bottom:1px solid grey}.settings-links.on,.settings-links:hover{background:grey;color:#fff;text-shadow:0 -1px 0 #333}.settings-links:first-child{border-top-left-radius:3px;border-top-right-radius:3px}.vfb-tooltip{position:relative;float:right;margin-right:2px;width:16px;height:16px;cursor:pointer}.rtl .vfb-tooltip{float:left;margin-right:0;margin-left:2px}.vfb-tooltip-popup{position:absolute;top:-40px;z-index:200;display:none;padding:5px 20px;width:250px;border:2px solid #333;border-radius:5px;background:#222;box-shadow:0 0 7px #000;color:#fff;text-indent:0;font-style:normal}.vfb-tooltip .vfb-tooltip-popup h3,.vfb-tooltip-popup h3{margin:5px 0;padding:0 0 6px;border-bottom:1px solid #fff;color:#fff;font-weight:400;font-size:13px;font-family:sans-serif}.vfb-tooltip-popup p{margin-top:1 0;color:#fff;font-size:12px}.vfb-add-options-group{display:inline-block;margin:10px 0;list-style:none;text-align:center;width:95%}.vfb-add-options-group .vfb-interface-plus{top:4px}.vfb-export-label{width:10em;float:left}.rtl .vfb-export-label{float:right}#vfb-export-entries-fields{height:275px;width:300px;overflow:auto;display:block;border:1px solid #e8e8e8;border-radius:3px;margin-left:10em;padding:5px;background:#fff}#vfb-export-select-all,#vfb-export-unselect-all{width:150px;display:inline-block;text-align:left}#vfb-export-unselect-all{text-align:right;margin-left:5px}@media print{body *{float:none}#vfb-poststuff,#wpbody-content,.wrap,html{background:0 0!important;padding:0;margin:0;height:auto}#adminmenuback,#adminmenushadow,#adminmenuwrap,#icon-options-general,#major-publishing-actions,#screen-meta,#screen-meta-links,#wpadminbar,#wpfooter,.clear,.screen-reader-shortcut,.view-entry,.wrap h2{display:none}#wpcontent,body #wpcontent{margin-left:0;width:auto;height:auto}#entry-edit h3 span{font-size:23px;font-weight:400}#vfb-poststuff{page-break-after:auto}#vfb-entries-body-content{width:100%;height:auto;margin:0 0 50px;padding:0}#side-info-column{width:100%;height:auto;float:none}#side-info-column .postbox .inside{margin:0;padding:0}#minor-publishing,#submitdiv,#submitdiv h3,.misc-pub-section{background:0 0!important;border:none;margin:0}#submitdiv h3 span{font-family:sans-serif;font-size:16px}.columns-2 .inner-sidebar #side-sortables,.inner-sidebar #side-sortables{margin:0;padding:0;width:auto}table{page-break-inside:auto}tr textarea{overflow:visible}}@media print,(-o-min-device-pixel-ratio:5/4),(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.vfb-interface-icon{top:5px;background-image:url(../img/vfb-interface-icons-2x.png?d=20130712);background-size:cover}.vfb-draggable-form-items b{background-image:url(../img/vfb-form-items-2x.png?d=20130712);background-size:cover}.vfb-add-options-group .vfb-interface-plus{top:5px}.addEmail,.deleteEmail{top:28px}.item-edit{background-image:url(../img/arrows-2x.png?d=20130611);background-size:15px 123px}.admin-color-classic .item-edit{background-image:url(../img/arrows-vs-2x.png?d=20130611);background-size:15px 123px}.item-edit:hover{background-image:url(../img/arrows-dark-2x.png?d=20130611);background-size:15px 123px}.admin-color-classic .item-edit:hover{background-image:url(../img/arrows-dark-vs-2x.png?d=20130611);background-size:15px 123px}.item-edit.opened{background-image:url(../img/arrows-2x.png?d=20130611);background-size:15px 123px}.admin-color-classic .item-edit.opened{background-image:url(../img/arrows-vs-2x.png?d=20130611);background-size:15px 123px}.item-edit.opened:hover{background-image:url(../img/arrows-dark-2x.png?d=20130611);background-size:15px 123px}.admin-color-classic .item-edit.opened:hover{background-image:url(../img/arrows-dark-vs-2x.png?d=20130611);background-size:15px 123px}.button-icon.vfb-small-arrow{background-image:url(../img/arrows-2x.png?d=20130611);background-size:15px 123px}.admin-color-classic .button-icon.vfb-small-arrow{background-image:url(../img/arrows-vs-2x.png?d=20130611);background-size:15px 123px}.current .button-icon.vfb-small-arrow{background-image:url(../img/arrows-2x.png?d=20130611);background-size:15px 123px}.admin-color-classic .current .button-icon.vfb-small-arrow{background-image:url(../img/arrows-vs.png?d=20130611);background-size:15px 123px}}
{images → admin/assets/img}/arrows-2x.png RENAMED
File without changes
{images → admin/assets/img}/arrows-dark-2x.png RENAMED
File without changes
{images → admin/assets/img}/arrows-dark-vs-2x.png RENAMED
File without changes
{images → admin/assets/img}/arrows-dark-vs.png RENAMED
File without changes
{images → admin/assets/img}/arrows-dark.png RENAMED
File without changes
{images → admin/assets/img}/arrows-vs-2x.png RENAMED
File without changes
{images → admin/assets/img}/arrows-vs.png RENAMED
File without changes
{images → admin/assets/img}/arrows.png RENAMED
File without changes
admin/assets/img/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
{images → admin/assets/img}/vfb-form-items-2x.png RENAMED
File without changes
{images → admin/assets/img}/vfb-form-items.png RENAMED
File without changes
{images → admin/assets/img}/vfb-interface-icons-2x.png RENAMED
File without changes
{images → admin/assets/img}/vfb-interface-icons.png RENAMED
File without changes
admin/assets/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
admin/assets/js/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
{js → admin/assets/js}/jquery.ui.nestedSortable.js RENAMED
File without changes
{js → admin/assets/js}/jquery.ui.nestedSortable.min.js RENAMED
File without changes
{js → admin/assets/js}/jquery.validate.min.js RENAMED
File without changes
{js → admin/assets/js}/vfb-admin.js RENAMED
@@ -1,15 +1,4 @@
1
  jQuery(document).ready(function($) {
2
-
3
- if( window.VfbAdminPages ) {
4
- var obj = VfbAdminPages.vfb_pages;
5
-
6
- // Only add meta box toggles to main form builder
7
- if ( pagenow == obj['vfb'] ) {
8
- $( '.if-js-closed' ).removeClass( 'if-js-closed' ).addClass( 'closed' );
9
- postboxes.add_postbox_toggles( obj['vfb'] );
10
- }
11
- }
12
-
13
  // Initialize our tooltip timeout var
14
  var tooltip_timeout = null;
15
 
@@ -657,4 +646,4 @@ jQuery(document).ready(function($) {
657
 
658
  return count;
659
  }
660
- });
1
  jQuery(document).ready(function($) {
 
 
 
 
 
 
 
 
 
 
 
2
  // Initialize our tooltip timeout var
3
  var tooltip_timeout = null;
4
 
646
 
647
  return count;
648
  }
649
+ });
admin/assets/js/vfb-admin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(e){var t=null;e(document).on("mouseenter mouseleave",".vfb-tooltip",function(i){if("mouseenter"==i.type){t&&(clearTimeout(t),t=null);var o=e(this).attr("title"),n=e(this).attr("rel"),a=e(this).width();e(this).append('<div class="vfb-tooltip-popup"><h3>'+o+"</h3><p>"+n+"</p></div>"),e.data(this,"title",o),this.title="",e(this).find(".vfb-tooltip-popup").css({left:a+22}),t=setTimeout(function(){e(".vfb-tooltip-popup").fadeIn(300)},500)}else this.title=e.data(this,"title"),e(".vfb-tooltip-popup").fadeOut(500),e(this).children().remove()}),e(document).on("click","a.vfb-add-option",function(t){t.preventDefault();var i=e(this).parent().siblings(".vfb-cloned-options").children(),o=i.length,n=o+1,a=i[o-1],s=e(a).attr("id"),r=e(a).children("label").attr("for").replace(new RegExp(/(\d+)$/g),""),l=s.replace(new RegExp(/(\d+)$/g),""),f=e("#"+s).clone().attr("id",l+n);f.children("label").attr("for",r+n),f.find('input[type="text"]').attr("id",r+n),f.find('input[type="radio"]').attr("value",n),e("#"+l+o).after(f)}),e(document).on("click","a.deleteOption",function(t){t.preventDefault(),e(this).parent().parent().find(".clonedOption").length-1==0?alert("You must have at least one option."):e(this).closest("div").remove()}),e(".vfb-cloned-options").sortable({items:"div.option"}),e(document).on("click","a.addEmail",function(t){t.preventDefault();var i=e(this).closest("#email-details").find(".clonedOption").length,o=i+1,n=e(this).closest("div").attr("id"),a=e(this).closest("div").find("label").attr("for").replace(new RegExp(/(\d+)$/g),""),s=n.replace(new RegExp(/(\d+)$/g),""),r=e("#"+n).clone().attr("id",s+o);r.find("label").attr("for",a+o),r.find("input").attr("id",a+o),e("#"+s+i).after(r)}),e(document).on("click","a.deleteEmail",function(t){t.preventDefault(),e(this).closest("#email-details").find(".clonedOption").length-1==0?alert("You must have at least one option."):e(this).closest("div").remove()}),e('.option input[type="radio"]').mousedown(function(){e(this).attr("previousValue",e(this).prop("checked"))}).click(function(){"true"==e(this).attr("previousValue")&&e(this).prop("checked",!1)}),e(".menu-delete").click(function(){var t=e(this).hasClass("entry-delete")?"entry":"form";return!!confirm("You are about to permanently delete this "+t+" and all of its data.\n'Cancel' to stop, 'OK' to delete.")}),e(document).on("click","a.item-edit",function(t){t.preventDefault(),e(t.target).closest("li").children(".menu-item-settings").slideToggle("fast"),e(this).toggleClass("opened");var i=e(t.target).closest("dl");i.hasClass("vfb-menu-item-inactive")?i.removeClass("vfb-menu-item-inactive").addClass("vfb-menu-item-active"):i.removeClass("vfb-menu-item-active").addClass("vfb-menu-item-inactive")}),e("#vfb-menu-to-edit").nestedSortable({listType:"ul",maxLevels:3,handle:".vfb-menu-item-handle",placeholder:"vfb-sortable-placeholder",forcePlaceholderSize:!0,forceHelperSize:!0,tolerance:"pointer",toleranceElement:"> dl",items:"li:not(.ui-state-disabled)",create:function(t,i){e(this).css("min-height",e(this).height())},start:function(e,t){t.placeholder.height(t.item.height())},stop:function(t,i){var o=e("#vfb-menu-to-edit .item-type:first").text();opts={url:ajaxurl,type:"POST",async:!0,cache:!1,data:{action:"visual_form_builder_sort_field",order:e(this).nestedSortable("toArray")},success:function(t){e("#loading-animation").hide(),"FIELDSET"!==o?e("#vfb-fieldset-first-warning").show():e("#vfb-fieldset-first-warning").hide()}},e.ajax(opts)}}),e("#form-items .vfb-draggable-form-items").click(function(t){t.preventDefault(),e(this).data("submit_value",e(this).text())}),e("#form-items .vfb-draggable-form-items").click(function(t){t.preventDefault();var i=e(this).closest("form").serializeArray(),o=e(this).data("submit_value"),n=e("#vfb-menu-to-edit li.ui-state-disabled:first").attr("id").match(new RegExp(/(\d+)$/g))[0];e("img.waiting").show(),e.post(ajaxurl,{action:"visual_form_builder_create_field",data:i,field_type:o,previous:n,page:pagenow,nonce:e("#_wpnonce").val()}).done(function(t){e("img.waiting").hide(),e(t).hide().insertBefore("#vfb-menu-to-edit li.ui-state-disabled:first").fadeIn()})}),e(document).on("click","a.item-delete",function(t){t.preventDefault();var i=childs=new Array,o=0,n=e(this).attr("href").split("&");if(!confirm("You are about to permanently delete this field.\n'Cancel' to stop, 'OK' to delete."))return!1;for(var a=0;a<n.length;a++){var s=n[a].indexOf("="),r=n[a].substring(0,s),l=n[a].substring(s+1);i[r]=l}var f=e(this).closest(".form-item").find("ul").children(),c=f.parent().html();f.each(function(t){childs[t]=e(this).attr("id").match(new RegExp(/(\d+)$/g))[0]});var d=e(this).closest("li.form-item").parents("li.form-item");d.length&&(o=d.attr("id").match(new RegExp(/(\d+)$/g))[0]),e.post(ajaxurl,{action:"visual_form_builder_delete_field",form:i.form,field:i.field,child_ids:childs,parent_id:o,page:pagenow,nonce:i._wpnonce}).done(function(t){e("#form_item_"+i.field).addClass("deleting").animate({opacity:0,height:0},350,function(){e(this).before(c).remove()})})}),e("#form-settings-button").click(function(t){t.preventDefault(),e(this).toggleClass("current"),e("#form-settings").slideToggle("fast");var i=e('input[name="form_id"]').val(),o=e(this).hasClass("current")?"opened":"closed";e.post(ajaxurl,{action:"visual_form_builder_form_settings",form:i,status:o,page:pagenow}).done(function(t){"closed"==o&&(e(".settings-links").removeClass("on"),e(".settings-links:first").addClass("on"),e(".form-details").slideUp("normal"),e(".form-details:first").show("normal"))})}),e(".settings-links").click(function(t){t.preventDefault(),e(".settings-links").removeClass("on"),e(".form-details").slideUp("fast"),1==e(this).next("div").is(":hidden")&&(e(this).addClass("on"),e(this).next().slideDown("normal"));var i=e('input[name="form_id"]').val(),o=this.hash.replace(/#/g,"");e.post(ajaxurl,{action:"visual_form_builder_form_settings",form:i,accordion:o,page:pagenow})});var i=!1;if(e("#vfb-form-builder-management input, #vfb-form-builder-management select, #vfb-form-builder-management textarea").change(function(){i=!0}),window.onbeforeunload=function(){if(i)return"The changes you made will be lost if you navigate away from this page."},e(document).on("submit","#visual-form-builder-update",function(){window.onbeforeunload=null}),e(".columns-2 #side-sortables").length>0){var o=e("#vfb_form_items_meta_box"),n=o.width(),a=o.offset(),s=o.nextAll(),r=!1;e(window).on("scroll",function(){e(window).scrollTop()>a.top?(o.stop().css({top:55,position:"fixed","z-index":"1",width:n}),s.is(":visible")&&(r=!0,s.stop().css({opacity:.1}))):(o.stop().css({top:0,position:"relative"}),r&&s.stop().css({opacity:1}))})}var l=e(".form-success-type:checked").val();e("#form-success-message-"+l).show(),e(".form-success-type").change(function(){switch(e(this).val()){case"text":e("#form-success-message-text").show(),e("#form-success-message-page, #form-success-message-redirect").hide();break;case"page":e("#form-success-message-page").show(),e("#form-success-message-text, #form-success-message-redirect").hide();break;case"redirect":e("#form-success-message-redirect").show(),e("#form-success-message-text, #form-success-message-page").hide()}}),e(".vfb-field-types").click(function(t){t.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 i=this.hash;e(i).removeClass("tabs-panel-inactive").addClass("tabs-panel-active")}),e("#visual-form-builder-update").validate({rules:{"form_email_to[]":{email:!0},form_email_from:{email:!0},form_success_message_redirect:{url:!0},form_notification_email_name:{required:function(t){return e("#form-notification-setting").is(":checked")}},form_notification_email_from:{required:function(t){return e("#form-notification-setting").is(":checked")},email:!0},form_notification_email:{required:function(t){return e("#form-notification-setting").is(":checked")}}},errorPlacement:function(e,t){e.insertAfter(t.parent())}}),e("#visual-form-builder-new-form").validate(),e("#form_email_from_name_override").change(function(){""==e("#form_email_from_name_override").val()?e("#form-email-sender-name").prop("readonly",!1):e("#form-email-sender-name").prop("readonly","readonly")}),e("#form_email_from_override").change(function(){""==e("#form_email_from_override").val()?e("#form-email-sender").prop("readonly",!1):e("#form-email-sender").prop("readonly","readonly")}),e("#notification-email").toggle(e("#form-notification-setting").prop("checked")),e("#form-notification-setting").change(function(){e(this).is(":checked")?(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").prop("disabled",!1)):(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").prop("disabled","disabled"))}),e("#vfb-export-select-all").click(function(t){t.preventDefault(),e('#vfb-export-entries-fields input[type="checkbox"]').prop("checked",!0)}),e("#vfb-export-unselect-all").click(function(t){t.preventDefault(),e('#vfb-export-entries-fields input[type="checkbox"]').prop("checked",!1)}),e("#vfb-export-entries-forms").change(function(){var t,i,o=e(this).val(),n=(t=o,i="",e.ajax(ajaxurl,{async:!1,data:{action:"visual_form_builder_export_entries_count",id:t,page:pagenow}}).done(function(t){if(t>1e3){e("#vfb-export-entries-rows").empty();for(var o=Math.ceil(parseInt(t)/1e3),n=1;n<=o;n++)e("#vfb-export-entries-rows").append(e("<option></option>").attr("value",n).text(n));e("#vfb-export-entries-pages").show()}else e("#vfb-export-entries-pages").hide();i=t}).fail(function(e){}),i);e("#vfb-export-entries-fields").html("Loading..."),e.get(ajaxurl,{action:"visual_form_builder_export_load_options",id:o,count:n,page:pagenow}).done(function(t){e("#vfb-export-entries-fields").html(t)}).fail(function(t){e("#vfb-export-entries-fields").html("Error loading entry fields.")})}),e("#vfb-export-entries-rows").change(function(){var t=e("#vfb-export-entries-forms").val(),i=e(this).val();e("#vfb-export-entries-fields").html("Loading..."),e.get(ajaxurl,{action:"visual_form_builder_export_load_options",id:t,offset:i,page:pagenow}).done(function(t){e("#vfb-export-entries-fields").html(t)}).fail(function(t){e("#vfb-export-entries-fields").html("Error loading entry fields.")})})});
{js → admin/assets/js}/vfb-validation.js RENAMED
File without changes
{js → admin/assets/js}/vfb-validation.min.js RENAMED
File without changes
admin/class-admin-menu.php ADDED
@@ -0,0 +1,390 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Add all admin menus
4
+ *
5
+ * Defines and adds all admin menus
6
+ *
7
+ */
8
+ class Visual_Form_Builder_Admin_Menu {
9
+
10
+ /**
11
+ * Initial setup
12
+ *
13
+ * @access public
14
+ * @return void
15
+ */
16
+ public function __construct() {
17
+ // Add main menu
18
+ add_action( 'admin_menu', array( $this, 'add_menu' ) );
19
+ }
20
+
21
+ /**
22
+ * Adds the main menu
23
+ *
24
+ * @since 3.0
25
+ * @access public
26
+ * @return void
27
+ */
28
+ public function add_menu() {
29
+ global $pagenow, $typenow;
30
+
31
+ $page = add_menu_page(
32
+ 'Visual Form Builder',
33
+ __( 'Visual Form Builder', 'visual-form-builder' ),
34
+ 'manage_options',
35
+ 'visual-form-builder',
36
+ array( $this, 'admin' ),
37
+ 'dashicons-feedback'
38
+ );
39
+
40
+ $all_forms = add_submenu_page(
41
+ 'visual-form-builder',
42
+ __( 'Visual Form Builder', 'visual-form-builder' ),
43
+ __( 'All Forms', 'visual-form-builder' ),
44
+ 'manage_options',
45
+ 'visual-form-builder',
46
+ array( $this, 'admin' )
47
+ );
48
+
49
+ $add_new = add_submenu_page(
50
+ 'visual-form-builder',
51
+ __( 'Add New', 'visual-form-builder' ),
52
+ __( 'Add New', 'visual-form-builder' ),
53
+ 'manage_options',
54
+ 'vfb-add-new',
55
+ array( $this, 'add_new_form' )
56
+ );
57
+
58
+ $entries = add_submenu_page(
59
+ 'visual-form-builder',
60
+ __( 'Entries', 'visual-form-builder' ),
61
+ __( 'Entries', 'visual-form-builder' ),
62
+ 'manage_options',
63
+ 'vfb-entries',
64
+ array( $this, 'entries' )
65
+ );
66
+
67
+ $export = add_submenu_page(
68
+ 'visual-form-builder',
69
+ __( 'Export', 'visual-form-builder' ),
70
+ __( 'Export', 'visual-form-builder' ),
71
+ 'manage_options',
72
+ 'vfb-export',
73
+ array( $this, 'export' )
74
+ );
75
+
76
+ $settings = add_submenu_page(
77
+ 'visual-form-builder',
78
+ __( 'Settings', 'visual-form-builder' ),
79
+ __( 'Settings', 'visual-form-builder' ),
80
+ 'manage_options',
81
+ 'vfb-settings',
82
+ array( $this, 'settings' )
83
+ );
84
+
85
+ $scripts = new Visual_Form_Builder_Admin_Scripts_Loader();
86
+ add_action( 'load-' . $page, array( $scripts, 'add_css' ) );
87
+ add_action( 'load-' . $page, array( $scripts, 'add_js' ) );
88
+
89
+ add_action( 'load-' . $add_new, array( $scripts, 'add_css' ) );
90
+ add_action( 'load-' . $add_new, array( $scripts, 'add_js' ) );
91
+
92
+ add_action( 'load-' . $entries, array( $scripts, 'add_css' ) );
93
+ add_action( 'load-' . $entries, array( $scripts, 'add_js' ) );
94
+
95
+ add_action( 'load-' . $settings, array( $scripts, 'add_css' ) );
96
+ add_action( 'load-' . $settings, array( $scripts, 'add_js' ) );
97
+
98
+ add_action( 'load-' . $export, array( $scripts, 'add_css' ) );
99
+ add_action( 'load-' . $export, array( $scripts, 'add_js' ) );
100
+
101
+ // Enable Screen Options tabs here (saving is hooked in main plugin instance() )
102
+ $screen_options = new Visual_Form_Builder_Admin_Screen_Options();
103
+ add_action( 'load-' . $page, array( $screen_options, 'add_option' ) );
104
+ add_action( 'load-' . $entries, array( $screen_options, 'add_option_entries' ) );
105
+
106
+ // Add Meta Boxes
107
+ $meta_boxes = new Visual_Form_Builder_Meta_Boxes();
108
+ add_action( 'load-' . $page, array( $meta_boxes, 'add_meta_boxes' ) );
109
+
110
+ // Add Help dropdown
111
+ add_action( 'load-' . $page, array( $this, 'help' ) );
112
+ }
113
+
114
+ /**
115
+ * Load either the All Forms list or Edit Form view
116
+ *
117
+ * @since 3.0
118
+ * @access public
119
+ * @return void
120
+ */
121
+ public function admin() {
122
+ if ( isset( $_GET['form'] ) && 'edit' == $_GET['action'] )
123
+ $this->edit_form();
124
+ else
125
+ $this->forms_list();
126
+ }
127
+
128
+ /**
129
+ * View for All Forms list
130
+ *
131
+ * @since 3.0
132
+ * @access public
133
+ * @return void
134
+ */
135
+ public function forms_list() {
136
+ $forms = new Visual_Form_Builder_Forms_List();
137
+ ?>
138
+ <div class="wrap">
139
+ <h1>
140
+ <?php
141
+ _e( 'Visual Form Builder', 'visual-form-builder' );
142
+
143
+ // Add New link
144
+ echo sprintf(
145
+ ' <a href="%1$s" class="page-title-action">%2$s</a>',
146
+ esc_url( admin_url( 'admin.php?page=vfb-add-new' ) ),
147
+ esc_html( __( 'Add New', 'visual-form-builder' ) )
148
+ );
149
+
150
+ // If searched, output the query
151
+ if ( isset( $_POST['s'] ) && !empty( $_POST['s'] ) )
152
+ echo '<span class="subtitle">' . sprintf( __( 'Search results for "%s"' , 'visual-form-builder'), esc_html( $_POST['s'] ) );
153
+
154
+ $form_nav_selected_id = isset( $_GET['form'] ) ? $_GET['form'] : '0';
155
+ ?>
156
+ </h1>
157
+
158
+ <div id="vfb-form-list">
159
+ <div id="vfb-sidebar">
160
+ <div id="vfb-upgrade-column">
161
+ <div class="vfb-pro-upgrade">
162
+ <h2><a href="http://vfbpro.com">VFB Pro</a></h2>
163
+ <p class="vfb-pro-call-to-action">
164
+ <a class="vfb-btn vfb-btn-inverse" href="http://vfbpro.com/pages/pricing" target="_blank"><?php _e( 'View Pricing' , 'visual-form-builder'); ?></a>
165
+ <a class="vfb-btn vfb-btn-primary" href="http://vfbpro.com/pages/pricing" target="_blank"><?php _e( 'Buy Now' , 'visual-form-builder'); ?></a>
166
+ </p>
167
+ <p class="vfb-pro-call-to-action">
168
+ <a class="button" href="http://demo.vfbpro.com" target="_blank"><?php _e( 'Try the Free Live Demo &rarr;' , 'visual-form-builder'); ?></a>
169
+ </p>
170
+ <h3><?php _e( 'New Features' , 'visual-form-builder'); ?></h3>
171
+ <ul>
172
+ <li><a href="http://vfbpro.com/collections/add-ons"><?php _e( 'Now with Add-Ons' , 'visual-form-builder'); ?></a></li>
173
+ <li><?php _e( 'Akismet Support' , 'visual-form-builder'); ?></li>
174
+ <li><?php _e( 'reCAPTCHA v2' , 'visual-form-builder'); ?></li>
175
+ <li><?php _e( 'Conditional Logic' , 'visual-form-builder'); ?></li>
176
+ <li><?php _e( '15 new Form Fields' , 'visual-form-builder'); ?></li>
177
+ <li><?php _e( 'Complete Entries Management' , 'visual-form-builder'); ?></li>
178
+ <li><?php _e( 'Import/Export' , 'visual-form-builder'); ?></li>
179
+ <li><?php _e( 'Quality HTML Email Template' , 'visual-form-builder'); ?></li>
180
+ <li><?php _e( 'Plain Text Email Option' , 'visual-form-builder'); ?></li>
181
+ <li><?php _e( 'Email Designer' , 'visual-form-builder'); ?></li>
182
+ <li><?php _e( 'Data &amp; Form Migration' , 'visual-form-builder'); ?></li>
183
+ <li><?php _e( 'Scheduling' , 'visual-form-builder'); ?></li>
184
+ <li><?php _e( 'Limit Form Entries' , 'visual-form-builder'); ?></li>
185
+ <li><?php _e( 'Form Paging' , 'visual-form-builder'); ?></li>
186
+ <li><?php _e( 'Custom Capabilities' , 'visual-form-builder'); ?></li>
187
+ <li><?php _e( 'Automatic Updates' , 'visual-form-builder'); ?></li>
188
+ </ul>
189
+
190
+ <p><a href="http://vfbpro.com/pages/features"><?php _e( 'View all features' , 'visual-form-builder'); ?></a></p>
191
+ </div> <!-- .vfb-pro-upgrade -->
192
+
193
+ <h3><?php _e( 'Promote Visual Form Builder' , 'visual-form-builder'); ?></h3>
194
+ <ul id="promote-vfb">
195
+ <li id="twitter"><?php _e( 'Follow VFB Pro on Twitter' , 'visual-form-builder'); ?>: <a href="http://twitter.com/#!/vfbpro">@vfbpro</a></li>
196
+ <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>
197
+ <li id="paypal">
198
+ <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>
199
+ </li>
200
+ </ul>
201
+ </div> <!-- #vfb-upgrade-column -->
202
+ </div> <!-- #vfb-sidebar -->
203
+ <div id="vfb-main" class="vfb-order-type-list">
204
+ <form id="forms-filter" method="post" action="">
205
+ <?php
206
+ $forms->views();
207
+ $forms->prepare_items();
208
+
209
+ $forms->search_box( 'search', 'search_id' );
210
+ $forms->display();
211
+ ?>
212
+ </form>
213
+ </div> <!-- #vfb-main -->
214
+ </div> <!-- #vfb-form-list -->
215
+ </div> <!-- .wrap -->
216
+ <?php
217
+ }
218
+
219
+ /**
220
+ * Display the Add New form
221
+ *
222
+ * Uses the Visual_Form_Builder_Forms_New class
223
+ *
224
+ * @since 3.0
225
+ * @access public
226
+ * @return void
227
+ */
228
+ public function add_new_form() {
229
+ $add_new = new Visual_Form_Builder_Forms_New();
230
+ $add_new->display();
231
+ }
232
+
233
+ /**
234
+ * View for Edit Form
235
+ *
236
+ * @since 3.0
237
+ * @access public
238
+ * @return void
239
+ */
240
+ public function edit_form() {
241
+ $edit = new Visual_Form_Builder_Forms_Edit();
242
+ $edit->display();
243
+ }
244
+
245
+ /**
246
+ * View for Entries
247
+ * @return [type] [description]
248
+ */
249
+ public function entries() {
250
+ $entries_list = new Visual_Form_Builder_Entries_List();
251
+ $entries_detail = new Visual_Form_Builder_Entries_Detail();
252
+ ?>
253
+ <div class="wrap">
254
+ <h1>
255
+ <?php
256
+ _e( 'Entries', 'visual-form-builder' );
257
+
258
+ // If searched, output the query
259
+ if ( isset( $_POST['s'] ) && !empty( $_POST['s'] ) )
260
+ echo '<span class="subtitle">' . sprintf( __( 'Search results for "%s"' , 'visual-form-builder' ), esc_html( $_POST['s'] ) );
261
+ ?>
262
+ </h1>
263
+ <?php
264
+ if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'view', 'edit', 'update_entry' ) ) ) :
265
+ $entries_detail->entries_detail();
266
+ else :
267
+ $entries_list->views();
268
+ $entries_list->prepare_items();
269
+ ?>
270
+ <form id="entries-filter" method="post" action="">
271
+ <?php
272
+ $entries_list->search_box( 'search', 'search_id' );
273
+ $entries_list->display();
274
+ ?>
275
+ </form>
276
+ <?php endif; ?>
277
+ </div>
278
+ <?php
279
+ }
280
+
281
+ /**
282
+ * View for the Export page
283
+ *
284
+ * @since 3.0
285
+ * @access public
286
+ * @return void
287
+ */
288
+ public function export() {
289
+ $export = new Visual_Form_Builder_Export();
290
+ $export->display();
291
+ }
292
+
293
+ /**
294
+ * View for the Settings page
295
+ *
296
+ * @since 3.0
297
+ * @access public
298
+ * @return void
299
+ */
300
+ public function settings() {
301
+ $settings = new Visual_Form_Builder_Page_Settings();
302
+ $settings->display();
303
+ }
304
+
305
+ /**
306
+ * Add Help dropdown
307
+ * @return [type] [description]
308
+ */
309
+ public function help() {
310
+ $screen = get_current_screen();
311
+
312
+ $screen->add_help_tab( array(
313
+ 'id' => 'vfb-help-tab-getting-started',
314
+ 'title' => 'Getting Started',
315
+ 'content' => '<ul>
316
+ <li>Click on the + tab, give your form a name and click Create Form.</li>
317
+ <li>Select form fields from the box on the left and click a field to add it to your form.</li>
318
+ <li>Edit the information for each form field by clicking on the down arrow.</li>
319
+ <li>Drag and drop the elements to put them in order.</li>
320
+ <li>Click Save Form to save your changes.</li>
321
+ </ul>'
322
+ ) );
323
+
324
+ $screen->add_help_tab( array(
325
+ 'id' => 'vfb-help-tab-item-config',
326
+ 'title' => 'Form Item Configuration',
327
+ 'content' => "<ul>
328
+ <li><em>Name</em> will change the display name of your form input.</li>
329
+ <li><em>Description</em> will be displayed below the associated input.</li>
330
+ <li><em>Validation</em> allows you to select from several of jQuery's Form Validation methods for text inputs. For more about the types of validation, read the <em>Validation</em> section below.</li>
331
+ <li><em>Required</em> is either Yes or No. Selecting 'Yes' will make the associated input a required field and the form will not submit until the user fills this field out correctly.</li>
332
+ <li><em>Options</em> will only be active for Radio and Checkboxes. This field contols how many options are available for the associated input.</li>
333
+ <li><em>Size</em> controls the width of Text, Textarea, Select, and Date Picker input fields. The default is set to Medium but if you need a longer text input, select Large.</li>
334
+ <li><em>CSS Classes</em> allow you to add custom CSS to a field. This option allows you to fine tune the look of the form.</li>
335
+ </ul>"
336
+ ) );
337
+
338
+ $screen->add_help_tab( array(
339
+ 'id' => 'vfb-help-tab-validation',
340
+ 'title' => 'Validation',
341
+ 'content' => "<p>Visual Form Builder uses the <a href='http://docs.jquery.com/Plugins/Validation/Validator'>jQuery Form Validation plugin</a> to perform clientside form validation.</p>
342
+ <ul>
343
+
344
+ <li><em>Email</em>: makes the element require a valid email.</li>
345
+ <li><em>URL</em>: makes the element require a valid url.</li>
346
+ <li><em>Date</em>: makes the element require a date. <a href='http://docs.jquery.com/Plugins/Validation/Methods/date'>Refer to documentation for various accepted formats</a>.
347
+ <li><em>Number</em>: makes the element require a decimal number.</li>
348
+ <li><em>Digits</em>: makes the element require digits only.</li>
349
+ <li><em>Phone</em>: makes the element require a US or International phone number. Most formats are accepted.</li>
350
+ <li><em>Time</em>: choose either 12- or 24-hour time format (NOTE: only available with the Time field).</li>
351
+ </ul>"
352
+ ) );
353
+
354
+ $screen->add_help_tab( array(
355
+ 'id' => 'vfb-help-tab-confirmation',
356
+ 'title' => 'Confirmation',
357
+ 'content' => "<p>Each form allows you to customize the confirmation by selecing either a Text Message, a WordPress Page, or to Redirect to a URL.</p>
358
+ <ul>
359
+ <li><em>Text</em> allows you to enter a custom formatted message that will be displayed on the page after your form is submitted. HTML is allowed here.</li>
360
+ <li><em>Page</em> displays a dropdown of all WordPress Pages you have created. Select one to redirect the user to that page after your form is submitted.</li>
361
+ <li><em>Redirect</em> will only accept URLs and can be used to send the user to a different site completely, if you choose.</li>
362
+ </ul>"
363
+ ) );
364
+
365
+ $screen->add_help_tab( array(
366
+ 'id' => 'vfb-help-tab-notification',
367
+ 'title' => 'Notification',
368
+ 'content' => "<p>Send a customized notification email to the user when the form has been successfully submitted.</p>
369
+ <ul>
370
+ <li><em>Sender Name</em>: the name that will be displayed on the email.</li>
371
+ <li><em>Sender Email</em>: the email that will be used as the Reply To email.</li>
372
+ <li><em>Send To</em>: the email where the notification will be sent. This must be a required text field with email validation.</li>
373
+ <li><em>Subject</em>: the subject of the email.</li>
374
+ <li><em>Message</em>: additional text that can be displayed in the body of the email. HTML tags are allowed.</li>
375
+ <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>
376
+ </ul>"
377
+ ) );
378
+
379
+ $screen->add_help_tab( array(
380
+ 'id' => 'vfb-help-tab-tips',
381
+ 'title' => 'Tips',
382
+ 'content' => "<ul>
383
+ <li>Fieldsets, a way to group form fields, are an essential piece of this plugin's HTML. As such, at least one fieldset is required and must be first in the order. Subsequent fieldsets may be placed wherever you would like to start your next grouping of fields.</li>
384
+ <li>Security verification is automatically included on very form. It's a simple logic question and should keep out most, if not all, spam bots.</li>
385
+ <li>There is a hidden spam field, known as a honey pot, that should also help deter potential abusers of your form.</li>
386
+ <li>Nesting is allowed underneath fieldsets and sections. Sections can be nested underneath fieldsets. Nesting is not required, however, it does make reorganizing easier.</li>
387
+ </ul>"
388
+ ) );
389
+ }
390
+ }
admin/class-admin-notices.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class that displays all Admin Notices after saving
4
+ *
5
+ */
6
+ class Visual_Form_Builder_Admin_Notices {
7
+ /**
8
+ * __construct function.
9
+ *
10
+ * @access public
11
+ * @return void
12
+ */
13
+ public function __construct() {
14
+ add_action( 'admin_notices', array( $this, 'create_form' ) );
15
+ add_action( 'admin_notices', array( $this, 'save_form' ) );
16
+ add_action( 'admin_notices', array( $this, 'delete_form' ) );
17
+ add_action( 'admin_notices', array( $this, 'copy_form' ) );
18
+ add_action( 'admin_notices', array( $this, 'settings' ) );
19
+ }
20
+
21
+ /**
22
+ * Create Form
23
+ *
24
+ * @access public
25
+ * @return void
26
+ */
27
+ public function create_form() {
28
+ if ( !$this->submit_check() )
29
+ return;
30
+
31
+ if ( 'create_form' !== $_POST['action'] )
32
+ return;
33
+
34
+ echo sprintf( '<div id="message" class="updated"><p>%s</p></div>', __( 'Form created.' , 'visual-form-builder' ) );
35
+ }
36
+
37
+ /**
38
+ * Save Form
39
+ *
40
+ * @access public
41
+ * @return void
42
+ */
43
+ public function save_form() {
44
+ if ( !$this->submit_check() )
45
+ return;
46
+
47
+ if ( 'update_form' !== $_POST['action'] )
48
+ return;
49
+
50
+ echo sprintf( '<div id="message" class="updated"><p>%s</p></div>', __( 'Form updated.' , 'visual-form-builder' ) );
51
+ }
52
+
53
+ /**
54
+ * Delete Form
55
+ *
56
+ * @access public
57
+ * @return void
58
+ */
59
+ public function delete_form() {
60
+ if ( !$this->submit_check() )
61
+ return;
62
+
63
+ if ( 'deleted' !== $_POST['action'] )
64
+ return;
65
+
66
+ echo sprintf( '<div id="message" class="updated"><p>%s</p></div>', __( 'Item permanently deleted.' , 'visual-form-builder' ) );
67
+ }
68
+
69
+ /**
70
+ * Copy Form
71
+ *
72
+ * @access public
73
+ * @return void
74
+ */
75
+ public function copy_form() {
76
+ if ( !$this->submit_check() )
77
+ return;
78
+
79
+ if ( 'copy_form' !== $_POST['action'] )
80
+ return;
81
+
82
+ echo sprintf( '<div id="message" class="updated"><p>%s</p></div>', __( 'Item successfully duplicated.' , 'visual-form-builder' ) );
83
+ }
84
+
85
+ /**
86
+ * Settings page
87
+ *
88
+ * @access public
89
+ * @return void
90
+ */
91
+ public function settings() {
92
+ if ( !$this->submit_check() )
93
+ return;
94
+
95
+ if ( 'vfb_settings' !== $_POST['action'] )
96
+ return;
97
+
98
+ echo sprintf( '<div id="message" class="updated"><p>%s</p></div>', __( 'Settings saved.' , 'visual-form-builder' ) );
99
+ }
100
+
101
+ /**
102
+ * Basic check to exit if the form hasn't been submitted
103
+ *
104
+ * @access public
105
+ * @return void
106
+ */
107
+ public function submit_check() {
108
+ if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
109
+ return;
110
+
111
+ $pages = array(
112
+ 'visual-form-builder',
113
+ 'vfb-add-new',
114
+ 'vfb-entries',
115
+ 'vfb-export',
116
+ 'vfb-settings',
117
+ );
118
+
119
+ if ( !in_array( $_GET['page'], $pages ) )
120
+ return;
121
+
122
+ return true;
123
+ }
124
+ }
admin/class-ajax.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class that handles all AJAX calls
4
+ *
5
+ * @since 3.0
6
+ */
7
+ class Visual_Form_Builder_Admin_AJAX {
8
+ /**
9
+ * [__construct description]
10
+ */
11
+ public function __construct() {
12
+ add_action( 'wp_ajax_visual_form_builder_sort_field', array( $this, 'sort_field' ) );
13
+ add_action( 'wp_ajax_visual_form_builder_create_field', array( $this, 'create_field' ) );
14
+ add_action( 'wp_ajax_visual_form_builder_delete_field', array( $this, 'delete_field' ) );
15
+ add_action( 'wp_ajax_visual_form_builder_form_settings', array( $this, 'form_settings' ) );
16
+ }
17
+
18
+ /**
19
+ * Sort fields
20
+ * @return [type] [description]
21
+ */
22
+ public function sort_field() {
23
+ global $wpdb;
24
+
25
+ $data = array();
26
+
27
+ foreach ( $_POST['order'] as $k ) {
28
+ if ( 'root' !== $k['item_id'] && !empty( $k['item_id'] ) ) {
29
+ $data[] = array(
30
+ 'field_id' => $k['item_id'],
31
+ 'parent' => $k['parent_id']
32
+ );
33
+ }
34
+ }
35
+
36
+ foreach ( $data as $k => $v ) {
37
+ // Update each field with it's new sequence and parent ID
38
+ $wpdb->update( VFB_WP_FIELDS_TABLE_NAME, array(
39
+ 'field_sequence' => $k,
40
+ 'field_parent' => $v['parent'] ),
41
+ array(
42
+ 'field_id' => $v['field_id']
43
+ ),
44
+ '%d'
45
+ );
46
+ }
47
+
48
+ die(1);
49
+ }
50
+
51
+ /**
52
+ * Create field by click
53
+ * @return [type] [description]
54
+ */
55
+ public function create_field() {
56
+ global $wpdb;
57
+
58
+ $data = array();
59
+ $field_options = $field_validation = '';
60
+
61
+ foreach ( $_POST['data'] as $k ) {
62
+ $data[ $k['name'] ] = $k['value'];
63
+ }
64
+
65
+ check_ajax_referer( 'create-field-' . $data['form_id'], 'nonce' );
66
+
67
+ $form_id = absint( $data['form_id'] );
68
+ $field_key = sanitize_title( $_POST['field_type'] );
69
+ $field_name = esc_html( $_POST['field_type'] );
70
+ $field_type = strtolower( sanitize_title( $_POST['field_type'] ) );
71
+
72
+ // Set defaults for validation
73
+ switch ( $field_type ) {
74
+ case 'select' :
75
+ case 'radio' :
76
+ case 'checkbox' :
77
+ $field_options = serialize( array( 'Option 1', 'Option 2', 'Option 3' ) );
78
+ break;
79
+
80
+ case 'email' :
81
+ case 'url' :
82
+ case 'phone' :
83
+ $field_validation = $field_type;
84
+ break;
85
+
86
+ case 'currency' :
87
+ $field_validation = 'number';
88
+ break;
89
+
90
+ case 'number' :
91
+ $field_validation = 'digits';
92
+ break;
93
+
94
+ case 'time' :
95
+ $field_validation = 'time-12';
96
+ break;
97
+
98
+ case 'file-upload' :
99
+ $field_options = serialize( array( 'png|jpe?g|gif' ) );
100
+ break;
101
+ }
102
+
103
+
104
+ // Get the last row's sequence that isn't a Verification
105
+ $sequence_last_row = $wpdb->get_var( $wpdb->prepare( "SELECT field_sequence FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE form_id = %d AND field_type = 'verification' ORDER BY field_sequence DESC LIMIT 1", $form_id ) );
106
+
107
+ // If it's not the first for this form, add 1
108
+ $field_sequence = ( !empty( $sequence_last_row ) ) ? $sequence_last_row : 0;
109
+
110
+ $newdata = array(
111
+ 'form_id' => $form_id,
112
+ 'field_key' => $field_key,
113
+ 'field_name' => $field_name,
114
+ 'field_type' => $field_type,
115
+ 'field_options' => $field_options,
116
+ 'field_sequence' => $field_sequence,
117
+ 'field_validation' => $field_validation
118
+ );
119
+
120
+ // Create the field
121
+ $wpdb->insert( VFB_WP_FIELDS_TABLE_NAME, $newdata );
122
+ $insert_id = $wpdb->insert_id;
123
+
124
+ // VIP fields
125
+ $vip_fields = array( 'verification', 'secret', 'submit' );
126
+
127
+ // Move the VIPs
128
+ foreach ( $vip_fields as $update ) {
129
+ $field_sequence++;
130
+ $where = array(
131
+ 'form_id' => absint( $data['form_id'] ),
132
+ 'field_type' => $update
133
+ );
134
+ $wpdb->update( VFB_WP_FIELDS_TABLE_NAME, array( 'field_sequence' => $field_sequence ), $where );
135
+
136
+ }
137
+
138
+ $field = new Visual_Form_Builder_Admin_Fields();
139
+ echo $field->field_output( $data['form_id'], $insert_id );
140
+
141
+ die(1);
142
+ }
143
+
144
+ /**
145
+ * Delete field
146
+ * @return [type] [description]
147
+ */
148
+ public function delete_field() {
149
+ global $wpdb;
150
+
151
+ if ( isset( $_POST['action'] ) && $_POST['action'] == 'visual_form_builder_delete_field' ) {
152
+ $form_id = absint( $_POST['form'] );
153
+ $field_id = absint( $_POST['field'] );
154
+
155
+ check_ajax_referer( 'delete-field-' . $form_id, 'nonce' );
156
+
157
+ if ( isset( $_POST['child_ids'] ) ) {
158
+ foreach ( $_POST['child_ids'] as $children ) {
159
+ $parent = absint( $_POST['parent_id'] );
160
+
161
+ // Update each child item with the new parent ID
162
+ $wpdb->update( VFB_WP_FIELDS_TABLE_NAME, array( 'field_parent' => $parent ), array( 'field_id' => $children ) );
163
+ }
164
+ }
165
+
166
+ // Delete the field
167
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE field_id = %d", $field_id ) );
168
+ }
169
+
170
+ die(1);
171
+ }
172
+
173
+ /**
174
+ * Form settings
175
+ * @return [type] [description]
176
+ */
177
+ public function form_settings() {
178
+ $current_user = wp_get_current_user();
179
+
180
+ if ( isset( $_POST['action'] ) && $_POST['action'] == 'visual_form_builder_form_settings' ) {
181
+ $form_id = absint( $_POST['form'] );
182
+ $status = isset( $_POST['status'] ) ? $_POST['status'] : 'opened';
183
+ $accordion = isset( $_POST['accordion'] ) ? $_POST['accordion'] : 'general-settings';
184
+ $user_id = $current_user instanceof WP_User ? $current_user->ID : 1;
185
+
186
+ $form_settings = get_user_meta( $user_id, 'vfb-form-settings', true );
187
+
188
+ $array = array(
189
+ 'form_setting_tab' => $status,
190
+ 'setting_accordion' => $accordion
191
+ );
192
+
193
+ // Set defaults if meta key doesn't exist
194
+ if ( !$form_settings || $form_settings == '' ) {
195
+ $meta_value[ $form_id ] = $array;
196
+
197
+ update_user_meta( $user_id, 'vfb-form-settings', $meta_value );
198
+ }
199
+ else {
200
+ $form_settings[ $form_id ] = $array;
201
+
202
+ update_user_meta( $user_id, 'vfb-form-settings', $form_settings );
203
+ }
204
+ }
205
+
206
+ die(1);
207
+ }
208
+ }
admin/class-dashboard-widgets.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class that displays widgets on the WordPress dashboard
4
+ *
5
+ */
6
+ class Visual_Form_Builder_Dashboard_Widgets {
7
+ /**
8
+ * __construct function.
9
+ *
10
+ * @access public
11
+ * @param mixed $id
12
+ * @return void
13
+ */
14
+ public function __construct() {
15
+ // Adds a Dashboard widget
16
+ add_action( 'wp_dashboard_setup', array( $this, 'register_widgets' ) );
17
+ }
18
+
19
+ /**
20
+ * Register our Dashboard widget
21
+ *
22
+ * @access public
23
+ * @return void
24
+ */
25
+ public function register_widgets() {
26
+ wp_add_dashboard_widget(
27
+ 'vfb-dashboard',
28
+ __( 'Recent Visual Form Builder Entries', 'visual-form-builder' ),
29
+ array( $this, 'widget_entries' ),
30
+ array( $this, 'widget_control' )
31
+ );
32
+
33
+ if ( !get_option( 'vfb_dashboard_widget_options' ) ) {
34
+ $widget_options['vfb_dashboard_recent_entries'] = array(
35
+ 'items' => 5,
36
+ );
37
+ update_option( 'vfb_dashboard_widget_options', $widget_options );
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Display recent submitted entries
43
+ * @return [type] [description]
44
+ */
45
+ public function widget_entries() {
46
+ global $wpdb;
47
+
48
+ // Get the date/time format that is saved in the options table
49
+ $date_format = get_option( 'date_format' );
50
+ $time_format = get_option( 'time_format' );
51
+
52
+ $widgets = get_option( 'vfb_dashboard_widget_options' );
53
+ $total_items = isset( $widgets['vfb_dashboard_recent_entries'] ) && isset( $widgets['vfb_dashboard_recent_entries']['items'] ) ? absint( $widgets['vfb_dashboard_recent_entries']['items'] ) : 5;
54
+
55
+ $forms = $wpdb->get_var( "SELECT COUNT(*) FROM " . VFB_WP_FORMS_TABLE_NAME );
56
+
57
+ if ( !$forms ) {
58
+ echo sprintf(
59
+ '<p>%1$s <a href="%2$s">%3$s</a></p>',
60
+ __( 'You currently do not have any forms.', 'visual-form-builder' ),
61
+ esc_url( admin_url( 'admin.php?page=vfb-add-new' ) ),
62
+ __( 'Get started!', 'visual-form-builder' )
63
+ );
64
+
65
+ return;
66
+ }
67
+
68
+ $entries = $wpdb->get_results( $wpdb->prepare( "SELECT forms.form_title, entries.entries_id, entries.form_id, entries.sender_name, entries.sender_email, entries.date_submitted FROM " . VFB_WP_FORMS_TABLE_NAME . " AS forms INNER JOIN " . VFB_WP_ENTRIES_TABLE_NAME . " AS entries ON entries.form_id = forms.form_id ORDER BY entries.date_submitted DESC LIMIT %d", $total_items ) );
69
+
70
+ if ( !$entries ) {
71
+ echo sprintf( '<p>%1$s</p>', __( 'You currently do not have any entries.', 'visual-form-builder' ) );
72
+ }
73
+ else {
74
+
75
+ $content = '';
76
+
77
+ foreach ( $entries as $entry ) {
78
+ $content .= sprintf(
79
+ '<li><a href="%1$s">%4$s</a> via <a href="%2$s">%5$s</a> <span class="rss-date">%6$s</span><cite>%3$s</cite></li>',
80
+ esc_url( add_query_arg( array( 'action' => 'view', 'entry' => absint( $entry->entries_id ) ), admin_url( 'admin.php?page=vfb-entries' ) ) ),
81
+ esc_url( add_query_arg( 'form-filter', absint( $entry->form_id ), admin_url( 'admin.php?page=vfb-entries' ) ) ),
82
+ esc_html( $entry->sender_name ),
83
+ esc_html( $entry->sender_email ),
84
+ esc_html( $entry->form_title ),
85
+ date( "$date_format $time_format", strtotime( $entry->date_submitted ) )
86
+ );
87
+ }
88
+
89
+ echo "<div class='rss-widget'><ul>$content</ul></div>";
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Displays the dashboard widget form control
95
+ * @return [type] [description]
96
+ */
97
+ public function widget_control() {
98
+ if ( !$widget_options = get_option( 'vfb_dashboard_widget_options' ) )
99
+ $widget_options = array();
100
+
101
+ if ( !isset( $widget_options['vfb_dashboard_recent_entries'] ) )
102
+ $widget_options['vfb_dashboard_recent_entries'] = array();
103
+
104
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['vfb-widget-recent-entries'] ) ) {
105
+ $number = absint( $_POST['vfb-widget-recent-entries']['items'] );
106
+ $widget_options['vfb_dashboard_recent_entries']['items'] = $number;
107
+ update_option( 'vfb_dashboard_widget_options', $widget_options );
108
+ }
109
+
110
+ $number = isset( $widget_options['vfb_dashboard_recent_entries']['items'] ) ? (int) $widget_options['vfb_dashboard_recent_entries']['items'] : '';
111
+
112
+ echo sprintf(
113
+ '<p>
114
+ <label for="comments-number">%1$s</label>
115
+ <input id="comments-number" name="vfb-widget-recent-entries[items]" type="text" value="%2$d" size="3" />
116
+ </p>',
117
+ __( 'Number of entries to show:', 'visual-form-builder' ),
118
+ $number
119
+ );
120
+ }
121
+ }
{includes → admin}/class-entries-detail.php RENAMED
@@ -4,48 +4,20 @@
4
  *
5
  * @since 1.4
6
  */
7
- class VisualFormBuilder_Entries_Detail{
8
  /**
9
- * field_table_name
10
- *
11
- * @var mixed
12
- * @access public
13
  */
14
- public $field_table_name;
15
-
16
- /**
17
- * form_table_name
18
- *
19
- * @var mixed
20
- * @access public
21
- */
22
- public $form_table_name;
23
-
24
- /**
25
- * entries_table_name
26
- *
27
- * @var mixed
28
- * @access public
29
- */
30
- public $entries_table_name;
31
-
32
- public function __construct(){
33
- global $wpdb;
34
-
35
- // Setup global database table names
36
- $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
37
- $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
38
- $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
39
-
40
- add_action( 'admin_init', array( &$this, 'entries_detail' ) );
41
  }
42
 
43
- public function entries_detail(){
44
  global $wpdb;
45
 
46
  $entry_id = absint( $_GET['entry'] );
47
 
48
- $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 ) );
49
 
50
  echo '<p>' . sprintf( '<a href="?page=%s" class="view-entry">&laquo; Back to Entries</a>', $_GET['page'] ) . '</p>';
51
 
4
  *
5
  * @since 1.4
6
  */
7
+ class Visual_Form_Builder_Entries_Detail {
8
  /**
9
+ * [__construct description]
 
 
 
10
  */
11
+ public function __construct() {
12
+ add_action( 'admin_init', array( $this, 'entries_detail' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
 
15
+ public function entries_detail() {
16
  global $wpdb;
17
 
18
  $entry_id = absint( $_GET['entry'] );
19
 
20
+ $entries = $wpdb->get_results( $wpdb->prepare( "SELECT forms.form_title, entries.* FROM " . VFB_WP_FORMS_TABLE_NAME . " AS forms INNER JOIN " . VFB_WP_ENTRIES_TABLE_NAME . " AS entries ON entries.form_id = forms.form_id WHERE entries.entries_id = %d", $entry_id ) );
21
 
22
  echo '<p>' . sprintf( '<a href="?page=%s" class="view-entry">&laquo; Back to Entries</a>', $_GET['page'] ) . '</p>';
23
 
{includes → admin}/class-entries-list.php RENAMED
@@ -4,42 +4,16 @@
4
  *
5
  * @since 1.2
6
  */
7
- class VisualFormBuilder_Entries_List extends WP_List_Table {
8
  /**
9
- * field_table_name
10
- *
11
- * @var mixed
12
- * @access public
13
- */
14
- public $field_table_name;
15
-
16
- /**
17
- * form_table_name
18
- *
19
- * @var mixed
20
- * @access public
21
  */
22
- public $form_table_name;
23
-
24
- /**
25
- * entries_table_name
26
- *
27
- * @var mixed
28
- * @access public
29
- */
30
- public $entries_table_name;
31
-
32
  function __construct(){
33
- global $status, $page, $wpdb;
34
 
35
  // CSV delimiter
36
  $this->delimiter = apply_filters( 'vfb_csv_delimiter', ',' );
37
 
38
- // Setup global database table names
39
- $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
40
- $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
41
- $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
42
-
43
  // Set parent defaults
44
  parent::__construct( array(
45
  'singular' => 'entry',
@@ -186,7 +160,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
186
  $where .= $wpdb->prepare( ' AND entries.entry_approved = %d', 1 );
187
 
188
  $sql_order = sanitize_sql_orderby( "$order_col $order" );
189
- $cols = $wpdb->get_results( "SELECT forms.form_title, entries.entries_id, entries.form_id, entries.subject, entries.sender_name, entries.sender_email, entries.emails_to, entries.date_submitted, entries.ip_address FROM $this->form_table_name AS forms INNER JOIN $this->entries_table_name AS entries ON entries.form_id = forms.form_id WHERE 1=1 $where $search ORDER BY $sql_order LIMIT $per_page $offset" );
190
 
191
  return $cols;
192
  }
@@ -252,7 +226,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
252
 
253
  $stats = array();
254
 
255
- $entries = $wpdb->get_results( "SELECT entries.entry_approved, COUNT( * ) AS num_entries FROM $this->entries_table_name AS entries WHERE 1=1 GROUP BY entries.entry_approved", ARRAY_A );
256
 
257
  $total = 0;
258
  $approved = array( '0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
@@ -334,21 +308,21 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
334
  case 'trash' :
335
  foreach ( $entry_id as $id ) {
336
  $id = absint( $id );
337
- $wpdb->update( $this->entries_table_name, array( 'entry_approved' => 'trash' ), array( 'entries_id' => $id ) );
338
  }
339
  break;
340
 
341
  case 'delete' :
342
  foreach ( $entry_id as $id ) {
343
  $id = absint( $id );
344
- $wpdb->query( $wpdb->prepare( "DELETE FROM $this->entries_table_name WHERE entries_id = %d", $id ) );
345
  }
346
  break;
347
 
348
  case 'restore' :
349
  foreach ( $entry_id as $id ) {
350
  $id = absint( $id );
351
- $wpdb->update( $this->entries_table_name, array( 'entry_approved' => 1 ), array( 'entries_id' => $id ) );
352
  }
353
  break;
354
 
@@ -359,7 +333,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
359
 
360
  foreach ( $entry_id as $id ) {
361
  $id = absint( $id );
362
- $wpdb->query( $wpdb->prepare( "DELETE FROM $this->entries_table_name WHERE entries_id = %d", $id ) );
363
  }
364
  break;
365
  endswitch;
@@ -373,14 +347,14 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
373
  function extra_tablenav( $which ) {
374
  global $wpdb;
375
 
376
- $cols = $wpdb->get_results( "SELECT DISTINCT forms.form_title, forms.form_id FROM $this->form_table_name AS forms ORDER BY forms.form_id ASC" );
377
 
378
  // Only display the dropdown on the top of the table
379
  if ( 'top' == $which ) {
380
  echo '<div class="alignleft actions">';
381
  $this->months_dropdown();
382
  echo '<select id="form-filter" name="form-filter">
383
- <option value="-1"' . selected( $this->current_filter_action(), -1 ) . '>' . __( 'View all forms' , 'visual-form-builder-pro') . '</option>';
384
 
385
  foreach ( $cols as $form ) {
386
  echo sprintf( '<option value="%1$d"%2$s>%1$d - %3$s</option>',
@@ -391,7 +365,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
391
  }
392
 
393
  echo '</select>
394
- <input type="submit" value="' . __( 'Filter' , 'visual-form-builder-pro') . '" class="button-secondary" />
395
  </div>';
396
  }
397
  }
@@ -406,7 +380,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
406
 
407
  $months = $wpdb->get_results( "
408
  SELECT DISTINCT YEAR( forms.date_submitted ) AS year, MONTH( forms.date_submitted ) AS month
409
- FROM $this->entries_table_name AS forms
410
  ORDER BY forms.date_submitted DESC
411
  " );
412
 
@@ -482,8 +456,8 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
482
  $per_page = get_user_meta( $user, $screen_option, true );
483
 
484
  // get the default value if none is set
485
- if ( empty ( $per_page) || $per_page < 1 )
486
- $per_page = $screen->get_option( 'per_page', 'default' );
487
 
488
  // Get the date/time format that is saved in the options table
489
  $date_format = get_option( 'date_format' );
@@ -576,7 +550,7 @@ class VisualFormBuilder_Entries_List extends WP_List_Table {
576
  $where .= $wpdb->prepare( ' AND entries.entry_approved = %d', 1 );
577
 
578
  // How many entries do we have?
579
- $total_items = $wpdb->get_var( "SELECT COUNT(*) FROM $this->entries_table_name AS entries WHERE 1=1 $where" );
580
 
581
  // Add sorted data to the items property
582
  $this->items = $data;
4
  *
5
  * @since 1.2
6
  */
7
+ class Visual_Form_Builder_Entries_List extends Visual_Form_Builder_List_Table {
8
  /**
9
+ * [__construct description]
 
 
 
 
 
 
 
 
 
 
 
10
  */
 
 
 
 
 
 
 
 
 
 
11
  function __construct(){
12
+ global $status, $page;
13
 
14
  // CSV delimiter
15
  $this->delimiter = apply_filters( 'vfb_csv_delimiter', ',' );
16
 
 
 
 
 
 
17
  // Set parent defaults
18
  parent::__construct( array(
19
  'singular' => 'entry',
160
  $where .= $wpdb->prepare( ' AND entries.entry_approved = %d', 1 );
161
 
162
  $sql_order = sanitize_sql_orderby( "$order_col $order" );
163
+ $cols = $wpdb->get_results( "SELECT forms.form_title, entries.entries_id, entries.form_id, entries.subject, entries.sender_name, entries.sender_email, entries.emails_to, entries.date_submitted, entries.ip_address FROM " . VFB_WP_FORMS_TABLE_NAME . " AS forms INNER JOIN " . VFB_WP_ENTRIES_TABLE_NAME . " AS entries ON entries.form_id = forms.form_id WHERE 1=1 $where $search ORDER BY $sql_order LIMIT $per_page $offset" );
164
 
165
  return $cols;
166
  }
226
 
227
  $stats = array();
228
 
229
+ $entries = $wpdb->get_results( "SELECT entries.entry_approved, COUNT( * ) AS num_entries FROM " . VFB_WP_ENTRIES_TABLE_NAME . " AS entries WHERE 1=1 GROUP BY entries.entry_approved", ARRAY_A );
230
 
231
  $total = 0;
232
  $approved = array( '0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
308
  case 'trash' :
309
  foreach ( $entry_id as $id ) {
310
  $id = absint( $id );
311
+ $wpdb->update( VFB_WP_ENTRIES_TABLE_NAME, array( 'entry_approved' => 'trash' ), array( 'entries_id' => $id ) );
312
  }
313
  break;
314
 
315
  case 'delete' :
316
  foreach ( $entry_id as $id ) {
317
  $id = absint( $id );
318
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE entries_id = %d", $id ) );
319
  }
320
  break;
321
 
322
  case 'restore' :
323
  foreach ( $entry_id as $id ) {
324
  $id = absint( $id );
325
+ $wpdb->update( VFB_WP_ENTRIES_TABLE_NAME, array( 'entry_approved' => 1 ), array( 'entries_id' => $id ) );
326
  }
327
  break;
328
 
333
 
334
  foreach ( $entry_id as $id ) {
335
  $id = absint( $id );
336
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE entries_id = %d", $id ) );
337
  }
338
  break;
339
  endswitch;
347
  function extra_tablenav( $which ) {
348
  global $wpdb;
349
 
350
+ $cols = $wpdb->get_results( "SELECT DISTINCT forms.form_title, forms.form_id FROM " . VFB_WP_FORMS_TABLE_NAME . " AS forms ORDER BY forms.form_id ASC" );
351
 
352
  // Only display the dropdown on the top of the table
353
  if ( 'top' == $which ) {
354
  echo '<div class="alignleft actions">';
355
  $this->months_dropdown();
356
  echo '<select id="form-filter" name="form-filter">
357
+ <option value="-1"' . selected( $this->current_filter_action(), -1 ) . '>' . __( 'View all forms' , 'visual-form-builder') . '</option>';
358
 
359
  foreach ( $cols as $form ) {
360
  echo sprintf( '<option value="%1$d"%2$s>%1$d - %3$s</option>',
365
  }
366
 
367
  echo '</select>
368
+ <input type="submit" value="' . __( 'Filter' , 'visual-form-builder') . '" class="button-secondary" />
369
  </div>';
370
  }
371
  }
380
 
381
  $months = $wpdb->get_results( "
382
  SELECT DISTINCT YEAR( forms.date_submitted ) AS year, MONTH( forms.date_submitted ) AS month
383
+ FROM " . VFB_WP_ENTRIES_TABLE_NAME . " AS forms
384
  ORDER BY forms.date_submitted DESC
385
  " );
386
 
456
  $per_page = get_user_meta( $user, $screen_option, true );
457
 
458
  // get the default value if none is set
459
+ if ( empty ( $per_page ) || $per_page < 1 )
460
+ $per_page = 20;
461
 
462
  // Get the date/time format that is saved in the options table
463
  $date_format = get_option( 'date_format' );
550
  $where .= $wpdb->prepare( ' AND entries.entry_approved = %d', 1 );
551
 
552
  // How many entries do we have?
553
+ $total_items = $wpdb->get_var( "SELECT COUNT(*) FROM " . VFB_WP_ENTRIES_TABLE_NAME . " AS entries WHERE 1=1 $where" );
554
 
555
  // Add sorted data to the items property
556
  $this->items = $data;
{includes → admin}/class-export.php RENAMED
@@ -1,34 +1,9 @@
1
  <?php
2
  /**
3
- * Class that builds our Entries table
4
  *
5
- * @since 1.2
6
  */
7
- class VisualFormBuilder_Export {
8
- /**
9
- * field_table_name
10
- *
11
- * @var mixed
12
- * @access public
13
- */
14
- public $field_table_name;
15
-
16
- /**
17
- * form_table_name
18
- *
19
- * @var mixed
20
- * @access public
21
- */
22
- public $form_table_name;
23
-
24
- /**
25
- * entries_table_name
26
- *
27
- * @var mixed
28
- * @access public
29
- */
30
- public $entries_table_name;
31
-
32
  /**
33
  * delimiter
34
  *
@@ -62,16 +37,11 @@ class VisualFormBuilder_Export {
62
  'emails_to' => __( 'Emailed To' , 'visual-form-builder'),
63
  );
64
 
65
- // Setup global database table names
66
- $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
67
- $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
68
- $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
69
-
70
  // AJAX for loading new entry checkboxes
71
- add_action( 'wp_ajax_visual_form_builder_export_load_options', array( &$this, 'ajax_load_options' ) );
72
 
73
  // AJAX for getting entries count
74
- add_action( 'wp_ajax_visual_form_builder_export_entries_count', array( &$this, 'ajax_entries_count' ) );
75
 
76
  $this->process_export_action();
77
  }
@@ -88,7 +58,7 @@ class VisualFormBuilder_Export {
88
  // Query to get all forms
89
  $order = sanitize_sql_orderby( 'form_id ASC' );
90
  $where = apply_filters( 'vfb_pre_get_forms_export', '' );
91
- $forms = $wpdb->get_results( "SELECT form_id, form_key, form_title FROM $this->form_table_name WHERE 1=1 $where ORDER BY $order" );
92
 
93
  if ( !$forms ) :
94
  echo sprintf(
@@ -109,7 +79,7 @@ class VisualFormBuilder_Export {
109
  $limit = $entries_count > 1000 ? 1000 : $entries_count;
110
 
111
  // Safe to get entries now
112
- $entries = $wpdb->get_results( $wpdb->prepare( "SELECT data FROM $this->entries_table_name WHERE form_id = %d AND entry_approved = 1 LIMIT %d", $forms[0]->form_id, $limit ), ARRAY_A );
113
 
114
  // Get columns
115
  $columns = $this->get_cols( $entries );
@@ -252,8 +222,8 @@ class VisualFormBuilder_Export {
252
 
253
  $form_id = ( 0 !== $args['form_id'] ) ? $args['form_id'] : null;
254
 
255
- $entries = $wpdb->get_results( "SELECT * FROM $this->entries_table_name WHERE entry_approved = 1 $where ORDER BY entries_id ASC LIMIT $limit" );
256
- $form_key = $wpdb->get_var( $wpdb->prepare( "SELECT form_key, form_title FROM $this->form_table_name WHERE form_id = %d", $args['form_id'] ) );
257
  $form_title = $wpdb->get_var( null, 1 );
258
 
259
  $sitename = sanitize_key( get_bloginfo( 'name' ) );
@@ -373,10 +343,15 @@ class VisualFormBuilder_Export {
373
  return json_encode( $output );
374
  }
375
 
 
 
 
 
 
376
  public function count_entries( $form_id ) {
377
  global $wpdb;
378
 
379
- $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $this->entries_table_name WHERE form_id = %d", $form_id ) );
380
 
381
  if ( !$count )
382
  return 0;
@@ -384,6 +359,11 @@ class VisualFormBuilder_Export {
384
  return $count;
385
  }
386
 
 
 
 
 
 
387
  public function get_form_IDs( $form_id = null ) {
388
  global $wpdb;
389
 
@@ -392,7 +372,7 @@ class VisualFormBuilder_Export {
392
  if ( $form_id )
393
  $where .= $wpdb->prepare( " AND form_id = %d", $form_id );
394
 
395
- $form_ids = $wpdb->get_col( "SELECT DISTINCT form_id FROM $this->form_table_name WHERE 1=1 $where" );
396
 
397
  if ( !$form_ids )
398
  return;
@@ -400,6 +380,11 @@ class VisualFormBuilder_Export {
400
  return $form_ids;
401
  }
402
 
 
 
 
 
 
403
  public function get_field_IDs( $form_id = null ) {
404
  global $wpdb;
405
 
@@ -408,7 +393,7 @@ class VisualFormBuilder_Export {
408
  if ( $form_id )
409
  $where .= $wpdb->prepare( " AND form_id = %d", $form_id );
410
 
411
- $field_ids = $wpdb->get_col( "SELECT DISTINCT field_id FROM $this->field_table_name WHERE 1=1 $where" );
412
 
413
  if ( !$field_ids )
414
  return;
@@ -416,6 +401,11 @@ class VisualFormBuilder_Export {
416
  return $field_ids;
417
  }
418
 
 
 
 
 
 
419
  public function get_entry_IDs( $form_id = null ) {
420
  global $wpdb;
421
 
@@ -430,7 +420,7 @@ class VisualFormBuilder_Export {
430
 
431
 
432
 
433
- $entry_ids = $wpdb->get_col( "SELECT DISTINCT entries_id FROM $this->entries_table_name WHERE entry_approved = 1 $where" );
434
 
435
  if ( !$entry_ids )
436
  return;
@@ -438,38 +428,6 @@ class VisualFormBuilder_Export {
438
  return $entry_ids;
439
  }
440
 
441
- public function get_form_design_IDs( $form_id = null ) {
442
- global $wpdb;
443
-
444
- $where = '';
445
-
446
- if ( $form_id )
447
- $where .= $wpdb->prepare( " AND form_id = %d", $form_id );
448
-
449
- $design_ids = $wpdb->get_col( "SELECT DISTINCT design_id FROM {$this->design_table_name} WHERE 1=1 $where" );
450
-
451
- if ( !$design_ids )
452
- return;
453
-
454
- return $design_ids;
455
- }
456
-
457
- public function get_payments_IDs( $form_id = null ) {
458
- global $wpdb;
459
-
460
- $where = '';
461
-
462
- if ( $form_id )
463
- $where .= $wpdb->prepare( " AND form_id = %d", $form_id );
464
-
465
- $payments_ids = $wpdb->get_col( "SELECT DISTINCT payment_id FROM {$this->payment_table_name} WHERE 1=1 $where" );
466
-
467
- if ( !$payments_ids )
468
- return;
469
-
470
- return $payments_ids;
471
- }
472
-
473
  /**
474
  * Return the entries data formatted for CSV
475
  *
@@ -538,7 +496,7 @@ class VisualFormBuilder_Export {
538
 
539
  // Return nothing if no entries found
540
  if ( !$entry_ids ) {
541
- echo __( 'No entries to pull field names from.', 'visual-form-builder-pro' );
542
  wp_die();
543
  }
544
 
@@ -558,7 +516,7 @@ class VisualFormBuilder_Export {
558
  $offset = $offset >= 1 ? "OFFSET $offset_num" : '';
559
  }
560
 
561
- $entries = $wpdb->get_results( "SELECT data FROM {$this->entries_table_name} WHERE form_id = $form_id AND entry_approved = 1 LIMIT $limit $offset", ARRAY_A );
562
 
563
  // Get columns
564
  $columns = $export->get_cols( $entries );
@@ -676,7 +634,7 @@ class VisualFormBuilder_Export {
676
 
677
  $months = $wpdb->get_results( "
678
  SELECT DISTINCT YEAR( forms.date_submitted ) AS year, MONTH( forms.date_submitted ) AS month
679
- FROM $this->entries_table_name AS forms
680
  WHERE 1=1 $where
681
  ORDER BY forms.date_submitted DESC
682
  " );
1
  <?php
2
  /**
3
+ * Class that controls the Export page view
4
  *
 
5
  */
6
+ class Visual_Form_Builder_Export {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  /**
8
  * delimiter
9
  *
37
  'emails_to' => __( 'Emailed To' , 'visual-form-builder'),
38
  );
39
 
 
 
 
 
 
40
  // AJAX for loading new entry checkboxes
41
+ add_action( 'wp_ajax_visual_form_builder_export_load_options', array( $this, 'ajax_load_options' ) );
42
 
43
  // AJAX for getting entries count
44
+ add_action( 'wp_ajax_visual_form_builder_export_entries_count', array( $this, 'ajax_entries_count' ) );
45
 
46
  $this->process_export_action();
47
  }
58
  // Query to get all forms
59
  $order = sanitize_sql_orderby( 'form_id ASC' );
60
  $where = apply_filters( 'vfb_pre_get_forms_export', '' );
61
+ $forms = $wpdb->get_results( "SELECT form_id, form_key, form_title FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE 1=1 $where ORDER BY $order" );
62
 
63
  if ( !$forms ) :
64
  echo sprintf(
79
  $limit = $entries_count > 1000 ? 1000 : $entries_count;
80
 
81
  // Safe to get entries now
82
+ $entries = $wpdb->get_results( $wpdb->prepare( "SELECT data FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE form_id = %d AND entry_approved = 1 LIMIT %d", $forms[0]->form_id, $limit ), ARRAY_A );
83
 
84
  // Get columns
85
  $columns = $this->get_cols( $entries );
222
 
223
  $form_id = ( 0 !== $args['form_id'] ) ? $args['form_id'] : null;
224
 
225
+ $entries = $wpdb->get_results( "SELECT * FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE entry_approved = 1 $where ORDER BY entries_id ASC LIMIT $limit" );
226
+ $form_key = $wpdb->get_var( $wpdb->prepare( "SELECT form_key, form_title FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE form_id = %d", $args['form_id'] ) );
227
  $form_title = $wpdb->get_var( null, 1 );
228
 
229
  $sitename = sanitize_key( get_bloginfo( 'name' ) );
343
  return json_encode( $output );
344
  }
345
 
346
+ /**
347
+ * [count_entries description]
348
+ * @param [type] $form_id [description]
349
+ * @return [type] [description]
350
+ */
351
  public function count_entries( $form_id ) {
352
  global $wpdb;
353
 
354
+ $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE form_id = %d", $form_id ) );
355
 
356
  if ( !$count )
357
  return 0;
359
  return $count;
360
  }
361
 
362
+ /**
363
+ * [get_form_IDs description]
364
+ * @param [type] $form_id [description]
365
+ * @return [type] [description]
366
+ */
367
  public function get_form_IDs( $form_id = null ) {
368
  global $wpdb;
369
 
372
  if ( $form_id )
373
  $where .= $wpdb->prepare( " AND form_id = %d", $form_id );
374
 
375
+ $form_ids = $wpdb->get_col( "SELECT DISTINCT form_id FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE 1=1 $where" );
376
 
377
  if ( !$form_ids )
378
  return;
380
  return $form_ids;
381
  }
382
 
383
+ /**
384
+ * [get_field_IDs description]
385
+ * @param [type] $form_id [description]
386
+ * @return [type] [description]
387
+ */
388
  public function get_field_IDs( $form_id = null ) {
389
  global $wpdb;
390
 
393
  if ( $form_id )
394
  $where .= $wpdb->prepare( " AND form_id = %d", $form_id );
395
 
396
+ $field_ids = $wpdb->get_col( "SELECT DISTINCT field_id FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE 1=1 $where" );
397
 
398
  if ( !$field_ids )
399
  return;
401
  return $field_ids;
402
  }
403
 
404
+ /**
405
+ * [get_entry_IDs description]
406
+ * @param [type] $form_id [description]
407
+ * @return [type] [description]
408
+ */
409
  public function get_entry_IDs( $form_id = null ) {
410
  global $wpdb;
411
 
420
 
421
 
422
 
423
+ $entry_ids = $wpdb->get_col( "SELECT DISTINCT entries_id FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE entry_approved = 1 $where" );
424
 
425
  if ( !$entry_ids )
426
  return;
428
  return $entry_ids;
429
  }
430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  /**
432
  * Return the entries data formatted for CSV
433
  *
496
 
497
  // Return nothing if no entries found
498
  if ( !$entry_ids ) {
499
+ echo __( 'No entries to pull field names from.', 'visual-form-builder' );
500
  wp_die();
501
  }
502
 
516
  $offset = $offset >= 1 ? "OFFSET $offset_num" : '';
517
  }
518
 
519
+ $entries = $wpdb->get_results( "SELECT data FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE form_id = $form_id AND entry_approved = 1 LIMIT $limit $offset", ARRAY_A );
520
 
521
  // Get columns
522
  $columns = $export->get_cols( $entries );
634
 
635
  $months = $wpdb->get_results( "
636
  SELECT DISTINCT YEAR( forms.date_submitted ) AS year, MONTH( forms.date_submitted ) AS month
637
+ FROM " . VFB_WP_ENTRIES_TABLE_NAME . " AS forms
638
  WHERE 1=1 $where
639
  ORDER BY forms.date_submitted DESC
640
  " );
admin/class-fields.php ADDED
@@ -0,0 +1,455 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * [Visual_Form_Builder_Admin_Fields description]
4
+ */
5
+ class Visual_Form_Builder_Admin_Fields {
6
+ public function field_output( $form_nav_selected_id, $field_id = NULL ) {
7
+ global $wpdb;
8
+
9
+ $field_where = ( isset( $field_id ) && !is_null( $field_id ) ) ? "AND field_id = $field_id" : '';
10
+ // Display all fields for the selected form
11
+ $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE form_id = %d $field_where ORDER BY field_sequence ASC", $form_nav_selected_id ) );
12
+
13
+ $depth = 1;
14
+ $parent = $last = 0;
15
+ ob_start();
16
+
17
+ // Loop through each field and display
18
+ foreach ( $fields as &$field ) :
19
+ // If we are at the root level
20
+ if ( !$field->field_parent && $depth > 1 ) {
21
+ // If we've been down a level, close out the list
22
+ while ( $depth > 1 ) {
23
+ echo '</li></ul>';
24
+ $depth--;
25
+ }
26
+
27
+ // Close out the root item
28
+ echo '</li>';
29
+ }
30
+ // first item of <ul>, so move down a level
31
+ elseif ( $field->field_parent && $field->field_parent == $last ) {
32
+ echo '<ul class="parent">';
33
+ $depth++;
34
+ }
35
+ // Close up a <ul> and move up a level
36
+ elseif ( $field->field_parent && $field->field_parent != $parent ) {
37
+ echo '</li></ul></li>';
38
+ $depth--;
39
+ }
40
+ // Same level so close list item
41
+ elseif ( $field->field_parent && $field->field_parent == $parent )
42
+ echo '</li>';
43
+
44
+ // Store item ID and parent ID to test for nesting
45
+ $last = $field->field_id;
46
+ $parent = $field->field_parent;
47
+ ?>
48
+ <li id="form_item_<?php echo $field->field_id; ?>" class="form-item<?php echo ( in_array( $field->field_type, array( 'submit', 'secret', 'verification' ) ) ) ? ' ui-state-disabled' : ''; ?><?php echo ( !in_array( $field->field_type, array( 'fieldset', 'section', 'verification' ) ) ) ? ' mjs-nestedSortable-no-nesting' : ''; ?>">
49
+ <dl class="menu-item-bar vfb-menu-item-inactive">
50
+ <dt class="vfb-menu-item-handle vfb-menu-item-type-<?php echo esc_attr( $field->field_type ); ?>">
51
+ <span class="item-title"><?php echo stripslashes( esc_attr( $field->field_name ) ); ?><?php echo ( $field->field_required == 'yes' ) ? ' <span class="is-field-required">*</span>' : ''; ?></span>
52
+ <span class="item-controls">
53
+ <span class="item-type"><?php echo strtoupper( str_replace( '-', ' ', $field->field_type ) ); ?></span>
54
+ <a href="#" title="<?php _e( 'Edit Field Item' , 'visual-form-builder'); ?>" id="edit-<?php echo $field->field_id; ?>" class="item-edit"><?php _e( 'Edit Field Item' , 'visual-form-builder'); ?></a>
55
+ </span>
56
+ </dt>
57
+ </dl>
58
+
59
+ <div id="form-item-settings-<?php echo $field->field_id; ?>" class="menu-item-settings field-type-<?php echo $field->field_type; ?>" style="display: none;">
60
+ <?php if ( in_array( $field->field_type, array( 'fieldset', 'section', 'verification' ) ) ) : ?>
61
+
62
+ <p class="description description-wide">
63
+ <label for="edit-form-item-name-<?php echo $field->field_id; ?>"><?php echo ( in_array( $field->field_type, array( 'fieldset', 'verification' ) ) ) ? 'Legend' : 'Name'; ?>
64
+ <span class="vfb-tooltip" rel="<?php esc_attr_e( 'For Fieldsets, a Legend is simply the name of that group. Use general terms that describe the fields included in this Fieldset.', 'visual-form-builder' ); ?>" title="<?php esc_attr_e( 'About Legend', 'visual-form-builder' ); ?>">(?)</span>
65
+ <br />
66
+ <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" maxlength="255" />
67
+ </label>
68
+ </p>
69
+ <p class="description description-wide">
70
+ <label for="edit-form-item-css-<?php echo $field->field_id; ?>">
71
+ <?php _e( 'CSS Classes' , 'visual-form-builder'); ?>
72
+ <span class="vfb-tooltip" rel="<?php esc_attr_e( 'For each field, you can insert your own CSS class names which can be used in your own stylesheets.', 'visual-form-builder' ); ?>" title="<?php esc_attr_e( 'About CSS Classes', 'visual-form-builder' ); ?>">(?)</span>
73
+ <br />
74
+ <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" />
75
+ </label>
76
+ </p>
77
+
78
+ <?php elseif( $field->field_type == 'instructions' ) : ?>
79
+ <!-- Instructions -->
80
+ <p class="description description-wide">
81
+ <label for="edit-form-item-name-<?php echo $field->field_id; ?>">
82
+ <?php _e( 'Name' , 'visual-form-builder'); ?>
83
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Name', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( "A field's name is the most visible and direct way to describe what that field is for.", 'visual-form-builder' ); ?>">(?)</span>
84
+ <br />
85
+ <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" maxlength="255" />
86
+ </label>
87
+ </p>
88
+ <!-- Description -->
89
+ <p class="description description-wide">
90
+ <label for="edit-form-item-description-<?php echo $field->field_id; ?>">
91
+ <?php _e( 'Description (HTML tags allowed)', 'visual-form-builder' ); ?>
92
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Instructions Description', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'The Instructions field allows for long form explanations, typically seen at the beginning of Fieldsets or Sections. HTML tags are allowed.', 'visual-form-builder' ); ?>">(?)</span>
93
+ <br />
94
+ <textarea name="field_description-<?php echo $field->field_id; ?>" class="widefat edit-menu-item-description" cols="20" rows="3" id="edit-form-item-description-<?php echo $field->field_id; ?>" /><?php echo stripslashes( $field->field_description ); ?></textarea>
95
+ </label>
96
+ </p>
97
+ <!-- CSS Classes -->
98
+ <p class="description description-thin">
99
+ <label for="edit-form-item-css-<?php echo $field->field_id; ?>">
100
+ <?php _e( 'CSS Classes' , 'visual-form-builder'); ?>
101
+ <span class="vfb-tooltip" rel="<?php esc_attr_e( 'For each field, you can insert your own CSS class names which can be used in your own stylesheets.', 'visual-form-builder' ); ?>" title="<?php esc_attr_e( 'About CSS Classes', 'visual-form-builder' ); ?>">(?)</span>
102
+ <br />
103
+ <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" />
104
+ </label>
105
+ </p>
106
+
107
+ <!-- Field Layout -->
108
+ <p class="description description-thin">
109
+ <label for="edit-form-item-layout">
110
+ <?php _e( 'Field Layout' , 'visual-form-builder'); ?>
111
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Field Layout', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Used to create advanced layouts. Align fields side by side in various configurations.', 'visual-form-builder' ); ?>">(?)</span>
112
+ <br />
113
+ <select name="field_layout-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-layout-<?php echo $field->field_id; ?>">
114
+
115
+ <option value="" <?php selected( $field->field_layout, '' ); ?>><?php _e( 'Default' , 'visual-form-builder'); ?></option>
116
+ <optgroup label="------------">
117
+ <option value="left-half" <?php selected( $field->field_layout, 'left-half' ); ?>><?php _e( 'Left Half' , 'visual-form-builder'); ?></option>
118
+ <option value="right-half" <?php selected( $field->field_layout, 'right-half' ); ?>><?php _e( 'Right Half' , 'visual-form-builder'); ?></option>
119
+ </optgroup>
120
+ <optgroup label="------------">
121
+ <option value="left-third" <?php selected( $field->field_layout, 'left-third' ); ?>><?php _e( 'Left Third' , 'visual-form-builder'); ?></option>
122
+ <option value="middle-third" <?php selected( $field->field_layout, 'middle-third' ); ?>><?php _e( 'Middle Third' , 'visual-form-builder'); ?></option>
123
+ <option value="right-third" <?php selected( $field->field_layout, 'right-third' ); ?>><?php _e( 'Right Third' , 'visual-form-builder'); ?></option>
124
+ </optgroup>
125
+ <optgroup label="------------">
126
+ <option value="left-two-thirds" <?php selected( $field->field_layout, 'left-two-thirds' ); ?>><?php _e( 'Left Two Thirds' , 'visual-form-builder'); ?></option>
127
+ <option value="right-two-thirds" <?php selected( $field->field_layout, 'right-two-thirds' ); ?>><?php _e( 'Right Two Thirds' , 'visual-form-builder'); ?></option>
128
+ </optgroup>
129
+ <?php apply_filters( 'vfb_admin_field_layout', $field->field_layout ); ?>
130
+ </select>
131
+ </label>
132
+ </p>
133
+
134
+ <?php else: ?>
135
+
136
+ <!-- Name -->
137
+ <p class="description description-wide">
138
+ <label for="edit-form-item-name-<?php echo $field->field_id; ?>">
139
+ <?php _e( 'Name' , 'visual-form-builder'); ?>
140
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Name', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( "A field's name is the most visible and direct way to describe what that field is for.", 'visual-form-builder' ); ?>">(?)</span>
141
+ <br />
142
+ <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" maxlength="255" />
143
+ </label>
144
+ </p>
145
+ <?php if ( $field->field_type == 'submit' ) : ?>
146
+ <!-- CSS Classes -->
147
+ <p class="description description-wide">
148
+ <label for="edit-form-item-css-<?php echo $field->field_id; ?>">
149
+ <?php _e( 'CSS Classes' , 'visual-form-builder'); ?>
150
+ <span class="vfb-tooltip" rel="<?php esc_attr_e( 'For each field, you can insert your own CSS class names which can be used in your own stylesheets.', 'visual-form-builder' ); ?>" title="<?php esc_attr_e( 'About CSS Classes', 'visual-form-builder' ); ?>">(?)</span>
151
+ <br />
152
+ <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" />
153
+ </label>
154
+ </p>
155
+ <?php elseif ( $field->field_type !== 'submit' ) : ?>
156
+ <!-- Description -->
157
+ <p class="description description-wide">
158
+ <label for="edit-form-item-description-<?php echo $field->field_id; ?>">
159
+ <?php _e( 'Description' , 'visual-form-builder'); ?>
160
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Description', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'A description is an optional piece of text that further explains the meaning of this field. Descriptions are displayed below the field. HTML tags are allowed.', 'visual-form-builder' ); ?>">(?)</span>
161
+ <br />
162
+ <textarea name="field_description-<?php echo $field->field_id; ?>" class="widefat edit-menu-item-description" cols="20" rows="3" id="edit-form-item-description-<?php echo $field->field_id; ?>" /><?php echo stripslashes( $field->field_description ); ?></textarea>
163
+ </label>
164
+ </p>
165
+
166
+ <?php
167
+ // Display the Options input only for radio, checkbox, and select fields
168
+ if ( in_array( $field->field_type, array( 'radio', 'checkbox', 'select' ) ) ) : ?>
169
+ <!-- Options -->
170
+ <p class="description description-wide">
171
+ <?php _e( 'Options' , 'visual-form-builder'); ?>
172
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Options', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( '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.', 'visual-form-builder' ); ?>">(?)</span>
173
+ <br />
174
+ <?php
175
+ // If the options field isn't empty, unserialize and build array
176
+ if ( !empty( $field->field_options ) ) {
177
+ if ( is_serialized( $field->field_options ) )
178
+ $opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
179
+ }
180
+ // Otherwise, present some default options
181
+ else
182
+ $opts_vals = array( 'Option 1', 'Option 2', 'Option 3' );
183
+
184
+ // Basic count to keep track of multiple options
185
+ $count = 1;
186
+ ?>
187
+ <div class="vfb-cloned-options">
188
+ <?php foreach ( $opts_vals as $options ) : ?>
189
+ <div id="clone-<?php echo $field->field_id . '-' . $count; ?>" class="option">
190
+ <label for="edit-form-item-options-<?php echo $field->field_id . "-$count"; ?>" class="clonedOption">
191
+ <input type="radio" value="<?php echo esc_attr( $count ); ?>" name="field_default-<?php echo $field->field_id; ?>" <?php checked( $field->field_default, $count ); ?> />
192
+ <input type="text" value="<?php echo stripslashes( esc_attr( $options ) ); ?>" name="field_options-<?php echo $field->field_id; ?>[]" class="widefat" id="edit-form-item-options-<?php echo $field->field_id . "-$count"; ?>" />
193
+ </label>
194
+
195
+ <a href="#" class="deleteOption vfb-interface-icon vfb-interface-minus" title="Delete Option">
196
+ <?php _e( 'Delete', 'visual-form-builder' ); ?>
197
+ </a>
198
+ <span class="vfb-interface-icon vfb-interface-sort" title="<?php esc_attr_e( 'Drag and Drop to Sort Options', 'visual-form-builder' ); ?>"></span>
199
+ </div>
200
+ <?php
201
+ $count++;
202
+ endforeach;
203
+ ?>
204
+
205
+ </div> <!-- .vfb-cloned-options -->
206
+ <div class="clear"></div>
207
+ <div class="vfb-add-options-group">
208
+ <a href="#" class="vfb-button vfb-add-option" title="Add Option">
209
+ <?php _e( 'Add Option', 'visual-form-builder' ); ?>
210
+ <span class="vfb-interface-icon vfb-interface-plus"></span>
211
+ </a>
212
+ </div>
213
+ </p>
214
+ <?php
215
+ // Unset the options for any following radio, checkboxes, or selects
216
+ unset( $opts_vals );
217
+ endif;
218
+ ?>
219
+
220
+ <?php if ( in_array( $field->field_type, array( 'file-upload' ) ) ) : ?>
221
+ <!-- File Upload Accepts -->
222
+ <p class="description description-wide">
223
+ <?php
224
+ $opts_vals = array( '' );
225
+
226
+ // If the options field isn't empty, unserialize and build array
227
+ if ( !empty( $field->field_options ) ) {
228
+ if ( is_serialized( $field->field_options ) )
229
+ $opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : unserialize( $field->field_options );
230
+ }
231
+
232
+ // Loop through the options
233
+ foreach ( $opts_vals as $options ) {
234
+ ?>
235
+ <label for="edit-form-item-options-<?php echo $field->field_id; ?>">
236
+ <?php _e( 'Accepted File Extensions' , 'visual-form-builder'); ?>
237
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Accepted File Extensions', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Control the types of files allowed. Enter extensions without periods and separate multiples using the pipe character ( | ).', 'visual-form-builder' ); ?>">(?)</span>
238
+ <br />
239
+ <input type="text" value="<?php echo stripslashes( esc_attr( $options ) ); ?>" name="field_options-<?php echo $field->field_id; ?>[]" class="widefat" id="edit-form-item-options-<?php echo $field->field_id; ?>" />
240
+ </label>
241
+ </p>
242
+ <?php
243
+ }
244
+ // Unset the options for any following radio, checkboxes, or selects
245
+ unset( $opts_vals );
246
+ endif;
247
+ ?>
248
+
249
+ <?php if ( in_array( $field->field_type, array( 'date' ) ) ) : ?>
250
+ <!-- Date Format -->
251
+ <p class="description description-wide">
252
+ <?php
253
+ $opts_vals = maybe_unserialize( $field->field_options );
254
+ $dateFormat = ( isset( $opts_vals['dateFormat'] ) ) ? $opts_vals['dateFormat'] : 'mm/dd/yy';
255
+ ?>
256
+ <label for="edit-form-item-date-dateFormat-<?php echo $field->field_id; ?>">
257
+ <?php _e( 'Date Format', 'visual-form-builder' ); ?>
258
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Date Format', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Set the date format for each date picker.', 'visual-form-builder' ); ?>">(?)</span>
259
+ <br />
260
+ <input type="text" value="<?php echo esc_attr( $dateFormat ); ?>" name="field_options-<?php echo $field->field_id; ?>[dateFormat]" class="widefat" id="edit-form-item-date-dateFormat-<?php echo $field->field_id; ?>" />
261
+ </label>
262
+ </p>
263
+ <?php
264
+ // Unset the options for any following radio, checkboxes, or selects
265
+ unset( $opts_vals );
266
+ endif;
267
+ ?>
268
+ <!-- Validation -->
269
+ <p class="description description-thin">
270
+ <label for="edit-form-item-validation">
271
+ <?php _e( 'Validation' , 'visual-form-builder'); ?>
272
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Validation', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Ensures user-entered data is formatted properly. For more information on Validation, refer to the Help tab at the top of this page.', 'visual-form-builder' ); ?>">(?)</span>
273
+ <br />
274
+
275
+ <?php if ( in_array( $field->field_type , array( 'text', 'time', 'number' ) ) ) : ?>
276
+ <select name="field_validation-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-validation-<?php echo $field->field_id; ?>">
277
+ <?php if ( $field->field_type == 'time' ) : ?>
278
+ <option value="time-12" <?php selected( $field->field_validation, 'time-12' ); ?>><?php _e( '12 Hour Format' , 'visual-form-builder'); ?></option>
279
+ <option value="time-24" <?php selected( $field->field_validation, 'time-24' ); ?>><?php _e( '24 Hour Format' , 'visual-form-builder'); ?></option>
280
+ <?php elseif ( in_array( $field->field_type, array( 'number' ) ) ) : ?>
281
+ <option value="number" <?php selected( $field->field_validation, 'number' ); ?>><?php _e( 'Number' , 'visual-form-builder'); ?></option>
282
+ <option value="digits" <?php selected( $field->field_validation, 'digits' ); ?>><?php _e( 'Digits' , 'visual-form-builder'); ?></option>
283
+ <?php else : ?>
284
+ <option value="" <?php selected( $field->field_validation, '' ); ?>><?php _e( 'None' , 'visual-form-builder'); ?></option>
285
+ <option value="email" <?php selected( $field->field_validation, 'email' ); ?>><?php _e( 'Email' , 'visual-form-builder'); ?></option>
286
+ <option value="url" <?php selected( $field->field_validation, 'url' ); ?>><?php _e( 'URL' , 'visual-form-builder'); ?></option>
287
+ <option value="date" <?php selected( $field->field_validation, 'date' ); ?>><?php _e( 'Date' , 'visual-form-builder'); ?></option>
288
+ <option value="number" <?php selected( $field->field_validation, 'number' ); ?>><?php _e( 'Number' , 'visual-form-builder'); ?></option>
289
+ <option value="digits" <?php selected( $field->field_validation, 'digits' ); ?>><?php _e( 'Digits' , 'visual-form-builder'); ?></option>
290
+ <option value="phone" <?php selected( $field->field_validation, 'phone' ); ?>><?php _e( 'Phone' , 'visual-form-builder'); ?></option>
291
+ <?php endif; ?>
292
+ </select>
293
+ <?php else :
294
+ $field_validation = '';
295
+
296
+ switch ( $field->field_type ) {
297
+ case 'email' :
298
+ case 'url' :
299
+ case 'phone' :
300
+ $field_validation = $field->field_type;
301
+ break;
302
+
303
+ case 'currency' :
304
+ $field_validation = 'number';
305
+ break;
306
+
307
+ case 'number' :
308
+ $field_validation = 'digits';
309
+ break;
310
+ }
311
+
312
+ ?>
313
+ <input type="text" class="widefat" name="field_validation-<?php echo $field->field_id; ?>" value="<?php echo $field_validation; ?>" readonly="readonly" />
314
+ <?php endif; ?>
315
+
316
+ </label>
317
+ </p>
318
+
319
+ <!-- Required -->
320
+ <p class="field-link-target description description-thin">
321
+ <label for="edit-form-item-required">
322
+ <?php _e( 'Required' , 'visual-form-builder'); ?>
323
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Required', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Requires the field to be completed before the form is submitted. By default, all fields are set to No.', 'visual-form-builder' ); ?>">(?)</span>
324
+ <br />
325
+ <select name="field_required-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-required-<?php echo $field->field_id; ?>">
326
+ <option value="no" <?php selected( $field->field_required, 'no' ); ?>><?php _e( 'No' , 'visual-form-builder'); ?></option>
327
+ <option value="yes" <?php selected( $field->field_required, 'yes' ); ?>><?php _e( 'Yes' , 'visual-form-builder'); ?></option>
328
+ </select>
329
+ </label>
330
+ </p>
331
+
332
+ <?php if ( !in_array( $field->field_type, array( 'radio', 'checkbox', 'time' ) ) ) : ?>
333
+ <!-- Size -->
334
+ <p class="description description-thin">
335
+ <label for="edit-form-item-size">
336
+ <?php _e( 'Size' , 'visual-form-builder'); ?>
337
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Size', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Control the size of the field. By default, all fields are set to Medium.', 'visual-form-builder' ); ?>">(?)</span>
338
+ <br />
339
+ <select name="field_size-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-size-<?php echo $field->field_id; ?>">
340
+ <option value="small" <?php selected( $field->field_size, 'small' ); ?>><?php _e( 'Small' , 'visual-form-builder'); ?></option>
341
+ <option value="medium" <?php selected( $field->field_size, 'medium' ); ?>><?php _e( 'Medium' , 'visual-form-builder'); ?></option>
342
+ <option value="large" <?php selected( $field->field_size, 'large' ); ?>><?php _e( 'Large' , 'visual-form-builder'); ?></option>
343
+ </select>
344
+ </label>
345
+ </p>
346
+
347
+ <?php elseif ( in_array( $field->field_type, array( 'radio', 'checkbox', 'time' ) ) ) : ?>
348
+ <!-- Options Layout -->
349
+ <p class="description description-thin">
350
+ <label for="edit-form-item-size">
351
+ <?php _e( 'Options Layout' , 'visual-form-builder'); ?>
352
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Options Layout', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Control the layout of radio buttons or checkboxes. By default, options are arranged in One Column.', 'visual-form-builder' ); ?>">(?)</span>
353
+ <br />
354
+ <select name="field_size-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-size-<?php echo $field->field_id; ?>"<?php echo ( $field->field_type == 'time' ) ? ' disabled="disabled"' : ''; ?>>
355
+ <option value="" <?php selected( $field->field_size, '' ); ?>><?php _e( 'One Column' , 'visual-form-builder'); ?></option>
356
+ <option value="two-column" <?php selected( $field->field_size, 'two-column' ); ?>><?php _e( 'Two Columns' , 'visual-form-builder'); ?></option>
357
+ <option value="three-column" <?php selected( $field->field_size, 'three-column' ); ?>><?php _e( 'Three Columns' , 'visual-form-builder'); ?></option>
358
+ <option value="auto-column" <?php selected( $field->field_size, 'auto-column' ); ?>><?php _e( 'Auto Width' , 'visual-form-builder'); ?></option>
359
+ </select>
360
+ </label>
361
+ </p>
362
+
363
+ <?php endif; ?>
364
+ <!-- Field Layout -->
365
+ <p class="description description-thin">
366
+ <label for="edit-form-item-layout">
367
+ <?php _e( 'Field Layout' , 'visual-form-builder'); ?>
368
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Field Layout', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Used to create advanced layouts. Align fields side by side in various configurations.', 'visual-form-builder' ); ?>">(?)</span>
369
+ <br />
370
+ <select name="field_layout-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-layout-<?php echo $field->field_id; ?>">
371
+
372
+ <option value="" <?php selected( $field->field_layout, '' ); ?>><?php _e( 'Default' , 'visual-form-builder'); ?></option>
373
+ <optgroup label="------------">
374
+ <option value="left-half" <?php selected( $field->field_layout, 'left-half' ); ?>><?php _e( 'Left Half' , 'visual-form-builder'); ?></option>
375
+ <option value="right-half" <?php selected( $field->field_layout, 'right-half' ); ?>><?php _e( 'Right Half' , 'visual-form-builder'); ?></option>
376
+ </optgroup>
377
+ <optgroup label="------------">
378
+ <option value="left-third" <?php selected( $field->field_layout, 'left-third' ); ?>><?php _e( 'Left Third' , 'visual-form-builder'); ?></option>
379
+ <option value="middle-third" <?php selected( $field->field_layout, 'middle-third' ); ?>><?php _e( 'Middle Third' , 'visual-form-builder'); ?></option>
380
+ <option value="right-third" <?php selected( $field->field_layout, 'right-third' ); ?>><?php _e( 'Right Third' , 'visual-form-builder'); ?></option>
381
+ </optgroup>
382
+ <optgroup label="------------">
383
+ <option value="left-two-thirds" <?php selected( $field->field_layout, 'left-two-thirds' ); ?>><?php _e( 'Left Two Thirds' , 'visual-form-builder'); ?></option>
384
+ <option value="right-two-thirds" <?php selected( $field->field_layout, 'right-two-thirds' ); ?>><?php _e( 'Right Two Thirds' , 'visual-form-builder'); ?></option>
385
+ </optgroup>
386
+ </select>
387
+ </label>
388
+ </p>
389
+ <?php if ( !in_array( $field->field_type, array( 'radio', 'select', 'checkbox', 'time', 'address' ) ) ) : ?>
390
+ <!-- Default Value -->
391
+ <p class="description description-wide">
392
+ <label for="edit-form-item-default-<?php echo $field->field_id; ?>">
393
+ <?php _e( 'Default Value' , 'visual-form-builder'); ?>
394
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Default Value', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Set a default value that will be inserted automatically.', 'visual-form-builder' ); ?>">(?)</span>
395
+ <br />
396
+ <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_default ) ); ?>" name="field_default-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-default-<?php echo $field->field_id; ?>" maxlength="255" />
397
+ </label>
398
+ </p>
399
+ <?php elseif( in_array( $field->field_type, array( 'address' ) ) ) : ?>
400
+ <!-- Default Country -->
401
+ <p class="description description-wide">
402
+ <label for="edit-form-item-default-<?php echo $field->field_id; ?>">
403
+ <?php _e( 'Default Country' , 'visual-form-builder'); ?>
404
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Default Country', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Select the country you would like to be displayed by default.', 'visual-form-builder' ); ?>">(?)</span>
405
+ <br />
406
+ <select name="field_default-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-default-<?php echo $field->field_id; ?>">
407
+ <?php
408
+ foreach ( $this->countries as $country ) {
409
+ echo '<option value="' . $country . '" ' . selected( $field->field_default, $country, 0 ) . '>' . $country . '</option>';
410
+ }
411
+ ?>
412
+ </select>
413
+ </label>
414
+ </p>
415
+ <?php endif; ?>
416
+ <!-- CSS Classes -->
417
+ <p class="description description-wide">
418
+ <label for="edit-form-item-css-<?php echo $field->field_id; ?>">
419
+ <?php _e( 'CSS Classes' , 'visual-form-builder'); ?>
420
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About CSS Classes', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'For each field, you can insert your own CSS class names which can be used in your own stylesheets.', 'visual-form-builder' ); ?>">(?)</span>
421
+ <br />
422
+ <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" maxlength="255" />
423
+ </label>
424
+ </p>
425
+
426
+ <?php endif; ?>
427
+ <?php endif; ?>
428
+
429
+ <?php if ( !in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) : ?>
430
+ <!-- Delete link -->
431
+ <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="vfb-button vfb-delete item-delete submitdelete deletion">
432
+ <?php _e( 'Delete' , 'visual-form-builder'); ?>
433
+ <span class="vfb-interface-icon vfb-interface-trash"></span>
434
+ </a>
435
+ <?php endif; ?>
436
+
437
+ <input type="hidden" name="field_id[<?php echo $field->field_id; ?>]" value="<?php echo $field->field_id; ?>" />
438
+ </div>
439
+ <?php
440
+ endforeach;
441
+
442
+ // This assures all of the <ul> and <li> are closed
443
+ if ( $depth > 1 ) {
444
+ while( $depth > 1 ) {
445
+ echo '</li>
446
+ </ul>';
447
+ $depth--;
448
+ }
449
+ }
450
+
451
+ // Close out last item
452
+ echo '</li>';
453
+ echo ob_get_clean();
454
+ }
455
+ }
admin/class-forms-edit.php ADDED
@@ -0,0 +1,449 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class that controls the Edit Form view
4
+ *
5
+ */
6
+ class Visual_Form_Builder_Forms_Edit {
7
+ /**
8
+ * display function.
9
+ *
10
+ * @access public
11
+ * @return void
12
+ */
13
+ public function display() {
14
+ global $wpdb;
15
+
16
+ $current_user = wp_get_current_user();
17
+
18
+ // Save current user ID
19
+ $user_id = $current_user instanceof WP_User ? $current_user->ID : 1;
20
+
21
+ // Set variables depending on which tab is selected
22
+ $form_nav_selected_id = isset( $_GET['form'] ) ? $_GET['form'] : '0';
23
+
24
+ $order = sanitize_sql_orderby( 'form_id DESC' );
25
+ $form = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE form_id = %d ORDER BY $order", $form_nav_selected_id ) );
26
+
27
+ if ( !$form || $form->form_id !== $form_nav_selected_id )
28
+ wp_die( 'You must select a form' );
29
+
30
+ $form_id = $form->form_id;
31
+ $form_title = stripslashes( $form->form_title );
32
+ $form_subject = stripslashes( $form->form_email_subject );
33
+ $form_email_from_name = stripslashes( $form->form_email_from_name );
34
+ $form_email_from = stripslashes( $form->form_email_from);
35
+ $form_email_from_override = stripslashes( $form->form_email_from_override);
36
+ $form_email_from_name_override = stripslashes( $form->form_email_from_name_override);
37
+ $form_email_to = ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) );
38
+ $form_success_type = stripslashes( $form->form_success_type );
39
+ $form_success_message = stripslashes( $form->form_success_message );
40
+ $form_notification_setting = stripslashes( $form->form_notification_setting );
41
+ $form_notification_email_name = stripslashes( $form->form_notification_email_name );
42
+ $form_notification_email_from = stripslashes( $form->form_notification_email_from );
43
+ $form_notification_email = stripslashes( $form->form_notification_email );
44
+ $form_notification_subject = stripslashes( $form->form_notification_subject );
45
+ $form_notification_message = stripslashes( $form->form_notification_message );
46
+ $form_notification_entry = stripslashes( $form->form_notification_entry );
47
+
48
+ $form_label_alignment = stripslashes( $form->form_label_alignment );
49
+
50
+ // Only show required text fields for the sender name override
51
+ $senders = $wpdb->get_results( $wpdb->prepare( "SELECT field_id, field_name FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE form_id = %d AND field_type IN( 'text', 'name' ) AND field_validation = '' AND field_required = 'yes'", $form_nav_selected_id ) );
52
+
53
+ // Only show required email fields for the email override
54
+ $emails = $wpdb->get_results( $wpdb->prepare( "SELECT field_id, field_name FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE (form_id = %d AND field_type='text' AND field_validation = 'email' AND field_required = 'yes') OR (form_id = %d AND field_type='email' AND field_validation = 'email' AND field_required = 'yes')", $form_nav_selected_id, $form_nav_selected_id ) );
55
+
56
+ $screen = get_current_screen();
57
+ $class = 'columns-' . get_current_screen()->get_columns();
58
+ ?>
59
+ <div class="wrap">
60
+ <h1>
61
+ <?php
62
+ _e( 'Visual Form Builder', 'visual-form-builder' );
63
+
64
+ // Add New link
65
+ echo sprintf(
66
+ ' <a href="%1$s" class="page-title-action">%2$s</a>',
67
+ esc_url( admin_url( 'admin.php?page=vfb-add-new' ) ),
68
+ esc_html( __( 'Add New', 'visual-form-builder' ) )
69
+ );
70
+
71
+ // If searched, output the query
72
+ if ( isset( $_POST['s'] ) && !empty( $_POST['s'] ) )
73
+ echo '<span class="subtitle">' . sprintf( __( 'Search results for "%s"' , 'visual-form-builder'), esc_html( $_POST['s'] ) );
74
+
75
+ $form_nav_selected_id = isset( $_GET['form'] ) ? $_GET['form'] : '0';
76
+ ?>
77
+ </h1>
78
+ <div id="vfb-form-builder-frame" class="metabox-holder <?php echo $class; ?>">
79
+ <div id="vfb-postbox-container-1" class='vfb-postbox-container'>
80
+ <form id="form-items" class="nav-menu-meta" method="post" action="">
81
+ <input name="action" type="hidden" value="create_field" />
82
+ <input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
83
+ <?php
84
+ wp_nonce_field( 'create-field-' . $form_nav_selected_id );
85
+ do_meta_boxes( 'visual-form-builder', 'side', null );
86
+ ?>
87
+ </form>
88
+ </div> <!-- .vfb-postbox-container -->
89
+
90
+ <div id="vfb-postbox-container-2" class='vfb-postbox-container'>
91
+ <div id="vfb-form-builder-main">
92
+ <div id="vfb-form-builder-management">
93
+ <div class="form-edit">
94
+ <form method="post" id="visual-form-builder-update" action="">
95
+ <input name="action" type="hidden" value="update_form" />
96
+ <input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
97
+ <?php wp_nonce_field( 'vfb_update_form' ); ?>
98
+ <div id="form-editor-header">
99
+ <div id="submitpost" class="submitbox">
100
+ <div class="vfb-major-publishing-actions">
101
+ <label for="form-name" class="menu-name-label howto open-label">
102
+ <span class="sender-labels"><?php _e( 'Form Name' , 'visual-form-builder'); ?></span>
103
+ <input type="text" value="<?php echo ( isset( $form_title ) ) ? $form_title : ''; ?>" placeholder="<?php _e( 'Enter form name here' , 'visual-form-builder'); ?>" class="menu-name regular-text menu-item-textbox required" id="form-name" name="form_title" />
104
+ </label>
105
+ <br class="clear" />
106
+
107
+ <?php
108
+ // Get the Form Setting drop down and accordion settings, if any
109
+ $user_form_settings = get_user_meta( $user_id, 'vfb-form-settings' );
110
+
111
+ // Setup defaults for the Form Setting tab and accordion
112
+ $settings_tab = 'closed';
113
+ $settings_accordion = 'general-settings';
114
+
115
+ // Loop through the user_meta array
116
+ foreach( $user_form_settings as $set ) :
117
+ // If form settings exist for this form, use them instead of the defaults
118
+ if ( isset( $set[ $form_id ] ) ) :
119
+ $settings_tab = $set[ $form_id ]['form_setting_tab'];
120
+ $settings_accordion = $set[ $form_id ]['setting_accordion'];
121
+ endif;
122
+ endforeach;
123
+
124
+ // If tab is opened, set current class
125
+ $opened_tab = ( $settings_tab == 'opened' ) ? 'current' : '';
126
+ ?>
127
+
128
+
129
+ <div class="vfb-button-group">
130
+ <a href="#form-settings" id="form-settings-button" class="vfb-button vfb-settings <?php echo $opened_tab; ?>">
131
+ <?php _e( 'Settings' , 'visual-form-builder'); ?>
132
+ <span class="vfb-interface-icon vfb-interface-settings"></span>
133
+ </a>
134
+ <a href="<?php echo esc_url( wp_nonce_url( admin_url('admin.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">
135
+ <?php _e( 'Duplicate' , 'visual-form-builder'); ?>
136
+ <span class="vfb-interface-icon vfb-interface-duplicate"></span>
137
+ </a>
138
+ <a href="<?php echo esc_url( wp_nonce_url( admin_url('admin.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">
139
+ <?php _e( 'Delete' , 'visual-form-builder'); ?>
140
+ <span class="vfb-interface-icon vfb-interface-trash"></span>
141
+ </a>
142
+
143
+ <?php submit_button( __( 'Save', 'visual-form-builder' ), 'primary', 'save_form', false ); ?>
144
+ </div>
145
+
146
+ <div id="form-settings" class="<?php echo $opened_tab; ?>">
147
+ <!-- General settings section -->
148
+ <a href="#general-settings" class="settings-links<?php echo ( $settings_accordion == 'general-settings' ) ? ' on' : ''; ?>"><?php _e( 'General', 'visual-form-builder' ); ?><span class="vfb-large-arrow"></span></a>
149
+ <div id="general-settings" class="form-details<?php echo ( $settings_accordion == 'general-settings' ) ? ' on' : ''; ?>">
150
+ <!-- Label Alignment -->
151
+ <p class="description description-wide">
152
+ <label for="form-label-alignment">
153
+ <?php _e( 'Label Alignment' , 'visual-form-builder'); ?>
154
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Label Alignment', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( '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>
155
+ <br />
156
+ </label>
157
+ <select name="form_label_alignment" id="form-label-alignment" class="widefat">
158
+ <option value="" <?php selected( $form_label_alignment, '' ); ?>><?php _e( 'Top Aligned' , 'visual-form-builder'); ?></option>
159
+ <option value="left-label" <?php selected( $form_label_alignment, 'left-label' ); ?>><?php _e( 'Left Aligned' , 'visual-form-builder'); ?></option>
160
+ <option value="right-label" <?php selected( $form_label_alignment, 'right-label' ); ?>><?php _e( 'Right Aligned' , 'visual-form-builder'); ?></option>
161
+ </select>
162
+ </p>
163
+ <br class="clear" />
164
+ </div> <!-- #general-settings -->
165
+
166
+
167
+ <!-- Email section -->
168
+ <a href="#email-details" class="settings-links<?php echo ( $settings_accordion == 'email-details' ) ? ' on' : ''; ?>"><?php _e( 'Email', 'visual-form-builder' ); ?><span class="vfb-large-arrow"></span></a>
169
+ <div id="email-details" class="form-details<?php echo ( $settings_accordion == 'email-details' ) ? ' on' : ''; ?>">
170
+
171
+ <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>
172
+
173
+ <!-- E-mail Subject -->
174
+ <p class="description description-wide">
175
+ <label for="form-email-subject">
176
+ <?php _e( 'E-mail Subject' , 'visual-form-builder'); ?>
177
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About E-mail Subject', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'This option sets the subject of the email that is sent to the emails you have set in the E-mail(s) To field.', 'visual-form-builder' ); ?>">(?)</span>
178
+ <br />
179
+ <input type="text" value="<?php echo stripslashes( $form_subject ); ?>" class="widefat" id="form-email-subject" name="form_email_subject" />
180
+ </label>
181
+ </p>
182
+ <br class="clear" />
183
+
184
+ <!-- Sender Name -->
185
+ <p class="description description-thin">
186
+ <label for="form-email-sender-name">
187
+ <?php _e( 'Your Name or Company' , 'visual-form-builder'); ?>
188
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Your Name or Company', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( '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.', 'visual-form-builder' ); ?>">(?)</span>
189
+ <br />
190
+ <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"' : ''; ?> />
191
+ </label>
192
+ </p>
193
+ <p class="description description-thin">
194
+ <label for="form_email_from_name_override">
195
+ <?php _e( "User's Name (optional)" , 'visual-form-builder'); ?>
196
+ <span class="vfb-tooltip" title="<?php esc_attr_e( "About User's Name", 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Select a required text field from your form to use as the From display name in the email.', 'visual-form-builder' ); ?>">(?)</span>
197
+ <br />
198
+ <?php if ( empty( $senders ) ) : ?>
199
+ <span><?php _e( 'No required text fields detected', 'visual-form-builder' ); ?></span>
200
+ <?php else : ?>
201
+ <select name="form_email_from_name_override" id="form_email_from_name_override" class="widefat">
202
+ <option value="" <?php selected( $form_email_from_name_override, '' ); ?>></option>
203
+ <?php
204
+ foreach( $senders as $sender ) {
205
+ echo sprintf( '<option value="%1$d"%2$s>%3$s</option>',
206
+ $sender->field_id,
207
+ selected( $form_email_from_name_override, $sender->field_id, 0 ),
208
+ stripslashes( $sender->field_name )
209
+ );
210
+ }
211
+ ?>
212
+ </select>
213
+ <?php endif; ?>
214
+ </label>
215
+ </p>
216
+ <br class="clear" />
217
+
218
+ <!-- Sender E-mail -->
219
+ <p class="description description-thin">
220
+ <label for="form-email-sender">
221
+ <?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?>
222
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Reply-To Email', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Manually set the email address that users will reply to.', 'visual-form-builder' ); ?>">(?)</span>
223
+ <br />
224
+ <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"' : ''; ?> />
225
+ </label>
226
+ </p>
227
+ <p class="description description-thin">
228
+ <label for="form_email_from_override">
229
+ <?php _e( "User's E-mail (optional)" , 'visual-form-builder'); ?>
230
+ <span class="vfb-tooltip" title="<?php esc_attr_e( "About User's Email", 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Select a required email field from your form to use as the Reply-To email.', 'visual-form-builder' ); ?>">(?)</span>
231
+ <br />
232
+ <?php if ( empty( $emails ) ) : ?>
233
+ <span><?php _e( 'No required email fields detected', 'visual-form-builder' ); ?></span>
234
+ <?php else : ?>
235
+ <select name="form_email_from_override" id="form_email_from_override" class="widefat">
236
+ <option value="" <?php selected( $form_email_from_override, '' ); ?>></option>
237
+ <?php
238
+ foreach( $emails as $email ) {
239
+ echo sprintf( '<option value="%1$d"%2$s>%3$s</option>',
240
+ $email->field_id,
241
+ selected( $form_email_from_override, $email->field_id, 0 ),
242
+ stripslashes( $email->field_name )
243
+ );
244
+ }
245
+ ?>
246
+ </select>
247
+ <?php endif; ?>
248
+ </label>
249
+ </p>
250
+ <br class="clear" />
251
+
252
+ <!-- E-mail(s) To -->
253
+ <?php
254
+ // Basic count to keep track of multiple options
255
+ $count = 1;
256
+
257
+ // Loop through the options
258
+ foreach ( $form_email_to as $email_to ) :
259
+ ?>
260
+ <div id="clone-email-<?php echo $count; ?>" class="option">
261
+ <p class="description description-wide">
262
+ <label for="form-email-to-<?php echo "$count"; ?>" class="clonedOption">
263
+ <?php _e( 'E-mail(s) To' , 'visual-form-builder'); ?>
264
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About E-mail(s) To', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'This option sets single or multiple emails to send the submitted form data to. At least one email is required.', 'visual-form-builder' ); ?>">(?)</span>
265
+ <br />
266
+ <input type="text" value="<?php echo stripslashes( $email_to ); ?>" name="form_email_to[]" class="widefat" id="form-email-to-<?php echo "$count"; ?>" />
267
+ </label>
268
+
269
+ <a href="#" class="addEmail vfb-interface-icon vfb-interface-plus" title="<?php esc_attr_e( 'Add an Email', 'visua-form-builder' ); ?>">
270
+ <?php _e( 'Add', 'visual-form-builder' ); ?>
271
+ </a>
272
+ <a href="#" class="deleteEmail vfb-interface-icon vfb-interface-minus" title="<?php esc_attr_e( 'Delete Email', 'visual-form-builder' ); ?>">
273
+ <?php _e( 'Delete', 'visual-form-builder' ); ?>
274
+ </a>
275
+
276
+ </p>
277
+ <br class="clear" />
278
+ </div>
279
+ <?php
280
+ $count++;
281
+ endforeach;
282
+ ?>
283
+ <div class="clear"></div>
284
+ </div>
285
+
286
+ <!-- Confirmation section -->
287
+ <a href="#confirmation" class="settings-links<?php echo ( $settings_accordion == 'confirmation' ) ? ' on' : ''; ?>"><?php _e( 'Confirmation', 'visual-form-builder' ); ?><span class="vfb-large-arrow"></span></a>
288
+ <div id="confirmation-message" class="form-details<?php echo ( $settings_accordion == 'confirmation' ) ? ' on' : ''; ?>">
289
+ <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>
290
+ <label for="form-success-type-text" class="menu-name-label open-label">
291
+ <input type="radio" value="text" id="form-success-type-text" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'text' ); ?> />
292
+ <span><?php _e( 'Text' , 'visual-form-builder'); ?></span>
293
+ </label>
294
+ <label for="form-success-type-page" class="menu-name-label open-label">
295
+ <input type="radio" value="page" id="form-success-type-page" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'page' ); ?>/>
296
+ <span><?php _e( 'Page' , 'visual-form-builder'); ?></span>
297
+ </label>
298
+ <label for="form-success-type-redirect" class="menu-name-label open-label">
299
+ <input type="radio" value="redirect" id="form-success-type-redirect" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'redirect' ); ?>/>
300
+ <span><?php _e( 'Redirect' , 'visual-form-builder'); ?></span>
301
+ </label>
302
+ <br class="clear" />
303
+ <p class="description description-wide">
304
+ <?php
305
+ $default_text = '';
306
+
307
+ /* If there's no text message, make sure there is something displayed by setting a default */
308
+ if ( $form_success_message === '' )
309
+ $default_text = sprintf( '<p id="form_success">%s</p>', __( 'Your form was successfully submitted. Thank you for contacting us.' , 'visual-form-builder') );
310
+ ?>
311
+ <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>
312
+
313
+ <?php
314
+ /* Display all Pages */
315
+ wp_dropdown_pages( array(
316
+ 'name' => 'form_success_message_page',
317
+ 'id' => 'form-success-message-page',
318
+ 'class' => 'widefat',
319
+ 'show_option_none' => __( 'Select a Page' , 'visual-form-builder'),
320
+ 'selected' => $form_success_message
321
+ ));
322
+ ?>
323
+ <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://" />
324
+ </p>
325
+ <br class="clear" />
326
+
327
+ </div>
328
+
329
+ <!-- Notification section -->
330
+ <a href="#notification" class="settings-links<?php echo ( $settings_accordion == 'notification' ) ? ' on' : ''; ?>"><?php _e( 'Notification', 'visual-form-builder' ); ?><span class="vfb-large-arrow"></span></a>
331
+ <div id="notification" class="form-details<?php echo ( $settings_accordion == 'notification' ) ? ' on' : ''; ?>">
332
+ <p><em><?php _e( "When a user submits their entry, you can send a customizable notification email." , 'visual-form-builder'); ?></em></p>
333
+ <label for="form-notification-setting">
334
+ <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;"/>
335
+ <?php _e( 'Send Confirmation Email to User' , 'visual-form-builder'); ?>
336
+ </label>
337
+ <br class="clear" />
338
+ <div id="notification-email">
339
+ <p class="description description-wide">
340
+ <label for="form-notification-email-name">
341
+ <?php _e( 'Sender Name or Company' , 'visual-form-builder'); ?>
342
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Sender Name or Company', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Enter the name you would like to use for the email notification.', 'visual-form-builder' ); ?>">(?)</span>
343
+ <br />
344
+ <input type="text" value="<?php echo $form_notification_email_name; ?>" class="widefat" id="form-notification-email-name" name="form_notification_email_name" />
345
+ </label>
346
+ </p>
347
+ <br class="clear" />
348
+ <p class="description description-wide">
349
+ <label for="form-notification-email-from">
350
+ <?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?>
351
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Reply-To Email', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Manually set the email address that users will reply to.', 'visual-form-builder' ); ?>">(?)</span>
352
+ <br />
353
+ <input type="text" value="<?php echo $form_notification_email_from; ?>" class="widefat" id="form-notification-email-from" name="form_notification_email_from" />
354
+ </label>
355
+ </p>
356
+ <br class="clear" />
357
+ <p class="description description-wide">
358
+ <label for="form-notification-email">
359
+ <?php _e( 'E-mail To' , 'visual-form-builder'); ?>
360
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About E-mail To', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Select a required email field from your form to send the notification email to.', 'visual-form-builder' ); ?>">(?)</span>
361
+ <br />
362
+ <?php if ( empty( $emails ) ) : ?>
363
+ <span><?php _e( 'No required email fields detected', 'visual-form-builder' ); ?></span>
364
+ <?php else : ?>
365
+ <select name="form_notification_email" id="form-notification-email" class="widefat">
366
+ <option value="" <?php selected( $form_notification_email, '' ); ?>></option>
367
+ <?php
368
+ foreach( $emails as $email ) {
369
+ echo sprintf( '<option value="%1$d"%2$s>%3$s</option>',
370
+ $email->field_id,
371
+ selected( $form_notification_email, $email->field_id, 0 ),
372
+ $email->field_name
373
+ );
374
+ }
375
+ ?>
376
+ </select>
377
+ <?php endif; ?>
378
+ </label>
379
+ </p>
380
+ <br class="clear" />
381
+ <p class="description description-wide">
382
+ <label for="form-notification-subject">
383
+ <?php _e( 'E-mail Subject' , 'visual-form-builder'); ?>
384
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About E-mail Subject', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'This option sets the subject of the email that is sent to the emails you have set in the E-mail To field.', 'visual-form-builder' ); ?>">(?)</span>
385
+ <br />
386
+ <input type="text" value="<?php echo $form_notification_subject; ?>" class="widefat" id="form-notification-subject" name="form_notification_subject" />
387
+ </label>
388
+ </p>
389
+ <br class="clear" />
390
+ <p class="description description-wide">
391
+ <label for="form-notification-message"><?php _e( 'Message' , 'visual-form-builder'); ?></label>
392
+ <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Message', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Insert a message to the user. This will be inserted into the beginning of the email body.', 'visual-form-builder' ); ?>">(?)</span>
393
+ <br />
394
+ <textarea id="form-notification-message" class="form-notification-message widefat" name="form_notification_message"><?php echo $form_notification_message; ?></textarea>
395
+ </p>
396
+ <br class="clear" />
397
+ <label for="form-notification-entry">
398
+ <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;"/>
399
+ <?php _e( "Include a Copy of the User's Entry" , 'visual-form-builder'); ?>
400
+ </label>
401
+ <br class="clear" />
402
+ </div>
403
+ </div>
404
+ </div>
405
+ </div>
406
+ </div>
407
+ </div>
408
+ <div id="post-body">
409
+ <div id="post-body-content">
410
+ <div id="vfb-fieldset-first-warning" class="error"><?php printf( '<p><strong>%1$s </strong><br>%2$s</p>', __( 'Warning &mdash; Missing Fieldset', 'visual-form-builder' ), __( 'Your form may not function or display correctly. Please be sure to add or move a Fieldset to the beginning of your form.' , 'visual-form-builder') ); ?></div>
411
+ <!-- !Field Items output -->
412
+ <ul id="vfb-menu-to-edit" class="menu ui-sortable droppable">
413
+ <?php echo $this->edit_field( $form_nav_selected_id ); ?>
414
+ </ul>
415
+ </div>
416
+ <br class="clear" />
417
+ </div>
418
+ <br class="clear" />
419
+ <div id="form-editor-footer">
420
+ <div class="vfb-major-publishing-actions">
421
+ <div class="publishing-action">
422
+ <?php submit_button( __( 'Save Form', 'visual-form-builder' ), 'primary', 'save_form', false ); ?>
423
+ </div> <!-- .publishing-action -->
424
+ </div> <!-- .vfb-major-publishing-actions -->
425
+ </div> <!-- #form-editor-footer -->
426
+ </form>
427
+ </div> <!-- .form-edit -->
428
+ </div> <!-- #vfb-form-builder-management -->
429
+ </div> <!-- vfb-form-builder-main -->
430
+ </div> <!-- .vfb-postbox-container -->
431
+ </div> <!-- #vfb-form-builder-frame -->
432
+ </div> <!-- .wrap -->
433
+ <?php
434
+ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
435
+ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
436
+ }
437
+
438
+ /**
439
+ * A wrapper function to output the Edit Field box
440
+ *
441
+ * @access public
442
+ * @param mixed $id
443
+ * @return void
444
+ */
445
+ public function edit_field( $id ) {
446
+ $field = new Visual_Form_Builder_Admin_Fields();
447
+ $field->field_output( $id );
448
+ }
449
+ }
{includes → admin}/class-forms-list.php RENAMED
@@ -4,31 +4,7 @@
4
  *
5
  * @since 1.2
6
  */
7
- class VisualFormBuilder_Forms_List extends WP_List_Table {
8
- /**
9
- * field_table_name
10
- *
11
- * @var mixed
12
- * @access public
13
- */
14
- public $field_table_name;
15
-
16
- /**
17
- * form_table_name
18
- *
19
- * @var mixed
20
- * @access public
21
- */
22
- public $form_table_name;
23
-
24
- /**
25
- * entries_table_name
26
- *
27
- * @var mixed
28
- * @access public
29
- */
30
- public $entries_table_name;
31
-
32
  /**
33
  * errors
34
  *
@@ -38,12 +14,7 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
38
  public $errors;
39
 
40
  function __construct(){
41
- global $status, $page, $wpdb;
42
-
43
- // Setup global database table names
44
- $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
45
- $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
46
- $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
47
 
48
  // Set parent defaults
49
  parent::__construct( array(
@@ -80,7 +51,7 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
80
  $actions = array();
81
 
82
  // Edit Form
83
- $form_title = sprintf( '<strong><a href="?page=%s&form=%s" id="%3$s" class="view-form">%s</a></strong>', $_GET['page'], $item['form_id'], $item['form_title'] );
84
  $actions['edit'] = sprintf( '<a href="?page=%s&action=%s&form=%s" id="%3$s" class="view-form">%s</a>', $_GET['page'], 'edit', $item['form_id'], __( 'Edit', 'visual-form-builder' ) );
85
 
86
  // Duplicate Form
@@ -92,17 +63,28 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
92
  return sprintf( '%1$s %2$s', $form_title, $this->row_actions( $actions ) );
93
  }
94
 
 
 
 
 
 
95
  function column_entries( $item ) {
96
  $this->comments_bubble( $item['form_id'], $item['entries'] );
97
  }
98
 
 
 
 
 
 
 
99
  function comments_bubble( $form_id, $count ) {
100
 
101
  echo sprintf(
102
  '<div class="entries-count-wrapper"><a href="%1$s" title="%2$s" class="vfb-meta-entries-total"><span class="entries-count">%4$s</span></a> %3$s</div>',
103
  esc_url( add_query_arg( array( 'form-filter' => $form_id ), admin_url( 'admin.php?page=vfb-entries' ) ) ),
104
- esc_attr__( 'Entries Total', 'visual-form-builder-pro' ),
105
- __( 'Total', 'visual-form-builder-pro' ),
106
  number_format_i18n( $count['total'] )
107
  );
108
 
@@ -112,8 +94,8 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
112
  echo sprintf(
113
  '<div class="entries-count-wrapper"><a href="%1$s" title="%2$s" class="vfb-meta-entries-total"><span class="entries-count">%4$s</span></a> %3$s</div>',
114
  esc_url( add_query_arg( array( 'form-filter' => $form_id, 'today' => 1 ), admin_url( 'admin.php?page=vfb-entries' ) ) ),
115
- esc_attr__( 'Entries Today', 'visual-form-builder-pro' ),
116
- __( 'Today', 'visual-form-builder-pro' ),
117
  number_format_i18n( $count['today'] )
118
  );
119
 
@@ -165,7 +147,7 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
165
  $where .= ' AND forms.form_id = ' . $this->current_filter_action();
166
 
167
  $sql_order = sanitize_sql_orderby( "$orderby $order" );
168
- $cols = $wpdb->get_results( "SELECT forms.form_id, forms.form_title FROM $this->form_table_name AS forms WHERE 1=1 $where $search ORDER BY $sql_order LIMIT $per_page $offset" );
169
 
170
  return $cols;
171
  }
@@ -217,7 +199,7 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
217
 
218
  $total_entries = array();
219
 
220
- $entries = $wpdb->get_results( "SELECT form_id, COUNT(form_id) as num_entries FROM $this->entries_table_name AS entries WHERE entries.entry_approved = 1 GROUP BY form_id", ARRAY_A );
221
 
222
  if ( $entries ) {
223
  foreach ( $entries as $entry )
@@ -240,7 +222,7 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
240
 
241
  $total_entries = array();
242
 
243
- $entries = $wpdb->get_results( "SELECT form_id, COUNT(form_id) as num_entries FROM $this->entries_table_name AS entries WHERE entries.entry_approved = 1 AND date_submitted >= curdate() GROUP BY form_id", ARRAY_A );
244
 
245
  if ( $entries ) {
246
  foreach ( $entries as $entry )
@@ -263,7 +245,7 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
263
 
264
  $stats = array();
265
 
266
- $count = $wpdb->get_var( "SELECT COUNT(*) FROM $this->form_table_name" );
267
 
268
  $stats['all'] = $count;
269
 
@@ -326,16 +308,16 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
326
  case 'trash' :
327
  foreach ( $form_id as $id ) {
328
  $id = absint( $id );
329
- $wpdb->update( $this->form_table_name, array( 'form_approved' => 'trash' ), array( 'form_id' => $id ) );
330
  }
331
  break;
332
 
333
  case 'delete' :
334
  foreach ( $form_id as $id ) {
335
  $id = absint( $id );
336
- $wpdb->query( $wpdb->prepare( "DELETE FROM $this->form_table_name WHERE form_id = %d", $id ) );
337
- $wpdb->query( $wpdb->prepare( "DELETE FROM $this->field_table_name WHERE form_id = %d", $id ) );
338
- $wpdb->query( $wpdb->prepare( "DELETE FROM $this->entries_table_name WHERE form_id = %d", $id ) );
339
  }
340
  break;
341
 
@@ -387,7 +369,7 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
387
 
388
  // get the default value if none is set
389
  if ( empty ( $per_page) || $per_page < 1 )
390
- $per_page = $screen->get_option( 'per_page', 'default' );
391
 
392
  // Get the date/time format that is saved in the options table
393
  $date_format = get_option( 'date_format' );
@@ -561,5 +543,4 @@ class VisualFormBuilder_Forms_List extends WP_List_Table {
561
 
562
  echo $this->_pagination;
563
  }
564
-
565
  }
4
  *
5
  * @since 1.2
6
  */
7
+ class Visual_Form_Builder_Forms_List extends Visual_Form_Builder_List_Table {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  /**
9
  * errors
10
  *
14
  public $errors;
15
 
16
  function __construct(){
17
+ global $status, $page;
 
 
 
 
 
18
 
19
  // Set parent defaults
20
  parent::__construct( array(
51
  $actions = array();
52
 
53
  // Edit Form
54
+ $form_title = sprintf( '<strong><a href="?page=%s&action=%s&form=%s" id="%3$s" class="view-form">%s</a></strong>', $_GET['page'], 'edit', $item['form_id'], $item['form_title'] );
55
  $actions['edit'] = sprintf( '<a href="?page=%s&action=%s&form=%s" id="%3$s" class="view-form">%s</a>', $_GET['page'], 'edit', $item['form_id'], __( 'Edit', 'visual-form-builder' ) );
56
 
57
  // Duplicate Form
63
  return sprintf( '%1$s %2$s', $form_title, $this->row_actions( $actions ) );
64
  }
65
 
66
+ /**
67
+ * [column_entries description]
68
+ * @param [type] $item [description]
69
+ * @return [type] [description]
70
+ */
71
  function column_entries( $item ) {
72
  $this->comments_bubble( $item['form_id'], $item['entries'] );
73
  }
74
 
75
+ /**
76
+ * [comments_bubble description]
77
+ * @param [type] $form_id [description]
78
+ * @param [type] $count [description]
79
+ * @return [type] [description]
80
+ */
81
  function comments_bubble( $form_id, $count ) {
82
 
83
  echo sprintf(
84
  '<div class="entries-count-wrapper"><a href="%1$s" title="%2$s" class="vfb-meta-entries-total"><span class="entries-count">%4$s</span></a> %3$s</div>',
85
  esc_url( add_query_arg( array( 'form-filter' => $form_id ), admin_url( 'admin.php?page=vfb-entries' ) ) ),
86
+ esc_attr__( 'Entries Total', 'visual-form-builder' ),
87
+ __( 'Total', 'visual-form-builder' ),
88
  number_format_i18n( $count['total'] )
89
  );
90
 
94
  echo sprintf(
95
  '<div class="entries-count-wrapper"><a href="%1$s" title="%2$s" class="vfb-meta-entries-total"><span class="entries-count">%4$s</span></a> %3$s</div>',
96
  esc_url( add_query_arg( array( 'form-filter' => $form_id, 'today' => 1 ), admin_url( 'admin.php?page=vfb-entries' ) ) ),
97
+ esc_attr__( 'Entries Today', 'visual-form-builder' ),
98
+ __( 'Today', 'visual-form-builder' ),
99
  number_format_i18n( $count['today'] )
100
  );
101
 
147
  $where .= ' AND forms.form_id = ' . $this->current_filter_action();
148
 
149
  $sql_order = sanitize_sql_orderby( "$orderby $order" );
150
+ $cols = $wpdb->get_results( "SELECT forms.form_id, forms.form_title FROM " . VFB_WP_FORMS_TABLE_NAME . " AS forms WHERE 1=1 $where $search ORDER BY $sql_order LIMIT $per_page $offset" );
151
 
152
  return $cols;
153
  }
199
 
200
  $total_entries = array();
201
 
202
+ $entries = $wpdb->get_results( "SELECT form_id, COUNT(form_id) as num_entries FROM " . VFB_WP_ENTRIES_TABLE_NAME . " AS entries WHERE entries.entry_approved = 1 GROUP BY form_id", ARRAY_A );
203
 
204
  if ( $entries ) {
205
  foreach ( $entries as $entry )
222
 
223
  $total_entries = array();
224
 
225
+ $entries = $wpdb->get_results( "SELECT form_id, COUNT(form_id) as num_entries FROM " . VFB_WP_ENTRIES_TABLE_NAME . " AS entries WHERE entries.entry_approved = 1 AND date_submitted >= curdate() GROUP BY form_id", ARRAY_A );
226
 
227
  if ( $entries ) {
228
  foreach ( $entries as $entry )
245
 
246
  $stats = array();
247
 
248
+ $count = $wpdb->get_var( "SELECT COUNT(*) FROM " . VFB_WP_FORMS_TABLE_NAME );
249
 
250
  $stats['all'] = $count;
251
 
308
  case 'trash' :
309
  foreach ( $form_id as $id ) {
310
  $id = absint( $id );
311
+ $wpdb->update( VFB_WP_FORMS_TABLE_NAME, array( 'form_approved' => 'trash' ), array( 'form_id' => $id ) );
312
  }
313
  break;
314
 
315
  case 'delete' :
316
  foreach ( $form_id as $id ) {
317
  $id = absint( $id );
318
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE form_id = %d", $id ) );
319
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE form_id = %d", $id ) );
320
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE form_id = %d", $id ) );
321
  }
322
  break;
323
 
369
 
370
  // get the default value if none is set
371
  if ( empty ( $per_page) || $per_page < 1 )
372
+ $per_page = 20;
373
 
374
  // Get the date/time format that is saved in the options table
375
  $date_format = get_option( 'date_format' );
543
 
544
  echo $this->_pagination;
545
  }
 
546
  }
admin/class-forms-metaboxes.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * [Visual_Form_Builder_Meta_Boxes description]
4
+ */
5
+ class Visual_Form_Builder_Meta_Boxes {
6
+ /**
7
+ * [add_meta_boxes description]
8
+ */
9
+ public function add_meta_boxes() {
10
+ add_meta_box( 'vfb_form_items_meta_box', __( 'Form Items', 'visual-form-builder' ), array( $this, 'form_items' ), 'visual-form-builder', 'side', 'high' );
11
+ add_meta_box( 'vfb_form_media_button_tip', __( 'Display Forms', 'visual-form-builder' ), array( $this, 'display_forms' ), 'visual-form-builder', 'side', 'low' );
12
+ }
13
+
14
+ /**
15
+ * [form_items description]
16
+ * @return [type] [description]
17
+ */
18
+ public function form_items() {
19
+ ?>
20
+ <div class="taxonomydiv">
21
+ <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>
22
+ <ul class="posttype-tabs add-menu-item-tabs" id="vfb-field-tabs">
23
+ <li class="tabs"><a href="#standard-fields" class="nav-tab-link vfb-field-types"><?php _e( 'Standard' , 'visual-form-builder'); ?></a></li>
24
+ </ul>
25
+ <div id="standard-fields" class="tabs-panel tabs-panel-active">
26
+ <ul class="vfb-fields-col-1">
27
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-fieldset">Fieldset</a></li>
28
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-text"><b></b>Text</a></li>
29
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-checkbox"><b></b>Checkbox</a></li>
30
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-select"><b></b>Select</a></li>
31
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-datepicker"><b></b>Date</a></li>
32
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-url"><b></b>URL</a></li>
33
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-digits"><b></b>Number</a></li>
34
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-phone"><b></b>Phone</a></li>
35
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-file"><b></b>File Upload</a></li>
36
+ </ul>
37
+ <ul class="vfb-fields-col-2">
38
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-section">Section</a></li>
39
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-textarea"><b></b>Textarea</a></li>
40
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-radio"><b></b>Radio</a></li>
41
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-address"><b></b>Address</a></li>
42
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-email"><b></b>Email</a></li>
43
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-currency"><b></b>Currency</a></li>
44
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-time"><b></b>Time</a></li>
45
+
46
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-html"><b></b>HTML</a></li>
47
+
48
+ <li><a href="#" class="vfb-draggable-form-items" id="form-element-instructions"><b></b>Instructions</a></li>
49
+ </ul>
50
+ <div class="clear"></div>
51
+ </div> <!-- #standard-fields -->
52
+ </div> <!-- .taxonomydiv -->
53
+ <div class="clear"></div>
54
+ <?php
55
+ }
56
+
57
+ /**
58
+ * [display_forms description]
59
+ * @return [type] [description]
60
+ */
61
+ public function display_forms() {
62
+ ?>
63
+ <p><?php _e( 'Add forms to your Posts or Pages by locating the <strong>Add Form</strong> button in the area above your post/page editor.', 'visual-form-builder' ); ?></p>
64
+ <p><?php _e( 'You may also manually insert the shortcode into a post/page.', 'visual-form-builder' ); ?></p>
65
+ <p>
66
+ <?php _e( 'Shortcode', 'visual-form-builder' ); ?>
67
+ <input value="[vfb id='<?php echo (int) $_GET['form']; ?>']" readonly="readonly" />
68
+ </p>
69
+ <?php
70
+ }
71
+ }
admin/class-forms-new.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class that controls the Add New Form view
4
+ *
5
+ */
6
+ class Visual_Form_Builder_Forms_New {
7
+
8
+ /**
9
+ * display function.
10
+ *
11
+ * @access public
12
+ * @return void
13
+ */
14
+ public function display() {
15
+ ?>
16
+ <form method="post" id="visual-form-builder-new-form" action="">
17
+ <input name="action" type="hidden" value="create_form" />
18
+ <?php
19
+ wp_nonce_field( 'create_form' );
20
+
21
+ if ( !current_user_can( 'manage_options' ) )
22
+ wp_die( __( 'You do not have sufficient permissions to create a new form.', 'visual-form-builder' ) );
23
+ ?>
24
+ <h3><?php _e( 'Create a form' , 'visual-form-builder'); ?></h3>
25
+
26
+ <table class="form-table">
27
+ <tbody>
28
+ <!-- Form Name -->
29
+ <tr valign="top">
30
+ <th scope="row"><label for="form-name"><?php _e( 'Name the form' , 'visual-form-builder'); ?></label></th>
31
+ <td>
32
+ <input type="text" autofocus="autofocus" class="regular-text required" id="form-name" name="form_title" />
33
+ <p class="description"><?php _e( 'Required. This name is used for admin purposes.' , 'visual-form-builder'); ?></p>
34
+ </td>
35
+ </tr>
36
+ <!-- Sender Name -->
37
+ <tr valign="top">
38
+ <th scope="row"><label for="form-email-sender-name"><?php _e( 'Your Name or Company' , 'visual-form-builder'); ?></label></th>
39
+ <td>
40
+ <input type="text" value="" placeholder="" class="regular-text required" id="form-email-sender-name" name="form_email_from_name" />
41
+ <p class="description"><?php _e( 'Required. This option sets the "From" display name of the email that is sent.' , 'visual-form-builder'); ?></p>
42
+ </td>
43
+ </tr>
44
+ <!-- Reply-to Email -->
45
+ <tr valign="top">
46
+ <th scope="row"><label for="form-email-from"><?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?></label></th>
47
+ <td>
48
+ <input type="text" value="" placeholder="" class="regular-text required" id="form-email-from" name="form_email_from" />
49
+ <p class="description"><?php _e( 'Required. Replies to your email will go here.' , 'visual-form-builder'); ?></p>
50
+ <p class="description"><?php _e( 'Tip: for best results, use an email that exists on this domain.' , 'visual-form-builder'); ?></p>
51
+ </td>
52
+ </tr>
53
+ <!-- Email Subject -->
54
+ <tr valign="top">
55
+ <th scope="row"><label for="form-email-subject"><?php _e( 'E-mail Subject' , 'visual-form-builder'); ?></label></th>
56
+ <td>
57
+ <input type="text" value="" placeholder="" class="regular-text" id="form-email-subject" name="form_email_subject" />
58
+ <p class="description"><?php _e( 'This sets the subject of the email that is sent.' , 'visual-form-builder'); ?></p>
59
+ </td>
60
+ </tr>
61
+ <!-- E-mail To -->
62
+ <tr valign="top">
63
+ <th scope="row"><label for="form-email-to"><?php _e( 'E-mail To' , 'visual-form-builder'); ?></label></th>
64
+ <td>
65
+ <input type="text" value="" placeholder="" class="regular-text" id="form-email-to" name="form_email_to[]" />
66
+ <p class="description"><?php _e( 'Who to send the submitted data to. You can add more after creating the form.' , 'visual-form-builder'); ?></p>
67
+ </td>
68
+ </tr>
69
+
70
+ </tbody>
71
+ </table>
72
+ <?php submit_button( __( 'Create Form', 'visual-form-builder' ) ); ?>
73
+ </form>
74
+ <?php
75
+ }
76
+ }
admin/class-load-css-js.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Loads all CSS and JS files that VFB needs
5
+ *
6
+ * This class should be called when the menu is added
7
+ * so the CSS and JS is added to ONLY our VFB pages.
8
+ *
9
+ */
10
+ class Visual_Form_Builder_Admin_Scripts_Loader {
11
+ /**
12
+ * Load CSS on VFB admin pages.
13
+ *
14
+ * Called from the Visual_Form_Builder_Admin_Menu class
15
+ *
16
+ * @access public
17
+ * @return void
18
+ */
19
+ public function add_css() {
20
+ wp_enqueue_style( 'visual-form-builder-style', VFB_WP_PLUGIN_URL . "admin/assets/css/visual-form-builder-admin.min.css", array(), '2018.01.23' );
21
+ }
22
+
23
+ /**
24
+ * Load JS on VFB admin pages
25
+ *
26
+ * Called from the Visual_Form_Builder_Admin_Menu class
27
+ *
28
+ * @access public
29
+ * @return void
30
+ */
31
+ public function add_js() {
32
+ wp_enqueue_script( 'jquery-ui-sortable' );
33
+ wp_enqueue_script( 'postbox' );
34
+ wp_enqueue_script( 'jquery-form-validation', VFB_WP_PLUGIN_URL . 'admin/assets/js/jquery.validate.min.js', array( 'jquery' ), '1.9.0', true );
35
+ wp_enqueue_script( 'vfb-admin', VFB_WP_PLUGIN_URL . 'admin/assets/js/vfb-admin.min.js', array( 'jquery', 'jquery-form-validation' ), '20140412', true );
36
+ wp_enqueue_script( 'nested-sortable', VFB_WP_PLUGIN_URL . 'admin/assets/js/jquery.ui.nestedSortable.min.js', array( 'jquery', 'jquery-ui-sortable' ), '1.3.5', true );
37
+ }
38
+ }
admin/class-media-button.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class that handles the Media Button display
4
+ *
5
+ */
6
+ class Visual_Form_Builder_Media_Button {
7
+ /**
8
+ * __construct function.
9
+ *
10
+ * @access public
11
+ * @return void
12
+ */
13
+ public function __construct() {
14
+ add_action( 'media_buttons', array( $this, 'add_button' ), 999 );
15
+ add_action( 'wp_ajax_vfb-media-button', array( $this, 'display' ) );
16
+ }
17
+
18
+ /**
19
+ * Add button above visual editor
20
+ *
21
+ * @access public
22
+ * @return void
23
+ */
24
+ public function add_button() {
25
+ // Check permission before display
26
+ if ( !current_user_can( 'manage_options' ) )
27
+ return;
28
+
29
+ $button_url = add_query_arg(
30
+ array(
31
+ 'page' => 'visual-form-builder',
32
+ 'action' => 'vfb-media-button',
33
+ 'width' => 600,
34
+ 'height' => 550,
35
+ ),
36
+ wp_nonce_url( admin_url( 'admin-ajax.php' ), 'vfb_media_button' )
37
+ );
38
+ ?>
39
+ <a href="<?php echo esc_url( $button_url ); ?>" class="button add_media thickbox" title="<?php _e( 'Add Visual Form Builder form', 'visual-form-builder' ); ?>">
40
+ <span class="dashicons dashicons-feedback" style="color:#888; display: inline-block; width: 18px; height: 18px; vertical-align: text-top; margin: 0 4px 0 0;"></span>
41
+ <?php _e( 'Add Form', 'visual-form-builder' ); ?>
42
+ </a>
43
+ <?php
44
+ }
45
+
46
+ /**
47
+ * Displays the form after add_button is clicked
48
+ *
49
+ * @access public
50
+ * @return void
51
+ */
52
+ public function display() {
53
+ global $wpdb;
54
+
55
+ check_admin_referer( 'vfb_media_button' );
56
+
57
+ // Sanitize the sql orderby
58
+ $order = sanitize_sql_orderby( 'form_id ASC' );
59
+
60
+ // Build our forms as an object
61
+ $forms = $wpdb->get_results( "SELECT form_id, form_title FROM " . VFB_WP_FORMS_TABLE_NAME . " ORDER BY $order" );
62
+
63
+ ?>
64
+ <script type="text/javascript">
65
+ jQuery(document).ready(function($) {
66
+ $( '#add_vfb_form' ).submit(function(e){
67
+ e.preventDefault();
68
+
69
+ window.send_to_editor( '[vfb id=' + $( '#vfb_forms' ).val() + ']' );
70
+
71
+ window.tb_remove();
72
+ });
73
+ });
74
+ </script>
75
+ <div>
76
+ <form id="add_vfb_form" class="media-upload-form type-form validate">
77
+ <h3><?php _e( 'Insert Visual Form Builder form', 'visual-form-builder' ); ?></h3>
78
+ <p><?php _e( 'Select a form below to insert into any Post or Page.', 'visual-form-builder' ); ?></p>
79
+ <select id="vfb_forms" name="vfb_forms">
80
+ <?php foreach( $forms as $form ) : ?>
81
+ <option value="<?php echo $form->form_id; ?>"><?php echo $form->form_title; ?></option>
82
+ <?php endforeach; ?>
83
+ </select>
84
+ <?php
85
+ submit_button(
86
+ __( 'Add Form', 'visual-form-builder' ),
87
+ 'primary',
88
+ '' // leave blank so "name" attribute will not be added
89
+ );
90
+ ?>
91
+ </form>
92
+ </div>
93
+ <?php
94
+ die(1);
95
+ }
96
+ }
admin/class-page-settings.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class that controls the Settings page view
5
+ *
6
+ */
7
+ class Visual_Form_Builder_Page_Settings {
8
+ /**
9
+ * [display description]
10
+ * @return [type] [description]
11
+ */
12
+ public function display() {
13
+ $vfb_settings = get_option( 'vfb-settings' );
14
+ ?>
15
+ <div class="wrap">
16
+ <h2><?php _e( 'Settings', 'visual-form-builder' ); ?></h2>
17
+ <form id="vfb-settings" method="post">
18
+ <input name="action" type="hidden" value="vfb_settings" />
19
+ <?php wp_nonce_field( 'vfb-update-settings' ); ?>
20
+ <h3><?php _e( 'Global Settings', 'visual-form-builder' ); ?></h3>
21
+ <p><?php _e( 'These settings will affect all forms on your site.', 'visual-form-builder' ); ?></p>
22
+ <table class="form-table">
23
+ <tr valign="top">
24
+ <th scope="row"><?php _e( 'CSS', 'visual-form-builder' ); ?></th>
25
+ <td>
26
+ <fieldset>
27
+ <?php
28
+ $disable = array(
29
+ 'always-load-css' => __( 'Always load CSS', 'visual-form-builder' ),
30
+ 'disable-css' => __( 'Disable CSS', 'visual-form-builder' ), // visual-form-builder-css
31
+ );
32
+
33
+ foreach ( $disable as $key => $title ) :
34
+
35
+ $vfb_settings[ $key ] = isset( $vfb_settings[ $key ] ) ? $vfb_settings[ $key ] : '';
36
+ ?>
37
+ <label for="vfb-settings-<?php echo $key; ?>">
38
+ <input type="checkbox" name="vfb-settings[<?php echo $key; ?>]" id="vfb-settings-<?php echo $key; ?>" value="1" <?php checked( $vfb_settings[ $key ], 1 ); ?> /> <?php echo $title; ?>
39
+ </label>
40
+ <br>
41
+ <?php endforeach; ?>
42
+ </fieldset>
43
+ </td>
44
+ </tr>
45
+
46
+ <tr valign="top">
47
+ <th scope="row"><?php _e( 'Form Output', 'visual-form-builder' ); ?></th>
48
+ <td>
49
+ <fieldset>
50
+ <?php
51
+ $disable = array(
52
+ 'address-labels' => __( 'Place Address labels above fields', 'visual-form-builder' ), // vfb_address_labels_placement
53
+ );
54
+
55
+ foreach ( $disable as $key => $title ) :
56
+
57
+ $vfb_settings[ $key ] = isset( $vfb_settings[ $key ] ) ? $vfb_settings[ $key ] : '';
58
+ ?>
59
+ <label for="vfb-settings-<?php echo $key; ?>">
60
+ <input type="checkbox" name="vfb-settings[<?php echo $key; ?>]" id="vfb-settings-<?php echo $key; ?>" value="1" <?php checked( $vfb_settings[ $key ], 1 ); ?> /> <?php echo $title; ?>
61
+ </label>
62
+ <br>
63
+ <?php endforeach; ?>
64
+ </fieldset>
65
+ </td>
66
+ </tr>
67
+
68
+ <tr valign="top">
69
+ <th scope="row"><label for="vfb-settings-spam-points"><?php _e( 'Spam word sensitivity', 'visual-form-builder' ); ?></label></th>
70
+ <td>
71
+ <?php $vfb_settings['spam-points'] = isset( $vfb_settings['spam-points'] ) ? $vfb_settings['spam-points'] : '4'; ?>
72
+ <input type="number" min="1" name="vfb-settings[spam-points]" id="vfb-settings-spam-points" value="<?php echo $vfb_settings['spam-points']; ?>" class="small-text" />
73
+ </td>
74
+ </tr>
75
+
76
+ <tr valign="top">
77
+ <th scope="row"><label for="vfb-settings-max-upload-size"><?php _e( 'Max Upload Size', 'visual-form-builder' ); ?></label></th>
78
+ <td>
79
+ <?php $vfb_settings['max-upload-size'] = isset( $vfb_settings['max-upload-size'] ) ? $vfb_settings['max-upload-size'] : '25'; ?>
80
+ <input type="number" name="vfb-settings[max-upload-size]" id="vfb-settings-max-upload-size" value="<?php echo $vfb_settings['max-upload-size']; ?>" class="small-text" /> MB
81
+ </td>
82
+ </tr>
83
+
84
+ <tr valign="top">
85
+ <th scope="row"><label for="vfb-settings-sender-mail-header"><?php _e( 'Sender Mail Header', 'visual-form-builder' ); ?></label></th>
86
+ <td>
87
+ <?php
88
+ // Use the admin_email as the From email
89
+ $from_email = get_site_option( 'admin_email' );
90
+
91
+ // Get the site domain and get rid of www.
92
+ $sitename = strtolower( $_SERVER['SERVER_NAME'] );
93
+ if ( substr( $sitename, 0, 4 ) == 'www.' )
94
+ $sitename = substr( $sitename, 4 );
95
+
96
+ // Get the domain from the admin_email
97
+ list( $user, $domain ) = explode( '@', $from_email );
98
+
99
+ // If site domain and admin_email domain match, use admin_email, otherwise a same domain email must be created
100
+ $from_email = ( $sitename == $domain ) ? $from_email : "wordpress@$sitename";
101
+
102
+ $vfb_settings['sender-mail-header'] = isset( $vfb_settings['sender-mail-header'] ) ? $vfb_settings['sender-mail-header'] : $from_email;
103
+ ?>
104
+ <input type="text" name="vfb-settings[sender-mail-header]" id="vfb-settings-sender-mail-header" value="<?php echo $vfb_settings['sender-mail-header']; ?>" class="regular-text" />
105
+ <p class="description"><?php _e( 'Some server configurations require an existing email on the domain be used when sending emails.', 'visual-form-builder' ); ?></p>
106
+ </td>
107
+ </tr>
108
+ </table>
109
+
110
+ <?php submit_button( __( 'Save', 'visual-form-builder' ), 'primary', 'submit', false ); ?>
111
+ </form>
112
+ </div> <!-- .wrap -->
113
+ <?php
114
+ }
115
+ }
admin/class-save.php ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * [Visual_Form_Builder_Admin_Save description]
4
+ */
5
+ class Visual_Form_Builder_Admin_Save {
6
+
7
+ /**
8
+ * Hook our save functions to the admin
9
+ *
10
+ * @access public
11
+ * @return void
12
+ */
13
+ public function __construct() {
14
+ add_action( 'admin_init', array( $this, 'add_new_form' ) );
15
+ add_action( 'admin_init', array( $this, 'save_update_form' ) );
16
+ add_action( 'admin_init', array( $this, 'save_trash_delete_form' ) );
17
+ add_action( 'admin_init', array( $this, 'save_copy_form' ) );
18
+ add_action( 'admin_init', array( $this, 'save_settings' ) );
19
+ }
20
+
21
+ /**
22
+ * Add New form
23
+ */
24
+ public function add_new_form() {
25
+ global $wpdb;
26
+
27
+ if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
28
+ return;
29
+
30
+ if ( 'vfb-add-new' !== $_GET['page'] )
31
+ return;
32
+
33
+ if ( 'create_form' !== $_POST['action'] )
34
+ return;
35
+
36
+ if ( !current_user_can( 'manage_options' ) )
37
+ wp_die( __( 'You do not have sufficient permissions to create a new form.', 'visual-form-builder' ) );
38
+
39
+ check_admin_referer( 'create_form' );
40
+
41
+ $form_key = sanitize_title( $_POST['form_title'] );
42
+ $form_title = esc_html( $_POST['form_title'] );
43
+ $form_from_name = esc_html( $_POST['form_email_from_name'] );
44
+ $form_subject = esc_html( $_POST['form_email_subject'] );
45
+ $form_from = esc_html( $_POST['form_email_from'] );
46
+ $form_to = serialize( $_POST['form_email_to'] );
47
+
48
+ $newdata = array(
49
+ 'form_key' => $form_key,
50
+ 'form_title' => $form_title,
51
+ 'form_email_from_name' => $form_from_name,
52
+ 'form_email_subject' => $form_subject,
53
+ 'form_email_from' => $form_from,
54
+ 'form_email_to' => $form_to,
55
+ 'form_success_message' => '<p id="form_success">Your form was successfully submitted. Thank you for contacting us.</p>'
56
+ );
57
+
58
+ // Create the form
59
+ $wpdb->insert( VFB_WP_FORMS_TABLE_NAME, $newdata );
60
+
61
+ // Get form ID to add our first field
62
+ $new_form_selected = $wpdb->insert_id;
63
+
64
+ // Setup the initial fieldset
65
+ $initial_fieldset = array(
66
+ 'form_id' => $wpdb->insert_id,
67
+ 'field_key' => 'fieldset',
68
+ 'field_type' => 'fieldset',
69
+ 'field_name' => 'Fieldset',
70
+ 'field_sequence' => 0
71
+ );
72
+
73
+ // Add the first fieldset to get things started
74
+ $wpdb->insert( VFB_WP_FIELDS_TABLE_NAME, $initial_fieldset );
75
+
76
+ $verification_fieldset = array(
77
+ 'form_id' => $new_form_selected,
78
+ 'field_key' => 'verification',
79
+ 'field_type' => 'verification',
80
+ 'field_name' => 'Verification',
81
+ 'field_description' => '(This is for preventing spam)',
82
+ 'field_sequence' => 1
83
+ );
84
+
85
+ // Insert the submit field
86
+ $wpdb->insert( VFB_WP_FIELDS_TABLE_NAME, $verification_fieldset );
87
+
88
+ $verify_fieldset_parent_id = $wpdb->insert_id;
89
+
90
+ $secret = array(
91
+ 'form_id' => $new_form_selected,
92
+ 'field_key' => 'secret',
93
+ 'field_type' => 'secret',
94
+ 'field_name' => 'Please enter any two digits',
95
+ 'field_description' => 'Example: 12',
96
+ 'field_size' => 'medium',
97
+ 'field_required' => 'yes',
98
+ 'field_parent' => $verify_fieldset_parent_id,
99
+ 'field_sequence' => 2
100
+ );
101
+
102
+ // Insert the submit field
103
+ $wpdb->insert( VFB_WP_FIELDS_TABLE_NAME, $secret );
104
+
105
+ // Make the submit last in the sequence
106
+ $submit = array(
107
+ 'form_id' => $new_form_selected,
108
+ 'field_key' => 'submit',
109
+ 'field_type' => 'submit',
110
+ 'field_name' => 'Submit',
111
+ 'field_parent' => $verify_fieldset_parent_id,
112
+ 'field_sequence' => 3
113
+ );
114
+
115
+ // Insert the submit field
116
+ $wpdb->insert( VFB_WP_FIELDS_TABLE_NAME, $submit );
117
+
118
+ // Redirect to keep the URL clean (use AJAX in the future?)
119
+ wp_redirect( 'admin.php?page=visual-form-builder&action=edit&form=' . $new_form_selected );
120
+ exit();
121
+ }
122
+
123
+ /**
124
+ * [save_update_form description]
125
+ * @return [type] [description]
126
+ */
127
+ public function save_update_form() {
128
+ global $wpdb;
129
+
130
+ if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
131
+ return;
132
+
133
+ if ( 'visual-form-builder' !== $_GET['page'] )
134
+ return;
135
+
136
+ if ( 'update_form' !== $_POST['action'] )
137
+ return;
138
+
139
+ check_admin_referer( 'vfb_update_form' );
140
+
141
+ $form_id = absint( $_POST['form_id'] );
142
+ $form_key = sanitize_title( $_POST['form_title'], $form_id );
143
+ $form_title = $_POST['form_title'];
144
+ $form_subject = $_POST['form_email_subject'];
145
+ $form_to = serialize( array_map( 'sanitize_email', $_POST['form_email_to'] ) );
146
+ $form_from = sanitize_email( $_POST['form_email_from'] );
147
+ $form_from_name = $_POST['form_email_from_name'];
148
+ $form_from_override = isset( $_POST['form_email_from_override'] ) ? $_POST['form_email_from_override'] : '';
149
+ $form_from_name_override = isset( $_POST['form_email_from_name_override'] ) ? $_POST['form_email_from_name_override'] : '';
150
+ $form_success_type = $_POST['form_success_type'];
151
+ $form_notification_setting = isset( $_POST['form_notification_setting'] ) ? $_POST['form_notification_setting'] : '';
152
+ $form_notification_email_name = isset( $_POST['form_notification_email_name'] ) ? $_POST['form_notification_email_name'] : '';
153
+ $form_notification_email_from = isset( $_POST['form_notification_email_from'] ) ? sanitize_email( $_POST['form_notification_email_from'] ) : '';
154
+ $form_notification_email = isset( $_POST['form_notification_email'] ) ? $_POST['form_notification_email'] : '';
155
+ $form_notification_subject = isset( $_POST['form_notification_subject'] ) ? $_POST['form_notification_subject'] : '';
156
+ $form_notification_message = isset( $_POST['form_notification_message'] ) ? format_for_editor( $_POST['form_notification_message'] ) : '';
157
+ $form_notification_entry = isset( $_POST['form_notification_entry'] ) ? $_POST['form_notification_entry'] : '';
158
+ $form_label_alignment = $_POST['form_label_alignment'];
159
+
160
+ // Add confirmation based on which type was selected
161
+ switch ( $form_success_type ) {
162
+ case 'text' :
163
+ $form_success_message = format_for_editor( $_POST['form_success_message_text'] );
164
+ break;
165
+ case 'page' :
166
+ $form_success_message = $_POST['form_success_message_page'];
167
+ break;
168
+ case 'redirect' :
169
+ $form_success_message = $_POST['form_success_message_redirect'];
170
+ break;
171
+ }
172
+
173
+ $newdata = array(
174
+ 'form_key' => $form_key,
175
+ 'form_title' => $form_title,
176
+ 'form_email_subject' => $form_subject,
177
+ 'form_email_to' => $form_to,
178
+ 'form_email_from' => $form_from,
179
+ 'form_email_from_name' => $form_from_name,
180
+ 'form_email_from_override' => $form_from_override,
181
+ 'form_email_from_name_override' => $form_from_name_override,
182
+ 'form_success_type' => $form_success_type,
183
+ 'form_success_message' => $form_success_message,
184
+ 'form_notification_setting' => $form_notification_setting,
185
+ 'form_notification_email_name' => $form_notification_email_name,
186
+ 'form_notification_email_from' => $form_notification_email_from,
187
+ 'form_notification_email' => $form_notification_email,
188
+ 'form_notification_subject' => $form_notification_subject,
189
+ 'form_notification_message' => $form_notification_message,
190
+ 'form_notification_entry' => $form_notification_entry,
191
+ 'form_label_alignment' => $form_label_alignment
192
+ );
193
+
194
+ $where = array( 'form_id' => $form_id );
195
+
196
+ // Update form details
197
+ $wpdb->update( VFB_WP_FORMS_TABLE_NAME, $newdata, $where );
198
+
199
+ $field_ids = array();
200
+
201
+ foreach ( $_POST['field_id'] as $fields ) {
202
+ $field_ids[] = $fields;
203
+ }
204
+
205
+ // Initialize field sequence
206
+ $field_sequence = 0;
207
+
208
+ // Loop through each field and update
209
+ foreach ( $field_ids as $id ) {
210
+ $id = absint( $id );
211
+
212
+ $field_name = isset( $_POST['field_name-' . $id] ) ? trim( $_POST['field_name-' . $id] ) : '';
213
+ $field_key = sanitize_key( sanitize_title( $field_name, $id ) );
214
+ $field_desc = isset( $_POST['field_description-' . $id] ) ? trim( $_POST['field_description-' . $id] ) : '';
215
+ $field_options = isset( $_POST['field_options-' . $id] ) ? serialize( array_map( 'trim', $_POST['field_options-' . $id] ) ) : '';
216
+ $field_validation = isset( $_POST['field_validation-' . $id] ) ? $_POST['field_validation-' . $id] : '';
217
+ $field_required = isset( $_POST['field_required-' . $id] ) ? $_POST['field_required-' . $id] : '';
218
+ $field_size = isset( $_POST['field_size-' . $id] ) ? $_POST['field_size-' . $id] : '';
219
+ $field_css = isset( $_POST['field_css-' . $id] ) ? $_POST['field_css-' . $id] : '';
220
+ $field_layout = isset( $_POST['field_layout-' . $id] ) ? $_POST['field_layout-' . $id] : '';
221
+ $field_default = isset( $_POST['field_default-' . $id] ) ? trim( $_POST['field_default-' . $id] ) : '';
222
+
223
+ $field_data = array(
224
+ 'field_key' => $field_key,
225
+ 'field_name' => $field_name,
226
+ 'field_description' => $field_desc,
227
+ 'field_options' => $field_options,
228
+ 'field_validation' => $field_validation,
229
+ 'field_required' => $field_required,
230
+ 'field_size' => $field_size,
231
+ 'field_css' => $field_css,
232
+ 'field_layout' => $field_layout,
233
+ 'field_sequence' => $field_sequence,
234
+ 'field_default' => $field_default
235
+ );
236
+
237
+ $where = array(
238
+ 'form_id' => $form_id,
239
+ 'field_id' => $id
240
+ );
241
+
242
+ // Update all fields
243
+ $wpdb->update( VFB_WP_FIELDS_TABLE_NAME, $field_data, $where );
244
+
245
+ $field_sequence++;
246
+ }
247
+ }
248
+
249
+ /**
250
+ * [save_trash_delete_form description]
251
+ * @return [type] [description]
252
+ */
253
+ public function save_trash_delete_form() {
254
+ global $wpdb;
255
+
256
+ if ( !isset( $_GET['action'] ) || !isset( $_GET['page'] ) )
257
+ return;
258
+
259
+ if ( 'visual-form-builder' !== $_GET['page'] )
260
+ return;
261
+
262
+ if ( 'delete_form' !== $_GET['action'] )
263
+ return;
264
+
265
+ $id = absint( $_GET['form'] );
266
+
267
+ check_admin_referer( 'delete-form-' . $id );
268
+
269
+ // Delete form and all fields
270
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE form_id = %d", $id ) );
271
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE form_id = %d", $id ) );
272
+ $wpdb->query( $wpdb->prepare( "DELETE FROM " . VFB_WP_ENTRIES_TABLE_NAME . " WHERE form_id = %d", $id ) );
273
+
274
+ // Redirect to keep the URL clean (use AJAX in the future?)
275
+ wp_redirect( add_query_arg( 'action', 'deleted', 'admin.php?page=visual-form-builder' ) );
276
+ exit();
277
+ }
278
+
279
+ /**
280
+ * [save_copy_form description]
281
+ * @return [type] [description]
282
+ */
283
+ public function save_copy_form() {
284
+ global $wpdb;
285
+
286
+ if ( !isset( $_GET['action'] ) || !isset( $_GET['page'] ) )
287
+ return;
288
+
289
+ if ( 'visual-form-builder' !== $_GET['page'] )
290
+ return;
291
+
292
+ if ( 'copy_form' !== $_GET['action'] )
293
+ return;
294
+
295
+ $id = absint( $_GET['form'] );
296
+
297
+ check_admin_referer( 'copy-form-' . $id );
298
+
299
+ // Get all fields and data for the request form
300
+ $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE form_id = %d", $id ) );
301
+ $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE form_id = %d", $id ) );
302
+ $override = $wpdb->get_var( $wpdb->prepare( "SELECT form_email_from_override, form_email_from_name_override, form_notification_email FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE form_id = %d", $id ) );
303
+ $from_name = $wpdb->get_var( null, 1 );
304
+ $notify = $wpdb->get_var( null, 2 );
305
+
306
+ // Copy this form and force the initial title to denote a copy
307
+ foreach ( $forms as $form ) {
308
+ $data = array(
309
+ 'form_key' => sanitize_title( $form->form_key . ' copy' ),
310
+ 'form_title' => $form->form_title . ' Copy',
311
+ 'form_email_subject' => $form->form_email_subject,
312
+ 'form_email_to' => $form->form_email_to,
313
+ 'form_email_from' => $form->form_email_from,
314
+ 'form_email_from_name' => $form->form_email_from_name,
315
+ 'form_email_from_override' => $form->form_email_from_override,
316
+ 'form_email_from_name_override' => $form->form_email_from_name_override,
317
+ 'form_success_type' => $form->form_success_type,
318
+ 'form_success_message' => $form->form_success_message,
319
+ 'form_notification_setting' => $form->form_notification_setting,
320
+ 'form_notification_email_name' => $form->form_notification_email_name,
321
+ 'form_notification_email_from' => $form->form_notification_email_from,
322
+ 'form_notification_email' => $form->form_notification_email,
323
+ 'form_notification_subject' => $form->form_notification_subject,
324
+ 'form_notification_message' => $form->form_notification_message,
325
+ 'form_notification_entry' => $form->form_notification_entry,
326
+ 'form_label_alignment' => $form->form_label_alignment
327
+ );
328
+
329
+ $wpdb->insert( VFB_WP_FORMS_TABLE_NAME, $data );
330
+ }
331
+
332
+ // Get form ID to add our first field
333
+ $new_form_selected = $wpdb->insert_id;
334
+
335
+ // Copy each field and data
336
+ foreach ( $fields as $field ) {
337
+ $data = array(
338
+ 'form_id' => $new_form_selected,
339
+ 'field_key' => $field->field_key,
340
+ 'field_type' => $field->field_type,
341
+ 'field_name' => $field->field_name,
342
+ 'field_description' => $field->field_description,
343
+ 'field_options' => $field->field_options,
344
+ 'field_sequence' => $field->field_sequence,
345
+ 'field_validation' => $field->field_validation,
346
+ 'field_required' => $field->field_required,
347
+ 'field_size' => $field->field_size,
348
+ 'field_css' => $field->field_css,
349
+ 'field_layout' => $field->field_layout,
350
+ 'field_parent' => $field->field_parent
351
+ );
352
+
353
+ $wpdb->insert( VFB_WP_FIELDS_TABLE_NAME, $data );
354
+
355
+ // If a parent field, save the old ID and the new ID to update new parent ID
356
+ if ( in_array( $field->field_type, array( 'fieldset', 'section', 'verification' ) ) ) {
357
+ $parents[ $field->field_id ] = $wpdb->insert_id;
358
+ }
359
+
360
+ if ( $override == $field->field_id ) {
361
+ $wpdb->update( VFB_WP_FORMS_TABLE_NAME, array( 'form_email_from_override' => $wpdb->insert_id ), array( 'form_id' => $new_form_selected ) );
362
+ }
363
+
364
+
365
+ if ( $from_name == $field->field_id ) {
366
+ $wpdb->update( VFB_WP_FORMS_TABLE_NAME, array( 'form_email_from_name_override' => $wpdb->insert_id ), array( 'form_id' => $new_form_selected ) );
367
+ }
368
+
369
+ if ( $notify == $field->field_id ) {
370
+ $wpdb->update( VFB_WP_FORMS_TABLE_NAME, array( 'form_notification_email' => $wpdb->insert_id ), array( 'form_id' => $new_form_selected ) );
371
+ }
372
+ }
373
+
374
+ // Loop through our parents and update them to their new IDs
375
+ foreach ( $parents as $k => $v ) {
376
+ $wpdb->update( VFB_WP_FIELDS_TABLE_NAME, array( 'field_parent' => $v ), array( 'form_id' => $new_form_selected, 'field_parent' => $k ) );
377
+ }
378
+
379
+ // Redirect to keep the URL clean (use AJAX in the future?)
380
+ wp_redirect( 'admin.php?page=visual-form-builder&action=edit&form=' . $new_form_selected );
381
+ exit();
382
+ }
383
+
384
+ /**
385
+ * [save_settings description]
386
+ * @return [type] [description]
387
+ */
388
+ public function save_settings() {
389
+ if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
390
+ return;
391
+
392
+ if ( 'vfb-settings' !== $_GET['page'] )
393
+ return;
394
+
395
+ if ( 'vfb_settings' !== $_POST['action'] )
396
+ return;
397
+
398
+ check_admin_referer( 'vfb-update-settings' );
399
+
400
+ $data = array();
401
+
402
+ foreach ( $_POST['vfb-settings'] as $key => $val ) {
403
+ $data[ $key ] = esc_html( $val );
404
+ }
405
+
406
+ update_option( 'vfb-settings', $data );
407
+ }
408
+ }
admin/class-screen-options.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Handle Screen Options
4
+ *
5
+ * Defines and saves all options in Screen Options tabs
6
+ *
7
+ */
8
+ class Visual_Form_Builder_Admin_Screen_Options {
9
+
10
+ /**
11
+ * Add options to Screen Options
12
+ *
13
+ * @access public
14
+ * @return void
15
+ */
16
+ public function add_option() {
17
+ if ( isset( $_GET['form'] ) ) {
18
+ add_screen_option( 'layout_columns', array(
19
+ 'max' => 2,
20
+ 'default' => 2
21
+ ) );
22
+ } else {
23
+ add_screen_option( 'per_page', array(
24
+ 'label' => __( 'Forms per page', 'visual-form-builder' ),
25
+ 'default' => 20,
26
+ 'option' => 'vfb_forms_per_page'
27
+ ) );
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Add options to Entries page
33
+ */
34
+ public function add_option_entries() {
35
+ add_screen_option( 'per_page', array(
36
+ 'label' => __( 'Entries per page', 'visual-form-builder' ),
37
+ 'default' => 20,
38
+ 'option' => 'vfb_entries_per_page'
39
+ ) );
40
+ }
41
+
42
+ /**
43
+ * Save Screen Options
44
+ *
45
+ * @access public
46
+ * @param mixed $status Return this so we don't break other plugins
47
+ * @param mixed $option The option name
48
+ * @param mixed $value The submitted value
49
+ * @return void
50
+ */
51
+ public function save_option( $status, $option, $value ) {
52
+
53
+ if ( 'vfb_forms_per_page' == $option )
54
+ return $value;
55
+
56
+ if ( 'vfb_entries_per_page' == $option )
57
+ return $value;
58
+
59
+ return $status;
60
+ }
61
+ }
{includes → admin}/class-widget.php RENAMED
@@ -3,7 +3,7 @@
3
  add_action( 'widgets_init', 'vfb_register_widgets' );
4
 
5
  function vfb_register_widgets() {
6
- register_widget( 'VisualFormBuilder_Widget' );
7
  }
8
 
9
  /**
@@ -11,42 +11,14 @@ function vfb_register_widgets() {
11
  *
12
  * @since 2.7
13
  */
14
- class VisualFormBuilder_Widget extends WP_Widget {
15
  /**
16
- * field_table_name
17
- *
18
- * @var mixed
19
- * @access public
20
  */
21
- public $field_table_name;
22
-
23
- /**
24
- * form_table_name
25
- *
26
- * @var mixed
27
- * @access public
28
- */
29
- public $form_table_name;
30
-
31
- /**
32
- * entries_table_name
33
- *
34
- * @var mixed
35
- * @access public
36
- */
37
- public $entries_table_name;
38
-
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
  parent::__construct(
48
  'vfb_widget',
49
- __( 'Visual Form Builder', 'vfb-pro' ),
50
  array(
51
  'classname' => 'vfb_widget_class',
52
  'description' => __( 'Visual Form Builder Widget', 'visual-form-builder' ),
@@ -54,13 +26,18 @@ class VisualFormBuilder_Widget extends WP_Widget {
54
  );
55
  }
56
 
 
 
 
 
 
57
  public function form( $instance ) {
58
  global $wpdb;
59
 
60
  // Query to get all forms
61
  $order = sanitize_sql_orderby( 'form_id ASC' );
62
  $where = apply_filters( 'vfb_pre_get_forms_widget', '' );
63
- $forms = $wpdb->get_results( "SELECT * FROM $this->form_table_name WHERE 1=1 $where ORDER BY $order" );
64
 
65
  $instance = wp_parse_args( (array) $instance );
66
 
@@ -89,6 +66,12 @@ class VisualFormBuilder_Widget extends WP_Widget {
89
  <?php
90
  }
91
 
 
 
 
 
 
 
92
  public function widget( $args, $instance ) {
93
  extract( $args );
94
 
@@ -106,6 +89,12 @@ class VisualFormBuilder_Widget extends WP_Widget {
106
  echo $after_widget;
107
  }
108
 
 
 
 
 
 
 
109
  public function update( $new_instance, $old_instance ) {
110
  $instance = array();
111
 
3
  add_action( 'widgets_init', 'vfb_register_widgets' );
4
 
5
  function vfb_register_widgets() {
6
+ register_widget( 'Visual_Form_Builder_Widget' );
7
  }
8
 
9
  /**
11
  *
12
  * @since 2.7
13
  */
14
+ class Visual_Form_Builder_Widget extends WP_Widget {
15
  /**
16
+ * [__construct description]
 
 
 
17
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  public function __construct(){
 
 
 
 
 
 
 
19
  parent::__construct(
20
  'vfb_widget',
21
+ __( 'Visual Form Builder', 'visual-form-builder' ),
22
  array(
23
  'classname' => 'vfb_widget_class',
24
  'description' => __( 'Visual Form Builder Widget', 'visual-form-builder' ),
26
  );
27
  }
28
 
29
+ /**
30
+ * [form description]
31
+ * @param [type] $instance [description]
32
+ * @return [type] [description]
33
+ */
34
  public function form( $instance ) {
35
  global $wpdb;
36
 
37
  // Query to get all forms
38
  $order = sanitize_sql_orderby( 'form_id ASC' );
39
  $where = apply_filters( 'vfb_pre_get_forms_widget', '' );
40
+ $forms = $wpdb->get_results( "SELECT * FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE 1=1 $where ORDER BY $order" );
41
 
42
  $instance = wp_parse_args( (array) $instance );
43
 
66
  <?php
67
  }
68
 
69
+ /**
70
+ * [widget description]
71
+ * @param [type] $args [description]
72
+ * @param [type] $instance [description]
73
+ * @return [type] [description]
74
+ */
75
  public function widget( $args, $instance ) {
76
  extract( $args );
77
 
89
  echo $after_widget;
90
  }
91
 
92
+ /**
93
+ * [update description]
94
+ * @param [type] $new_instance [description]
95
+ * @param [type] $old_instance [description]
96
+ * @return [type] [description]
97
+ */
98
  public function update( $new_instance, $old_instance ) {
99
  $instance = array();
100
 
admin/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
css/visual-form-builder-admin.min.css DELETED
@@ -1 +0,0 @@
1
- .vfb-pro-call-to-action{padding:5px 0;text-align:center}.vfb-btn{display:inline-block;*display:inline;*zoom:1;padding:15px 10px;margin-bottom:0;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;font-size:21px;font-weight:500;text-shadow:0 1px 1px rgba(255,255,255,0.75);background-color:#f5f5f5;background-repeat:repeat-x;border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);text-decoration:none}.vfb-btn:hover,.vfb-btn:focus{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.vfb-btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.vfb-btn.active,.vfb-btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.vfb-btn-primary.active{color:rgba(255,255,255,0.75)}.vfb-btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0044cc',GradientType=0);border-color:#04c #0044cc #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.vfb-btn-primary:hover,.vfb-btn-primary:focus,.vfb-btn-primary:active,.vfb-btn-primary.active,.vfb-btn-primary.disabled,.vfb-btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.vfb-btn-primary:active,.vfb-btn-primary.active{background-color:#039 \9}.vfb-btn-inverse{background-color:#363636;background-repeat:repeat-x;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.vfb-btn-inverse:hover,.vfb-btn-inverse:focus,.vfb-btn-inverse:active,.vfb-btn-inverse.active,.vfb-btn-inverse.disabled,.vfb-btn-inverse[disabled]{background-color:#222;color:#fff}.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}.rtl .vfb-pro-upgrade{float:right}.vfb-pro-upgrade h2,.wrap .vfb-pro-upgrade h2{font-size:23px;font-weight:500;padding:5px 0;text-align:center}.vfb-pro-upgrade h2 a{text-decoration:none}.vfb-pro-upgrade ul{list-style:outside;margin-left:10px}.rtl .vfb-pro-upgrade ul{margin-left:0;margin-right:10px}#vfb-form-builder-frame{display:block;margin:0 -8px 0 290px}.rtl #vfb-form-builder-frame{margin:0 290px 0 -8px}#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,.option:after{display:block;visibility:hidden;clear:both;height:0;content:"."}#vfb-form-builder-sidebar{clear:both;width:281px}#vfb-form-builder-management{position:relative;margin-right:10px}.rtl #vfb-form-builder-management{margin-right:0;margin-left:10px}#vfb-form-builder-management .form-edit{margin-bottom:20px;border:1px solid #dfdfdf;border-radius:3px}.admin-color-classic #vfb-form-builder-management .form-edit{border-color:#d0dfe9}#form-editor-header,#form-editor-footer{padding:0 10px;background-color:#f1f1f1}#form-editor-footer{border-top:1px solid #dfdfdf}.admin-color-classic #form-editor-header,.admin-color-classic #form-editor-footer{background-color:#f5fafd}.admin-color-class #form-editor-footer{border-top-color:#d0dfe9}.vfb-major-publishing-actions{clear:both;padding:3px 0 5px}.vfb-major-publishing-actions .publishing-action{float:right;margin:5px 0 1px;text-align:right;line-height:23px}#form-editor-header .publishing-action{margin-top:12px}.sub-navigation{float:none;margin:8px 0 5px;padding:0;list-style:none;white-space:nowrap;font-size:12px}.sub-navigation li{display:inline;margin:0;padding:0}.sub-navigation a{padding:.2em;text-decoration:none;line-height:2}.sub-navigation a.current{border:medium none;background:0;color:black;font-weight:bold}.sub-navigation a:hover{color:#d54e21}#vfb-sidebar,#vfb-main{float:left;margin:10px 0;width:280px}.rtl #vfb-sidebar,.rtl #vfb-main{float:right}#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:-300px}.rtl #vfb-sidebar{margin-left:0;margin-right:-300px}#vfb-form-list{display:block;margin-left:300px}.rtl #vfb-form-list{margin-left:0;margin-right:300px}.vfb-box{position:relative;float:left;padding:0 10px;border:1px solid #dfdfdf;border-radius:3px 3px 3px 3px;background-color:#f5f5f5;background:-moz-linear-gradient(top,#fff 0,#f5f5f5 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#fff),color-stop(100%,#f5f5f5));background:-webkit-linear-gradient(top,#fff 0,#f5f5f5 100%);background:-o-linear-gradient(top,#fff 0,#f5f5f5 100%);background:-ms-linear-gradient(top,#fff 0,#f5f5f5 100%);background:linear-gradient(to bottom,#fff 0,#f5f5f5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#f5f5f5',GradientType=0);box-shadow:0 1px 0 #fff inset;line-height:1.4em}.vfb-form-alpha-list{width:70%;float:left;padding-right:20px}.rtl .vfb-form-alpha-list{float:right;padding-right:0;padding-left:20px}.vfb-form-alpha-list hr{display:block;margin:1em 0;padding:0;height:1px;border:0;border-top:1px solid #ccc}.vfb-form-alpha-group .letter,.wrap h2.letter{float:left;padding:0;color:#666;font-size:14px;line-height:17px}.vfb-form-alpha-form{display:block;margin:10px 0;padding-left:150px;width:auto}.vfb-form-alpha-form h3{float:left;margin:0;width:50%;word-wrap:break-word;font-size:17px}.vfb-form-alpha-form .vfb-publishing-actions,.vfb-form-alpha-form .vfb-form-meta{float:left;width:20%;text-align:center}.vfb-form-alpha-form .vfb-form-meta{width:30%}.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;margin:0;text-align:left}.rtl .vfb-form-alpha-form .vfb-form-meta,.rtl .vfb-form-alpha-form .paypal{float:right;text-align:right}.vfb-sortable-placeholder{display:block;height:35px;width:400px;margin:8px;border:1px dashed #bbb;background-color:#f5f5f5}#vfb-main .vfb-sortable-placeholder{float:left;margin:8px;height:200px;width:210px}.rtl #vfb-main .vfb-sortable-placeholder{float:right}#vfb-menu-to-edit .mjs-nestedSortable-error{border-color:red;background-color:#fbe3e4;color:#8a1f11}.vfb-meta-entries-total span,.vfb-meta-entries-total-today span{font-size:11px;font-weight:bold;height:1.4em;line-height:1.4em;min-width:.7em;padding:0 6px;display:inline-block;border-radius:5px;background-color:#bbb;color:white;text-align:center}.vfb-meta-entries-total:hover span,.vfb-meta-entries-total-today:hover span{background-color:#d54e21}.fixed .column-entries,.fixed .column-form_id{width:8em}strong .vfb-meta-entries-total span{background-color:#21759b}.entries-count-wrapper{font-family:sans-serif;min-width:22px;padding-bottom:1px}#new-form{margin:8px 0;padding-top:10px;width:75px;height:105px;text-align:center}#new-form a{display:block;width:auto;text-decoration:none}#post-body{padding:10px;background:white}.vfb-postbox-container{float:left;margin:0 8px;width:100%}.rtl .vfb-postbox-container{float:right}#vfb-postbox-container-1 .postbox{min-width:281px}#vfb-postbox-container-2{min-width:485px}#vfb-form-builder-frame.columns-1{margin-left:-8px}.rtl #vfb-form-builder-frame.columns-1{margin-left:0;margin-right:-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{margin-left:-290px;width:281px}.rtl #vfb-form-builder-frame.columns-2 #vfb-postbox-container-1,.rtl #vfb-form-builder-frame.columns-3 #vfb-postbox-container-1{margin-left:0;margin-right:-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%}.rtl #vfb-form-builder-frame.columns-3 #vfb-postbox-container-3{margin-right:0;margin-left:0}#vfb-form-meta-preview iframe{width:100%;height:100%}#vfb_form_media_button_tip input{width:100%;border:0;padding:6px;font-family:Consolas,Monaco,monospace;font-size:12px}@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;top:3px;right:-20px;display:block;overflow:hidden;width:30px;height:40px;background:url('../images/arrows.png?d=20130703') no-repeat scroll 8px 10px transparent;text-indent:-999em}.admin-color-classic .item-edit{background:url('../images/arrows-vs.png?d=20130703') no-repeat scroll 8px 10px transparent}.rtl .item-edit{right:auto;left:-20px}.item-edit:hover{background:url('../images/arrows-dark.png?d=20130703') no-repeat scroll 8px 10px transparent}.admin-color-classic .item-edit:hover{background:url('../images/arrows-dark-vs.png?d=20130703') no-repeat scroll 8px 10px transparent}.item-edit.opened{background:url('../images/arrows.png?d=20130703') no-repeat scroll 8px -25px transparent}.admin-color-classic .item-edit.opened{background:url('../images/arrows-vs.png?d=20130703') no-repeat scroll 8px -25px transparent}.item-edit.opened:hover{background:url('../images/arrows-dark.png?d=20130703') no-repeat scroll 8px -25px transparent}.admin-color-classic .item-edit.opened:hover{background:url('../images/arrows-dark-vs.png?d=20130703') no-repeat scroll 8px -25px transparent}.option .widefat,.options-other-show .widefat,.options-other-hide .widefat{margin:0 6px 7px 0;width:320px}.rtl .option .widefat,.rtl .options-other-show .widefat,.rtl .options-other-hide .widefat{margin:0 0 7px 6px}#form-settings .description-thin{margin:12px 10px 12px 0}.rtl #form-settings .description-thin{margin:12px 0 12px 10px}.description-thin,.description-wide{float:left;margin-right:10px}.rtl .description-thin,.rtl .description-wide{float:right;margin-right:0;margin-left:10px}.description-thin{width:190px;height:40px}.description-wide{width:390px}.vfb-interface-icon{position:absolute;top:4px;right:4px;display:inline-block;width:16px;height:16px;background-color:transparent;background-image:url('../images/vfb-interface-icons.png?d=20130713');background-repeat:no-repeat;text-indent:-9999px}.vfb-interface-settings{background-position:-32px 0}.vfb-interface-duplicate{background-position:0 0}.vfb-interface-trash{background-position:-64px 0}.vfb-interface-conditional{background-position:-224px 0}.vfb-interface-sort{background-position:-128px 0}.vfb-interface-plus{background-position:-160px 0}.vfb-interface-minus{background-position:-192px 0}.vfb-interface-bulk-add{background-position:-96px 0}.vfb-interface-plus,.vfb-interface-minus{top:0}.addEmail,.deleteEmail{top:28px}.addEmail{right:55px}.rtl .addEmail{right:auto;left:55px}.deleteEmail{right:30px}.rtl .deleteEmail{right:auto;left:30px}.deleteOption,.vfb-interface-sort,.addCondition,.deleteCondition{top:3px}.deleteOption,.addCondition{right:25px}.rtl .deleteOption,.rtl .addCondition{right:auto;left:25px}.vfb-interface-sort,.deleteCondition{right:0}.rtl .vfb-interface-sort,.rtl .deleteCondition{right:auto;left:0}.vfb-interface-sort:hover{cursor:pointer}.option{float:left;width:97%;position:relative}.rtl .option{float:right}#vfb-poststuff{display:block;margin-right:300px}.rtl #vfb-poststuff{margin-right:0;margin-left:300px}#vfb-entries-body-content{float:left;width:100%}.rtl #vfb-entries-body-content{float:right}.metabox-holder #vfb-entries-body-content h3{font-weight:bold;font-family:sans-serif}#entry-edit #side-info-column{margin-right:-300px}.rtl #entry-edit #side-info-column{margin-right:0;margin-left:-300px}label.error{display:block;color:red}#visual-form-builder-update input.error,#visual-form-builder-update textarea.error,#visual-form-builder-update select.error{border:1px solid red}#vfb-menu-to-edit .menu-item-settings{width:402px}.vfb-menu-item-handle{background:white;border:1px solid #dfdfdf;border-radius:3px;height:auto;line-height:35px;overflow:hidden;padding:10px 15px;position:relative;text-shadow:0 1px 0 #fff;width:382px;word-wrap:break-word;cursor:move}.vfb-menu-item-handle:hover{border-color:#999}.admin-color-classic .vfb-menu-item-handle{background:#f5fafd;box-shadow:0 1px 0 #fff inset;border-color:#d0dfe9}.rtl .vfb-menu-item-handle{padding-left:0;padding-right:10px}.vfb-menu-item-type-fieldset,.vfb-menu-item-type-verification,#form-element-fieldset{background:#e3e3e3;box-shadow:0 1px 0 #e3e3e3 inset}.admin-color-classic .vfb-menu-item-type-fieldset,.admin-color-classic .vfb-menu-item-type-verification,.admin-color-classic #form-element-fieldset{background:#e2f3ff;box-shadow:0 1px 0 #fff inset}.vfb-menu-item-handle .item-title{min-height:20px;display:block;font-size:12px;font-weight:bold;line-height:20px;margin-right:13em}.rtl .vfb-menu-item-handle .item-title{margin-right:0;margin-left:13em}.vfb-menu-item-active .vfb-menu-item-handle{border-bottom-left-radius:0;border-bottom-right-radius:0}.sender-labels{width:80px}.is-field-required{color:#bc1212}#form-details-nav{padding-top:10px;font-size:1.0em}#form-details-nav a,.charts-nav a{padding:5px 10px;text-decoration:none;font-weight:bold}#form-details-nav a.current,.charts-nav a.current{height:40px;border-color:#dfdfdf;border-radius:5px;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;text-shadow:0 -1px 0 #333}.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{width:100%;height:10em;font-family:Consolas,Monaco,monospace}#form-success-message-page,#form-success-message-redirect{margin-top:10px;width:100%}.post-body-plain ol li{list-style:decimal}#vfb-upgrade-column{display:inline;float:left;width:auto}.rtl #vfb-upgrade-column{float:right}ul#promote-vfb{margin-left:20px;list-style:disc}.rtl ul#promote-vfb{margin-left:auto;margin-right:20px}#promote-vfb li{text-align:left}.rtl #promote-vfb li{text-align:right}.menu .ui-nestedSortable-error{background-color:#fbe3e4;border-color:red;color:#8a1f11}ul#vfb-menu-to-edit ul{margin:0 0 0 25px;padding:0;width:98%;list-style-type:none}#vfb-menu-to-edit{margin-top:0;padding:1em 0}#vfb-fieldset-first-warning{display:none}.ui-state-disabled,.ui-state-disabled dl,.ui-state-disabled dt,.form-item.ui-state-disabled{opacity:100;filter:alpha(Opacity=100);background-image:none}.ui-state-disabled .vfb-menu-item-handle,.ui-state-disabled .menu-item-handle{background:#dfdfdf;box-shadow:none;cursor:default}.vfb-details{margin-bottom:10px;padding:0 10px;border:1px solid #ccc;border-radius:3px}.vfb-details.section{width:97.55%;background-color:#efefef}.vfb-details .postbox{min-height:60px}#poststuff .vfb-details h2{margin-top:0}#poststuff h3.section-heading{padding-left:0}#form-items .tabs-panel{overflow:visible;padding:.5em 0 .5em 4px;min-height:325px;height:auto}.rtl #form-items .tabs-panel{padding:.5em 4px .5em 0}ul.vfb-fields-col-1,ul.vfb-fields-col-2{float:left;width:50%;list-style:none}.rtl ul.vfb-fields-col-1,.rtl ul.vfb-fields-col-2{float:right}#vfb-form-builder-frame.columns-1 #vfb-postbox-container-1 #form-items .tabs-panel{height:auto}.vfb-draggable-form-items{position:relative;position:relative;display:block;margin-right:8px;padding:4px 0 4px 34px;border:1px solid #bbb;border-radius:3px;color:#464646;text-align:left;text-decoration:none;font-size:12px}.rtl .vfb-draggable-form-items{margin-right:0;margin-left:8px;padding:4px 34px 4px 10px}.vfb-draggable-form-items:hover{border-color:#aaa}.vfb-draggable-form-items b{position:absolute;left:8px;display:inline-block;width:16px;height:16px;background-color:transparent;background-image:url('../images/vfb-form-items.png?d=20130712');background-repeat:no-repeat;line-height:16px}.rtl .vfb-draggable-form-items b{left:auto;right:8px}#form-element-address b{background-position:-128px 0}#form-element-autocomplete b{background-position:-384px 0}#form-element-checkbox b{background-position:-672px 0}#form-element-color b{background-position:0 0}#form-element-currency b{background-position:-64px 0}#form-element-datepicker b{background-position:-224px 0}#form-element-digits b{background-position:-832px 0}#form-element-email b{background-position:-160px 0}#form-element-file b{background-position:-512px 0}#form-element-hidden b{background-position:-544px 0}#form-element-html b{background-position:-800px 0}#form-element-instructions b{background-position:-256px 0}#form-element-ip b{background-position:-448px 0}#form-element-max b{background-position:-576px 0}#form-element-min b{background-position:-608px 0}#form-element-name b{background-position:-320px 0}#form-element-pagebreak b{background-position:-768px 0}#form-element-password b{background-position:-352px 0}#form-element-phone b{background-position:-96px 0}#form-element-radio b{background-position:-704px 0}#form-element-range b{background-position:-640px 0}#form-element-select b{background-position:-416px 0}#form-element-text b{background-position:-736px 0}#form-element-textarea b{background-position:-32px 0}#form-element-time b{background-position:-192px 0}#form-element-username b{background-position:-288px 0}#form-element-url b{background-position:-480px 0}.static-vars-inactive{display:none}.static-vars-active{display:block}.vfb-button{position:relative;display:inline-block;overflow:visible;margin:0;padding:.5em 2.5em .5em 1em;outline:0;border:1px solid #d4d4d4;border-radius:.2em;background-color:#f5f5f5;color:#333;text-decoration:none;white-space:nowrap;font:12px/normal sans-serif;cursor:pointer;zoom:1;-webkit-background-clip:padding;-moz-background-clip:padding;-o-background-clip:padding-box;*display:inline}.vfb-button:hover,.vfb-button:active,.vfb-button.current{border-color:#929292;border-bottom-color:#929292;background-color:#eee;background-image:-webkit-gradient(linear,0 0,0 100%,from(#eee),to(#ccc));background-image:-moz-linear-gradient(#eee,#ccc);background-image:-o-linear-gradient(#eee,#ccc);background-image:linear-gradient(#eee,#ccc);color:#000}.vfb-button.current{font-weight:bold}.vfb-button::-moz-focus-inner{padding:0;border:0}.vfb-button.vfb-settings:hover,.vfb-button.vfb-settings:focus,.vfb-button.vfb-settings:active{color:#3072b3}.vfb-button.vfb-delete:hover,.vfb-button.vfb-delete:focus,.vfb-button.vfb-delete:active{color:#900}.vfb-button.vfb-duplicate:hover,.vfb-button.vfb-duplicate:focus,.vfb-button.vfb-duplicate:active{color:#008e0d}.vfb-button-group{display:inline-block;margin:10px 0;list-style:none}.rtl .vfb-button-group{margin-left:-2px}.vfb-button-group .vfb-button{float:left;margin-right:5px}.rtl .vfb-button-group .vfb-button{float:right;margin-right:0;margin-left:5px}.vfb-button-group .button-primary{margin-top:2px}.vfb-item-actions{margin-right:10px;margin-bottom:10px;text-align:center}.rtl .vfb-item-actions{margin-right:0;margin-left:10px}.vfb-item-actions .vfb-delete{float:left}.rtl .vfb-item-actions .vfb-delete{float:right}.vfb-item-actions .vfb-conditional-fields{float:right}.rtl .vfb-item-actions .vfb-conditional-fields{float:left}.vfb-item-actions .vfb-delete,.vfb-item-actions .vfb-duplicate,.vfb-item-actions .vfb-conditional-fields{margin-top:10px}#form-settings{display:none;width:100%;max-width:460px;margin-bottom:15px;border-bottom:1px solid #d6d6d6}#form-settings.current{display:block}.form-details{padding:20px;background:#fff;background:rgba(255,255,255,0.5);border-left:1px solid #d6d6d6;border-right:1px solid #d6d6d6}.form-details.on{display:block}.settings-links{position:relative;z-index:1;display:block;padding:5px 15px;height:25px;background:#f5f5f5;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;color:#333;text-decoration:none;text-transform:uppercase;text-shadow:0 1px 0 #fff;font-weight:normal;font-size:15px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:25px;cursor:pointer}.settings-links .vfb-large-arrow{position:absolute;top:16px;right:25px;width:5px;height:0;z-index:1}.settings-links .vfb-large-arrow:after{content:'';width:0;height:0;border-color:#ccc transparent;border-style:solid;border-width:6px 6px 0;position:absolute;z-index:1}.rtl .settings-links .vfb-large-arrow{right:auto;left:13px}.settings-links.on{border-bottom:1px solid #808080}.settings-links:hover,.settings-links.on{background:#808080;color:#fff;text-shadow:0 -1px 0 #333}.settings-links:first-child{border-top-left-radius:3px;border-top-right-radius:3px}.vfb-tooltip{position:relative;float:right;margin-right:2px;width:16px;height:16px;cursor:pointer}.rtl .vfb-tooltip{float:left;margin-right:0;margin-left:2px}.vfb-tooltip-popup{position:absolute;top:-40px;z-index:200;display:none;padding:5px 20px;width:250px;border:2px solid #333;border-radius:5px;background:#222;box-shadow:0 0 7px black;color:white;text-indent:0;font-style:normal}.vfb-tooltip-popup h3,.vfb-tooltip .vfb-tooltip-popup h3{margin:5px 0;padding:0 0 6px 0;border-bottom:1px solid white;color:white;font-weight:normal;font-size:13px;font-family:sans-serif}.vfb-tooltip-popup p{margin-top:1 0;color:white;font-size:12px}.vfb-add-options-group{display:inline-block;margin:10px 0;list-style:none;text-align:center;width:95%}.vfb-add-options-group .vfb-interface-plus{top:4px}.vfb-export-label{width:10em;float:left}.rtl .vfb-export-label{float:right}#vfb-export-entries-fields{height:275px;width:300px;overflow:auto;display:block;border:1px solid #e8e8e8;border-radius:3px;margin-left:10em;padding:5px;background:white}#vfb-export-select-all,#vfb-export-unselect-all{width:150px;display:inline-block;text-align:left}#vfb-export-unselect-all{text-align:right;margin-left:5px}@media print{body *{float:none}html,.wrap,#wpbody-content,#vfb-poststuff{background:none!important;padding:0;margin:0;height:auto}#wpadminbar,#adminmenuwrap,#adminmenushadow,#adminmenuback,.screen-reader-shortcut,#screen-meta,#screen-meta-links,#wpfooter,#icon-options-general,.wrap h2,.view-entry,#major-publishing-actions,.clear{display:none}#wpcontent,body #wpcontent{margin-left:0;width:auto;height:auto}#entry-edit h3 span{font-size:23px;font-weight:normal}#vfb-poststuff{page-break-after:auto}#vfb-entries-body-content{width:100%;height:auto;margin:0 0 50px 0;padding:0}#side-info-column{width:100%;height:auto;float:none}#side-info-column .postbox .inside{margin:0;padding:0}#minor-publishing,.misc-pub-section,#submitdiv,#submitdiv h3{background:none!important;border:0;margin:0}#submitdiv h3 span{font-family:sans-serif;font-size:16px}.inner-sidebar #side-sortables,.columns-2 .inner-sidebar #side-sortables{margin:0;padding:0;width:auto}table{page-break-inside:auto}tr textarea{overflow:visible}}@media print,(-o-min-device-pixel-ratio:5/4),(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.vfb-interface-icon{top:5px;background-image:url('../images/vfb-interface-icons-2x.png?d=20130712');background-size:cover}.vfb-draggable-form-items b{background-image:url('../images/vfb-form-items-2x.png?d=20130712');background-size:cover}.vfb-add-options-group .vfb-interface-plus{top:5px}.addEmail,.deleteEmail{top:28px}.item-edit{background-image:url('../images/arrows-2x.png?d=20130611');background-size:15px 123px}.admin-color-classic .item-edit{background-image:url('../images/arrows-vs-2x.png?d=20130611');background-size:15px 123px}.item-edit:hover{background-image:url('../images/arrows-dark-2x.png?d=20130611');background-size:15px 123px}.admin-color-classic .item-edit:hover{background-image:url('../images/arrows-dark-vs-2x.png?d=20130611');background-size:15px 123px}.item-edit.opened{background-image:url('../images/arrows-2x.png?d=20130611');background-size:15px 123px}.admin-color-classic .item-edit.opened{background-image:url('../images/arrows-vs-2x.png?d=20130611');background-size:15px 123px}.item-edit.opened:hover{background-image:url('../images/arrows-dark-2x.png?d=20130611');background-size:15px 123px}.admin-color-classic .item-edit.opened:hover{background-image:url('../images/arrows-dark-vs-2x.png?d=20130611');background-size:15px 123px}.button-icon.vfb-small-arrow{background-image:url('../images/arrows-2x.png?d=20130611');background-size:15px 123px}.admin-color-classic .button-icon.vfb-small-arrow{background-image:url('../images/arrows-vs-2x.png?d=20130611');background-size:15px 123px}.current .button-icon.vfb-small-arrow{background-image:url('../images/arrows-2x.png?d=20130611');background-size:15px 123px}.admin-color-classic .current .button-icon.vfb-small-arrow{background-image:url('../images/arrows-vs.png?d=20130611');background-size:15px 123px}}
 
inc/class-i18n.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Define the internationalization functionality.
4
+ *
5
+ * Loads and defines the internationalization files for this plugin
6
+ * so that its ready for translation.
7
+ *
8
+ * @since 1.0
9
+ */
10
+ class Visual_Form_Builder_i18n {
11
+
12
+ /**
13
+ * The domain specified for this plugin.
14
+ *
15
+ * @since 1.0
16
+ * @access private
17
+ * @var string $domain The domain identifier for this plugin.
18
+ */
19
+ private $domain;
20
+
21
+ /**
22
+ * Load the plugin text domain for translation.
23
+ *
24
+ * @since 1.0
25
+ */
26
+ public function load_lang() {
27
+
28
+ // The "plugin_locale" filter is also used in load_plugin_textdomain()
29
+ $locale = apply_filters( 'plugin_locale', get_locale(), $this->domain );
30
+
31
+ $wp_lang_dir = WP_LANG_DIR . '/' . $this->domain . '/' . $locale . '.mo';
32
+
33
+ // Load translated strings from WP_LANG_DIR
34
+ load_textdomain( $this->domain, $wp_lang_dir );
35
+
36
+ // Main plugin path
37
+ $plugin_dir = VFB_WP_PLUGIN_FILE;
38
+
39
+ // Lang folder path
40
+ $lang_dir = dirname( plugin_basename( $plugin_dir ) ) . '/lang/';
41
+
42
+ // Load translated strings, if no WP_LANG_DIR found
43
+ load_plugin_textdomain( $this->domain, false, $lang_dir );
44
+
45
+ }
46
+
47
+ /**
48
+ * Set the domain equal to that of the specified domain.
49
+ *
50
+ * @since 1.0
51
+ * @param string $domain The domain that represents the locale of this plugin.
52
+ */
53
+ public function set_domain( $domain ) {
54
+ $this->domain = $domain;
55
+ }
56
+
57
+ }
inc/class-install.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Visual_Form_Builder_Install {
4
+ /**
5
+ * Initial setup
6
+ */
7
+ public function __construct() {
8
+ }
9
+
10
+ /**
11
+ * Check DB version and run SQL install, if needed
12
+ * @return [type] [description]
13
+ */
14
+ public function upgrade_db_check() {
15
+ $current_db_version = VFB_WP_DB_VERSION;
16
+
17
+ if ( get_site_option( 'vfb_db_version' ) != $current_db_version )
18
+ $this->install_db();
19
+ }
20
+
21
+ public function install_db() {
22
+ global $wpdb;
23
+
24
+ $charset_collate = $wpdb->get_charset_collate();
25
+
26
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
27
+
28
+ // Forms table
29
+ $sql = "CREATE TABLE " . VFB_WP_FORMS_TABLE_NAME . " (
30
+ form_id BIGINT(20) NOT NULL AUTO_INCREMENT,
31
+ form_key TINYTEXT NOT NULL,
32
+ form_title TEXT NOT NULL,
33
+ form_email_subject TEXT,
34
+ form_email_to TEXT,
35
+ form_email_from VARCHAR(255),
36
+ form_email_from_name VARCHAR(255),
37
+ form_email_from_override VARCHAR(255),
38
+ form_email_from_name_override VARCHAR(255),
39
+ form_success_type VARCHAR(25) DEFAULT 'text',
40
+ form_success_message TEXT,
41
+ form_notification_setting VARCHAR(25),
42
+ form_notification_email_name VARCHAR(255),
43
+ form_notification_email_from VARCHAR(255),
44
+ form_notification_email VARCHAR(25),
45
+ form_notification_subject VARCHAR(255),
46
+ form_notification_message TEXT,
47
+ form_notification_entry VARCHAR(25),
48
+ form_label_alignment VARCHAR(25),
49
+ PRIMARY KEY (form_id)
50
+ ) $charset_collate;";
51
+
52
+ dbDelta( $sql );
53
+
54
+ // Fields table
55
+ $sql = "CREATE TABLE " . VFB_WP_FIELDS_TABLE_NAME . " (
56
+ field_id BIGINT(20) NOT NULL AUTO_INCREMENT,
57
+ form_id BIGINT(20) NOT NULL,
58
+ field_key VARCHAR(255) NOT NULL,
59
+ field_type VARCHAR(25) NOT NULL,
60
+ field_options TEXT,
61
+ field_description TEXT,
62
+ field_name TEXT NOT NULL,
63
+ field_sequence BIGINT(20) DEFAULT '0',
64
+ field_parent BIGINT(20) DEFAULT '0',
65
+ field_validation VARCHAR(25),
66
+ field_required VARCHAR(25),
67
+ field_size VARCHAR(25) DEFAULT 'medium',
68
+ field_css VARCHAR(255),
69
+ field_layout VARCHAR(255),
70
+ field_default TEXT,
71
+ PRIMARY KEY (field_id)
72
+ ) $charset_collate;";
73
+
74
+ dbDelta( $sql );
75
+
76
+ // Entries table
77
+ $sql = "CREATE TABLE " . VFB_WP_ENTRIES_TABLE_NAME . " (
78
+ entries_id BIGINT(20) NOT NULL AUTO_INCREMENT,
79
+ form_id BIGINT(20) NOT NULL,
80
+ data LONGTEXT NOT NULL,
81
+ subject TEXT,
82
+ sender_name VARCHAR(255),
83
+ sender_email VARCHAR(255),
84
+ emails_to TEXT,
85
+ date_submitted DATETIME,
86
+ ip_address VARCHAR(50),
87
+ entry_approved VARCHAR(20) DEFAULT '1',
88
+ PRIMARY KEY (entries_id)
89
+ ) $charset_collate;";
90
+
91
+ dbDelta( $sql );
92
+
93
+ update_option( 'vfb_db_version', VFB_WP_DB_VERSION );
94
+ }
95
+
96
+ /**
97
+ * A wrapper to check DB version which then calls install_db
98
+ * @return [type] [description]
99
+ */
100
+ public function install() {
101
+ $this->upgrade_db_check();
102
+ }
103
+ }
inc/class-list-table.php ADDED
@@ -0,0 +1,1365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Base class for displaying a list of items in an ajaxified HTML table.
4
+ * A copy of the WP_List_Table class
5
+ *
6
+ * @since 3.1.0
7
+ * @access private
8
+ *
9
+ * @package WordPress
10
+ * @subpackage List_Table
11
+ */
12
+ class Visual_Form_Builder_List_Table {
13
+
14
+ /**
15
+ * The current list of items.
16
+ *
17
+ * @since 3.1.0
18
+ * @var array
19
+ * @access public
20
+ */
21
+ public $items;
22
+
23
+ /**
24
+ * Various information about the current table.
25
+ *
26
+ * @since 3.1.0
27
+ * @var array
28
+ * @access protected
29
+ */
30
+ protected $_args;
31
+
32
+ /**
33
+ * Various information needed for displaying the pagination.
34
+ *
35
+ * @since 3.1.0
36
+ * @var array
37
+ */
38
+ protected $_pagination_args = array();
39
+
40
+ /**
41
+ * The current screen.
42
+ *
43
+ * @since 3.1.0
44
+ * @var object
45
+ * @access protected
46
+ */
47
+ protected $screen;
48
+
49
+ /**
50
+ * Cached bulk actions.
51
+ *
52
+ * @since 3.1.0
53
+ * @var array
54
+ * @access private
55
+ */
56
+ private $_actions;
57
+
58
+ /**
59
+ * Cached pagination output.
60
+ *
61
+ * @since 3.1.0
62
+ * @var string
63
+ * @access private
64
+ */
65
+ private $_pagination;
66
+
67
+ /**
68
+ * The view switcher modes.
69
+ *
70
+ * @since 4.1.0
71
+ * @var array
72
+ * @access protected
73
+ */
74
+ protected $modes = array();
75
+
76
+ /**
77
+ * Stores the value returned by ->get_column_info()
78
+ *
79
+ * @var array
80
+ */
81
+ protected $_column_headers;
82
+
83
+ /**
84
+ * [protected description]
85
+ * @var array
86
+ */
87
+ protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' );
88
+
89
+ /**
90
+ * [protected description]
91
+ * @var array
92
+ */
93
+ protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions',
94
+ 'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination',
95
+ 'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav',
96
+ 'single_row_columns' );
97
+
98
+ /**
99
+ * Constructor.
100
+ *
101
+ * The child class should call this constructor from its own constructor to override
102
+ * the default $args.
103
+ *
104
+ * @since 3.1.0
105
+ * @access public
106
+ *
107
+ * @param array|string $args {
108
+ * Array or string of arguments.
109
+ *
110
+ * @type string $plural Plural value used for labels and the objects being listed.
111
+ * This affects things such as CSS class-names and nonces used
112
+ * in the list table, e.g. 'posts'. Default empty.
113
+ * @type string $singular Singular label for an object being listed, e.g. 'post'.
114
+ * Default empty
115
+ * @type bool $ajax Whether the list table supports AJAX. This includes loading
116
+ * and sorting data, for example. If true, the class will call
117
+ * the {@see _js_vars()} method in the footer to provide variables
118
+ * to any scripts handling AJAX events. Default false.
119
+ * @type string $screen String containing the hook name used to determine the current
120
+ * screen. If left null, the current screen will be automatically set.
121
+ * Default null.
122
+ * }
123
+ */
124
+ public function __construct( $args = array() ) {
125
+ $args = wp_parse_args( $args, array(
126
+ 'plural' => '',
127
+ 'singular' => '',
128
+ 'ajax' => false,
129
+ 'screen' => null,
130
+ ) );
131
+
132
+ $this->screen = convert_to_screen( $args['screen'] );
133
+
134
+ add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
135
+
136
+ if ( !$args['plural'] )
137
+ $args['plural'] = $this->screen->base;
138
+
139
+ $args['plural'] = sanitize_key( $args['plural'] );
140
+ $args['singular'] = sanitize_key( $args['singular'] );
141
+
142
+ $this->_args = $args;
143
+
144
+ if ( $args['ajax'] ) {
145
+ // wp_enqueue_script( 'list-table' );
146
+ add_action( 'admin_footer', array( $this, '_js_vars' ) );
147
+ }
148
+
149
+ if ( empty( $this->modes ) ) {
150
+ $this->modes = array(
151
+ 'list' => __( 'List View' ),
152
+ 'excerpt' => __( 'Excerpt View' )
153
+ );
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Make private properties readable for backwards compatibility.
159
+ *
160
+ * @since 4.0.0
161
+ * @access public
162
+ *
163
+ * @param string $name Property to get.
164
+ * @return mixed Property.
165
+ */
166
+ public function __get( $name ) {
167
+ if ( in_array( $name, $this->compat_fields ) ) {
168
+ return $this->$name;
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Make private properties settable for backwards compatibility.
174
+ *
175
+ * @since 4.0.0
176
+ * @access public
177
+ *
178
+ * @param string $name Property to check if set.
179
+ * @param mixed $value Property value.
180
+ * @return mixed Newly-set property.
181
+ */
182
+ public function __set( $name, $value ) {
183
+ if ( in_array( $name, $this->compat_fields ) ) {
184
+ return $this->$name = $value;
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Make private properties checkable for backwards compatibility.
190
+ *
191
+ * @since 4.0.0
192
+ * @access public
193
+ *
194
+ * @param string $name Property to check if set.
195
+ * @return bool Whether the property is set.
196
+ */
197
+ public function __isset( $name ) {
198
+ if ( in_array( $name, $this->compat_fields ) ) {
199
+ return isset( $this->$name );
200
+ }
201
+ }
202
+
203
+ /**
204
+ * Make private properties un-settable for backwards compatibility.
205
+ *
206
+ * @since 4.0.0
207
+ * @access public
208
+ *
209
+ * @param string $name Property to unset.
210
+ */
211
+ public function __unset( $name ) {
212
+ if ( in_array( $name, $this->compat_fields ) ) {
213
+ unset( $this->$name );
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Make private/protected methods readable for backwards compatibility.
219
+ *
220
+ * @since 4.0.0
221
+ * @access public
222
+ *
223
+ * @param callable $name Method to call.
224
+ * @param array $arguments Arguments to pass when calling.
225
+ * @return mixed|bool Return value of the callback, false otherwise.
226
+ */
227
+ public function __call( $name, $arguments ) {
228
+ if ( in_array( $name, $this->compat_methods ) ) {
229
+ return call_user_func_array( array( $this, $name ), $arguments );
230
+ }
231
+ return false;
232
+ }
233
+
234
+ /**
235
+ * Checks the current user's permissions
236
+ *
237
+ * @since 3.1.0
238
+ * @access public
239
+ * @abstract
240
+ */
241
+ public function ajax_user_can() {
242
+ die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' );
243
+ }
244
+
245
+ /**
246
+ * Prepares the list of items for displaying.
247
+ * @uses WP_List_Table::set_pagination_args()
248
+ *
249
+ * @since 3.1.0
250
+ * @access public
251
+ * @abstract
252
+ */
253
+ public function prepare_items() {
254
+ die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' );
255
+ }
256
+
257
+ /**
258
+ * An internal method that sets all the necessary pagination arguments
259
+ *
260
+ * @param array $args An associative array with information about the pagination
261
+ * @access protected
262
+ *
263
+ * @param array|string $args Array or string of arguments with information about the pagination.
264
+ */
265
+ protected function set_pagination_args( $args ) {
266
+ $args = wp_parse_args( $args, array(
267
+ 'total_items' => 0,
268
+ 'total_pages' => 0,
269
+ 'per_page' => 0,
270
+ ) );
271
+
272
+ if ( !$args['total_pages'] && $args['per_page'] > 0 )
273
+ $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
274
+
275
+ // Redirect if page number is invalid and headers are not already sent.
276
+ if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
277
+ wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
278
+ exit;
279
+ }
280
+
281
+ $this->_pagination_args = $args;
282
+ }
283
+
284
+ /**
285
+ * Access the pagination args.
286
+ *
287
+ * @since 3.1.0
288
+ * @access public
289
+ *
290
+ * @param string $key Pagination argument to retrieve. Common values include 'total_items',
291
+ * 'total_pages', 'per_page', or 'infinite_scroll'.
292
+ * @return int Number of items that correspond to the given pagination argument.
293
+ */
294
+ public function get_pagination_arg( $key ) {
295
+ if ( 'page' === $key ) {
296
+ return $this->get_pagenum();
297
+ }
298
+
299
+ if ( isset( $this->_pagination_args[$key] ) ) {
300
+ return $this->_pagination_args[$key];
301
+ }
302
+ }
303
+
304
+ /**
305
+ * Whether the table has items to display or not
306
+ *
307
+ * @since 3.1.0
308
+ * @access public
309
+ *
310
+ * @return bool
311
+ */
312
+ public function has_items() {
313
+ return !empty( $this->items );
314
+ }
315
+
316
+ /**
317
+ * Message to be displayed when there are no items
318
+ *
319
+ * @since 3.1.0
320
+ * @access public
321
+ */
322
+ public function no_items() {
323
+ _e( 'No items found.' );
324
+ }
325
+
326
+ /**
327
+ * Display the search box.
328
+ *
329
+ * @since 3.1.0
330
+ * @access public
331
+ *
332
+ * @param string $text The search button text
333
+ * @param string $input_id The search input id
334
+ */
335
+ public function search_box( $text, $input_id ) {
336
+ if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
337
+ return;
338
+
339
+ $input_id = $input_id . '-search-input';
340
+
341
+ if ( ! empty( $_REQUEST['orderby'] ) )
342
+ echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
343
+ if ( ! empty( $_REQUEST['order'] ) )
344
+ echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
345
+ if ( ! empty( $_REQUEST['post_mime_type'] ) )
346
+ echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
347
+ if ( ! empty( $_REQUEST['detached'] ) )
348
+ echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
349
+ ?>
350
+ <p class="search-box">
351
+ <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
352
+ <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" />
353
+ <?php submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); ?>
354
+ </p>
355
+ <?php
356
+ }
357
+
358
+ /**
359
+ * Get an associative array ( id => link ) with the list
360
+ * of views available on this table.
361
+ *
362
+ * @since 3.1.0
363
+ * @access protected
364
+ *
365
+ * @return array
366
+ */
367
+ protected function get_views() {
368
+ return array();
369
+ }
370
+
371
+ /**
372
+ * Display the list of views available on this table.
373
+ *
374
+ * @since 3.1.0
375
+ * @access public
376
+ */
377
+ public function views() {
378
+ $views = $this->get_views();
379
+ /**
380
+ * Filter the list of available list table views.
381
+ *
382
+ * The dynamic portion of the hook name, `$this->screen->id`, refers
383
+ * to the ID of the current screen, usually a string.
384
+ *
385
+ * @since 3.5.0
386
+ *
387
+ * @param array $views An array of available list table views.
388
+ */
389
+ $views = apply_filters( "views_{$this->screen->id}", $views );
390
+
391
+ if ( empty( $views ) )
392
+ return;
393
+
394
+ $this->screen->render_screen_reader_content( 'heading_views' );
395
+
396
+ echo "<ul class='subsubsub'>\n";
397
+ foreach ( $views as $class => $view ) {
398
+ $views[ $class ] = "\t<li class='$class'>$view";
399
+ }
400
+ echo implode( " |</li>\n", $views ) . "</li>\n";
401
+ echo "</ul>";
402
+ }
403
+
404
+ /**
405
+ * Get an associative array ( option_name => option_title ) with the list
406
+ * of bulk actions available on this table.
407
+ *
408
+ * @since 3.1.0
409
+ * @access protected
410
+ *
411
+ * @return array
412
+ */
413
+ protected function get_bulk_actions() {
414
+ return array();
415
+ }
416
+
417
+ /**
418
+ * Display the bulk actions dropdown.
419
+ *
420
+ * @since 3.1.0
421
+ * @access protected
422
+ *
423
+ * @param string $which The location of the bulk actions: 'top' or 'bottom'.
424
+ * This is designated as optional for backward compatibility.
425
+ */
426
+ protected function bulk_actions( $which = '' ) {
427
+ if ( is_null( $this->_actions ) ) {
428
+ $this->_actions = $this->get_bulk_actions();
429
+ /**
430
+ * Filters the list table Bulk Actions drop-down.
431
+ *
432
+ * The dynamic portion of the hook name, `$this->screen->id`, refers
433
+ * to the ID of the current screen, usually a string.
434
+ *
435
+ * This filter can currently only be used to remove bulk actions.
436
+ *
437
+ * @since 3.5.0
438
+ *
439
+ * @param array $actions An array of the available bulk actions.
440
+ */
441
+ $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
442
+ $two = '';
443
+ } else {
444
+ $two = '2';
445
+ }
446
+
447
+ if ( empty( $this->_actions ) )
448
+ return;
449
+
450
+ echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
451
+ echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
452
+ echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>\n";
453
+
454
+ foreach ( $this->_actions as $name => $title ) {
455
+ $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
456
+
457
+ echo "\t" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>\n";
458
+ }
459
+
460
+ echo "</select>\n";
461
+
462
+ submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
463
+ echo "\n";
464
+ }
465
+
466
+ /**
467
+ * Get the current action selected from the bulk actions dropdown.
468
+ *
469
+ * @since 3.1.0
470
+ * @access public
471
+ *
472
+ * @return string|false The action name or False if no action was selected
473
+ */
474
+ public function current_action() {
475
+ if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) )
476
+ return false;
477
+
478
+ if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
479
+ return $_REQUEST['action'];
480
+
481
+ if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
482
+ return $_REQUEST['action2'];
483
+
484
+ return false;
485
+ }
486
+
487
+ /**
488
+ * Generate row actions div
489
+ *
490
+ * @since 3.1.0
491
+ * @access protected
492
+ *
493
+ * @param array $actions The list of actions
494
+ * @param bool $always_visible Whether the actions should be always visible
495
+ * @return string
496
+ */
497
+ protected function row_actions( $actions, $always_visible = false ) {
498
+ $action_count = count( $actions );
499
+ $i = 0;
500
+
501
+ if ( !$action_count )
502
+ return '';
503
+
504
+ $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
505
+ foreach ( $actions as $action => $link ) {
506
+ ++$i;
507
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
508
+ $out .= "<span class='$action'>$link$sep</span>";
509
+ }
510
+ $out .= '</div>';
511
+
512
+ $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>';
513
+
514
+ return $out;
515
+ }
516
+
517
+ /**
518
+ * Display a monthly dropdown for filtering items
519
+ *
520
+ * @since 3.1.0
521
+ * @access protected
522
+ *
523
+ * @global wpdb $wpdb
524
+ * @global WP_Locale $wp_locale
525
+ *
526
+ * @param string $post_type
527
+ */
528
+ protected function months_dropdown( $post_type ) {
529
+ global $wpdb, $wp_locale;
530
+
531
+ /**
532
+ * Filters whether to remove the 'Months' drop-down from the post list table.
533
+ *
534
+ * @since 4.2.0
535
+ *
536
+ * @param bool $disable Whether to disable the drop-down. Default false.
537
+ * @param string $post_type The post type.
538
+ */
539
+ if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) {
540
+ return;
541
+ }
542
+
543
+ $extra_checks = "AND post_status != 'auto-draft'";
544
+ if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_status'] ) {
545
+ $extra_checks .= " AND post_status != 'trash'";
546
+ } elseif ( isset( $_GET['post_status'] ) ) {
547
+ $extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_status'] );
548
+ }
549
+
550
+ $months = $wpdb->get_results( $wpdb->prepare( "
551
+ SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
552
+ FROM $wpdb->posts
553
+ WHERE post_type = %s
554
+ $extra_checks
555
+ ORDER BY post_date DESC
556
+ ", $post_type ) );
557
+
558
+ /**
559
+ * Filters the 'Months' drop-down results.
560
+ *
561
+ * @since 3.7.0
562
+ *
563
+ * @param object $months The months drop-down query results.
564
+ * @param string $post_type The post type.
565
+ */
566
+ $months = apply_filters( 'months_dropdown_results', $months, $post_type );
567
+
568
+ $month_count = count( $months );
569
+
570
+ if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
571
+ return;
572
+
573
+ $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
574
+ ?>
575
+ <label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label>
576
+ <select name="m" id="filter-by-date">
577
+ <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
578
+ <?php
579
+ foreach ( $months as $arc_row ) {
580
+ if ( 0 == $arc_row->year )
581
+ continue;
582
+
583
+ $month = zeroise( $arc_row->month, 2 );
584
+ $year = $arc_row->year;
585
+
586
+ printf( "<option %s value='%s'>%s</option>\n",
587
+ selected( $m, $year . $month, false ),
588
+ esc_attr( $arc_row->year . $month ),
589
+ /* translators: 1: month name, 2: 4-digit year */
590
+ sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
591
+ );
592
+ }
593
+ ?>
594
+ </select>
595
+ <?php
596
+ }
597
+
598
+ /**
599
+ * Display a view switcher
600
+ *
601
+ * @since 3.1.0
602
+ * @access protected
603
+ *
604
+ * @param string $current_mode
605
+ */
606
+ protected function view_switcher( $current_mode ) {
607
+ ?>
608
+ <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
609
+ <div class="view-switch">
610
+ <?php
611
+ foreach ( $this->modes as $mode => $title ) {
612
+ $classes = array( 'view-' . $mode );
613
+ if ( $current_mode === $mode )
614
+ $classes[] = 'current';
615
+ printf(
616
+ "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
617
+ esc_url( add_query_arg( 'mode', $mode ) ),
618
+ implode( ' ', $classes ),
619
+ $title
620
+ );
621
+ }
622
+ ?>
623
+ </div>
624
+ <?php
625
+ }
626
+
627
+ /**
628
+ * Display a comment count bubble
629
+ *
630
+ * @since 3.1.0
631
+ * @access protected
632
+ *
633
+ * @param int $post_id The post ID.
634
+ * @param int $pending_comments Number of pending comments.
635
+ */
636
+ protected function comments_bubble( $post_id, $pending_comments ) {
637
+ $approved_comments = get_comments_number();
638
+
639
+ $approved_comments_number = number_format_i18n( $approved_comments );
640
+ $pending_comments_number = number_format_i18n( $pending_comments );
641
+
642
+ $approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number );
643
+ $approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number );
644
+ $pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );
645
+
646
+ // No comments at all.
647
+ if ( ! $approved_comments && ! $pending_comments ) {
648
+ printf( '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
649
+ __( 'No comments' )
650
+ );
651
+ // Approved comments have different display depending on some conditions.
652
+ } elseif ( $approved_comments ) {
653
+ printf( '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
654
+ esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ),
655
+ $approved_comments_number,
656
+ $pending_comments ? $approved_phrase : $approved_only_phrase
657
+ );
658
+ } else {
659
+ printf( '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
660
+ $approved_comments_number,
661
+ $pending_comments ? __( 'No approved comments' ) : __( 'No comments' )
662
+ );
663
+ }
664
+
665
+ if ( $pending_comments ) {
666
+ printf( '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
667
+ esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ),
668
+ $pending_comments_number,
669
+ $pending_phrase
670
+ );
671
+ } else {
672
+ printf( '<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
673
+ $pending_comments_number,
674
+ $approved_comments ? __( 'No pending comments' ) : __( 'No comments' )
675
+ );
676
+ }
677
+ }
678
+
679
+ /**
680
+ * Get the current page number
681
+ *
682
+ * @since 3.1.0
683
+ * @access public
684
+ *
685
+ * @return int
686
+ */
687
+ public function get_pagenum() {
688
+ $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
689
+
690
+ if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
691
+ $pagenum = $this->_pagination_args['total_pages'];
692
+
693
+ return max( 1, $pagenum );
694
+ }
695
+
696
+ /**
697
+ * Get number of items to display on a single page
698
+ *
699
+ * @since 3.1.0
700
+ * @access protected
701
+ *
702
+ * @param string $option
703
+ * @param int $default
704
+ * @return int
705
+ */
706
+ protected function get_items_per_page( $option, $default = 20 ) {
707
+ $per_page = (int) get_user_option( $option );
708
+ if ( empty( $per_page ) || $per_page < 1 )
709
+ $per_page = $default;
710
+
711
+ /**
712
+ * Filters the number of items to be displayed on each page of the list table.
713
+ *
714
+ * The dynamic hook name, $option, refers to the `per_page` option depending
715
+ * on the type of list table in use. Possible values include: 'edit_comments_per_page',
716
+ * 'sites_network_per_page', 'site_themes_network_per_page', 'themes_network_per_page',
717
+ * 'users_network_per_page', 'edit_post_per_page', 'edit_page_per_page',
718
+ * 'edit_{$post_type}_per_page', etc.
719
+ *
720
+ * @since 2.9.0
721
+ *
722
+ * @param int $per_page Number of items to be displayed. Default 20.
723
+ */
724
+ return (int) apply_filters( "{$option}", $per_page );
725
+ }
726
+
727
+ /**
728
+ * Display the pagination.
729
+ *
730
+ * @since 3.1.0
731
+ * @access protected
732
+ *
733
+ * @param string $which
734
+ */
735
+ protected function pagination( $which ) {
736
+ if ( empty( $this->_pagination_args ) ) {
737
+ return;
738
+ }
739
+
740
+ $total_items = $this->_pagination_args['total_items'];
741
+ $total_pages = $this->_pagination_args['total_pages'];
742
+ $infinite_scroll = false;
743
+ if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
744
+ $infinite_scroll = $this->_pagination_args['infinite_scroll'];
745
+ }
746
+
747
+ if ( 'top' === $which && $total_pages > 1 ) {
748
+ $this->screen->render_screen_reader_content( 'heading_pagination' );
749
+ }
750
+
751
+ $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
752
+
753
+ $current = $this->get_pagenum();
754
+ $removable_query_args = wp_removable_query_args();
755
+
756
+ $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
757
+
758
+ $current_url = remove_query_arg( $removable_query_args, $current_url );
759
+
760
+ $page_links = array();
761
+
762
+ $total_pages_before = '<span class="paging-input">';
763
+ $total_pages_after = '</span></span>';
764
+
765
+ $disable_first = $disable_last = $disable_prev = $disable_next = false;
766
+
767
+ if ( $current == 1 ) {
768
+ $disable_first = true;
769
+ $disable_prev = true;
770
+ }
771
+ if ( $current == 2 ) {
772
+ $disable_first = true;
773
+ }
774
+ if ( $current == $total_pages ) {
775
+ $disable_last = true;
776
+ $disable_next = true;
777
+ }
778
+ if ( $current == $total_pages - 1 ) {
779
+ $disable_last = true;
780
+ }
781
+
782
+ if ( $disable_first ) {
783
+ $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&laquo;</span>';
784
+ } else {
785
+ $page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
786
+ esc_url( remove_query_arg( 'paged', $current_url ) ),
787
+ __( 'First page' ),
788
+ '&laquo;'
789
+ );
790
+ }
791
+
792
+ if ( $disable_prev ) {
793
+ $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&lsaquo;</span>';
794
+ } else {
795
+ $page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
796
+ esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
797
+ __( 'Previous page' ),
798
+ '&lsaquo;'
799
+ );
800
+ }
801
+
802
+ if ( 'bottom' === $which ) {
803
+ $html_current_page = $current;
804
+ $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
805
+ } else {
806
+ $html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
807
+ '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
808
+ $current,
809
+ strlen( $total_pages )
810
+ );
811
+ }
812
+ $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
813
+ $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
814
+
815
+ if ( $disable_next ) {
816
+ $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&rsaquo;</span>';
817
+ } else {
818
+ $page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
819
+ esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
820
+ __( 'Next page' ),
821
+ '&rsaquo;'
822
+ );
823
+ }
824
+
825
+ if ( $disable_last ) {
826
+ $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo;</span>';
827
+ } else {
828
+ $page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
829
+ esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
830
+ __( 'Last page' ),
831
+ '&raquo;'
832
+ );
833
+ }
834
+
835
+ $pagination_links_class = 'pagination-links';
836
+ if ( ! empty( $infinite_scroll ) ) {
837
+ $pagination_links_class .= ' hide-if-js';
838
+ }
839
+ $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
840
+
841
+ if ( $total_pages ) {
842
+ $page_class = $total_pages < 2 ? ' one-page' : '';
843
+ } else {
844
+ $page_class = ' no-pages';
845
+ }
846
+ $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
847
+
848
+ echo $this->_pagination;
849
+ }
850
+
851
+ /**
852
+ * Get a list of columns. The format is:
853
+ * 'internal-name' => 'Title'
854
+ *
855
+ * @since 3.1.0
856
+ * @access public
857
+ * @abstract
858
+ *
859
+ * @return array
860
+ */
861
+ public function get_columns() {
862
+ die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
863
+ }
864
+
865
+ /**
866
+ * Get a list of sortable columns. The format is:
867
+ * 'internal-name' => 'orderby'
868
+ * or
869
+ * 'internal-name' => array( 'orderby', true )
870
+ *
871
+ * The second format will make the initial sorting order be descending
872
+ *
873
+ * @since 3.1.0
874
+ * @access protected
875
+ *
876
+ * @return array
877
+ */
878
+ protected function get_sortable_columns() {
879
+ return array();
880
+ }
881
+
882
+ /**
883
+ * Gets the name of the default primary column.
884
+ *
885
+ * @since 4.3.0
886
+ * @access protected
887
+ *
888
+ * @return string Name of the default primary column, in this case, an empty string.
889
+ */
890
+ protected function get_default_primary_column_name() {
891
+ $columns = $this->get_columns();
892
+ $column = '';
893
+
894
+ if ( empty( $columns ) ) {
895
+ return $column;
896
+ }
897
+
898
+ // We need a primary defined so responsive views show something,
899
+ // so let's fall back to the first non-checkbox column.
900
+ foreach ( $columns as $col => $column_name ) {
901
+ if ( 'cb' === $col ) {
902
+ continue;
903
+ }
904
+
905
+ $column = $col;
906
+ break;
907
+ }
908
+
909
+ return $column;
910
+ }
911
+
912
+ /**
913
+ * Public wrapper for Visual_Form_Builder_List_Table::get_default_primary_column_name().
914
+ *
915
+ * @since 4.4.0
916
+ *
917
+ * @return string Name of the default primary column.
918
+ */
919
+ public function get_primary_column() {
920
+ return $this->get_primary_column_name();
921
+ }
922
+
923
+ /**
924
+ * Gets the name of the primary column.
925
+ *
926
+ * @since 4.3.0
927
+ * @access protected
928
+ *
929
+ * @return string The name of the primary column.
930
+ */
931
+ protected function get_primary_column_name() {
932
+ $columns = get_column_headers( $this->screen );
933
+ $default = $this->get_default_primary_column_name();
934
+
935
+ // If the primary column doesn't exist fall back to the
936
+ // first non-checkbox column.
937
+ if ( ! isset( $columns[ $default ] ) ) {
938
+ $default = Visual_Form_Builder_List_Table::get_default_primary_column_name();
939
+ }
940
+
941
+ /**
942
+ * Filters the name of the primary column for the current list table.
943
+ *
944
+ * @since 4.3.0
945
+ *
946
+ * @param string $default Column name default for the specific list table, e.g. 'name'.
947
+ * @param string $context Screen ID for specific list table, e.g. 'plugins'.
948
+ */
949
+ $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
950
+
951
+ if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
952
+ $column = $default;
953
+ }
954
+
955
+ return $column;
956
+ }
957
+
958
+ /**
959
+ * Get a list of all, hidden and sortable columns, with filter applied
960
+ *
961
+ * @since 3.1.0
962
+ * @access protected
963
+ *
964
+ * @return array
965
+ */
966
+ protected function get_column_info() {
967
+ // $_column_headers is already set / cached
968
+ if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) {
969
+ // Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
970
+ // In 4.3, we added a fourth argument for primary column.
971
+ $column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
972
+ foreach ( $this->_column_headers as $key => $value ) {
973
+ $column_headers[ $key ] = $value;
974
+ }
975
+
976
+ return $column_headers;
977
+ }
978
+
979
+ $columns = get_column_headers( $this->screen );
980
+ $hidden = get_hidden_columns( $this->screen );
981
+
982
+ $sortable_columns = $this->get_sortable_columns();
983
+ /**
984
+ * Filters the list table sortable columns for a specific screen.
985
+ *
986
+ * The dynamic portion of the hook name, `$this->screen->id`, refers
987
+ * to the ID of the current screen, usually a string.
988
+ *
989
+ * @since 3.5.0
990
+ *
991
+ * @param array $sortable_columns An array of sortable columns.
992
+ */
993
+ $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
994
+
995
+ $sortable = array();
996
+ foreach ( $_sortable as $id => $data ) {
997
+ if ( empty( $data ) )
998
+ continue;
999
+
1000
+ $data = (array) $data;
1001
+ if ( !isset( $data[1] ) )
1002
+ $data[1] = false;
1003
+
1004
+ $sortable[$id] = $data;
1005
+ }
1006
+
1007
+ $primary = $this->get_primary_column_name();
1008
+ $this->_column_headers = array( $columns, $hidden, $sortable, $primary );
1009
+
1010
+ return $this->_column_headers;
1011
+ }
1012
+
1013
+ /**
1014
+ * Return number of visible columns
1015
+ *
1016
+ * @since 3.1.0
1017
+ * @access public
1018
+ *
1019
+ * @return int
1020
+ */
1021
+ public function get_column_count() {
1022
+ list ( $columns, $hidden ) = $this->get_column_info();
1023
+ $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
1024
+ return count( $columns ) - count( $hidden );
1025
+ }
1026
+
1027
+ /**
1028
+ * Print column headers, accounting for hidden and sortable columns.
1029
+ *
1030
+ * @since 3.1.0
1031
+ * @access public
1032
+ *
1033
+ * @staticvar int $cb_counter
1034
+ *
1035
+ * @param bool $with_id Whether to set the id attribute or not
1036
+ */
1037
+ public function print_column_headers( $with_id = true ) {
1038
+ list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
1039
+
1040
+ $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1041
+ $current_url = remove_query_arg( 'paged', $current_url );
1042
+
1043
+ if ( isset( $_GET['orderby'] ) ) {
1044
+ $current_orderby = $_GET['orderby'];
1045
+ } else {
1046
+ $current_orderby = '';
1047
+ }
1048
+
1049
+ if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) {
1050
+ $current_order = 'desc';
1051
+ } else {
1052
+ $current_order = 'asc';
1053
+ }
1054
+
1055
+ if ( ! empty( $columns['cb'] ) ) {
1056
+ static $cb_counter = 1;
1057
+ $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
1058
+ . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
1059
+ $cb_counter++;
1060
+ }
1061
+
1062
+ foreach ( $columns as $column_key => $column_display_name ) {
1063
+ $class = array( 'manage-column', "column-$column_key" );
1064
+
1065
+ if ( in_array( $column_key, $hidden ) ) {
1066
+ $class[] = 'hidden';
1067
+ }
1068
+
1069
+ if ( 'cb' === $column_key )
1070
+ $class[] = 'check-column';
1071
+ elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
1072
+ $class[] = 'num';
1073
+
1074
+ if ( $column_key === $primary ) {
1075
+ $class[] = 'column-primary';
1076
+ }
1077
+
1078
+ if ( isset( $sortable[$column_key] ) ) {
1079
+ list( $orderby, $desc_first ) = $sortable[$column_key];
1080
+
1081
+ if ( $current_orderby === $orderby ) {
1082
+ $order = 'asc' === $current_order ? 'desc' : 'asc';
1083
+ $class[] = 'sorted';
1084
+ $class[] = $current_order;
1085
+ } else {
1086
+ $order = $desc_first ? 'desc' : 'asc';
1087
+ $class[] = 'sortable';
1088
+ $class[] = $desc_first ? 'asc' : 'desc';
1089
+ }
1090
+
1091
+ $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
1092
+ }
1093
+
1094
+ $tag = ( 'cb' === $column_key ) ? 'td' : 'th';
1095
+ $scope = ( 'th' === $tag ) ? 'scope="col"' : '';
1096
+ $id = $with_id ? "id='$column_key'" : '';
1097
+
1098
+ if ( !empty( $class ) )
1099
+ $class = "class='" . join( ' ', $class ) . "'";
1100
+
1101
+ echo "<$tag $scope $id $class>$column_display_name</$tag>";
1102
+ }
1103
+ }
1104
+
1105
+ /**
1106
+ * Display the table
1107
+ *
1108
+ * @since 3.1.0
1109
+ * @access public
1110
+ */
1111
+ public function display() {
1112
+ $singular = $this->_args['singular'];
1113
+
1114
+ $this->display_tablenav( 'top' );
1115
+
1116
+ $this->screen->render_screen_reader_content( 'heading_list' );
1117
+ ?>
1118
+ <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
1119
+ <thead>
1120
+ <tr>
1121
+ <?php $this->print_column_headers(); ?>
1122
+ </tr>
1123
+ </thead>
1124
+
1125
+ <tbody id="the-list"<?php
1126
+ if ( $singular ) {
1127
+ echo " data-wp-lists='list:$singular'";
1128
+ } ?>>
1129
+ <?php $this->display_rows_or_placeholder(); ?>
1130
+ </tbody>
1131
+
1132
+ <tfoot>
1133
+ <tr>
1134
+ <?php $this->print_column_headers( false ); ?>
1135
+ </tr>
1136
+ </tfoot>
1137
+
1138
+ </table>
1139
+ <?php
1140
+ $this->display_tablenav( 'bottom' );
1141
+ }
1142
+
1143
+ /**
1144
+ * Get a list of CSS classes for the list table table tag.
1145
+ *
1146
+ * @since 3.1.0
1147
+ * @access protected
1148
+ *
1149
+ * @return array List of CSS classes for the table tag.
1150
+ */
1151
+ protected function get_table_classes() {
1152
+ return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] );
1153
+ }
1154
+
1155
+ /**
1156
+ * Generate the table navigation above or below the table
1157
+ *
1158
+ * @since 3.1.0
1159
+ * @access protected
1160
+ * @param string $which
1161
+ */
1162
+ protected function display_tablenav( $which ) {
1163
+ if ( 'top' === $which ) {
1164
+ wp_nonce_field( 'bulk-' . $this->_args['plural'] );
1165
+ }
1166
+ ?>
1167
+ <div class="tablenav <?php echo esc_attr( $which ); ?>">
1168
+
1169
+ <?php if ( $this->has_items() ): ?>
1170
+ <div class="alignleft actions bulkactions">
1171
+ <?php $this->bulk_actions( $which ); ?>
1172
+ </div>
1173
+ <?php endif;
1174
+ $this->extra_tablenav( $which );
1175
+ $this->pagination( $which );
1176
+ ?>
1177
+
1178
+ <br class="clear" />
1179
+ </div>
1180
+ <?php
1181
+ }
1182
+
1183
+ /**
1184
+ * Extra controls to be displayed between bulk actions and pagination
1185
+ *
1186
+ * @since 3.1.0
1187
+ * @access protected
1188
+ *
1189
+ * @param string $which
1190
+ */
1191
+ protected function extra_tablenav( $which ) {}
1192
+
1193
+ /**
1194
+ * Generate the tbody element for the list table.
1195
+ *
1196
+ * @since 3.1.0
1197
+ * @access public
1198
+ */
1199
+ public function display_rows_or_placeholder() {
1200
+ if ( $this->has_items() ) {
1201
+ $this->display_rows();
1202
+ } else {
1203
+ echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
1204
+ $this->no_items();
1205
+ echo '</td></tr>';
1206
+ }
1207
+ }
1208
+
1209
+ /**
1210
+ * Generate the table rows
1211
+ *
1212
+ * @since 3.1.0
1213
+ * @access public
1214
+ */
1215
+ public function display_rows() {
1216
+ foreach ( $this->items as $item )
1217
+ $this->single_row( $item );
1218
+ }
1219
+
1220
+ /**
1221
+ * Generates content for a single row of the table
1222
+ *
1223
+ * @since 3.1.0
1224
+ * @access public
1225
+ *
1226
+ * @param object $item The current item
1227
+ */
1228
+ public function single_row( $item ) {
1229
+ echo '<tr>';
1230
+ $this->single_row_columns( $item );
1231
+ echo '</tr>';
1232
+ }
1233
+
1234
+ /**
1235
+ *
1236
+ * @param object $item
1237
+ * @param string $column_name
1238
+ */
1239
+ protected function column_default( $item, $column_name ) {}
1240
+
1241
+ /**
1242
+ *
1243
+ * @param object $item
1244
+ */
1245
+ protected function column_cb( $item ) {}
1246
+
1247
+ /**
1248
+ * Generates the columns for a single row of the table
1249
+ *
1250
+ * @since 3.1.0
1251
+ * @access protected
1252
+ *
1253
+ * @param object $item The current item
1254
+ */
1255
+ protected function single_row_columns( $item ) {
1256
+ list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
1257
+
1258
+ foreach ( $columns as $column_name => $column_display_name ) {
1259
+ $classes = "$column_name column-$column_name";
1260
+ if ( $primary === $column_name ) {
1261
+ $classes .= ' has-row-actions column-primary';
1262
+ }
1263
+
1264
+ if ( in_array( $column_name, $hidden ) ) {
1265
+ $classes .= ' hidden';
1266
+ }
1267
+
1268
+ // Comments column uses HTML in the display name with screen reader text.
1269
+ // Instead of using esc_attr(), we strip tags to get closer to a user-friendly string.
1270
+ $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"';
1271
+
1272
+ $attributes = "class='$classes' $data";
1273
+
1274
+ if ( 'cb' === $column_name ) {
1275
+ echo '<th scope="row" class="check-column">';
1276
+ echo $this->column_cb( $item );
1277
+ echo '</th>';
1278
+ } elseif ( method_exists( $this, '_column_' . $column_name ) ) {
1279
+ echo call_user_func(
1280
+ array( $this, '_column_' . $column_name ),
1281
+ $item,
1282
+ $classes,
1283
+ $data,
1284
+ $primary
1285
+ );
1286
+ } elseif ( method_exists( $this, 'column_' . $column_name ) ) {
1287
+ echo "<td $attributes>";
1288
+ echo call_user_func( array( $this, 'column_' . $column_name ), $item );
1289
+ echo $this->handle_row_actions( $item, $column_name, $primary );
1290
+ echo "</td>";
1291
+ } else {
1292
+ echo "<td $attributes>";
1293
+ echo $this->column_default( $item, $column_name );
1294
+ echo $this->handle_row_actions( $item, $column_name, $primary );
1295
+ echo "</td>";
1296
+ }
1297
+ }
1298
+ }
1299
+
1300
+ /**
1301
+ * Generates and display row actions links for the list table.
1302
+ *
1303
+ * @since 4.3.0
1304
+ * @access protected
1305
+ *
1306
+ * @param object $item The item being acted upon.
1307
+ * @param string $column_name Current column name.
1308
+ * @param string $primary Primary column name.
1309
+ * @return string The row actions HTML, or an empty string if the current column is the primary column.
1310
+ */
1311
+ protected function handle_row_actions( $item, $column_name, $primary ) {
1312
+ return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>' : '';
1313
+ }
1314
+
1315
+ /**
1316
+ * Handle an incoming ajax request (called from admin-ajax.php)
1317
+ *
1318
+ * @since 3.1.0
1319
+ * @access public
1320
+ */
1321
+ public function ajax_response() {
1322
+ $this->prepare_items();
1323
+
1324
+ ob_start();
1325
+ if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
1326
+ $this->display_rows();
1327
+ } else {
1328
+ $this->display_rows_or_placeholder();
1329
+ }
1330
+
1331
+ $rows = ob_get_clean();
1332
+
1333
+ $response = array( 'rows' => $rows );
1334
+
1335
+ if ( isset( $this->_pagination_args['total_items'] ) ) {
1336
+ $response['total_items_i18n'] = sprintf(
1337
+ _n( '%s item', '%s items', $this->_pagination_args['total_items'] ),
1338
+ number_format_i18n( $this->_pagination_args['total_items'] )
1339
+ );
1340
+ }
1341
+ if ( isset( $this->_pagination_args['total_pages'] ) ) {
1342
+ $response['total_pages'] = $this->_pagination_args['total_pages'];
1343
+ $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
1344
+ }
1345
+
1346
+ die( wp_json_encode( $response ) );
1347
+ }
1348
+
1349
+ /**
1350
+ * Send required variables to JavaScript land
1351
+ *
1352
+ * @access public
1353
+ */
1354
+ public function _js_vars() {
1355
+ $args = array(
1356
+ 'class' => get_class( $this ),
1357
+ 'screen' => array(
1358
+ 'id' => $this->screen->id,
1359
+ 'base' => $this->screen->base,
1360
+ )
1361
+ );
1362
+
1363
+ printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );
1364
+ }
1365
+ }
inc/countries.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Countries
4
+ *
5
+ * Returns an array of countries and codes.
6
+ *
7
+ * @package VFB
8
+ */
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit; // Exit if accessed directly
12
+ }
13
+
14
+ return array(
15
+ "",
16
+ "Afghanistan",
17
+ "Albania",
18
+ "Algeria",
19
+ "Andorra",
20
+ "Angola",
21
+ "Antigua and Barbuda",
22
+ "Argentina",
23
+ "Armenia",
24
+ "Australia",
25
+ "Austria",
26
+ "Azerbaijan",
27
+ "Bahamas",
28
+ "Bahrain",
29
+ "Bangladesh",
30
+ "Barbados",
31
+ "Belarus",
32
+ "Belgium",
33
+ "Belize",
34
+ "Benin",
35
+ "Bhutan",
36
+ "Bolivia",
37
+ "Bosnia and Herzegovina",
38
+ "Botswana",
39
+ "Brazil",
40
+ "Brunei",
41
+ "Bulgaria",
42
+ "Burkina Faso",
43
+ "Burundi",
44
+ "Cambodia",
45
+ "Cameroon",
46
+ "Canada",
47
+ "Cape Verde",
48
+ "Central African Republic",
49
+ "Chad",
50
+ "Chile",
51
+ "China",
52
+ "Colombia",
53
+ "Comoros",
54
+ "Congo (Brazzaville)",
55
+ "Congo",
56
+ "Costa Rica",
57
+ "Cote d\'Ivoire",
58
+ "Croatia",
59
+ "Cuba",
60
+ "Cyprus",
61
+ "Czech Republic",
62
+ "Denmark",
63
+ "Djibouti",
64
+ "Dominica",
65
+ "Dominican Republic",
66
+ "East Timor (Timor Timur)",
67
+ "Ecuador",
68
+ "Egypt",
69
+ "El Salvador",
70
+ "Equatorial Guinea",
71
+ "Eritrea",
72
+ "Estonia",
73
+ "Ethiopia",
74
+ "Fiji",
75
+ "Finland",
76
+ "France",
77
+ "Gabon",
78
+ "Gambia, The",
79
+ "Georgia",
80
+ "Germany",
81
+ "Ghana",
82
+ "Greece",
83
+ "Grenada",
84
+ "Guatemala",
85
+ "Guinea",
86
+ "Guinea-Bissau",
87
+ "Guyana",
88
+ "Haiti",
89
+ "Honduras",
90
+ "Hungary",
91
+ "Iceland",
92
+ "India",
93
+ "Indonesia",
94
+ "Iran",
95
+ "Iraq",
96
+ "Ireland",
97
+ "Israel",
98
+ "Italy",
99
+ "Jamaica",
100
+ "Japan",
101
+ "Jordan",
102
+ "Kazakhstan",
103
+ "Kenya",
104
+ "Kiribati",
105
+ "Korea, North",
106
+ "Korea, South",
107
+ "Kuwait",
108
+ "Kyrgyzstan",
109
+ "Laos",
110
+ "Latvia",
111
+ "Lebanon",
112
+ "Lesotho",
113
+ "Liberia",
114
+ "Libya",
115
+ "Liechtenstein",
116
+ "Lithuania",
117
+ "Luxembourg",
118
+ "Macedonia",
119
+ "Madagascar",
120
+ "Malawi",
121
+ "Malaysia",
122
+ "Maldives",
123
+ "Mali",
124
+ "Malta",
125
+ "Marshall Islands",
126
+ "Mauritania",
127
+ "Mauritius",
128
+ "Mexico",
129
+ "Micronesia",
130
+ "Moldova",
131
+ "Monaco",
132
+ "Mongolia",
133
+ "Montenegro",
134
+ "Morocco",
135
+ "Mozambique",
136
+ "Myanmar",
137
+ "Namibia",
138
+ "Nauru",
139
+ "Nepal",
140
+ "Netherlands",
141
+ "New Zealand",
142
+ "Nicaragua",
143
+ "Niger",
144
+ "Nigeria",
145
+ "Norway",
146
+ "Oman",
147
+ "Pakistan",
148
+ "Palestinian Territory",
149
+ "Palau",
150
+ "Panama",
151
+ "Papua New Guinea",
152
+ "Paraguay",
153
+ "Peru",
154
+ "Philippines",
155
+ "Poland",
156
+ "Portugal",
157
+ "Qatar",
158
+ "Romania",
159
+ "Russia",
160
+ "Rwanda",
161
+ "Saint Kitts and Nevis",
162
+ "Saint Lucia",
163
+ "Saint Vincent",
164
+ "Samoa",
165
+ "San Marino",
166
+ "Sao Tome and Principe",
167
+ "Saudi Arabia",
168
+ "Senegal",
169
+ "Serbia",
170
+ "Seychelles",
171
+ "Sierra Leone",
172
+ "Singapore",
173
+ "Slovakia",
174
+ "Slovenia",
175
+ "Solomon Islands",
176
+ "Somalia",
177
+ "South Africa",
178
+ "Spain",
179
+ "Sri Lanka",
180
+ "Sudan",
181
+ "Suriname",
182
+ "Swaziland",
183
+ "Sweden",
184
+ "Switzerland",
185
+ "Syria",
186
+ "Taiwan",
187
+ "Tajikistan",
188
+ "Tanzania",
189
+ "Thailand",
190
+ "Togo",
191
+ "Tonga",
192
+ "Trinidad and Tobago",
193
+ "Tunisia",
194
+ "Turkey",
195
+ "Turkmenistan",
196
+ "Tuvalu",
197
+ "Uganda",
198
+ "Ukraine",
199
+ "United Arab Emirates",
200
+ "United Kingdom",
201
+ "United States of America",
202
+ "Uruguay",
203
+ "Uzbekistan",
204
+ "Vanuatu",
205
+ "Vatican City",
206
+ "Venezuela",
207
+ "Vietnam",
208
+ "Western Sahara",
209
+ "Western Samoa",
210
+ "Yemen",
211
+ "Zambia",
212
+ "Zimbabwe"
213
+ );
inc/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
includes/admin-field-options.php DELETED
@@ -1,448 +0,0 @@
1
- <?php
2
- global $wpdb;
3
-
4
- $field_where = ( isset( $field_id ) && !is_null( $field_id ) ) ? "AND field_id = $field_id" : '';
5
- // Display all fields for the selected form
6
- $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 ) );
7
-
8
- $depth = 1;
9
- $parent = $last = 0;
10
- ob_start();
11
-
12
- // Loop through each field and display
13
- foreach ( $fields as &$field ) :
14
- // If we are at the root level
15
- if ( !$field->field_parent && $depth > 1 ) {
16
- // If we've been down a level, close out the list
17
- while ( $depth > 1 ) {
18
- echo '</li></ul>';
19
- $depth--;
20
- }
21
-
22
- // Close out the root item
23
- echo '</li>';
24
- }
25
- // first item of <ul>, so move down a level
26
- elseif ( $field->field_parent && $field->field_parent == $last ) {
27
- echo '<ul class="parent">';
28
- $depth++;
29
- }
30
- // Close up a <ul> and move up a level
31
- elseif ( $field->field_parent && $field->field_parent != $parent ) {
32
- echo '</li></ul></li>';
33
- $depth--;
34
- }
35
- // Same level so close list item
36
- elseif ( $field->field_parent && $field->field_parent == $parent )
37
- echo '</li>';
38
-
39
- // Store item ID and parent ID to test for nesting
40
- $last = $field->field_id;
41
- $parent = $field->field_parent;
42
- ?>
43
- <li id="form_item_<?php echo $field->field_id; ?>" class="form-item<?php echo ( in_array( $field->field_type, array( 'submit', 'secret', 'verification' ) ) ) ? ' ui-state-disabled' : ''; ?><?php echo ( !in_array( $field->field_type, array( 'fieldset', 'section', 'verification' ) ) ) ? ' mjs-nestedSortable-no-nesting' : ''; ?>">
44
- <dl class="menu-item-bar vfb-menu-item-inactive">
45
- <dt class="vfb-menu-item-handle vfb-menu-item-type-<?php echo esc_attr( $field->field_type ); ?>">
46
- <span class="item-title"><?php echo stripslashes( esc_attr( $field->field_name ) ); ?><?php echo ( $field->field_required == 'yes' ) ? ' <span class="is-field-required">*</span>' : ''; ?></span>
47
- <span class="item-controls">
48
- <span class="item-type"><?php echo strtoupper( str_replace( '-', ' ', $field->field_type ) ); ?></span>
49
- <a href="#" title="<?php _e( 'Edit Field Item' , 'visual-form-builder'); ?>" id="edit-<?php echo $field->field_id; ?>" class="item-edit"><?php _e( 'Edit Field Item' , 'visual-form-builder'); ?></a>
50
- </span>
51
- </dt>
52
- </dl>
53
-
54
- <div id="form-item-settings-<?php echo $field->field_id; ?>" class="menu-item-settings field-type-<?php echo $field->field_type; ?>" style="display: none;">
55
- <?php if ( in_array( $field->field_type, array( 'fieldset', 'section', 'verification' ) ) ) : ?>
56
-
57
- <p class="description description-wide">
58
- <label for="edit-form-item-name-<?php echo $field->field_id; ?>"><?php echo ( in_array( $field->field_type, array( 'fieldset', 'verification' ) ) ) ? 'Legend' : 'Name'; ?>
59
- <span class="vfb-tooltip" rel="<?php esc_attr_e( 'For Fieldsets, a Legend is simply the name of that group. Use general terms that describe the fields included in this Fieldset.', 'visual-form-builder' ); ?>" title="<?php esc_attr_e( 'About Legend', 'visual-form-builder' ); ?>">(?)</span>
60
- <br />
61
- <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" maxlength="255" />
62
- </label>
63
- </p>
64
- <p class="description description-wide">
65
- <label for="edit-form-item-css-<?php echo $field->field_id; ?>">
66
- <?php _e( 'CSS Classes' , 'visual-form-builder'); ?>
67
- <span class="vfb-tooltip" rel="<?php esc_attr_e( 'For each field, you can insert your own CSS class names which can be used in your own stylesheets.', 'visual-form-builder' ); ?>" title="<?php esc_attr_e( 'About CSS Classes', 'visual-form-builder' ); ?>">(?)</span>
68
- <br />
69
- <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" />
70
- </label>
71
- </p>
72
-
73
- <?php elseif( $field->field_type == 'instructions' ) : ?>
74
- <!-- Instructions -->
75
- <p class="description description-wide">
76
- <label for="edit-form-item-name-<?php echo $field->field_id; ?>">
77
- <?php _e( 'Name' , 'visual-form-builder'); ?>
78
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Name', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( "A field's name is the most visible and direct way to describe what that field is for.", 'visual-form-builder' ); ?>">(?)</span>
79
- <br />
80
- <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" maxlength="255" />
81
- </label>
82
- </p>
83
- <!-- Description -->
84
- <p class="description description-wide">
85
- <label for="edit-form-item-description-<?php echo $field->field_id; ?>">
86
- <?php _e( 'Description (HTML tags allowed)', 'visual-form-builder' ); ?>
87
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Instructions Description', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'The Instructions field allows for long form explanations, typically seen at the beginning of Fieldsets or Sections. HTML tags are allowed.', 'visual-form-builder' ); ?>">(?)</span>
88
- <br />
89
- <textarea name="field_description-<?php echo $field->field_id; ?>" class="widefat edit-menu-item-description" cols="20" rows="3" id="edit-form-item-description-<?php echo $field->field_id; ?>" /><?php echo stripslashes( $field->field_description ); ?></textarea>
90
- </label>
91
- </p>
92
- <!-- CSS Classes -->
93
- <p class="description description-thin">
94
- <label for="edit-form-item-css-<?php echo $field->field_id; ?>">
95
- <?php _e( 'CSS Classes' , 'visual-form-builder-pro'); ?>
96
- <span class="vfb-tooltip" rel="<?php esc_attr_e( 'For each field, you can insert your own CSS class names which can be used in your own stylesheets.', 'visual-form-builder-pro' ); ?>" title="<?php esc_attr_e( 'About CSS Classes', 'visual-form-builder-pro' ); ?>">(?)</span>
97
- <br />
98
- <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" />
99
- </label>
100
- </p>
101
-
102
- <!-- Field Layout -->
103
- <p class="description description-thin">
104
- <label for="edit-form-item-layout">
105
- <?php _e( 'Field Layout' , 'visual-form-builder-pro'); ?>
106
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Field Layout', 'visual-form-builder-pro' ); ?>" rel="<?php esc_attr_e( 'Used to create advanced layouts. Align fields side by side in various configurations.', 'visual-form-builder-pro' ); ?>">(?)</span>
107
- <br />
108
- <select name="field_layout-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-layout-<?php echo $field->field_id; ?>">
109
-
110
- <option value="" <?php selected( $field->field_layout, '' ); ?>><?php _e( 'Default' , 'visual-form-builder-pro'); ?></option>
111
- <optgroup label="------------">
112
- <option value="left-half" <?php selected( $field->field_layout, 'left-half' ); ?>><?php _e( 'Left Half' , 'visual-form-builder-pro'); ?></option>
113
- <option value="right-half" <?php selected( $field->field_layout, 'right-half' ); ?>><?php _e( 'Right Half' , 'visual-form-builder-pro'); ?></option>
114
- </optgroup>
115
- <optgroup label="------------">
116
- <option value="left-third" <?php selected( $field->field_layout, 'left-third' ); ?>><?php _e( 'Left Third' , 'visual-form-builder-pro'); ?></option>
117
- <option value="middle-third" <?php selected( $field->field_layout, 'middle-third' ); ?>><?php _e( 'Middle Third' , 'visual-form-builder-pro'); ?></option>
118
- <option value="right-third" <?php selected( $field->field_layout, 'right-third' ); ?>><?php _e( 'Right Third' , 'visual-form-builder-pro'); ?></option>
119
- </optgroup>
120
- <optgroup label="------------">
121
- <option value="left-two-thirds" <?php selected( $field->field_layout, 'left-two-thirds' ); ?>><?php _e( 'Left Two Thirds' , 'visual-form-builder-pro'); ?></option>
122
- <option value="right-two-thirds" <?php selected( $field->field_layout, 'right-two-thirds' ); ?>><?php _e( 'Right Two Thirds' , 'visual-form-builder-pro'); ?></option>
123
- </optgroup>
124
- <?php apply_filters( 'vfb_admin_field_layout', $field->field_layout ); ?>
125
- </select>
126
- </label>
127
- </p>
128
-
129
- <?php else: ?>
130
-
131
- <!-- Name -->
132
- <p class="description description-wide">
133
- <label for="edit-form-item-name-<?php echo $field->field_id; ?>">
134
- <?php _e( 'Name' , 'visual-form-builder'); ?>
135
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Name', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( "A field's name is the most visible and direct way to describe what that field is for.", 'visual-form-builder' ); ?>">(?)</span>
136
- <br />
137
- <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_name ) ); ?>" name="field_name-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-name-<?php echo $field->field_id; ?>" maxlength="255" />
138
- </label>
139
- </p>
140
- <?php if ( $field->field_type == 'submit' ) : ?>
141
- <!-- CSS Classes -->
142
- <p class="description description-wide">
143
- <label for="edit-form-item-css-<?php echo $field->field_id; ?>">
144
- <?php _e( 'CSS Classes' , 'visual-form-builder'); ?>
145
- <span class="vfb-tooltip" rel="<?php esc_attr_e( 'For each field, you can insert your own CSS class names which can be used in your own stylesheets.', 'visual-form-builder' ); ?>" title="<?php esc_attr_e( 'About CSS Classes', 'visual-form-builder' ); ?>">(?)</span>
146
- <br />
147
- <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" />
148
- </label>
149
- </p>
150
- <?php elseif ( $field->field_type !== 'submit' ) : ?>
151
- <!-- Description -->
152
- <p class="description description-wide">
153
- <label for="edit-form-item-description-<?php echo $field->field_id; ?>">
154
- <?php _e( 'Description' , 'visual-form-builder'); ?>
155
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Description', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'A description is an optional piece of text that further explains the meaning of this field. Descriptions are displayed below the field. HTML tags are allowed.', 'visual-form-builder' ); ?>">(?)</span>
156
- <br />
157
- <textarea name="field_description-<?php echo $field->field_id; ?>" class="widefat edit-menu-item-description" cols="20" rows="3" id="edit-form-item-description-<?php echo $field->field_id; ?>" /><?php echo stripslashes( $field->field_description ); ?></textarea>
158
- </label>
159
- </p>
160
-
161
- <?php
162
- // Display the Options input only for radio, checkbox, and select fields
163
- if ( in_array( $field->field_type, array( 'radio', 'checkbox', 'select' ) ) ) : ?>
164
- <!-- Options -->
165
- <p class="description description-wide">
166
- <?php _e( 'Options' , 'visual-form-builder'); ?>
167
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Options', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( '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.', 'visual-form-builder' ); ?>">(?)</span>
168
- <br />
169
- <?php
170
- // If the options field isn't empty, unserialize and build array
171
- if ( !empty( $field->field_options ) ) {
172
- if ( is_serialized( $field->field_options ) )
173
- $opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
174
- }
175
- // Otherwise, present some default options
176
- else
177
- $opts_vals = array( 'Option 1', 'Option 2', 'Option 3' );
178
-
179
- // Basic count to keep track of multiple options
180
- $count = 1;
181
- ?>
182
- <div class="vfb-cloned-options">
183
- <?php foreach ( $opts_vals as $options ) : ?>
184
- <div id="clone-<?php echo $field->field_id . '-' . $count; ?>" class="option">
185
- <label for="edit-form-item-options-<?php echo $field->field_id . "-$count"; ?>" class="clonedOption">
186
- <input type="radio" value="<?php echo esc_attr( $count ); ?>" name="field_default-<?php echo $field->field_id; ?>" <?php checked( $field->field_default, $count ); ?> />
187
- <input type="text" value="<?php echo stripslashes( esc_attr( $options ) ); ?>" name="field_options-<?php echo $field->field_id; ?>[]" class="widefat" id="edit-form-item-options-<?php echo $field->field_id . "-$count"; ?>" />
188
- </label>
189
-
190
- <a href="#" class="deleteOption vfb-interface-icon vfb-interface-minus" title="Delete Option">
191
- <?php _e( 'Delete', 'visual-form-builder' ); ?>
192
- </a>
193
- <span class="vfb-interface-icon vfb-interface-sort" title="<?php esc_attr_e( 'Drag and Drop to Sort Options', 'visual-form-builder-pro' ); ?>"></span>
194
- </div>
195
- <?php
196
- $count++;
197
- endforeach;
198
- ?>
199
-
200
- </div> <!-- .vfb-cloned-options -->
201
- <div class="clear"></div>
202
- <div class="vfb-add-options-group">
203
- <a href="#" class="vfb-button vfb-add-option" title="Add Option">
204
- <?php _e( 'Add Option', 'visual-form-builder' ); ?>
205
- <span class="vfb-interface-icon vfb-interface-plus"></span>
206
- </a>
207
- </div>
208
- </p>
209
- <?php
210
- // Unset the options for any following radio, checkboxes, or selects
211
- unset( $opts_vals );
212
- endif;
213
- ?>
214
-
215
- <?php if ( in_array( $field->field_type, array( 'file-upload' ) ) ) : ?>
216
- <!-- File Upload Accepts -->
217
- <p class="description description-wide">
218
- <?php
219
- $opts_vals = array( '' );
220
-
221
- // If the options field isn't empty, unserialize and build array
222
- if ( !empty( $field->field_options ) ) {
223
- if ( is_serialized( $field->field_options ) )
224
- $opts_vals = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : unserialize( $field->field_options );
225
- }
226
-
227
- // Loop through the options
228
- foreach ( $opts_vals as $options ) {
229
- ?>
230
- <label for="edit-form-item-options-<?php echo $field->field_id; ?>">
231
- <?php _e( 'Accepted File Extensions' , 'visual-form-builder'); ?>
232
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Accepted File Extensions', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Control the types of files allowed. Enter extensions without periods and separate multiples using the pipe character ( | ).', 'visual-form-builder' ); ?>">(?)</span>
233
- <br />
234
- <input type="text" value="<?php echo stripslashes( esc_attr( $options ) ); ?>" name="field_options-<?php echo $field->field_id; ?>[]" class="widefat" id="edit-form-item-options-<?php echo $field->field_id; ?>" />
235
- </label>
236
- </p>
237
- <?php
238
- }
239
- // Unset the options for any following radio, checkboxes, or selects
240
- unset( $opts_vals );
241
- endif;
242
- ?>
243
-
244
- <?php if ( in_array( $field->field_type, array( 'date' ) ) ) : ?>
245
- <!-- Date Format -->
246
- <p class="description description-wide">
247
- <?php
248
- $opts_vals = maybe_unserialize( $field->field_options );
249
- $dateFormat = ( isset( $opts_vals['dateFormat'] ) ) ? $opts_vals['dateFormat'] : 'mm/dd/yy';
250
- ?>
251
- <label for="edit-form-item-date-dateFormat-<?php echo $field->field_id; ?>">
252
- <?php _e( 'Date Format', 'visual-form-builder' ); ?>
253
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Date Format', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Set the date format for each date picker.', 'visual-form-builder' ); ?>">(?)</span>
254
- <br />
255
- <input type="text" value="<?php echo esc_attr( $dateFormat ); ?>" name="field_options-<?php echo $field->field_id; ?>[dateFormat]" class="widefat" id="edit-form-item-date-dateFormat-<?php echo $field->field_id; ?>" />
256
- </label>
257
- </p>
258
- <?php
259
- // Unset the options for any following radio, checkboxes, or selects
260
- unset( $opts_vals );
261
- endif;
262
- ?>
263
- <!-- Validation -->
264
- <p class="description description-thin">
265
- <label for="edit-form-item-validation">
266
- <?php _e( 'Validation' , 'visual-form-builder'); ?>
267
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Validation', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Ensures user-entered data is formatted properly. For more information on Validation, refer to the Help tab at the top of this page.', 'visual-form-builder' ); ?>">(?)</span>
268
- <br />
269
-
270
- <?php if ( in_array( $field->field_type , array( 'text', 'time', 'number' ) ) ) : ?>
271
- <select name="field_validation-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-validation-<?php echo $field->field_id; ?>">
272
- <?php if ( $field->field_type == 'time' ) : ?>
273
- <option value="time-12" <?php selected( $field->field_validation, 'time-12' ); ?>><?php _e( '12 Hour Format' , 'visual-form-builder'); ?></option>
274
- <option value="time-24" <?php selected( $field->field_validation, 'time-24' ); ?>><?php _e( '24 Hour Format' , 'visual-form-builder'); ?></option>
275
- <?php elseif ( in_array( $field->field_type, array( 'number' ) ) ) : ?>
276
- <option value="number" <?php selected( $field->field_validation, 'number' ); ?>><?php _e( 'Number' , 'visual-form-builder'); ?></option>
277
- <option value="digits" <?php selected( $field->field_validation, 'digits' ); ?>><?php _e( 'Digits' , 'visual-form-builder'); ?></option>
278
- <?php else : ?>
279
- <option value="" <?php selected( $field->field_validation, '' ); ?>><?php _e( 'None' , 'visual-form-builder'); ?></option>
280
- <option value="email" <?php selected( $field->field_validation, 'email' ); ?>><?php _e( 'Email' , 'visual-form-builder'); ?></option>
281
- <option value="url" <?php selected( $field->field_validation, 'url' ); ?>><?php _e( 'URL' , 'visual-form-builder'); ?></option>
282
- <option value="date" <?php selected( $field->field_validation, 'date' ); ?>><?php _e( 'Date' , 'visual-form-builder'); ?></option>
283
- <option value="number" <?php selected( $field->field_validation, 'number' ); ?>><?php _e( 'Number' , 'visual-form-builder'); ?></option>
284
- <option value="digits" <?php selected( $field->field_validation, 'digits' ); ?>><?php _e( 'Digits' , 'visual-form-builder'); ?></option>
285
- <option value="phone" <?php selected( $field->field_validation, 'phone' ); ?>><?php _e( 'Phone' , 'visual-form-builder'); ?></option>
286
- <?php endif; ?>
287
- </select>
288
- <?php else :
289
- $field_validation = '';
290
-
291
- switch ( $field->field_type ) {
292
- case 'email' :
293
- case 'url' :
294
- case 'phone' :
295
- $field_validation = $field->field_type;
296
- break;
297
-
298
- case 'currency' :
299
- $field_validation = 'number';
300
- break;
301
-
302
- case 'number' :
303
- $field_validation = 'digits';
304
- break;
305
- }
306
-
307
- ?>
308
- <input type="text" class="widefat" name="field_validation-<?php echo $field->field_id; ?>" value="<?php echo $field_validation; ?>" readonly="readonly" />
309
- <?php endif; ?>
310
-
311
- </label>
312
- </p>
313
-
314
- <!-- Required -->
315
- <p class="field-link-target description description-thin">
316
- <label for="edit-form-item-required">
317
- <?php _e( 'Required' , 'visual-form-builder'); ?>
318
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Required', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Requires the field to be completed before the form is submitted. By default, all fields are set to No.', 'visual-form-builder' ); ?>">(?)</span>
319
- <br />
320
- <select name="field_required-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-required-<?php echo $field->field_id; ?>">
321
- <option value="no" <?php selected( $field->field_required, 'no' ); ?>><?php _e( 'No' , 'visual-form-builder'); ?></option>
322
- <option value="yes" <?php selected( $field->field_required, 'yes' ); ?>><?php _e( 'Yes' , 'visual-form-builder'); ?></option>
323
- </select>
324
- </label>
325
- </p>
326
-
327
- <?php if ( !in_array( $field->field_type, array( 'radio', 'checkbox', 'time' ) ) ) : ?>
328
- <!-- Size -->
329
- <p class="description description-thin">
330
- <label for="edit-form-item-size">
331
- <?php _e( 'Size' , 'visual-form-builder'); ?>
332
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Size', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Control the size of the field. By default, all fields are set to Medium.', 'visual-form-builder' ); ?>">(?)</span>
333
- <br />
334
- <select name="field_size-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-size-<?php echo $field->field_id; ?>">
335
- <option value="small" <?php selected( $field->field_size, 'small' ); ?>><?php _e( 'Small' , 'visual-form-builder'); ?></option>
336
- <option value="medium" <?php selected( $field->field_size, 'medium' ); ?>><?php _e( 'Medium' , 'visual-form-builder'); ?></option>
337
- <option value="large" <?php selected( $field->field_size, 'large' ); ?>><?php _e( 'Large' , 'visual-form-builder'); ?></option>
338
- </select>
339
- </label>
340
- </p>
341
-
342
- <?php elseif ( in_array( $field->field_type, array( 'radio', 'checkbox', 'time' ) ) ) : ?>
343
- <!-- Options Layout -->
344
- <p class="description description-thin">
345
- <label for="edit-form-item-size">
346
- <?php _e( 'Options Layout' , 'visual-form-builder'); ?>
347
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Options Layout', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Control the layout of radio buttons or checkboxes. By default, options are arranged in One Column.', 'visual-form-builder' ); ?>">(?)</span>
348
- <br />
349
- <select name="field_size-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-size-<?php echo $field->field_id; ?>"<?php echo ( $field->field_type == 'time' ) ? ' disabled="disabled"' : ''; ?>>
350
- <option value="" <?php selected( $field->field_size, '' ); ?>><?php _e( 'One Column' , 'visual-form-builder'); ?></option>
351
- <option value="two-column" <?php selected( $field->field_size, 'two-column' ); ?>><?php _e( 'Two Columns' , 'visual-form-builder'); ?></option>
352
- <option value="three-column" <?php selected( $field->field_size, 'three-column' ); ?>><?php _e( 'Three Columns' , 'visual-form-builder'); ?></option>
353
- <option value="auto-column" <?php selected( $field->field_size, 'auto-column' ); ?>><?php _e( 'Auto Width' , 'visual-form-builder'); ?></option>
354
- </select>
355
- </label>
356
- </p>
357
-
358
- <?php endif; ?>
359
- <!-- Field Layout -->
360
- <p class="description description-thin">
361
- <label for="edit-form-item-layout">
362
- <?php _e( 'Field Layout' , 'visual-form-builder'); ?>
363
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Field Layout', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Used to create advanced layouts. Align fields side by side in various configurations.', 'visual-form-builder' ); ?>">(?)</span>
364
- <br />
365
- <select name="field_layout-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-layout-<?php echo $field->field_id; ?>">
366
-
367
- <option value="" <?php selected( $field->field_layout, '' ); ?>><?php _e( 'Default' , 'visual-form-builder'); ?></option>
368
- <optgroup label="------------">
369
- <option value="left-half" <?php selected( $field->field_layout, 'left-half' ); ?>><?php _e( 'Left Half' , 'visual-form-builder'); ?></option>
370
- <option value="right-half" <?php selected( $field->field_layout, 'right-half' ); ?>><?php _e( 'Right Half' , 'visual-form-builder'); ?></option>
371
- </optgroup>
372
- <optgroup label="------------">
373
- <option value="left-third" <?php selected( $field->field_layout, 'left-third' ); ?>><?php _e( 'Left Third' , 'visual-form-builder'); ?></option>
374
- <option value="middle-third" <?php selected( $field->field_layout, 'middle-third' ); ?>><?php _e( 'Middle Third' , 'visual-form-builder'); ?></option>
375
- <option value="right-third" <?php selected( $field->field_layout, 'right-third' ); ?>><?php _e( 'Right Third' , 'visual-form-builder'); ?></option>
376
- </optgroup>
377
- <optgroup label="------------">
378
- <option value="left-two-thirds" <?php selected( $field->field_layout, 'left-two-thirds' ); ?>><?php _e( 'Left Two Thirds' , 'visual-form-builder'); ?></option>
379
- <option value="right-two-thirds" <?php selected( $field->field_layout, 'right-two-thirds' ); ?>><?php _e( 'Right Two Thirds' , 'visual-form-builder'); ?></option>
380
- </optgroup>
381
- </select>
382
- </label>
383
- </p>
384
- <?php if ( !in_array( $field->field_type, array( 'radio', 'select', 'checkbox', 'time', 'address' ) ) ) : ?>
385
- <!-- Default Value -->
386
- <p class="description description-wide">
387
- <label for="edit-form-item-default-<?php echo $field->field_id; ?>">
388
- <?php _e( 'Default Value' , 'visual-form-builder'); ?>
389
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Default Value', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Set a default value that will be inserted automatically.', 'visual-form-builder' ); ?>">(?)</span>
390
- <br />
391
- <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_default ) ); ?>" name="field_default-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-default-<?php echo $field->field_id; ?>" maxlength="255" />
392
- </label>
393
- </p>
394
- <?php elseif( in_array( $field->field_type, array( 'address' ) ) ) : ?>
395
- <!-- Default Country -->
396
- <p class="description description-wide">
397
- <label for="edit-form-item-default-<?php echo $field->field_id; ?>">
398
- <?php _e( 'Default Country' , 'visual-form-builder'); ?>
399
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Default Country', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Select the country you would like to be displayed by default.', 'visual-form-builder' ); ?>">(?)</span>
400
- <br />
401
- <select name="field_default-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-default-<?php echo $field->field_id; ?>">
402
- <?php
403
- foreach ( $this->countries as $country ) {
404
- echo '<option value="' . $country . '" ' . selected( $field->field_default, $country, 0 ) . '>' . $country . '</option>';
405
- }
406
- ?>
407
- </select>
408
- </label>
409
- </p>
410
- <?php endif; ?>
411
- <!-- CSS Classes -->
412
- <p class="description description-wide">
413
- <label for="edit-form-item-css-<?php echo $field->field_id; ?>">
414
- <?php _e( 'CSS Classes' , 'visual-form-builder'); ?>
415
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About CSS Classes', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'For each field, you can insert your own CSS class names which can be used in your own stylesheets.', 'visual-form-builder' ); ?>">(?)</span>
416
- <br />
417
- <input type="text" value="<?php echo stripslashes( esc_attr( $field->field_css ) ); ?>" name="field_css-<?php echo $field->field_id; ?>" class="widefat" id="edit-form-item-css-<?php echo $field->field_id; ?>" maxlength="255" />
418
- </label>
419
- </p>
420
-
421
- <?php endif; ?>
422
- <?php endif; ?>
423
-
424
- <?php if ( !in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) : ?>
425
- <!-- Delete link -->
426
- <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="vfb-button vfb-delete item-delete submitdelete deletion">
427
- <?php _e( 'Delete' , 'visual-form-builder'); ?>
428
- <span class="vfb-interface-icon vfb-interface-trash"></span>
429
- </a>
430
- <?php endif; ?>
431
-
432
- <input type="hidden" name="field_id[<?php echo $field->field_id; ?>]" value="<?php echo $field->field_id; ?>" />
433
- </div>
434
- <?php
435
- endforeach;
436
-
437
- // This assures all of the <ul> and <li> are closed
438
- if ( $depth > 1 ) {
439
- while( $depth > 1 ) {
440
- echo '</li>
441
- </ul>';
442
- $depth--;
443
- }
444
- }
445
-
446
- // Close out last item
447
- echo '</li>';
448
- echo ob_get_clean();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin-form-creator.php DELETED
@@ -1,395 +0,0 @@
1
- <?php
2
- $order = sanitize_sql_orderby( 'form_id DESC' );
3
- $form = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_nav_selected_id ) );
4
-
5
- if ( !$form || $form->form_id !== $form_nav_selected_id )
6
- wp_die( 'You must select a form' );
7
-
8
- $form_id = $form->form_id;
9
- $form_title = stripslashes( $form->form_title );
10
- $form_subject = stripslashes( $form->form_email_subject );
11
- $form_email_from_name = stripslashes( $form->form_email_from_name );
12
- $form_email_from = stripslashes( $form->form_email_from);
13
- $form_email_from_override = stripslashes( $form->form_email_from_override);
14
- $form_email_from_name_override = stripslashes( $form->form_email_from_name_override);
15
- $form_email_to = ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) );
16
- $form_success_type = stripslashes( $form->form_success_type );
17
- $form_success_message = stripslashes( $form->form_success_message );
18
- $form_notification_setting = stripslashes( $form->form_notification_setting );
19
- $form_notification_email_name = stripslashes( $form->form_notification_email_name );
20
- $form_notification_email_from = stripslashes( $form->form_notification_email_from );
21
- $form_notification_email = stripslashes( $form->form_notification_email );
22
- $form_notification_subject = stripslashes( $form->form_notification_subject );
23
- $form_notification_message = stripslashes( $form->form_notification_message );
24
- $form_notification_entry = stripslashes( $form->form_notification_entry );
25
-
26
- $form_label_alignment = stripslashes( $form->form_label_alignment );
27
-
28
- // Only show required text fields for the sender name override
29
- $senders = $wpdb->get_results( $wpdb->prepare( "SELECT field_id, field_name FROM $this->field_table_name WHERE form_id = %d AND field_type IN( 'text', 'name' ) AND field_validation = '' AND field_required = 'yes'", $form_nav_selected_id ) );
30
-
31
- // Only show required email fields for the email override
32
- $emails = $wpdb->get_results( $wpdb->prepare( "SELECT field_id, field_name FROM $this->field_table_name WHERE (form_id = %d AND field_type='text' AND field_validation = 'email' AND field_required = 'yes') OR (form_id = %d AND field_type='email' AND field_validation = 'email' AND field_required = 'yes')", $form_nav_selected_id, $form_nav_selected_id ) );
33
-
34
- $screen = get_current_screen();
35
- $class = 'columns-' . get_current_screen()->get_columns();
36
-
37
- $page_main = $this->_admin_pages[ 'vfb' ];
38
- ?>
39
- <div id="vfb-form-builder-frame" class="metabox-holder <?php echo $class; ?>">
40
- <div id="vfb-postbox-container-1" class='vfb-postbox-container'>
41
- <form id="form-items" class="nav-menu-meta" method="post" action="">
42
- <input name="action" type="hidden" value="create_field" />
43
- <input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
44
- <?php
45
- wp_nonce_field( 'create-field-' . $form_nav_selected_id );
46
- do_meta_boxes( $page_main, 'side', null );
47
- ?>
48
- </form>
49
- </div> <!-- .vfb-postbox-container -->
50
-
51
- <div id="vfb-postbox-container-2" class='vfb-postbox-container'>
52
- <div id="vfb-form-builder-main">
53
- <div id="vfb-form-builder-management">
54
- <div class="form-edit">
55
- <form method="post" id="visual-form-builder-update" action="">
56
- <input name="action" type="hidden" value="update_form" />
57
- <input name="form_id" type="hidden" value="<?php echo $form_nav_selected_id; ?>" />
58
- <?php wp_nonce_field( 'vfb_update_form' ); ?>
59
- <div id="form-editor-header">
60
- <div id="submitpost" class="submitbox">
61
- <div class="vfb-major-publishing-actions">
62
- <label for="form-name" class="menu-name-label howto open-label">
63
- <span class="sender-labels"><?php _e( 'Form Name' , 'visual-form-builder'); ?></span>
64
- <input type="text" value="<?php echo ( isset( $form_title ) ) ? $form_title : ''; ?>" placeholder="<?php _e( 'Enter form name here' , 'visual-form-builder'); ?>" class="menu-name regular-text menu-item-textbox required" id="form-name" name="form_title" />
65
- </label>
66
- <br class="clear" />
67
-
68
- <?php
69
- // Get the Form Setting drop down and accordion settings, if any
70
- $user_form_settings = get_user_meta( $user_id, 'vfb-form-settings' );
71
-
72
- // Setup defaults for the Form Setting tab and accordion
73
- $settings_tab = 'closed';
74
- $settings_accordion = 'general-settings';
75
-
76
- // Loop through the user_meta array
77
- foreach( $user_form_settings as $set ) :
78
- // If form settings exist for this form, use them instead of the defaults
79
- if ( isset( $set[ $form_id ] ) ) :
80
- $settings_tab = $set[ $form_id ]['form_setting_tab'];
81
- $settings_accordion = $set[ $form_id ]['setting_accordion'];
82
- endif;
83
- endforeach;
84
-
85
- // If tab is opened, set current class
86
- $opened_tab = ( $settings_tab == 'opened' ) ? 'current' : '';
87
- ?>
88
-
89
-
90
- <div class="vfb-button-group">
91
- <a href="#form-settings" id="form-settings-button" class="vfb-button vfb-settings <?php echo $opened_tab; ?>">
92
- <?php _e( 'Settings' , 'visual-form-builder'); ?>
93
- <span class="vfb-interface-icon vfb-interface-settings"></span>
94
- </a>
95
- <a href="<?php echo esc_url( wp_nonce_url( admin_url('admin.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">
96
- <?php _e( 'Duplicate' , 'visual-form-builder'); ?>
97
- <span class="vfb-interface-icon vfb-interface-duplicate"></span>
98
- </a>
99
- <a href="<?php echo esc_url( wp_nonce_url( admin_url('admin.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">
100
- <?php _e( 'Delete' , 'visual-form-builder'); ?>
101
- <span class="vfb-interface-icon vfb-interface-trash"></span>
102
- </a>
103
-
104
- <?php submit_button( __( 'Save', 'visual-form-builder' ), 'primary', 'save_form', false ); ?>
105
- </div>
106
-
107
- <div id="form-settings" class="<?php echo $opened_tab; ?>">
108
- <!-- General settings section -->
109
- <a href="#general-settings" class="settings-links<?php echo ( $settings_accordion == 'general-settings' ) ? ' on' : ''; ?>"><?php _e( 'General', 'visual-form-builder' ); ?><span class="vfb-large-arrow"></span></a>
110
- <div id="general-settings" class="form-details<?php echo ( $settings_accordion == 'general-settings' ) ? ' on' : ''; ?>">
111
- <!-- Label Alignment -->
112
- <p class="description description-wide">
113
- <label for="form-label-alignment">
114
- <?php _e( 'Label Alignment' , 'visual-form-builder'); ?>
115
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Label Alignment', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( '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>
116
- <br />
117
- </label>
118
- <select name="form_label_alignment" id="form-label-alignment" class="widefat">
119
- <option value="" <?php selected( $form_label_alignment, '' ); ?>><?php _e( 'Top Aligned' , 'visual-form-builder'); ?></option>
120
- <option value="left-label" <?php selected( $form_label_alignment, 'left-label' ); ?>><?php _e( 'Left Aligned' , 'visual-form-builder'); ?></option>
121
- <option value="right-label" <?php selected( $form_label_alignment, 'right-label' ); ?>><?php _e( 'Right Aligned' , 'visual-form-builder'); ?></option>
122
- </select>
123
- </p>
124
- <br class="clear" />
125
- </div> <!-- #general-settings -->
126
-
127
-
128
- <!-- Email section -->
129
- <a href="#email-details" class="settings-links<?php echo ( $settings_accordion == 'email-details' ) ? ' on' : ''; ?>"><?php _e( 'Email', 'visual-form-builder' ); ?><span class="vfb-large-arrow"></span></a>
130
- <div id="email-details" class="form-details<?php echo ( $settings_accordion == 'email-details' ) ? ' on' : ''; ?>">
131
-
132
- <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>
133
-
134
- <!-- E-mail Subject -->
135
- <p class="description description-wide">
136
- <label for="form-email-subject">
137
- <?php _e( 'E-mail Subject' , 'visual-form-builder'); ?>
138
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About E-mail Subject', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'This option sets the subject of the email that is sent to the emails you have set in the E-mail(s) To field.', 'visual-form-builder' ); ?>">(?)</span>
139
- <br />
140
- <input type="text" value="<?php echo stripslashes( $form_subject ); ?>" class="widefat" id="form-email-subject" name="form_email_subject" />
141
- </label>
142
- </p>
143
- <br class="clear" />
144
-
145
- <!-- Sender Name -->
146
- <p class="description description-thin">
147
- <label for="form-email-sender-name">
148
- <?php _e( 'Your Name or Company' , 'visual-form-builder'); ?>
149
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Your Name or Company', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( '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.', 'visual-form-builder' ); ?>">(?)</span>
150
- <br />
151
- <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"' : ''; ?> />
152
- </label>
153
- </p>
154
- <p class="description description-thin">
155
- <label for="form_email_from_name_override">
156
- <?php _e( "User's Name (optional)" , 'visual-form-builder'); ?>
157
- <span class="vfb-tooltip" title="<?php esc_attr_e( "About User's Name", 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Select a required text field from your form to use as the From display name in the email.', 'visual-form-builder' ); ?>">(?)</span>
158
- <br />
159
- <?php if ( empty( $senders ) ) : ?>
160
- <span><?php _e( 'No required text fields detected', 'visual-form-builder' ); ?></span>
161
- <?php else : ?>
162
- <select name="form_email_from_name_override" id="form_email_from_name_override" class="widefat">
163
- <option value="" <?php selected( $form_email_from_name_override, '' ); ?>></option>
164
- <?php
165
- foreach( $senders as $sender ) {
166
- echo sprintf( '<option value="%1$d"%2$s>%3$s</option>',
167
- $sender->field_id,
168
- selected( $form_email_from_name_override, $sender->field_id, 0 ),
169
- stripslashes( $sender->field_name )
170
- );
171
- }
172
- ?>
173
- </select>
174
- <?php endif; ?>
175
- </label>
176
- </p>
177
- <br class="clear" />
178
-
179
- <!-- Sender E-mail -->
180
- <p class="description description-thin">
181
- <label for="form-email-sender">
182
- <?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?>
183
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Reply-To Email', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Manually set the email address that users will reply to.', 'visual-form-builder' ); ?>">(?)</span>
184
- <br />
185
- <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"' : ''; ?> />
186
- </label>
187
- </p>
188
- <p class="description description-thin">
189
- <label for="form_email_from_override">
190
- <?php _e( "User's E-mail (optional)" , 'visual-form-builder'); ?>
191
- <span class="vfb-tooltip" title="<?php esc_attr_e( "About User's Email", 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Select a required email field from your form to use as the Reply-To email.', 'visual-form-builder' ); ?>">(?)</span>
192
- <br />
193
- <?php if ( empty( $emails ) ) : ?>
194
- <span><?php _e( 'No required email fields detected', 'visual-form-builder' ); ?></span>
195
- <?php else : ?>
196
- <select name="form_email_from_override" id="form_email_from_override" class="widefat">
197
- <option value="" <?php selected( $form_email_from_override, '' ); ?>></option>
198
- <?php
199
- foreach( $emails as $email ) {
200
- echo sprintf( '<option value="%1$d"%2$s>%3$s</option>',
201
- $email->field_id,
202
- selected( $form_email_from_override, $email->field_id, 0 ),
203
- stripslashes( $email->field_name )
204
- );
205
- }
206
- ?>
207
- </select>
208
- <?php endif; ?>
209
- </label>
210
- </p>
211
- <br class="clear" />
212
-
213
- <!-- E-mail(s) To -->
214
- <?php
215
- // Basic count to keep track of multiple options
216
- $count = 1;
217
-
218
- // Loop through the options
219
- foreach ( $form_email_to as $email_to ) :
220
- ?>
221
- <div id="clone-email-<?php echo $count; ?>" class="option">
222
- <p class="description description-wide">
223
- <label for="form-email-to-<?php echo "$count"; ?>" class="clonedOption">
224
- <?php _e( 'E-mail(s) To' , 'visual-form-builder'); ?>
225
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About E-mail(s) To', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'This option sets single or multiple emails to send the submitted form data to. At least one email is required.', 'visual-form-builder' ); ?>">(?)</span>
226
- <br />
227
- <input type="text" value="<?php echo stripslashes( $email_to ); ?>" name="form_email_to[]" class="widefat" id="form-email-to-<?php echo "$count"; ?>" />
228
- </label>
229
-
230
- <a href="#" class="addEmail vfb-interface-icon vfb-interface-plus" title="<?php esc_attr_e( 'Add an Email', 'visua-form-builder' ); ?>">
231
- <?php _e( 'Add', 'visual-form-builder' ); ?>
232
- </a>
233
- <a href="#" class="deleteEmail vfb-interface-icon vfb-interface-minus" title="<?php esc_attr_e( 'Delete Email', 'visual-form-builder' ); ?>">
234
- <?php _e( 'Delete', 'visual-form-builder' ); ?>
235
- </a>
236
-
237
- </p>
238
- <br class="clear" />
239
- </div>
240
- <?php
241
- $count++;
242
- endforeach;
243
- ?>
244
- <div class="clear"></div>
245
- </div>
246
-
247
- <!-- Confirmation section -->
248
- <a href="#confirmation" class="settings-links<?php echo ( $settings_accordion == 'confirmation' ) ? ' on' : ''; ?>"><?php _e( 'Confirmation', 'visual-form-builder' ); ?><span class="vfb-large-arrow"></span></a>
249
- <div id="confirmation-message" class="form-details<?php echo ( $settings_accordion == 'confirmation' ) ? ' on' : ''; ?>">
250
- <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>
251
- <label for="form-success-type-text" class="menu-name-label open-label">
252
- <input type="radio" value="text" id="form-success-type-text" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'text' ); ?> />
253
- <span><?php _e( 'Text' , 'visual-form-builder'); ?></span>
254
- </label>
255
- <label for="form-success-type-page" class="menu-name-label open-label">
256
- <input type="radio" value="page" id="form-success-type-page" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'page' ); ?>/>
257
- <span><?php _e( 'Page' , 'visual-form-builder'); ?></span>
258
- </label>
259
- <label for="form-success-type-redirect" class="menu-name-label open-label">
260
- <input type="radio" value="redirect" id="form-success-type-redirect" class="form-success-type" name="form_success_type" <?php checked( $form_success_type, 'redirect' ); ?>/>
261
- <span><?php _e( 'Redirect' , 'visual-form-builder'); ?></span>
262
- </label>
263
- <br class="clear" />
264
- <p class="description description-wide">
265
- <?php
266
- $default_text = '';
267
-
268
- /* If there's no text message, make sure there is something displayed by setting a default */
269
- if ( $form_success_message === '' )
270
- $default_text = sprintf( '<p id="form_success">%s</p>', __( 'Your form was successfully submitted. Thank you for contacting us.' , 'visual-form-builder') );
271
- ?>
272
- <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>
273
-
274
- <?php
275
- /* Display all Pages */
276
- wp_dropdown_pages( array(
277
- 'name' => 'form_success_message_page',
278
- 'id' => 'form-success-message-page',
279
- 'class' => 'widefat',
280
- 'show_option_none' => __( 'Select a Page' , 'visual-form-builder'),
281
- 'selected' => $form_success_message
282
- ));
283
- ?>
284
- <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://" />
285
- </p>
286
- <br class="clear" />
287
-
288
- </div>
289
-
290
- <!-- Notification section -->
291
- <a href="#notification" class="settings-links<?php echo ( $settings_accordion == 'notification' ) ? ' on' : ''; ?>"><?php _e( 'Notification', 'visual-form-builder' ); ?><span class="vfb-large-arrow"></span></a>
292
- <div id="notification" class="form-details<?php echo ( $settings_accordion == 'notification' ) ? ' on' : ''; ?>">
293
- <p><em><?php _e( "When a user submits their entry, you can send a customizable notification email." , 'visual-form-builder'); ?></em></p>
294
- <label for="form-notification-setting">
295
- <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;"/>
296
- <?php _e( 'Send Confirmation Email to User' , 'visual-form-builder'); ?>
297
- </label>
298
- <br class="clear" />
299
- <div id="notification-email">
300
- <p class="description description-wide">
301
- <label for="form-notification-email-name">
302
- <?php _e( 'Sender Name or Company' , 'visual-form-builder'); ?>
303
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Sender Name or Company', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Enter the name you would like to use for the email notification.', 'visual-form-builder' ); ?>">(?)</span>
304
- <br />
305
- <input type="text" value="<?php echo $form_notification_email_name; ?>" class="widefat" id="form-notification-email-name" name="form_notification_email_name" />
306
- </label>
307
- </p>
308
- <br class="clear" />
309
- <p class="description description-wide">
310
- <label for="form-notification-email-from">
311
- <?php _e( 'Reply-To E-mail' , 'visual-form-builder'); ?>
312
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Reply-To Email', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Manually set the email address that users will reply to.', 'visual-form-builder' ); ?>">(?)</span>
313
- <br />
314
- <input type="text" value="<?php echo $form_notification_email_from; ?>" class="widefat" id="form-notification-email-from" name="form_notification_email_from" />
315
- </label>
316
- </p>
317
- <br class="clear" />
318
- <p class="description description-wide">
319
- <label for="form-notification-email">
320
- <?php _e( 'E-mail To' , 'visual-form-builder'); ?>
321
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About E-mail To', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Select a required email field from your form to send the notification email to.', 'visual-form-builder' ); ?>">(?)</span>
322
- <br />
323
- <?php if ( empty( $emails ) ) : ?>
324
- <span><?php _e( 'No required email fields detected', 'visual-form-builder' ); ?></span>
325
- <?php else : ?>
326
- <select name="form_notification_email" id="form-notification-email" class="widefat">
327
- <option value="" <?php selected( $form_notification_email, '' ); ?>></option>
328
- <?php
329
- foreach( $emails as $email ) {
330
- echo sprintf( '<option value="%1$d"%2$s>%3$s</option>',
331
- $email->field_id,
332
- selected( $form_notification_email, $email->field_id, 0 ),
333
- $email->field_name
334
- );
335
- }
336
- ?>
337
- </select>
338
- <?php endif; ?>
339
- </label>
340
- </p>
341
- <br class="clear" />
342
- <p class="description description-wide">
343
- <label for="form-notification-subject">
344
- <?php _e( 'E-mail Subject' , 'visual-form-builder'); ?>
345
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About E-mail Subject', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'This option sets the subject of the email that is sent to the emails you have set in the E-mail To field.', 'visual-form-builder' ); ?>">(?)</span>
346
- <br />
347
- <input type="text" value="<?php echo $form_notification_subject; ?>" class="widefat" id="form-notification-subject" name="form_notification_subject" />
348
- </label>
349
- </p>
350
- <br class="clear" />
351
- <p class="description description-wide">
352
- <label for="form-notification-message"><?php _e( 'Message' , 'visual-form-builder'); ?></label>
353
- <span class="vfb-tooltip" title="<?php esc_attr_e( 'About Message', 'visual-form-builder' ); ?>" rel="<?php esc_attr_e( 'Insert a message to the user. This will be inserted into the beginning of the email body.', 'visual-form-builder' ); ?>">(?)</span>
354
- <br />
355
- <textarea id="form-notification-message" class="form-notification-message widefat" name="form_notification_message"><?php echo $form_notification_message; ?></textarea>
356
- </p>
357
- <br class="clear" />
358
- <label for="form-notification-entry">
359
- <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;"/>
360
- <?php _e( "Include a Copy of the User's Entry" , 'visual-form-builder'); ?>
361
- </label>
362
- <br class="clear" />
363
- </div>
364
- </div>
365
- </div>
366
- </div>
367
- </div>
368
- </div>
369
- <div id="post-body">
370
- <div id="post-body-content">
371
- <div id="vfb-fieldset-first-warning" class="error"><?php printf( '<p><strong>%1$s </strong><br>%2$s</p>', __( 'Warning &mdash; Missing Fieldset', 'visual-form-builder' ), __( 'Your form may not function or display correctly. Please be sure to add or move a Fieldset to the beginning of your form.' , 'visual-form-builder') ); ?></div>
372
- <!-- !Field Items output -->
373
- <ul id="vfb-menu-to-edit" class="menu ui-sortable droppable">
374
- <?php echo $this->field_output( $form_nav_selected_id ); ?>
375
- </ul>
376
- </div>
377
- <br class="clear" />
378
- </div>
379
- <br class="clear" />
380
- <div id="form-editor-footer">
381
- <div class="vfb-major-publishing-actions">
382
- <div class="publishing-action">
383
- <?php submit_button( __( 'Save Form', 'visual-form-builder' ), 'primary', 'save_form', false ); ?>
384
- </div> <!-- .publishing-action -->
385
- </div> <!-- .vfb-major-publishing-actions -->
386
- </div> <!-- #form-editor-footer -->
387
- </form>
388
- </div> <!-- .form-edit -->
389
- </div> <!-- #vfb-form-builder-management -->
390
- </div> <!-- vfb-form-builder-main -->
391
- </div> <!-- .vfb-postbox-container -->
392
- </div> <!-- #vfb-form-builder-frame -->
393
- <?php
394
- wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
395
- wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin-new-form.php DELETED
@@ -1,58 +0,0 @@
1
- <form method="post" id="visual-form-builder-new-form" action="">
2
- <input name="action" type="hidden" value="create_form" />
3
- <?php
4
- wp_nonce_field( 'create_form' );
5
-
6
- if ( !current_user_can( 'manage_options' ) )
7
- wp_die( __( 'You do not have sufficient permissions to create a new form.', 'visual-form-builder' ) );
8
- ?>
9
- <h3><?php _e( 'Create a form' , 'visual-form-builder'); ?></h3>
10
-
11
- <table class="form-table">
12
- <tbody>
13
- <!-- Form Name -->
14
- <tr valign="top">
15
- <th scope="row"><label for="form-name"><?php _e( 'Name the form' , 'visual-form-builder'); ?></label></th>
16
- <td>
17
- <input type="text" autofocus="autofocus" class="regular-text required" id="form-name" name="form_title" />
18
- <p class="description"><?php _e( 'Required. This name is used for admin purposes.' , 'visual-form-builder'); ?></p>
19
- </td>
20
- </tr>
21
- <!-- Sender Name -->
22
- <tr valign="top">
23
- <th scope="row"><label for="form-email-sender-name"><?php _e( 'Your Name or Company' , 'visual-form-builder'); ?></label></th>
24
- <td>
25
- <input type="text" value="" placeholder="" class="regular-text required" id="form-email-sender-name" name="form_email_from_name" />
26
- <p class="description"><?php _e( 'Required. This option sets the "From" display name of the email that is sent.' , 'visual-form-builder'); ?></p>
27
- </td>
28
- </tr>
29
- <!-- Reply-to Email -->
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 required" id="form-email-from" name="form_email_from" />
34
- <p class="description"><?php _e( 'Required. Replies to your email will go here.' , 'visual-form-builder'); ?></p>
35
- <p class="description"><?php _e( 'Tip: for best results, use an email that exists on this domain.' , 'visual-form-builder'); ?></p>
36
- </td>
37
- </tr>
38
- <!-- Email Subject -->
39
- <tr valign="top">
40
- <th scope="row"><label for="form-email-subject"><?php _e( 'E-mail Subject' , 'visual-form-builder'); ?></label></th>
41
- <td>
42
- <input type="text" value="" placeholder="" class="regular-text" id="form-email-subject" name="form_email_subject" />
43
- <p class="description"><?php _e( 'This sets the subject of the email that is sent.' , 'visual-form-builder'); ?></p>
44
- </td>
45
- </tr>
46
- <!-- E-mail To -->
47
- <tr valign="top">
48
- <th scope="row"><label for="form-email-to"><?php _e( 'E-mail To' , 'visual-form-builder'); ?></label></th>
49
- <td>
50
- <input type="text" value="" placeholder="" class="regular-text" id="form-email-to" name="form_email_to[]" />
51
- <p class="description"><?php _e( 'Who to send the submitted data to. You can add more after creating the form.' , 'visual-form-builder'); ?></p>
52
- </td>
53
- </tr>
54
-
55
- </tbody>
56
- </table>
57
- <?php submit_button( __( 'Create Form', 'visual-form-builder' ) ); ?>
58
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/email.php DELETED
@@ -1,406 +0,0 @@
1
- <?php
2
- global $wpdb, $post;
3
-
4
- $required = ( isset( $_POST['_vfb-required-secret'] ) && $_POST['_vfb-required-secret'] == '0' ) ? false : true;
5
- $secret_field = ( isset( $_POST['_vfb-secret'] ) ) ? esc_html( $_POST['_vfb-secret'] ) : '';
6
- $honeypot = ( isset( $_POST['vfb-spam'] ) ) ? esc_html( $_POST['vfb-spam'] ) : '';
7
- $referrer = ( isset( $_POST['_wp_http_referer'] ) ) ? esc_html( $_POST['_wp_http_referer'] ) : false;
8
- $wp_get_referer = wp_get_referer();
9
-
10
- // If the verification is set to required, run validation check
11
- if ( true == $required && !empty( $secret_field ) ) {
12
- if ( !empty( $honeypot ) ) {
13
- wp_die( __( 'Security check: hidden spam field should be blank.' , 'visual-form-builder'), '', array( 'back_link' => true ) );
14
- }
15
-
16
- if ( !is_numeric( $_POST[ $secret_field ] ) || strlen( $_POST[ $secret_field ] ) !== 2 ) {
17
- wp_die( __( 'Security check: failed secret question. Please try again!' , 'visual-form-builder'), '', array( 'back_link' => true ) );
18
- }
19
- }
20
-
21
- // Basic security check before moving any further
22
- if ( !isset( $_POST['vfb-submit'] ) )
23
- return;
24
-
25
- // Get global settings
26
- $vfb_settings = get_option( 'vfb-settings' );
27
-
28
- // Settings - Max Upload Size
29
- $settings_max_upload = isset( $vfb_settings['max-upload-size'] ) ? $vfb_settings['max-upload-size'] : 25;
30
-
31
- // Settings - Spam word sensitivity
32
- $settings_spam_points = isset( $vfb_settings['spam-points'] ) ? $vfb_settings['spam-points'] : 4;
33
-
34
- // Set submitted action to display success message
35
- $this->submitted = true;
36
-
37
- // Tells us which form to get from the database
38
- $form_id = absint( $_POST['form_id'] );
39
-
40
- $skip_referrer_check = apply_filters( 'vfb_skip_referrer_check', false, $form_id );
41
-
42
- // Test if referral URL has been set
43
- if ( !$referrer )
44
- wp_die( __( 'Security check: referal URL does not appear to be set.' , 'visual-form-builder'), '', array( 'back_link' => true ) );
45
-
46
- // Allow referrer check to be skipped
47
- if ( !$skip_referrer_check ) :
48
- // Test if the referral URL matches what sent from WordPress
49
- if ( $wp_get_referer )
50
- wp_die( __( 'Security check: referal does not match this site.' , 'visual-form-builder'), '', array( 'back_link' => true ) );
51
- endif;
52
-
53
- // Test if it's a known SPAM bot
54
- if ( $this->isBot() )
55
- wp_die( __( 'Security check: looks like you are a SPAM bot. If you think this is an error, please email the site owner.' , 'visual-form-builder' ), '', array( 'back_link' => true ) );
56
-
57
- // Query to get all forms
58
- $order = sanitize_sql_orderby( 'form_id DESC' );
59
- $form = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
60
-
61
- $form_settings = (object) array(
62
- 'form_title' => stripslashes( html_entity_decode( $form->form_title, ENT_QUOTES, 'UTF-8' ) ),
63
- 'form_subject' => stripslashes( html_entity_decode( $form->form_email_subject, ENT_QUOTES, 'UTF-8' ) ),
64
- 'form_to' => ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) ),
65
- 'form_from' => stripslashes( $form->form_email_from ),
66
- 'form_from_name' => stripslashes( $form->form_email_from_name ),
67
- 'form_notification_setting' => stripslashes( $form->form_notification_setting ),
68
- 'form_notification_email_name' => stripslashes( $form->form_notification_email_name ),
69
- 'form_notification_email_from' => stripslashes( $form->form_notification_email_from ),
70
- 'form_notification_subject' => stripslashes( html_entity_decode( $form->form_notification_subject, ENT_QUOTES, 'UTF-8' ) ),
71
- 'form_notification_message' => stripslashes( $form->form_notification_message ),
72
- 'form_notification_entry' => stripslashes( $form->form_notification_entry )
73
- );
74
- // Allow the form settings to be filtered (ex: return $form_settings->'form_title' = 'Hello World';)
75
- $form_settings = (object) apply_filters_ref_array( 'vfb_email_form_settings', array( $form_settings, $form_id ) );
76
-
77
- // Sender name field ID
78
- $sender = $form->form_email_from_name_override;
79
-
80
- // Sender email field ID
81
- $email = $form->form_email_from_override;
82
-
83
- // Notifcation email field ID
84
- $notify = $form->form_notification_email;
85
-
86
- $reply_to_name = $form_settings->form_from_name;
87
- $reply_to_email = $form_settings->form_from;
88
-
89
- // Use field for sender name
90
- if ( !empty( $sender ) && isset( $_POST[ 'vfb-' . $sender ] ) ) {
91
- $form_settings->form_from_name = wp_kses_data( $_POST[ 'vfb-' . $sender ] );
92
- $reply_to_name = $form_settings->form_from_name;
93
- }
94
-
95
- // Use field for sender email
96
- if ( !empty( $email ) && isset( $_POST[ 'vfb-' . $email ] ) ) {
97
- $form_settings->form_from = sanitize_email( $_POST[ 'vfb-' . $email ] );
98
- $reply_to_email = $form_settings->form_from;
99
- }
100
-
101
- // Use field for copy email
102
- $copy_email = ( !empty( $notify ) ) ? sanitize_email( $_POST[ 'vfb-' . $notify ] ) : '';
103
-
104
- // Query to get all forms
105
- $order = sanitize_sql_orderby( 'field_sequence ASC' );
106
- $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 ) );
107
-
108
- // Setup counter for alt rows
109
- $i = $points = 0;
110
-
111
- // Setup HTML email vars
112
- $header = $body = $message = $footer = $html_email = $auto_response_email = $attachments = '';
113
-
114
- // Prepare the beginning of the content
115
- $header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
116
- <html>
117
- <head>
118
- <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
119
- <title>HTML Email</title>
120
- </head>
121
- <body><table rules="all" style="border-color: #666;" cellpadding="10">' . "\n";
122
-
123
- // Loop through each form field and build the body of the message
124
- foreach ( $fields as $field ) :
125
- // Handle attachments
126
- if ( $field->field_type == 'file-upload' ) :
127
- $value = ( isset( $_FILES[ 'vfb-' . $field->field_id ] ) ) ? $_FILES[ 'vfb-' . $field->field_id ] : '';
128
-
129
- if ( is_array( $value) && $value['size'] > 0 ) :
130
- // 25MB is the max size allowed
131
- $size = apply_filters( 'vfb_max_file_size', $settings_max_upload );
132
- $max_attach_size = $size * 1048576;
133
-
134
- // Display error if file size has been exceeded
135
- if ( $value['size'] > $max_attach_size )
136
- wp_die( sprintf( __( "File size exceeds %dMB. Please decrease the file size and try again.", 'visual-form-builder' ), $size ), '', array( 'back_link' => true ) );
137
-
138
- // Options array for the wp_handle_upload function. 'test_form' => false
139
- $upload_overrides = array( 'test_form' => false );
140
-
141
- // We need to include the file that runs the wp_handle_upload function
142
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
143
-
144
- // Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array
145
- $uploaded_file = wp_handle_upload( $value, $upload_overrides );
146
-
147
- // If the wp_handle_upload call returned a local path for the image
148
- if ( isset( $uploaded_file['file'] ) ) :
149
- // Retrieve the file type from the file name. Returns an array with extension and mime type
150
- $wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );
151
-
152
- // Return the current upload directory location
153
- $wp_upload_dir = wp_upload_dir();
154
-
155
- $media_upload = array(
156
- 'guid' => $wp_upload_dir['url'] . '/' . basename( $uploaded_file['file'] ),
157
- 'post_mime_type' => $wp_filetype['type'],
158
- 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $uploaded_file['file'] ) ),
159
- 'post_content' => '',
160
- 'post_status' => 'inherit'
161
- );
162
-
163
- // Insert attachment into Media Library and get attachment ID
164
- $attach_id = wp_insert_attachment( $media_upload, $uploaded_file['file'] );
165
-
166
- // Include the file that runs wp_generate_attachment_metadata()
167
- require_once( ABSPATH . 'wp-admin/includes/image.php' );
168
- require_once( ABSPATH . 'wp-admin/includes/media.php' );
169
-
170
- // Setup attachment metadata
171
- $attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_file['file'] );
172
-
173
- // Update the attachment metadata
174
- wp_update_attachment_metadata( $attach_id, $attach_data );
175
-
176
- $attachments[ 'vfb-' . $field->field_id ] = $uploaded_file['file'];
177
-
178
- $data[] = array(
179
- 'id' => $field->field_id,
180
- 'slug' => $field->field_key,
181
- 'name' => $field->field_name,
182
- 'type' => $field->field_type,
183
- 'options' => $field->field_options,
184
- 'parent_id' => $field->field_parent,
185
- 'value' => $uploaded_file['url']
186
- );
187
-
188
- $body .= sprintf(
189
- '<tr>
190
- <td><strong>%1$s: </strong></td>
191
- <td><a href="%2$s">%2$s</a></td>
192
- </tr>' . "\n",
193
- stripslashes( $field->field_name ),
194
- $uploaded_file['url']
195
- );
196
- endif;
197
- else :
198
- $value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
199
- $body .= sprintf(
200
- '<tr>
201
- <td><strong>%1$s: </strong></td>
202
- <td>%2$s</td>
203
- </tr>' . "\n",
204
- stripslashes( $field->field_name ),
205
- $value
206
- );
207
- endif;
208
-
209
- // Everything else
210
- else :
211
- $value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
212
-
213
- // If time field, build proper output
214
- if ( is_array( $value ) && $field->field_type == 'time' )
215
- $value = $this->build_array_form_item( $value, $field->field_type );
216
- // If address field, build proper output
217
- elseif ( is_array( $value ) && $field->field_type == 'address' )
218
- $value = $this->build_array_form_item( $value, $field->field_type );
219
- // If multiple values, build the list
220
- elseif ( is_array( $value ) )
221
- $value = $this->build_array_form_item( $value, $field->field_type );
222
- elseif ( 'radio' == $field->field_type )
223
- $value = wp_specialchars_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES );
224
- // Lastly, handle single values
225
- else
226
- $value = html_entity_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES, 'UTF-8' );
227
-
228
- // Spam Words - Exploits
229
- $exploits = array( 'content-type', 'bcc:', 'cc:', 'document.cookie', 'onclick', 'onload', 'javascript', 'alert' );
230
- $exploits = apply_filters( 'vfb_spam_words_exploits', $exploits, $form_id );
231
-
232
- // Spam Words - Exploits
233
- $profanity = array( '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' );
234
- $profanity = apply_filters( 'vfb_spam_words_profanity', $profanity, $form_id );
235
-
236
- // Spam Words - Misc
237
- $spamwords = array( 'viagra', 'phentermine', 'tramadol', 'adipex', 'advai', 'alprazolam', 'ambien', 'ambian', 'amoxicillin', 'antivert', 'blackjack', 'backgammon', 'holdem', 'poker', 'carisoprodol', 'ciara', 'ciprofloxacin', 'debt', 'dating', 'porn' );
238
- $spamwords = apply_filters( 'vfb_spam_words_misc', $spamwords, $form_id );
239
-
240
- // Add up points for each spam hit
241
- if ( preg_match( '/(' . implode( '|', $exploits ) . ')/i', $value ) )
242
- $points += 2;
243
- elseif ( preg_match( '/(' . implode( '|', $profanity ) . ')/i', $value ) )
244
- $points += 1;
245
- elseif ( preg_match( '/(' . implode( '|', $spamwords ) . ')/i', $value ) )
246
- $points += 1;
247
-
248
- //Sanitize input
249
- $value = $this->sanitize_input( $value, $field->field_type );
250
- // Validate input
251
- $this->validate_input( $value, $field->field_name, $field->field_type, $field->field_required );
252
-
253
- $removed_field_types = array( 'verification', 'secret', 'submit' );
254
-
255
- // Don't add certain fields to the email
256
- if ( ! in_array( $field->field_type, $removed_field_types ) ) :
257
- if ( $field->field_type == 'fieldset' ) :
258
- $body .= sprintf(
259
- '<tr style="background-color:#393E40;color:white;font-size:14px;">
260
- <td colspan="2">%1$s</td>
261
- </tr>' . "\n",
262
- stripslashes( $field->field_name )
263
- );
264
- elseif ( $field->field_type == 'section' ) :
265
- $body .= sprintf(
266
- '<tr style="background-color:#6E7273;color:white;font-size:14px;">
267
- <td colspan="2">%1$s</td>
268
- </tr>' . "\n",
269
- stripslashes( $field->field_name )
270
- );
271
- else :
272
- // Convert new lines to break tags for textarea in html
273
- $display_value = ( 'textarea' == $field->field_type ) ? nl2br( $value ) : $value;
274
-
275
- $body .= sprintf(
276
- '<tr>
277
- <td><strong>%1$s: </strong></td>
278
- <td>%2$s</td>
279
- </tr>' . "\n",
280
- stripslashes( $field->field_name ),
281
- $display_value
282
- );
283
- endif;
284
- endif;
285
-
286
- $data[] = array(
287
- 'id' => $field->field_id,
288
- 'slug' => $field->field_key,
289
- 'name' => $field->field_name,
290
- 'type' => $field->field_type,
291
- 'options' => $field->field_options,
292
- 'parent_id' => $field->field_parent,
293
- 'value' => esc_html( $value )
294
- );
295
-
296
- endif;
297
-
298
- // If the user accumulates more than 4 points, it might be spam
299
- if ( $points > $settings_spam_points )
300
- wp_die( __( 'Your responses look too much like spam and could not be sent at this time.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
301
- endforeach;
302
-
303
- // Setup our entries data
304
- $entry = array(
305
- 'form_id' => $form_id,
306
- 'data' => serialize( $data ),
307
- 'subject' => $form_settings->form_subject,
308
- 'sender_name' => $form_settings->form_from_name,
309
- 'sender_email' => $form_settings->form_from,
310
- 'emails_to' => serialize( $form_settings->form_to ),
311
- 'date_submitted' => date_i18n( 'Y-m-d H:i:s' ),
312
- 'ip_address' => esc_html( $_SERVER['REMOTE_ADDR'] )
313
- );
314
-
315
- // Insert this data into the entries table
316
- $wpdb->insert( $this->entries_table_name, $entry );
317
-
318
- // Close out the content
319
- $footer .= '<tr>
320
- <td class="footer" height="61" align="left" valign="middle" colspan="2">
321
- <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>
322
- </td>
323
- </tr>
324
- </table>
325
- </body>
326
- </html>' . "\n";
327
-
328
- // Build complete HTML email
329
- $message = $header . $body . $footer;
330
-
331
- // Wrap lines longer than 70 words to meet email standards
332
- $message = wordwrap( $message, 70 );
333
-
334
- // Decode HTML for message so it outputs properly
335
- $notify_message = ( $form_settings->form_notification_message !== '' ) ? html_entity_decode( $form_settings->form_notification_message ) : '';
336
-
337
- // Initialize header filter vars
338
- $header_from_name = function_exists( 'mb_encode_mimeheader' ) ? mb_encode_mimeheader( stripslashes( $reply_to_name ) ) : stripslashes( $reply_to_name );
339
- $header_from = $reply_to_email;
340
- $header_content_type = 'text/html';
341
-
342
- // Either prepend the notification message to the submitted entry, or send by itself
343
- if ( $form_settings->form_notification_entry !== '' )
344
- $auto_response_email = $header . $notify_message . $body . $footer;
345
- else
346
- $auto_response_email = sprintf( '%1$s<table cellspacing="0" border="0" cellpadding="0" width="100%%"><tr><td colspan="2" class="mainbar" align="left" valign="top" width="600">%2$s</td></tr>%3$s', $header, $notify_message, $footer );
347
-
348
-
349
- // Build email headers
350
- $from_name = ( $header_from_name == '' ) ? 'WordPress' : $header_from_name;
351
-
352
- // Use the admin_email as the From email
353
- $from_email = get_site_option( 'admin_email' );
354
-
355
- // Get the site domain and get rid of www.
356
- $sitename = strtolower( $_SERVER['SERVER_NAME'] );
357
- if ( substr( $sitename, 0, 4 ) == 'www.' )
358
- $sitename = substr( $sitename, 4 );
359
-
360
- // Get the domain from the admin_email
361
- list( $user, $domain ) = explode( '@', $from_email );
362
-
363
- // If site domain and admin_email domain match, use admin_email, otherwise a same domain email must be created
364
- $from_email = ( $sitename == $domain ) ? $from_email : "wordpress@$sitename";
365
-
366
- // Settings - Sender Mail Header
367
- $settings_sender_header = isset( $vfb_settings['sender-mail-header'] ) ? $vfb_settings['sender-mail-header'] : $from_email;
368
-
369
- // Allow Sender email to be filtered
370
- $from_email = apply_filters( 'vfb_sender_mail_header', $settings_sender_header, $form_id );
371
-
372
- $reply_to = "\"$from_name\" <$header_from>";
373
- $headers[] = "Sender: $from_email";
374
- $headers[] = "From: $reply_to";
375
- $headers[] = "Reply-To: $reply_to";
376
- $headers[] = "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"";
377
-
378
- $form_subject = wp_specialchars_decode( $form_settings->form_subject, ENT_QUOTES );
379
- $notify_subject = wp_specialchars_decode( $form_settings->form_notification_subject, ENT_QUOTES );
380
-
381
- // Sanitize main emails_to
382
- $emails_to = array_map( 'sanitize_email', $form_settings->form_to );
383
-
384
- // Send the mail
385
- foreach ( $emails_to as $email ) {
386
- wp_mail( $email, $form_subject, $message, $headers, $attachments );
387
- }
388
-
389
- // Send auto-responder email
390
- if ( $form_settings->form_notification_setting !== '' ) :
391
-
392
- $attachments = ( $form_settings->form_notification_entry !== '' ) ? $attachments : '';
393
-
394
- // Reset headers for notification email
395
- $reply_name = function_exists( 'mb_encode_mimeheader' ) ? mb_encode_mimeheader( stripslashes( $form_settings->form_notification_email_name ) ) : stripslashes( $form_settings->form_notification_email_name );
396
- $reply_email = $form_settings->form_notification_email_from;
397
- $reply_to = "\"$reply_name\" <$reply_email>";
398
- $headers[] = "Sender: $from_email";
399
- $headers[] = "From: $reply_to";
400
- $headers[] = "Reply-To: $reply_to";
401
- $headers[] = "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"";
402
-
403
- // Send the mail
404
- wp_mail( $copy_email, $notify_subject, $auto_response_email, $headers, $attachments );
405
-
406
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/form-output.php DELETED
@@ -1,639 +0,0 @@
1
- <?php
2
- global $wpdb;
3
-
4
- // Get global settings
5
- $vfb_settings = get_option( 'vfb-settings' );
6
-
7
- // Settings - Place Address labels above fields
8
- $settings_address_labels = isset( $vfb_settings['address-labels'] ) ? false : true;
9
-
10
- // Extract shortcode attributes, set defaults
11
- extract( shortcode_atts( array(
12
- 'id' => ''
13
- ), $atts )
14
- );
15
-
16
- // Add JavaScript files to the front-end, only once
17
- if ( !$this->add_scripts )
18
- $this->scripts();
19
-
20
- // Get form id. Allows use of [vfb id=1] or [vfb 1]
21
- $form_id = ( isset( $id ) && !empty( $id ) ) ? (int) $id : key( $atts );
22
-
23
- // If form is submitted, show success message, otherwise the form
24
- if ( isset( $_POST['vfb-submit'] ) && isset( $_POST['form_id'] ) && $_POST['form_id'] == $form_id ) {
25
- $output = $this->confirmation();
26
- return;
27
- }
28
-
29
- $order = sanitize_sql_orderby( 'form_id DESC' );
30
- $form = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
31
-
32
- // Return if no form found
33
- if ( !$form )
34
- return;
35
-
36
- // Get fields
37
- $order_fields = sanitize_sql_orderby( 'field_sequence ASC' );
38
- $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d ORDER BY $order_fields", $form_id ) );
39
-
40
- // Setup default variables
41
- $count = 1;
42
- $open_fieldset = $open_section = false;
43
- $submit = 'Submit';
44
- $verification = '';
45
-
46
- $label_alignment = ( $form->form_label_alignment !== '' ) ? esc_attr( " $form->form_label_alignment" ) : '';
47
-
48
- // Start form container
49
- $output .= sprintf( '<div id="vfb-form-%d" class="visual-form-builder-container">', $form_id );
50
-
51
- $output .= sprintf(
52
- '<form id="%1$s-%2$d" class="visual-form-builder %3$s %4$s" method="post" enctype="multipart/form-data">
53
- <input type="hidden" name="form_id" value="%5$d" />',
54
- esc_attr( $form->form_key ),
55
- $form_id,
56
- "vfb-form-$form_id",
57
- $label_alignment,
58
- absint( $form->form_id )
59
- );
60
- foreach ( $fields as $field ) :
61
- $field_id = absint( $field->field_id );
62
- $field_type = esc_html( $field->field_type );
63
- $field_name = esc_html( stripslashes( $field->field_name ) );
64
- $required_span = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' <span class="vfb-required-asterisk">*</span>' : '';
65
- $required = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? esc_attr( ' required' ) : '';
66
- $validation = ( !empty( $field->field_validation ) ) ? esc_attr( " $field->field_validation" ) : '';
67
- $css = ( !empty( $field->field_css ) ) ? esc_attr( " $field->field_css" ) : '';
68
- $id_attr = "vfb-{$field_id}";
69
- $size = ( !empty( $field->field_size ) ) ? esc_attr( " vfb-$field->field_size" ) : '';
70
- $layout = ( !empty( $field->field_layout ) ) ? esc_attr( " vfb-$field->field_layout" ) : '';
71
- $default = ( !empty( $field->field_default ) ) ? wp_specialchars_decode( esc_html( stripslashes( $field->field_default ) ), ENT_QUOTES ) : '';
72
- $description = ( !empty( $field->field_description ) ) ? wp_specialchars_decode( esc_html( stripslashes( $field->field_description ) ), ENT_QUOTES ) : '';
73
-
74
- // Close each section
75
- if ( $open_section == true ) :
76
- // If this field's parent does NOT equal our section ID
77
- if ( $sec_id && $sec_id !== absint( $field->field_parent ) ) :
78
- $output .= '</div><div class="vfb-clear"></div>';
79
- $open_section = false;
80
- endif;
81
- endif;
82
-
83
- // Force an initial fieldset and display an error message to strongly encourage user to add one
84
- if ( $count === 1 && $field_type !== 'fieldset' ) :
85
- $output .= sprintf( '<fieldset class="vfb-fieldset"><div class="vfb-legend" style="background-color:#FFEBE8;border:1px solid #CC0000;"><h3>%1$s</h3><p style="color:black;">%2$s</p></div><ul class="section section-%3$d">',
86
- __( 'Oops! Missing Fieldset', 'visual-form-builder' ),
87
- __( '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.', 'visual-form-builder' ),
88
- $count
89
- );
90
-
91
- $count++;
92
- endif;
93
-
94
- if ( $field_type == 'fieldset' ) :
95
- // Close each fieldset
96
- if ( $open_fieldset == true )
97
- $output .= '</ul>&nbsp;</fieldset>';
98
-
99
- // Only display Legend if field name is not blank
100
- $legend = !empty( $field_name ) ? sprintf( '<div class="vfb-legend"><h3>%s</h3></div>', $field_name ) : '&nbsp;';
101
-
102
- $output .= sprintf(
103
- '<fieldset class="vfb-fieldset vfb-fieldset-%1$d %2$s %3$s" id="item-%4$s">%5$s<ul class="vfb-section vfb-section-%1$d">',
104
- $count,
105
- esc_attr( $field->field_key ),
106
- $css,
107
- $id_attr,
108
- $legend
109
- );
110
-
111
- $open_fieldset = true;
112
- $count++;
113
-
114
- elseif ( $field_type == 'section' ) :
115
-
116
- $output .= sprintf(
117
- '<div id="item-%1$s" class="vfb-section-div %2$s"><h4>%3$s</h4>',
118
- $id_attr,
119
- $css,
120
- $field_name
121
- );
122
-
123
- // Save section ID for future comparison
124
- $sec_id = $field_id;
125
- $open_section = true;
126
-
127
- elseif ( !in_array( $field_type, array( 'verification', 'secret', 'submit' ) ) ) :
128
-
129
- $columns_choice = ( !empty( $field->field_size ) && in_array( $field_type, array( 'radio', 'checkbox' ) ) ) ? esc_attr( " vfb-$field->field_size" ) : '';
130
-
131
- if ( $field_type !== 'hidden' ) :
132
-
133
- // Don't add for attribute for certain form items
134
- $for = !in_array( $field_type, array( 'checkbox', 'radio', 'time', 'address', 'instructions' ) ) ? ' for="%4$s"' : '';
135
-
136
- $output .= sprintf(
137
- '<li class="vfb-item vfb-item-%1$s %2$s %3$s" id="item-%4$s"><label' . $for . ' class="vfb-desc">%5$s %6$s</label>',
138
- $field_type,
139
- $columns_choice,
140
- $layout,
141
- $id_attr,
142
- $field_name,
143
- $required_span
144
- );
145
- endif;
146
-
147
- elseif ( in_array( $field_type, array( 'verification', 'secret' ) ) ) :
148
-
149
- if ( $field_type == 'verification' ) :
150
- $verification .= sprintf(
151
- '<fieldset class="vfb-fieldset vfb-fieldset-%1$d %2$s %3$s" id="item-%4$s" style="display:block"><div class="vfb-legend"><h3>%5$s</h3></div><ul class="vfb-section vfb-section-%1$d">',
152
- $count,
153
- esc_attr( $field->field_key ),
154
- $css,
155
- $id_attr,
156
- $field_name
157
- );
158
- endif;
159
-
160
- if ( $field_type == 'secret' ) :
161
- // Default logged in values
162
- $logged_in_display = $logged_in_value = '';
163
-
164
- // If the user is logged in, fill the field in for them
165
- if ( is_user_logged_in() ) :
166
- // Hide the secret field if logged in
167
- $logged_in_display = ' style="display:none;"';
168
- $logged_in_value = 14;
169
-
170
- // Get logged in user details
171
- $user = wp_get_current_user();
172
- $user_identity = ! empty( $user->ID ) ? $user->display_name : '';
173
-
174
- // Display a message for logged in users
175
- $logged_in_as = sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. Verification not required.', 'visual-form-builder-pro' ), admin_url( 'profile.php' ), $user_identity );
176
-
177
- $verification .= sprintf(
178
- '<li class="vfb-item" id="%1$s">%2$s</li>',
179
- $id_attr,
180
- $logged_in_as
181
- );
182
- endif;
183
-
184
- $verification .= sprintf(
185
- '<li class="vfb-item vfb-item-%1$s" %2$s style="display:block"><label for="%3$s" class="vfb-desc">%4$s%5$s</label>',
186
- $field_type,
187
- $logged_in_display,
188
- $id_attr,
189
- $field_name,
190
- $required_span
191
- );
192
-
193
- // Set variable for testing if required is Yes/No
194
- $verification .= ( empty( $required ) ) ? '<input type="hidden" name="_vfb-required-secret" value="0" />' : '';
195
-
196
- // Set hidden secret to matching input
197
- $verification .= sprintf( '<input type="hidden" name="_vfb-secret" value="vfb-%d" />', $field_id );
198
-
199
- $validation = '{digits:true,maxlength:2,minlength:2}';
200
-
201
- $verification_item = sprintf(
202
- '<input type="text" name="vfb-%1$d" id="%2$s" value="%3$s" class="vfb-text %4$s %5$s %6$s %7$s" style="display:block" />',
203
- $field_id,
204
- $id_attr,
205
- $logged_in_value,
206
- $size,
207
- $required,
208
- $validation,
209
- $css
210
- );
211
-
212
- $verification .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span">%1$s<label>%2$s</label></span>', $verification_item, $description ) : $verification_item;
213
-
214
- endif;
215
- endif;
216
-
217
- switch ( $field_type ) {
218
- case 'text' :
219
- case 'email' :
220
- case 'url' :
221
- case 'currency' :
222
- case 'number' :
223
- case 'phone' :
224
-
225
- // HTML5 types
226
- if ( in_array( $field_type, array( 'email', 'url' ) ) )
227
- $type = esc_attr( $field_type );
228
- elseif ( 'phone' == $field_type )
229
- $type = 'tel';
230
- else
231
- $type = 'text';
232
-
233
- $form_item = sprintf(
234
- '<input type="%8$s" name="vfb-%1$d" id="%2$s" value="%3$s" class="vfb-text %4$s %5$s %6$s %7$s" />',
235
- $field_id,
236
- $id_attr,
237
- $default,
238
- $size,
239
- $required,
240
- $validation,
241
- $css,
242
- $type
243
- );
244
-
245
- $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span">%1$s<label>%2$s</label></span>', $form_item, $description ) : $form_item;
246
-
247
- break;
248
-
249
- case 'textarea' :
250
-
251
- $form_item = sprintf(
252
- '<textarea name="vfb-%1$d" id="%2$s" class="vfb-textarea %4$s %5$s %6$s">%3$s</textarea>',
253
- $field_id,
254
- $id_attr,
255
- $default,
256
- $size,
257
- $required,
258
- $css
259
- );
260
-
261
- $output .= '<div>';
262
-
263
- $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span"><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
264
-
265
- $output .= '</div>';
266
-
267
- break;
268
-
269
- case 'select' :
270
-
271
- $field_options = maybe_unserialize( $field->field_options );
272
-
273
- $options = '';
274
-
275
- // Loop through each option and output
276
- foreach ( $field_options as $option => $value ) {
277
- $options .= sprintf( '<option value="%1$s"%2$s>%1$s</option>', esc_attr(trim( stripslashes( $value ) ) ), selected( $default, ++$option, 0 ) );
278
- }
279
-
280
- $form_item = sprintf(
281
- '<select name="vfb-%1$d" id="%2$s" class="vfb-select %3$s %4$s %5$s">%6$s</select>',
282
- $field_id,
283
- $id_attr,
284
- $size,
285
- $required,
286
- $css,
287
- $options
288
- );
289
-
290
- $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span"><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
291
-
292
- break;
293
-
294
- case 'radio' :
295
-
296
- $field_options = maybe_unserialize( $field->field_options );
297
-
298
- $options = '';
299
-
300
- // Loop through each option and output
301
- foreach ( $field_options as $option => $value ) {
302
- $option++;
303
-
304
- $options .= sprintf(
305
- '<span class="vfb-span"><input type="radio" name="vfb-%1$d" id="%2$s-%3$d" value="%6$s" class="vfb-radio %4$s %5$s"%8$s /><label for="%2$s-%3$d" class="vfb-choice">%7$s</label></span>',
306
- $field_id,
307
- $id_attr,
308
- $option,
309
- $required,
310
- $css,
311
- esc_attr( trim( stripslashes( $value ) ) ),
312
- wp_specialchars_decode( stripslashes( $value ) ),
313
- checked( $default, $option, 0 )
314
- );
315
- }
316
-
317
- $form_item = $options;
318
-
319
- $output .= '<div>';
320
-
321
- $output .= ( !empty( $description ) ) ? sprintf( '<span><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
322
-
323
- $output .= '<div style="clear:both"></div></div>';
324
-
325
- break;
326
-
327
- case 'checkbox' :
328
-
329
- $field_options = maybe_unserialize( $field->field_options );
330
-
331
- $options = '';
332
-
333
- // Loop through each option and output
334
- foreach ( $field_options as $option => $value ) {
335
- $options .= sprintf(
336
- '<span class="vfb-span"><input type="checkbox" name="vfb-%1$d[]" id="%2$s-%3$d" value="%6$s" class="vfb-checkbox %4$s %5$s"%8$s /><label for="%2$s-%3$d" class="vfb-choice">%7$s</label></span>',
337
- $field_id,
338
- $id_attr,
339
- $option,
340
- $required,
341
- $css,
342
- esc_attr( trim( stripslashes( $value ) ) ),
343
- wp_specialchars_decode( stripslashes( $value ) ),
344
- checked( $default, ++$option, 0 )
345
- );
346
- }
347
-
348
- $form_item = $options;
349
-
350
- $output .= '<div>';
351
-
352
- $output .= ( !empty( $description ) ) ? sprintf( '<span><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
353
-
354
- $output .= '<div style="clear:both"></div></div>';
355
-
356
- break;
357
-
358
- case 'address' :
359
-
360
- $address = '';
361
-
362
- $address_parts = array(
363
- 'address' => array(
364
- 'label' => __( 'Street Address', 'visual-form-builder' ),
365
- 'layout' => 'full'
366
- ),
367
- 'address-2' => array(
368
- 'label' => __( 'Apt, Suite, Bldg. (optional)', 'visual-form-builder' ),
369
- 'layout' => 'full'
370
- ),
371
- 'city' => array(
372
- 'label' => __( 'City', 'visual-form-builder' ),
373
- 'layout' => 'left'
374
- ),
375
- 'state' => array(
376
- 'label' => __( 'State / Province / Region', 'visual-form-builder' ),
377
- 'layout' => 'right'
378
- ),
379
- 'zip' => array(
380
- 'label' => __( 'Postal / Zip Code', 'visual-form-builder' ),
381
- 'layout' => 'left'
382
- ),
383
- 'country' => array(
384
- 'label' => __( 'Country', 'visual-form-builder' ),
385
- 'layout' => 'right'
386
- )
387
- );
388
-
389
- $address_parts = apply_filters( 'vfb_address_labels', $address_parts, $form_id );
390
-
391
- $label_placement = apply_filters( 'vfb_address_labels_placement', $settings_address_labels, $form_id );
392
-
393
- $placement_bottom = ( $label_placement ) ? '<label for="%2$s-%4$s">%5$s</label>' : '';
394
- $placement_top = ( !$label_placement ) ? '<label for="%2$s-%4$s">%5$s</label>' : '';
395
-
396
- foreach ( $address_parts as $parts => $part ) :
397
-
398
- // Make sure the second address line is not required
399
- $addr_required = ( 'address-2' !== $parts ) ? $required : '';
400
-
401
- if ( 'country' == $parts ) :
402
-
403
- $options = '';
404
-
405
- foreach ( $this->countries as $country ) {
406
- $options .= sprintf( '<option value="%1$s"%2$s>%1$s</option>', $country, selected( $default, $country, 0 ) );
407
- }
408
-
409
- $address .= sprintf(
410
- '<span class="vfb-%3$s">' . $placement_top . '<select name="vfb-%1$d[%4$s]" class="vfb-select %7$s %8$s" id="%2$s-%4$s">%6$s</select>' . $placement_bottom . '</span>',
411
- $field_id,
412
- $id_attr,
413
- esc_attr( $part['layout'] ),
414
- esc_attr( $parts ),
415
- esc_html( $part['label'] ),
416
- $options,
417
- $addr_required,
418
- $css
419
- );
420
-
421
- else :
422
-
423
- $address .= sprintf(
424
- '<span class="vfb-%3$s">' . $placement_top . '<input type="text" name="vfb-%1$d[%4$s]" id="%2$s-%4$s" maxlength="150" class="vfb-text vfb-medium %7$s %8$s" />' . $placement_bottom . '</span>',
425
- $field_id,
426
- $id_attr,
427
- esc_attr( $part['layout'] ),
428
- esc_attr( $parts ),
429
- esc_html( $part['label'] ),
430
- $size,
431
- $addr_required,
432
- $css
433
- );
434
-
435
- endif;
436
-
437
- endforeach;
438
-
439
- $output .= '<div>';
440
-
441
- $output .= !empty( $description ) ? "<span class='vfb-span'><label>$description</label></span>$address" : $address;
442
-
443
- $output .= '</div>';
444
-
445
- break;
446
-
447
- case 'date' :
448
- // Load jQuery UI datepicker library
449
- wp_enqueue_script( 'jquery-ui-datepicker' );
450
- wp_enqueue_script( 'vfb-datepicker-i18n' );
451
-
452
- $options = maybe_unserialize( $field->field_options );
453
- $dateFormat = ( $options ) ? $options['dateFormat'] : '';
454
-
455
- $form_item = sprintf(
456
- '<input type="text" name="vfb-%1$d" id="%2$s" value="%3$s" class="vfb-text vfb-date-picker %4$s %5$s %6$s" data-dp-dateFormat="%7$s" />',
457
- $field_id,
458
- $id_attr,
459
- $default,
460
- $size,
461
- $required,
462
- $css,
463
- $dateFormat
464
- );
465
-
466
- $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span">%1$s<label>%2$s</label></span>', $form_item, $description ) : $form_item;
467
-
468
- break;
469
-
470
- case 'time' :
471
-
472
- $hour = $minute = $ampm = '';
473
-
474
- // Get the time format (12 or 24)
475
- $time_format = str_replace( 'time-', '', $validation );
476
-
477
- $time_format = apply_filters( 'vfb_time_format', $time_format, $form_id );
478
- $total_mins = apply_filters( 'vfb_time_min_total', 55, $form_id );
479
- $min_interval = apply_filters( 'vfb_time_min_interval', 5, $form_id );
480
-
481
- // Set whether we start with 0 or 1 and how many total hours
482
- $hour_start = ( $time_format == '12' ) ? 1 : 0;
483
- $hour_total = ( $time_format == '12' ) ? 12 : 23;
484
-
485
- // Hour
486
- for ( $i = $hour_start; $i <= $hour_total; $i++ ) {
487
- $hour .= sprintf( '<option value="%1$02d">%1$02d</option>', $i );
488
- }
489
-
490
- // Minute
491
- for ( $i = 0; $i <= $total_mins; $i += $min_interval ) {
492
- $minute .= sprintf( '<option value="%1$02d">%1$02d</option>', $i );
493
- }
494
-
495
- // AM/PM
496
- if ( $time_format == '12' ) {
497
- $ampm = sprintf(
498
- '<span class="vfb-time"><select name="vfb-%1$d[ampm]" id="%2$s-ampm" class="vfb-select %5$s %6$s"><option value="AM">AM</option><option value="PM">PM</option></select><label for="%2$s-ampm">AM/PM</label></span>',
499
- $field_id,
500
- $id_attr,
501
- $hour,
502
- $minute,
503
- $required,
504
- $css
505
- );
506
- }
507
-
508
- $form_item = sprintf(
509
- '<span class="vfb-time"><select name="vfb-%1$d[hour]" id="%2$s-hour" class="vfb-select %5$s %6$s">%3$s</select><label for="%2$s-hour">HH</label></span>' .
510
- '<span class="vfb-time"><select name="vfb-%1$d[min]" id="%2$s-min" class="vfb-select %5$s %6$s">%4$s</select><label for="%2$s-min">MM</label></span>' .
511
- '%7$s',
512
- $field_id,
513
- $id_attr,
514
- $hour,
515
- $minute,
516
- $required,
517
- $css,
518
- $ampm
519
- );
520
-
521
- $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span"><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
522
-
523
- $output .= '<div class="clear"></div>';
524
-
525
- break;
526
-
527
- case 'html' :
528
- //Load CKEditor library
529
- wp_enqueue_script( 'vfb-ckeditor' );
530
-
531
- $form_item = sprintf(
532
- '<textarea name="vfb-%1$d" id="%2$s" class="vfb-textarea ckeditor %4$s %5$s %6$s">%3$s</textarea>',
533
- $field_id,
534
- $id_attr,
535
- $default,
536
- $size,
537
- $required,
538
- $css
539
- );
540
-
541
- $output .= '<div>';
542
-
543
- $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span"><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
544
-
545
- $output .= '</div>';
546
-
547
- break;
548
-
549
- case 'file-upload' :
550
-
551
- $options = maybe_unserialize( $field->field_options );
552
- $accept = ( !empty( $options[0] ) ) ? " {accept:'$options[0]'}" : '';
553
-
554
-
555
- $form_item = sprintf(
556
- '<input type="file" name="vfb-%1$d" id="%2$s" value="%3$s" class="vfb-text %4$s %5$s %6$s %7$s %8$s" />',
557
- $field_id,
558
- $id_attr,
559
- $default,
560
- $size,
561
- $required,
562
- $validation,
563
- $css,
564
- $accept
565
- );
566
-
567
- $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span">%1$s<label>%2$s</label></span>', $form_item, $description ) : $form_item;
568
-
569
- break;
570
-
571
- case 'instructions' :
572
-
573
- $output .= wp_specialchars_decode( esc_html( stripslashes( $description ) ), ENT_QUOTES );
574
-
575
- break;
576
-
577
- case 'submit' :
578
- $submit = sprintf(
579
- '<li class="vfb-item vfb-item-submit" id="item-%2$s">
580
- <input type="submit" name="vfb-submit" id="%2$s" value="%3$s" class="vfb-submit %4$s" />
581
- </li>',
582
- $field_id,
583
- $id_attr,
584
- wp_specialchars_decode( esc_html( $field_name ), ENT_QUOTES ),
585
- $css
586
- );
587
-
588
- break;
589
-
590
- default:
591
- echo '';
592
- }
593
-
594
- // Closing </li>
595
- $output .= ( !in_array( $field_type , array( 'verification', 'secret', 'submit', 'fieldset', 'section' ) ) ) ? '</li>' : '';
596
- endforeach;
597
-
598
-
599
- // Close user-added fields
600
- $output .= '</ul>&nbsp;</fieldset>';
601
-
602
- // Make sure the verification displays even if they have not updated their form
603
- if ( empty( $verification ) ) :
604
-
605
- $verification = sprintf(
606
- '<fieldset class="vfb-fieldset vfb-verification" style="display:block">
607
- <div class="vfb-legend"><h3>%1$s</h3></div>
608
- <ul class="vfb-section vfb-section-%2$d">
609
- <li class="vfb-item vfb-item-text" style="display:block">
610
- <label for="vfb-secret" class="vfb-desc">%3$s<span>*</span></label>
611
- <div><input type="text" name="vfb-secret" id="vfb-secret" class="vfb-text vfb-medium" style="display:block" /></div>
612
- </li>',
613
- __( 'Verification' , 'visual-form-builder'),
614
- $count,
615
- __( 'Please enter any two digits with <strong>no</strong> spaces (Example: 12)' , 'visual-form-builder')
616
- );
617
-
618
- endif;
619
-
620
- // Output our security test
621
- $output .= sprintf(
622
- $verification .
623
- '<li style="display:none;"><label>%1$s:</label><div><input name="vfb-spam" /></div></li>
624
- %2$s</ul>
625
- </fieldset>',
626
- __( 'This box is for spam protection - <strong>please leave it blank</strong>' , 'visual-form-builder'),
627
- $submit
628
- );
629
-
630
- $output .= wp_referer_field( false );
631
-
632
- // Close the form out
633
- $output .= '</form>';
634
-
635
- // Close form container
636
- $output .= '</div> <!-- .visual-form-builder-container -->';
637
-
638
- // Force tags to balance
639
- force_balance_tags( $output );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/vfb-admin.min.js DELETED
@@ -1 +0,0 @@
1
- jQuery(document).ready(function(h){if(window.VfbAdminPages){var g=VfbAdminPages.vfb_pages;if(pagenow==g.vfb){h(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles(g.vfb)}}var c=null;h(document).on("mouseenter mouseleave",".vfb-tooltip",function(q){if(q.type=="mouseenter"){if(c){clearTimeout(c);c=null}var n=h(this).attr("title"),p=h(this).attr("rel"),o=h(this).width();h(this).append('<div class="vfb-tooltip-popup"><h3>'+n+"</h3><p>"+p+"</p></div>");h.data(this,"title",n);this.title="";h(this).find(".vfb-tooltip-popup").css({left:o+22});c=setTimeout(function(){h(".vfb-tooltip-popup").fadeIn(300)},500)}else{this.title=h.data(this,"title");h(".vfb-tooltip-popup").fadeOut(500);h(this).children().remove()}});h(document).on("click","a.vfb-add-option",function(t){t.preventDefault();var x=h(this).parent().siblings(".vfb-cloned-options"),p=x.children(),r=p.length,q=r+1,n=p[r-1],o=h(n).attr("id"),v=h(n).children("label").attr("for");var u=v.replace(new RegExp(/(\d+)$/g),""),s=o.replace(new RegExp(/(\d+)$/g),"");var w=h("#"+o).clone().attr("id",s+q);w.children("label").attr("for",u+q);w.find('input[type="text"]').attr("id",u+q);w.find('input[type="radio"]').attr("value",q);h("#"+s+r).after(w)});h(document).on("click","a.deleteOption",function(o){o.preventDefault();var n=h(this).parent().parent().find(".clonedOption").length;if(n-1==0){alert("You must have at least one option.")}else{h(this).closest("div").remove()}});h(".vfb-cloned-options").sortable({items:"div.option"});h(document).on("click","a.addEmail",function(t){t.preventDefault();var o=h(this).closest("#email-details").find(".clonedOption").length;var s=o+1;var u=h(this).closest("div").attr("id");var r=h(this).closest("div").find("label").attr("for");var n=r.replace(new RegExp(/(\d+)$/g),"");var q=u.replace(new RegExp(/(\d+)$/g),"");var p=h("#"+u).clone().attr("id",q+s);p.find("label").attr("for",n+s);p.find("input").attr("id",n+s);h("#"+q+o).after(p)});h(document).on("click","a.deleteEmail",function(o){o.preventDefault();var n=h(this).closest("#email-details").find(".clonedOption").length;if(n-1==0){alert("You must have at least one option.")}else{h(this).closest("div").remove()}});h('.option input[type="radio"]').mousedown(function(){h(this).attr("previousValue",h(this).prop("checked"))}).click(function(){var n=h(this).attr("previousValue");if(n=="true"){h(this).prop("checked",false)}});h(".menu-delete").click(function(){var n=(h(this).hasClass("entry-delete"))?"entry":"form";var o=confirm("You are about to permanently delete this "+n+" and all of its data.\n'Cancel' to stop, 'OK' to delete.");if(o){return true}return false});h(document).on("click","a.item-edit",function(o){o.preventDefault();h(o.target).closest("li").children(".menu-item-settings").slideToggle("fast");h(this).toggleClass("opened");var n=h(o.target).closest("dl");if(n.hasClass("vfb-menu-item-inactive")){n.removeClass("vfb-menu-item-inactive").addClass("vfb-menu-item-active")}else{n.removeClass("vfb-menu-item-active").addClass("vfb-menu-item-inactive")}});function m(n){if("FIELDSET"!==n){h("#vfb-fieldset-first-warning").show()}else{h("#vfb-fieldset-first-warning").hide()}}h("#vfb-menu-to-edit").nestedSortable({listType:"ul",maxLevels:3,handle:".vfb-menu-item-handle",placeholder:"vfb-sortable-placeholder",forcePlaceholderSize:true,forceHelperSize:true,tolerance:"pointer",toleranceElement:"> dl",items:"li:not(.ui-state-disabled)",create:function(n,o){h(this).css("min-height",h(this).height())},start:function(n,o){o.placeholder.height(o.item.height())},stop:function(o,p){var n=h("#vfb-menu-to-edit .item-type:first").text();opts={url:ajaxurl,type:"POST",async:true,cache:false,data:{action:"visual_form_builder_sort_field",order:h(this).nestedSortable("toArray")},success:function(q){h("#loading-animation").hide();m(n);return}};h.ajax(opts)}});h("#form-items .vfb-draggable-form-items").click(function(n){n.preventDefault();h(this).data("submit_value",h(this).text())});h("#form-items .vfb-draggable-form-items").click(function(p){p.preventDefault();var q=h(this).closest("form").serializeArray(),o=h(this).data("submit_value"),n=h("#vfb-menu-to-edit li.ui-state-disabled:first").attr("id").match(new RegExp(/(\d+)$/g))[0];h("img.waiting").show();h.post(ajaxurl,{action:"visual_form_builder_create_field",data:q,field_type:o,previous:n,page:pagenow,nonce:h("#_wpnonce").val()}).done(function(r){h("img.waiting").hide();h(r).hide().insertBefore("#vfb-menu-to-edit li.ui-state-disabled:first").fadeIn()})});h(document).on("click","a.item-delete",function(v){v.preventDefault();var r=childs=new Array(),z=0,o=h(this).attr("href"),n=o.split("&"),u=confirm("You are about to permanently delete this field.\n'Cancel' to stop, 'OK' to delete.");if(!u){return false}for(var s=0;s<n.length;s++){var x=n[s].indexOf("=");var w=n[s].substring(0,x);var y=n[s].substring(x+1);r[w]=y}var p=h(this).closest(".form-item").find("ul").children();var q=p.parent().html();p.each(function(t){childs[t]=h(this).attr("id").match(new RegExp(/(\d+)$/g))[0]});var A=h(this).closest("li.form-item").parents("li.form-item");if(A.length){z=A.attr("id").match(new RegExp(/(\d+)$/g))[0]}h.post(ajaxurl,{action:"visual_form_builder_delete_field",form:r.form,field:r.field,child_ids:childs,parent_id:z,page:pagenow,nonce:r._wpnonce}).done(function(t){h("#form_item_"+r.field).addClass("deleting").animate({opacity:0,height:0},350,function(){h(this).before(q).remove()})})});h("#form-settings-button").click(function(p){p.preventDefault();h(this).toggleClass("current");h("#form-settings").slideToggle("fast");var n=h('input[name="form_id"]').val(),o=(h(this).hasClass("current"))?"opened":"closed";h.post(ajaxurl,{action:"visual_form_builder_form_settings",form:n,status:o,page:pagenow}).done(function(q){if(o=="closed"){h(".settings-links").removeClass("on");h(".settings-links:first").addClass("on");h(".form-details").slideUp("normal");h(".form-details:first").show("normal")}})});h(".settings-links").click(function(p){p.preventDefault();h(".settings-links").removeClass("on");h(".form-details").slideUp("fast");if(h(this).next("div").is(":hidden")==true){h(this).addClass("on");h(this).next().slideDown("normal")}var o=h('input[name="form_id"]').val(),n=this.hash.replace(/#/g,"");h.post(ajaxurl,{action:"visual_form_builder_form_settings",form:o,accordion:n,page:pagenow})});var b=false;h("#vfb-form-builder-management input, #vfb-form-builder-management select, #vfb-form-builder-management textarea").change(function(){j()});function j(){b=true}window.onbeforeunload=function(){if(b){return"The changes you made will be lost if you navigate away from this page."}};h(document).on("submit","#visual-form-builder-update",function(){window.onbeforeunload=null});if(h(".columns-2 #side-sortables").length>0){var a=h("#vfb_form_items_meta_box"),d=a.width(),e=a.offset(),f=a.nextAll(),i=false;h(window).on("scroll",function(){if(h(window).scrollTop()>e.top){a.stop().css({top:55,position:"fixed","z-index":"1",width:d});if(f.is(":visible")){i=true;f.stop().css({opacity:0.1})}}else{a.stop().css({top:0,position:"relative"});if(i){f.stop().css({opacity:1})}}})}var l=h(".form-success-type:checked").val();h("#form-success-message-"+l).show();h(".form-success-type").change(function(){var n=h(this).val();switch(n){case"text":h("#form-success-message-text").show();h("#form-success-message-page, #form-success-message-redirect").hide();break;case"page":h("#form-success-message-page").show();h("#form-success-message-text, #form-success-message-redirect").hide();break;case"redirect":h("#form-success-message-redirect").show();h("#form-success-message-text, #form-success-message-page").hide();break}});h(".vfb-field-types").click(function(o){o.preventDefault();h("#vfb-field-tabs li").removeClass("tabs");h(this).parent().addClass("tabs");h(".tabs-panel-active").removeClass("tabs-panel-active").addClass("tabs-panel-inactive");var n=this.hash;h(n).removeClass("tabs-panel-inactive").addClass("tabs-panel-active")});h("#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(n){return h("#form-notification-setting").is(":checked")}},form_notification_email_from:{required:function(n){return h("#form-notification-setting").is(":checked")},email:true},form_notification_email:{required:function(n){return h("#form-notification-setting").is(":checked")}}},errorPlacement:function(n,o){n.insertAfter(o.parent())}});h("#visual-form-builder-new-form").validate();h("#form_email_from_name_override").change(function(){if(h("#form_email_from_name_override").val()==""){h("#form-email-sender-name").prop("readonly",false)}else{h("#form-email-sender-name").prop("readonly","readonly")}});h("#form_email_from_override").change(function(){if(h("#form_email_from_override").val()==""){h("#form-email-sender").prop("readonly",false)}else{h("#form-email-sender").prop("readonly","readonly")}});h("#notification-email").toggle(h("#form-notification-setting").prop("checked"));h("#form-notification-setting").change(function(){var n=h(this).is(":checked");if(n){h("#notification-email").show();h("#form-notification-email-name, #form-notification-email-from, #form-notification-email, #form-notification-subject, #form-notification-message, #form-notification-entry").prop("disabled",false)}else{h("#notification-email").hide();h("#form-notification-email-name, #form-notification-email-from, #form-notification-email, #form-notification-subject, #form-notification-message, #form-notification-entry").prop("disabled","disabled")}});h("#vfb-export-select-all").click(function(n){n.preventDefault();h('#vfb-export-entries-fields input[type="checkbox"]').prop("checked",true)});h("#vfb-export-unselect-all").click(function(n){n.preventDefault();h('#vfb-export-entries-fields input[type="checkbox"]').prop("checked",false)});h("#vfb-export-entries-forms").change(function(){var o=h(this).val(),n=k(o);h("#vfb-export-entries-fields").html("Loading...");h.get(ajaxurl,{action:"visual_form_builder_export_load_options",id:o,count:n,page:pagenow}).done(function(p){h("#vfb-export-entries-fields").html(p)}).fail(function(p){h("#vfb-export-entries-fields").html("Error loading entry fields.")})});h("#vfb-export-entries-rows").change(function(){var o=h("#vfb-export-entries-forms").val();var n=h(this).val();h("#vfb-export-entries-fields").html("Loading...");h.get(ajaxurl,{action:"visual_form_builder_export_load_options",id:o,offset:n,page:pagenow}).done(function(p){h("#vfb-export-entries-fields").html(p)}).fail(function(p){h("#vfb-export-entries-fields").html("Error loading entry fields.")})});function k(o){var n="";h.ajax(ajaxurl,{async:false,data:{action:"visual_form_builder_export_entries_count",id:o,page:pagenow}}).done(function(p){if(p>1000){h("#vfb-export-entries-rows").empty();var r=Math.ceil(parseInt(p)/1000);for(var q=1;q<=r;q++){h("#vfb-export-entries-rows").append(h("<option></option>").attr("value",q).text(q))}h("#vfb-export-entries-pages").show()}else{h("#vfb-export-entries-pages").hide()}n=p}).fail(function(p){});return n}});
 
{languages → lang}/visual-form-builder-bg_BG.mo RENAMED
File without changes
{languages → lang}/visual-form-builder-bg_BG.po RENAMED
File without changes
{languages → lang}/visual-form-builder-es_ES.mo RENAMED
File without changes
{languages → lang}/visual-form-builder-es_ES.po RENAMED
File without changes
{languages → lang}/visual-form-builder-fr_FR.mo RENAMED
File without changes
{languages → lang}/visual-form-builder-fr_FR.po RENAMED
File without changes
{languages → lang}/visual-form-builder-hu_HU.mo RENAMED
File without changes
{languages → lang}/visual-form-builder-hu_HU.po RENAMED
File without changes
{languages → lang}/visual-form-builder-nl_NL.mo RENAMED
File without changes
{languages → lang}/visual-form-builder-nl_NL.po RENAMED
File without changes
{languages → lang}/visual-form-builder-pt_PT.mo RENAMED
File without changes
{languages → lang}/visual-form-builder-pt_PT.po RENAMED
File without changes
{languages → lang}/visual-form-builder.pot RENAMED
File without changes
public/assets/css/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
{css → public/assets/css}/smoothness/images/animated-overlay.gif RENAMED
File without changes
public/assets/css/smoothness/images/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
{css → public/assets/css}/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-bg_flat_75_ffffff_40x100.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-bg_glass_65_ffffff_1x400.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-bg_glass_75_dadada_1x400.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-icons_222222_256x240.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-icons_2e83ff_256x240.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-icons_454545_256x240.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-icons_888888_256x240.png RENAMED
File without changes
{css → public/assets/css}/smoothness/images/ui-icons_cd0a0a_256x240.png RENAMED
File without changes
public/assets/css/smoothness/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
{css → public/assets/css}/smoothness/jquery-ui-1.10.3.css RENAMED
File without changes
{css → public/assets/css}/smoothness/jquery-ui-1.10.3.min.css RENAMED
File without changes
{css → public/assets/css}/visual-form-builder.css RENAMED
File without changes
{css → public/assets/css}/visual-form-builder.min.css RENAMED
File without changes
public/assets/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
{js → public/assets/js}/ckeditor/ckeditor.js RENAMED
File without changes
{js → public/assets/js}/ckeditor/config.js RENAMED
File without changes
{js → public/assets/js}/ckeditor/contents.css RENAMED
File without changes
public/assets/js/ckeditor/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
{js → public/assets/js}/ckeditor/lang/en.js RENAMED
File without changes
{js → public/assets/js}/ckeditor/plugins/dialog/dialogDefinition.js RENAMED
File without changes
{js → public/assets/js}/ckeditor/plugins/icons.png RENAMED
File without changes
{js → public/assets/js}/ckeditor/plugins/link/dialogs/anchor.js RENAMED
File without changes
{js → public/assets/js}/ckeditor/plugins/link/dialogs/link.js RENAMED
File without changes
{js → public/assets/js}/ckeditor/plugins/link/images/anchor.png RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/dialog.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/dialog_ie.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/dialog_ie7.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/dialog_ie8.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/dialog_iequirks.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/dialog_opera.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/editor.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/editor_gecko.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/editor_ie.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/editor_ie7.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/editor_ie8.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/editor_iequirks.css RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/icons.png RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/images/arrow.png RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/images/close.png RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/images/mini.png RENAMED
File without changes
{js → public/assets/js}/ckeditor/skins/moono/readme.md RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-cs_CS.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-de_DE.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-el_GR.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-en_AU.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-en_GB.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-en_US.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-es_ES.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-fr_FR.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-he_IL.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-hu_HU.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-id_ID.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-it_IT.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-ja_JP.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-ko_KR.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-nl_NL.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-pl_PL.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-pt_BR.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-pt_PT.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-ro_RO.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-ru_RU.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-sv_SE.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-tr_TR.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-zh_CN.js RENAMED
File without changes
{js → public/assets/js}/i18n/datepicker/datepicker-zh_TW.js RENAMED
File without changes
public/assets/js/i18n/datepicker/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
public/assets/js/i18n/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
public/assets/js/i18n/validate/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
{js → public/assets/js}/i18n/validate/messages-cs_CS.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-de_DE.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-el_GR.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-en_AU.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-en_GB.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-en_US.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-es_ES.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-fr_FR.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-he_IL.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-hu_HU.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-id_ID.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-it_IT.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-ja_JP.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-ko_KR.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-nl_NL.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-pl_PL.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-pt_BR.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-pt_PT.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-ro_RO.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-ru_RU.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-sv_SE.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-tr_TR.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-zh_CN.js RENAMED
File without changes
{js → public/assets/js}/i18n/validate/messages-zh_TW.js RENAMED
File without changes
public/assets/js/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
{js → public/assets/js}/jquery.metadata.js RENAMED
File without changes
public/assets/js/jquery.validate.min.js ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * jQuery Validation Plugin 1.9.0
3
+ *
4
+ * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
5
+ * http://docs.jquery.com/Plugins/Validation
6
+ *
7
+ * Copyright (c) 2006 - 2011 Jörn Zaefferer
8
+ *
9
+ * Dual licensed under the MIT and GPL licenses:
10
+ * http://www.opensource.org/licenses/mit-license.php
11
+ * http://www.gnu.org/licenses/gpl.html
12
+ */
13
+ (function(c){c.extend(c.fn,{validate:function(a){if(this.length){var b=c.data(this[0],"validator");if(b)return b;this.attr("novalidate","novalidate");b=new c.validator(a,this[0]);c.data(this[0],"validator",b);if(b.settings.onsubmit){a=this.find("input, button");a.filter(".cancel").click(function(){b.cancelSubmit=true});b.settings.submitHandler&&a.filter(":submit").click(function(){b.submitButton=this});this.submit(function(d){function e(){if(b.settings.submitHandler){if(b.submitButton)var f=c("<input type='hidden'/>").attr("name",
14
+ b.submitButton.name).val(b.submitButton.value).appendTo(b.currentForm);b.settings.submitHandler.call(b,b.currentForm);b.submitButton&&f.remove();return false}return true}b.settings.debug&&d.preventDefault();if(b.cancelSubmit){b.cancelSubmit=false;return e()}if(b.form()){if(b.pendingRequest){b.formSubmitted=true;return false}return e()}else{b.focusInvalid();return false}})}return b}else a&&a.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing")},valid:function(){if(c(this[0]).is("form"))return this.validate().form();
15
+ else{var a=true,b=c(this[0].form).validate();this.each(function(){a&=b.element(this)});return a}},removeAttrs:function(a){var b={},d=this;c.each(a.split(/\s/),function(e,f){b[f]=d.attr(f);d.removeAttr(f)});return b},rules:function(a,b){var d=this[0];if(a){var e=c.data(d.form,"validator").settings,f=e.rules,g=c.validator.staticRules(d);switch(a){case "add":c.extend(g,c.validator.normalizeRule(b));f[d.name]=g;if(b.messages)e.messages[d.name]=c.extend(e.messages[d.name],b.messages);break;case "remove":if(!b){delete f[d.name];
16
+ return g}var h={};c.each(b.split(/\s/),function(j,i){h[i]=g[i];delete g[i]});return h}}d=c.validator.normalizeRules(c.extend({},c.validator.metadataRules(d),c.validator.classRules(d),c.validator.attributeRules(d),c.validator.staticRules(d)),d);if(d.required){e=d.required;delete d.required;d=c.extend({required:e},d)}return d}});c.extend(c.expr[":"],{blank:function(a){return!c.trim(""+a.value)},filled:function(a){return!!c.trim(""+a.value)},unchecked:function(a){return!a.checked}});c.validator=function(a,
17
+ b){this.settings=c.extend(true,{},c.validator.defaults,a);this.currentForm=b;this.init()};c.validator.format=function(a,b){if(arguments.length==1)return function(){var d=c.makeArray(arguments);d.unshift(a);return c.validator.format.apply(this,d)};if(arguments.length>2&&b.constructor!=Array)b=c.makeArray(arguments).slice(1);if(b.constructor!=Array)b=[b];c.each(b,function(d,e){a=a.replace(RegExp("\\{"+d+"\\}","g"),e)});return a};c.extend(c.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",
18
+ validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:c([]),errorLabelContainer:c([]),onsubmit:true,ignore:":hidden",ignoreTitle:false,onfocusin:function(a){this.lastActive=a;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass);this.addWrapper(this.errorsFor(a)).hide()}},onfocusout:function(a){if(!this.checkable(a)&&(a.name in this.submitted||!this.optional(a)))this.element(a)},
19
+ onkeyup:function(a){if(a.name in this.submitted||a==this.lastElement)this.element(a)},onclick:function(a){if(a.name in this.submitted)this.element(a);else a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).addClass(b).removeClass(d):c(a).addClass(b).removeClass(d)},unhighlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).removeClass(b).addClass(d):c(a).removeClass(b).addClass(d)}},setDefaults:function(a){c.extend(c.validator.defaults,
20
+ a)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:c.validator.format("Please enter no more than {0} characters."),
21
+ minlength:c.validator.format("Please enter at least {0} characters."),rangelength:c.validator.format("Please enter a value between {0} and {1} characters long."),range:c.validator.format("Please enter a value between {0} and {1}."),max:c.validator.format("Please enter a value less than or equal to {0}."),min:c.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){function a(e){var f=c.data(this[0].form,"validator"),g="on"+e.type.replace(/^validate/,
22
+ "");f.settings[g]&&f.settings[g].call(f,this[0],e)}this.labelContainer=c(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||c(this.currentForm);this.containers=c(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var b=this.groups={};c.each(this.settings.groups,function(e,f){c.each(f.split(/\s/),function(g,h){b[h]=e})});var d=
23
+ this.settings.rules;c.each(d,function(e,f){d[e]=c.validator.normalizeRule(f)});c(this.currentForm).validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",a).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",
24
+ a);this.settings.invalidHandler&&c(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){this.checkForm();c.extend(this.submitted,this.errorMap);this.invalid=c.extend({},this.errorMap);this.valid()||c(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(a){this.lastElement=
25
+ a=this.validationTargetFor(this.clean(a));this.prepareElement(a);this.currentElements=c(a);var b=this.check(a);if(b)delete this.invalid[a.name];else this.invalid[a.name]=true;if(!this.numberOfInvalids())this.toHide=this.toHide.add(this.containers);this.showErrors();return b},showErrors:function(a){if(a){c.extend(this.errorMap,a);this.errorList=[];for(var b in a)this.errorList.push({message:a[b],element:this.findByName(b)[0]});this.successList=c.grep(this.successList,function(d){return!(d.name in a)})}this.settings.showErrors?
26
+ this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){c.fn.resetForm&&c(this.currentForm).resetForm();this.submitted={};this.lastElement=null;this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b=0,d;for(d in a)b++;return b},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return this.size()==
27
+ 0},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{c(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(a){}},findLastActive:function(){var a=this.lastActive;return a&&c.grep(this.errorList,function(b){return b.element.name==a.name}).length==1&&a},elements:function(){var a=this,b={};return c(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&
28
+ a.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in b||!a.objectLength(c(this).rules()))return false;return b[this.name]=true})},clean:function(a){return c(a)[0]},errors:function(){return c(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext)},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=c([]);this.toHide=c([]);this.currentElements=c([])},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers)},
29
+ prepareElement:function(a){this.reset();this.toHide=this.errorsFor(a)},check:function(a){a=this.validationTargetFor(this.clean(a));var b=c(a).rules(),d=false,e;for(e in b){var f={method:e,parameters:b[e]};try{var g=c.validator.methods[e].call(this,a.value.replace(/\r/g,""),a,f.parameters);if(g=="dependency-mismatch")d=true;else{d=false;if(g=="pending"){this.toHide=this.toHide.not(this.errorsFor(a));return}if(!g){this.formatAndAdd(a,f);return false}}}catch(h){this.settings.debug&&window.console&&console.log("exception occured when checking element "+
30
+ a.id+", check the '"+f.method+"' method",h);throw h;}}if(!d){this.objectLength(b)&&this.successList.push(a);return true}},customMetaMessage:function(a,b){if(c.metadata){var d=this.settings.meta?c(a).metadata()[this.settings.meta]:c(a).metadata();return d&&d.messages&&d.messages[b]}},customMessage:function(a,b){var d=this.settings.messages[a];return d&&(d.constructor==String?d:d[b])},findDefined:function(){for(var a=0;a<arguments.length;a++)if(arguments[a]!==undefined)return arguments[a]},defaultMessage:function(a,
31
+ b){return this.findDefined(this.customMessage(a.name,b),this.customMetaMessage(a,b),!this.settings.ignoreTitle&&a.title||undefined,c.validator.messages[b],"<strong>Warning: No message defined for "+a.name+"</strong>")},formatAndAdd:function(a,b){var d=this.defaultMessage(a,b.method),e=/\$?\{(\d+)\}/g;if(typeof d=="function")d=d.call(this,b.parameters,a);else if(e.test(d))d=jQuery.format(d.replace(e,"{$1}"),b.parameters);this.errorList.push({message:d,element:a});this.errorMap[a.name]=d;this.submitted[a.name]=
32
+ d},addWrapper:function(a){if(this.settings.wrapper)a=a.add(a.parent(this.settings.wrapper));return a},defaultShowErrors:function(){for(var a=0;this.errorList[a];a++){var b=this.errorList[a];this.settings.highlight&&this.settings.highlight.call(this,b.element,this.settings.errorClass,this.settings.validClass);this.showLabel(b.element,b.message)}if(this.errorList.length)this.toShow=this.toShow.add(this.containers);if(this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);
33
+ if(this.settings.unhighlight){a=0;for(b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass)}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return c(this.errorList).map(function(){return this.element})},showLabel:function(a,b){var d=this.errorsFor(a);if(d.length){d.removeClass(this.settings.validClass).addClass(this.settings.errorClass);
34
+ d.attr("generated")&&d.html(b)}else{d=c("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(a),generated:true}).addClass(this.settings.errorClass).html(b||"");if(this.settings.wrapper)d=d.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();this.labelContainer.append(d).length||(this.settings.errorPlacement?this.settings.errorPlacement(d,c(a)):d.insertAfter(a))}if(!b&&this.settings.success){d.text("");typeof this.settings.success=="string"?d.addClass(this.settings.success):this.settings.success(d)}this.toShow=
35
+ this.toShow.add(d)},errorsFor:function(a){var b=this.idOrName(a);return this.errors().filter(function(){return c(this).attr("for")==b})},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(a){if(this.checkable(a))a=this.findByName(a.name).not(this.settings.ignore)[0];return a},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(a){var b=this.currentForm;return c(document.getElementsByName(a)).map(function(d,
36
+ e){return e.form==b&&e.name==a&&e||null})},getLength:function(a,b){switch(b.nodeName.toLowerCase()){case "select":return c("option:selected",b).length;case "input":if(this.checkable(b))return this.findByName(b.name).filter(":checked").length}return a.length},depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):true},dependTypes:{"boolean":function(a){return a},string:function(a,b){return!!c(a,b.form).length},"function":function(a,b){return a(b)}},optional:function(a){return!c.validator.methods.required.call(this,
37
+ c.trim(a.value),a)&&"dependency-mismatch"},startRequest:function(a){if(!this.pending[a.name]){this.pendingRequest++;this.pending[a.name]=true}},stopRequest:function(a,b){this.pendingRequest--;if(this.pendingRequest<0)this.pendingRequest=0;delete this.pending[a.name];if(b&&this.pendingRequest==0&&this.formSubmitted&&this.form()){c(this.currentForm).submit();this.formSubmitted=false}else if(!b&&this.pendingRequest==0&&this.formSubmitted){c(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=
38
+ false}},previousValue:function(a){return c.data(a,"previousValue")||c.data(a,"previousValue",{old:null,valid:true,message:this.defaultMessage(a,"remote")})}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(a,b){a.constructor==String?this.classRuleSettings[a]=b:c.extend(this.classRuleSettings,
39
+ a)},classRules:function(a){var b={};(a=c(a).attr("class"))&&c.each(a.split(" "),function(){this in c.validator.classRuleSettings&&c.extend(b,c.validator.classRuleSettings[this])});return b},attributeRules:function(a){var b={};a=c(a);for(var d in c.validator.methods){var e;if(e=d==="required"&&typeof c.fn.prop==="function"?a.prop(d):a.attr(d))b[d]=e;else if(a[0].getAttribute("type")===d)b[d]=true}b.maxlength&&/-1|2147483647|524288/.test(b.maxlength)&&delete b.maxlength;return b},metadataRules:function(a){if(!c.metadata)return{};
40
+ var b=c.data(a.form,"validator").settings.meta;return b?c(a).metadata()[b]:c(a).metadata()},staticRules:function(a){var b={},d=c.data(a.form,"validator");if(d.settings.rules)b=c.validator.normalizeRule(d.settings.rules[a.name])||{};return b},normalizeRules:function(a,b){c.each(a,function(d,e){if(e===false)delete a[d];else if(e.param||e.depends){var f=true;switch(typeof e.depends){case "string":f=!!c(e.depends,b.form).length;break;case "function":f=e.depends.call(b,b)}if(f)a[d]=e.param!==undefined?
41
+ e.param:true;else delete a[d]}});c.each(a,function(d,e){a[d]=c.isFunction(e)?e(b):e});c.each(["minlength","maxlength","min","max"],function(){if(a[this])a[this]=Number(a[this])});c.each(["rangelength","range"],function(){if(a[this])a[this]=[Number(a[this][0]),Number(a[this][1])]});if(c.validator.autoCreateRanges){if(a.min&&a.max){a.range=[a.min,a.max];delete a.min;delete a.max}if(a.minlength&&a.maxlength){a.rangelength=[a.minlength,a.maxlength];delete a.minlength;delete a.maxlength}}a.messages&&delete a.messages;
42
+ return a},normalizeRule:function(a){if(typeof a=="string"){var b={};c.each(a.split(/\s/),function(){b[this]=true});a=b}return a},addMethod:function(a,b,d){c.validator.methods[a]=b;c.validator.messages[a]=d!=undefined?d:c.validator.messages[a];b.length<3&&c.validator.addClassRules(a,c.validator.normalizeRule(a))},methods:{required:function(a,b,d){if(!this.depend(d,b))return"dependency-mismatch";switch(b.nodeName.toLowerCase()){case "select":return(a=c(b).val())&&a.length>0;case "input":if(this.checkable(b))return this.getLength(a,
43
+ b)>0;default:return c.trim(a).length>0}},remote:function(a,b,d){if(this.optional(b))return"dependency-mismatch";var e=this.previousValue(b);this.settings.messages[b.name]||(this.settings.messages[b.name]={});e.originalMessage=this.settings.messages[b.name].remote;this.settings.messages[b.name].remote=e.message;d=typeof d=="string"&&{url:d}||d;if(this.pending[b.name])return"pending";if(e.old===a)return e.valid;e.old=a;var f=this;this.startRequest(b);var g={};g[b.name]=a;c.ajax(c.extend(true,{url:d,
44
+ mode:"abort",port:"validate"+b.name,dataType:"json",data:g,success:function(h){f.settings.messages[b.name].remote=e.originalMessage;var j=h===true;if(j){var i=f.formSubmitted;f.prepareElement(b);f.formSubmitted=i;f.successList.push(b);f.showErrors()}else{i={};h=h||f.defaultMessage(b,"remote");i[b.name]=e.message=c.isFunction(h)?h(a):h;f.showErrors(i)}e.valid=j;f.stopRequest(b,j)}},d));return"pending"},minlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)>=d},maxlength:function(a,
45
+ b,d){return this.optional(b)||this.getLength(c.trim(a),b)<=d},rangelength:function(a,b,d){a=this.getLength(c.trim(a),b);return this.optional(b)||a>=d[0]&&a<=d[1]},min:function(a,b,d){return this.optional(b)||a>=d},max:function(a,b,d){return this.optional(b)||a<=d},range:function(a,b,d){return this.optional(b)||a>=d[0]&&a<=d[1]},email:function(a,b){return this.optional(b)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(a)},
46
+ url:function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},
47
+ date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a))},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(a)},number:function(a,b){return this.optional(b)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9 -]+/.test(a))return false;var d=0,e=0,f=false;a=a.replace(/\D/g,"");for(var g=a.length-1;g>=
48
+ 0;g--){e=a.charAt(g);e=parseInt(e,10);if(f)if((e*=2)>9)e-=9;d+=e;f=!f}return d%10==0},accept:function(a,b,d){d=typeof d=="string"?d.replace(/,/g,"|"):"png|jpe?g|gif";return this.optional(b)||a.match(RegExp(".("+d+")$","i"))},equalTo:function(a,b,d){d=c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){c(b).valid()});return a==d.val()}}});c.format=c.validator.format})(jQuery);
49
+ (function(c){var a={};if(c.ajaxPrefilter)c.ajaxPrefilter(function(d,e,f){e=d.port;if(d.mode=="abort"){a[e]&&a[e].abort();a[e]=f}});else{var b=c.ajax;c.ajax=function(d){var e=("port"in d?d:c.ajaxSettings).port;if(("mode"in d?d:c.ajaxSettings).mode=="abort"){a[e]&&a[e].abort();return a[e]=b.apply(this,arguments)}return b.apply(this,arguments)}}})(jQuery);
50
+ (function(c){!jQuery.event.special.focusin&&!jQuery.event.special.focusout&&document.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.handle.call(this,e)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)},handler:function(e){arguments[0]=c.event.fix(e);arguments[0].type=b;return c.event.handle.apply(this,arguments)}}});c.extend(c.fn,{validateDelegate:function(a,
51
+ b,d){return this.bind(b,function(e){var f=c(e.target);if(f.is(a))return d.apply(f,arguments)})}})})(jQuery);
public/assets/js/vfb-validation.js ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ // !Validate each form on the page
3
+ $( '.visual-form-builder' ).each( function() {
4
+ $( this ).validate({
5
+ rules: {
6
+ "vfb-secret":{
7
+ required: true,
8
+ digits: true,
9
+ maxlength:2
10
+ }
11
+ },
12
+ errorClass : 'vfb-error',
13
+ errorPlacement: function(error, element) {
14
+ if ( element.is( ':radio' ) || element.is( ':checkbox' ) )
15
+ error.appendTo( element.parent().parent() );
16
+ else if ( element.is( ':password' ) )
17
+ error.hide();
18
+ else
19
+ error.insertAfter( element );
20
+ }
21
+ });
22
+ });
23
+
24
+ // Force bullets to hide, but only if list-style-type isn't set
25
+ $( '.visual-form-builder li:not(.vfb-item-instructions li, .vfb-span li)' ).filter( function(){
26
+ return $( this ).css( 'list-style-type' ) !== 'none';
27
+ }).css( 'list-style', 'none' );
28
+
29
+ // !Display jQuery UI date picker
30
+ $( '.vfb-date-picker' ).each( function(){
31
+ var vfb_dateFormat = $( this ).attr( 'data-dp-dateFormat' ) ? $( this ).attr( 'data-dp-dateFormat' ) : 'mm/dd/yy';
32
+
33
+ $( this ).datepicker({
34
+ dateFormat: vfb_dateFormat
35
+ });
36
+ });
37
+
38
+ // !Custom validation method to check multiple emails
39
+ $.validator.addMethod( 'phone', function( value, element ) {
40
+ // Strip out all spaces, periods, dashes, parentheses, and plus signs
41
+ value = value.replace(/[\+\s\(\)\.\-\ ]/g, '');
42
+
43
+ return this.optional(element) || value.length > 9 &&
44
+ value.match( /^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/ );
45
+
46
+ }, $.validator.messages.phone
47
+ );
48
+ });
public/assets/js/vfb-validation.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(a){a(".visual-form-builder").each(function(){a(this).validate({rules:{"vfb-secret":{required:true,digits:true,maxlength:2}},errorClass:"vfb-error",errorPlacement:function(b,c){if(c.is(":radio")||c.is(":checkbox")){b.appendTo(c.parent().parent())}else{if(c.is(":password")){b.hide()}else{b.insertAfter(c)}}}})});a(".visual-form-builder li:not(.vfb-item-instructions li, .vfb-span li)").filter(function(){return a(this).css("list-style-type")!=="none"}).css("list-style","none");a(".vfb-date-picker").each(function(){var b=a(this).attr("data-dp-dateFormat")?a(this).attr("data-dp-dateFormat"):"mm/dd/yy";a(this).datepicker({dateFormat:b})});a.validator.addMethod("phone",function(c,b){c=c.replace(/[\+\s\(\)\.\-\ ]/g,"");return this.optional(b)||c.length>9&&c.match(/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/)},a.validator.messages.phone)});
public/class-confirmation.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Handles form confirmation actions
4
+ *
5
+ */
6
+ class Visual_Form_Builder_Confirmation {
7
+
8
+ /**
9
+ * form
10
+ *
11
+ * @var mixed
12
+ * @access public
13
+ */
14
+ public $form_id;
15
+
16
+ /**
17
+ * __construct function.
18
+ *
19
+ * @access public
20
+ * @return void
21
+ */
22
+ public function __construct( $form_id ) {
23
+ $this->form_id = $form_id;
24
+ }
25
+
26
+ /**
27
+ * Text message confirmation
28
+ *
29
+ * @access public
30
+ * @param mixed $message
31
+ * @return void
32
+ */
33
+ public function text() {
34
+ $data = $this->get_settings();
35
+
36
+ $type = isset( $data['form_success_type'] ) ? $data['form_success_type'] : 'text';
37
+ $message = isset( $data['form_success_message'] ) ? stripslashes( html_entity_decode( wp_kses_stripslashes( $data['form_success_message'] ) ) ) : '';
38
+
39
+ if ( 'text' !== $type )
40
+ return;
41
+
42
+ return $message;
43
+ }
44
+
45
+ /**
46
+ * WordPress Page redirect
47
+ *
48
+ * @access public
49
+ * @param mixed $page
50
+ * @return void
51
+ */
52
+ public function wp_page() {
53
+ $data = $this->get_settings();
54
+
55
+ $type = isset( $data['form_success_type'] ) ? $data['form_success_type'] : 'text';
56
+ $page = isset( $data['form_success_message'] ) ? $data['form_success_message'] : '';
57
+
58
+ if ( 'page' !== $type )
59
+ return;
60
+
61
+ $permalink = get_permalink( $page );
62
+ wp_redirect( esc_url_raw( $permalink ) );
63
+
64
+ exit();
65
+ }
66
+
67
+ /**
68
+ * Custom URL redirect
69
+ *
70
+ * @access public
71
+ * @param mixed $url
72
+ * @return void
73
+ */
74
+ public function redirect() {
75
+ $data = $this->get_settings();
76
+
77
+ $type = isset( $data['form_success_type'] ) ? $data['form_success_type'] : 'text';
78
+ $redirect = isset( $data['form_success_message'] ) ? $data['form_success_message'] : '';
79
+
80
+ if ( 'redirect' !== $type )
81
+ return;
82
+
83
+ wp_redirect( esc_url_raw( $redirect ) );
84
+
85
+ exit();
86
+ }
87
+
88
+ /**
89
+ * Get confirmaton settings
90
+ *
91
+ * @access public
92
+ * @return void
93
+ */
94
+ public function get_settings() {
95
+ global $wpdb;
96
+
97
+ $form_id = $this->get_form_id();
98
+ if ( !$form_id )
99
+ return;
100
+
101
+ $order = sanitize_sql_orderby( 'form_id DESC' );
102
+ $form = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE form_id = %d ORDER BY $order", $form_id ), ARRAY_A );
103
+
104
+ if ( $form != null ) {
105
+ return $form;
106
+ }
107
+ else {
108
+ return false;
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Get just created Entry ID.
114
+ *
115
+ * @access public
116
+ * @return void
117
+ */
118
+ public function get_entry_id() {
119
+ $form_id = $this->get_form_id();
120
+ if ( !$form_id )
121
+ return;
122
+
123
+ $vfbdb = new VFB_Pro_Data();
124
+ $settings = $vfbdb->get_form_settings( $form_id );
125
+
126
+ if ( !isset( $settings['data']['last-entry'] ) )
127
+ return 0;
128
+
129
+ return $settings['data']['last-entry'];
130
+ }
131
+
132
+ /**
133
+ * Get form ID
134
+ *
135
+ * @access private
136
+ * @return void
137
+ */
138
+ public function get_form_id() {
139
+ if ( !isset( $this->form_id ) )
140
+ return false;
141
+
142
+ return (int) $this->form_id;
143
+ }
144
+
145
+ /**
146
+ * Basic check to exit if the form hasn't been submitted
147
+ *
148
+ * @access public
149
+ * @return void
150
+ */
151
+ public function submit_check() {
152
+ // If class form ID hasn't been set, exit
153
+ if ( !$this->get_form_id() )
154
+ return;
155
+
156
+ // If form ID hasn't been submitted by $_POST, exit
157
+ if ( !isset( $_POST['vfb-submit'] ) )
158
+ return;
159
+
160
+ // If class form ID doesn't match $_POST form ID, exit
161
+ if ( $this->get_form_id() !== absint( $_POST['form_id'] ) )
162
+ return;
163
+
164
+ return true;
165
+ }
166
+ }
public/class-email.php ADDED
@@ -0,0 +1,635 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Handles the main email
4
+ *
5
+ */
6
+ class Visual_Form_Builder_Email {
7
+ /**
8
+ * form_id
9
+ *
10
+ * @var mixed
11
+ * @access protected
12
+ */
13
+ protected $form_id;
14
+
15
+ /**
16
+ * __construct function.
17
+ *
18
+ * @access public
19
+ * @return void
20
+ */
21
+ public function __construct() {
22
+ }
23
+
24
+ /**
25
+ * email function.
26
+ *
27
+ * @access public
28
+ * @return void
29
+ */
30
+ public function email() {
31
+ $form_id = $this->get_form_id();
32
+ if ( !$form_id )
33
+ return;
34
+
35
+ // Save Form ID to pass to phpmailer()
36
+ $this->form_id = $form_id;
37
+
38
+ // Main Email
39
+ $this->notification( $form_id );
40
+
41
+ /**
42
+ * Action that fires after all emails have been processed
43
+ *
44
+ * Passes the Entry ID and Form ID
45
+ *
46
+ */
47
+ do_action( 'vfb_after_email', $form_id );
48
+ }
49
+
50
+ /**
51
+ * Send out main email
52
+ * @param [type] $form_id [description]
53
+ * @return [type] [description]
54
+ */
55
+ public function notification( $form_id ) {
56
+ global $wpdb;
57
+
58
+ // Query to get all forms
59
+ $order = sanitize_sql_orderby( 'form_id DESC' );
60
+ $form = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE form_id = %d ORDER BY $order", $form_id ) );
61
+
62
+ $form_settings = (object) array(
63
+ 'form_title' => stripslashes( html_entity_decode( $form->form_title, ENT_QUOTES, 'UTF-8' ) ),
64
+ 'form_subject' => stripslashes( html_entity_decode( $form->form_email_subject, ENT_QUOTES, 'UTF-8' ) ),
65
+ 'form_to' => ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) ),
66
+ 'form_from' => stripslashes( $form->form_email_from ),
67
+ 'form_from_name' => stripslashes( $form->form_email_from_name ),
68
+ 'form_notification_setting' => stripslashes( $form->form_notification_setting ),
69
+ 'form_notification_email_name' => stripslashes( $form->form_notification_email_name ),
70
+ 'form_notification_email_from' => stripslashes( $form->form_notification_email_from ),
71
+ 'form_notification_subject' => stripslashes( html_entity_decode( $form->form_notification_subject, ENT_QUOTES, 'UTF-8' ) ),
72
+ 'form_notification_message' => stripslashes( $form->form_notification_message ),
73
+ 'form_notification_entry' => stripslashes( $form->form_notification_entry )
74
+ );
75
+ // Allow the form settings to be filtered (ex: return $form_settings->'form_title' = 'Hello World';)
76
+ $form_settings = (object) apply_filters_ref_array( 'vfb_email_form_settings', array( $form_settings, $form_id ) );
77
+
78
+ // Get global settings
79
+ $vfb_settings = get_option( 'vfb-settings' );
80
+
81
+ // Settings - Max Upload Size
82
+ $settings_max_upload = isset( $vfb_settings['max-upload-size'] ) ? $vfb_settings['max-upload-size'] : 25;
83
+
84
+ // Settings - Spam word sensitivity
85
+ $settings_spam_points = isset( $vfb_settings['spam-points'] ) ? $vfb_settings['spam-points'] : 4;
86
+
87
+ // Sender name field ID
88
+ $sender = $form->form_email_from_name_override;
89
+
90
+ // Sender email field ID
91
+ $email = $form->form_email_from_override;
92
+
93
+ // Notifcation email field ID
94
+ $notify = $form->form_notification_email;
95
+
96
+ $reply_to_name = $form_settings->form_from_name;
97
+ $reply_to_email = $form_settings->form_from;
98
+
99
+ // Use field for sender name
100
+ if ( !empty( $sender ) && isset( $_POST[ 'vfb-' . $sender ] ) ) {
101
+ $form_settings->form_from_name = wp_kses_data( $_POST[ 'vfb-' . $sender ] );
102
+ $reply_to_name = $form_settings->form_from_name;
103
+ }
104
+
105
+ // Use field for sender email
106
+ if ( !empty( $email ) && isset( $_POST[ 'vfb-' . $email ] ) ) {
107
+ $form_settings->form_from = sanitize_email( $_POST[ 'vfb-' . $email ] );
108
+ $reply_to_email = $form_settings->form_from;
109
+ }
110
+
111
+ // Use field for copy email
112
+ $copy_email = ( !empty( $notify ) ) ? sanitize_email( $_POST[ 'vfb-' . $notify ] ) : '';
113
+
114
+ // Query to get all forms
115
+ $order = sanitize_sql_orderby( 'field_sequence ASC' );
116
+ $fields = $wpdb->get_results( $wpdb->prepare( "SELECT field_id, field_key, field_name, field_type, field_options, field_parent, field_required FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE form_id = %d ORDER BY $order", $form_id ) );
117
+
118
+ // Setup counter for alt rows
119
+ $i = $points = 0;
120
+
121
+ // Setup HTML email vars
122
+ $header = $body = $message = $footer = $html_email = $auto_response_email = $attachments = '';
123
+
124
+ // Prepare the beginning of the content
125
+ $header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
126
+ <html>
127
+ <head>
128
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
129
+ <title>HTML Email</title>
130
+ </head>
131
+ <body><table rules="all" style="border-color: #666;" cellpadding="10">' . "\n";
132
+
133
+ // Loop through each form field and build the body of the message
134
+ foreach ( $fields as $field ) {
135
+ // Handle attachments
136
+ if ( $field->field_type == 'file-upload' ) {
137
+ $value = ( isset( $_FILES[ 'vfb-' . $field->field_id ] ) ) ? $_FILES[ 'vfb-' . $field->field_id ] : '';
138
+
139
+ if ( is_array( $value) && $value['size'] > 0 ) {
140
+ // 25MB is the max size allowed
141
+ $size = apply_filters( 'vfb_max_file_size', $settings_max_upload );
142
+ $max_attach_size = $size * 1048576;
143
+
144
+ // Display error if file size has been exceeded
145
+ if ( $value['size'] > $max_attach_size ) {
146
+ wp_die( sprintf( __( "File size exceeds %dMB. Please decrease the file size and try again.", 'visual-form-builder' ), $size ), '', array( 'back_link' => true ) );
147
+ }
148
+
149
+ // Options array for the wp_handle_upload function. 'test_form' => false
150
+ $upload_overrides = array( 'test_form' => false );
151
+
152
+ // We need to include the file that runs the wp_handle_upload function
153
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
154
+
155
+ // Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array
156
+ $uploaded_file = wp_handle_upload( $value, $upload_overrides );
157
+
158
+ // If the wp_handle_upload call returned a local path for the image
159
+ if ( isset( $uploaded_file['file'] ) ) {
160
+ // Retrieve the file type from the file name. Returns an array with extension and mime type
161
+ $wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );
162
+
163
+ // Return the current upload directory location
164
+ $wp_upload_dir = wp_upload_dir();
165
+
166
+ $media_upload = array(
167
+ 'guid' => $wp_upload_dir['url'] . '/' . basename( $uploaded_file['file'] ),
168
+ 'post_mime_type' => $wp_filetype['type'],
169
+ 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $uploaded_file['file'] ) ),
170
+ 'post_content' => '',
171
+ 'post_status' => 'inherit'
172
+ );
173
+
174
+ // Insert attachment into Media Library and get attachment ID
175
+ $attach_id = wp_insert_attachment( $media_upload, $uploaded_file['file'] );
176
+
177
+ // Include the file that runs wp_generate_attachment_metadata()
178
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
179
+ require_once( ABSPATH . 'wp-admin/includes/media.php' );
180
+
181
+ // Setup attachment metadata
182
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_file['file'] );
183
+
184
+ // Update the attachment metadata
185
+ wp_update_attachment_metadata( $attach_id, $attach_data );
186
+
187
+ $attachments[ 'vfb-' . $field->field_id ] = $uploaded_file['file'];
188
+
189
+ $data[] = array(
190
+ 'id' => $field->field_id,
191
+ 'slug' => $field->field_key,
192
+ 'name' => $field->field_name,
193
+ 'type' => $field->field_type,
194
+ 'options' => $field->field_options,
195
+ 'parent_id' => $field->field_parent,
196
+ 'value' => $uploaded_file['url']
197
+ );
198
+
199
+ $body .= sprintf(
200
+ '<tr>
201
+ <td><strong>%1$s: </strong></td>
202
+ <td><a href="%2$s">%2$s</a></td>
203
+ </tr>' . "\n",
204
+ stripslashes( $field->field_name ),
205
+ $uploaded_file['url']
206
+ );
207
+ }
208
+ }
209
+ else {
210
+ $value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
211
+ $body .= sprintf(
212
+ '<tr>
213
+ <td><strong>%1$s: </strong></td>
214
+ <td>%2$s</td>
215
+ </tr>' . "\n",
216
+ stripslashes( $field->field_name ),
217
+ $value
218
+ );
219
+ }
220
+ }
221
+ // Everything else
222
+ else {
223
+ $value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
224
+
225
+ // If time field, build proper output
226
+ if ( is_array( $value ) && $field->field_type == 'time' )
227
+ $value = $this->format_field( $value, $field->field_type );
228
+ // If address field, build proper output
229
+ elseif ( is_array( $value ) && $field->field_type == 'address' )
230
+ $value = $this->format_field( $value, $field->field_type );
231
+ // If multiple values, build the list
232
+ elseif ( is_array( $value ) )
233
+ $value = $this->format_field( $value, $field->field_type );
234
+ elseif ( 'radio' == $field->field_type )
235
+ $value = wp_specialchars_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES );
236
+ // Lastly, handle single values
237
+ else
238
+ $value = html_entity_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES, 'UTF-8' );
239
+
240
+ // Spam Words - Exploits
241
+ $exploits = array( 'content-type', 'bcc:', 'cc:', 'document.cookie', 'onclick', 'onload', 'javascript', 'alert' );
242
+ $exploits = apply_filters( 'vfb_spam_words_exploits', $exploits, $form_id );
243
+
244
+ // Spam Words - Exploits
245
+ $profanity = array( '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' );
246
+ $profanity = apply_filters( 'vfb_spam_words_profanity', $profanity, $form_id );
247
+
248
+ // Spam Words - Misc
249
+ $spamwords = array( 'viagra', 'phentermine', 'tramadol', 'adipex', 'advai', 'alprazolam', 'ambien', 'ambian', 'amoxicillin', 'antivert', 'blackjack', 'backgammon', 'holdem', 'poker', 'carisoprodol', 'ciara', 'ciprofloxacin', 'debt', 'dating', 'porn' );
250
+ $spamwords = apply_filters( 'vfb_spam_words_misc', $spamwords, $form_id );
251
+
252
+ // Add up points for each spam hit
253
+ if ( preg_match( '/(' . implode( '|', $exploits ) . ')/i', $value ) ) {
254
+ $points += 2;
255
+ }
256
+ elseif ( preg_match( '/(' . implode( '|', $profanity ) . ')/i', $value ) ) {
257
+ $points += 1;
258
+ }
259
+ elseif ( preg_match( '/(' . implode( '|', $spamwords ) . ')/i', $value ) ) {
260
+ $points += 1;
261
+ }
262
+
263
+ //Sanitize input
264
+ $value = $this->sanitize_input( $value, $field->field_type );
265
+ // Validate input
266
+ $this->validate_input( $value, $field->field_name, $field->field_type, $field->field_required );
267
+
268
+ $removed_field_types = array( 'verification', 'secret', 'submit' );
269
+
270
+ // Don't add certain fields to the email
271
+ if ( ! in_array( $field->field_type, $removed_field_types ) ) {
272
+ if ( $field->field_type == 'fieldset' ) {
273
+ $body .= sprintf(
274
+ '<tr style="background-color:#393E40;color:white;font-size:14px;">
275
+ <td colspan="2">%1$s</td>
276
+ </tr>' . "\n",
277
+ stripslashes( $field->field_name )
278
+ );
279
+ }
280
+ elseif ( $field->field_type == 'section' ) {
281
+ $body .= sprintf(
282
+ '<tr style="background-color:#6E7273;color:white;font-size:14px;">
283
+ <td colspan="2">%1$s</td>
284
+ </tr>' . "\n",
285
+ stripslashes( $field->field_name )
286
+ );
287
+ }
288
+ else {
289
+ // Convert new lines to break tags for textarea in html
290
+ $display_value = ( 'textarea' == $field->field_type ) ? nl2br( $value ) : $value;
291
+
292
+ $body .= sprintf(
293
+ '<tr>
294
+ <td><strong>%1$s: </strong></td>
295
+ <td>%2$s</td>
296
+ </tr>' . "\n",
297
+ stripslashes( $field->field_name ),
298
+ $display_value
299
+ );
300
+ }
301
+ }
302
+
303
+ $data[] = array(
304
+ 'id' => $field->field_id,
305
+ 'slug' => $field->field_key,
306
+ 'name' => $field->field_name,
307
+ 'type' => $field->field_type,
308
+ 'options' => $field->field_options,
309
+ 'parent_id' => $field->field_parent,
310
+ 'value' => esc_html( $value )
311
+ );
312
+ }
313
+
314
+ // If the user accumulates more than 4 points, it might be spam
315
+ if ( $points > $settings_spam_points ) {
316
+ wp_die( __( 'Your responses look too much like spam and could not be sent at this time.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
317
+ }
318
+ }
319
+
320
+ // Setup our entries data
321
+ $entry = array(
322
+ 'form_id' => $form_id,
323
+ 'data' => serialize( $data ),
324
+ 'subject' => $form_settings->form_subject,
325
+ 'sender_name' => $form_settings->form_from_name,
326
+ 'sender_email' => $form_settings->form_from,
327
+ 'emails_to' => serialize( $form_settings->form_to ),
328
+ 'date_submitted' => date_i18n( 'Y-m-d H:i:s' ),
329
+ 'ip_address' => esc_html( $_SERVER['REMOTE_ADDR'] )
330
+ );
331
+
332
+ // Insert this data into the entries table
333
+ $wpdb->insert( VFB_WP_ENTRIES_TABLE_NAME, $entry );
334
+
335
+ // Close out the content
336
+ $footer .= '<tr>
337
+ <td class="footer" height="61" align="left" valign="middle" colspan="2">
338
+ <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>
339
+ </td>
340
+ </tr>
341
+ </table>
342
+ </body>
343
+ </html>' . "\n";
344
+
345
+ // Build complete HTML email
346
+ $message = $header . $body . $footer;
347
+
348
+ // Wrap lines longer than 70 words to meet email standards
349
+ $message = wordwrap( $message, 70 );
350
+
351
+ // Decode HTML for message so it outputs properly
352
+ $notify_message = ( $form_settings->form_notification_message !== '' ) ? html_entity_decode( $form_settings->form_notification_message ) : '';
353
+
354
+ // Initialize header filter vars
355
+ $header_from_name = function_exists( 'mb_encode_mimeheader' ) ? mb_encode_mimeheader( stripslashes( $reply_to_name ) ) : stripslashes( $reply_to_name );
356
+ $header_from = $reply_to_email;
357
+ $header_content_type = 'text/html';
358
+
359
+ // Either prepend the notification message to the submitted entry, or send by itself
360
+ if ( $form_settings->form_notification_entry !== '' ) {
361
+ $auto_response_email = $header . $notify_message . $body . $footer;
362
+ }
363
+ else {
364
+ $auto_response_email = sprintf(
365
+ '%1$s<table cellspacing="0" border="0" cellpadding="0" width="100%%"><tr><td colspan="2" class="mainbar" align="left" valign="top" width="600">%2$s</td></tr>%3$s',
366
+ $header,
367
+ $notify_message,
368
+ $footer
369
+ );
370
+ }
371
+
372
+
373
+ // Build email headers
374
+ $from_name = ( $header_from_name == '' ) ? 'WordPress' : $header_from_name;
375
+
376
+ // Use the admin_email as the From email
377
+ $from_email = get_site_option( 'admin_email' );
378
+
379
+ // Get the site domain and get rid of www.
380
+ $sitename = strtolower( $_SERVER['SERVER_NAME'] );
381
+ if ( substr( $sitename, 0, 4 ) == 'www.' )
382
+ $sitename = substr( $sitename, 4 );
383
+
384
+ // Get the domain from the admin_email
385
+ list( $user, $domain ) = explode( '@', $from_email );
386
+
387
+ // If site domain and admin_email domain match, use admin_email, otherwise a same domain email must be created
388
+ $from_email = ( $sitename == $domain ) ? $from_email : "wordpress@$sitename";
389
+
390
+ // Settings - Sender Mail Header
391
+ $settings_sender_header = isset( $vfb_settings['sender-mail-header'] ) ? $vfb_settings['sender-mail-header'] : $from_email;
392
+
393
+ // Allow Sender email to be filtered
394
+ $from_email = apply_filters( 'vfb_sender_mail_header', $settings_sender_header, $form_id );
395
+
396
+ $reply_to = "\"$from_name\" <$header_from>";
397
+ $headers[] = "Sender: $from_email";
398
+ $headers[] = "From: $reply_to";
399
+ $headers[] = "Reply-To: $reply_to";
400
+ $headers[] = "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"";
401
+
402
+ $form_subject = wp_specialchars_decode( $form_settings->form_subject, ENT_QUOTES );
403
+ $notify_subject = wp_specialchars_decode( $form_settings->form_notification_subject, ENT_QUOTES );
404
+
405
+ // Sanitize main emails_to
406
+ $emails_to = array_map( 'sanitize_email', $form_settings->form_to );
407
+
408
+ // Send the mail
409
+ foreach ( $emails_to as $email ) {
410
+ wp_mail( $email, $form_subject, $message, $headers, $attachments );
411
+ }
412
+
413
+ // Send auto-responder email
414
+ if ( $form_settings->form_notification_setting !== '' ) {
415
+ $attachments = ( $form_settings->form_notification_entry !== '' ) ? $attachments : '';
416
+
417
+ // Reset headers for notification email
418
+ $reply_name = function_exists( 'mb_encode_mimeheader' ) ? mb_encode_mimeheader( stripslashes( $form_settings->form_notification_email_name ) ) : stripslashes( $form_settings->form_notification_email_name );
419
+ $reply_email = $form_settings->form_notification_email_from;
420
+ $reply_to = "\"$reply_name\" <$reply_email>";
421
+ $headers[] = "Sender: $from_email";
422
+ $headers[] = "From: $reply_to";
423
+ $headers[] = "Reply-To: $reply_to";
424
+ $headers[] = "Content-Type: $header_content_type; charset=\"" . get_option('blog_charset') . "\"";
425
+
426
+ // Send the mail
427
+ wp_mail( $copy_email, $notify_subject, $auto_response_email, $headers, $attachments );
428
+ }
429
+ }
430
+
431
+ /**
432
+ * [format_field description]
433
+ * @param [type] $value [description]
434
+ * @param string $type [description]
435
+ * @return [type] [description]
436
+ */
437
+ public function format_field( $value, $type = '' ) {
438
+
439
+ $output = '';
440
+
441
+ // Basic check for type when not set
442
+ if ( empty( $type ) ) {
443
+ if ( is_array( $value ) && array_key_exists( 'address', $value ) )
444
+ $type = 'address';
445
+ elseif ( is_array( $value ) && array_key_exists( 'hour', $value ) && array_key_exists( 'min', $value ) )
446
+ $type = 'time';
447
+ elseif ( is_array( $value ) )
448
+ $type = 'checkbox';
449
+ else
450
+ $type = 'default';
451
+ }
452
+
453
+ // Build array'd form item output
454
+ switch( $type ) {
455
+
456
+ case 'time' :
457
+ $output = ( array_key_exists( 'ampm', $value ) ) ? substr_replace( implode( ':', $value ), ' ', 5, 1 ) : implode( ':', $value );
458
+ break;
459
+
460
+ case 'address' :
461
+ if ( !empty( $value['address'] ) )
462
+ $output .= $value['address'];
463
+
464
+ if ( !empty( $value['address-2'] ) ) {
465
+ if ( !empty( $output ) )
466
+ $output .= '<br>';
467
+ $output .= $value['address-2'];
468
+ }
469
+
470
+ if ( !empty( $value['city'] ) ) {
471
+ if ( !empty( $output ) )
472
+ $output .= '<br>';
473
+ $output .= $value['city'];
474
+ }
475
+ if ( !empty( $value['state'] ) ) {
476
+ if ( !empty( $output ) && empty( $value['city'] ) )
477
+ $output .= '<br>';
478
+ elseif ( !empty( $output ) && !empty( $value['city'] ) )
479
+ $output .= ', ';
480
+ $output .= $value['state'];
481
+ }
482
+ if ( !empty( $value['zip'] ) ) {
483
+ if ( !empty( $output ) && ( empty( $value['city'] ) && empty( $value['state'] ) ) )
484
+ $output .= '<br>';
485
+ elseif ( !empty( $output ) && ( !empty( $value['city'] ) || !empty( $value['state'] ) ) )
486
+ $output .= ' ';
487
+ $output .= $value['zip'];
488
+ }
489
+ if ( !empty( $value['country'] ) ) {
490
+ if ( !empty( $output ) )
491
+ $output .= '<br>';
492
+ $output .= $value['country'];
493
+ }
494
+
495
+ break;
496
+
497
+ case 'checkbox' :
498
+ $output = esc_html( implode( ', ', $value ) );
499
+ break;
500
+
501
+ default :
502
+ $output = wp_specialchars_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES );
503
+ break;
504
+ }
505
+
506
+ return $output;
507
+ }
508
+
509
+ /**
510
+ * Validate the input
511
+ *
512
+ * @since 2.2
513
+ */
514
+ public function validate_input( $data, $name, $type, $required ) {
515
+
516
+ if ( 'yes' == $required && strlen( $data ) == 0 ) {
517
+ wp_die( "<h1>$name</h1><br>" . __( 'This field is required and cannot be empty.', 'visual-form-builder' ), $name, array( 'back_link' => true ) );
518
+ }
519
+
520
+ if ( strlen( $data ) > 0 ) {
521
+ switch( $type ) {
522
+
523
+ case 'email' :
524
+ if ( !is_email( $data ) ) {
525
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid email address', 'visual-form-builder' ), '', array( 'back_link' => true ) );
526
+ }
527
+
528
+ break;
529
+
530
+ case 'number' :
531
+ case 'currency' :
532
+ if ( !is_numeric( $data ) ) {
533
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid number', 'visual-form-builder' ), '', array( 'back_link' => true ) );
534
+ }
535
+
536
+ break;
537
+
538
+ case 'phone' :
539
+ 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 ) ) {
540
+ return true;
541
+ }
542
+ else {
543
+ 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 ) );
544
+ }
545
+
546
+ break;
547
+
548
+ case 'url' :
549
+ if ( !preg_match( '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $data ) ) {
550
+ wp_die( "<h1>$name</h1><br>" . __( 'Not a valid URL.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
551
+ }
552
+
553
+ break;
554
+
555
+ default :
556
+ return true;
557
+ break;
558
+
559
+ }
560
+ }
561
+ }
562
+
563
+ /**
564
+ * Sanitize the input
565
+ *
566
+ * @since 2.5
567
+ */
568
+ public function sanitize_input( $data, $type ) {
569
+ if ( strlen( $data ) > 0 ) {
570
+ switch( $type ) {
571
+ case 'text' :
572
+ return sanitize_text_field( $data );
573
+ break;
574
+
575
+ case 'textarea' :
576
+ return wp_strip_all_tags( $data );
577
+ break;
578
+
579
+ case 'email' :
580
+ return sanitize_email( $data );
581
+ break;
582
+
583
+ case 'html' :
584
+ return wp_kses_data( force_balance_tags( $data ) );
585
+ break;
586
+
587
+ case 'min' :
588
+ case 'max' :
589
+ case 'digits' :
590
+ return preg_replace( '/\D/i', '', $data );
591
+ break;
592
+
593
+ case 'address' :
594
+ $allowed_html = array( 'br' => array() );
595
+ return wp_kses( $data, $allowed_html );
596
+ break;
597
+
598
+ default :
599
+ return wp_kses_data( $data );
600
+ break;
601
+ }
602
+ }
603
+ }
604
+
605
+ /**
606
+ * Get form ID
607
+ *
608
+ * @access private
609
+ * @return void
610
+ */
611
+ private function get_form_id() {
612
+ if ( !isset( $_POST['form_id'] ) )
613
+ return false;
614
+
615
+ return (int) $_POST['form_id'];
616
+ }
617
+
618
+ /**
619
+ * Basic check to exit if the form hasn't been submitted
620
+ *
621
+ * @access public
622
+ * @return void
623
+ */
624
+ public function submit_check() {
625
+ // If form ID hasn't been submitted by $_POST, exit
626
+ if ( !$this->get_form_id() )
627
+ return;
628
+
629
+ // If form ID hasn't been submitted by $_POST, exit
630
+ if ( !isset( $_POST['vfb-submit'] ) )
631
+ return;
632
+
633
+ return true;
634
+ }
635
+ }
public/class-form-display.php ADDED
@@ -0,0 +1,846 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Outputs public VFB form
4
+ *
5
+ */
6
+ class Visual_Form_Builder_Form_Display {
7
+ /**
8
+ * The main instanace
9
+ *
10
+ * @var mixed
11
+ * @access private
12
+ * @static
13
+ */
14
+ private static $instance = null;
15
+
16
+ /**
17
+ * Protected constructor to prevent creating a new instance
18
+ * via the 'new' operator from outside of this class.
19
+ *
20
+ * @return void
21
+ */
22
+ protected function __construct() {
23
+ }
24
+
25
+ /**
26
+ * Private clone method to prevent cloning of the instance.
27
+ *
28
+ * @return void
29
+ */
30
+ private function __clone() {
31
+ }
32
+
33
+ /**
34
+ * Private unserialize method to prevent unserializing of the instance.
35
+ *
36
+ * @return void
37
+ */
38
+ private function __wakeup() {
39
+ }
40
+
41
+ /**
42
+ * Create a single instance
43
+ *
44
+ * Insures that only one instance of this class is running.
45
+ * Otherwise known as the Singleton class pattern
46
+ *
47
+ * @access public
48
+ * @static
49
+ */
50
+ public static function instance() {
51
+ if ( null === self::$instance ) {
52
+ self::$instance = new Visual_Form_Builder_Form_Display;
53
+
54
+ add_shortcode( 'vfb', array( self::$instance, 'display' ) );
55
+ add_action( 'wp_enqueue_scripts', array( self::$instance, 'css' ) );
56
+ add_action( 'wp_enqueue_scripts', array( self::$instance, 'js' ) );
57
+ add_action( 'init', array( self::$instance, 'process_email' ) );
58
+ add_action( 'vfb_after_email', array( self::$instance, 'process_redirect' ) );
59
+ add_action( 'vfb_after_email', array( self::$instance, 'process_confirmation' ) );
60
+ }
61
+
62
+ return self::$instance;
63
+ }
64
+
65
+ /**
66
+ * Load public CSS files
67
+ *
68
+ * @access public
69
+ * @return void
70
+ */
71
+ public function css() {
72
+ $scripts = new Visual_Form_Builder_Scripts_Loader();
73
+ $scripts->add_css();
74
+ }
75
+
76
+ /**
77
+ * Load public JS files
78
+ *
79
+ * @access public
80
+ * @return void
81
+ */
82
+ public function js() {
83
+ $scripts = new Visual_Form_Builder_Scripts_Loader();
84
+ $scripts->add_js();
85
+ }
86
+
87
+ /**
88
+ * Handle all security checks
89
+ *
90
+ * Called in the process_email function
91
+ *
92
+ * @access public
93
+ * @static
94
+ * @return void
95
+ */
96
+ public static function security_checks() {
97
+ $security = new Visual_Form_Builder_Security();
98
+
99
+ // Secret check
100
+ if ( true !== $security->secret_check() ) {
101
+ wp_die( $security->secret_check() );
102
+ }
103
+
104
+ // Referer check
105
+ if ( true !== $security->referer_check() ) {
106
+ wp_die( $security->referer_check() );
107
+ }
108
+
109
+ // SPAM Bot check
110
+ if ( true !== $security->bot_check() ) {
111
+ wp_die( $security->bot_check() );
112
+ }
113
+
114
+ // Honeypot check
115
+ if ( true !== $security->honeypot_check() ) {
116
+ wp_die( $security->honeypot_check() );
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Handle the main Email
122
+ *
123
+ * Must be hooked into 'init' so it works properly
124
+ *
125
+ * @access public
126
+ * @static
127
+ * @return void
128
+ */
129
+ public static function process_email() {
130
+ $email = new Visual_Form_Builder_Email();
131
+
132
+ // If form hasn't been submitted, exit
133
+ if ( null == $email->submit_check() )
134
+ return;
135
+
136
+ // Run security checks
137
+ self::security_checks();
138
+
139
+ $email->email();
140
+ }
141
+
142
+ /**
143
+ * Handle the confirmation redirects
144
+ *
145
+ * Must be hooked into 'init' so it works properly
146
+ *
147
+ * @access public
148
+ * @return void
149
+ */
150
+ public static function process_redirect( $form_id ) {
151
+ $confirmation = new Visual_Form_Builder_Confirmation( $form_id );
152
+
153
+ // If form hasn't been submitted, exit
154
+ if ( null == $confirmation->submit_check() )
155
+ return;
156
+
157
+ // WP Page
158
+ $confirmation->wp_page();
159
+
160
+ // Custom URL
161
+ $confirmation->redirect();
162
+ }
163
+
164
+ /**
165
+ * Handle the Text message confirmation action
166
+ *
167
+ * Called directly from the display() function below
168
+ *
169
+ * @access public
170
+ * @return void
171
+ */
172
+ public static function process_confirmation( $form_id ) {
173
+ $confirmation = new Visual_Form_Builder_Confirmation( $form_id );
174
+
175
+ // If form hasn't been submitted, exit
176
+ if ( null == $confirmation->submit_check() )
177
+ return;
178
+
179
+ // Save entry ID to class instance
180
+ //self::$entry_id = $entry_id;
181
+ $message = $confirmation->text();
182
+
183
+ return $message;
184
+ }
185
+
186
+ /**
187
+ * Display form
188
+ *
189
+ * @access public
190
+ * @param mixed $atts
191
+ * @return void
192
+ */
193
+ public static function display( $atts, $output = '' ) {
194
+ wp_enqueue_script( 'jquery-form-validation' );
195
+ wp_enqueue_script( 'visual-form-builder-validation' );
196
+ wp_enqueue_script( 'visual-form-builder-metadata' );
197
+ wp_enqueue_script( 'vfb-validation-i18n' );
198
+
199
+ $atts = shortcode_atts(
200
+ array(
201
+ 'id' => '',
202
+ ),
203
+ $atts,
204
+ 'vfb'
205
+ );
206
+
207
+ $form_id = absint( $atts['id'] );
208
+
209
+ // Text confirmation
210
+ $confirm_message = self::process_confirmation( $form_id );
211
+
212
+ // If text message is returned, output
213
+ if ( null !== $confirm_message ) {
214
+ return $confirm_message;
215
+ }
216
+
217
+ $form = self::get_form( $form_id );
218
+ $fields = self::get_fields( $form_id );
219
+
220
+ // Setup default variables
221
+ $count = 1;
222
+ $open_fieldset = $open_section = false;
223
+ $submit = 'Submit';
224
+ $verification = '';
225
+
226
+ $label_alignment = ( $form->form_label_alignment !== '' ) ? esc_attr( " $form->form_label_alignment" ) : '';
227
+
228
+ // Start form container
229
+ $output .= sprintf( '<div id="vfb-form-%d" class="visual-form-builder-container">', $form_id );
230
+
231
+ $output .= sprintf(
232
+ '<form id="%1$s-%2$d" class="visual-form-builder %3$s %4$s" method="post" enctype="multipart/form-data">
233
+ <input type="hidden" name="form_id" value="%5$d" />',
234
+ esc_attr( $form->form_key ),
235
+ $form_id,
236
+ "vfb-form-$form_id",
237
+ $label_alignment,
238
+ absint( $form->form_id )
239
+ );
240
+
241
+ foreach ( $fields as $field ) {
242
+ $field_id = absint( $field->field_id );
243
+ $field_type = esc_html( $field->field_type );
244
+ $field_name = esc_html( stripslashes( $field->field_name ) );
245
+ $required_span = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? ' <span class="vfb-required-asterisk">*</span>' : '';
246
+ $required = ( !empty( $field->field_required ) && $field->field_required === 'yes' ) ? esc_attr( ' required' ) : '';
247
+ $validation = ( !empty( $field->field_validation ) ) ? esc_attr( " $field->field_validation" ) : '';
248
+ $css = ( !empty( $field->field_css ) ) ? esc_attr( " $field->field_css" ) : '';
249
+ $id_attr = "vfb-{$field_id}";
250
+ $size = ( !empty( $field->field_size ) ) ? esc_attr( " vfb-$field->field_size" ) : '';
251
+ $layout = ( !empty( $field->field_layout ) ) ? esc_attr( " vfb-$field->field_layout" ) : '';
252
+ $default = ( !empty( $field->field_default ) ) ? wp_specialchars_decode( esc_html( stripslashes( $field->field_default ) ), ENT_QUOTES ) : '';
253
+ $description = ( !empty( $field->field_description ) ) ? wp_specialchars_decode( esc_html( stripslashes( $field->field_description ) ), ENT_QUOTES ) : '';
254
+
255
+ // Close each section
256
+ if ( $open_section == true ) {
257
+ // If this field's parent does NOT equal our section ID
258
+ if ( $sec_id && $sec_id !== absint( $field->field_parent ) ) {
259
+ $output .= '</div><div class="vfb-clear"></div>';
260
+ $open_section = false;
261
+ }
262
+ }
263
+
264
+ // Force an initial fieldset and display an error message to strongly encourage user to add one
265
+ if ( $count === 1 && $field_type !== 'fieldset' ) {
266
+ $output .= sprintf(
267
+ '<fieldset class="vfb-fieldset"><div class="vfb-legend" style="background-color:#FFEBE8;border:1px solid #CC0000;"><h3>%1$s</h3><p style="color:black;">%2$s</p></div><ul class="section section-%3$d">',
268
+ __( 'Oops! Missing Fieldset', 'visual-form-builder' ),
269
+ __( '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.', 'visual-form-builder' ),
270
+ $count
271
+ );
272
+
273
+ $count++;
274
+ }
275
+
276
+ if ( $field_type == 'fieldset' ) {
277
+ // Close each fieldset
278
+ if ( $open_fieldset == true ) {
279
+ $output .= '</ul>&nbsp;</fieldset>';
280
+ }
281
+
282
+ // Only display Legend if field name is not blank
283
+ $legend = !empty( $field_name ) ? sprintf( '<div class="vfb-legend"><h3>%s</h3></div>', $field_name ) : '&nbsp;';
284
+
285
+ $output .= sprintf(
286
+ '<fieldset class="vfb-fieldset vfb-fieldset-%1$d %2$s %3$s" id="item-%4$s">%5$s<ul class="vfb-section vfb-section-%1$d">',
287
+ $count,
288
+ esc_attr( $field->field_key ),
289
+ $css,
290
+ $id_attr,
291
+ $legend
292
+ );
293
+
294
+ $open_fieldset = true;
295
+ $count++;
296
+ }
297
+ elseif ( $field_type == 'section' ) {
298
+ $output .= sprintf(
299
+ '<div id="item-%1$s" class="vfb-section-div %2$s"><h4>%3$s</h4>',
300
+ $id_attr,
301
+ $css,
302
+ $field_name
303
+ );
304
+
305
+ // Save section ID for future comparison
306
+ $sec_id = $field_id;
307
+ $open_section = true;
308
+ }
309
+ elseif ( !in_array( $field_type, array( 'verification', 'secret', 'submit' ) ) ) {
310
+ $columns_choice = ( !empty( $field->field_size ) && in_array( $field_type, array( 'radio', 'checkbox' ) ) ) ? esc_attr( " vfb-$field->field_size" ) : '';
311
+
312
+ if ( $field_type !== 'hidden' ) {
313
+ // Don't add for attribute for certain form items
314
+ $for = !in_array( $field_type, array( 'checkbox', 'radio', 'time', 'address', 'instructions' ) ) ? ' for="%4$s"' : '';
315
+
316
+ $output .= sprintf(
317
+ '<li class="vfb-item vfb-item-%1$s %2$s %3$s" id="item-%4$s"><label' . $for . ' class="vfb-desc">%5$s %6$s</label>',
318
+ $field_type,
319
+ $columns_choice,
320
+ $layout,
321
+ $id_attr,
322
+ $field_name,
323
+ $required_span
324
+ );
325
+ }
326
+ }
327
+ elseif ( in_array( $field_type, array( 'verification', 'secret' ) ) ) {
328
+
329
+ if ( $field_type == 'verification' ) {
330
+ $verification .= sprintf(
331
+ '<fieldset class="vfb-fieldset vfb-fieldset-%1$d %2$s %3$s" id="item-%4$s" style="display:block"><div class="vfb-legend"><h3>%5$s</h3></div><ul class="vfb-section vfb-section-%1$d">',
332
+ $count,
333
+ esc_attr( $field->field_key ),
334
+ $css,
335
+ $id_attr,
336
+ $field_name
337
+ );
338
+ }
339
+
340
+ if ( $field_type == 'secret' ) {
341
+ // Default logged in values
342
+ $logged_in_display = $logged_in_value = '';
343
+
344
+ // If the user is logged in, fill the field in for them
345
+ if ( is_user_logged_in() ) {
346
+ // Hide the secret field if logged in
347
+ $logged_in_display = ' style="display:none;"';
348
+ $logged_in_value = 14;
349
+
350
+ // Get logged in user details
351
+ $user = wp_get_current_user();
352
+ $user_identity = ! empty( $user->ID ) ? $user->display_name : '';
353
+
354
+ // Display a message for logged in users
355
+ $logged_in_as = sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. Verification not required.', 'visual-form-builder' ), admin_url( 'profile.php' ), $user_identity );
356
+
357
+ $verification .= sprintf(
358
+ '<li class="vfb-item" id="%1$s">%2$s</li>',
359
+ $id_attr,
360
+ $logged_in_as
361
+ );
362
+ }
363
+
364
+ $verification .= sprintf(
365
+ '<li class="vfb-item vfb-item-%1$s" %2$s style="display:block"><label for="%3$s" class="vfb-desc">%4$s%5$s</label>',
366
+ $field_type,
367
+ $logged_in_display,
368
+ $id_attr,
369
+ $field_name,
370
+ $required_span
371
+ );
372
+
373
+ // Set variable for testing if required is Yes/No
374
+ $verification .= ( empty( $required ) ) ? '<input type="hidden" name="_vfb-required-secret" value="0" />' : '';
375
+
376
+ // Set hidden secret to matching input
377
+ $verification .= sprintf( '<input type="hidden" name="_vfb-secret" value="vfb-%d" />', $field_id );
378
+
379
+ $validation = '{digits:true,maxlength:2,minlength:2}';
380
+
381
+ $verification_item = sprintf(
382
+ '<input type="text" name="vfb-%1$d" id="%2$s" value="%3$s" class="vfb-text %4$s %5$s %6$s %7$s" style="display:block" />',
383
+ $field_id,
384
+ $id_attr,
385
+ $logged_in_value,
386
+ $size,
387
+ $required,
388
+ $validation,
389
+ $css
390
+ );
391
+
392
+ $verification .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span">%1$s<label>%2$s</label></span>', $verification_item, $description ) : $verification_item;
393
+ }
394
+ }
395
+
396
+ switch ( $field_type ) {
397
+ case 'text' :
398
+ case 'email' :
399
+ case 'url' :
400
+ case 'currency' :
401
+ case 'number' :
402
+ case 'phone' :
403
+
404
+ // HTML5 types
405
+ if ( in_array( $field_type, array( 'email', 'url' ) ) ) {
406
+ $type = esc_attr( $field_type );
407
+ }
408
+ elseif ( 'phone' == $field_type ) {
409
+ $type = 'tel';
410
+ }
411
+ else {
412
+ $type = 'text';
413
+ }
414
+
415
+ $form_item = sprintf(
416
+ '<input type="%8$s" name="vfb-%1$d" id="%2$s" value="%3$s" class="vfb-text %4$s %5$s %6$s %7$s" />',
417
+ $field_id,
418
+ $id_attr,
419
+ $default,
420
+ $size,
421
+ $required,
422
+ $validation,
423
+ $css,
424
+ $type
425
+ );
426
+
427
+ $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span">%1$s<label>%2$s</label></span>', $form_item, $description ) : $form_item;
428
+
429
+ break;
430
+
431
+ case 'textarea' :
432
+ $form_item = sprintf(
433
+ '<textarea name="vfb-%1$d" id="%2$s" class="vfb-textarea %4$s %5$s %6$s">%3$s</textarea>',
434
+ $field_id,
435
+ $id_attr,
436
+ $default,
437
+ $size,
438
+ $required,
439
+ $css
440
+ );
441
+
442
+ $output .= '<div>';
443
+
444
+ $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span"><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
445
+
446
+ $output .= '</div>';
447
+
448
+ break;
449
+
450
+ case 'select' :
451
+ $field_options = maybe_unserialize( $field->field_options );
452
+
453
+ $options = '';
454
+
455
+ // Loop through each option and output
456
+ foreach ( $field_options as $option => $value ) {
457
+ $options .= sprintf( '<option value="%1$s"%2$s>%1$s</option>', esc_attr(trim( stripslashes( $value ) ) ), selected( $default, ++$option, 0 ) );
458
+ }
459
+
460
+ $form_item = sprintf(
461
+ '<select name="vfb-%1$d" id="%2$s" class="vfb-select %3$s %4$s %5$s">%6$s</select>',
462
+ $field_id,
463
+ $id_attr,
464
+ $size,
465
+ $required,
466
+ $css,
467
+ $options
468
+ );
469
+
470
+ $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span"><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
471
+
472
+ break;
473
+
474
+ case 'radio' :
475
+ $field_options = maybe_unserialize( $field->field_options );
476
+
477
+ $options = '';
478
+
479
+ // Loop through each option and output
480
+ foreach ( $field_options as $option => $value ) {
481
+ $option++;
482
+
483
+ $options .= sprintf(
484
+ '<span class="vfb-span"><input type="radio" name="vfb-%1$d" id="%2$s-%3$d" value="%6$s" class="vfb-radio %4$s %5$s"%8$s /><label for="%2$s-%3$d" class="vfb-choice">%7$s</label></span>',
485
+ $field_id,
486
+ $id_attr,
487
+ $option,
488
+ $required,
489
+ $css,
490
+ esc_attr( trim( stripslashes( $value ) ) ),
491
+ wp_specialchars_decode( stripslashes( $value ) ),
492
+ checked( $default, $option, 0 )
493
+ );
494
+ }
495
+
496
+ $form_item = $options;
497
+
498
+ $output .= '<div>';
499
+
500
+ $output .= ( !empty( $description ) ) ? sprintf( '<span><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
501
+
502
+ $output .= '<div style="clear:both"></div></div>';
503
+
504
+ break;
505
+
506
+ case 'checkbox' :
507
+ $field_options = maybe_unserialize( $field->field_options );
508
+
509
+ $options = '';
510
+
511
+ // Loop through each option and output
512
+ foreach ( $field_options as $option => $value ) {
513
+ $options .= sprintf(
514
+ '<span class="vfb-span"><input type="checkbox" name="vfb-%1$d[]" id="%2$s-%3$d" value="%6$s" class="vfb-checkbox %4$s %5$s"%8$s /><label for="%2$s-%3$d" class="vfb-choice">%7$s</label></span>',
515
+ $field_id,
516
+ $id_attr,
517
+ $option,
518
+ $required,
519
+ $css,
520
+ esc_attr( trim( stripslashes( $value ) ) ),
521
+ wp_specialchars_decode( stripslashes( $value ) ),
522
+ checked( $default, ++$option, 0 )
523
+ );
524
+ }
525
+
526
+ $form_item = $options;
527
+
528
+ $output .= '<div>';
529
+
530
+ $output .= ( !empty( $description ) ) ? sprintf( '<span><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
531
+
532
+ $output .= '<div style="clear:both"></div></div>';
533
+
534
+ break;
535
+
536
+ case 'address' :
537
+ $address = '';
538
+
539
+ $address_parts = array(
540
+ 'address' => array(
541
+ 'label' => __( 'Street Address', 'visual-form-builder' ),
542
+ 'layout' => 'full'
543
+ ),
544
+ 'address-2' => array(
545
+ 'label' => __( 'Apt, Suite, Bldg. (optional)', 'visual-form-builder' ),
546
+ 'layout' => 'full'
547
+ ),
548
+ 'city' => array(
549
+ 'label' => __( 'City', 'visual-form-builder' ),
550
+ 'layout' => 'left'
551
+ ),
552
+ 'state' => array(
553
+ 'label' => __( 'State / Province / Region', 'visual-form-builder' ),
554
+ 'layout' => 'right'
555
+ ),
556
+ 'zip' => array(
557
+ 'label' => __( 'Postal / Zip Code', 'visual-form-builder' ),
558
+ 'layout' => 'left'
559
+ ),
560
+ 'country' => array(
561
+ 'label' => __( 'Country', 'visual-form-builder' ),
562
+ 'layout' => 'right'
563
+ )
564
+ );
565
+
566
+ $address_parts = apply_filters( 'vfb_address_labels', $address_parts, $form_id );
567
+
568
+ $label_placement = apply_filters( 'vfb_address_labels_placement', $settings_address_labels, $form_id );
569
+
570
+ $placement_bottom = ( $label_placement ) ? '<label for="%2$s-%4$s">%5$s</label>' : '';
571
+ $placement_top = ( !$label_placement ) ? '<label for="%2$s-%4$s">%5$s</label>' : '';
572
+
573
+ foreach ( $address_parts as $parts => $part ) {
574
+
575
+ // Make sure the second address line is not required
576
+ $addr_required = ( 'address-2' !== $parts ) ? $required : '';
577
+
578
+ if ( 'country' == $parts ) {
579
+
580
+ $options = '';
581
+ $countries = include( VFB_WP_PLUGIN_DIR . '/inc/countries.php' );
582
+ foreach ( $countries as $country ) {
583
+ $options .= sprintf( '<option value="%1$s"%2$s>%1$s</option>', $country, selected( $default, $country, 0 ) );
584
+ }
585
+
586
+ $address .= sprintf(
587
+ '<span class="vfb-%3$s">' . $placement_top . '<select name="vfb-%1$d[%4$s]" class="vfb-select %7$s %8$s" id="%2$s-%4$s">%6$s</select>' . $placement_bottom . '</span>',
588
+ $field_id,
589
+ $id_attr,
590
+ esc_attr( $part['layout'] ),
591
+ esc_attr( $parts ),
592
+ esc_html( $part['label'] ),
593
+ $options,
594
+ $addr_required,
595
+ $css
596
+ );
597
+ }
598
+ else {
599
+ $address .= sprintf(
600
+ '<span class="vfb-%3$s">' . $placement_top . '<input type="text" name="vfb-%1$d[%4$s]" id="%2$s-%4$s" maxlength="150" class="vfb-text vfb-medium %7$s %8$s" />' . $placement_bottom . '</span>',
601
+ $field_id,
602
+ $id_attr,
603
+ esc_attr( $part['layout'] ),
604
+ esc_attr( $parts ),
605
+ esc_html( $part['label'] ),
606
+ $size,
607
+ $addr_required,
608
+ $css
609
+ );
610
+ }
611
+ }
612
+
613
+ $output .= '<div>';
614
+
615
+ $output .= !empty( $description ) ? "<span class='vfb-span'><label>$description</label></span>$address" : $address;
616
+
617
+ $output .= '</div>';
618
+
619
+ break;
620
+
621
+ case 'date' :
622
+ // Load jQuery UI datepicker library
623
+ wp_enqueue_script( 'jquery-ui-datepicker' );
624
+ wp_enqueue_script( 'vfb-datepicker-i18n' );
625
+
626
+ $options = maybe_unserialize( $field->field_options );
627
+ $dateFormat = ( $options ) ? $options['dateFormat'] : '';
628
+
629
+ $form_item = sprintf(
630
+ '<input type="text" name="vfb-%1$d" id="%2$s" value="%3$s" class="vfb-text vfb-date-picker %4$s %5$s %6$s" data-dp-dateFormat="%7$s" />',
631
+ $field_id,
632
+ $id_attr,
633
+ $default,
634
+ $size,
635
+ $required,
636
+ $css,
637
+ $dateFormat
638
+ );
639
+
640
+ $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span">%1$s<label>%2$s</label></span>', $form_item, $description ) : $form_item;
641
+
642
+ break;
643
+
644
+ case 'time' :
645
+ $hour = $minute = $ampm = '';
646
+
647
+ // Get the time format (12 or 24)
648
+ $time_format = str_replace( 'time-', '', $validation );
649
+
650
+ $time_format = apply_filters( 'vfb_time_format', $time_format, $form_id );
651
+ $total_mins = apply_filters( 'vfb_time_min_total', 55, $form_id );
652
+ $min_interval = apply_filters( 'vfb_time_min_interval', 5, $form_id );
653
+
654
+ // Set whether we start with 0 or 1 and how many total hours
655
+ $hour_start = ( $time_format == '12' ) ? 1 : 0;
656
+ $hour_total = ( $time_format == '12' ) ? 12 : 23;
657
+
658
+ // Hour
659
+ for ( $i = $hour_start; $i <= $hour_total; $i++ ) {
660
+ $hour .= sprintf( '<option value="%1$02d">%1$02d</option>', $i );
661
+ }
662
+
663
+ // Minute
664
+ for ( $i = 0; $i <= $total_mins; $i += $min_interval ) {
665
+ $minute .= sprintf( '<option value="%1$02d">%1$02d</option>', $i );
666
+ }
667
+
668
+ // AM/PM
669
+ if ( $time_format == '12' ) {
670
+ $ampm = sprintf(
671
+ '<span class="vfb-time"><select name="vfb-%1$d[ampm]" id="%2$s-ampm" class="vfb-select %5$s %6$s"><option value="AM">AM</option><option value="PM">PM</option></select><label for="%2$s-ampm">AM/PM</label></span>',
672
+ $field_id,
673
+ $id_attr,
674
+ $hour,
675
+ $minute,
676
+ $required,
677
+ $css
678
+ );
679
+ }
680
+
681
+ $form_item = sprintf(
682
+ '<span class="vfb-time"><select name="vfb-%1$d[hour]" id="%2$s-hour" class="vfb-select %5$s %6$s">%3$s</select><label for="%2$s-hour">HH</label></span>' .
683
+ '<span class="vfb-time"><select name="vfb-%1$d[min]" id="%2$s-min" class="vfb-select %5$s %6$s">%4$s</select><label for="%2$s-min">MM</label></span>' .
684
+ '%7$s',
685
+ $field_id,
686
+ $id_attr,
687
+ $hour,
688
+ $minute,
689
+ $required,
690
+ $css,
691
+ $ampm
692
+ );
693
+
694
+ $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span"><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
695
+
696
+ $output .= '<div class="clear"></div>';
697
+
698
+ break;
699
+
700
+ case 'html' :
701
+ //Load CKEditor library
702
+ wp_enqueue_script( 'vfb-ckeditor' );
703
+
704
+ $form_item = sprintf(
705
+ '<textarea name="vfb-%1$d" id="%2$s" class="vfb-textarea ckeditor %4$s %5$s %6$s">%3$s</textarea>',
706
+ $field_id,
707
+ $id_attr,
708
+ $default,
709
+ $size,
710
+ $required,
711
+ $css
712
+ );
713
+
714
+ $output .= '<div>';
715
+
716
+ $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span"><label>%2$s</label></span>%1$s', $form_item, $description ) : $form_item;
717
+
718
+ $output .= '</div>';
719
+
720
+ break;
721
+
722
+ case 'file-upload' :
723
+ $options = maybe_unserialize( $field->field_options );
724
+ $accept = ( !empty( $options[0] ) ) ? " {accept:'$options[0]'}" : '';
725
+
726
+
727
+ $form_item = sprintf(
728
+ '<input type="file" name="vfb-%1$d" id="%2$s" value="%3$s" class="vfb-text %4$s %5$s %6$s %7$s %8$s" />',
729
+ $field_id,
730
+ $id_attr,
731
+ $default,
732
+ $size,
733
+ $required,
734
+ $validation,
735
+ $css,
736
+ $accept
737
+ );
738
+
739
+ $output .= ( !empty( $description ) ) ? sprintf( '<span class="vfb-span">%1$s<label>%2$s</label></span>', $form_item, $description ) : $form_item;
740
+
741
+ break;
742
+
743
+ case 'instructions' :
744
+
745
+ $output .= wp_specialchars_decode( esc_html( stripslashes( $description ) ), ENT_QUOTES );
746
+
747
+ break;
748
+
749
+ case 'submit' :
750
+ $submit = sprintf(
751
+ '<li class="vfb-item vfb-item-submit" id="item-%2$s">
752
+ <input type="submit" name="vfb-submit" id="%2$s" value="%3$s" class="vfb-submit %4$s" />
753
+ </li>',
754
+ $field_id,
755
+ $id_attr,
756
+ wp_specialchars_decode( esc_html( $field_name ), ENT_QUOTES ),
757
+ $css
758
+ );
759
+
760
+ break;
761
+
762
+ default:
763
+ echo '';
764
+ }
765
+
766
+ // Closing </li>
767
+ $output .= ( !in_array( $field_type , array( 'verification', 'secret', 'submit', 'fieldset', 'section' ) ) ) ? '</li>' : '';
768
+ }
769
+
770
+ // Close user-added fields
771
+ $output .= '</ul>&nbsp;</fieldset>';
772
+
773
+ // Make sure the verification displays even if they have not updated their form
774
+ if ( empty( $verification ) ) {
775
+ $verification = sprintf(
776
+ '<fieldset class="vfb-fieldset vfb-verification" style="display:block">
777
+ <div class="vfb-legend"><h3>%1$s</h3></div>
778
+ <ul class="vfb-section vfb-section-%2$d">
779
+ <li class="vfb-item vfb-item-text" style="display:block">
780
+ <label for="vfb-secret" class="vfb-desc">%3$s<span>*</span></label>
781
+ <div><input type="text" name="vfb-secret" id="vfb-secret" class="vfb-text vfb-medium" style="display:block" /></div>
782
+ </li>',
783
+ __( 'Verification' , 'visual-form-builder'),
784
+ $count,
785
+ __( 'Please enter any two digits with <strong>no</strong> spaces (Example: 12)' , 'visual-form-builder')
786
+ );
787
+ }
788
+
789
+ // Output our security test
790
+ $output .= sprintf(
791
+ $verification .
792
+ '<li style="display:none;"><label>%1$s:</label><div><input name="vfb-spam" /></div></li>
793
+ %2$s</ul>
794
+ </fieldset>',
795
+ __( 'This box is for spam protection - <strong>please leave it blank</strong>' , 'visual-form-builder'),
796
+ $submit
797
+ );
798
+
799
+ $output .= wp_referer_field( false );
800
+
801
+ // Close the form out
802
+ $output .= '</form>';
803
+
804
+ // Close form container
805
+ $output .= '</div> <!-- .visual-form-builder-container -->';
806
+
807
+ // Force tags to balance
808
+ force_balance_tags( $output );
809
+
810
+ return $output;
811
+ }
812
+
813
+ /**
814
+ * [get_form description]
815
+ * @param [type] $form_id [description]
816
+ * @return [type] [description]
817
+ */
818
+ public function get_form( $form_id ) {
819
+ global $wpdb;
820
+
821
+ $order = sanitize_sql_orderby( 'form_id DESC' );
822
+ $form = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . VFB_WP_FORMS_TABLE_NAME . " WHERE form_id = %d ORDER BY $order", $form_id ) );
823
+
824
+ if ( !$form )
825
+ return;
826
+
827
+ return $form;
828
+ }
829
+
830
+ /**
831
+ * [get_fields description]
832
+ * @param [type] $form_id [description]
833
+ * @return [type] [description]
834
+ */
835
+ public function get_fields( $form_id ) {
836
+ global $wpdb;
837
+
838
+ $order_fields = sanitize_sql_orderby( 'field_sequence ASC' );
839
+ $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . VFB_WP_FIELDS_TABLE_NAME . " WHERE form_id = %d ORDER BY $order_fields", $form_id ) );
840
+
841
+ if ( !$fields )
842
+ return;
843
+
844
+ return $fields;
845
+ }
846
+ }
public/class-load-css-js.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads all CSS and JS files that VFB needs
4
+ *
5
+ * This class should be called when the menu is added
6
+ * so the CSS and JS is added to ONLY our VFB pages.
7
+ *
8
+ */
9
+ class Visual_Form_Builder_Scripts_Loader {
10
+
11
+ /**
12
+ * Load CSS on VFB pages.
13
+ *
14
+ * @access public
15
+ * @return void
16
+ */
17
+ public function add_css() {
18
+ wp_register_style( 'vfb-jqueryui-css', apply_filters( 'vfb-date-picker-css', VFB_WP_PLUGIN_URL . "public/assets/css/smoothness/jquery-ui-1.10.3.min.css" ), array(), '2013.12.03' );
19
+ wp_register_style( 'visual-form-builder-css', apply_filters( 'visual-form-builder-css', VFB_WP_PLUGIN_URL . "public/assets/css/visual-form-builder.min.css" ), array(), '2014.04.12' );
20
+
21
+ $vfb_settings = get_option( 'vfb-settings' );
22
+
23
+ // Settings - Always load CSS
24
+ if ( isset( $vfb_settings['always-load-css'] ) ) {
25
+ wp_enqueue_style( 'visual-form-builder-css' );
26
+ wp_enqueue_style( 'vfb-jqueryui-css' );
27
+
28
+ return;
29
+ }
30
+
31
+ // Settings - Disable CSS
32
+ if ( isset( $vfb_settings['disable-css'] ) )
33
+ return;
34
+
35
+ // Get active widgets
36
+ $widget = is_active_widget( false, false, 'vfb_widget' );
37
+
38
+ // If no widget is found, test for shortcode
39
+ if ( empty( $widget ) ) {
40
+ // If WordPress 3.6, use internal function. Otherwise, my own
41
+ if ( function_exists( 'has_shortcode' ) ) {
42
+ global $post;
43
+
44
+ // If no post exists, exit
45
+ if ( !$post )
46
+ return;
47
+
48
+ if ( !has_shortcode( $post->post_content, 'vfb' ) )
49
+ return;
50
+ } elseif ( !$this->has_shortcode( 'vfb' ) ) {
51
+ return;
52
+ }
53
+ }
54
+
55
+ wp_enqueue_style( 'visual-form-builder-css' );
56
+ wp_enqueue_style( 'vfb-jqueryui-css' );
57
+ }
58
+
59
+ /**
60
+ * Load JS on VFB pages
61
+ *
62
+ * @access public
63
+ * @return void
64
+ */
65
+ public function add_js() {
66
+ wp_register_script( 'jquery-form-validation', VFB_WP_PLUGIN_URL . "public/assets/js/jquery.validate.min.js", array( 'jquery' ), '1.9.0', true );
67
+ wp_register_script( 'visual-form-builder-validation', VFB_WP_PLUGIN_URL . "public/assets/js/vfb-validation.min.js", array( 'jquery', 'jquery-form-validation' ), '2014.04.12', true );
68
+ wp_register_script( 'visual-form-builder-metadata', VFB_WP_PLUGIN_URL . "public/assets/js/jquery.metadata.js", array( 'jquery', 'jquery-form-validation' ), '2.0', true );
69
+ wp_register_script( 'vfb-ckeditor', VFB_WP_PLUGIN_URL . "public/assets/js/ckeditor/ckeditor.js", array( 'jquery' ), '4.1', true );
70
+
71
+ $locale = get_locale();
72
+ $translations = array(
73
+ 'cs_CS', // Czech
74
+ 'de_DE', // German
75
+ 'el_GR', // Greek
76
+ 'en_US', // English (US)
77
+ 'en_AU', // English (AU)
78
+ 'en_GB', // English (GB)
79
+ 'es_ES', // Spanish
80
+ 'fr_FR', // French
81
+ 'he_IL', // Hebrew
82
+ 'hu_HU', // Hungarian
83
+ 'id_ID', // Indonseian
84
+ 'it_IT', // Italian
85
+ 'ja_JP', // Japanese
86
+ 'ko_KR', // Korean
87
+ 'nl_NL', // Dutch
88
+ 'pl_PL', // Polish
89
+ 'pt_BR', // Portuguese (Brazilian)
90
+ 'pt_PT', // Portuguese (European)
91
+ 'ro_RO', // Romanian
92
+ 'ru_RU', // Russian
93
+ 'sv_SE', // Swedish
94
+ 'tr_TR', // Turkish
95
+ 'zh_CN', // Chinese
96
+ 'zh_TW', // Chinese (Taiwan)
97
+ );
98
+
99
+ // Load localized vaidation and datepicker text, if translation files exist
100
+ if ( in_array( $locale, $translations ) ) {
101
+ wp_register_script( 'vfb-validation-i18n', VFB_WP_PLUGIN_URL . "public/assets/js/i18n/validate/messages-$locale.js", array( 'jquery-form-validation' ), '1.9.0', true );
102
+ wp_register_script( 'vfb-datepicker-i18n', VFB_WP_PLUGIN_URL . "public/assets/js/i18n/datepicker/datepicker-$locale.js", array( 'jquery-ui-datepicker' ), '1.0', true );
103
+ }
104
+ // Otherwise, load English translations
105
+ else {
106
+ wp_register_script( 'vfb-validation-i18n', VFB_WP_PLUGIN_URL . "public/assets/js/i18n/validate/messages-en_US.js", array( 'jquery-form-validation' ), '1.9.0', true );
107
+ wp_register_script( 'vfb-datepicker-i18n', VFB_WP_PLUGIN_URL . "public/assets/js/i18n/datepicker/datepicker-en_US.js", array( 'jquery-ui-datepicker' ), '1.0', true );
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Check whether the content contains the specified shortcode
113
+ *
114
+ * @access public
115
+ * @param string $shortcode (default: '')
116
+ * @return void
117
+ */
118
+ public function has_shortcode( $shortcode = '' ) {
119
+
120
+ $post_to_check = get_post( get_the_ID() );
121
+
122
+ // false because we have to search through the post content first
123
+ $found = false;
124
+
125
+ // if no short code was provided, return false
126
+ if ( !$shortcode ) {
127
+ return $found;
128
+ }
129
+
130
+ // check the post content for the short code
131
+ if ( stripos( $post_to_check->post_content, '[' . $shortcode ) !== false ) {
132
+ // we have found the short code
133
+ $found = true;
134
+ }
135
+
136
+ // return our final results
137
+ return $found;
138
+ }
139
+ }
public/class-security.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Handles all security checks
4
+ *
5
+ */
6
+ class Visual_Form_Builder_Security {
7
+ /**
8
+ * __construct function.
9
+ *
10
+ * @access public
11
+ * @return void
12
+ */
13
+ public function __construct() {
14
+ }
15
+
16
+ /**
17
+ * honeypot_check function.
18
+ *
19
+ * @access public
20
+ * @return void
21
+ */
22
+ public function honeypot_check() {
23
+ if ( !isset( $_POST['vfb-spam'] ) )
24
+ return true;
25
+
26
+ if ( isset( $_POST['vfb-spam'] ) && !empty( $_POST['vfb-spam'] ) )
27
+ return __( 'Security check: you filled out a form field that was created to stop spam bots and should be left blank. If you think this is an error, please email the site owner.', 'visual-form-builder' );
28
+
29
+ return true;
30
+ }
31
+
32
+ /**
33
+ * secret_check function.
34
+ *
35
+ * @access public
36
+ * @return void
37
+ */
38
+ public function secret_check() {
39
+ $required = ( isset( $_POST['_vfb-required-secret'] ) && $_POST['_vfb-required-secret'] == '0' ) ? false : true;
40
+ $secret_field = ( isset( $_POST['_vfb-secret'] ) ) ? esc_html( $_POST['_vfb-secret'] ) : '';
41
+
42
+ // If the verification is set to required, run validation check
43
+ if ( true == $required && !empty( $secret_field ) ) {
44
+ if ( !is_numeric( $_POST[ $secret_field ] ) || strlen( $_POST[ $secret_field ] ) !== 2 ) {
45
+ return __( 'Security check: failed secret question. Please try again!' , 'visual-form-builder' );
46
+ }
47
+ }
48
+
49
+ return true;
50
+ }
51
+
52
+ /**
53
+ * [referer_check description]
54
+ * @return [type] [description]
55
+ */
56
+ public function referer_check() {
57
+ $referrer = ( isset( $_POST['_wp_http_referer'] ) ) ? esc_html( $_POST['_wp_http_referer'] ) : false;
58
+ $wp_get_referer = wp_get_referer();
59
+ $form_id = absint( $_POST['form_id'] );
60
+
61
+ $skip_referrer_check = apply_filters( 'vfb_skip_referrer_check', false, $form_id );
62
+
63
+ // Test if referral URL has been set
64
+ if ( !$referrer ) {
65
+ return __( 'Security check: referal URL does not appear to be set.' , 'visual-form-builder' );
66
+ }
67
+
68
+ // Allow referrer check to be skipped
69
+ if ( !$skip_referrer_check ) {
70
+ // Test if the referral URL matches what sent from WordPress
71
+ if ( $wp_get_referer ) {
72
+ return __( 'Security check: referal does not match this site.' , 'visual-form-builder' );
73
+ }
74
+ }
75
+
76
+ return true;
77
+ }
78
+
79
+ /**
80
+ * Make sure the User Agent string is not a SPAM bot.
81
+ *
82
+ * Returns true if NOT a SPAM bot
83
+ *
84
+ * @access public
85
+ * @return void
86
+ */
87
+ public function bot_check() {
88
+ $bots = array(
89
+ '<', '>', '&lt;', '%0A', '%0D', '%27', '%3C', '%3E', '%00', 'href',
90
+ 'binlar', 'casper', 'cmsworldmap', 'comodo', 'diavol',
91
+ 'dotbot', 'feedfinder', 'flicky', 'ia_archiver', 'jakarta',
92
+ 'kmccrew', 'nutch', 'planetwork', 'purebot', 'pycurl',
93
+ 'skygrid', 'sucker', 'turnit', 'vikspider', 'zmeu',
94
+ );
95
+
96
+ $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? wp_kses_data( $_SERVER['HTTP_USER_AGENT'] ) : '';
97
+
98
+ do_action( 'vfb_isBot', $user_agent, $bots );
99
+
100
+ foreach ( $bots as $bot ) {
101
+ if ( stripos( $user_agent, $bot ) !== false )
102
+ return __( 'Security check: looks like you are a SPAM bot. If you think this is an error, please email the site owner.' , 'visual-form-builder' );
103
+ }
104
+
105
+ return true;
106
+ }
107
+ }
public/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden.
readme.txt CHANGED
@@ -3,8 +3,8 @@ 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, contact forms, form, forms, form to email, email form, email, input, validation, jquery, shortcode, form builder, contact form builder, form manager, form creator
5
  Requires at least: 4.3
6
- Tested up to: 4.8.2
7
- Stable tag: 2.9.4
8
  License: GPLv2 or later
9
 
10
  Build beautiful, fully functional contact forms in only a few minutes without writing PHP, CSS, or HTML.
@@ -13,9 +13,9 @@ Build beautiful, fully functional contact forms in only a few minutes without wr
13
 
14
  *Visual Form Builder* is a plugin that allows you to build and manage all kinds of forms for your website in a single place. Building a fully functional contact form takes only a few minutes and you don't have to write one bit of PHP, CSS, or HTML!
15
 
16
- = Upgrade to Visual Form Builder Pro =
17
 
18
- If you are a fan of Visual Form Builder and want extra features and functionality, [Visual Form Builder Pro](http://vfbpro.com) is available.
19
 
20
  = Features =
21
 
@@ -156,16 +156,16 @@ Visual Form Builder requires at least jQuery version 1.7. Please make sure your
156
 
157
  **CSS conflicts**
158
 
159
- If your forms do not look as expected, chances are there's some CSS in your theme conflicting with the built-in CSS of Visual Form Builder. Please follow the tutorial on [how to customize the CSS](http://matthewmuro.com/2012/11/15/visual-form-builder-pro-customizing-the-form-design/).
160
 
161
  **Theme conflicts**
162
 
163
  If you have confirmed that you are using the latest version of jQuery and can rule out CSS conflicts, there's probably something in your theme still causing problems.
164
 
165
- 1. Activate the default Twenty Eleven theme
166
  1. Test your site to see if the issue still occurs
167
 
168
- Still having problems even with Twenty Eleven running? If not, it's a conflict with your theme. Otherwise, it's probably a plugin conflict.
169
 
170
  **Plugin conflicts**
171
 
@@ -181,19 +181,12 @@ If, after following the above procedures, you are still having problems please r
181
 
182
  = Customizing the form design =
183
 
184
- Please follow the tutorial on [how to customize the CSS](http://matthewmuro.com/2012/11/15/visual-form-builder-pro-customizing-the-form-design/).
185
-
186
- By upgrading to Visual Form Builder Pro, you be able to purchase the [Form Designer](http://vfbpro.com/add-ons/form-designer) add-on which will let you easily customize the design.
187
 
188
  = Customizing the Date Picker =
189
 
190
  The jQuery UI Date Picker is a complex and highly configurable plugin. By default, Visual Form Builder's date field will use the default options and configuration.
191
 
192
- To use the more complex features of the Date Picker plugin, please read these tutorials from the blog:
193
-
194
- 1. [How to customize the Date Picker](http://matthewmuro.com/2012/02/23/how-to-customize-the-date-picker/)
195
- 1. [Even more Date Picker customizations](http://matthewmuro.com/2012/08/20/even-more-date-picker-customizations/).
196
-
197
  = How do I translate the error messages to my language? =
198
 
199
  The validation messages (ex: ‘This field is required’ or ‘Please enter a valid email address’) are generated by the jQuery Form Validation plugin.
@@ -237,6 +230,10 @@ function my_scripts_method() {
237
 
238
  == Changelog ==
239
 
 
 
 
 
240
  **Version 2.9.4 - Oct 01, 2017**
241
 
242
  * Minor code updates
@@ -850,4 +847,4 @@ Recommended update immediately! Fix for bug where confirmation screen does not i
850
  New, faster way to add form items and ability to customize Confirmation. Fix for validation on security field.
851
 
852
  = 1.2.1 =
853
- Recommended update immediately! Fix for bug where entries table does not install.
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, contact forms, form, forms, form to email, email form, email, input, validation, jquery, shortcode, form builder, contact form builder, form manager, form creator
5
  Requires at least: 4.3
6
+ Tested up to: 4.9.2
7
+ Stable tag: 2.9.5
8
  License: GPLv2 or later
9
 
10
  Build beautiful, fully functional contact forms in only a few minutes without writing PHP, CSS, or HTML.
13
 
14
  *Visual Form Builder* is a plugin that allows you to build and manage all kinds of forms for your website in a single place. Building a fully functional contact form takes only a few minutes and you don't have to write one bit of PHP, CSS, or HTML!
15
 
16
+ = Upgrade to VFB Pro =
17
 
18
+ If you are a fan of Visual Form Builder and want extra features and functionality, [VFB Pro](http://vfbpro.com) is available.
19
 
20
  = Features =
21
 
156
 
157
  **CSS conflicts**
158
 
159
+ If your forms do not look as expected, chances are there's some CSS in your theme conflicting with the built-in CSS of Visual Form Builder.
160
 
161
  **Theme conflicts**
162
 
163
  If you have confirmed that you are using the latest version of jQuery and can rule out CSS conflicts, there's probably something in your theme still causing problems.
164
 
165
+ 1. Activate the default "Twenty" theme
166
  1. Test your site to see if the issue still occurs
167
 
168
+ Still having problems even with the default theme running? If not, it's a conflict with your theme. Otherwise, it's probably a plugin conflict.
169
 
170
  **Plugin conflicts**
171
 
181
 
182
  = Customizing the form design =
183
 
184
+ By upgrading to VFB Pro, you be able to purchase the [Form Designer](http://vfbpro.com/add-ons/form-designer) add-on which will let you easily customize the design.
 
 
185
 
186
  = Customizing the Date Picker =
187
 
188
  The jQuery UI Date Picker is a complex and highly configurable plugin. By default, Visual Form Builder's date field will use the default options and configuration.
189
 
 
 
 
 
 
190
  = How do I translate the error messages to my language? =
191
 
192
  The validation messages (ex: ‘This field is required’ or ‘Please enter a valid email address’) are generated by the jQuery Form Validation plugin.
230
 
231
  == Changelog ==
232
 
233
+ **Version 2.9.5 - Feb 11, 2018**
234
+
235
+ * Refactor structure of plugin
236
+
237
  **Version 2.9.4 - Oct 01, 2017**
238
 
239
  * Minor code updates
847
  New, faster way to add form items and ability to customize Confirmation. Fix for validation on security field.
848
 
849
  = 1.2.1 =
850
+ Recommended update immediately! Fix for bug where entries table does not install.
visual-form-builder.php CHANGED
@@ -3,2172 +3,233 @@
3
  Plugin Name: Visual Form Builder
4
  Plugin URI: https://wordpress.org/plugins/visual-form-builder/
5
  Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
6
- Version: 2.9.4
7
  Author: Matthew Muro
8
- Author URI: http://matthewmuro.com
9
  Text Domain: visual-form-builder
10
  Domain Path: /languages/
11
  */
12
 
13
- // Version number to output as meta tag
14
- define( 'VFB_VERSION', '2.9.4' );
 
15
 
16
- /*
17
- This program is free software; you can redistribute it and/or modify
18
- it under the terms of the GNU General Public License as published by
19
- the Free Software Foundation; version 2 of the License.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29
- */
30
-
31
- // Instantiate new class
32
- $visual_form_builder = new Visual_Form_Builder();
33
-
34
- // Visual Form Builder class
35
- class Visual_Form_Builder{
36
-
37
- /**
38
- * The DB version. Used for SQL install and upgrades.
39
- *
40
- * Should only be changed when needing to change SQL
41
- * structure or custom capabilities.
42
- *
43
- * @since 1.0
44
- * @var string
45
- * @access protected
46
- */
47
- protected $vfb_db_version = '2.9';
48
-
49
- /**
50
- * Flag used to add scripts to front-end only once
51
- *
52
- * @since 1.0
53
- * @var string
54
- * @access protected
55
- */
56
- protected $add_scripts = false;
57
-
58
- /**
59
- * An array of countries to be used throughout plugin
60
- *
61
- * @since 1.0
62
- * @var array
63
- * @access public
64
- */
65
- 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", "Colombia", "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", "Montenegro", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palestinian Territory", "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", "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", "Western Sahara", "Western Samoa", "Yemen", "Zambia", "Zimbabwe" );
66
-
67
- /**
68
- * Admin page menu hooks
69
- *
70
- * @since 2.7.2
71
- * @var array
72
- * @access private
73
- */
74
- private $_admin_pages = array();
75
-
76
- /**
77
- * Flag used to display post_max_vars error when saving
78
- *
79
- * @since 2.7.6
80
- * @var string
81
- * @access protected
82
- */
83
- protected $post_max_vars = false;
84
-
85
- /**
86
- * field_table_name
87
- *
88
- * @var mixed
89
- * @access public
90
- */
91
- public $field_table_name;
92
-
93
- /**
94
- * form_table_name
95
- *
96
- * @var mixed
97
- * @access public
98
- */
99
- public $form_table_name;
100
-
101
- /**
102
- * entries_table_name
103
- *
104
- * @var mixed
105
- * @access public
106
- */
107
- public $entries_table_name;
108
-
109
- /**
110
- * load_dev_files
111
- *
112
- * @var mixed
113
- * @access public
114
- */
115
- public $load_dev_files;
116
-
117
- /**
118
- * Constructor. Register core filters and actions.
119
- *
120
- * @access public
121
- */
122
- public function __construct(){
123
- global $wpdb;
124
-
125
- // Setup global database table names
126
- $this->field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
127
- $this->form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
128
- $this->entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
129
-
130
- // Add suffix to load dev files
131
- $this->load_dev_files = ( defined( 'VFB_SCRIPT_DEBUG' ) && VFB_SCRIPT_DEBUG ) ? '' : '.min';
132
-
133
- // Saving functions
134
- add_action( 'admin_init', array( &$this, 'save_add_new_form' ) );
135
- add_action( 'admin_init', array( &$this, 'save_update_form' ) );
136
- add_action( 'admin_init', array( &$this, 'save_trash_delete_form' ) );
137
- add_action( 'admin_init', array( &$this, 'save_copy_form' ) );
138
- add_action( 'admin_init', array( &$this, 'save_settings' ) );
139
-
140
- // Build options and settings pages.
141
- add_action( 'admin_menu', array( &$this, 'add_admin' ) );
142
- add_action( 'admin_menu', array( &$this, 'additional_plugin_setup' ) );
143
-
144
- // Register AJAX functions
145
- $actions = array(
146
- // Form Builder
147
- 'sort_field',
148
- 'create_field',
149
- 'delete_field',
150
- 'form_settings',
151
-
152
- // Media button
153
- 'media_button',
154
- );
155
-
156
- // Add all AJAX functions
157
- foreach( $actions as $name ) {
158
- add_action( "wp_ajax_visual_form_builder_$name", array( &$this, "ajax_$name" ) );
159
- }
160
-
161
- // Adds additional media button to insert form shortcode
162
- add_action( 'media_buttons', array( &$this, 'add_media_button' ), 999 );
163
-
164
- // Adds a Dashboard widget
165
- add_action( 'wp_dashboard_setup', array( &$this, 'add_dashboard_widget' ) );
166
-
167
- // Adds a Settings link to the Plugins page
168
- add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
169
-
170
- // Check the db version and run SQL install, if needed
171
- add_action( 'plugins_loaded', array( &$this, 'update_db_check' ) );
172
-
173
- // Display update messages
174
- add_action( 'admin_notices', array( &$this, 'admin_notices' ) );
175
-
176
- // Load i18n
177
- add_action( 'plugins_loaded', array( &$this, 'languages' ) );
178
-
179
- // Print meta keyword
180
- add_action( 'wp_head', array( &$this, 'add_meta_keyword' ) );
181
-
182
- add_shortcode( 'vfb', array( &$this, 'form_code' ) );
183
- add_action( 'init', array( &$this, 'email' ), 10 );
184
- add_action( 'init', array( &$this, 'confirmation' ), 12 );
185
-
186
- // Add CSS to the front-end
187
- add_action( 'wp_enqueue_scripts', array( &$this, 'css' ) );
188
- }
189
-
190
- /**
191
- * Allow for additional plugin code to be run during admin_init
192
- * which is not available during the plugin __construct()
193
- *
194
- * @since 2.7
195
- */
196
- public function additional_plugin_setup() {
197
-
198
- $page_main = $this->_admin_pages[ 'vfb' ];
199
-
200
- if ( !get_option( 'vfb_dashboard_widget_options' ) ) {
201
- $widget_options['vfb_dashboard_recent_entries'] = array(
202
- 'items' => 5,
203
- );
204
- update_option( 'vfb_dashboard_widget_options', $widget_options );
205
- }
206
- }
207
-
208
- /**
209
- * Output plugin version number to help with troubleshooting
210
- *
211
- * @since 2.7.5
212
- */
213
- public function add_meta_keyword() {
214
- // Get global settings
215
- $vfb_settings = get_option( 'vfb-settings' );
216
-
217
- // Settings - Disable meta tag version
218
- $settings_meta = isset( $vfb_settings['show-version'] ) ? '' : '<!-- <meta name="vfb" version="'. VFB_VERSION . '" /> -->' . "\n";
219
-
220
- echo apply_filters( 'vfb_show_version', $settings_meta );
221
- }
222
-
223
- /**
224
- * Load localization file
225
- *
226
- * @since 2.7
227
- */
228
- public function languages() {
229
- $domain = 'visual-form-builder';
230
-
231
- // The "plugin_locale" filter is also used in load_plugin_textdomain()
232
- $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
233
-
234
- $wp_lang_dir = WP_LANG_DIR . '/' . $domain . '/' . $locale . '.mo';
235
-
236
- // Load translated strings from WP_LANG_DIR
237
- load_textdomain( $domain, $wp_lang_dir );
238
-
239
- // Lang folder path
240
- $lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
241
-
242
- // Load translated strings, if no WP_LANG_DIR found
243
- load_plugin_textdomain( $domain, false, $lang_dir );
244
- }
245
-
246
- /**
247
- * Adds extra include files
248
- *
249
- * @since 1.2
250
- */
251
- public function includes(){
252
- global $entries_list, $entries_detail;
253
-
254
- // Load the Entries List class
255
- require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/class-entries-list.php' );
256
- $entries_list = new VisualFormBuilder_Entries_List();
257
-
258
- // Load the Entries Details class
259
- require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/class-entries-detail.php' );
260
- $entries_detail = new VisualFormBuilder_Entries_Detail();
261
- }
262
-
263
-
264
- /**
265
- * include_forms_list function.
266
- *
267
- * @access public
268
- * @return void
269
- */
270
- public function include_forms_list() {
271
- global $forms_list;
272
-
273
- // Load the Forms List class
274
- require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/class-forms-list.php' );
275
- $forms_list = new VisualFormBuilder_Forms_List();
276
- }
277
-
278
- /**
279
- * Add Settings link to Plugins page
280
- *
281
- * @since 1.8
282
- * @return $links array Links to add to plugin name
283
- */
284
- public function plugin_action_links( $links, $file ) {
285
- if ( $file == plugin_basename( __FILE__ ) )
286
- $links[] = '<a href="admin.php?page=visual-form-builder">' . __( 'Settings' , 'visual-form-builder') . '</a>';
287
-
288
- return $links;
289
- }
290
-
291
- /**
292
- * Adds the media button image
293
- *
294
- * @since 2.3
295
- */
296
- public function add_media_button(){
297
- if ( current_user_can( 'manage_options' ) ) :
298
- ?>
299
- <a href="<?php echo add_query_arg( array( 'action' => 'visual_form_builder_media_button', 'width' => '450' ), admin_url( 'admin-ajax.php' ) ); ?>" class="button add_media thickbox" title="Add Visual Form Builder form">
300
- <span class="dashicons dashicons-feedback" style="color:#888; display: inline-block; width: 18px; height: 18px; vertical-align: text-top; margin: 0 4px 0 0;"></span>
301
- <?php _e( 'Add Form', 'visual-form-builder' ); ?>
302
- </a>
303
- <?php
304
- endif;
305
- }
306
-
307
- /**
308
- * Adds the dashboard widget
309
- *
310
- * @since 2.7
311
- */
312
- public function add_dashboard_widget() {
313
- wp_add_dashboard_widget( 'vfb-dashboard', __( 'Recent Visual Form Builder Entries', 'visual-form-builder' ), array( &$this, 'dashboard_widget' ), array( &$this, 'dashboard_widget_control' ) );
314
- }
315
-
316
- /**
317
- * Displays the dashboard widget content
318
- *
319
- * @since 2.7
320
- */
321
- public function dashboard_widget() {
322
- global $wpdb;
323
-
324
- // Get the date/time format that is saved in the options table
325
- $date_format = get_option( 'date_format' );
326
- $time_format = get_option( 'time_format' );
327
-
328
- $widgets = get_option( 'vfb_dashboard_widget_options' );
329
- $total_items = isset( $widgets['vfb_dashboard_recent_entries'] ) && isset( $widgets['vfb_dashboard_recent_entries']['items'] ) ? absint( $widgets['vfb_dashboard_recent_entries']['items'] ) : 5;
330
-
331
- $forms = $wpdb->get_var( "SELECT COUNT(*) FROM {$this->form_table_name}" );
332
-
333
- if ( !$forms ) {
334
- echo sprintf(
335
- '<p>%1$s <a href="%2$s">%3$s</a></p>',
336
- __( 'You currently do not have any forms.', 'visual-form-builder' ),
337
- esc_url( admin_url( 'admin.php?page=vfb-add-new' ) ),
338
- __( 'Get started!', 'visual-form-builder' )
339
- );
340
-
341
- return;
342
- }
343
-
344
- $entries = $wpdb->get_results( $wpdb->prepare( "SELECT forms.form_title, entries.entries_id, entries.form_id, entries.sender_name, entries.sender_email, entries.date_submitted FROM $this->form_table_name AS forms INNER JOIN $this->entries_table_name AS entries ON entries.form_id = forms.form_id ORDER BY entries.date_submitted DESC LIMIT %d", $total_items ) );
345
-
346
- if ( !$entries ) {
347
- echo sprintf( '<p>%1$s</p>', __( 'You currently do not have any entries.', 'visual-form-builder' ) );
348
- }
349
- else {
350
-
351
- $content = '';
352
-
353
- foreach ( $entries as $entry ) {
354
- $content .= sprintf(
355
- '<li><a href="%1$s">%4$s</a> via <a href="%2$s">%5$s</a> <span class="rss-date">%6$s</span><cite>%3$s</cite></li>',
356
- esc_url( add_query_arg( array( 'action' => 'view', 'entry' => absint( $entry->entries_id ) ), admin_url( 'admin.php?page=vfb-entries' ) ) ),
357
- esc_url( add_query_arg( 'form-filter', absint( $entry->form_id ), admin_url( 'admin.php?page=vfb-entries' ) ) ),
358
- esc_html( $entry->sender_name ),
359
- esc_html( $entry->sender_email ),
360
- esc_html( $entry->form_title ),
361
- date( "$date_format $time_format", strtotime( $entry->date_submitted ) )
362
- );
363
- }
364
-
365
- echo "<div class='rss-widget'><ul>$content</ul></div>";
366
- }
367
- }
368
-
369
- /**
370
- * Displays the dashboard widget form control
371
- *
372
- * @since 2.7
373
- */
374
- public function dashboard_widget_control() {
375
- if ( !$widget_options = get_option( 'vfb_dashboard_widget_options' ) )
376
- $widget_options = array();
377
-
378
- if ( !isset( $widget_options['vfb_dashboard_recent_entries'] ) )
379
- $widget_options['vfb_dashboard_recent_entries'] = array();
380
-
381
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['vfb-widget-recent-entries'] ) ) {
382
- $number = absint( $_POST['vfb-widget-recent-entries']['items'] );
383
- $widget_options['vfb_dashboard_recent_entries']['items'] = $number;
384
- update_option( 'vfb_dashboard_widget_options', $widget_options );
385
- }
386
-
387
- $number = isset( $widget_options['vfb_dashboard_recent_entries']['items'] ) ? (int) $widget_options['vfb_dashboard_recent_entries']['items'] : '';
388
-
389
- echo sprintf(
390
- '<p>
391
- <label for="comments-number">%1$s</label>
392
- <input id="comments-number" name="vfb-widget-recent-entries[items]" type="text" value="%2$d" size="3" />
393
- </p>',
394
- __( 'Number of entries to show:', 'visual-form-builder' ),
395
- $number
396
- );
397
- }
398
-
399
- /**
400
- * Register contextual help. This is for the Help tab dropdown
401
- *
402
- * @since 1.0
403
- */
404
- public function help() {
405
- $screen = get_current_screen();
406
-
407
- $screen->add_help_tab( array(
408
- 'id' => 'vfb-help-tab-getting-started',
409
- 'title' => 'Getting Started',
410
- 'content' => '<ul>
411
- <li>Click on the + tab, give your form a name and click Create Form.</li>
412
- <li>Select form fields from the box on the left and click a field to add it to your form.</li>
413
- <li>Edit the information for each form field by clicking on the down arrow.</li>
414
- <li>Drag and drop the elements to put them in order.</li>
415
- <li>Click Save Form to save your changes.</li>
416
- </ul>'
417
- ) );
418
-
419
- $screen->add_help_tab( array(
420
- 'id' => 'vfb-help-tab-item-config',
421
- 'title' => 'Form Item Configuration',
422
- 'content' => "<ul>
423
- <li><em>Name</em> will change the display name of your form input.</li>
424
- <li><em>Description</em> will be displayed below the associated input.</li>
425
- <li><em>Validation</em> allows you to select from several of jQuery's Form Validation methods for text inputs. For more about the types of validation, read the <em>Validation</em> section below.</li>
426
- <li><em>Required</em> is either Yes or No. Selecting 'Yes' will make the associated input a required field and the form will not submit until the user fills this field out correctly.</li>
427
- <li><em>Options</em> will only be active for Radio and Checkboxes. This field contols how many options are available for the associated input.</li>
428
- <li><em>Size</em> controls the width of Text, Textarea, Select, and Date Picker input fields. The default is set to Medium but if you need a longer text input, select Large.</li>
429
- <li><em>CSS Classes</em> allow you to add custom CSS to a field. This option allows you to fine tune the look of the form.</li>
430
- </ul>"
431
- ) );
432
-
433
- $screen->add_help_tab( array(
434
- 'id' => 'vfb-help-tab-validation',
435
- 'title' => 'Validation',
436
- 'content' => "<p>Visual Form Builder uses the <a href='http://docs.jquery.com/Plugins/Validation/Validator'>jQuery Form Validation plugin</a> to perform clientside form validation.</p>
437
- <ul>
438
-
439
- <li><em>Email</em>: makes the element require a valid email.</li>
440
- <li><em>URL</em>: makes the element require a valid url.</li>
441
- <li><em>Date</em>: makes the element require a date. <a href='http://docs.jquery.com/Plugins/Validation/Methods/date'>Refer to documentation for various accepted formats</a>.
442
- <li><em>Number</em>: makes the element require a decimal number.</li>
443
- <li><em>Digits</em>: makes the element require digits only.</li>
444
- <li><em>Phone</em>: makes the element require a US or International phone number. Most formats are accepted.</li>
445
- <li><em>Time</em>: choose either 12- or 24-hour time format (NOTE: only available with the Time field).</li>
446
- </ul>"
447
- ) );
448
-
449
- $screen->add_help_tab( array(
450
- 'id' => 'vfb-help-tab-confirmation',
451
- 'title' => 'Confirmation',
452
- 'content' => "<p>Each form allows you to customize the confirmation by selecing either a Text Message, a WordPress Page, or to Redirect to a URL.</p>
453
- <ul>
454
- <li><em>Text</em> allows you to enter a custom formatted message that will be displayed on the page after your form is submitted. HTML is allowed here.</li>
455
- <li><em>Page</em> displays a dropdown of all WordPress Pages you have created. Select one to redirect the user to that page after your form is submitted.</li>
456
- <li><em>Redirect</em> will only accept URLs and can be used to send the user to a different site completely, if you choose.</li>
457
- </ul>"
458
- ) );
459
-
460
- $screen->add_help_tab( array(
461
- 'id' => 'vfb-help-tab-notification',
462
- 'title' => 'Notification',
463
- 'content' => "<p>Send a customized notification email to the user when the form has been successfully submitted.</p>
464
- <ul>
465
- <li><em>Sender Name</em>: the name that will be displayed on the email.</li>
466
- <li><em>Sender Email</em>: the email that will be used as the Reply To email.</li>
467
- <li><em>Send To</em>: the email where the notification will be sent. This must be a required text field with email validation.</li>
468
- <li><em>Subject</em>: the subject of the email.</li>
469
- <li><em>Message</em>: additional text that can be displayed in the body of the email. HTML tags are allowed.</li>
470
- <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>
471
- </ul>"
472
- ) );
473
-
474
- $screen->add_help_tab( array(
475
- 'id' => 'vfb-help-tab-tips',
476
- 'title' => 'Tips',
477
- 'content' => "<ul>
478
- <li>Fieldsets, a way to group form fields, are an essential piece of this plugin's HTML. As such, at least one fieldset is required and must be first in the order. Subsequent fieldsets may be placed wherever you would like to start your next grouping of fields.</li>
479
- <li>Security verification is automatically included on very form. It's a simple logic question and should keep out most, if not all, spam bots.</li>
480
- <li>There is a hidden spam field, known as a honey pot, that should also help deter potential abusers of your form.</li>
481
- <li>Nesting is allowed underneath fieldsets and sections. Sections can be nested underneath fieldsets. Nesting is not required, however, it does make reorganizing easier.</li>
482
- </ul>"
483
- ) );
484
- }
485
-
486
- /**
487
- * Adds the Screen Options tab to the Entries screen
488
- *
489
- * @since 1.0
490
- */
491
- public function screen_options() {
492
- $screen = get_current_screen();
493
-
494
- $page_main = $this->_admin_pages[ 'vfb' ];
495
- $page_entries = $this->_admin_pages[ 'vfb-entries' ];
496
-
497
- switch( $screen->id ) {
498
- case $page_entries :
499
-
500
- add_screen_option( 'per_page', array(
501
- 'label' => __( 'Entries per page', 'visual-form-builder' ),
502
- 'default' => 20,
503
- 'option' => 'vfb_entries_per_page'
504
- ) );
505
-
506
- break;
507
-
508
- case $page_main :
509
-
510
- if ( isset( $_GET['form'] ) ) :
511
- add_screen_option( 'layout_columns', array(
512
- 'max' => 2,
513
- 'default' => 2
514
- ) );
515
- else :
516
- add_screen_option( 'per_page', array(
517
- 'label' => __( 'Forms per page', 'visual-form-builder' ),
518
- 'default' => 20,
519
- 'option' => 'vfb_forms_per_page'
520
- ) );
521
- endif;
522
-
523
- break;
524
- }
525
- }
526
-
527
- /**
528
- * Saves the Screen Options
529
- *
530
- * @since 1.0
531
- */
532
- public function save_screen_options( $status, $option, $value ) {
533
-
534
- if ( $option == 'vfb_entries_per_page' )
535
- return $value;
536
- elseif ( $option == 'vfb_forms_per_page' )
537
- return $value;
538
- }
539
-
540
- /**
541
- * Add meta boxes to form builder screen
542
- *
543
- * @since 1.8
544
- */
545
- public function add_meta_boxes() {
546
- global $current_screen;
547
-
548
- $page_main = $this->_admin_pages[ 'vfb' ];
549
-
550
- if ( $current_screen->id == $page_main && isset( $_GET['form'] ) ) {
551
- add_meta_box( 'vfb_form_items_meta_box', __( 'Form Items', 'visual-form-builder' ), array( &$this, 'meta_box_form_items' ), $page_main, 'side', 'high' );
552
- add_meta_box( 'vfb_form_media_button_tip', __( 'Display Forms', 'visual-form-builder' ), array( &$this, 'meta_box_display_forms' ), $page_main, 'side', 'low' );
553
- }
554
- }
555
- /**
556
- * Output for Form Items meta box
557
- *
558
- * @since 1.8
559
- */
560
- public function meta_box_form_items() {
561
- ?>
562
- <div class="taxonomydiv">
563
- <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>
564
- <ul class="posttype-tabs add-menu-item-tabs" id="vfb-field-tabs">
565
- <li class="tabs"><a href="#standard-fields" class="nav-tab-link vfb-field-types"><?php _e( 'Standard' , 'visual-form-builder'); ?></a></li>
566
- </ul>
567
- <div id="standard-fields" class="tabs-panel tabs-panel-active">
568
- <ul class="vfb-fields-col-1">
569
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-fieldset">Fieldset</a></li>
570
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-text"><b></b>Text</a></li>
571
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-checkbox"><b></b>Checkbox</a></li>
572
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-select"><b></b>Select</a></li>
573
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-datepicker"><b></b>Date</a></li>
574
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-url"><b></b>URL</a></li>
575
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-digits"><b></b>Number</a></li>
576
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-phone"><b></b>Phone</a></li>
577
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-file"><b></b>File Upload</a></li>
578
- </ul>
579
- <ul class="vfb-fields-col-2">
580
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-section">Section</a></li>
581
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-textarea"><b></b>Textarea</a></li>
582
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-radio"><b></b>Radio</a></li>
583
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-address"><b></b>Address</a></li>
584
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-email"><b></b>Email</a></li>
585
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-currency"><b></b>Currency</a></li>
586
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-time"><b></b>Time</a></li>
587
-
588
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-html"><b></b>HTML</a></li>
589
-
590
- <li><a href="#" class="vfb-draggable-form-items" id="form-element-instructions"><b></b>Instructions</a></li>
591
- </ul>
592
- <div class="clear"></div>
593
- </div> <!-- #standard-fields -->
594
- </div> <!-- .taxonomydiv -->
595
- <div class="clear"></div>
596
- <?php
597
- }
598
-
599
- /**
600
- * Output for the Display Forms meta box
601
- *
602
- * @since 1.8
603
- */
604
- public function meta_box_display_forms() {
605
- ?>
606
- <p><?php _e( 'Add forms to your Posts or Pages by locating the <strong>Add Form</strong> button in the area above your post/page editor.', 'visual-form-builder' ); ?></p>
607
- <p><?php _e( 'You may also manually insert the shortcode into a post/page.', 'visual-form-builder' ); ?></p>
608
- <p>
609
- <?php _e( 'Shortcode', 'visual-form-builder' ); ?>
610
- <input value="[vfb id='<?php echo (int) $_GET['form']; ?>']" readonly="readonly" />
611
- </p>
612
- <?php
613
- }
614
-
615
- /**
616
- * Check database version and run SQL install, if needed
617
- *
618
- * @since 2.1
619
- */
620
- public function update_db_check() {
621
- // Add a database version to help with upgrades and run SQL install
622
- if ( !get_option( 'vfb_db_version' ) ) {
623
- update_option( 'vfb_db_version', $this->vfb_db_version );
624
- $this->install_db();
625
- }
626
-
627
- // If database version doesn't match, update and run SQL install
628
- if ( version_compare( get_option( 'vfb_db_version' ), $this->vfb_db_version, '<' ) ) {
629
- update_option( 'vfb_db_version', $this->vfb_db_version );
630
- $this->install_db();
631
- }
632
- }
633
-
634
- /**
635
- * Install database tables
636
- *
637
- * @since 1.0
638
- */
639
- static function install_db() {
640
- global $wpdb;
641
-
642
- $field_table_name = $wpdb->prefix . 'visual_form_builder_fields';
643
- $form_table_name = $wpdb->prefix . 'visual_form_builder_forms';
644
- $entries_table_name = $wpdb->prefix . 'visual_form_builder_entries';
645
-
646
- // Explicitly set the character set and collation when creating the tables
647
- $charset = ( defined( 'DB_CHARSET' && '' !== DB_CHARSET ) ) ? DB_CHARSET : 'utf8';
648
- $collate = ( defined( 'DB_COLLATE' && '' !== DB_COLLATE ) ) ? DB_COLLATE : 'utf8_general_ci';
649
-
650
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
651
-
652
- $field_sql = "CREATE TABLE $field_table_name (
653
- field_id BIGINT(20) NOT NULL AUTO_INCREMENT,
654
- form_id BIGINT(20) NOT NULL,
655
- field_key VARCHAR(255) NOT NULL,
656
- field_type VARCHAR(25) NOT NULL,
657
- field_options TEXT,
658
- field_description TEXT,
659
- field_name TEXT NOT NULL,
660
- field_sequence BIGINT(20) DEFAULT '0',
661
- field_parent BIGINT(20) DEFAULT '0',
662
- field_validation VARCHAR(25),
663
- field_required VARCHAR(25),
664
- field_size VARCHAR(25) DEFAULT 'medium',
665
- field_css VARCHAR(255),
666
- field_layout VARCHAR(255),
667
- field_default TEXT,
668
- PRIMARY KEY (field_id)
669
- ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
670
-
671
- $form_sql = "CREATE TABLE $form_table_name (
672
- form_id BIGINT(20) NOT NULL AUTO_INCREMENT,
673
- form_key TINYTEXT NOT NULL,
674
- form_title TEXT NOT NULL,
675
- form_email_subject TEXT,
676
- form_email_to TEXT,
677
- form_email_from VARCHAR(255),
678
- form_email_from_name VARCHAR(255),
679
- form_email_from_override VARCHAR(255),
680
- form_email_from_name_override VARCHAR(255),
681
- form_success_type VARCHAR(25) DEFAULT 'text',
682
- form_success_message TEXT,
683
- form_notification_setting VARCHAR(25),
684
- form_notification_email_name VARCHAR(255),
685
- form_notification_email_from VARCHAR(255),
686
- form_notification_email VARCHAR(25),
687
- form_notification_subject VARCHAR(255),
688
- form_notification_message TEXT,
689
- form_notification_entry VARCHAR(25),
690
- form_label_alignment VARCHAR(25),
691
- PRIMARY KEY (form_id)
692
- ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
693
-
694
- $entries_sql = "CREATE TABLE $entries_table_name (
695
- entries_id BIGINT(20) NOT NULL AUTO_INCREMENT,
696
- form_id BIGINT(20) NOT NULL,
697
- data LONGTEXT NOT NULL,
698
- subject TEXT,
699
- sender_name VARCHAR(255),
700
- sender_email VARCHAR(255),
701
- emails_to TEXT,
702
- date_submitted DATETIME,
703
- ip_address VARCHAR(50),
704
- entry_approved VARCHAR(20) DEFAULT '1',
705
- PRIMARY KEY (entries_id)
706
- ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
707
-
708
- // Create or Update database tables
709
- dbDelta( $field_sql );
710
- dbDelta( $form_sql );
711
- dbDelta( $entries_sql );
712
- }
713
-
714
- /**
715
- * Queue plugin scripts for sorting form fields
716
- *
717
- * @since 1.0
718
- */
719
- public function admin_scripts() {
720
- wp_enqueue_script( 'jquery-ui-sortable' );
721
- wp_enqueue_script( 'postbox' );
722
- wp_enqueue_script( 'jquery-form-validation', plugins_url( '/js/jquery.validate.min.js', __FILE__ ), array( 'jquery' ), '1.9.0', true );
723
- wp_enqueue_script( 'vfb-admin', plugins_url( "/js/vfb-admin$this->load_dev_files.js", __FILE__ ) , array( 'jquery', 'jquery-form-validation' ), '20140412', true );
724
- wp_enqueue_script( 'nested-sortable', plugins_url( "/js/jquery.ui.nestedSortable$this->load_dev_files.js", __FILE__ ) , array( 'jquery', 'jquery-ui-sortable' ), '1.3.5', true );
725
-
726
- wp_enqueue_style( 'visual-form-builder-style', plugins_url( "/css/visual-form-builder-admin$this->load_dev_files.css", __FILE__ ), array(), '20140412' );
727
-
728
- wp_localize_script( 'vfb-admin', 'VfbAdminPages', array( 'vfb_pages' => $this->_admin_pages ) );
729
- }
730
-
731
- /**
732
- * Queue form validation scripts
733
- *
734
- * Scripts loaded in form-output.php, when field is present:
735
- * jQuery UI date picker
736
- * CKEditor
737
- *
738
- * @since 1.0
739
- */
740
- public function scripts() {
741
- // Make sure scripts are only added once via shortcode
742
- $this->add_scripts = true;
743
-
744
- wp_register_script( 'jquery-form-validation', plugins_url( '/js/jquery.validate.min.js', __FILE__ ), array( 'jquery' ), '1.9.0', true );
745
- wp_register_script( 'visual-form-builder-validation', plugins_url( "/js/vfb-validation$this->load_dev_files.js", __FILE__ ) , array( 'jquery', 'jquery-form-validation' ), '20140412', true );
746
- wp_register_script( 'visual-form-builder-metadata', plugins_url( '/js/jquery.metadata.js', __FILE__ ) , array( 'jquery', 'jquery-form-validation' ), '2.0', true );
747
- wp_register_script( 'vfb-ckeditor', plugins_url( '/js/ckeditor/ckeditor.js', __FILE__ ), array( 'jquery' ), '4.1', true );
748
-
749
- wp_enqueue_script( 'jquery-form-validation' );
750
- wp_enqueue_script( 'visual-form-builder-validation' );
751
- wp_enqueue_script( 'visual-form-builder-metadata' );
752
-
753
- $locale = get_locale();
754
- $translations = array(
755
- 'cs_CS', // Czech
756
- 'de_DE', // German
757
- 'el_GR', // Greek
758
- 'en_US', // English (US)
759
- 'en_AU', // English (AU)
760
- 'en_GB', // English (GB)
761
- 'es_ES', // Spanish
762
- 'fr_FR', // French
763
- 'he_IL', // Hebrew
764
- 'hu_HU', // Hungarian
765
- 'id_ID', // Indonseian
766
- 'it_IT', // Italian
767
- 'ja_JP', // Japanese
768
- 'ko_KR', // Korean
769
- 'nl_NL', // Dutch
770
- 'pl_PL', // Polish
771
- 'pt_BR', // Portuguese (Brazilian)
772
- 'pt_PT', // Portuguese (European)
773
- 'ro_RO', // Romanian
774
- 'ru_RU', // Russian
775
- 'sv_SE', // Swedish
776
- 'tr_TR', // Turkish
777
- 'zh_CN', // Chinese
778
- 'zh_TW', // Chinese (Taiwan)
779
- );
780
-
781
- // Load localized vaidation and datepicker text, if translation files exist
782
- if ( in_array( $locale, $translations ) ) {
783
- wp_register_script( 'vfb-validation-i18n', plugins_url( "/js/i18n/validate/messages-$locale.js", __FILE__ ), array( 'jquery-form-validation' ), '1.9.0', true );
784
- wp_register_script( 'vfb-datepicker-i18n', plugins_url( "/js/i18n/datepicker/datepicker-$locale.js", __FILE__ ), array( 'jquery-ui-datepicker' ), '1.0', true );
785
-
786
- wp_enqueue_script( 'vfb-validation-i18n' );
787
- }
788
- // Otherwise, load English translations
789
- else {
790
- wp_register_script( 'vfb-validation-i18n', plugins_url( "/js/i18n/validate/messages-en_US.js", __FILE__ ), array( 'jquery-form-validation' ), '1.9.0', true );
791
- wp_register_script( 'vfb-datepicker-i18n', plugins_url( "/js/i18n/datepicker/datepicker-en_US.js", __FILE__ ), array( 'jquery-ui-datepicker' ), '1.0', true );
792
-
793
- wp_enqueue_script( 'vfb-validation-i18n' );
794
- }
795
- }
796
-
797
- /**
798
- * Add form CSS to wp_head
799
- *
800
- * @since 1.0
801
- */
802
- public function css() {
803
-
804
- $vfb_settings = get_option( 'vfb-settings' );
805
-
806
- wp_register_style( 'vfb-jqueryui-css', apply_filters( 'vfb-date-picker-css', plugins_url( '/css/smoothness/jquery-ui-1.10.3.min.css', __FILE__ ) ), array(), '20131203' );
807
- wp_register_style( 'visual-form-builder-css', apply_filters( 'visual-form-builder-css', plugins_url( "/css/visual-form-builder$this->load_dev_files.css", __FILE__ ) ), array(), '20140412' );
808
-
809
- // Settings - Always load CSS
810
- if ( isset( $vfb_settings['always-load-css'] ) ) {
811
- wp_enqueue_style( 'visual-form-builder-css' );
812
- wp_enqueue_style( 'vfb-jqueryui-css' );
813
-
814
- return;
815
- }
816
-
817
- // Settings - Disable CSS
818
- if ( isset( $vfb_settings['disable-css'] ) )
819
- return;
820
-
821
- // Get active widgets
822
- $widget = is_active_widget( false, false, 'vfb_widget' );
823
-
824
- // If no widget is found, test for shortcode
825
- if ( empty( $widget ) ) {
826
- // If WordPress 3.6, use internal function. Otherwise, my own
827
- if ( function_exists( 'has_shortcode' ) ) {
828
- global $post;
829
-
830
- // If no post exists, exit
831
- if ( !$post )
832
- return;
833
-
834
- if ( !has_shortcode( $post->post_content, 'vfb' ) )
835
- return;
836
- } elseif ( !$this->has_shortcode( 'vfb' ) ) {
837
- return;
838
- }
839
- }
840
-
841
- wp_enqueue_style( 'visual-form-builder-css' );
842
- wp_enqueue_style( 'vfb-jqueryui-css' );
843
- }
844
-
845
- /**
846
- * Save new forms on the VFB Pro > Add New page
847
- *
848
- * @access public
849
- * @since 2.8.1
850
- * @return void
851
- */
852
- public function save_add_new_form() {
853
- global $wpdb;
854
-
855
- if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
856
- return;
857
-
858
- if ( 'vfb-add-new' !== $_GET['page'] )
859
- return;
860
-
861
- if ( 'create_form' !== $_POST['action'] )
862
- return;
863
-
864
- if ( !current_user_can( 'manage_options' ) )
865
- wp_die( __( 'You do not have sufficient permissions to create a new form.', 'visual-form-builder' ) );
866
-
867
- check_admin_referer( 'create_form' );
868
-
869
- $form_key = sanitize_title( $_POST['form_title'] );
870
- $form_title = esc_html( $_POST['form_title'] );
871
- $form_from_name = esc_html( $_POST['form_email_from_name'] );
872
- $form_subject = esc_html( $_POST['form_email_subject'] );
873
- $form_from = esc_html( $_POST['form_email_from'] );
874
- $form_to = serialize( $_POST['form_email_to'] );
875
-
876
- $newdata = array(
877
- 'form_key' => $form_key,
878
- 'form_title' => $form_title,
879
- 'form_email_from_name' => $form_from_name,
880
- 'form_email_subject' => $form_subject,
881
- 'form_email_from' => $form_from,
882
- 'form_email_to' => $form_to,
883
- 'form_success_message' => '<p id="form_success">Your form was successfully submitted. Thank you for contacting us.</p>'
884
- );
885
-
886
- // Create the form
887
- $wpdb->insert( $this->form_table_name, $newdata );
888
-
889
- // Get form ID to add our first field
890
- $new_form_selected = $wpdb->insert_id;
891
-
892
- // Setup the initial fieldset
893
- $initial_fieldset = array(
894
- 'form_id' => $wpdb->insert_id,
895
- 'field_key' => 'fieldset',
896
- 'field_type' => 'fieldset',
897
- 'field_name' => 'Fieldset',
898
- 'field_sequence' => 0
899
- );
900
-
901
- // Add the first fieldset to get things started
902
- $wpdb->insert( $this->field_table_name, $initial_fieldset );
903
-
904
- $verification_fieldset = array(
905
- 'form_id' => $new_form_selected,
906
- 'field_key' => 'verification',
907
- 'field_type' => 'verification',
908
- 'field_name' => 'Verification',
909
- 'field_description' => '(This is for preventing spam)',
910
- 'field_sequence' => 1
911
- );
912
-
913
- // Insert the submit field
914
- $wpdb->insert( $this->field_table_name, $verification_fieldset );
915
-
916
- $verify_fieldset_parent_id = $wpdb->insert_id;
917
-
918
- $secret = array(
919
- 'form_id' => $new_form_selected,
920
- 'field_key' => 'secret',
921
- 'field_type' => 'secret',
922
- 'field_name' => 'Please enter any two digits',
923
- 'field_description' => 'Example: 12',
924
- 'field_size' => 'medium',
925
- 'field_required' => 'yes',
926
- 'field_parent' => $verify_fieldset_parent_id,
927
- 'field_sequence' => 2
928
- );
929
-
930
- // Insert the submit field
931
- $wpdb->insert( $this->field_table_name, $secret );
932
-
933
- // Make the submit last in the sequence
934
- $submit = array(
935
- 'form_id' => $new_form_selected,
936
- 'field_key' => 'submit',
937
- 'field_type' => 'submit',
938
- 'field_name' => 'Submit',
939
- 'field_parent' => $verify_fieldset_parent_id,
940
- 'field_sequence' => 3
941
- );
942
-
943
- // Insert the submit field
944
- $wpdb->insert( $this->field_table_name, $submit );
945
-
946
- // Redirect to keep the URL clean (use AJAX in the future?)
947
- wp_redirect( 'admin.php?page=visual-form-builder&action=edit&form=' . $new_form_selected );
948
- exit();
949
- }
950
-
951
- /**
952
- * Save the form
953
- *
954
- * @access public
955
- * @since 2.8.1
956
- * @return void
957
- */
958
- public function save_update_form() {
959
- global $wpdb;
960
-
961
- if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
962
- return;
963
-
964
- if ( 'visual-form-builder' !== $_GET['page'] )
965
- return;
966
-
967
- if ( 'update_form' !== $_POST['action'] )
968
- return;
969
-
970
- check_admin_referer( 'vfb_update_form' );
971
-
972
- $form_id = absint( $_POST['form_id'] );
973
- $form_key = sanitize_title( $_POST['form_title'], $form_id );
974
- $form_title = $_POST['form_title'];
975
- $form_subject = $_POST['form_email_subject'];
976
- $form_to = serialize( array_map( 'sanitize_email', $_POST['form_email_to'] ) );
977
- $form_from = sanitize_email( $_POST['form_email_from'] );
978
- $form_from_name = $_POST['form_email_from_name'];
979
- $form_from_override = isset( $_POST['form_email_from_override'] ) ? $_POST['form_email_from_override'] : '';
980
- $form_from_name_override = isset( $_POST['form_email_from_name_override'] ) ? $_POST['form_email_from_name_override'] : '';
981
- $form_success_type = $_POST['form_success_type'];
982
- $form_notification_setting = isset( $_POST['form_notification_setting'] ) ? $_POST['form_notification_setting'] : '';
983
- $form_notification_email_name = isset( $_POST['form_notification_email_name'] ) ? $_POST['form_notification_email_name'] : '';
984
- $form_notification_email_from = isset( $_POST['form_notification_email_from'] ) ? sanitize_email( $_POST['form_notification_email_from'] ) : '';
985
- $form_notification_email = isset( $_POST['form_notification_email'] ) ? $_POST['form_notification_email'] : '';
986
- $form_notification_subject = isset( $_POST['form_notification_subject'] ) ? $_POST['form_notification_subject'] : '';
987
- $form_notification_message = isset( $_POST['form_notification_message'] ) ? format_for_editor( $_POST['form_notification_message'] ) : '';
988
- $form_notification_entry = isset( $_POST['form_notification_entry'] ) ? $_POST['form_notification_entry'] : '';
989
- $form_label_alignment = $_POST['form_label_alignment'];
990
-
991
- // Add confirmation based on which type was selected
992
- switch ( $form_success_type ) {
993
- case 'text' :
994
- $form_success_message = format_for_editor( $_POST['form_success_message_text'] );
995
- break;
996
- case 'page' :
997
- $form_success_message = $_POST['form_success_message_page'];
998
- break;
999
- case 'redirect' :
1000
- $form_success_message = $_POST['form_success_message_redirect'];
1001
- break;
1002
- }
1003
-
1004
- $newdata = array(
1005
- 'form_key' => $form_key,
1006
- 'form_title' => $form_title,
1007
- 'form_email_subject' => $form_subject,
1008
- 'form_email_to' => $form_to,
1009
- 'form_email_from' => $form_from,
1010
- 'form_email_from_name' => $form_from_name,
1011
- 'form_email_from_override' => $form_from_override,
1012
- 'form_email_from_name_override' => $form_from_name_override,
1013
- 'form_success_type' => $form_success_type,
1014
- 'form_success_message' => $form_success_message,
1015
- 'form_notification_setting' => $form_notification_setting,
1016
- 'form_notification_email_name' => $form_notification_email_name,
1017
- 'form_notification_email_from' => $form_notification_email_from,
1018
- 'form_notification_email' => $form_notification_email,
1019
- 'form_notification_subject' => $form_notification_subject,
1020
- 'form_notification_message' => $form_notification_message,
1021
- 'form_notification_entry' => $form_notification_entry,
1022
- 'form_label_alignment' => $form_label_alignment
1023
- );
1024
-
1025
- $where = array( 'form_id' => $form_id );
1026
-
1027
- // Update form details
1028
- $wpdb->update( $this->form_table_name, $newdata, $where );
1029
-
1030
- $field_ids = array();
1031
-
1032
- // Get max post vars, if available. Otherwise set to 1000
1033
- $max_post_vars = ( ini_get( 'max_input_vars' ) ) ? intval( ini_get( 'max_input_vars' ) ) : 1000;
1034
-
1035
- // Set a message to be displayed if we've reached a limit
1036
- if ( count( $_POST, COUNT_RECURSIVE ) > $max_post_vars )
1037
- $this->post_max_vars = true;
1038
-
1039
- foreach ( $_POST['field_id'] as $fields ) :
1040
- $field_ids[] = $fields;
1041
- endforeach;
1042
-
1043
- // Initialize field sequence
1044
- $field_sequence = 0;
1045
-
1046
- // Loop through each field and update
1047
- foreach ( $field_ids as $id ) :
1048
- $id = absint( $id );
1049
-
1050
- $field_name = isset( $_POST['field_name-' . $id] ) ? trim( $_POST['field_name-' . $id] ) : '';
1051
- $field_key = sanitize_key( sanitize_title( $field_name, $id ) );
1052
- $field_desc = isset( $_POST['field_description-' . $id] ) ? trim( $_POST['field_description-' . $id] ) : '';
1053
- $field_options = isset( $_POST['field_options-' . $id] ) ? serialize( array_map( 'trim', $_POST['field_options-' . $id] ) ) : '';
1054
- $field_validation = isset( $_POST['field_validation-' . $id] ) ? $_POST['field_validation-' . $id] : '';
1055
- $field_required = isset( $_POST['field_required-' . $id] ) ? $_POST['field_required-' . $id] : '';
1056
- $field_size = isset( $_POST['field_size-' . $id] ) ? $_POST['field_size-' . $id] : '';
1057
- $field_css = isset( $_POST['field_css-' . $id] ) ? $_POST['field_css-' . $id] : '';
1058
- $field_layout = isset( $_POST['field_layout-' . $id] ) ? $_POST['field_layout-' . $id] : '';
1059
- $field_default = isset( $_POST['field_default-' . $id] ) ? trim( $_POST['field_default-' . $id] ) : '';
1060
-
1061
- $field_data = array(
1062
- 'field_key' => $field_key,
1063
- 'field_name' => $field_name,
1064
- 'field_description' => $field_desc,
1065
- 'field_options' => $field_options,
1066
- 'field_validation' => $field_validation,
1067
- 'field_required' => $field_required,
1068
- 'field_size' => $field_size,
1069
- 'field_css' => $field_css,
1070
- 'field_layout' => $field_layout,
1071
- 'field_sequence' => $field_sequence,
1072
- 'field_default' => $field_default
1073
- );
1074
-
1075
- $where = array(
1076
- 'form_id' => $form_id,
1077
- 'field_id' => $id
1078
- );
1079
-
1080
- // Update all fields
1081
- $wpdb->update( $this->field_table_name, $field_data, $where );
1082
-
1083
- $field_sequence++;
1084
- endforeach;
1085
- }
1086
-
1087
- /**
1088
- * Handle trashing and deleting forms
1089
- *
1090
- * This is a placeholder function since all processing is handled in includes/class-forms-list.php
1091
- *
1092
- * @access public
1093
- * @since 2.8.1
1094
- * @return void
1095
- */
1096
- public function save_trash_delete_form() {
1097
- global $wpdb;
1098
-
1099
- if ( !isset( $_GET['action'] ) || !isset( $_GET['page'] ) )
1100
- return;
1101
-
1102
- if ( 'visual-form-builder' !== $_GET['page'] )
1103
- return;
1104
-
1105
- if ( 'delete_form' !== $_GET['action'] )
1106
- return;
1107
-
1108
- $id = absint( $_GET['form'] );
1109
-
1110
- check_admin_referer( 'delete-form-' . $id );
1111
-
1112
- // Delete form and all fields
1113
- $wpdb->query( $wpdb->prepare( "DELETE FROM $this->form_table_name WHERE form_id = %d", $id ) );
1114
- $wpdb->query( $wpdb->prepare( "DELETE FROM $this->field_table_name WHERE form_id = %d", $id ) );
1115
- $wpdb->query( $wpdb->prepare( "DELETE FROM $this->entries_table_name WHERE form_id = %d", $id ) );
1116
-
1117
- // Redirect to keep the URL clean (use AJAX in the future?)
1118
- wp_redirect( add_query_arg( 'action', 'deleted', 'admin.php?page=visual-form-builder' ) );
1119
- exit();
1120
- }
1121
-
1122
- /**
1123
- * Handle form duplication
1124
- *
1125
- * @access public
1126
- * @since 2.8.1
1127
- * @return void
1128
- */
1129
- public function save_copy_form() {
1130
- global $wpdb;
1131
-
1132
- if ( !isset( $_GET['action'] ) || !isset( $_GET['page'] ) )
1133
- return;
1134
-
1135
- if ( 'visual-form-builder' !== $_GET['page'] )
1136
- return;
1137
-
1138
- if ( 'copy_form' !== $_GET['action'] )
1139
- return;
1140
-
1141
- $id = absint( $_GET['form'] );
1142
-
1143
- check_admin_referer( 'copy-form-' . $id );
1144
-
1145
- // Get all fields and data for the request form
1146
- $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->field_table_name WHERE form_id = %d", $id ) );
1147
- $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d", $id ) );
1148
- $override = $wpdb->get_var( $wpdb->prepare( "SELECT form_email_from_override, form_email_from_name_override, form_notification_email FROM $this->form_table_name WHERE form_id = %d", $id ) );
1149
- $from_name = $wpdb->get_var( null, 1 );
1150
- $notify = $wpdb->get_var( null, 2 );
1151
-
1152
- // Copy this form and force the initial title to denote a copy
1153
- foreach ( $forms as $form ) {
1154
- $data = array(
1155
- 'form_key' => sanitize_title( $form->form_key . ' copy' ),
1156
- 'form_title' => $form->form_title . ' Copy',
1157
- 'form_email_subject' => $form->form_email_subject,
1158
- 'form_email_to' => $form->form_email_to,
1159
- 'form_email_from' => $form->form_email_from,
1160
- 'form_email_from_name' => $form->form_email_from_name,
1161
- 'form_email_from_override' => $form->form_email_from_override,
1162
- 'form_email_from_name_override' => $form->form_email_from_name_override,
1163
- 'form_success_type' => $form->form_success_type,
1164
- 'form_success_message' => $form->form_success_message,
1165
- 'form_notification_setting' => $form->form_notification_setting,
1166
- 'form_notification_email_name' => $form->form_notification_email_name,
1167
- 'form_notification_email_from' => $form->form_notification_email_from,
1168
- 'form_notification_email' => $form->form_notification_email,
1169
- 'form_notification_subject' => $form->form_notification_subject,
1170
- 'form_notification_message' => $form->form_notification_message,
1171
- 'form_notification_entry' => $form->form_notification_entry,
1172
- 'form_label_alignment' => $form->form_label_alignment
1173
- );
1174
-
1175
- $wpdb->insert( $this->form_table_name, $data );
1176
- }
1177
-
1178
- // Get form ID to add our first field
1179
- $new_form_selected = $wpdb->insert_id;
1180
-
1181
- // Copy each field and data
1182
- foreach ( $fields as $field ) {
1183
- $data = array(
1184
- 'form_id' => $new_form_selected,
1185
- 'field_key' => $field->field_key,
1186
- 'field_type' => $field->field_type,
1187
- 'field_name' => $field->field_name,
1188
- 'field_description' => $field->field_description,
1189
- 'field_options' => $field->field_options,
1190
- 'field_sequence' => $field->field_sequence,
1191
- 'field_validation' => $field->field_validation,
1192
- 'field_required' => $field->field_required,
1193
- 'field_size' => $field->field_size,
1194
- 'field_css' => $field->field_css,
1195
- 'field_layout' => $field->field_layout,
1196
- 'field_parent' => $field->field_parent
1197
- );
1198
-
1199
- $wpdb->insert( $this->field_table_name, $data );
1200
-
1201
- // If a parent field, save the old ID and the new ID to update new parent ID
1202
- if ( in_array( $field->field_type, array( 'fieldset', 'section', 'verification' ) ) ) {
1203
- $parents[ $field->field_id ] = $wpdb->insert_id;
1204
- }
1205
-
1206
- if ( $override == $field->field_id ) {
1207
- $wpdb->update( $this->form_table_name, array( 'form_email_from_override' => $wpdb->insert_id ), array( 'form_id' => $new_form_selected ) );
1208
- }
1209
-
1210
-
1211
- if ( $from_name == $field->field_id ) {
1212
- $wpdb->update( $this->form_table_name, array( 'form_email_from_name_override' => $wpdb->insert_id ), array( 'form_id' => $new_form_selected ) );
1213
- }
1214
-
1215
- if ( $notify == $field->field_id ) {
1216
- $wpdb->update( $this->form_table_name, array( 'form_notification_email' => $wpdb->insert_id ), array( 'form_id' => $new_form_selected ) );
1217
- }
1218
- }
1219
-
1220
- // Loop through our parents and update them to their new IDs
1221
- foreach ( $parents as $k => $v ) {
1222
- $wpdb->update( $this->field_table_name, array( 'field_parent' => $v ), array( 'form_id' => $new_form_selected, 'field_parent' => $k ) );
1223
- }
1224
-
1225
- // Redirect to keep the URL clean (use AJAX in the future?)
1226
- wp_redirect( 'admin.php?page=visual-form-builder&action=edit&form=' . $new_form_selected );
1227
- exit();
1228
- }
1229
-
1230
- /**
1231
- * Save options on the VFB Pro > Settings page
1232
- *
1233
- * @access public
1234
- * @since 2.8.1
1235
- * @return void
1236
- */
1237
- public function save_settings() {
1238
- if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
1239
- return;
1240
-
1241
- if ( 'vfb-settings' !== $_GET['page'] )
1242
- return;
1243
-
1244
- if ( 'vfb_settings' !== $_POST['action'] )
1245
- return;
1246
-
1247
- check_admin_referer( 'vfb-update-settings' );
1248
-
1249
- $data = array();
1250
-
1251
- foreach ( $_POST['vfb-settings'] as $key => $val ) {
1252
- $data[ $key ] = esc_html( $val );
1253
- }
1254
-
1255
- update_option( 'vfb-settings', $data );
1256
- }
1257
 
1258
  /**
1259
- * The jQuery field sorting callback
1260
- *
1261
- * @since 1.0
1262
  */
1263
- public function ajax_sort_field() {
1264
- global $wpdb;
1265
-
1266
- $data = array();
1267
-
1268
- foreach ( $_POST['order'] as $k ) {
1269
- if ( 'root' !== $k['item_id'] && !empty( $k['item_id'] ) ) {
1270
- $data[] = array(
1271
- 'field_id' => $k['item_id'],
1272
- 'parent' => $k['parent_id']
1273
- );
1274
- }
1275
- }
1276
-
1277
- foreach ( $data as $k => $v ) {
1278
- // Update each field with it's new sequence and parent ID
1279
- $wpdb->update( $this->field_table_name, array(
1280
- 'field_sequence' => $k,
1281
- 'field_parent' => $v['parent'] ),
1282
- array( 'field_id' => $v['field_id'] ),
1283
- '%d'
1284
- );
1285
- }
1286
-
1287
- die(1);
1288
- }
1289
 
1290
  /**
1291
- * The jQuery create field callback
1292
- *
1293
- * @since 1.9
1294
  */
1295
- public function ajax_create_field() {
1296
- global $wpdb;
1297
-
1298
- $data = array();
1299
- $field_options = $field_validation = '';
1300
-
1301
- foreach ( $_POST['data'] as $k ) {
1302
- $data[ $k['name'] ] = $k['value'];
1303
- }
1304
-
1305
- check_ajax_referer( 'create-field-' . $data['form_id'], 'nonce' );
1306
-
1307
- $form_id = absint( $data['form_id'] );
1308
- $field_key = sanitize_title( $_POST['field_type'] );
1309
- $field_name = esc_html( $_POST['field_type'] );
1310
- $field_type = strtolower( sanitize_title( $_POST['field_type'] ) );
1311
-
1312
- // Set defaults for validation
1313
- switch ( $field_type ) {
1314
- case 'select' :
1315
- case 'radio' :
1316
- case 'checkbox' :
1317
- $field_options = serialize( array( 'Option 1', 'Option 2', 'Option 3' ) );
1318
- break;
1319
-
1320
- case 'email' :
1321
- case 'url' :
1322
- case 'phone' :
1323
- $field_validation = $field_type;
1324
- break;
1325
-
1326
- case 'currency' :
1327
- $field_validation = 'number';
1328
- break;
1329
-
1330
- case 'number' :
1331
- $field_validation = 'digits';
1332
- break;
1333
-
1334
- case 'time' :
1335
- $field_validation = 'time-12';
1336
- break;
1337
-
1338
- case 'file-upload' :
1339
- $field_options = serialize( array( 'png|jpe?g|gif' ) );
1340
- break;
1341
- }
1342
-
1343
-
1344
- // Get the last row's sequence that isn't a Verification
1345
- $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 ) );
1346
-
1347
- // If it's not the first for this form, add 1
1348
- $field_sequence = ( !empty( $sequence_last_row ) ) ? $sequence_last_row : 0;
1349
-
1350
- $newdata = array(
1351
- 'form_id' => $form_id,
1352
- 'field_key' => $field_key,
1353
- 'field_name' => $field_name,
1354
- 'field_type' => $field_type,
1355
- 'field_options' => $field_options,
1356
- 'field_sequence' => $field_sequence,
1357
- 'field_validation' => $field_validation
1358
- );
1359
-
1360
- // Create the field
1361
- $wpdb->insert( $this->field_table_name, $newdata );
1362
- $insert_id = $wpdb->insert_id;
1363
-
1364
- // VIP fields
1365
- $vip_fields = array( 'verification', 'secret', 'submit' );
1366
-
1367
- // Move the VIPs
1368
- foreach ( $vip_fields as $update ) {
1369
- $field_sequence++;
1370
- $where = array(
1371
- 'form_id' => absint( $data['form_id'] ),
1372
- 'field_type' => $update
1373
- );
1374
- $wpdb->update( $this->field_table_name, array( 'field_sequence' => $field_sequence ), $where );
1375
-
1376
- }
1377
-
1378
- echo $this->field_output( $data['form_id'], $insert_id );
1379
-
1380
- die(1);
1381
- }
1382
 
1383
  /**
1384
- * The jQuery delete field callback
1385
- *
1386
- * @since 1.9
1387
  */
1388
- public function ajax_delete_field() {
1389
- global $wpdb;
1390
-
1391
- if ( isset( $_POST['action'] ) && $_POST['action'] == 'visual_form_builder_delete_field' ) {
1392
- $form_id = absint( $_POST['form'] );
1393
- $field_id = absint( $_POST['field'] );
1394
-
1395
- check_ajax_referer( 'delete-field-' . $form_id, 'nonce' );
1396
-
1397
- if ( isset( $_POST['child_ids'] ) ) {
1398
- foreach ( $_POST['child_ids'] as $children ) {
1399
- $parent = absint( $_POST['parent_id'] );
1400
-
1401
- // Update each child item with the new parent ID
1402
- $wpdb->update( $this->field_table_name, array( 'field_parent' => $parent ), array( 'field_id' => $children ) );
1403
- }
1404
- }
1405
-
1406
- // Delete the field
1407
- $wpdb->query( $wpdb->prepare( "DELETE FROM $this->field_table_name WHERE field_id = %d", $field_id ) );
1408
- }
1409
-
1410
- die(1);
1411
- }
1412
 
1413
  /**
1414
- * The jQuery form settings callback
1415
- *
1416
- * @since 2.2
1417
  */
1418
- public function ajax_form_settings() {
1419
- $current_user = wp_get_current_user();
1420
-
1421
- if ( isset( $_POST['action'] ) && $_POST['action'] == 'visual_form_builder_form_settings' ) {
1422
- $form_id = absint( $_POST['form'] );
1423
- $status = isset( $_POST['status'] ) ? $_POST['status'] : 'opened';
1424
- $accordion = isset( $_POST['accordion'] ) ? $_POST['accordion'] : 'general-settings';
1425
- $user_id = $current_user instanceof WP_User ? $current_user->ID : 1;
1426
-
1427
- $form_settings = get_user_meta( $user_id, 'vfb-form-settings', true );
1428
-
1429
- $array = array(
1430
- 'form_setting_tab' => $status,
1431
- 'setting_accordion' => $accordion
1432
- );
1433
-
1434
- // Set defaults if meta key doesn't exist
1435
- if ( !$form_settings || $form_settings == '' ) {
1436
- $meta_value[ $form_id ] = $array;
1437
-
1438
- update_user_meta( $user_id, 'vfb-form-settings', $meta_value );
1439
- }
1440
- else {
1441
- $form_settings[ $form_id ] = $array;
1442
-
1443
- update_user_meta( $user_id, 'vfb-form-settings', $form_settings );
1444
- }
1445
- }
1446
-
1447
- die(1);
1448
- }
1449
 
1450
  /**
1451
- * Display the additional media button
1452
- *
1453
- * Used for inserting the form shortcode with desired form ID
1454
- *
1455
- * @since 2.3
1456
- */
1457
- public function ajax_media_button(){
1458
- global $wpdb;
1459
-
1460
- // Sanitize the sql orderby
1461
- $order = sanitize_sql_orderby( 'form_id ASC' );
1462
-
1463
- // Build our forms as an object
1464
- $forms = $wpdb->get_results( "SELECT form_id, form_title FROM $this->form_table_name ORDER BY $order" );
1465
- ?>
1466
- <script type="text/javascript">
1467
- jQuery(document).ready(function($) {
1468
- $( '#add_vfb_form' ).submit(function(e){
1469
- e.preventDefault();
1470
-
1471
- window.send_to_editor( '[vfb id=' + $( '#vfb_forms' ).val() + ']' );
1472
-
1473
- window.tb_remove();
1474
- });
1475
- });
1476
- </script>
1477
- <div id="vfb_form">
1478
- <form id="add_vfb_form" class="media-upload-form type-form validate">
1479
- <h3 class="media-title">Insert Visual Form Builder Form</h3>
1480
- <p>Select a form below to insert into any Post or Page.</p>
1481
- <select id="vfb_forms" name="vfb_forms">
1482
- <?php foreach( $forms as $form ) : ?>
1483
- <option value="<?php echo $form->form_id; ?>"><?php echo $form->form_title; ?></option>
1484
- <?php endforeach; ?>
1485
- </select>
1486
- <p><input type="submit" class="button-primary" value="Insert Form" /></p>
1487
- </form>
1488
- </div>
1489
- <?php
1490
- die(1);
1491
  }
1492
 
1493
  /**
1494
- * All Forms output in admin
1495
- *
1496
- * @since 2.5
1497
- */
1498
- public function all_forms() {
1499
- global $wpdb, $forms_list;
1500
-
1501
- $order = sanitize_sql_orderby( 'form_title ASC' );
1502
-
1503
- $where = apply_filters( 'vfb_pre_get_forms', '' );
1504
- $forms = $wpdb->get_results( "SELECT form_id, form_title FROM $this->form_table_name WHERE 1=1 $where ORDER BY $order" );
1505
-
1506
- if ( !$forms ) :
1507
- echo '<div class="vfb-form-alpha-list"><h3 id="vfb-no-forms">You currently do not have any forms. <a href="' . esc_url( admin_url( 'admin.php?page=vfb-add-new' ) ) . '">Click here to get started</a>.</h3></div>';
1508
- return;
1509
- endif;
1510
 
1511
- echo '<form id="forms-filter" method="post" action="">';
1512
- $forms_list->views();
1513
- $forms_list->prepare_items();
1514
-
1515
- $forms_list->search_box( 'search', 'search_id' );
1516
- $forms_list->display();
1517
-
1518
- echo '</form>';
1519
- ?>
1520
-
1521
- <?php
1522
- }
1523
 
1524
  /**
1525
- * Build field output in admin
1526
  *
1527
- * @since 1.9
1528
- */
1529
- public function field_output( $form_nav_selected_id, $field_id = NULL ) {
1530
- require( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/admin-field-options.php' );
1531
- }
1532
-
1533
- /**
1534
- * Display admin notices
1535
  *
1536
- * @since 1.0
 
 
1537
  */
1538
- public function admin_notices(){
1539
- if ( !isset( $_POST['action'] ) || !isset( $_GET['page'] ) )
1540
- return;
 
 
 
1541
 
1542
- if ( !in_array( $_GET['page'], array( 'visual-form-builder', 'vfb-add-new', 'vfb-entries', 'vfb-email-design', 'vfb-reports', 'vfb-import', 'vfb-export', 'vfb-settings' ) ) )
1543
- return;
1544
 
1545
- switch( $_POST['action'] ) {
1546
- case 'create_form' :
1547
- echo '<div id="message" class="updated"><p>' . __( 'Form created.' , 'visual-form-builder' ) . '</p></div>';
1548
- break;
1549
 
1550
- case 'update_form' :
1551
- echo '<div id="message" class="updated"><p>' . __( 'Form updated.' , 'visual-form-builder' ) . '</p></div>';
1552
 
1553
- if ( $this->post_max_vars ) :
1554
- // Get max post vars, if available. Otherwise set to 1000
1555
- $max_post_vars = ( ini_get( 'max_input_vars' ) ) ? intval( ini_get( 'max_input_vars' ) ) : 1000;
1556
 
1557
- echo '<div id="message" class="error"><p>' . sprintf( __( 'Error saving form. The maximum amount of data allowed by your server has been reached. Please update <a href="%s" target="_blank">max_input_vars</a> in your php.ini file to allow more data to be saved. Current limit is <strong>%d</strong>', 'visual-form-builder' ), 'http://www.php.net/manual/en/info.configuration.php#ini.max-input-vars', $max_post_vars ) . '</p></div>';
1558
- endif;
1559
- break;
1560
-
1561
- case 'deleted' :
1562
- echo '<div id="message" class="updated"><p>' . __( 'Item permanently deleted.' , 'visual-form-builder') . '</p></div>';
1563
- break;
1564
-
1565
- case 'copy_form' :
1566
- echo '<div id="message" class="updated"><p>' . __( 'Item successfully duplicated.' , 'visual-form-builder') . '</p></div>';
1567
- break;
1568
-
1569
- case 'vfb_settings' :
1570
- echo sprintf( '<div id="message" class="updated"><p>%s</p></div>', __( 'Settings saved.' , 'visual-form-builder' ) );
1571
- break;
1572
  }
1573
- }
1574
 
1575
- /**
1576
- * Add options page to Settings menu
1577
- *
1578
- *
1579
- * @since 1.0
1580
- * @uses add_options_page() Creates a menu item under the Settings menu.
1581
- */
1582
- public function add_admin() {
1583
- $current_pages = array();
1584
-
1585
- $current_pages[ 'vfb' ] = add_menu_page( __( 'Visual Form Builder', 'visual-form-builder' ), __( 'Visual Form Builder', 'visual-form-builder' ), 'manage_options', 'visual-form-builder', array( &$this, 'admin' ), 'dashicons-feedback' );
1586
-
1587
- 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' ) );
1588
- $current_pages[ 'vfb-add-new' ] = add_submenu_page( 'visual-form-builder', __( 'Add New Form', 'visual-form-builder' ), __( 'Add New Form', 'visual-form-builder' ), 'manage_options', 'vfb-add-new', array( &$this, 'admin_add_new' ) );
1589
- $current_pages[ 'vfb-entries' ] = add_submenu_page( 'visual-form-builder', __( 'Entries', 'visual-form-builder' ), __( 'Entries', 'visual-form-builder' ), 'manage_options', 'vfb-entries', array( &$this, 'admin_entries' ) );
1590
- $current_pages[ 'vfb-export' ] = add_submenu_page( 'visual-form-builder', __( 'Export', 'visual-form-builder' ), __( 'Export', 'visual-form-builder' ), 'manage_options', 'vfb-export', array( &$this, 'admin_export' ) );
1591
- $current_pages[ 'vfb-settings' ] = add_submenu_page( 'visual-form-builder', __( 'Settings', 'visual-form-builder' ), __( 'Settings', 'visual-form-builder' ), 'manage_options', 'vfb-settings', array( &$this, 'admin_settings' ) );
1592
-
1593
- // All plugin page load hooks
1594
- foreach ( $current_pages as $key => $page ) :
1595
- // Load the jQuery and CSS we need if we're on our plugin page
1596
- add_action( "load-$page", array( &$this, 'admin_scripts' ) );
1597
-
1598
- // Load the Help tab on all pages
1599
- add_action( "load-$page", array( &$this, 'help' ) );
1600
- endforeach;
1601
-
1602
- // Save pages array for filter/action use throughout plugin
1603
- $this->_admin_pages = $current_pages;
1604
-
1605
- // Adds a Screen Options tab to the Entries screen
1606
- add_action( 'load-' . $current_pages['vfb'], array( &$this, 'screen_options' ) );
1607
- add_action( 'load-' . $current_pages['vfb-entries'], array( &$this, 'screen_options' ) );
1608
-
1609
- // Add meta boxes to the form builder admin page
1610
- add_action( 'load-' . $current_pages['vfb'], array( &$this, 'add_meta_boxes' ) );
1611
-
1612
- // Include Entries and Import files
1613
- add_action( 'load-' . $current_pages['vfb-entries'], array( &$this, 'includes' ) );
1614
-
1615
- add_action( 'load-' . $current_pages['vfb'], array( &$this, 'include_forms_list' ) );
1616
- }
1617
-
1618
- /**
1619
- * Display Add New Form page
1620
- *
1621
- *
1622
- * @since 2.7.2
1623
- */
1624
- public function admin_add_new() {
1625
- ?>
1626
- <div class="wrap">
1627
- <h2><?php _e( 'Add New Form', 'visual-form-builder' ); ?></h2>
1628
- <?php
1629
- include_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/admin-new-form.php' );
1630
- ?>
1631
- </div>
1632
- <?php
1633
- }
1634
-
1635
- /**
1636
- * Display Entries
1637
- *
1638
- *
1639
- * @since 2.7.2
1640
- */
1641
- public function admin_entries() {
1642
- global $entries_list, $entries_detail;
1643
- ?>
1644
- <div class="wrap">
1645
- <h2>
1646
- <?php _e( 'Entries', 'visual-form-builder' ); ?>
1647
- <?php
1648
- // If searched, output the query
1649
- if ( isset( $_POST['s'] ) && !empty( $_POST['s'] ) )
1650
- echo '<span class="subtitle">' . sprintf( __( 'Search results for "%s"' , 'visual-form-builder' ), esc_html( $_POST['s'] ) );
1651
- ?>
1652
- </h2>
1653
- <?php
1654
- if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'view', 'edit', 'update_entry' ) ) ) :
1655
- $entries_detail->entries_detail();
1656
- else :
1657
- $entries_list->views();
1658
- $entries_list->prepare_items();
1659
- ?>
1660
- <form id="entries-filter" method="post" action="">
1661
- <?php
1662
- $entries_list->search_box( 'search', 'search_id' );
1663
- $entries_list->display();
1664
- ?>
1665
- </form>
1666
- <?php endif; ?>
1667
- </div>
1668
- <?php
1669
- }
1670
-
1671
- /**
1672
- * Display Export
1673
- *
1674
- *
1675
- * @since 2.7.2
1676
- */
1677
- public function admin_export() {
1678
- global $export;
1679
- ?>
1680
- <div class="wrap">
1681
- <h2><?php _e( 'Export', 'visual-form-builder' ); ?></h2>
1682
- <?php
1683
- $export->display();
1684
- ?>
1685
- </div>
1686
- <?php
1687
- }
1688
-
1689
- /**
1690
- * admin_settings function.
1691
- *
1692
- * @access public
1693
- * @return void
1694
- */
1695
- public function admin_settings() {
1696
-
1697
- $vfb_settings = get_option( 'vfb-settings' );
1698
- ?>
1699
- <div class="wrap">
1700
- <h2><?php _e( 'Settings', 'visual-form-builder' ); ?></h2>
1701
- <form id="vfb-settings" method="post">
1702
- <input name="action" type="hidden" value="vfb_settings" />
1703
- <?php wp_nonce_field( 'vfb-update-settings' ); ?>
1704
- <h3><?php _e( 'Global Settings', 'visual-form-builder' ); ?></h3>
1705
- <p><?php _e( 'These settings will affect all forms on your site.', 'visual-form-builder' ); ?></p>
1706
- <table class="form-table">
1707
- <tr valign="top">
1708
- <th scope="row"><?php _e( 'CSS', 'visual-form-builder-pro' ); ?></th>
1709
- <td>
1710
- <fieldset>
1711
- <?php
1712
- $disable = array(
1713
- 'always-load-css' => __( 'Always load CSS', 'visual-form-builder' ),
1714
- 'disable-css' => __( 'Disable CSS', 'visual-form-builder' ), // visual-form-builder-css
1715
- );
1716
-
1717
- foreach ( $disable as $key => $title ) :
1718
-
1719
- $vfb_settings[ $key ] = isset( $vfb_settings[ $key ] ) ? $vfb_settings[ $key ] : '';
1720
- ?>
1721
- <label for="vfb-settings-<?php echo $key; ?>">
1722
- <input type="checkbox" name="vfb-settings[<?php echo $key; ?>]" id="vfb-settings-<?php echo $key; ?>" value="1" <?php checked( $vfb_settings[ $key ], 1 ); ?> /> <?php echo $title; ?>
1723
- </label>
1724
- <br>
1725
- <?php endforeach; ?>
1726
- </fieldset>
1727
- </td>
1728
- </tr>
1729
-
1730
- <tr valign="top">
1731
- <th scope="row"><?php _e( 'Form Output', 'visual-form-builder-pro' ); ?></th>
1732
- <td>
1733
- <fieldset>
1734
- <?php
1735
- $disable = array(
1736
- 'address-labels' => __( 'Place Address labels above fields', 'visual-form-builder' ), // vfb_address_labels_placement
1737
- 'show-version' => __( 'Disable meta tag version', 'visual-form-builder' ), // vfb_show_version
1738
- );
1739
-
1740
- foreach ( $disable as $key => $title ) :
1741
-
1742
- $vfb_settings[ $key ] = isset( $vfb_settings[ $key ] ) ? $vfb_settings[ $key ] : '';
1743
- ?>
1744
- <label for="vfb-settings-<?php echo $key; ?>">
1745
- <input type="checkbox" name="vfb-settings[<?php echo $key; ?>]" id="vfb-settings-<?php echo $key; ?>" value="1" <?php checked( $vfb_settings[ $key ], 1 ); ?> /> <?php echo $title; ?>
1746
- </label>
1747
- <br>
1748
- <?php endforeach; ?>
1749
- </fieldset>
1750
- </td>
1751
- </tr>
1752
-
1753
- <tr valign="top">
1754
- <th scope="row"><label for="vfb-settings-spam-points"><?php _e( 'Spam word sensitivity', 'visual-form-builder' ); ?></label></th>
1755
- <td>
1756
- <?php $vfb_settings['spam-points'] = isset( $vfb_settings['spam-points'] ) ? $vfb_settings['spam-points'] : '4'; ?>
1757
- <input type="number" min="1" name="vfb-settings[spam-points]" id="vfb-settings-spam-points" value="<?php echo $vfb_settings['spam-points']; ?>" class="small-text" />
1758
- </td>
1759
- </tr>
1760
-
1761
- <tr valign="top">
1762
- <th scope="row"><label for="vfb-settings-max-upload-size"><?php _e( 'Max Upload Size', 'visual-form-builder' ); ?></label></th>
1763
- <td>
1764
- <?php $vfb_settings['max-upload-size'] = isset( $vfb_settings['max-upload-size'] ) ? $vfb_settings['max-upload-size'] : '25'; ?>
1765
- <input type="number" name="vfb-settings[max-upload-size]" id="vfb-settings-max-upload-size" value="<?php echo $vfb_settings['max-upload-size']; ?>" class="small-text" /> MB
1766
- </td>
1767
- </tr>
1768
-
1769
- <tr valign="top">
1770
- <th scope="row"><label for="vfb-settings-sender-mail-header"><?php _e( 'Sender Mail Header', 'visual-form-builder' ); ?></label></th>
1771
- <td>
1772
- <?php
1773
- // Use the admin_email as the From email
1774
- $from_email = get_site_option( 'admin_email' );
1775
-
1776
- // Get the site domain and get rid of www.
1777
- $sitename = strtolower( $_SERVER['SERVER_NAME'] );
1778
- if ( substr( $sitename, 0, 4 ) == 'www.' )
1779
- $sitename = substr( $sitename, 4 );
1780
-
1781
- // Get the domain from the admin_email
1782
- list( $user, $domain ) = explode( '@', $from_email );
1783
-
1784
- // If site domain and admin_email domain match, use admin_email, otherwise a same domain email must be created
1785
- $from_email = ( $sitename == $domain ) ? $from_email : "wordpress@$sitename";
1786
-
1787
- $vfb_settings['sender-mail-header'] = isset( $vfb_settings['sender-mail-header'] ) ? $vfb_settings['sender-mail-header'] : $from_email;
1788
- ?>
1789
- <input type="text" name="vfb-settings[sender-mail-header]" id="vfb-settings-sender-mail-header" value="<?php echo $vfb_settings['sender-mail-header']; ?>" class="regular-text" />
1790
- <p class="description"><?php _e( 'Some server configurations require an existing email on the domain be used when sending emails.', 'visual-form-builder' ); ?></p>
1791
- </td>
1792
- </tr>
1793
- </table>
1794
-
1795
- <?php submit_button( __( 'Save', 'visual-form-builder' ), 'primary', 'submit', false ); ?>
1796
- </form>
1797
- </div>
1798
- <?php
1799
  }
1800
 
1801
  /**
1802
- * Builds the options settings page
1803
- *
1804
- * @since 1.0
1805
  */
1806
- public function admin() {
1807
  global $wpdb;
1808
 
1809
- $current_user = wp_get_current_user();
1810
-
1811
- // Save current user ID
1812
- $user_id = $current_user instanceof WP_User ? $current_user->ID : 1;
1813
-
1814
- // Set variables depending on which tab is selected
1815
- $form_nav_selected_id = isset( $_GET['form'] ) ? $_GET['form'] : '0';
1816
- ?>
1817
- <div class="wrap">
1818
- <h2>
1819
- <?php _e( 'Visual Form Builder', 'visual-form-builder' ); ?>
1820
- <?php
1821
- // Add New link
1822
- echo sprintf( ' <a href="%1$s" class="add-new-h2">%2$s</a>', esc_url( admin_url( 'admin.php?page=vfb-add-new' ) ), esc_html( __( 'Add New', 'visual-form-builder' ) ) );
1823
-
1824
- // If searched, output the query
1825
- if ( isset( $_POST['s'] ) && !empty( $_POST['s'] ) )
1826
- echo '<span class="subtitle">' . sprintf( __( 'Search results for "%s"' , 'visual-form-builder' ), esc_html( $_POST['s'] ) );
1827
- ?>
1828
- </h2>
1829
- <?php if ( empty( $form_nav_selected_id ) ) : ?>
1830
- <div id="vfb-form-list">
1831
- <div id="vfb-sidebar">
1832
- <div id="vfb-upgrade-column">
1833
- <div class="vfb-pro-upgrade">
1834
- <h2><a href="http://vfbpro.com">VFB Pro</a></h2>
1835
- <p class="vfb-pro-call-to-action">
1836
- <a class="vfb-btn vfb-btn-inverse" href="http://vfbpro.com/pages/pricing" target="_blank"><?php _e( 'View Pricing' , 'visual-form-builder'); ?></a>
1837
- <a class="vfb-btn vfb-btn-primary" href="http://vfbpro.com/pages/pricing" target="_blank"><?php _e( 'Buy Now' , 'visual-form-builder'); ?></a>
1838
- </p>
1839
- <p class="vfb-pro-call-to-action">
1840
- <a class="button" href="http://demo.vfbpro.com" target="_blank"><?php _e( 'Try the Free Live Demo &rarr;' , 'visual-form-builder'); ?></a>
1841
- </p>
1842
- <h3><?php _e( 'New Features' , 'visual-form-builder'); ?></h3>
1843
- <ul>
1844
- <li><a href="http://vfbpro.com/collections/add-ons"><?php _e( 'Now with Add-Ons' , 'visual-form-builder'); ?></a></li>
1845
- <li><?php _e( 'Akismet Support' , 'visual-form-builder'); ?></li>
1846
- <li><?php _e( 'reCAPTCHA v2' , 'visual-form-builder'); ?></li>
1847
- <li><?php _e( 'Conditional Logic' , 'visual-form-builder'); ?></li>
1848
- <li><?php _e( '15 new Form Fields' , 'visual-form-builder'); ?></li>
1849
- <li><?php _e( 'Complete Entries Management' , 'visual-form-builder'); ?></li>
1850
- <li><?php _e( 'Import/Export' , 'visual-form-builder'); ?></li>
1851
- <li><?php _e( 'Quality HTML Email Template' , 'visual-form-builder'); ?></li>
1852
- <li><?php _e( 'Plain Text Email Option' , 'visual-form-builder'); ?></li>
1853
- <li><?php _e( 'Email Designer' , 'visual-form-builder'); ?></li>
1854
- <li><?php _e( 'Data &amp; Form Migration' , 'visual-form-builder'); ?></li>
1855
- <li><?php _e( 'Scheduling' , 'visual-form-builder'); ?></li>
1856
- <li><?php _e( 'Limit Form Entries' , 'visual-form-builder'); ?></li>
1857
- <li><?php _e( 'Form Paging' , 'visual-form-builder'); ?></li>
1858
- <li><?php _e( 'Custom Capabilities' , 'visual-form-builder'); ?></li>
1859
- <li><?php _e( 'Automatic Updates' , 'visual-form-builder'); ?></li>
1860
- </ul>
1861
 
1862
- <p><a href="http://vfbpro.com/pages/features"><?php _e( 'View all features' , 'visual-form-builder'); ?></a></p>
1863
- </div> <!-- .vfb-pro-upgrade -->
 
1864
 
1865
- <h3><?php _e( 'Promote Visual Form Builder' , 'visual-form-builder'); ?></h3>
1866
- <ul id="promote-vfb">
1867
- <li id="twitter"><?php _e( 'Follow VFB Pro on Twitter' , 'visual-form-builder'); ?>: <a href="http://twitter.com/#!/vfbpro">@vfbpro</a></li>
1868
- <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>
1869
- <li id="paypal">
1870
- <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>
1871
- </li>
1872
- </ul>
1873
- </div> <!-- #vfb-upgrade-column -->
1874
- </div> <!-- #vfb-sidebar -->
1875
- <div id="vfb-main" class="vfb-order-type-list">
1876
- <?php $this->all_forms(); ?>
1877
- </div> <!-- #vfb-main -->
1878
- </div> <!-- #vfb-form-list -->
1879
 
1880
- <?php
1881
- elseif ( !empty( $form_nav_selected_id ) && $form_nav_selected_id !== '0' ) :
1882
- include_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/admin-form-creator.php' );
1883
- endif;
1884
- ?>
1885
- </div>
1886
- <?php
1887
- }
1888
-
1889
- /**
1890
- * Handle confirmation when form is submitted
1891
- *
1892
- * @since 1.3
1893
- */
1894
- function confirmation(){
1895
- global $wpdb;
1896
-
1897
- $form_id = isset( $_POST['form_id'] ) ? (int) esc_html( $_POST['form_id'] ) : '';
1898
-
1899
- if ( !isset( $_POST['vfb-submit'] ) )
1900
- return;
1901
 
1902
- // Get forms
1903
- $order = sanitize_sql_orderby( 'form_id DESC' );
1904
- $forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
1905
 
1906
- foreach ( $forms as $form ) :
1907
- // If text, return output and format the HTML for display
1908
- if ( 'text' == $form->form_success_type )
1909
- return stripslashes( html_entity_decode( wp_kses_stripslashes( $form->form_success_message ) ) );
1910
- // If page, redirect to the permalink
1911
- elseif ( 'page' == $form->form_success_type ) {
1912
- $page = get_permalink( $form->form_success_message );
1913
- wp_redirect( $page );
1914
- exit();
1915
- }
1916
- // If redirect, redirect to the URL
1917
- elseif ( 'redirect' == $form->form_success_type ) {
1918
- wp_redirect( esc_url( $form->form_success_message ) );
1919
- exit();
1920
- }
1921
- endforeach;
1922
- }
1923
-
1924
- /**
1925
- * Output form via shortcode
1926
- *
1927
- * @since 1.0
1928
- */
1929
- public function form_code( $atts, $output = '' ) {
1930
 
1931
- require( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/form-output.php' );
 
 
1932
 
1933
- return $output;
 
 
1934
  }
1935
 
1936
  /**
1937
- * Handle emailing the content
1938
- *
1939
- * @since 1.0
1940
- * @uses wp_mail() E-mails a message
1941
  */
1942
- public function email() {
1943
- require( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/email.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1944
  }
1945
 
1946
  /**
1947
- * Validate the input
1948
- *
1949
- * @since 2.2
1950
  */
1951
- public function validate_input( $data, $name, $type, $required ) {
1952
-
1953
- if ( 'yes' == $required && strlen( $data ) == 0 )
1954
- wp_die( "<h1>$name</h1><br>" . __( 'This field is required and cannot be empty.', 'visual-form-builder' ), $name, array( 'back_link' => true ) );
1955
-
1956
- if ( strlen( $data ) > 0 ) :
1957
- switch( $type ) :
1958
-
1959
- case 'email' :
1960
- if ( !is_email( $data ) )
1961
- wp_die( "<h1>$name</h1><br>" . __( 'Not a valid email address', 'visual-form-builder' ), '', array( 'back_link' => true ) );
1962
- break;
1963
-
1964
- case 'number' :
1965
- case 'currency' :
1966
- if ( !is_numeric( $data ) )
1967
- wp_die( "<h1>$name</h1><br>" . __( 'Not a valid number', 'visual-form-builder' ), '', array( 'back_link' => true ) );
1968
- break;
1969
-
1970
- case 'phone' :
1971
- 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 ) )
1972
- return true;
1973
- else
1974
- 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 ) );
1975
- break;
1976
-
1977
- case 'url' :
1978
- if ( !preg_match( '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $data ) )
1979
- wp_die( "<h1>$name</h1><br>" . __( 'Not a valid URL.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
1980
- break;
1981
-
1982
- default :
1983
- return true;
1984
- break;
1985
-
1986
- endswitch;
1987
- endif;
1988
  }
1989
 
1990
  /**
1991
- * Sanitize the input
1992
- *
1993
- * @since 2.5
1994
  */
1995
- public function sanitize_input( $data, $type ) {
1996
- if ( strlen( $data ) > 0 ) :
1997
- switch( $type ) :
1998
- case 'text' :
1999
- return sanitize_text_field( $data );
2000
- break;
2001
-
2002
- case 'textarea' :
2003
- return wp_strip_all_tags( $data );
2004
- break;
2005
-
2006
- case 'email' :
2007
- return sanitize_email( $data );
2008
- break;
2009
-
2010
- case 'html' :
2011
- return wp_kses_data( force_balance_tags( $data ) );
2012
- break;
2013
 
2014
- case 'min' :
2015
- case 'max' :
2016
- case 'digits' :
2017
- return preg_replace( '/\D/i', '', $data );
2018
- break;
2019
-
2020
- case 'address' :
2021
- $allowed_html = array( 'br' => array() );
2022
- return wp_kses( $data, $allowed_html );
2023
- break;
2024
-
2025
- default :
2026
- return wp_kses_data( $data );
2027
- break;
2028
- endswitch;
2029
- endif;
2030
  }
2031
 
2032
  /**
2033
- * Make sure the User Agent string is not a SPAM bot
2034
- *
2035
- * @since 1.3
2036
  */
2037
- public function isBot() {
2038
- $bots = apply_filters( 'vfb_blocked_spam_bots', array(
2039
- '<', '>', '&lt;', '%0A', '%0D', '%27', '%3C', '%3E', '%00', 'href',
2040
- 'binlar', 'casper', 'cmsworldmap', 'comodo', 'diavol',
2041
- 'dotbot', 'feedfinder', 'flicky', 'ia_archiver', 'jakarta',
2042
- 'kmccrew', 'nutch', 'planetwork', 'purebot', 'pycurl',
2043
- 'skygrid', 'sucker', 'turnit', 'vikspider', 'zmeu',
2044
- )
2045
- );
2046
-
2047
- $isBot = false;
2048
-
2049
- $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? wp_kses_data( $_SERVER['HTTP_USER_AGENT'] ) : '';
2050
-
2051
- do_action( 'vfb_isBot', $user_agent, $bots );
2052
-
2053
- foreach ( $bots as $bot ) {
2054
- if ( stripos( $user_agent, $bot ) !== false )
2055
- $isBot = true;
2056
- }
2057
-
2058
- return $isBot;
2059
- }
2060
-
2061
- public function build_array_form_item( $value, $type = '' ) {
2062
-
2063
- $output = '';
2064
-
2065
- // Basic check for type when not set
2066
- if ( empty( $type ) ) :
2067
- if ( is_array( $value ) && array_key_exists( 'address', $value ) )
2068
- $type = 'address';
2069
- elseif ( is_array( $value ) && array_key_exists( 'hour', $value ) && array_key_exists( 'min', $value ) )
2070
- $type = 'time';
2071
- elseif ( is_array( $value ) )
2072
- $type = 'checkbox';
2073
- else
2074
- $type = 'default';
2075
- endif;
2076
-
2077
- // Build array'd form item output
2078
- switch( $type ) :
2079
-
2080
- case 'time' :
2081
- $output = ( array_key_exists( 'ampm', $value ) ) ? substr_replace( implode( ':', $value ), ' ', 5, 1 ) : implode( ':', $value );
2082
- break;
2083
-
2084
- case 'address' :
2085
-
2086
- if ( !empty( $value['address'] ) )
2087
- $output .= $value['address'];
2088
-
2089
- if ( !empty( $value['address-2'] ) ) {
2090
- if ( !empty( $output ) )
2091
- $output .= '<br>';
2092
- $output .= $value['address-2'];
2093
- }
2094
 
2095
- if ( !empty( $value['city'] ) ) {
2096
- if ( !empty( $output ) )
2097
- $output .= '<br>';
2098
- $output .= $value['city'];
2099
- }
2100
- if ( !empty( $value['state'] ) ) {
2101
- if ( !empty( $output ) && empty( $value['city'] ) )
2102
- $output .= '<br>';
2103
- elseif ( !empty( $output ) && !empty( $value['city'] ) )
2104
- $output .= ', ';
2105
- $output .= $value['state'];
2106
- }
2107
- if ( !empty( $value['zip'] ) ) {
2108
- if ( !empty( $output ) && ( empty( $value['city'] ) && empty( $value['state'] ) ) )
2109
- $output .= '<br>';
2110
- elseif ( !empty( $output ) && ( !empty( $value['city'] ) || !empty( $value['state'] ) ) )
2111
- $output .= ' ';
2112
- $output .= $value['zip'];
2113
- }
2114
- if ( !empty( $value['country'] ) ) {
2115
- if ( !empty( $output ) )
2116
- $output .= '<br>';
2117
- $output .= $value['country'];
2118
- }
2119
-
2120
- break;
2121
-
2122
- case 'checkbox' :
2123
-
2124
- $output = esc_html( implode( ', ', $value ) );
2125
-
2126
- break;
2127
-
2128
- default :
2129
-
2130
- $output = wp_specialchars_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES );
2131
-
2132
- break;
2133
-
2134
- endswitch;
2135
-
2136
- return $output;
2137
  }
2138
 
2139
  /**
2140
- * Check whether the content contains the specified shortcode
2141
- *
2142
- * @access public
2143
- * @param string $shortcode (default: '')
2144
- * @return void
2145
  */
2146
- function has_shortcode($shortcode = '') {
2147
-
2148
- $post_to_check = get_post(get_the_ID());
2149
-
2150
- // false because we have to search through the post content first
2151
- $found = false;
 
 
2152
 
2153
- // if no short code was provided, return false
2154
- if (!$shortcode) {
2155
- return $found;
2156
- }
2157
- // check the post content for the short code
2158
- if ( stripos($post_to_check->post_content, '[' . $shortcode) !== false ) {
2159
- // we have found the short code
2160
- $found = true;
2161
- }
2162
-
2163
- // return our final results
2164
- return $found;
2165
  }
2166
  }
2167
 
2168
- // The VFB widget
2169
- require( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/class-widget.php' );
 
 
 
 
 
2170
 
2171
- // Special case to load Export class so AJAX is registered
2172
- require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/class-export.php' );
2173
- if ( !isset( $export ) )
2174
- $export = new VisualFormBuilder_Export();
3
  Plugin Name: Visual Form Builder
4
  Plugin URI: https://wordpress.org/plugins/visual-form-builder/
5
  Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
6
+ Version: 2.9.5
7
  Author: Matthew Muro
8
+ Author URI: http://vfbpro.com
9
  Text Domain: visual-form-builder
10
  Domain Path: /languages/
11
  */
12
 
13
+ // If this file is called directly, abort.
14
+ if ( ! defined( 'WPINC' ) )
15
+ exit;
16
 
17
+ class Visual_Form_Builder {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  /**
20
+ * The unique identifier of this plugin.
21
+ * @var [type]
 
22
  */
23
+ protected $plugin_name = 'visual-form-builder';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  /**
26
+ * The current version of the plugin.
27
+ * @var [type]
 
28
  */
29
+ protected $version = '2.9.5';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  /**
32
+ * The current DB version. Used if we need to update the DB later.
33
+ * @var [type]
 
34
  */
35
+ protected $db_version = '2.9';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  /**
38
+ * The main instance of Visual_Form_Builder
39
+ * @var [type]
 
40
  */
41
+ private static $instance = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  /**
44
+ * Protected constructor to prevent creating a new instance of Visual_Form_Builder
45
+ * via the 'new' operator from outside of this class.
46
+ *
47
+ * @return void
48
+ */
49
+ protected function __construct() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
 
52
  /**
53
+ * Private clone method to prevent cloning of the instance.
54
+ *
55
+ * @return void
56
+ */
57
+ private function __clone() {
58
+ }
 
 
 
 
 
 
 
 
 
 
59
 
60
+ /**
61
+ * Private unserialize method to prevent unserializing of the instance.
62
+ *
63
+ * @return void
64
+ */
65
+ private function __wakeup() {
66
+ }
 
 
 
 
 
67
 
68
  /**
69
+ * Create a single Visual_Form_Builder instance
70
  *
71
+ * Insures that only one instance of Visual_Form_Builder is running.
72
+ * Otherwise known as the Singleton class pattern
 
 
 
 
 
 
73
  *
74
+ * @since 3.0
75
+ * @access public
76
+ * @static
77
  */
78
+ public static function instance() {
79
+ if ( null === self::$instance ) {
80
+ self::$instance = new Visual_Form_Builder;
81
+ self::$instance->setup_constants();
82
+ self::$instance->includes();
83
+ self::$instance->autoload_classes();
84
 
85
+ // Setup Entries CPT
86
+ //self::$instance->entries_cpt = new VFB_Pro_Entries_CPT();
87
 
88
+ // Install DB
89
+ register_activation_hook( __FILE__, array( self::$instance, 'install' ) );
 
 
90
 
91
+ // Update DB
92
+ add_action( 'plugins_loaded', array( self::$instance, 'upgrade_db_check' ) );
93
 
94
+ // Load i18n
95
+ add_action( 'plugins_loaded', array( self::$instance, 'lang' ) );
 
96
 
97
+ $screen_options = new Visual_Form_Builder_Admin_Screen_Options();
98
+ add_filter( 'set-screen-option', array( $screen_options, 'save_option' ), 10, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
 
100
 
101
+ return self::$instance;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
103
 
104
  /**
105
+ * Setup constants
106
+ * @return [type] [description]
 
107
  */
108
+ private function setup_constants() {
109
  global $wpdb;
110
 
111
+ // Database version
112
+ if ( !defined( 'VFB_WP_DB_VERSION' ) )
113
+ define( 'VFB_WP_DB_VERSION', $this->db_version );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
+ // Plugin version
116
+ if ( !defined( 'VFB_WP_PLUGIN_VERSION' ) )
117
+ define( 'VFB_WP_PLUGIN_VERSION', $this->version );
118
 
119
+ // Plugin Folder Path
120
+ if ( !defined( 'VFB_WP_PLUGIN_DIR' ) )
121
+ define( 'VFB_WP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
 
 
 
 
 
 
 
 
 
 
 
122
 
123
+ // Plugin Folder URL
124
+ if ( !defined( 'VFB_WP_PLUGIN_URL' ) )
125
+ define( 'VFB_WP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
+ // Plugin Root File
128
+ if ( !defined( 'VFB_WP_PLUGIN_FILE' ) )
129
+ define( 'VFB_WP_PLUGIN_FILE', __FILE__ );
130
 
131
+ // Form table name
132
+ if ( !defined( 'VFB_WP_FORMS_TABLE_NAME' ) )
133
+ define( 'VFB_WP_FORMS_TABLE_NAME', $wpdb->prefix . 'visual_form_builder_forms' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
+ // Field table name
136
+ if ( !defined( 'VFB_WP_FIELDS_TABLE_NAME' ) )
137
+ define( 'VFB_WP_FIELDS_TABLE_NAME', $wpdb->prefix . 'visual_form_builder_fields' );
138
 
139
+ // Form meta table name
140
+ if ( !defined( 'VFB_WP_ENTRIES_TABLE_NAME' ) )
141
+ define( 'VFB_WP_ENTRIES_TABLE_NAME', $wpdb->prefix . 'visual_form_builder_entries' );
142
  }
143
 
144
  /**
145
+ * Include files
146
+ * @return [type] [description]
 
 
147
  */
148
+ private function includes() {
149
+ require_once( VFB_WP_PLUGIN_DIR . 'inc/class-install.php' );
150
+ require_once( VFB_WP_PLUGIN_DIR . 'inc/class-i18n.php' );
151
+ require_once( VFB_WP_PLUGIN_DIR . 'inc/class-list-table.php' );
152
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-admin-menu.php' );
153
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-admin-notices.php' );
154
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-screen-options.php' );
155
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-media-button.php' );
156
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-dashboard-widgets.php' );
157
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-widget.php' );
158
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-load-css-js.php' );
159
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-entries-detail.php' );
160
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-entries-list.php' );
161
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-forms-list.php' );
162
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-forms-new.php' );
163
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-forms-edit.php' );
164
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-forms-metaboxes.php' );
165
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-fields.php' );
166
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-page-settings.php' );
167
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-ajax.php' );
168
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-save.php' );
169
+ require_once( VFB_WP_PLUGIN_DIR . 'admin/class-export.php' );
170
+ require_once( VFB_WP_PLUGIN_DIR . 'public/class-form-display.php' );
171
+ require_once( VFB_WP_PLUGIN_DIR . 'public/class-load-css-js.php' );
172
+ require_once( VFB_WP_PLUGIN_DIR . 'public/class-confirmation.php' );
173
+ require_once( VFB_WP_PLUGIN_DIR . 'public/class-email.php' );
174
+ require_once( VFB_WP_PLUGIN_DIR . 'public/class-security.php' );
175
  }
176
 
177
  /**
178
+ * Install DB
179
+ * @return [type] [description]
 
180
  */
181
+ public function install() {
182
+ $install = new Visual_Form_Builder_Install();
183
+ $install->install();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  }
185
 
186
  /**
187
+ * Check database version and run SQL install, if needed
188
+ * @return [type] [description]
 
189
  */
190
+ public function upgrade_db_check() {
191
+ $current_db_version = VFB_WP_DB_VERSION;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
 
193
+ if ( get_site_option( 'vfb_db_version' ) != $current_db_version ) {
194
+ $install = new Visual_Form_Builder_Install();
195
+ $install->install_db();
196
+ }
 
 
 
 
 
 
 
 
 
 
 
 
197
  }
198
 
199
  /**
200
+ * Load localization file
201
+ * @return [type] [description]
 
202
  */
203
+ public function lang() {
204
+ $i18n = new Visual_Form_Builder_i18n();
205
+ $i18n->set_domain( $this->plugin_name );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
 
207
+ $i18n->load_lang();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  }
209
 
210
  /**
211
+ * Autoload some VFB classes that aren't loaded via other files.
212
+ * @return [type] [description]
 
 
 
213
  */
214
+ public function autoload_classes() {
215
+ $admin_menu = new Visual_Form_Builder_Admin_Menu();
216
+ $admin_ajax = new Visual_Form_Builder_Admin_AJAX();
217
+ $admin_save = new Visual_Form_Builder_Admin_Save();
218
+ $admin_notices = new Visual_Form_Builder_Admin_Notices();
219
+ $dashboard_widgets = new Visual_Form_Builder_Dashboard_Widgets();
220
+ $export = new Visual_Form_Builder_Export();
221
+ $media_button = new Visual_Form_Builder_Media_Button();
222
 
223
+ Visual_Form_Builder_Form_Display::instance();
 
 
 
 
 
 
 
 
 
 
 
224
  }
225
  }
226
 
227
+ /**
228
+ * The main function responsible for returning Visual Form Builder forms and functionality.
229
+ * @return [type] [description]
230
+ */
231
+ function visual_form_builder_plugin_instance() {
232
+ return Visual_Form_Builder::instance();
233
+ }
234
 
235
+ visual_form_builder_plugin_instance();