Version Description
- Settings screen UI improved.
- WordPress and WooCommerce compatible version updated.
Download this release
Release Info
Developer | ThemeHigh |
Plugin | WooCommerce Checkout Field Editor (Manager) Pro |
Version | 1.4.6 |
Comparing to | |
See all releases |
Code changes from version 1.4.5 to 1.4.6
- admin/assets/css/thwcfd-admin.min.css +1 -0
- {assets → admin/assets}/css/tick.png +0 -0
- {assets → admin/assets}/css/upgrade-btn.png +0 -0
- admin/assets/js/thwcfd-admin.js +921 -0
- admin/assets/js/thwcfd-admin.min.js +1 -0
- admin/class-thwcfd-admin-form-field.php +420 -0
- admin/class-thwcfd-admin-form.php +426 -0
- admin/class-thwcfd-admin-settings-advanced.php +201 -0
- classes/class-thwcfd-settings-general.php → admin/class-thwcfd-admin-settings-general.php +38 -269
- admin/class-thwcfd-admin-settings.php +259 -0
- classes/class-thwcfd-settings.php → admin/class-thwcfd-admin.php +63 -47
- assets/css/thwcfd-admin.css +0 -550
- assets/css/thwcfd-public.css +0 -8
- assets/js/thwcfd-admin.js +0 -499
- assets/js/thwcfd-checkout.js +0 -70
- checkout-form-designer.php +5 -5
- classes/class-thwcfd-settings-advanced.php +0 -390
- classes/class-thwcfd.php +0 -70
- includes/class-thwcfd-autoloader.php +82 -0
- includes/class-thwcfd.php +114 -0
- {classes → includes/utils}/class-thwcfd-utils.php +6 -7
- public/assets/css/thwcfd-public.min.css +1 -0
- public/assets/js/thwcfd-public.min.js +1 -0
- classes/class-thwcfd-checkout.php → public/class-thwcfd-public-checkout.php +8 -7
- readme.txt +17 -12
admin/assets/css/thwcfd-admin.min.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.align-center{text-align:center!important}.woocommerce-message{margin-top:10px}.err_msgs{color:red}.empty-msg-row{padding:20px 0!important;text-align:center}.color-red{color:red!important}.status-active{font-size:15px;color:green}.status-deactive{font-size:15px;color:red}.thpladmin-subtitle{font-size:11px;color:#666}.thpladmin-notice a.button-primary{font-size:14px;color:#fff;background-color:#d9534f;border-color:#d43f3a;line-height:38px;height:40px;padding-left:20px;padding-right:20px}.thpladmin-notice a.button-primary:hover{background-color:#d2322d;border-color:#ac2925}table.thpladmin_fields_table td.sort{cursor:move;font-size:15px;text-align:center}table.thpladmin_fields_table td.sort::before{content:'\f333';font-family:Dashicons;text-align:center;line-height:1;color:#999;display:block;width:17px;float:left;height:100%;line-height:24px}.thpladmin-tab{width:100%;border:0 solid #d4d4d1;border-top:0;background-color:#fff;float:left}.thpladmin-tabs-menu{width:100%;margin:0;margin-top:10px;float:left;clear:both;border-bottom:1px solid #bcd4e6}.thpladmin-tabs-menu li{float:left;margin-right:5px;margin-bottom:-1px;border:1px solid #bcd4e6;outline:1px solid transparent;border-radius:4px 4px 0 0;background:#e1ecf4}.thpladmin-tabs-menu li.current{color:#555;position:relative;background-color:#fff;border-bottom:1px solid #fff;box-shadow:none}.thpladmin-tabs-menu li.first{margin-left:20px}.thpladmin-tabs-menu li a{font-size:18px;display:block;padding:12px 20px;text-decoration:none;color:#9fc2db;-webkit-transition:color .2s;transition:color .2s}.thpladmin-tabs-menu li a:focus{outline:0;box-shadow:none}.thpladmin-tabs-menu .current a{color:#2e7da3}.thpladmin-tab-content{padding:0;display:none;min-height:200px;max-height:485px;color:#000}.thpladmin-sections{list-style:outside none none;margin:8px 0 0;padding:0;font-size:13px;color:#666}.thpladmin-sections li{display:inline-block;margin:0;padding:0;white-space:nowrap}.thpladmin-sections a.current{font-weight:600;border:medium none;color:#000}.thpladmin-sections a{line-height:2;padding:.2em;text-decoration:none}.thpladmin-sections .delete_section img,.thpladmin-sections a.edit_section img{width:12px;height:12px}.thpladmin-sections a.add_link{margin-left:30px;background-color:#00a0d2;border:1px solid #0073aa;color:#fff;padding:2px 5px;border-radius:3px}.thpladmin-sections a.add_link:hover{background-color:#0073aa}.thpladmin-form-table td{padding:5px 0}.thpladmin-form-table td.thpladmin-form-section-title{font-weight:700;border-bottom:1px dashed #cecece}.thpladmin_fields_table tr.strikeout td{background:rgba(255,0,0,.4)!important;opacity:.6;text-decoration:line-through}.thpladmin_fields_table tr.thpladmin-disabled td{opacity:.4}.thpladmin_fields_table tr.thpladmin-disabled td.td_select{opacity:1}.thpladmin_fields_table .td_actions{width:90px}.thpladmin_fields_table .td_enabled{width:80px}.thpladmin_fields_table .td_clear{width:65px}.thpladmin_fields_table .td_required{width:85px}.thpladmin_fields_table .td_select{width:45px}.thpladmin_fields_table .td_type{width:150px}.thpladmin_fields_table .td_validate{text-transform:capitalize}.thpladmin_fields_table th.status{white-space:nowrap}.thpladmin_fields_table .dashicons{line-height:inherit}.thpladmin_fields_table .td_actions .dashicons{background-color:#f7f7f7;border:1px solid #ccc;border-radius:3px;padding:0 2px 2px 2px;box-shadow:0 1px 0 #ccc;webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.thpladmin_fields_table .td_actions .dashicons.disabled{color:#ccc;border:1px solid #e9e9e9;cursor:default}.thpladmin_fields_table .td_actions .dashicons-edit{cursor:pointer}.thpladmin_fields_table .td_actions .dashicons-admin-page{cursor:pointer}.thpladmin-sections .dashicons{cursor:pointer}.thpladmin-sections .dashicons-no{color:#ff4c4c}.thpladmin-notice a{display:block;padding:0;height:63px}.thpladmin-notice p{margin-bottom:0}.thpladmin-notice ul{list-style-type:none;margin:0}.thpladmin-notice ul li{background:url("tick.png") no-repeat 0 50%;padding-left:20px}:root{--primary-bg-color:#007cba;--primary-text-color:#0071a1;--primary-border-color:#0071a1;--primary-alt-bg-color:#f3f5f6;--primary-alt-text-color:#0071a1;--primary-alt-border-color:#0071a1}*{box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}ol,ul{margin-top:0;margin-bottom:10px}:after,:before{box-sizing:border-box}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button,input,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{cursor:pointer;color:#337ab7;text-decoration:none;background-color:transparent}.btn-link,a{color:#528ff0}.wp-core-ui select{line-height:2;border-color:#e2e2e2}.pull-right{float:right!important}.ml-30{margin-left:30px!important}.mt-10{margin-top:10px!important}.mt-20{margin-top:20px!important}.p-0{padding:0!important}.ph-5{padding-left:5px!important;padding-right:5px!important}.pv-2{padding-top:2px!important;padding-bottom:2px!important}.thwcfd-wrap div.thwcfd-notice{margin:10px 20px 0 2px}.thwcfd-wrap input[type=number],.thwcfd-wrap input[type=text],.thwcfd-wrap select,.thwcfd-wrap textarea{color:#32373c;line-height:1;min-height:30px;height:36px;width:auto;background-color:#fff;border:1px solid #e2e2e2;border-radius:2px;overflow:hidden;font-size:14px;padding:0 12px;box-shadow:0 0 0 transparent}.thwcfd-wrap textarea{height:auto;overflow:auto;padding:2px 6px;line-height:1.5;resize:vertical}.thwcfd-wrap input[type=number]:disabled,.thwcfd-wrap input[type=text]:disabled,.thwcfd-wrap select:disabled,.thwcfd-wrap textarea:disabled{color:#a0a5aa;border-color:#ddd;background-color:#f7f7f7}.thwcfd-wrap input[type=number]:disabled::placeholder,.thwcfd-wrap input[type=text]:disabled::placeholder,.thwcfd-wrap select:disabled::placeholder,.thwcfd-wrap textarea:disabled::placeholder{color:#a0a5aa}.thwcfd-wrap .btn{display:inline-block;background-image:none;font-size:14px;font-weight:400;text-align:center;vertical-align:middle;white-space:nowrap;cursor:pointer;touch-action:manipulation;line-height:1;border-width:1px;border-style:solid;border-radius:2px;outline:0;margin:0;padding:12px 20px;box-sizing:border-box;-webkit-appearance:none;-webkit-box-sizing:border-box;transition:.1s;-webkit-transition:.1s;-ms-user-select:none;-moz-user-select:none;-webkit-user-select:none;color:var(--primary-alt-text-color);background-color:var(--primary-alt-bg-color);border-color:var(--primary-alt-border-color)}.thwcfd-wrap .btn:hover{opacity:.9}.thwcfd-wrap .btn-small{font-size:13px;padding:8px 10px;border-radius:2px}.thwcfd-wrap .btn-tiny{font-size:13px;padding:5px 5px;border-radius:2px}.thwcfd-wrap .btn-primary{color:#fff;background-color:var(--primary-bg-color);border-color:var(--primary-border-color)}.thwcfd-wrap .btn-primary-alt{color:var(--primary-alt-text-color);background-color:var(--primary-alt-bg-color);border-color:var(--primary-alt-border-color)}.thwcfd-wrap .btn-danger{color:#fff;background-color:#f44336;border-color:#c3352b}.thwcfd-wrap .btn:disabled,.thwcfd-wrap .btn[disabled]{color:#cbcbcb;border-color:#cbcbcb;background-color:#fcfcfc;cursor:default}.thwcfd-checkbox{display:inline-block;max-width:100%;margin-bottom:5px;font-weight:700}.thwcfd-checkbox .cb-input,.thwcfd-radio .rb-input{display:block;height:0;margin:0;opacity:0;line-height:normal;box-sizing:border-box;overflow:hidden}.thwcfd-checkbox .cb-el{width:16px;margin-top:2px;margin-right:8px;height:16px;background:#fff;border-radius:2px;float:left;transition:.3s;cursor:pointer;border:1px solid #ccc}.thwcfd-checkbox .cb-el::after{content:'';display:block;width:6px;height:11px;opacity:0;transition:.2s;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg) scale(1.5);margin:0 0 0 4px}.thwcfd-checkbox .cb-label{font-size:14px;cursor:pointer;white-space:normal;display:inline-block;font-weight:400;vertical-align:middle}.thwcfd-checkbox :checked+.cb-el{background:#528ff0;border-color:#528ff0}.thwcfd-checkbox :checked+.cb-el::after{opacity:1;transform:rotate(45deg)}.thwcfd-input-wrap{font-weight:400;display:block;margin:24px 0 8px;position:relative}.thwcfd-input-wrap .label{float:left;width:172px;text-align:right;margin-bottom:4px;font-weight:700;position:relative}.thwcfd-input-wrap.required .label::after{content:'*';font-size:12px;position:absolute;margin-left:1px;top:0;color:#f05050}.thwcfd-input-wrap .content{margin-left:190px;position:relative}.thwcfd-input-wrap.small .iel-wrapper{width:260px}.thwcfd-input-wrap .thwcfd-inputtext,.thwcfd-input-wrap .thwcfd-select{width:100%}.thpladmin-modal-mask{position:fixed;background-color:rgba(17,30,60,.6);top:0;left:0;width:100%;height:100%;z-index:9999;overflow:scroll;transition:opacity 250ms ease-in-out}.thpladmin-modal-mask{display:none}.thpladmin-modal .modal-container{position:absolute;background:#fff;border-radius:2px;overflow:hidden;left:50%;top:50%;transform:translate(-50%,-50%);width:90%;max-width:960px;min-height:560px;height:80vh;max-height:640px;animation:appear-down 250ms ease-in-out}.thpladmin-modal .modal-close{position:absolute;color:#58666e;font-size:30px;padding:9px 12px 11px;right:8px;top:8px;line-height:20px;cursor:pointer;z-index:10;user-select:none}.thpladmin-modal .form-wizard{max-width:1024px;height:80vh;max-height:640px;min-height:560px;background:#fafafa;position:relative}.thpladmin-modal .wizard aside{padding:24px 0;width:240px;background:#fff;position:absolute;height:100%;border-right:1px solid #eee}.thpladmin-modal .wizard aside p,.thpladmin-modal .wizard aside side-title{padding:0 24px}.thpladmin-modal .wizard aside side-title{font-size:18px;font-weight:700;display:block;margin-bottom:16px}.thpladmin-modal .wizard aside ul{margin:30px 0;padding:0}.thpladmin-modal .wizard aside li{cursor:pointer;list-style:none;padding:10px 24px;margin:4px 0;color:var(--primary-text-color);position:relative}.thpladmin-modal .wizard aside li.text-primary{color:var(--primary-text-color)}.thpladmin-modal .wizard aside li.active{background:var(--primary-bg-color);color:#fff}.thpladmin-modal .wizard aside li.disabled{display:none}.thpladmin-modal .wizard aside li .dashicons{margin-right:6px;line-height:18px;vertical-align:middle}.thpladmin-modal .wizard aside li.active .dashicons::before{color:#fff}.thpladmin-modal .wizard aside li i.i-chevron-right{font-style:normal;color:#fff;position:absolute;right:8px;font-family:dashicons;opacity:0;top:50%;transform:translate(-4px,-50%);transition:.35s}.thpladmin-modal .wizard aside li.active i.i-chevron-right{opacity:1}.thpladmin-modal .form-wizard main{left:0;right:0;padding:30px;position:absolute;bottom:80px;top:0;overflow:auto}.thpladmin-modal .wizard aside~footer,.thpladmin-modal .wizard aside~main{left:240px}.thpladmin-modal .form-wizard main.main-full{bottom:0}.thpladmin-modal .form-wizard main-title{text-transform:uppercase;display:block;font-weight:600;margin-bottom:12px;font-size:14px!important}.thpladmin-modal .form-wizard .sub-title{text-transform:uppercase;font-weight:600;font-size:14px!important}.thpladmin-modal .form-wizard .device-mobile{display:none}.thpladmin-modal .form-wizard .device-desktop{display:inline}.thpladmin-modal .form-wizard footer{left:0;padding:10px 20px;right:0;background:#f6f6f6;border-top:1px solid #e0e0e0;bottom:0;position:absolute;text-align:right;z-index:99999999}.thpladmin-modal .form-wizard footer .Loader{float:left;opacity:0;transition:1s opacity;margin-top:4px;line-height:27px}.thpladmin-modal .form-wizard footer .btn-toolbar>.btn{margin-left:5px}.thpladmin-modal .form-wizard .form{margin-top:0;padding-bottom:0}.thpladmin-modal .form-wizard .data-panel-content{margin-top:30px;padding-bottom:90px}.thwcfd_pp_table{width:100%}.thwcfd_pp_table tr.disabled td.label,.thwcfd_pp_table tr.disabled td.tip{opacity:.5}.thwcfd_pp_table tr.disabled.hide{display:none}.thwcfd_pp_table td{padding:5px 10px}.thwcfd_pp_table.compact td{padding:3px 10px}.thwcfd_pp_table td.h-separator{padding:20px 0!important}.thwcfd_pp_table td.h-separator span{display:block;height:2px;border-top:1px dashed #e6e6e6}.thwcfd_pp_table td.label{width:25%;text-align:right;padding-right:0;font-weight:700}.thwcfd_pp_table td.tip{width:16px;text-align:center;padding:0}.thwcfd_pp_table td.field{padding-left:0}.thwcfd_pp_table input[type=number],.thwcfd_pp_table input[type=text],.thwcfd_pp_table select{width:260px}.thwcfd_pp_table input[type=text].thwcfd-color{width:223px;border-left:0;border-top-left-radius:0;border-bottom-left-radius:0}.thwcfd_pp_table .thpladmin-colorpickpreview{padding:9.5px 15px 8.5px 20px;border:1px solid #e2e2e2;border-radius:2px 0 0 2px;border-right:1;background-color:#fff}.product_page_th_extra_product_options_pro .select2-container .select2-selection{border-radius:2px;border:1px solid #e2e2e2;min-height:36px;padding:0 4px}.thpladmin-options-table{width:100%;margin-bottom:30px}.thpladmin-options-table input[type=text],.thpladmin-options-table select{width:100%;padding:0 6px}.thpladmin-options-table td{padding:2px 0 2px 4px}.thpladmin-options-table td.price{width:70px}.thpladmin-options-table td.price-type{width:110px}.thpladmin-options-table td.action-cell{width:100px}.thpladmin-options-table td.action-cell .btn{margin-left:6px;padding:1px 5px 2px 5px;font-size:18px;line-height:1}.thpladmin-options-table td.action-cell span.sort{cursor:move;font-size:18px;padding:0 1px 1px 1px;border-color:#999}.thpladmin-options-table td.action-cell span.sort::before{content:'\f333';content:'\f228';font-family:Dashicons;text-align:center;vertical-align:middle;line-height:1;color:#999}.thwcfd_tooltip{float:right;display:inline;position:relative;font-size:12px;height:100%;z-index:99999999}.thwcfd_tooltip img{padding:0;vertical-align:middle;cursor:help;border:medium none;height:16px;width:16px}.thwcfd_tooltip:hover:after{background:#333;background:#000;border-radius:5px;bottom:26px;color:#fff;content:attr(title);left:-100px;padding:10px 15px;position:absolute;z-index:9998;width:350px}.thwcfd_tooltip:hover:before{border:solid;border-color:#000 transparent;border-width:6px 6px 0 6px;bottom:20px;content:"";left:50%;position:absolute;z-index:9999}.thwcfd-settings-table{width:100%}.thwcfd-settings-table td{padding:5px 0}.thwcfd-settings-table td.section-title{padding:30px 0 5px 0;text-align:left;font-weight:700;text-transform:capitalize;border-bottom:1px dashed #cecece}.thwcfd-settings-table td.label{width:22%;text-align:left;padding-right:0;font-weight:400}.thwcfd-settings-table td.label span{display:block}.thwcfd-settings-table td.label .description{font-size:.9em}.thwcfd-settings-table td.tip{width:16px;text-align:center;padding:0}.thwcfd-settings-table td.field{padding-left:0}.thwcfd-settings-table textarea{width:90%;font-size:.9em}.iris-picker{z-index:100;display:none;position:absolute!important;border:1px solid #ccc;border-radius:3px;box-shadow:0 1px 3px rgba(0,0,0,.2)}.iris-picker .ui-slider{border:0!important;margin:0!important;width:auto!important;height:auto!important;background:0 0!important}.iris-picker .ui-slider .ui-slider-handle{margin-bottom:0!important}.thpladmin-colorpickpreview{padding:7px 10px 7px 20px;border:1px solid #7e8993;border-radius:4px;border-right:1;background-color:#fff;border-top-right-radius:0;border-bottom-right-radius:0}.thwcfd-wrap .thpladmin-colorpick{border-left:0!important;margin-left:0!important;border-top-left-radius:0!important;border-bottom-left-radius:0!important}.select2-drop-mask{z-index:99999998!important}.select2-drop{z-index:99999999!important}.select2-container{z-index:99999999!important}.select2-container .select2-search--inline .select2-search__field{margin-top:0!important;margin-bottom:0!important;border:0!important}.select2-container .select2-search__field{min-width:0!important;background-image:none!important}.select2-results .select2-results__group{margin:0!important;padding:4px!important}.select2-results .select2-results__option{margin:0!important;padding:4px 4px 4px 8px!important;font-size:.9em}.thwcfd-wrap .select2-container .select2-selection{border-radius:2px!important;border:1px solid #e2e2e2!important;min-height:36px!important;padding:0 4px!important}.thwcfd-wrap .select2-container--default .select2-selection--multiple .select2-selection__rendered{padding:0 0!important}.thwcfd-wrap .select2-container--default .select2-selection--multiple .select2-selection__rendered li{font-size:.8em!important;margin:4px 4px 0 0!important}.thwcfd-wrap .select2-container--default .select2-selection--multiple .select2-selection__rendered li.select2-search{margin:0!important;height:26px!important;width:auto!important}
|
{assets → admin/assets}/css/tick.png
RENAMED
File without changes
|
{assets → admin/assets}/css/upgrade-btn.png
RENAMED
File without changes
|
admin/assets/js/thwcfd-admin.js
ADDED
@@ -0,0 +1,921 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var thwcfd_base = (function($, window, document) {
|
2 |
+
'use strict';
|
3 |
+
|
4 |
+
function escapeHTML(html) {
|
5 |
+
var fn = function(tag) {
|
6 |
+
var charsToReplace = {
|
7 |
+
'&': '&',
|
8 |
+
'<': '<',
|
9 |
+
'>': '>',
|
10 |
+
'"': '"'
|
11 |
+
};
|
12 |
+
return charsToReplace[tag] || tag;
|
13 |
+
}
|
14 |
+
return html.replace(/[&<>"]/g, fn);
|
15 |
+
}
|
16 |
+
|
17 |
+
function decodeHtml(str) {
|
18 |
+
if(str && typeof(str) === 'string'){
|
19 |
+
var map = {
|
20 |
+
'&': '&',
|
21 |
+
'<': '<',
|
22 |
+
'>': '>',
|
23 |
+
'"': '"',
|
24 |
+
''': "'"
|
25 |
+
};
|
26 |
+
return str.replace(/&|<|>|"|'/g, function(m) {return map[m];});
|
27 |
+
}
|
28 |
+
return str;
|
29 |
+
}
|
30 |
+
|
31 |
+
function isHtmlIdValid(id) {
|
32 |
+
//var re = /^[a-z]+[a-z0-9\_]*$/;
|
33 |
+
var re = /^[a-z\_]+[a-z0-9\_]*$/;
|
34 |
+
// if(wcfe_var.sanitize_names == false){
|
35 |
+
// re = /^[a-zA-Z\_]+[a-zA-Z0-9\_]*$/;
|
36 |
+
// }
|
37 |
+
return re.test(id.trim());
|
38 |
+
}
|
39 |
+
|
40 |
+
function isValidHexColor(value) {
|
41 |
+
if ( preg_match( '/^#[a-f0-9]{6}$/i', value ) ) { // if user insert a HEX color with #
|
42 |
+
return true;
|
43 |
+
}
|
44 |
+
return false;
|
45 |
+
}
|
46 |
+
|
47 |
+
function is_option_field(type){
|
48 |
+
var result = false;
|
49 |
+
if(type == 'select' || type == 'multiselect' || type == 'radio' || type == 'checkboxgroup'){
|
50 |
+
result = true;
|
51 |
+
}
|
52 |
+
return result;
|
53 |
+
}
|
54 |
+
|
55 |
+
function setup_tiptip_tooltips(){
|
56 |
+
var tiptip_args = {
|
57 |
+
'attribute': 'data-tip',
|
58 |
+
'fadeIn': 50,
|
59 |
+
'fadeOut': 50,
|
60 |
+
'delay': 200
|
61 |
+
};
|
62 |
+
|
63 |
+
$('.tips').tipTip( tiptip_args );
|
64 |
+
}
|
65 |
+
|
66 |
+
function setup_enhanced_multi_select(parent){
|
67 |
+
parent.find('select.thwcfd-enhanced-multi-select').each(function(){
|
68 |
+
if(!$(this).hasClass('enhanced')){
|
69 |
+
$(this).selectWoo({
|
70 |
+
//minimumResultsForSearch: 10,
|
71 |
+
allowClear : true,
|
72 |
+
placeholder: $(this).data('placeholder')
|
73 |
+
}).addClass('enhanced');
|
74 |
+
}
|
75 |
+
});
|
76 |
+
}
|
77 |
+
|
78 |
+
function setup_enhanced_multi_select_with_value(parent){
|
79 |
+
parent.find('select.thwcfd-enhanced-multi-select').each(function(){
|
80 |
+
if(!$(this).hasClass('enhanced')){
|
81 |
+
$(this).selectWoo({
|
82 |
+
//minimumResultsForSearch: 10,
|
83 |
+
allowClear : true,
|
84 |
+
placeholder: $(this).data('placeholder')
|
85 |
+
}).addClass('enhanced');
|
86 |
+
|
87 |
+
var value = $(this).data('value');
|
88 |
+
value = value.split(",");
|
89 |
+
|
90 |
+
$(this).val(value);
|
91 |
+
$(this).trigger('change');
|
92 |
+
}
|
93 |
+
});
|
94 |
+
}
|
95 |
+
|
96 |
+
function setup_color_picker(form){
|
97 |
+
form.find('.thpladmin-colorpick').iris({
|
98 |
+
change: function( event, ui ) {
|
99 |
+
$( this ).parent().find( '.thpladmin-colorpickpreview' ).css({ backgroundColor: ui.color.toString() });
|
100 |
+
},
|
101 |
+
hide: true,
|
102 |
+
border: true
|
103 |
+
}).click( function() {
|
104 |
+
$('.iris-picker').hide();
|
105 |
+
$(this ).closest('td').find('.iris-picker').show();
|
106 |
+
});
|
107 |
+
|
108 |
+
$('body').click( function() {
|
109 |
+
$('.iris-picker').hide();
|
110 |
+
});
|
111 |
+
|
112 |
+
$('.thpladmin-colorpick').click( function( event ) {
|
113 |
+
event.stopPropagation();
|
114 |
+
});
|
115 |
+
}
|
116 |
+
|
117 |
+
function setup_color_pick_preview(form){
|
118 |
+
form.find('.thpladmin-colorpick').each(function(){
|
119 |
+
$(this).parent().find('.thpladmin-colorpickpreview').css({ backgroundColor: this.value });
|
120 |
+
});
|
121 |
+
}
|
122 |
+
|
123 |
+
function prepare_field_order_indexes(elm) {
|
124 |
+
$(elm+" tbody tr").each(function(index, el){
|
125 |
+
$('input.f_order', el).val( parseInt( $(el).index(elm+" tbody tr") ) );
|
126 |
+
});
|
127 |
+
}
|
128 |
+
|
129 |
+
function setup_sortable_table(parent, elm, left){
|
130 |
+
parent.find(elm+" tbody").sortable({
|
131 |
+
items:'tr',
|
132 |
+
cursor:'move',
|
133 |
+
axis:'y',
|
134 |
+
handle: '.sort',
|
135 |
+
scrollSensitivity:40,
|
136 |
+
helper:function(e,ui){
|
137 |
+
ui.children().each(function(){
|
138 |
+
$(this).width($(this).width());
|
139 |
+
});
|
140 |
+
ui.css('left', left);
|
141 |
+
return ui;
|
142 |
+
}
|
143 |
+
});
|
144 |
+
|
145 |
+
$(elm+" tbody").on("sortstart", function( event, ui ){
|
146 |
+
ui.item.css('background-color','#f6f6f6');
|
147 |
+
});
|
148 |
+
$(elm+" tbody").on("sortstop", function( event, ui ){
|
149 |
+
ui.item.removeAttr('style');
|
150 |
+
prepare_field_order_indexes(elm);
|
151 |
+
});
|
152 |
+
}
|
153 |
+
|
154 |
+
function get_property_field_value(form, type, name){
|
155 |
+
var value = '';
|
156 |
+
|
157 |
+
switch(type) {
|
158 |
+
case 'select':
|
159 |
+
value = form.find("select[name=i_"+name+"]").val();
|
160 |
+
value = value == null ? '' : value;
|
161 |
+
break;
|
162 |
+
|
163 |
+
case 'checkbox':
|
164 |
+
value = form.find("input[name=i_"+name+"]").prop('checked');
|
165 |
+
value = value ? 1 : 0;
|
166 |
+
break;
|
167 |
+
|
168 |
+
case 'textarea':
|
169 |
+
value = form.find("textarea[name=i_"+name+"]").val();
|
170 |
+
value = value == null ? '' : value;
|
171 |
+
break;
|
172 |
+
|
173 |
+
default:
|
174 |
+
value = form.find("input[name=i_"+name+"]").val();
|
175 |
+
value = value == null ? '' : value;
|
176 |
+
}
|
177 |
+
|
178 |
+
return value;
|
179 |
+
}
|
180 |
+
|
181 |
+
function set_property_field_value(form, type, name, value, multiple){
|
182 |
+
switch(type) {
|
183 |
+
case 'select':
|
184 |
+
if(multiple == 1){
|
185 |
+
value = typeof(value) === 'string' ? value.split(",") : value;
|
186 |
+
name = name+"[]";
|
187 |
+
form.find('select[name="i_'+name+'"]').val(value).trigger("change");
|
188 |
+
}else{
|
189 |
+
form.find('select[name="i_'+name+'"]').val(value);
|
190 |
+
}
|
191 |
+
break;
|
192 |
+
|
193 |
+
case 'checkbox':
|
194 |
+
value = value == 1 || value == 'yes' ? true : false;
|
195 |
+
form.find("input[name=i_"+name+"]").prop('checked', value);
|
196 |
+
break;
|
197 |
+
|
198 |
+
case 'textarea':
|
199 |
+
value = value ? decodeHtml(value) : value;
|
200 |
+
form.find("textarea[name=i_"+name+"]").val(value);
|
201 |
+
break;
|
202 |
+
|
203 |
+
case 'colorpicker':
|
204 |
+
var bg_color = value ? { backgroundColor: value } : {};
|
205 |
+
form.find("input[name=i_"+name+"]").val(value);
|
206 |
+
form.find("."+name+"_preview").css(bg_color);
|
207 |
+
break;
|
208 |
+
|
209 |
+
default:
|
210 |
+
value = value ? decodeHtml(value) : value;
|
211 |
+
form.find("input[name=i_"+name+"]").val(value);
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
/*-------------------------------------------
|
216 |
+
*---- POPUP WIZARD FUNCTIONS - SATRT -------
|
217 |
+
*------------------------------------------*/
|
218 |
+
var active_tab = 0;
|
219 |
+
|
220 |
+
function setup_form_wizard(){
|
221 |
+
$('.pp_nav_links > li').click(function(){
|
222 |
+
var index = $(this).data('index');
|
223 |
+
var popup = $(this).closest('.thpladmin-modal-mask');
|
224 |
+
|
225 |
+
open_tab(popup, $(this), index);
|
226 |
+
active_tab = index;
|
227 |
+
});
|
228 |
+
}
|
229 |
+
|
230 |
+
function get_popup(elm){
|
231 |
+
return $(elm).closest('.thpladmin-modal-mask');
|
232 |
+
}
|
233 |
+
|
234 |
+
function get_active_tab(popup){
|
235 |
+
return popup.find('ul.pp_nav_links').find('li.active')
|
236 |
+
}
|
237 |
+
|
238 |
+
function get_next_tab_index(elm){
|
239 |
+
var popup = get_popup(elm);
|
240 |
+
var active = get_active_tab(popup);
|
241 |
+
|
242 |
+
var link = active.nextAll("li").not(".disabled").first();
|
243 |
+
var index = link.length ? link.data('index') : active_tab;
|
244 |
+
return index;
|
245 |
+
}
|
246 |
+
|
247 |
+
function get_prev_tab_index(elm){
|
248 |
+
var popup = get_popup(elm);
|
249 |
+
var active = get_active_tab(popup);
|
250 |
+
|
251 |
+
var link = active.prevAll("li").not(".disabled").first();
|
252 |
+
var index = link.length ? link.data('index') : active_tab;
|
253 |
+
return index;
|
254 |
+
}
|
255 |
+
|
256 |
+
function form_wizard_open(popup){
|
257 |
+
active_tab = 0;
|
258 |
+
popup.find('ul.pp_nav_links li').first().click();
|
259 |
+
popup.css("display", "block");
|
260 |
+
}
|
261 |
+
|
262 |
+
function form_wizard_close(elm) {
|
263 |
+
var popup = get_popup(elm);
|
264 |
+
popup.css("display", "none");
|
265 |
+
active_tab = 0;
|
266 |
+
}
|
267 |
+
|
268 |
+
function form_wizard_next(elm){
|
269 |
+
active_tab = get_next_tab_index(elm);
|
270 |
+
move_to(elm, active_tab);
|
271 |
+
}
|
272 |
+
|
273 |
+
function form_wizard_previous(elm){
|
274 |
+
active_tab = get_prev_tab_index(elm);
|
275 |
+
move_to(elm, active_tab);
|
276 |
+
}
|
277 |
+
|
278 |
+
function form_wizard_start(elm){
|
279 |
+
active_tab = 0;
|
280 |
+
move_to(elm, active_tab);
|
281 |
+
}
|
282 |
+
|
283 |
+
function move_to(elm, index){
|
284 |
+
var popup = get_popup(elm);
|
285 |
+
var link = popup.find('*[data-index="'+index+'"]');
|
286 |
+
open_tab(popup, link, index);
|
287 |
+
}
|
288 |
+
|
289 |
+
function open_tab(popup, link, index){
|
290 |
+
var panel = popup.find('.data_panel_'+index);
|
291 |
+
|
292 |
+
close_all_data_panel(popup);
|
293 |
+
link.addClass('active');
|
294 |
+
panel.css("display", "block");
|
295 |
+
|
296 |
+
enable_disable_btns(popup, link);
|
297 |
+
}
|
298 |
+
|
299 |
+
function close_all_data_panel(popup){
|
300 |
+
popup.find('.pp_nav_links > li').removeClass('active');
|
301 |
+
popup.find('.data-panel').css("display", "none");
|
302 |
+
}
|
303 |
+
|
304 |
+
function enable_disable_tab(popup, index, disable){
|
305 |
+
var link = popup.find('*[data-index="'+index+'"]');
|
306 |
+
var panel = popup.find('.data_panel_'+index);
|
307 |
+
|
308 |
+
if(disable){
|
309 |
+
link.addClass('disabled');
|
310 |
+
panel.find(":input").attr("disabled", true);
|
311 |
+
//panel.css("display", "none");
|
312 |
+
}else{
|
313 |
+
link.removeClass('disabled');
|
314 |
+
panel.find(":input").attr("disabled", false);
|
315 |
+
//panel.css("display", "block");
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
function form_wizard_enable_tab(popup, index){
|
320 |
+
enable_disable_tab(popup, index, 0);
|
321 |
+
}
|
322 |
+
function form_wizard_disable_tab(popup, index){
|
323 |
+
enable_disable_tab(popup, index, 1);
|
324 |
+
}
|
325 |
+
function form_wizard_enable_all_tabs(popup){
|
326 |
+
popup.find('.pp_nav_links > li').removeClass('disabled');
|
327 |
+
}
|
328 |
+
|
329 |
+
function enable_disable_btns(popup, link){
|
330 |
+
var nextBtn = popup.find('.next-btn');
|
331 |
+
var prevBtn = popup.find('.prev-btn');
|
332 |
+
var nextBtnTxt = 'Save & Next';
|
333 |
+
|
334 |
+
if(link.hasClass('first')){
|
335 |
+
nextBtn.prop( "disabled", false );
|
336 |
+
prevBtn.prop( "disabled", true );
|
337 |
+
}else if(link.hasClass('last')){
|
338 |
+
nextBtn.prop( "disabled", true );
|
339 |
+
prevBtn.prop( "disabled", false );
|
340 |
+
nextBtnTxt = 'Save & Close';
|
341 |
+
}else{
|
342 |
+
nextBtn.prop( "disabled", false );
|
343 |
+
prevBtn.prop( "disabled", false );
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
/*-------------------------------------------
|
348 |
+
*---- POPUP WIZARD FUNCTIONS - END ---------
|
349 |
+
*------------------------------------------*/
|
350 |
+
|
351 |
+
return {
|
352 |
+
escapeHTML : escapeHTML,
|
353 |
+
decodeHtml : decodeHtml,
|
354 |
+
isHtmlIdValid : isHtmlIdValid,
|
355 |
+
isValidHexColor : isValidHexColor,
|
356 |
+
is_option_field : is_option_field,
|
357 |
+
setup_tiptip_tooltips : setup_tiptip_tooltips,
|
358 |
+
setupEnhancedMultiSelect : setup_enhanced_multi_select,
|
359 |
+
setupEnhancedMultiSelectWithValue : setup_enhanced_multi_select_with_value,
|
360 |
+
setupColorPicker : setup_color_picker,
|
361 |
+
setup_color_pick_preview : setup_color_pick_preview,
|
362 |
+
setupSortableTable : setup_sortable_table,
|
363 |
+
get_property_field_value : get_property_field_value,
|
364 |
+
set_property_field_value : set_property_field_value,
|
365 |
+
|
366 |
+
setup_form_wizard : setup_form_wizard,
|
367 |
+
form_wizard_open : form_wizard_open,
|
368 |
+
form_wizard_close : form_wizard_close,
|
369 |
+
form_wizard_next : form_wizard_next,
|
370 |
+
form_wizard_previous : form_wizard_previous,
|
371 |
+
form_wizard_start : form_wizard_start,
|
372 |
+
form_wizard_enable_tab : form_wizard_enable_tab,
|
373 |
+
form_wizard_disable_tab : form_wizard_disable_tab,
|
374 |
+
form_wizard_enable_all_tabs : form_wizard_enable_all_tabs,
|
375 |
+
};
|
376 |
+
}(window.jQuery, window, document));
|
377 |
+
|
378 |
+
function thwcfdSetupEnhancedMultiSelectWithValue(elm){
|
379 |
+
thwcfd_base.setupEnhancedMultiSelectWithValue(elm);
|
380 |
+
}
|
381 |
+
|
382 |
+
function thwcfdSetupSortableTable(parent, elm, left){
|
383 |
+
thwcfd_base.setupSortableTable(parent, elm, left);
|
384 |
+
}
|
385 |
+
|
386 |
+
function thwcfdCloseModal(elm){
|
387 |
+
thwcfd_base.form_wizard_close(elm);
|
388 |
+
}
|
389 |
+
function thwcfdWizardNext(elm){
|
390 |
+
thwcfd_base.form_wizard_next(elm);
|
391 |
+
}
|
392 |
+
function thwcfdWizardPrevious(elm){
|
393 |
+
thwcfd_base.form_wizard_previous(elm);
|
394 |
+
}
|
395 |
+
|
396 |
+
var thwcfd_settings_field = (function($, window, document) {
|
397 |
+
'use strict';
|
398 |
+
|
399 |
+
var MSG_INVALID_NAME = 'NAME/ID must begin with a lowercase letter ([a-z]) or underscores ("_") and may be followed by any number of lowercase letters, digits ([0-9]) and underscores ("_")';
|
400 |
+
var SPECIAL_FIELD_TYPES = ["country", "state", "city"];
|
401 |
+
|
402 |
+
var FIELD_FORM_PROPS = {
|
403 |
+
name : {name : 'name', type : 'text'},
|
404 |
+
type : {name : 'type', type : 'select'},
|
405 |
+
|
406 |
+
label : {name : 'label', type : 'text'},
|
407 |
+
default : {name : 'default', type : 'text'},
|
408 |
+
placeholder : {name : 'placeholder', type : 'text'},
|
409 |
+
class : {name : 'class', type : 'text'},
|
410 |
+
validate : {name : 'validate', type : 'select', multiple : 1 },
|
411 |
+
|
412 |
+
required : {name : 'required', type : 'checkbox'},
|
413 |
+
enabled : {name : 'enabled', type : 'checkbox'},
|
414 |
+
|
415 |
+
show_in_email : {name : 'show_in_email', type : 'checkbox'},
|
416 |
+
show_in_order : {name : 'show_in_order', type : 'checkbox'},
|
417 |
+
};
|
418 |
+
|
419 |
+
var FIELDS_TO_HIDE = {
|
420 |
+
radio : ['placeholder', 'validate'],
|
421 |
+
select : ['validate'],
|
422 |
+
};
|
423 |
+
|
424 |
+
function open_new_field_form(sname){
|
425 |
+
open_field_form('new', false, sname);
|
426 |
+
}
|
427 |
+
|
428 |
+
function open_edit_field_form(elm, rowId){
|
429 |
+
open_field_form('edit', elm, false);
|
430 |
+
}
|
431 |
+
|
432 |
+
function open_copy_field_form(elm, rowId){
|
433 |
+
open_field_form('copy', elm, false);
|
434 |
+
}
|
435 |
+
|
436 |
+
function open_field_form(type, elm, sname){
|
437 |
+
var popup = $("#thwcfd_field_form_pp");
|
438 |
+
var form = $("#thwcfd_field_form");
|
439 |
+
|
440 |
+
populate_field_form(popup, form, type, elm, sname);
|
441 |
+
|
442 |
+
thwcfd_base.form_wizard_open(popup);
|
443 |
+
//thwcfd_base.setup_color_pick_preview(form);
|
444 |
+
}
|
445 |
+
|
446 |
+
function populate_field_form(popup, form, action, elm, sname){
|
447 |
+
var title = action === 'edit' ? 'Edit Field' : 'New Field';
|
448 |
+
popup.find('.wizard-title').text(title);
|
449 |
+
|
450 |
+
form.find('.err_msgs').html('');
|
451 |
+
form.find("input[name=f_action]").val(action);
|
452 |
+
|
453 |
+
if(action === 'new'){
|
454 |
+
if(sname == 'billing' || sname == 'shipping' || sname == 'additional'){
|
455 |
+
sname = sname+'_';
|
456 |
+
}
|
457 |
+
|
458 |
+
clear_field_form_general(form);
|
459 |
+
//clear_field_form_display(form);
|
460 |
+
form.find("select[name=i_type]").change();
|
461 |
+
|
462 |
+
thwcfd_base.set_property_field_value(form, 'text', 'name', sname, 0);
|
463 |
+
thwcfd_base.set_property_field_value(form, 'text', 'class', 'form-row-wide', 0);
|
464 |
+
|
465 |
+
}else{
|
466 |
+
var row = $(elm).closest('tr');
|
467 |
+
var props_json = row.find(".f_props").val();
|
468 |
+
var props = JSON.parse(props_json);
|
469 |
+
|
470 |
+
populate_field_form_general(action, form, props);
|
471 |
+
form.find("select[name=i_type]").change();
|
472 |
+
populate_field_form_props(form, row, props);
|
473 |
+
}
|
474 |
+
}
|
475 |
+
|
476 |
+
function clear_field_form_general(form){
|
477 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'autocomplete', '', 0);
|
478 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'priority', '', 0);
|
479 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'custom', '', 0);
|
480 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'oname', '', 0);
|
481 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'otype', '', 0);
|
482 |
+
|
483 |
+
thwcfd_base.set_property_field_value(form, 'select', 'type', 'text', 0);
|
484 |
+
thwcfd_base.set_property_field_value(form, 'text', 'name', '', 0);
|
485 |
+
/*
|
486 |
+
thwcfd_base.set_property_field_value(form, 'text', 'label', '', 0);
|
487 |
+
thwcfd_base.set_property_field_value(form, 'text', 'placeholder', '', 0);
|
488 |
+
thwcfd_base.set_property_field_value(form, 'text', 'default', '', 0);
|
489 |
+
thwcfd_base.set_property_field_value(form, 'text', 'class', '', 0);
|
490 |
+
thwcfd_base.set_property_field_value(form, 'select', 'validate', '', 1);
|
491 |
+
|
492 |
+
thwcfd_base.set_property_field_value(form, 'checkbox', 'required', 1, 0);
|
493 |
+
thwcfd_base.set_property_field_value(form, 'checkbox', 'enabled', 1, 0);
|
494 |
+
thwcfd_base.set_property_field_value(form, 'checkbox', 'show_in_email', 1, 0);
|
495 |
+
thwcfd_base.set_property_field_value(form, 'checkbox', 'show_in_order', 1, 0);
|
496 |
+
*/
|
497 |
+
}
|
498 |
+
|
499 |
+
/*
|
500 |
+
function clear_field_form_display(form){
|
501 |
+
thwcfd_base.set_property_field_value(form, 'text', 'class', '', 0);
|
502 |
+
thwcfd_base.set_property_field_value(form, 'checkbox', 'show_in_email', 1, 0);
|
503 |
+
thwcfd_base.set_property_field_value(form, 'checkbox', 'show_in_order', 1, 0);
|
504 |
+
}
|
505 |
+
*/
|
506 |
+
|
507 |
+
function populate_field_form_general(action, form, props){
|
508 |
+
var autocomplete = props['autocomplete'] ? props['autocomplete'] : '';
|
509 |
+
var priority = props['priority'] ? props['priority'] : '';
|
510 |
+
var custom = props['custom'] ? props['custom'] : '';
|
511 |
+
|
512 |
+
var type = props['type'] ? props['type'] : 'text';
|
513 |
+
var name = props['name'] ? props['name'] : '';
|
514 |
+
|
515 |
+
if(action === 'copy'){
|
516 |
+
name = '';
|
517 |
+
}
|
518 |
+
|
519 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'autocomplete', autocomplete, 0);
|
520 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'priority', priority, 0);
|
521 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'custom', custom, 0);
|
522 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'oname', name, 0);
|
523 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'otype', type, 0);
|
524 |
+
|
525 |
+
thwcfd_base.set_property_field_value(form, 'select', 'type', type, 0);
|
526 |
+
thwcfd_base.set_property_field_value(form, 'text', 'name', name, 0);
|
527 |
+
|
528 |
+
// if(type == "country" || type == "state" || type == "city"){
|
529 |
+
// form.find("select[name=i_type]").prop('disabled', true);
|
530 |
+
// }else{
|
531 |
+
// form.find("select[name=i_type]").prop('disabled', false);
|
532 |
+
// }
|
533 |
+
}
|
534 |
+
|
535 |
+
function populate_field_form_props(form, row, props){
|
536 |
+
var ftype = props.type;
|
537 |
+
var custom = props['custom'] ? props['custom'] : '';
|
538 |
+
|
539 |
+
$.each( FIELD_FORM_PROPS, function( name, field ) {
|
540 |
+
if(name == 'name' || name == 'type') {
|
541 |
+
return true;
|
542 |
+
}
|
543 |
+
|
544 |
+
var type = field['type'];
|
545 |
+
var value = props && props[name] ? props[name] : '';
|
546 |
+
|
547 |
+
if(ftype == 'textarea' && name == 'value'){
|
548 |
+
type = "textarea";
|
549 |
+
}
|
550 |
+
|
551 |
+
thwcfd_base.set_property_field_value(form, type, name, value, field['multiple']);
|
552 |
+
|
553 |
+
if(type == 'select'){
|
554 |
+
name = field['multiple'] == 1 ? name+"[]" : name;
|
555 |
+
|
556 |
+
if(field['multiple'] == 1 || field['change'] == 1){
|
557 |
+
form.find('select[name="i_'+name+'"]').trigger("change");
|
558 |
+
}
|
559 |
+
}else if(type == 'checkbox'){
|
560 |
+
if(field['change'] == 1){
|
561 |
+
form.find('input[name="i_'+name+'"]').trigger("change");
|
562 |
+
}
|
563 |
+
}
|
564 |
+
});
|
565 |
+
|
566 |
+
var optionsJson = row.find(".f_options").val();
|
567 |
+
populate_options_list(form, optionsJson);
|
568 |
+
|
569 |
+
if(custom == 1){
|
570 |
+
form.find("input[name=i_name]").prop('disabled', false);
|
571 |
+
form.find("select[name=i_type]").prop('disabled', false);
|
572 |
+
form.find("input[name=i_show_in_email]").prop('disabled', false);
|
573 |
+
form.find("input[name=i_show_in_order]").prop('disabled', false);
|
574 |
+
}else{
|
575 |
+
thwcfd_base.set_property_field_value(form, 'checkbox', 'show_in_email', true, 0);
|
576 |
+
thwcfd_base.set_property_field_value(form, 'checkbox', 'show_in_order', true, 0);
|
577 |
+
|
578 |
+
form.find("input[name=i_name]").prop('disabled', true);
|
579 |
+
form.find("select[name=i_type]").prop('disabled', true);
|
580 |
+
form.find("input[name=i_show_in_email]").prop('disabled', true);
|
581 |
+
form.find("input[name=i_show_in_order]").prop('disabled', true);
|
582 |
+
form.find("input[name=i_label]").focus();
|
583 |
+
}
|
584 |
+
}
|
585 |
+
|
586 |
+
function field_type_change_listner(elm){
|
587 |
+
var popup = $("#thwcfd_field_form_pp");
|
588 |
+
var form = $(elm).closest('form');
|
589 |
+
var type = $(elm).val();
|
590 |
+
|
591 |
+
type = type == null ? 'text' : type;
|
592 |
+
form.find('.thwcfd_field_form_tab_general_placeholder').html($('#thwcfd_field_form_id_'+type).html());
|
593 |
+
|
594 |
+
enable_all_tabs_and_fields(popup, form);
|
595 |
+
|
596 |
+
if(type in FIELDS_TO_HIDE){
|
597 |
+
$.each(FIELDS_TO_HIDE[type], function(index, name) {
|
598 |
+
|
599 |
+
if(FIELD_FORM_PROPS[name]){
|
600 |
+
var f_props = FIELD_FORM_PROPS[name];
|
601 |
+
disable_hide_field(form, f_props['type'], name);
|
602 |
+
}
|
603 |
+
});
|
604 |
+
}
|
605 |
+
|
606 |
+
thwcfd_base.setupEnhancedMultiSelect(form);
|
607 |
+
thwcfd_base.setupColorPicker(form);
|
608 |
+
thwcfd_base.setupSortableTable(form, '.thwcfd-option-list', '100');
|
609 |
+
}
|
610 |
+
|
611 |
+
function enable_all_tabs_and_fields(popup, form){
|
612 |
+
thwcfd_base.form_wizard_enable_all_tabs(popup);
|
613 |
+
form.find(':input').attr("disabled", false);
|
614 |
+
form.find('tr').removeClass('disabled hide');
|
615 |
+
}
|
616 |
+
|
617 |
+
function enable_disable_field(form, type, name, enabled, hide){
|
618 |
+
var elm = null;
|
619 |
+
|
620 |
+
switch(type) {
|
621 |
+
case 'select':
|
622 |
+
elm = form.find('select[name="i_'+name+'"]');
|
623 |
+
if(elm.length == 0){
|
624 |
+
elm = form.find('select[name="i_'+name+'[]"]');
|
625 |
+
}
|
626 |
+
break;
|
627 |
+
|
628 |
+
case 'textarea':
|
629 |
+
elm = form.find("textarea[name=i_"+name+"]");
|
630 |
+
if(elm.length == 0){
|
631 |
+
elm = form.find('textarea[name="i_'+name+'[]"]');
|
632 |
+
}
|
633 |
+
break;
|
634 |
+
|
635 |
+
default:
|
636 |
+
elm = form.find("input[name=i_"+name+"]");
|
637 |
+
if(elm.length == 0){
|
638 |
+
elm = form.find('input[name="i_'+name+'[]"]');
|
639 |
+
}
|
640 |
+
}
|
641 |
+
|
642 |
+
if(elm && elm.length){
|
643 |
+
var rowClass = hide ? 'disabled hide' : 'disabled';
|
644 |
+
|
645 |
+
if(!enabled){
|
646 |
+
elm.attr("disabled", true);
|
647 |
+
elm.closest('tr.form_field_'+name).addClass(rowClass);
|
648 |
+
}else{
|
649 |
+
elm.attr("disabled", false);
|
650 |
+
elm.closest('tr.form_field_'+name).removeClass('disabled hide');
|
651 |
+
}
|
652 |
+
}
|
653 |
+
}
|
654 |
+
function enable_field(form, type, name){
|
655 |
+
enable_disable_field(form, type, name, true, false);
|
656 |
+
}
|
657 |
+
function disable_field(form, type, name){
|
658 |
+
enable_disable_field(form, type, name, false, false);
|
659 |
+
}
|
660 |
+
function disable_hide_field(form, type, name){
|
661 |
+
enable_disable_field(form, type, name, false, true);
|
662 |
+
}
|
663 |
+
|
664 |
+
function save_field(elm){
|
665 |
+
var popup = $("#thwcfd_field_form_pp");
|
666 |
+
var form = $("#thwcfd_field_form");
|
667 |
+
var result = validate_field_form(form, popup);
|
668 |
+
|
669 |
+
if(result){
|
670 |
+
prepare_field_form(form);
|
671 |
+
form.submit();
|
672 |
+
}
|
673 |
+
}
|
674 |
+
|
675 |
+
function validate_field_form(form, popup){
|
676 |
+
var err_msgs = '';
|
677 |
+
|
678 |
+
var fname = thwcfd_base.get_property_field_value(form, 'text', 'name');
|
679 |
+
var ftype = thwcfd_base.get_property_field_value(form, 'select', 'type');
|
680 |
+
var ftitle = thwcfd_base.get_property_field_value(form, 'text', 'label');
|
681 |
+
var fotype = thwcfd_base.get_property_field_value(form, 'hidden', 'otype');
|
682 |
+
|
683 |
+
if(ftype == '' && ($.inArray(fotype, SPECIAL_FIELD_TYPES) == -1) ){
|
684 |
+
err_msgs = 'Type is required';
|
685 |
+
|
686 |
+
}else if(fname == ''){
|
687 |
+
err_msgs = 'Name is required';
|
688 |
+
|
689 |
+
}else if(!thwcfd_base.isHtmlIdValid(fname)){
|
690 |
+
err_msgs = MSG_INVALID_NAME;
|
691 |
+
}
|
692 |
+
|
693 |
+
if(err_msgs != ''){
|
694 |
+
form.find('.err_msgs').html(err_msgs);
|
695 |
+
thwcfd_base.form_wizard_start(popup);
|
696 |
+
return false;
|
697 |
+
}
|
698 |
+
|
699 |
+
return true;
|
700 |
+
}
|
701 |
+
|
702 |
+
function prepare_field_form(form){
|
703 |
+
var options_json = get_options(form);
|
704 |
+
thwcfd_base.set_property_field_value(form, 'hidden', 'options_json', options_json, 0);
|
705 |
+
}
|
706 |
+
/*------------------------------------
|
707 |
+
*---- PRODUCT FIELDS - END ----------
|
708 |
+
*------------------------------------*/
|
709 |
+
|
710 |
+
/*------------------------------------
|
711 |
+
*---- OPTIONS FUNCTIONS - SATRT -----
|
712 |
+
*------------------------------------*/
|
713 |
+
function get_options(form){
|
714 |
+
var optionsKey = form.find("input[name='i_options_key[]']").map(function(){ return $(this).val(); }).get();
|
715 |
+
var optionsText = form.find("input[name='i_options_text[]']").map(function(){ return $(this).val(); }).get();
|
716 |
+
|
717 |
+
var optionsSize = optionsText.length;
|
718 |
+
var optionsArr = [];
|
719 |
+
|
720 |
+
for(var i=0; i<optionsSize; i++){
|
721 |
+
var optionDetails = {};
|
722 |
+
optionDetails["key"] = optionsKey[i];
|
723 |
+
optionDetails["text"] = optionsText[i];
|
724 |
+
|
725 |
+
optionsArr.push(optionDetails);
|
726 |
+
}
|
727 |
+
|
728 |
+
var optionsJson = optionsArr.length > 0 ? JSON.stringify(optionsArr) : '';
|
729 |
+
optionsJson = encodeURIComponent(optionsJson);
|
730 |
+
return optionsJson;
|
731 |
+
}
|
732 |
+
|
733 |
+
function populate_options_list(form, optionsJson){
|
734 |
+
var optionsHtml = "";
|
735 |
+
|
736 |
+
if(optionsJson){
|
737 |
+
try{
|
738 |
+
optionsJson = decodeURIComponent(optionsJson);
|
739 |
+
var optionsList = $.parseJSON(optionsJson);
|
740 |
+
if(optionsList){
|
741 |
+
jQuery.each(optionsList, function() {
|
742 |
+
optionsHtml += prepare_option_row_html(this);
|
743 |
+
});
|
744 |
+
}
|
745 |
+
}catch(err) {
|
746 |
+
console.log(err);
|
747 |
+
}
|
748 |
+
}
|
749 |
+
|
750 |
+
var optionsTable = form.find(".thwcfd-option-list tbody");
|
751 |
+
if(optionsHtml){
|
752 |
+
optionsTable.html(optionsHtml);
|
753 |
+
}else{
|
754 |
+
optionsTable.html(prepare_option_row_html(null));
|
755 |
+
}
|
756 |
+
}
|
757 |
+
|
758 |
+
function prepare_option_row_html(option){
|
759 |
+
var key = '';
|
760 |
+
var text = '';
|
761 |
+
|
762 |
+
if(option){
|
763 |
+
key = option.key ? option.key : '';
|
764 |
+
text = option.text ? option.text : '';
|
765 |
+
}
|
766 |
+
|
767 |
+
var html = '<tr>';
|
768 |
+
html += '<td class="key"><input type="text" name="i_options_key[]" value="'+key+'" placeholder="Option Value"></td>';
|
769 |
+
html += '<td class="value"><input type="text" name="i_options_text[]" value="'+text+'" placeholder="Option Text"></td>';
|
770 |
+
html += '<td class="action-cell">';
|
771 |
+
html += '<a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-tiny btn-primary" title="Add new option">+</a>';
|
772 |
+
html += '<a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-tiny btn-danger" title="Remove option">x</a>';
|
773 |
+
html += '<span class="btn btn-tiny sort ui-sortable-handle"></span></td>';
|
774 |
+
html += '</tr>';
|
775 |
+
|
776 |
+
return html;
|
777 |
+
}
|
778 |
+
|
779 |
+
function add_new_option_row(elm){
|
780 |
+
var ptable = $(elm).closest('table');
|
781 |
+
var optionsSize = ptable.find('tbody tr').size();
|
782 |
+
|
783 |
+
if(optionsSize > 0){
|
784 |
+
ptable.find('tbody tr:last').after(prepare_option_row_html(null));
|
785 |
+
}else{
|
786 |
+
ptable.find('tbody').append(prepare_option_row_html(null));
|
787 |
+
}
|
788 |
+
}
|
789 |
+
|
790 |
+
function remove_option_row(elm){
|
791 |
+
var ptable = $(elm).closest('table');
|
792 |
+
$(elm).closest('tr').remove();
|
793 |
+
var optionsSize = ptable.find('tbody tr').size();
|
794 |
+
|
795 |
+
if(optionsSize == 0){
|
796 |
+
ptable.find('tbody').append(prepare_option_row_html(null));
|
797 |
+
}
|
798 |
+
}
|
799 |
+
/*------------------------------------
|
800 |
+
*---- OPTIONS FUNCTIONS - END -------
|
801 |
+
*------------------------------------*/
|
802 |
+
|
803 |
+
return {
|
804 |
+
openNewFieldForm : open_new_field_form,
|
805 |
+
openEditFieldForm : open_edit_field_form,
|
806 |
+
openCopyFieldForm : open_copy_field_form,
|
807 |
+
fieldTypeChangeListner : field_type_change_listner,
|
808 |
+
addNewOptionRow : add_new_option_row,
|
809 |
+
removeOptionRow : remove_option_row,
|
810 |
+
save_field : save_field,
|
811 |
+
};
|
812 |
+
}(window.jQuery, window, document));
|
813 |
+
|
814 |
+
function thwcfdOpenNewFieldForm(sectionName){
|
815 |
+
thwcfd_settings_field.openNewFieldForm(sectionName);
|
816 |
+
}
|
817 |
+
|
818 |
+
function thwcfdOpenEditFieldForm(elm, rowId){
|
819 |
+
thwcfd_settings_field.openEditFieldForm(elm, rowId);
|
820 |
+
}
|
821 |
+
|
822 |
+
function thwcfdOpenCopyFieldForm(elm, rowId){
|
823 |
+
thwcfd_settings_field.openCopyFieldForm(elm, rowId);
|
824 |
+
}
|
825 |
+
|
826 |
+
function thwcfdFieldTypeChangeListner(elm){
|
827 |
+
thwcfd_settings_field.fieldTypeChangeListner(elm);
|
828 |
+
}
|
829 |
+
|
830 |
+
function thwcfdAddNewOptionRow(elm){
|
831 |
+
thwcfd_settings_field.addNewOptionRow(elm);
|
832 |
+
}
|
833 |
+
function thwcfdRemoveOptionRow(elm){
|
834 |
+
thwcfd_settings_field.removeOptionRow(elm);
|
835 |
+
}
|
836 |
+
|
837 |
+
function thwcfdSaveField(elm){
|
838 |
+
thwcfd_settings_field.save_field(elm);
|
839 |
+
}
|
840 |
+
|
841 |
+
var thwcfd_settings = (function($, window, document) {
|
842 |
+
'use strict';
|
843 |
+
|
844 |
+
$(function() {
|
845 |
+
var settings_form = $('#thwcfd_checkout_fields_form');
|
846 |
+
|
847 |
+
thwcfd_base.setupSortableTable(settings_form, '#thwcfd_checkout_fields', '0');
|
848 |
+
thwcfd_base.setup_tiptip_tooltips();
|
849 |
+
thwcfd_base.setup_form_wizard();
|
850 |
+
});
|
851 |
+
|
852 |
+
|
853 |
+
$( document ).on( 'click', '.thpladmin-notice .notice-dismiss', function() {
|
854 |
+
var wrapper = $(this).closest('div.thpladmin-notice');
|
855 |
+
var nonce = wrapper.data("nonce");
|
856 |
+
var data = {
|
857 |
+
security: nonce,
|
858 |
+
action: 'dismiss_thwcfd_upgrade_notice',
|
859 |
+
};
|
860 |
+
|
861 |
+
$.post( ajaxurl, data, function() {
|
862 |
+
|
863 |
+
});
|
864 |
+
})
|
865 |
+
|
866 |
+
function select_all_fields(elm){
|
867 |
+
var checkAll = $(elm).prop('checked');
|
868 |
+
$('#thwcfd_checkout_fields tbody input:checkbox[name=select_field]').prop('checked', checkAll);
|
869 |
+
}
|
870 |
+
|
871 |
+
function remove_selected_fields(){
|
872 |
+
$('#thwcfd_checkout_fields tbody tr').removeClass('strikeout');
|
873 |
+
$('#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked').each(function () {
|
874 |
+
var row = $(this).closest('tr');
|
875 |
+
if(!row.hasClass("strikeout")){
|
876 |
+
row.addClass("strikeout");
|
877 |
+
}
|
878 |
+
row.find(".f_deleted").val(1);
|
879 |
+
//row.find(".f_edit_btn").prop('disabled', true);
|
880 |
+
});
|
881 |
+
}
|
882 |
+
|
883 |
+
function enable_disable_selected_fields(enabled){
|
884 |
+
$('#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked').each(function(){
|
885 |
+
var row = $(this).closest('tr');
|
886 |
+
if(enabled == 0){
|
887 |
+
if(!row.hasClass("thpladmin-disabled")){
|
888 |
+
row.addClass("thpladmin-disabled");
|
889 |
+
}
|
890 |
+
}else{
|
891 |
+
row.removeClass("thpladmin-disabled");
|
892 |
+
}
|
893 |
+
|
894 |
+
//row.find(".f_edit_btn").prop('disabled', enabled == 1 ? false : true);
|
895 |
+
row.find(".td_enabled").html(enabled == 1 ? '<span class="dashicons dashicons-yes tips" data-tip="Yes"></span>' : '-');
|
896 |
+
row.find(".f_enabled").val(enabled);
|
897 |
+
});
|
898 |
+
}
|
899 |
+
|
900 |
+
return {
|
901 |
+
selectAllFields : select_all_fields,
|
902 |
+
removeSelectedFields : remove_selected_fields,
|
903 |
+
enableDisableSelectedFields : enable_disable_selected_fields,
|
904 |
+
};
|
905 |
+
}(window.jQuery, window, document));
|
906 |
+
|
907 |
+
function thwcfdSelectAllCheckoutFields(elm){
|
908 |
+
thwcfd_settings.selectAllFields(elm);
|
909 |
+
}
|
910 |
+
|
911 |
+
function thwcfdRemoveSelectedFields(){
|
912 |
+
thwcfd_settings.removeSelectedFields();
|
913 |
+
}
|
914 |
+
|
915 |
+
function thwcfdEnableSelectedFields(){
|
916 |
+
thwcfd_settings.enableDisableSelectedFields(1);
|
917 |
+
}
|
918 |
+
|
919 |
+
function thwcfdDisableSelectedFields(){
|
920 |
+
thwcfd_settings.enableDisableSelectedFields(0);
|
921 |
+
}
|
admin/assets/js/thwcfd-admin.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
function thwcfdSetupEnhancedMultiSelectWithValue(elm){thwcfd_base.setupEnhancedMultiSelectWithValue(elm)}function thwcfdSetupSortableTable(parent,elm,left){thwcfd_base.setupSortableTable(parent,elm,left)}function thwcfdCloseModal(elm){thwcfd_base.form_wizard_close(elm)}function thwcfdWizardNext(elm){thwcfd_base.form_wizard_next(elm)}function thwcfdWizardPrevious(elm){thwcfd_base.form_wizard_previous(elm)}function thwcfdOpenNewFieldForm(sectionName){thwcfd_settings_field.openNewFieldForm(sectionName)}function thwcfdOpenEditFieldForm(elm,rowId){thwcfd_settings_field.openEditFieldForm(elm,rowId)}function thwcfdOpenCopyFieldForm(elm,rowId){thwcfd_settings_field.openCopyFieldForm(elm,rowId)}function thwcfdFieldTypeChangeListner(elm){thwcfd_settings_field.fieldTypeChangeListner(elm)}function thwcfdAddNewOptionRow(elm){thwcfd_settings_field.addNewOptionRow(elm)}function thwcfdRemoveOptionRow(elm){thwcfd_settings_field.removeOptionRow(elm)}function thwcfdSaveField(elm){thwcfd_settings_field.save_field(elm)}function thwcfdSelectAllCheckoutFields(elm){thwcfd_settings.selectAllFields(elm)}function thwcfdRemoveSelectedFields(){thwcfd_settings.removeSelectedFields()}function thwcfdEnableSelectedFields(){thwcfd_settings.enableDisableSelectedFields(1)}function thwcfdDisableSelectedFields(){thwcfd_settings.enableDisableSelectedFields(0)}var thwcfd_base=function($,window,document){"use strict";function escapeHTML(html){var fn=function(tag){return{"&":"&","<":"<",">":">",'"':"""}[tag]||tag};return html.replace(/[&<>"]/g,fn)}function decodeHtml(str){if(str&&"string"==typeof str){var map={"&":"&","<":"<",">":">",""":'"',"'":"'"};return str.replace(/&|<|>|"|'/g,function(m){return map[m]})}return str}function isHtmlIdValid(id){return/^[a-z\_]+[a-z0-9\_]*$/.test(id.trim())}function isValidHexColor(value){return!!preg_match("/^#[a-f0-9]{6}$/i",value)}function is_option_field(type){var result=!1;return"select"!=type&&"multiselect"!=type&&"radio"!=type&&"checkboxgroup"!=type||(result=!0),result}function setup_tiptip_tooltips(){var tiptip_args={attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200};$(".tips").tipTip(tiptip_args)}function setup_enhanced_multi_select(parent){parent.find("select.thwcfd-enhanced-multi-select").each(function(){$(this).hasClass("enhanced")||$(this).selectWoo({allowClear:!0,placeholder:$(this).data("placeholder")}).addClass("enhanced")})}function setup_enhanced_multi_select_with_value(parent){parent.find("select.thwcfd-enhanced-multi-select").each(function(){if(!$(this).hasClass("enhanced")){$(this).selectWoo({allowClear:!0,placeholder:$(this).data("placeholder")}).addClass("enhanced");var value=$(this).data("value");value=value.split(","),$(this).val(value),$(this).trigger("change")}})}function setup_color_picker(form){form.find(".thpladmin-colorpick").iris({change:function(event,ui){$(this).parent().find(".thpladmin-colorpickpreview").css({backgroundColor:ui.color.toString()})},hide:!0,border:!0}).click(function(){$(".iris-picker").hide(),$(this).closest("td").find(".iris-picker").show()}),$("body").click(function(){$(".iris-picker").hide()}),$(".thpladmin-colorpick").click(function(event){event.stopPropagation()})}function setup_color_pick_preview(form){form.find(".thpladmin-colorpick").each(function(){$(this).parent().find(".thpladmin-colorpickpreview").css({backgroundColor:this.value})})}function prepare_field_order_indexes(elm){$(elm+" tbody tr").each(function(index,el){$("input.f_order",el).val(parseInt($(el).index(elm+" tbody tr")))})}function setup_sortable_table(parent,elm,left){parent.find(elm+" tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:".sort",scrollSensitivity:40,helper:function(e,ui){return ui.children().each(function(){$(this).width($(this).width())}),ui.css("left",left),ui}}),$(elm+" tbody").on("sortstart",function(event,ui){ui.item.css("background-color","#f6f6f6")}),$(elm+" tbody").on("sortstop",function(event,ui){ui.item.removeAttr("style"),prepare_field_order_indexes(elm)})}function get_property_field_value(form,type,name){var value="";switch(type){case"select":value=form.find("select[name=i_"+name+"]").val(),value=null==value?"":value;break;case"checkbox":value=form.find("input[name=i_"+name+"]").prop("checked"),value=value?1:0;break;case"textarea":value=form.find("textarea[name=i_"+name+"]").val(),value=null==value?"":value;break;default:value=form.find("input[name=i_"+name+"]").val(),value=null==value?"":value}return value}function set_property_field_value(form,type,name,value,multiple){switch(type){case"select":1==multiple?(value="string"==typeof value?value.split(","):value,name+="[]",form.find('select[name="i_'+name+'"]').val(value).trigger("change")):form.find('select[name="i_'+name+'"]').val(value);break;case"checkbox":value=1==value||"yes"==value,form.find("input[name=i_"+name+"]").prop("checked",value);break;case"textarea":value=value?decodeHtml(value):value,form.find("textarea[name=i_"+name+"]").val(value);break;case"colorpicker":var bg_color=value?{backgroundColor:value}:{};form.find("input[name=i_"+name+"]").val(value),form.find("."+name+"_preview").css(bg_color);break;default:value=value?decodeHtml(value):value,form.find("input[name=i_"+name+"]").val(value)}}function setup_form_wizard(){$(".pp_nav_links > li").click(function(){var index=$(this).data("index");open_tab($(this).closest(".thpladmin-modal-mask"),$(this),index),active_tab=index})}function get_popup(elm){return $(elm).closest(".thpladmin-modal-mask")}function get_active_tab(popup){return popup.find("ul.pp_nav_links").find("li.active")}function get_next_tab_index(elm){var popup=get_popup(elm),active=get_active_tab(popup),link=active.nextAll("li").not(".disabled").first();return link.length?link.data("index"):active_tab}function get_prev_tab_index(elm){var popup=get_popup(elm),active=get_active_tab(popup),link=active.prevAll("li").not(".disabled").first();return link.length?link.data("index"):active_tab}function form_wizard_open(popup){active_tab=0,popup.find("ul.pp_nav_links li").first().click(),popup.css("display","block")}function form_wizard_close(elm){get_popup(elm).css("display","none"),active_tab=0}function form_wizard_next(elm){active_tab=get_next_tab_index(elm),move_to(elm,active_tab)}function form_wizard_previous(elm){active_tab=get_prev_tab_index(elm),move_to(elm,active_tab)}function form_wizard_start(elm){active_tab=0,move_to(elm,active_tab)}function move_to(elm,index){var popup=get_popup(elm);open_tab(popup,popup.find('*[data-index="'+index+'"]'),index)}function open_tab(popup,link,index){var panel=popup.find(".data_panel_"+index);close_all_data_panel(popup),link.addClass("active"),panel.css("display","block"),enable_disable_btns(popup,link)}function close_all_data_panel(popup){popup.find(".pp_nav_links > li").removeClass("active"),popup.find(".data-panel").css("display","none")}function enable_disable_tab(popup,index,disable){var link=popup.find('*[data-index="'+index+'"]'),panel=popup.find(".data_panel_"+index);disable?(link.addClass("disabled"),panel.find(":input").attr("disabled",!0)):(link.removeClass("disabled"),panel.find(":input").attr("disabled",!1))}function form_wizard_enable_tab(popup,index){enable_disable_tab(popup,index,0)}function form_wizard_disable_tab(popup,index){enable_disable_tab(popup,index,1)}function form_wizard_enable_all_tabs(popup){popup.find(".pp_nav_links > li").removeClass("disabled")}function enable_disable_btns(popup,link){var nextBtn=popup.find(".next-btn"),prevBtn=popup.find(".prev-btn");link.hasClass("first")?(nextBtn.prop("disabled",!1),prevBtn.prop("disabled",!0)):link.hasClass("last")?(nextBtn.prop("disabled",!0),prevBtn.prop("disabled",!1)):(nextBtn.prop("disabled",!1),prevBtn.prop("disabled",!1))}var active_tab=0;return{escapeHTML:escapeHTML,decodeHtml:decodeHtml,isHtmlIdValid:isHtmlIdValid,isValidHexColor:isValidHexColor,is_option_field:is_option_field,setup_tiptip_tooltips:setup_tiptip_tooltips,setupEnhancedMultiSelect:setup_enhanced_multi_select,setupEnhancedMultiSelectWithValue:setup_enhanced_multi_select_with_value,setupColorPicker:setup_color_picker,setup_color_pick_preview:setup_color_pick_preview,setupSortableTable:setup_sortable_table,get_property_field_value:get_property_field_value,set_property_field_value:set_property_field_value,setup_form_wizard:setup_form_wizard,form_wizard_open:form_wizard_open,form_wizard_close:form_wizard_close,form_wizard_next:form_wizard_next,form_wizard_previous:form_wizard_previous,form_wizard_start:form_wizard_start,form_wizard_enable_tab:form_wizard_enable_tab,form_wizard_disable_tab:form_wizard_disable_tab,form_wizard_enable_all_tabs:form_wizard_enable_all_tabs}}(window.jQuery,window,document),thwcfd_settings_field=function($,window,document){"use strict";function open_new_field_form(sname){open_field_form("new",!1,sname)}function open_edit_field_form(elm,rowId){open_field_form("edit",elm,!1)}function open_copy_field_form(elm,rowId){open_field_form("copy",elm,!1)}function open_field_form(type,elm,sname){var popup=$("#thwcfd_field_form_pp");populate_field_form(popup,$("#thwcfd_field_form"),type,elm,sname),thwcfd_base.form_wizard_open(popup)}function populate_field_form(popup,form,action,elm,sname){var title="edit"===action?"Edit Field":"New Field";if(popup.find(".wizard-title").text(title),form.find(".err_msgs").html(""),form.find("input[name=f_action]").val(action),"new"===action)"billing"!=sname&&"shipping"!=sname&&"additional"!=sname||(sname+="_"),clear_field_form_general(form),form.find("select[name=i_type]").change(),thwcfd_base.set_property_field_value(form,"text","name",sname,0),thwcfd_base.set_property_field_value(form,"text","class","form-row-wide",0);else{var row=$(elm).closest("tr"),props_json=row.find(".f_props").val(),props=JSON.parse(props_json);populate_field_form_general(action,form,props),form.find("select[name=i_type]").change(),populate_field_form_props(form,row,props)}}function clear_field_form_general(form){thwcfd_base.set_property_field_value(form,"hidden","autocomplete","",0),thwcfd_base.set_property_field_value(form,"hidden","priority","",0),thwcfd_base.set_property_field_value(form,"hidden","custom","",0),thwcfd_base.set_property_field_value(form,"hidden","oname","",0),thwcfd_base.set_property_field_value(form,"hidden","otype","",0),thwcfd_base.set_property_field_value(form,"select","type","text",0),thwcfd_base.set_property_field_value(form,"text","name","",0)}function populate_field_form_general(action,form,props){var autocomplete=props.autocomplete?props.autocomplete:"",priority=props.priority?props.priority:"",custom=props.custom?props.custom:"",type=props.type?props.type:"text",name=props.name?props.name:"";"copy"===action&&(name=""),thwcfd_base.set_property_field_value(form,"hidden","autocomplete",autocomplete,0),thwcfd_base.set_property_field_value(form,"hidden","priority",priority,0),thwcfd_base.set_property_field_value(form,"hidden","custom",custom,0),thwcfd_base.set_property_field_value(form,"hidden","oname",name,0),thwcfd_base.set_property_field_value(form,"hidden","otype",type,0),thwcfd_base.set_property_field_value(form,"select","type",type,0),thwcfd_base.set_property_field_value(form,"text","name",name,0)}function populate_field_form_props(form,row,props){var ftype=props.type,custom=props.custom?props.custom:"";$.each(FIELD_FORM_PROPS,function(name,field){if("name"==name||"type"==name)return!0;var type=field.type,value=props&&props[name]?props[name]:"";"textarea"==ftype&&"value"==name&&(type="textarea"),thwcfd_base.set_property_field_value(form,type,name,value,field.multiple),"select"==type?(name=1==field.multiple?name+"[]":name,1!=field.multiple&&1!=field.change||form.find('select[name="i_'+name+'"]').trigger("change")):"checkbox"==type&&1==field.change&&form.find('input[name="i_'+name+'"]').trigger("change")});var optionsJson=row.find(".f_options").val();populate_options_list(form,optionsJson),1==custom?(form.find("input[name=i_name]").prop("disabled",!1),form.find("select[name=i_type]").prop("disabled",!1),form.find("input[name=i_show_in_email]").prop("disabled",!1),form.find("input[name=i_show_in_order]").prop("disabled",!1)):(thwcfd_base.set_property_field_value(form,"checkbox","show_in_email",!0,0),thwcfd_base.set_property_field_value(form,"checkbox","show_in_order",!0,0),form.find("input[name=i_name]").prop("disabled",!0),form.find("select[name=i_type]").prop("disabled",!0),form.find("input[name=i_show_in_email]").prop("disabled",!0),form.find("input[name=i_show_in_order]").prop("disabled",!0),form.find("input[name=i_label]").focus())}function field_type_change_listner(elm){var popup=$("#thwcfd_field_form_pp"),form=$(elm).closest("form"),type=$(elm).val();type=null==type?"text":type,form.find(".thwcfd_field_form_tab_general_placeholder").html($("#thwcfd_field_form_id_"+type).html()),enable_all_tabs_and_fields(popup,form),type in FIELDS_TO_HIDE&&$.each(FIELDS_TO_HIDE[type],function(index,name){if(FIELD_FORM_PROPS[name]){var f_props=FIELD_FORM_PROPS[name];disable_hide_field(form,f_props.type,name)}}),thwcfd_base.setupEnhancedMultiSelect(form),thwcfd_base.setupColorPicker(form),thwcfd_base.setupSortableTable(form,".thwcfd-option-list","100")}function enable_all_tabs_and_fields(popup,form){thwcfd_base.form_wizard_enable_all_tabs(popup),form.find(":input").attr("disabled",!1),form.find("tr").removeClass("disabled hide")}function enable_disable_field(form,type,name,enabled,hide){var elm=null;switch(type){case"select":elm=form.find('select[name="i_'+name+'"]'),0==elm.length&&(elm=form.find('select[name="i_'+name+'[]"]'));break;case"textarea":elm=form.find("textarea[name=i_"+name+"]"),0==elm.length&&(elm=form.find('textarea[name="i_'+name+'[]"]'));break;default:elm=form.find("input[name=i_"+name+"]"),0==elm.length&&(elm=form.find('input[name="i_'+name+'[]"]'))}if(elm&&elm.length){var rowClass=hide?"disabled hide":"disabled";enabled?(elm.attr("disabled",!1),elm.closest("tr.form_field_"+name).removeClass("disabled hide")):(elm.attr("disabled",!0),elm.closest("tr.form_field_"+name).addClass(rowClass))}}function disable_hide_field(form,type,name){enable_disable_field(form,type,name,!1,!0)}function save_field(elm){var popup=$("#thwcfd_field_form_pp"),form=$("#thwcfd_field_form");validate_field_form(form,popup)&&(prepare_field_form(form),form.submit())}function validate_field_form(form,popup){var err_msgs="",fname=thwcfd_base.get_property_field_value(form,"text","name"),ftype=thwcfd_base.get_property_field_value(form,"select","type"),fotype=(thwcfd_base.get_property_field_value(form,"text","label"),thwcfd_base.get_property_field_value(form,"hidden","otype"));return""==ftype&&-1==$.inArray(fotype,SPECIAL_FIELD_TYPES)?err_msgs="Type is required":""==fname?err_msgs="Name is required":thwcfd_base.isHtmlIdValid(fname)||(err_msgs=MSG_INVALID_NAME),""==err_msgs||(form.find(".err_msgs").html(err_msgs),thwcfd_base.form_wizard_start(popup),!1)}function prepare_field_form(form){var options_json=get_options(form);thwcfd_base.set_property_field_value(form,"hidden","options_json",options_json,0)}function get_options(form){for(var optionsKey=form.find("input[name='i_options_key[]']").map(function(){return $(this).val()}).get(),optionsText=form.find("input[name='i_options_text[]']").map(function(){return $(this).val()}).get(),optionsSize=optionsText.length,optionsArr=[],i=0;i<optionsSize;i++){var optionDetails={};optionDetails.key=optionsKey[i],optionDetails.text=optionsText[i],optionsArr.push(optionDetails)}var optionsJson=optionsArr.length>0?JSON.stringify(optionsArr):"";return optionsJson=encodeURIComponent(optionsJson)}function populate_options_list(form,optionsJson){var optionsHtml="";if(optionsJson)try{optionsJson=decodeURIComponent(optionsJson);var optionsList=$.parseJSON(optionsJson);optionsList&&jQuery.each(optionsList,function(){optionsHtml+=prepare_option_row_html(this)})}catch(err){console.log(err)}var optionsTable=form.find(".thwcfd-option-list tbody");optionsHtml?optionsTable.html(optionsHtml):optionsTable.html(prepare_option_row_html(null))}function prepare_option_row_html(option){var key="",text="";option&&(key=option.key?option.key:"",text=option.text?option.text:"");var html="<tr>";return html+='<td class="key"><input type="text" name="i_options_key[]" value="'+key+'" placeholder="Option Value"></td>',html+='<td class="value"><input type="text" name="i_options_text[]" value="'+text+'" placeholder="Option Text"></td>',html+='<td class="action-cell">',html+='<a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-tiny btn-primary" title="Add new option">+</a>',html+='<a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-tiny btn-danger" title="Remove option">x</a>',html+='<span class="btn btn-tiny sort ui-sortable-handle"></span></td>',html+="</tr>"}function add_new_option_row(elm){var ptable=$(elm).closest("table");ptable.find("tbody tr").size()>0?ptable.find("tbody tr:last").after(prepare_option_row_html(null)):ptable.find("tbody").append(prepare_option_row_html(null))}function remove_option_row(elm){var ptable=$(elm).closest("table");$(elm).closest("tr").remove(),0==ptable.find("tbody tr").size()&&ptable.find("tbody").append(prepare_option_row_html(null))}var MSG_INVALID_NAME='NAME/ID must begin with a lowercase letter ([a-z]) or underscores ("_") and may be followed by any number of lowercase letters, digits ([0-9]) and underscores ("_")',SPECIAL_FIELD_TYPES=["country","state","city"],FIELD_FORM_PROPS={name:{name:"name",type:"text"},type:{name:"type",type:"select"},label:{name:"label",type:"text"},default:{name:"default",type:"text"},placeholder:{name:"placeholder",type:"text"},class:{name:"class",type:"text"},validate:{name:"validate",type:"select",multiple:1},required:{name:"required",type:"checkbox"},enabled:{name:"enabled",type:"checkbox"},show_in_email:{name:"show_in_email",type:"checkbox"},show_in_order:{name:"show_in_order",type:"checkbox"}},FIELDS_TO_HIDE={radio:["placeholder","validate"],select:["validate"]};return{openNewFieldForm:open_new_field_form,openEditFieldForm:open_edit_field_form,openCopyFieldForm:open_copy_field_form,fieldTypeChangeListner:field_type_change_listner,addNewOptionRow:add_new_option_row,removeOptionRow:remove_option_row,save_field:save_field}}(window.jQuery,window,document),thwcfd_settings=function($,window,document){"use strict";function select_all_fields(elm){var checkAll=$(elm).prop("checked");$("#thwcfd_checkout_fields tbody input:checkbox[name=select_field]").prop("checked",checkAll)}function remove_selected_fields(){$("#thwcfd_checkout_fields tbody tr").removeClass("strikeout"),$("#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked").each(function(){var row=$(this).closest("tr");row.hasClass("strikeout")||row.addClass("strikeout"),row.find(".f_deleted").val(1)})}function enable_disable_selected_fields(enabled){$("#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked").each(function(){var row=$(this).closest("tr");0==enabled?row.hasClass("thpladmin-disabled")||row.addClass("thpladmin-disabled"):row.removeClass("thpladmin-disabled"),row.find(".td_enabled").html(1==enabled?'<span class="dashicons dashicons-yes tips" data-tip="Yes"></span>':"-"),row.find(".f_enabled").val(enabled)})}return $(function(){var settings_form=$("#thwcfd_checkout_fields_form");thwcfd_base.setupSortableTable(settings_form,"#thwcfd_checkout_fields","0"),thwcfd_base.setup_tiptip_tooltips(),thwcfd_base.setup_form_wizard()}),$(document).on("click",".thpladmin-notice .notice-dismiss",function(){var wrapper=$(this).closest("div.thpladmin-notice"),nonce=wrapper.data("nonce"),data={security:nonce,action:"dismiss_thwcfd_upgrade_notice"};$.post(ajaxurl,data,function(){})}),{selectAllFields:select_all_fields,removeSelectedFields:remove_selected_fields,enableDisableSelectedFields:enable_disable_selected_fields}}(window.jQuery,window,document);
|
admin/class-thwcfd-admin-form-field.php
ADDED
@@ -0,0 +1,420 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The admin settings page functionality of the plugin.
|
4 |
+
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
*
|
7 |
+
* @package woo-checkout-field-editor-pro
|
8 |
+
* @subpackage woo-checkout-field-editor-pro/admin
|
9 |
+
*/
|
10 |
+
|
11 |
+
if(!defined('WPINC')){ die; }
|
12 |
+
|
13 |
+
if(!class_exists('THWCFD_Admin_Form_Field')):
|
14 |
+
|
15 |
+
class THWCFD_Admin_Form_Field extends THWCFD_Admin_Form{
|
16 |
+
private $field_props = array();
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->init_constants();
|
20 |
+
}
|
21 |
+
|
22 |
+
private function init_constants(){
|
23 |
+
$this->field_props = $this->get_field_form_props();
|
24 |
+
//$this->field_props_display = $this->get_field_form_props_display();
|
25 |
+
}
|
26 |
+
|
27 |
+
// private function get_field_types(){
|
28 |
+
// return array(
|
29 |
+
// 'text' => 'Text', 'hidden' => 'Hidden', 'password' => 'Password',
|
30 |
+
// 'tel' => 'Telephone', 'email' => 'Email', 'number' => 'Number',
|
31 |
+
// 'textarea' => 'Textarea', 'select' => 'Select', 'multiselect' => 'Multiselect',
|
32 |
+
// 'radio' => 'Radio', 'checkbox' => 'Checkbox', 'checkboxgroup' => 'Checkbox Group',
|
33 |
+
// 'datepicker' => 'Date Picker', 'timepicker' => 'Time Picker',
|
34 |
+
// 'file' => 'File Upload',
|
35 |
+
// 'heading' => 'Heading', 'label' => 'Label'
|
36 |
+
// );
|
37 |
+
// }
|
38 |
+
public function get_field_types(){
|
39 |
+
return array(
|
40 |
+
'text' => __('Text', 'woo-checkout-field-editor-pro'),
|
41 |
+
'password' => __('Password', 'woo-checkout-field-editor-pro'),
|
42 |
+
'email' => __('Email', 'woo-checkout-field-editor-pro'),
|
43 |
+
'tel' => __('Phone', 'woo-checkout-field-editor-pro'),
|
44 |
+
'select' => __('Select', 'woo-checkout-field-editor-pro'),
|
45 |
+
'textarea' => __('Textarea', 'woo-checkout-field-editor-pro'),
|
46 |
+
'radio' => __('Radio', 'woo-checkout-field-editor-pro'),
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
public function get_field_form_props(){
|
51 |
+
$field_types = $this->get_field_types();
|
52 |
+
|
53 |
+
$validations = array(
|
54 |
+
'email' => 'Email',
|
55 |
+
'phone' => 'Phone',
|
56 |
+
'postcode' => 'Postcode',
|
57 |
+
'state' => 'State',
|
58 |
+
'number' => 'Number',
|
59 |
+
);
|
60 |
+
|
61 |
+
$display_style = array(
|
62 |
+
'full' => 'Full width',
|
63 |
+
'half_left' => 'Half width left',
|
64 |
+
'ha;lf_right' => 'Half width right',
|
65 |
+
);
|
66 |
+
|
67 |
+
return array(
|
68 |
+
'type' => array('type'=>'select', 'name'=>'type', 'label'=>'Type', 'required'=>1, 'options'=>$field_types,
|
69 |
+
'onchange'=>'thwcfdFieldTypeChangeListner(this)'),
|
70 |
+
'name' => array('type'=>'text', 'name'=>'name', 'label'=>'Name', 'required'=>1),
|
71 |
+
'label' => array('type'=>'text', 'name'=>'label', 'label'=>'Label'),
|
72 |
+
'default' => array('type'=>'text', 'name'=>'default', 'label'=>'Default Value'),
|
73 |
+
'placeholder' => array('type'=>'text', 'name'=>'placeholder', 'label'=>'Placeholder'),
|
74 |
+
//'options' => array('type'=>'text', 'name'=>'options', 'label'=>'Options', 'placeholder'=>'Seperate options with pipe(|)'),
|
75 |
+
'class' => array('type'=>'text', 'name'=>'class', 'label'=>'Class', 'placeholder'=>'Separate classes with comma'),
|
76 |
+
'validate' => array('type'=>'multiselect', 'name'=>'validate', 'label'=>'Validation', 'placeholder'=>'Select validations', 'options'=>$validations, 'multiple'=>1),
|
77 |
+
'disp_style' => array('type'=>'select', 'name'=>'disp_style', 'label'=>'Field Display', 'options'=>$display_style),
|
78 |
+
|
79 |
+
'required' => array('type'=>'checkbox', 'name'=>'required', 'label'=>'Required', 'value'=>'1', 'checked'=>1),
|
80 |
+
//'clear' => array('type'=>'checkbox', 'name'=>'clear', 'label'=>'Clear Row', 'value'=>'1', 'checked'=>1),
|
81 |
+
'enabled' => array('type'=>'checkbox', 'name'=>'enabled', 'label'=>'Enabled', 'value'=>'1', 'checked'=>1),
|
82 |
+
|
83 |
+
'show_in_email' => array('type'=>'checkbox', 'name'=>'show_in_email', 'label'=>'Display in Emails', 'value'=>'1', 'checked'=>1),
|
84 |
+
'show_in_order' => array('type'=>'checkbox', 'name'=>'show_in_order', 'label'=>'Display in Order Detail Pages', 'value'=>'1', 'checked'=>1),
|
85 |
+
);
|
86 |
+
}
|
87 |
+
|
88 |
+
/*public function get_field_form_props_display(){
|
89 |
+
return array(
|
90 |
+
'name' => array('name'=>'name', 'type'=>'text'),
|
91 |
+
'type' => array('name'=>'type', 'type'=>'select'),
|
92 |
+
'title' => array('name'=>'title', 'type'=>'text', 'len'=>40),
|
93 |
+
'placeholder' => array('name'=>'placeholder', 'type'=>'text', 'len'=>30),
|
94 |
+
'validate' => array('name'=>'validate', 'type'=>'text'),
|
95 |
+
'required' => array('name'=>'required', 'type'=>'checkbox', 'status'=>1),
|
96 |
+
'enabled' => array('name'=>'enabled', 'type'=>'checkbox', 'status'=>1),
|
97 |
+
);
|
98 |
+
}*/
|
99 |
+
|
100 |
+
public function output_field_forms(){
|
101 |
+
$this->output_field_form_pp();
|
102 |
+
$this->output_form_fragments();
|
103 |
+
}
|
104 |
+
|
105 |
+
private function output_field_form_pp(){
|
106 |
+
?>
|
107 |
+
<div id="thwcfd_field_form_pp" class="thpladmin-modal-mask">
|
108 |
+
<?php $this->output_popup_form_fields(); ?>
|
109 |
+
</div>
|
110 |
+
<?php
|
111 |
+
}
|
112 |
+
|
113 |
+
/*****************************************/
|
114 |
+
/********** POPUP FORM WIZARD ************/
|
115 |
+
/*****************************************/
|
116 |
+
private function output_popup_form_fields(){
|
117 |
+
?>
|
118 |
+
<div class="thpladmin-modal">
|
119 |
+
<div class="modal-container">
|
120 |
+
<span class="modal-close" onclick="thwcfdCloseModal(this)">×</span>
|
121 |
+
<div class="modal-content">
|
122 |
+
<div class="modal-body">
|
123 |
+
<div class="form-wizard wizard">
|
124 |
+
<aside>
|
125 |
+
<side-title class="wizard-title">Save Field</side-title>
|
126 |
+
<ul class="pp_nav_links">
|
127 |
+
<li class="text-primary active first pp-nav-link-basic" data-index="0">
|
128 |
+
<i class="dashicons dashicons-admin-generic text-primary"></i>Basic Info
|
129 |
+
<i class="i i-chevron-right dashicons dashicons-arrow-right-alt2"></i>
|
130 |
+
</li>
|
131 |
+
<!-- <li class="text-primary pp-nav-link-styles" data-index="1">
|
132 |
+
<i class="dashicons dashicons-art text-primary"></i>Display Styles
|
133 |
+
<i class="i i-chevron-right dashicons dashicons-arrow-right-alt2"></i>
|
134 |
+
</li> -->
|
135 |
+
</ul>
|
136 |
+
</aside>
|
137 |
+
<main class="form-container main-full">
|
138 |
+
<form method="post" id="thwcfd_field_form" action="">
|
139 |
+
<input type="hidden" name="f_action" value="" />
|
140 |
+
<input type="hidden" name="i_autocomplete" value="" />
|
141 |
+
<input type="hidden" name="i_priority" value="" />
|
142 |
+
<input type="hidden" name="i_custom" value="" />
|
143 |
+
<input type="hidden" name="i_oname" value="" />
|
144 |
+
<input type="hidden" name="i_otype" value="" />
|
145 |
+
<input type="hidden" name="i_options_json" value="" />
|
146 |
+
|
147 |
+
<div class="data-panel data_panel_0">
|
148 |
+
<?php $this->render_form_tab_general_info(); ?>
|
149 |
+
</div>
|
150 |
+
<!-- <div class="data-panel data_panel_1">
|
151 |
+
<?php //$this->render_form_tab_display_details(); ?>
|
152 |
+
</div> -->
|
153 |
+
</form>
|
154 |
+
</main>
|
155 |
+
<footer>
|
156 |
+
<span class="Loader"></span>
|
157 |
+
<div class="btn-toolbar">
|
158 |
+
<button class="save-btn pull-right btn btn-primary" onclick="thwcfdSaveField(this)">
|
159 |
+
<span>Save & Close</span>
|
160 |
+
</button>
|
161 |
+
<!--<button class="next-btn pull-right btn btn-primary-alt" onclick="thwcfdWizardNext(this)">
|
162 |
+
<span>Next</span><i class="i i-plus"></i>
|
163 |
+
</button>
|
164 |
+
<button class="prev-btn pull-right btn btn-primary-alt" onclick="thwcfdWizardPrevious(this)">
|
165 |
+
<span>Back</span><i class="i i-plus"></i>
|
166 |
+
</button>-->
|
167 |
+
</div>
|
168 |
+
</footer>
|
169 |
+
</div>
|
170 |
+
</div>
|
171 |
+
</div>
|
172 |
+
</div>
|
173 |
+
</div>
|
174 |
+
<?php
|
175 |
+
}
|
176 |
+
|
177 |
+
/*----- TAB - General Info -----*/
|
178 |
+
private function render_form_tab_general_info(){
|
179 |
+
$this->render_form_tab_main_title('Basic Details');
|
180 |
+
|
181 |
+
?>
|
182 |
+
<div style="display: inherit;" class="data-panel-content">
|
183 |
+
<?php
|
184 |
+
$this->render_form_fragment_general();
|
185 |
+
?>
|
186 |
+
<table class="thwcfd_field_form_tab_general_placeholder thwcfd_pp_table thwcfd-general-info"></table>
|
187 |
+
</div>
|
188 |
+
<?php
|
189 |
+
}
|
190 |
+
|
191 |
+
/*----- TAB - Display Details -----*/
|
192 |
+
private function render_form_tab_display_details(){
|
193 |
+
$this->render_form_tab_main_title('Display Settings');
|
194 |
+
|
195 |
+
?>
|
196 |
+
<div style="display: inherit;" class="data-panel-content mt-10">
|
197 |
+
<table class="thwcfd_pp_table compact thwcfd-display-info">
|
198 |
+
<?php
|
199 |
+
$this->render_form_elm_row($this->field_props['class']);
|
200 |
+
|
201 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_email']);
|
202 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_order']);
|
203 |
+
?>
|
204 |
+
</table>
|
205 |
+
</div>
|
206 |
+
<?php
|
207 |
+
}
|
208 |
+
|
209 |
+
/*-------------------------------*/
|
210 |
+
/*------ Form Field Groups ------*/
|
211 |
+
/*-------------------------------*/
|
212 |
+
private function render_form_fragment_general($input_field = true){
|
213 |
+
?>
|
214 |
+
<div class="err_msgs"></div>
|
215 |
+
<table class="thwcfd_pp_table">
|
216 |
+
<?php
|
217 |
+
$this->render_form_elm_row($this->field_props['type']);
|
218 |
+
$this->render_form_elm_row($this->field_props['name']);
|
219 |
+
?>
|
220 |
+
</table>
|
221 |
+
<?php
|
222 |
+
}
|
223 |
+
|
224 |
+
private function output_form_fragments(){
|
225 |
+
$this->render_form_field_inputtext();
|
226 |
+
$this->render_form_field_password();
|
227 |
+
$this->render_form_field_tel();
|
228 |
+
$this->render_form_field_email();
|
229 |
+
$this->render_form_field_textarea();
|
230 |
+
$this->render_form_field_select();
|
231 |
+
$this->render_form_field_radio();
|
232 |
+
$this->render_form_field_default();
|
233 |
+
}
|
234 |
+
|
235 |
+
private function render_form_field_inputtext(){
|
236 |
+
?>
|
237 |
+
<table id="thwcfd_field_form_id_text" class="thwcfd_pp_table" style="display:none;">
|
238 |
+
<?php
|
239 |
+
$this->render_form_elm_row($this->field_props['label']);
|
240 |
+
$this->render_form_elm_row($this->field_props['placeholder']);
|
241 |
+
$this->render_form_elm_row($this->field_props['default']);
|
242 |
+
$this->render_form_elm_row($this->field_props['class']);
|
243 |
+
$this->render_form_elm_row($this->field_props['validate']);
|
244 |
+
|
245 |
+
$this->render_form_elm_row_cb($this->field_props['required']);
|
246 |
+
$this->render_form_elm_row_cb($this->field_props['enabled']);
|
247 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_email']);
|
248 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_order']);
|
249 |
+
?>
|
250 |
+
</table>
|
251 |
+
<?php
|
252 |
+
}
|
253 |
+
|
254 |
+
private function render_form_field_password(){
|
255 |
+
?>
|
256 |
+
<table id="thwcfd_field_form_id_password" class="thwcfd_field_form_table" width="100%" style="display:none;">
|
257 |
+
<?php
|
258 |
+
$this->render_form_elm_row($this->field_props['label']);
|
259 |
+
$this->render_form_elm_row($this->field_props['placeholder']);
|
260 |
+
$this->render_form_elm_row($this->field_props['default']);
|
261 |
+
$this->render_form_elm_row($this->field_props['class']);
|
262 |
+
$this->render_form_elm_row($this->field_props['validate']);
|
263 |
+
|
264 |
+
$this->render_form_elm_row_cb($this->field_props['required']);
|
265 |
+
$this->render_form_elm_row_cb($this->field_props['enabled']);
|
266 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_email']);
|
267 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_order']);
|
268 |
+
?>
|
269 |
+
</table>
|
270 |
+
<?php
|
271 |
+
}
|
272 |
+
|
273 |
+
private function render_form_field_tel(){
|
274 |
+
?>
|
275 |
+
<table id="thwcfd_field_form_id_tel" class="thwcfd_field_form_table" width="100%" style="display:none;">
|
276 |
+
<?php
|
277 |
+
$this->render_form_elm_row($this->field_props['label']);
|
278 |
+
$this->render_form_elm_row($this->field_props['placeholder']);
|
279 |
+
$this->render_form_elm_row($this->field_props['default']);
|
280 |
+
$this->render_form_elm_row($this->field_props['class']);
|
281 |
+
$this->render_form_elm_row($this->field_props['validate']);
|
282 |
+
|
283 |
+
$this->render_form_elm_row_cb($this->field_props['required']);
|
284 |
+
$this->render_form_elm_row_cb($this->field_props['enabled']);
|
285 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_email']);
|
286 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_order']);
|
287 |
+
?>
|
288 |
+
</table>
|
289 |
+
<?php
|
290 |
+
}
|
291 |
+
|
292 |
+
private function render_form_field_email(){
|
293 |
+
?>
|
294 |
+
<table id="thwcfd_field_form_id_email" class="thwcfd_field_form_table" width="100%" style="display:none;">
|
295 |
+
<?php
|
296 |
+
$this->render_form_elm_row($this->field_props['label']);
|
297 |
+
$this->render_form_elm_row($this->field_props['placeholder']);
|
298 |
+
$this->render_form_elm_row($this->field_props['default']);
|
299 |
+
$this->render_form_elm_row($this->field_props['class']);
|
300 |
+
$this->render_form_elm_row($this->field_props['validate']);
|
301 |
+
|
302 |
+
$this->render_form_elm_row_cb($this->field_props['required']);
|
303 |
+
$this->render_form_elm_row_cb($this->field_props['enabled']);
|
304 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_email']);
|
305 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_order']);
|
306 |
+
?>
|
307 |
+
</table>
|
308 |
+
<?php
|
309 |
+
}
|
310 |
+
|
311 |
+
private function render_form_field_textarea(){
|
312 |
+
$value_props = $this->field_props['default'];
|
313 |
+
$value_props['type'] = 'textarea';
|
314 |
+
|
315 |
+
?>
|
316 |
+
<table id="thwcfd_field_form_id_textarea" class="thwcfd_field_form_table" width="100%" style="display:none;">
|
317 |
+
<?php
|
318 |
+
$this->render_form_elm_row($this->field_props['label']);
|
319 |
+
$this->render_form_elm_row($this->field_props['placeholder']);
|
320 |
+
$this->render_form_elm_row($value_props);
|
321 |
+
$this->render_form_elm_row($this->field_props['class']);
|
322 |
+
$this->render_form_elm_row($this->field_props['validate']);
|
323 |
+
|
324 |
+
$this->render_form_elm_row_cb($this->field_props['required']);
|
325 |
+
$this->render_form_elm_row_cb($this->field_props['enabled']);
|
326 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_email']);
|
327 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_order']);
|
328 |
+
?>
|
329 |
+
</table>
|
330 |
+
<?php
|
331 |
+
}
|
332 |
+
|
333 |
+
private function render_form_field_select(){
|
334 |
+
?>
|
335 |
+
<table id="thwcfd_field_form_id_select" class="thwcfd_field_form_table" width="100%" style="display:none;">
|
336 |
+
<?php
|
337 |
+
$this->render_form_elm_row($this->field_props['label']);
|
338 |
+
$this->render_form_elm_row($this->field_props['placeholder']);
|
339 |
+
$this->render_form_elm_row($this->field_props['default']);
|
340 |
+
$this->render_form_elm_row($this->field_props['class']);
|
341 |
+
$this->render_form_elm_row($this->field_props['validate']);
|
342 |
+
|
343 |
+
$this->render_form_elm_row_cb($this->field_props['required']);
|
344 |
+
$this->render_form_elm_row_cb($this->field_props['enabled']);
|
345 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_email']);
|
346 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_order']);
|
347 |
+
|
348 |
+
$this->render_form_fragment_h_spacing();
|
349 |
+
$this->render_form_fragment_options();
|
350 |
+
?>
|
351 |
+
</table>
|
352 |
+
<?php
|
353 |
+
}
|
354 |
+
|
355 |
+
private function render_form_field_radio(){
|
356 |
+
?>
|
357 |
+
<table id="thwcfd_field_form_id_radio" class="thwcfd_field_form_table" width="100%" style="display:none;">
|
358 |
+
<?php
|
359 |
+
$this->render_form_elm_row($this->field_props['label']);
|
360 |
+
$this->render_form_elm_row($this->field_props['placeholder']);
|
361 |
+
$this->render_form_elm_row($this->field_props['default']);
|
362 |
+
$this->render_form_elm_row($this->field_props['class']);
|
363 |
+
$this->render_form_elm_row($this->field_props['validate']);
|
364 |
+
|
365 |
+
$this->render_form_elm_row_cb($this->field_props['required']);
|
366 |
+
$this->render_form_elm_row_cb($this->field_props['enabled']);
|
367 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_email']);
|
368 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_order']);
|
369 |
+
|
370 |
+
$this->render_form_fragment_h_spacing();
|
371 |
+
$this->render_form_fragment_options();
|
372 |
+
?>
|
373 |
+
</table>
|
374 |
+
<?php
|
375 |
+
}
|
376 |
+
|
377 |
+
private function render_form_field_default(){
|
378 |
+
?>
|
379 |
+
<table id="thwcfd_field_form_id_default" class="thwcfd_field_form_table" width="100%" style="display:none;">
|
380 |
+
<?php
|
381 |
+
$this->render_form_elm_row($this->field_props['label']);
|
382 |
+
$this->render_form_elm_row($this->field_props['placeholder']);
|
383 |
+
$this->render_form_elm_row($this->field_props['default']);
|
384 |
+
$this->render_form_elm_row($this->field_props['class']);
|
385 |
+
$this->render_form_elm_row($this->field_props['validate']);
|
386 |
+
|
387 |
+
$this->render_form_elm_row_cb($this->field_props['required']);
|
388 |
+
$this->render_form_elm_row_cb($this->field_props['enabled']);
|
389 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_email']);
|
390 |
+
$this->render_form_elm_row_cb($this->field_props['show_in_order']);
|
391 |
+
?>
|
392 |
+
</table>
|
393 |
+
<?php
|
394 |
+
}
|
395 |
+
|
396 |
+
private function render_form_fragment_options(){
|
397 |
+
?>
|
398 |
+
<tr>
|
399 |
+
<td class="sub-title"><?php _e('Options', 'woo-checkout-field-editor-pro'); ?></td>
|
400 |
+
<?php $this->render_form_fragment_tooltip(); ?>
|
401 |
+
<td></td>
|
402 |
+
</tr>
|
403 |
+
<tr>
|
404 |
+
<td colspan="3" class="p-0">
|
405 |
+
<table border="0" cellpadding="0" cellspacing="0" class="thwcfd-option-list thpladmin-options-table"><tbody>
|
406 |
+
<tr>
|
407 |
+
<td class="key"><input type="text" name="i_options_key[]" placeholder="Option Value"></td>
|
408 |
+
<td class="value"><input type="text" name="i_options_text[]" placeholder="Option Text"></td>
|
409 |
+
<td class="action-cell">
|
410 |
+
<a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-tiny btn-primary" title="Add new option">+</a><a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-tiny btn-danger" title="Remove option">x</a><span class="btn btn-tiny sort ui-sortable-handle"></span>
|
411 |
+
</td>
|
412 |
+
</tr>
|
413 |
+
</tbody></table>
|
414 |
+
</td>
|
415 |
+
</tr>
|
416 |
+
<?php
|
417 |
+
}
|
418 |
+
}
|
419 |
+
|
420 |
+
endif;
|
admin/class-thwcfd-admin-form.php
ADDED
@@ -0,0 +1,426 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The admin settings page functionality of the plugin.
|
4 |
+
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
*
|
7 |
+
* @package woo-checkout-field-editor-pro
|
8 |
+
* @subpackage woo-checkout-field-editor-pro/admin
|
9 |
+
*/
|
10 |
+
|
11 |
+
if(!defined('WPINC')){ die; }
|
12 |
+
|
13 |
+
if(!class_exists('THWCFD_Admin_Form')):
|
14 |
+
|
15 |
+
abstract class THWCFD_Admin_Form {
|
16 |
+
public $cell_props = array();
|
17 |
+
public $cell_props_TA = array();
|
18 |
+
public $cell_props_CP = array();
|
19 |
+
public $cell_props_CB = array();
|
20 |
+
|
21 |
+
public function __construct() {
|
22 |
+
$this->init_constants();
|
23 |
+
}
|
24 |
+
|
25 |
+
private function init_constants(){
|
26 |
+
$this->cell_props = array(
|
27 |
+
'label_cell_props' => 'class="label"',
|
28 |
+
'input_cell_props' => 'class="field"',
|
29 |
+
'input_width' => '260px',
|
30 |
+
);
|
31 |
+
$this->cell_props_TA = array(
|
32 |
+
'label_cell_props' => 'class="label"',
|
33 |
+
'input_cell_props' => 'class="field"',
|
34 |
+
'input_width' => '260px',
|
35 |
+
'rows' => 10,
|
36 |
+
'cols' => 29,
|
37 |
+
);
|
38 |
+
$this->cell_props_CP = array(
|
39 |
+
'label_cell_props' => 'class="label"',
|
40 |
+
'input_cell_props' => 'class="field"',
|
41 |
+
'input_width' => '223px',
|
42 |
+
);
|
43 |
+
|
44 |
+
$this->cell_props_CB = array(
|
45 |
+
'label_props' => 'style="margin-right: 40px;"',
|
46 |
+
);
|
47 |
+
$this->cell_props_CBS = array(
|
48 |
+
'label_props' => 'style="margin-right: 15px;"',
|
49 |
+
);
|
50 |
+
$this->cell_props_CBL = array(
|
51 |
+
'label_props' => 'style="margin-right: 52px;"',
|
52 |
+
);
|
53 |
+
|
54 |
+
$this->field_props = $this->get_field_form_props();
|
55 |
+
$this->field_props_display = $this->get_field_form_props_display();
|
56 |
+
}
|
57 |
+
|
58 |
+
public function render_form_field_element($field, $args = array(), $render_cell = true){
|
59 |
+
if($field && is_array($field)){
|
60 |
+
$defaults = array(
|
61 |
+
'label_cell_props' => 'class="label"',
|
62 |
+
'input_cell_props' => 'class="field"',
|
63 |
+
'label_cell_colspan' => '',
|
64 |
+
'input_cell_colspan' => '',
|
65 |
+
);
|
66 |
+
$args = wp_parse_args( $args, $defaults );
|
67 |
+
|
68 |
+
$ftype = isset($field['type']) ? $field['type'] : 'text';
|
69 |
+
$flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : '';
|
70 |
+
$sub_label = isset($field['sub_label']) && !empty($field['sub_label']) ? __($field['sub_label'], 'woo-checkout-field-editor-pro') : '';
|
71 |
+
$tooltip = isset($field['hint_text']) && !empty($field['hint_text']) ? __($field['hint_text'], 'woo-checkout-field-editor-pro') : '';
|
72 |
+
|
73 |
+
$field_html = '';
|
74 |
+
|
75 |
+
if($ftype == 'text'){
|
76 |
+
$field_html = $this->render_form_field_element_inputtext($field, $args);
|
77 |
+
|
78 |
+
}else if($ftype == 'textarea'){
|
79 |
+
$field_html = $this->render_form_field_element_textarea($field, $args);
|
80 |
+
|
81 |
+
}else if($ftype == 'select'){
|
82 |
+
$field_html = $this->render_form_field_element_select($field, $args);
|
83 |
+
|
84 |
+
}else if($ftype == 'multiselect'){
|
85 |
+
$field_html = $this->render_form_field_element_multiselect($field, $args);
|
86 |
+
|
87 |
+
}else if($ftype == 'colorpicker'){
|
88 |
+
$field_html = $this->render_form_field_element_colorpicker($field, $args);
|
89 |
+
|
90 |
+
}else if($ftype == 'checkbox'){
|
91 |
+
$field_html = $this->render_form_field_element_checkbox($field, $args, $render_cell);
|
92 |
+
$flabel = ' ';
|
93 |
+
|
94 |
+
}else if($ftype == 'number'){
|
95 |
+
$field_html = $this->render_form_field_element_number($field, $args);
|
96 |
+
}
|
97 |
+
|
98 |
+
if($render_cell){
|
99 |
+
$required_html = isset($field['required']) && $field['required'] ? '<abbr class="required" title="required">*</abbr>' : '';
|
100 |
+
|
101 |
+
$label_cell_props = !empty($args['label_cell_props']) ? $args['label_cell_props'] : '';
|
102 |
+
$input_cell_props = !empty($args['input_cell_props']) ? $args['input_cell_props'] : '';
|
103 |
+
|
104 |
+
?>
|
105 |
+
<td <?php echo $label_cell_props ?> >
|
106 |
+
<?php echo $flabel; echo $required_html;
|
107 |
+
if($sub_label){
|
108 |
+
?>
|
109 |
+
<br/><span class="thpladmin-subtitle"><?php echo $sub_label; ?></span>
|
110 |
+
<?php
|
111 |
+
}
|
112 |
+
?>
|
113 |
+
</td>
|
114 |
+
<?php $this->render_form_fragment_tooltip($tooltip); ?>
|
115 |
+
<td <?php echo $input_cell_props ?> ><?php echo $field_html; ?></td>
|
116 |
+
<?php
|
117 |
+
}else{
|
118 |
+
echo $field_html;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
private function prepare_form_field_props($field, $args = array()){
|
124 |
+
$field_props = '';
|
125 |
+
|
126 |
+
$defaults = array(
|
127 |
+
'input_width' => '',
|
128 |
+
'input_name_prefix' => 'i_',
|
129 |
+
'input_name_suffix' => '',
|
130 |
+
);
|
131 |
+
$args = wp_parse_args( $args, $defaults );
|
132 |
+
|
133 |
+
$ftype = isset($field['type']) ? $field['type'] : 'text';
|
134 |
+
|
135 |
+
$input_class = '';
|
136 |
+
if($ftype == 'text'){
|
137 |
+
$input_class = 'thwcfd-inputtext';
|
138 |
+
}else if($ftype == 'number'){
|
139 |
+
$input_class = 'thwcfd-inputtext';
|
140 |
+
}else if($ftype == 'select'){
|
141 |
+
$input_class = 'thwcfd-select';
|
142 |
+
}else if($ftype == 'multiselect' || $ftype == 'multiselect_grouped'){
|
143 |
+
$input_class = 'thwcfd-select thwcfd-enhanced-multi-select';
|
144 |
+
}else if($ftype == 'colorpicker'){
|
145 |
+
$input_class = 'thwcfd-color thpladmin-colorpick';
|
146 |
+
}
|
147 |
+
|
148 |
+
if($ftype == 'multiselect' || $ftype == 'multiselect_grouped'){
|
149 |
+
$args['input_name_suffix'] = $args['input_name_suffix'].'[]';
|
150 |
+
}
|
151 |
+
|
152 |
+
$fname = $args['input_name_prefix'].$field['name'].$args['input_name_suffix'];
|
153 |
+
$fvalue = isset($field['value']) ? esc_html($field['value']) : '';
|
154 |
+
|
155 |
+
$input_width = $args['input_width'] ? 'width:'.$args['input_width'].';' : '';
|
156 |
+
$field_props = 'name="'. $fname .'" style="'. $input_width .'"';
|
157 |
+
$field_props .= !empty($input_class) ? ' class="'. $input_class .'"' : '';
|
158 |
+
$field_props .= $ftype == 'textarea' ? '' : ' value="'. $fvalue .'"';
|
159 |
+
$field_props .= $ftype == 'multiselect_grouped' ? ' data-value="'. $fvalue .'"' : '';
|
160 |
+
$field_props .= ( isset($field['placeholder']) && !empty($field['placeholder']) ) ? ' placeholder="'.$field['placeholder'].'"' : '';
|
161 |
+
$field_props .= ( isset($field['onchange']) && !empty($field['onchange']) ) ? ' onchange="'.$field['onchange'].'"' : '';
|
162 |
+
|
163 |
+
if( $ftype == 'number' ){
|
164 |
+
$min = isset( $field['min'] ) ? $field['min'] : '';
|
165 |
+
$max = isset( $field['max'] ) ? $field['max'] : '';
|
166 |
+
$field_props .= ' min="'.$min.'" max="'.$max.'"';
|
167 |
+
}
|
168 |
+
|
169 |
+
return $field_props;
|
170 |
+
}
|
171 |
+
|
172 |
+
private function render_form_field_element_inputtext($field, $atts = array()){
|
173 |
+
$field_html = '';
|
174 |
+
if($field && is_array($field)){
|
175 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
176 |
+
$field_html = '<input type="text" '. $field_props .' />';
|
177 |
+
}
|
178 |
+
return $field_html;
|
179 |
+
}
|
180 |
+
|
181 |
+
private function render_form_field_element_textarea($field, $args = array()){
|
182 |
+
$field_html = '';
|
183 |
+
if($field && is_array($field)){
|
184 |
+
$args = wp_parse_args( $args, array(
|
185 |
+
'rows' => '5',
|
186 |
+
'cols' => '29',
|
187 |
+
));
|
188 |
+
|
189 |
+
$fvalue = isset($field['value']) ? $field['value'] : '';
|
190 |
+
$field_props = $this->prepare_form_field_props($field, $args);
|
191 |
+
$field_html = '<textarea '. $field_props .' rows="'.$args['rows'].'" cols="'.$args['cols'].'" >'.$fvalue.'</textarea>';
|
192 |
+
}
|
193 |
+
return $field_html;
|
194 |
+
}
|
195 |
+
|
196 |
+
private function render_form_field_element_select($field, $atts = array()){
|
197 |
+
$field_html = '';
|
198 |
+
if($field && is_array($field)){
|
199 |
+
$fvalue = isset($field['value']) ? $field['value'] : '';
|
200 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
201 |
+
|
202 |
+
$field_html = '<select '. $field_props .' >';
|
203 |
+
foreach($field['options'] as $value => $label){
|
204 |
+
$selected = $value === $fvalue ? 'selected' : '';
|
205 |
+
$field_html .= '<option value="'. trim($value) .'" '.$selected.'>'. __($label, 'woo-checkout-field-editor-pro') .'</option>';
|
206 |
+
}
|
207 |
+
$field_html .= '</select>';
|
208 |
+
}
|
209 |
+
return $field_html;
|
210 |
+
}
|
211 |
+
|
212 |
+
private function render_form_field_element_multiselect($field, $atts = array()){
|
213 |
+
$field_html = '';
|
214 |
+
if($field && is_array($field)){
|
215 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
216 |
+
|
217 |
+
$field_html = '<select multiple="multiple" '. $field_props .'>';
|
218 |
+
foreach($field['options'] as $value => $label){
|
219 |
+
//$selected = $value === $fvalue ? 'selected' : '';
|
220 |
+
$field_html .= '<option value="'. trim($value) .'" >'. __($label, 'woo-checkout-field-editor-pro') .'</option>';
|
221 |
+
}
|
222 |
+
$field_html .= '</select>';
|
223 |
+
}
|
224 |
+
return $field_html;
|
225 |
+
}
|
226 |
+
|
227 |
+
private function render_form_field_element_multiselect_grouped($field, $atts = array()){
|
228 |
+
$field_html = '';
|
229 |
+
if($field && is_array($field)){
|
230 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
231 |
+
|
232 |
+
$field_html = '<select multiple="multiple" '. $field_props .'>';
|
233 |
+
foreach($field['options'] as $group_label => $fields){
|
234 |
+
$field_html .= '<optgroup label="'. $group_label .'">';
|
235 |
+
|
236 |
+
foreach($fields as $value => $label){
|
237 |
+
$value = trim($value);
|
238 |
+
if(isset($field['glue']) && !empty($field['glue'])){
|
239 |
+
$value = $value.$field['glue'].trim($label);
|
240 |
+
}
|
241 |
+
|
242 |
+
$field_html .= '<option value="'. $value .'">'. __($label, 'woo-checkout-field-editor-pro') .'</option>';
|
243 |
+
}
|
244 |
+
|
245 |
+
$field_html .= '</optgroup>';
|
246 |
+
}
|
247 |
+
$field_html .= '</select>';
|
248 |
+
}
|
249 |
+
return $field_html;
|
250 |
+
}
|
251 |
+
|
252 |
+
private function render_form_field_element_radio($field, $atts = array()){
|
253 |
+
$field_html = '';
|
254 |
+
/*if($field && is_array($field)){
|
255 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
256 |
+
|
257 |
+
$field_html = '<select '. $field_props .' >';
|
258 |
+
foreach($field['options'] as $value => $label){
|
259 |
+
$selected = $value === $fvalue ? 'selected' : '';
|
260 |
+
$field_html .= '<option value="'. trim($value) .'" '.$selected.'>'. __($label, 'woo-checkout-field-editor-pro') .'</option>';
|
261 |
+
}
|
262 |
+
$field_html .= '</select>';
|
263 |
+
}*/
|
264 |
+
return $field_html;
|
265 |
+
}
|
266 |
+
|
267 |
+
private function render_form_field_element_checkbox($field, $atts = array(), $render_cell = true){
|
268 |
+
$field_html = '';
|
269 |
+
if($field && is_array($field)){
|
270 |
+
$args = shortcode_atts( array(
|
271 |
+
'label_props' => '',
|
272 |
+
'cell_props' => '',
|
273 |
+
'input_props' => '',
|
274 |
+
'id_prefix' => 'a_f',
|
275 |
+
'render_input_cell' => false,
|
276 |
+
), $atts );
|
277 |
+
|
278 |
+
$fid = $args['id_prefix']. $field['name'];
|
279 |
+
$flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : '';
|
280 |
+
|
281 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
282 |
+
$field_props .= isset($field['checked']) && $field['checked'] === 1 ? ' checked' : '';
|
283 |
+
$field_props .= $args['input_props'];
|
284 |
+
|
285 |
+
$field_html = '<input type="checkbox" id="'. $fid .'" '. $field_props .' />';
|
286 |
+
$field_html .= '<label for="'. $fid .'" '. $args['label_props'] .' > '. $flabel .'</label>';
|
287 |
+
}
|
288 |
+
if(!$render_cell && $args['render_input_cell']){
|
289 |
+
return '<td '. $args['cell_props'] .' >'. $field_html .'</td>';
|
290 |
+
}else{
|
291 |
+
return $field_html;
|
292 |
+
}
|
293 |
+
}
|
294 |
+
|
295 |
+
private function render_form_field_element_colorpicker($field, $atts = array()){
|
296 |
+
$field_html = '';
|
297 |
+
if($field && is_array($field)){
|
298 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
299 |
+
|
300 |
+
$field_html = '<span class="thpladmin-colorpickpreview '.$field['name'].'_preview" style=""></span>';
|
301 |
+
$field_html .= '<input type="text" '. $field_props .' >';
|
302 |
+
}
|
303 |
+
return $field_html;
|
304 |
+
}
|
305 |
+
|
306 |
+
private function render_form_field_element_number($field, $atts = array() ){
|
307 |
+
$field_html = '';
|
308 |
+
if($field && is_array($field)){
|
309 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
310 |
+
$field_html = '<input type="number" '. $field_props .' />';
|
311 |
+
}
|
312 |
+
return $field_html;
|
313 |
+
}
|
314 |
+
|
315 |
+
public function render_form_fragment_tooltip($tooltip = false){
|
316 |
+
if($tooltip){
|
317 |
+
?>
|
318 |
+
<td class="tip" style="width: 26px; padding:0px;">
|
319 |
+
<a href="javascript:void(0)" title="<?php echo $tooltip; ?>" class="thwcfd_tooltip"><img src="<?php echo THWCFD_ASSETS_URL_ADMIN; ?>/css/help.png" title=""/></a>
|
320 |
+
</td>
|
321 |
+
<?php
|
322 |
+
}else{
|
323 |
+
?>
|
324 |
+
<td style="width: 26px; padding:0px;"></td>
|
325 |
+
<?php
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
public function render_form_fragment_h_spacing($padding = 5){
|
330 |
+
$style = $padding ? 'padding-top:'.$padding.'px;' : '';
|
331 |
+
?>
|
332 |
+
<tr><td colspan="3" style="<?php echo $style ?>"></td></tr>
|
333 |
+
<?php
|
334 |
+
}
|
335 |
+
|
336 |
+
public function render_form_fragment_h_separator($atts = array()){
|
337 |
+
$args = shortcode_atts( array(
|
338 |
+
'colspan' => 6,
|
339 |
+
'padding-top' => '5px',
|
340 |
+
'border-style' => 'dashed',
|
341 |
+
'border-width' => '1px',
|
342 |
+
'border-color' => '#e6e6e6',
|
343 |
+
'content' => '',
|
344 |
+
), $atts );
|
345 |
+
|
346 |
+
$style = $args['padding-top'] ? 'padding-top:'.$args['padding-top'].';' : '';
|
347 |
+
$style .= $args['border-style'] ? ' border-bottom:'.$args['border-width'].' '.$args['border-style'].' '.$args['border-color'].';' : '';
|
348 |
+
|
349 |
+
?>
|
350 |
+
<tr><td colspan="<?php echo $args['colspan']; ?>" style="<?php echo $style; ?>"><?php echo $args['content']; ?></td></tr>
|
351 |
+
<?php
|
352 |
+
}
|
353 |
+
|
354 |
+
public function render_form_field_blank($colspan = 3){
|
355 |
+
?>
|
356 |
+
<td colspan="<?php echo $colspan; ?>"> </td>
|
357 |
+
<?php
|
358 |
+
}
|
359 |
+
|
360 |
+
public function render_form_section_separator($props, $atts=array()){
|
361 |
+
?>
|
362 |
+
<tr valign="top"><td colspan="<?php echo $props['colspan']; ?>" style="height:10px;"></td></tr>
|
363 |
+
<tr valign="top"><td colspan="<?php echo $props['colspan']; ?>" class="thpladmin-form-section-title" ><?php echo $props['title']; ?></td></tr>
|
364 |
+
<tr valign="top"><td colspan="<?php echo $props['colspan']; ?>" style="height:0px;"></td></tr>
|
365 |
+
<?php
|
366 |
+
}
|
367 |
+
|
368 |
+
/*----- Tab Title -----*/
|
369 |
+
public function render_form_tab_main_title($title){
|
370 |
+
?>
|
371 |
+
<main-title classname="main-title">
|
372 |
+
<button class="device-mobile btn--back Button">
|
373 |
+
<i class="button-icon button-icon-before i-arrow-back"></i>
|
374 |
+
</button>
|
375 |
+
<span class="device-mobile main-title-icon text-primary"><i class="i-check drishy"></i><?php echo $title; ?></span>
|
376 |
+
<span class="device-desktop"><?php echo $title; ?></span>
|
377 |
+
</main-title>
|
378 |
+
<?php
|
379 |
+
}
|
380 |
+
|
381 |
+
/*----- Form Element Row -----*/
|
382 |
+
public function render_form_elm_row($field, $args=array()){
|
383 |
+
$row_class = $this->prepare_settings_row_class( $field );
|
384 |
+
?>
|
385 |
+
<tr class="<?php echo esc_attr( $row_class ); ?>">
|
386 |
+
<?php $this->render_form_field_element($field, $this->cell_props); ?>
|
387 |
+
</tr>
|
388 |
+
<?php
|
389 |
+
}
|
390 |
+
|
391 |
+
public function render_form_elm_row_ta($field, $args=array()){
|
392 |
+
$row_class = $this->prepare_settings_row_class( $field );
|
393 |
+
?>
|
394 |
+
<tr class="<?php echo esc_attr( $row_class ); ?>">
|
395 |
+
<?php $this->render_form_field_element($field, $this->cell_props_TA); ?>
|
396 |
+
</tr>
|
397 |
+
<?php
|
398 |
+
}
|
399 |
+
|
400 |
+
public function render_form_elm_row_cb($field, $args=array()){
|
401 |
+
$row_class = $this->prepare_settings_row_class( $field );
|
402 |
+
?>
|
403 |
+
<tr class="<?php echo esc_attr( $row_class ); ?>">
|
404 |
+
<td colspan="2"></td>
|
405 |
+
<td class="field">
|
406 |
+
<?php $this->render_form_field_element($field, $this->cell_props_CB, false); ?>
|
407 |
+
</td>
|
408 |
+
</tr>
|
409 |
+
<?php
|
410 |
+
}
|
411 |
+
|
412 |
+
public function render_form_elm_row_cp($field, $args=array()){
|
413 |
+
?>
|
414 |
+
<tr>
|
415 |
+
<?php $this->render_form_field_element($field, $this->cell_props_CP); ?>
|
416 |
+
</tr>
|
417 |
+
<?php
|
418 |
+
}
|
419 |
+
|
420 |
+
public function prepare_settings_row_class( $field ){
|
421 |
+
$name = isset($field['name']) ? $field['name'] : '';
|
422 |
+
return 'form_field_'.$name;
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
endif;
|
admin/class-thwcfd-admin-settings-advanced.php
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The admin advanced settings page functionality of the plugin.
|
4 |
+
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
* @since 1.4.4
|
7 |
+
*
|
8 |
+
* @package woo-checkout-field-editor-pro
|
9 |
+
* @subpackage woo-checkout-field-editor-pro/admin
|
10 |
+
*/
|
11 |
+
|
12 |
+
if(!defined('WPINC')){ die; }
|
13 |
+
|
14 |
+
if(!class_exists('THWCFD_Admin_Settings_Advanced')):
|
15 |
+
|
16 |
+
class THWCFD_Admin_Settings_Advanced extends THWCFD_Admin_Settings{
|
17 |
+
protected static $_instance = null;
|
18 |
+
protected $tabs = '';
|
19 |
+
|
20 |
+
private $settings_fields = NULL;
|
21 |
+
private $cell_props = array();
|
22 |
+
private $cell_props_CB = array();
|
23 |
+
|
24 |
+
public function __construct() {
|
25 |
+
parent::__construct();
|
26 |
+
|
27 |
+
$this->page_id = 'advanced_settings';
|
28 |
+
$this->init_constants();
|
29 |
+
}
|
30 |
+
|
31 |
+
public static function instance() {
|
32 |
+
if(is_null(self::$_instance)){
|
33 |
+
self::$_instance = new self();
|
34 |
+
}
|
35 |
+
return self::$_instance;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function init_constants(){
|
39 |
+
$this->cell_props = array(
|
40 |
+
'label_cell_props' => 'class="label"',
|
41 |
+
'input_cell_props' => 'class="field"',
|
42 |
+
'input_width' => '260px',
|
43 |
+
'label_cell_th' => true
|
44 |
+
);
|
45 |
+
|
46 |
+
$this->cell_props_CB = array(
|
47 |
+
'label_props' => 'style="margin-right: 40px;"',
|
48 |
+
);
|
49 |
+
|
50 |
+
$this->settings_fields = $this->get_advanced_settings_fields();
|
51 |
+
}
|
52 |
+
|
53 |
+
public function get_advanced_settings_fields(){
|
54 |
+
return array(
|
55 |
+
'enable_label_override' => array(
|
56 |
+
'name'=>'enable_label_override', 'label'=>'Enable label override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>1
|
57 |
+
),
|
58 |
+
'enable_placeholder_override' => array(
|
59 |
+
'name'=>'enable_placeholder_override', 'label'=>'Enable placeholder override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>1
|
60 |
+
),
|
61 |
+
'enable_class_override' => array(
|
62 |
+
'name'=>'enable_class_override', 'label'=>'Enable class override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>0
|
63 |
+
),
|
64 |
+
'enable_priority_override' => array(
|
65 |
+
'name'=>'enable_priority_override', 'label'=>'Enable priority override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>1
|
66 |
+
),
|
67 |
+
'enable_required_override' => array(
|
68 |
+
'name'=>'enable_required_override', 'label'=>'Enable required validation override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>0
|
69 |
+
),
|
70 |
+
);
|
71 |
+
}
|
72 |
+
|
73 |
+
public function render_page(){
|
74 |
+
$this->render_tabs();
|
75 |
+
$this->render_content();
|
76 |
+
}
|
77 |
+
|
78 |
+
public function save_advanced_settings($settings){
|
79 |
+
$result = update_option(THWCFD_Utils::OPTION_KEY_ADVANCED_SETTINGS, $settings);
|
80 |
+
return $result;
|
81 |
+
}
|
82 |
+
|
83 |
+
private function reset_settings(){
|
84 |
+
delete_option(THWCFD_Utils::OPTION_KEY_ADVANCED_SETTINGS);
|
85 |
+
$this->print_notices('Settings successfully reset.', 'updated', false);
|
86 |
+
}
|
87 |
+
|
88 |
+
private function save_settings(){
|
89 |
+
$settings = array();
|
90 |
+
|
91 |
+
foreach( $this->settings_fields as $name => $field ) {
|
92 |
+
$value = '';
|
93 |
+
|
94 |
+
if($field['type'] === 'checkbox'){
|
95 |
+
$value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
|
96 |
+
|
97 |
+
}else if($field['type'] === 'multiselect_grouped'){
|
98 |
+
$value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
|
99 |
+
$value = is_array($value) ? implode(',', wc_clean(wp_unslash($value))) : wc_clean(wp_unslash($value));
|
100 |
+
|
101 |
+
}else if($field['type'] === 'text' || $field['type'] === 'textarea'){
|
102 |
+
$value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
|
103 |
+
$value = !empty($value) ? wc_clean( wp_unslash($value)) : '';
|
104 |
+
|
105 |
+
}else{
|
106 |
+
$value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
|
107 |
+
$value = !empty($value) ? wc_clean( wp_unslash($value)) : '';
|
108 |
+
}
|
109 |
+
|
110 |
+
$settings[$name] = $value;
|
111 |
+
}
|
112 |
+
|
113 |
+
$result = $this->save_advanced_settings($settings);
|
114 |
+
if ($result == true) {
|
115 |
+
$this->print_notices('Your changes were saved.', 'updated', false);
|
116 |
+
} else {
|
117 |
+
$this->print_notices('Your changes were not saved due to an error (or you made none!).', 'error', false);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
private function render_content(){
|
122 |
+
if(isset($_POST['reset_settings']))
|
123 |
+
$this->reset_settings();
|
124 |
+
|
125 |
+
if(isset($_POST['save_settings']))
|
126 |
+
$this->save_settings();
|
127 |
+
|
128 |
+
$this->render_plugin_settings();
|
129 |
+
}
|
130 |
+
|
131 |
+
private function render_plugin_settings(){
|
132 |
+
$settings = THWCFD_Utils::get_advanced_settings();
|
133 |
+
?>
|
134 |
+
<div style="padding-left: 30px;">
|
135 |
+
<form id="advanced_settings_form" method="post" action="">
|
136 |
+
<table class="thwcfd-settings-table thpladmin-form-table">
|
137 |
+
<tbody>
|
138 |
+
<?php
|
139 |
+
$this->render_locale_override_settings($settings);
|
140 |
+
?>
|
141 |
+
</tbody>
|
142 |
+
</table>
|
143 |
+
<p class="submit">
|
144 |
+
<input type="submit" name="save_settings" class="btn btn-small btn-primary" value="Save changes">
|
145 |
+
<input type="submit" name="reset_settings" class="btn btn-small" value="Reset to default"
|
146 |
+
onclick="return confirm('Are you sure you want to reset to default settings? all your changes will be deleted.');">
|
147 |
+
</p>
|
148 |
+
</form>
|
149 |
+
</div>
|
150 |
+
<?php
|
151 |
+
}
|
152 |
+
|
153 |
+
private function render_locale_override_settings($settings){
|
154 |
+
$this->render_form_elm_row_title('Locale override settings');
|
155 |
+
$this->render_form_elm_row_cb($this->settings_fields['enable_label_override'], $settings, true);
|
156 |
+
$this->render_form_elm_row_cb($this->settings_fields['enable_placeholder_override'], $settings, true);
|
157 |
+
$this->render_form_elm_row_cb($this->settings_fields['enable_class_override'], $settings, true);
|
158 |
+
$this->render_form_elm_row_cb($this->settings_fields['enable_priority_override'], $settings, true);
|
159 |
+
$this->render_form_elm_row_cb($this->settings_fields['enable_required_override'], $settings, true);
|
160 |
+
}
|
161 |
+
|
162 |
+
public function render_form_elm_row_title($title=''){
|
163 |
+
?>
|
164 |
+
<tr>
|
165 |
+
<td colspan="3" class="section-title" ><?php echo $title; ?></td>
|
166 |
+
</tr>
|
167 |
+
<?php
|
168 |
+
}
|
169 |
+
|
170 |
+
private function render_form_elm_row_cb($field, $settings=false, $merge_cells=false){
|
171 |
+
$name = $field['name'];
|
172 |
+
if(is_array($settings) && isset($settings[$name])){
|
173 |
+
if($field['value'] === $settings[$name]){
|
174 |
+
$field['checked'] = 1;
|
175 |
+
}else{
|
176 |
+
$field['checked'] = 0;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
if($merge_cells){
|
181 |
+
?>
|
182 |
+
<tr>
|
183 |
+
<td colspan="3">
|
184 |
+
<?php $this->render_form_field_element($field, $this->cell_props_CB, false); ?>
|
185 |
+
</td>
|
186 |
+
</tr>
|
187 |
+
<?php
|
188 |
+
}else{
|
189 |
+
?>
|
190 |
+
<tr>
|
191 |
+
<td colspan="2"></td>
|
192 |
+
<td class="field">
|
193 |
+
<?php $this->render_form_field_element($field, $this->cell_props_CB, false); ?>
|
194 |
+
</td>
|
195 |
+
</tr>
|
196 |
+
<?php
|
197 |
+
}
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
endif;
|
classes/class-thwcfd-settings-general.php → admin/class-thwcfd-admin-settings-general.php
RENAMED
@@ -11,15 +11,22 @@
|
|
11 |
|
12 |
defined( 'ABSPATH' ) || exit;
|
13 |
|
14 |
-
if(!class_exists('
|
15 |
|
16 |
-
class
|
17 |
protected static $_instance = null;
|
18 |
|
|
|
|
|
|
|
19 |
protected $tabs = '';
|
20 |
protected $sections = '';
|
21 |
|
22 |
public function __construct() {
|
|
|
|
|
|
|
|
|
23 |
$this->tabs = array( 'fields' => 'Checkout Fields', 'advanced_settings' => 'Advanced Settings');
|
24 |
$this->sections = array('billing' => 'Billing Fields', 'shipping' => 'Shipping Fields', 'additional' => 'Additional Fields');
|
25 |
}
|
@@ -38,17 +45,22 @@ class THWCFD_Settings_General {
|
|
38 |
add_action('woocommerce_admin_order_data_after_shipping_address', array($this, 'order_data_after_shipping_address'), 20, 1);
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
public function reset_to_default() {
|
42 |
delete_option('wc_fields_billing');
|
43 |
delete_option('wc_fields_shipping');
|
44 |
delete_option('wc_fields_additional');
|
45 |
-
|
|
|
46 |
}
|
47 |
|
48 |
public function render_page(){
|
49 |
-
if(isset($_POST['reset_fields']))
|
50 |
-
echo $this->reset_to_default();
|
51 |
-
|
52 |
$this->output_tabs();
|
53 |
$this->output_sections();
|
54 |
$this->output_content();
|
@@ -102,8 +114,8 @@ class THWCFD_Settings_General {
|
|
102 |
|
103 |
?>
|
104 |
<div class="wrap woocommerce"><div class="icon32 icon32-attributes" id="icon-woocommerce"><br /></div>
|
105 |
-
<form method="post" id="
|
106 |
-
<table id="thwcfd_checkout_fields" class="thpladmin_fields_table" cellspacing="0">
|
107 |
<thead>
|
108 |
<tr><?php $this->render_actions_row($section); ?></tr>
|
109 |
<tr><?php $this->render_checkout_fields_heading_row(); ?></tr>
|
@@ -169,9 +181,7 @@ class THWCFD_Settings_General {
|
|
169 |
</table>
|
170 |
</form>
|
171 |
<?php
|
172 |
-
$this->
|
173 |
-
$this->output_edit_field_form_pp();
|
174 |
-
//$this->output_popup_form_field_fragments();
|
175 |
}
|
176 |
|
177 |
public function get_property_set_json($name, $field){
|
@@ -215,12 +225,12 @@ class THWCFD_Settings_General {
|
|
215 |
$result = THWCFD_Utils::update_fields($section, $fields);
|
216 |
|
217 |
if($result == true) {
|
218 |
-
|
219 |
}else {
|
220 |
-
|
221 |
}
|
222 |
} catch (Exception $e) {
|
223 |
-
|
224 |
}
|
225 |
}
|
226 |
|
@@ -228,7 +238,7 @@ class THWCFD_Settings_General {
|
|
228 |
try {
|
229 |
$f_names = !empty( $_POST['f_name'] ) ? $_POST['f_name'] : array();
|
230 |
if(empty($f_names)){
|
231 |
-
|
232 |
return;
|
233 |
}
|
234 |
|
@@ -265,17 +275,17 @@ class THWCFD_Settings_General {
|
|
265 |
$result = THWCFD_Utils::update_fields($section, $fields);
|
266 |
|
267 |
if($result == true) {
|
268 |
-
|
269 |
}else {
|
270 |
-
|
271 |
}
|
272 |
} catch (Exception $e) {
|
273 |
-
|
274 |
}
|
275 |
}
|
276 |
|
277 |
private function prepare_field_from_posted_data($posted){
|
278 |
-
$field_props = $this->
|
279 |
$field = array();
|
280 |
|
281 |
foreach ($field_props as $pname => $prop) {
|
@@ -336,256 +346,6 @@ class THWCFD_Settings_General {
|
|
336 |
return $field;
|
337 |
}
|
338 |
|
339 |
-
/******* ADD,EDIT Forms *******/
|
340 |
-
/*******************************/
|
341 |
-
public function get_field_types(){
|
342 |
-
return array(
|
343 |
-
'text' => __('Text', 'woo-checkout-field-editor-pro'),
|
344 |
-
'password' => __('Password', 'woo-checkout-field-editor-pro'),
|
345 |
-
'email' => __('Email', 'woo-checkout-field-editor-pro'),
|
346 |
-
'tel' => __('Phone', 'woo-checkout-field-editor-pro'),
|
347 |
-
'select' => __('Select', 'woo-checkout-field-editor-pro'),
|
348 |
-
'textarea' => __('Textarea', 'woo-checkout-field-editor-pro'),
|
349 |
-
'radio' => __('Radio', 'woo-checkout-field-editor-pro'),
|
350 |
-
);
|
351 |
-
}
|
352 |
-
|
353 |
-
public function get_field_form_props(){
|
354 |
-
$field_types = $this->get_field_types();
|
355 |
-
|
356 |
-
$validations = array(
|
357 |
-
'email' => 'Email',
|
358 |
-
'phone' => 'Phone',
|
359 |
-
'postcode' => 'Postcode',
|
360 |
-
'state' => 'State',
|
361 |
-
'number' => 'Number',
|
362 |
-
);
|
363 |
-
|
364 |
-
$display_style = array(
|
365 |
-
'full' => 'Full width',
|
366 |
-
'half_left' => 'Half width left',
|
367 |
-
'ha;lf_right' => 'Half width right',
|
368 |
-
);
|
369 |
-
|
370 |
-
return array(
|
371 |
-
'type' => array('type'=>'select', 'name'=>'type', 'label'=>'Type', 'required'=>1, 'options'=>$field_types,
|
372 |
-
'onchange'=>'thwcfdFieldTypeChangeListner(this)'),
|
373 |
-
'name' => array('type'=>'text', 'name'=>'name', 'label'=>'Name', 'required'=>1),
|
374 |
-
'label' => array('type'=>'text', 'name'=>'label', 'label'=>'Label'),
|
375 |
-
'default' => array('type'=>'text', 'name'=>'default', 'label'=>'Default Value'),
|
376 |
-
'placeholder' => array('type'=>'text', 'name'=>'placeholder', 'label'=>'Placeholder'),
|
377 |
-
//'options' => array('type'=>'text', 'name'=>'options', 'label'=>'Options', 'placeholder'=>'Seperate options with pipe(|)'),
|
378 |
-
'class' => array('type'=>'text', 'name'=>'class', 'label'=>'Class', 'placeholder'=>'Seperate classes with comma'),
|
379 |
-
'validate' => array('type'=>'select', 'name'=>'validate', 'label'=>'Validation', 'options'=>$validations, 'multiple'=>1),
|
380 |
-
'disp_style' => array('type'=>'select', 'name'=>'disp_style', 'label'=>'Field Display', 'options'=>$display_style),
|
381 |
-
|
382 |
-
'required' => array('type'=>'checkbox', 'name'=>'required', 'label'=>'Required', 'value'=>'1', 'checked'=>1),
|
383 |
-
//'clear' => array('type'=>'checkbox', 'name'=>'clear', 'label'=>'Clear Row', 'value'=>'1', 'checked'=>1),
|
384 |
-
'enabled' => array('type'=>'checkbox', 'name'=>'enabled', 'label'=>'Enabled', 'value'=>'1', 'checked'=>1),
|
385 |
-
|
386 |
-
'show_in_email' => array('type'=>'checkbox', 'name'=>'show_in_email', 'label'=>'Display in Emails', 'value'=>'1', 'checked'=>1),
|
387 |
-
'show_in_order' => array('type'=>'checkbox', 'name'=>'show_in_order', 'label'=>'Display in Order Detail Pages', 'value'=>'1', 'checked'=>1),
|
388 |
-
);
|
389 |
-
}
|
390 |
-
|
391 |
-
private function output_add_field_form_pp(){
|
392 |
-
?>
|
393 |
-
<div id="thwcfd_new_field_form_pp" title="New Checkout Field" class="thpladmin-popup-wrapper">
|
394 |
-
<?php $this->output_popup_form_fields('new'); ?>
|
395 |
-
</div>
|
396 |
-
<?php
|
397 |
-
}
|
398 |
-
|
399 |
-
private function output_edit_field_form_pp(){
|
400 |
-
?>
|
401 |
-
<div id="thwcfd_edit_field_form_pp" title="Edit Checkout Field" class="thpladmin-popup-wrapper">
|
402 |
-
<?php $this->output_popup_form_fields('edit'); ?>
|
403 |
-
</div>
|
404 |
-
<?php
|
405 |
-
}
|
406 |
-
|
407 |
-
private function output_popup_form_fields($form_type){
|
408 |
-
$field_props = $this->get_field_form_props();
|
409 |
-
|
410 |
-
?>
|
411 |
-
<form method="post" id="thwcfd_<?php echo $form_type ?>_field_form" action="">
|
412 |
-
<input type="hidden" name="f_action" value="<?php echo $form_type ?>" />
|
413 |
-
<input type="hidden" name="i_autocomplete" value="" />
|
414 |
-
<input type="hidden" name="i_priority" value="" />
|
415 |
-
<input type="hidden" name="i_custom" value="" />
|
416 |
-
<input type="hidden" name="i_oname" value="" />
|
417 |
-
<input type="hidden" name="i_otype" value="" />
|
418 |
-
<input type="hidden" name="i_options_json" value="" />
|
419 |
-
|
420 |
-
<table width="100%">
|
421 |
-
<tr>
|
422 |
-
<td colspan="2" class="err_msgs"></td>
|
423 |
-
</tr>
|
424 |
-
<?php
|
425 |
-
$this->render_form_field_element($field_props['type']);
|
426 |
-
$this->render_form_field_element($field_props['name']);
|
427 |
-
$this->render_form_field_element($field_props['label']);
|
428 |
-
$this->render_form_field_element($field_props['placeholder']);
|
429 |
-
$this->render_form_field_element($field_props['default']);
|
430 |
-
$this->render_form_field_element($field_props['class']);
|
431 |
-
//$this->render_form_field_element($field_props['disp_style']);
|
432 |
-
$this->render_form_field_element($field_props['validate']);
|
433 |
-
//$this->render_form_field_element($field_props['options']);
|
434 |
-
$this->render_form_element_h_spacing();
|
435 |
-
$this->render_field_form_fragment_options();
|
436 |
-
$this->render_form_element_h_spacing();
|
437 |
-
|
438 |
-
?>
|
439 |
-
<tr class="row-required">
|
440 |
-
<td> </td>
|
441 |
-
<td>
|
442 |
-
<?php
|
443 |
-
$this->render_form_field_element($field_props['required']);
|
444 |
-
//$this->render_form_field_element($field_props['clear']);
|
445 |
-
$this->render_form_field_element($field_props['enabled']);
|
446 |
-
$this->render_form_field_element($field_props['show_in_email']);
|
447 |
-
$this->render_form_field_element($field_props['show_in_order']);
|
448 |
-
?>
|
449 |
-
</td>
|
450 |
-
</tr>
|
451 |
-
</table>
|
452 |
-
</form>
|
453 |
-
<?php
|
454 |
-
}
|
455 |
-
|
456 |
-
public function render_form_field_element($props){
|
457 |
-
if(is_array($props)){
|
458 |
-
$type = isset($props['type']) ? $props['type'] : 'text';
|
459 |
-
|
460 |
-
if($type === 'select'){
|
461 |
-
$this->render_form_field_element_select($props);
|
462 |
-
}else if($type === 'radio'){
|
463 |
-
$this->render_form_field_element_radio($props);
|
464 |
-
}else if($type === 'checkbox'){
|
465 |
-
$this->render_form_field_element_checkbox($props);
|
466 |
-
}else{
|
467 |
-
$this->render_form_field_element_inputtext($props);
|
468 |
-
}
|
469 |
-
}
|
470 |
-
}
|
471 |
-
|
472 |
-
private function render_form_field_element_inputtext($props){
|
473 |
-
$name = isset($props['name']) ? $props['name'] : '';
|
474 |
-
$fname = 'i_'.$name;
|
475 |
-
$label = isset($props['label']) ? __($props['label'], 'woo-checkout-field-editor-pro') : '';
|
476 |
-
|
477 |
-
$field_attr = 'name="'.$fname.'" value=""';
|
478 |
-
if(isset($props['placeholder']) && $props['placeholder']){
|
479 |
-
$field_attr .= ' placeholder="'.__($props['placeholder'], 'woo-checkout-field-editor-pro').'"';
|
480 |
-
}
|
481 |
-
$field_attr .= ' style="width:250px;"';
|
482 |
-
|
483 |
-
?>
|
484 |
-
<tr class="<?php echo 'row-'.$name; ?>">
|
485 |
-
<td width="30%"><?php echo $label; ?></td>
|
486 |
-
<td><input type="text" <?php echo $field_attr; ?> /></td>
|
487 |
-
</tr>
|
488 |
-
<?php
|
489 |
-
}
|
490 |
-
|
491 |
-
private function render_form_field_element_select($props){
|
492 |
-
$name = isset($props['name']) ? $props['name'] : '';
|
493 |
-
$fname = isset($props['multiple']) && $props['multiple'] ? 'i_'.$name.'[]' : 'i_'.$name;
|
494 |
-
$label = isset($props['label']) ? __($props['label'], 'woo-checkout-field-editor-pro') : '';
|
495 |
-
$options = isset($props['options']) ? $props['options'] : array();
|
496 |
-
$options = is_array($options) ? $options : $array();
|
497 |
-
|
498 |
-
$field_attr = 'name="'.$fname.'"';
|
499 |
-
if(isset($props['onchange']) && $props['onchange']){
|
500 |
-
$field_attr .= ' onchange="'.$props['onchange'].'"';
|
501 |
-
}
|
502 |
-
|
503 |
-
if(isset($props['placeholder']) && $props['placeholder']){
|
504 |
-
$field_attr .= ' data-placeholder="'.__($props['placeholder'], 'woo-checkout-field-editor-pro').'"';
|
505 |
-
}
|
506 |
-
|
507 |
-
if(isset($props['multiple']) && $props['multiple']){
|
508 |
-
$field_attr .= ' multiple="multiple"';
|
509 |
-
$field_attr .= ' class="thwcfd-enhanced-multi-select"';
|
510 |
-
$field_attr .= ' style="width:250px; height:30px;"';
|
511 |
-
}else{
|
512 |
-
$field_attr .= ' style="width:250px;"';
|
513 |
-
}
|
514 |
-
|
515 |
-
?>
|
516 |
-
<tr class="<?php echo 'row-'.$name; ?>">
|
517 |
-
<td width="30%"><?php echo $label; ?></td>
|
518 |
-
<td>
|
519 |
-
<select <?php echo $field_attr; ?> >
|
520 |
-
<?php foreach($options as $key => $value){ ?>
|
521 |
-
<option value="<?php echo trim($key); ?>"><?php echo $value; ?></option>
|
522 |
-
<?php } ?>
|
523 |
-
</select>
|
524 |
-
</td>
|
525 |
-
</tr>
|
526 |
-
<?php
|
527 |
-
}
|
528 |
-
|
529 |
-
private function render_form_field_element_radio($props){
|
530 |
-
$name = isset($props['name']) ? $props['name'] : '';
|
531 |
-
$label = isset($props['label']) ? __($props['label'], 'woo-checkout-field-editor-pro') : '';
|
532 |
-
$options = isset($props['options']) ? $props['options'] : array();
|
533 |
-
$options = is_array($options) ? $options : $array();
|
534 |
-
|
535 |
-
?>
|
536 |
-
<tr class="<?php echo 'row-'.$name; ?>">
|
537 |
-
<td width="30%"><?php echo $label; ?></td>
|
538 |
-
<td>
|
539 |
-
|
540 |
-
<?php foreach($options as $key => $value){ ?>
|
541 |
-
<input type="radio" name="<?php echo $name; ?>" value="<?php echo trim($key); ?>"> <?php echo $value; ?>
|
542 |
-
<?php } ?>
|
543 |
-
</td>
|
544 |
-
</tr>
|
545 |
-
<?php
|
546 |
-
}
|
547 |
-
|
548 |
-
private function render_form_field_element_checkbox($props){
|
549 |
-
$name = isset($props['name']) ? $props['name'] : '';
|
550 |
-
$fname = 'i_'.$name;
|
551 |
-
$label = isset($props['label']) ? __($props['label'], 'woo-checkout-field-editor-pro') : '';
|
552 |
-
|
553 |
-
$field_attr = 'id="'.$fname.'" name="'.$fname.'" value="1"';
|
554 |
-
if(isset($props['checked']) && $props['checked']){
|
555 |
-
$field_attr .= ' checked="checked"';
|
556 |
-
}
|
557 |
-
|
558 |
-
?>
|
559 |
-
<input type="checkbox" <?php echo $field_attr; ?> />
|
560 |
-
<label for="<?php echo $fname; ?>"><?php echo $label; ?></label><br/>
|
561 |
-
<?php
|
562 |
-
}
|
563 |
-
|
564 |
-
private function render_field_form_fragment_options(){
|
565 |
-
?>
|
566 |
-
<tr class="row-options">
|
567 |
-
<td width="30%" valign="top"><?php _e('Options', 'woo-checkout-field-editor-pro'); ?></td>
|
568 |
-
<td>
|
569 |
-
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="thwcfd-option-list thpladmin-dynamic-row-table"><tbody>
|
570 |
-
<tr>
|
571 |
-
<td style="width:150px;"><input type="text" name="i_options_key[]" placeholder="Option Value" style="width:140px;"/></td>
|
572 |
-
<td style="width:190px;"><input type="text" name="i_options_text[]" placeholder="Option Text" style="width:180px;"/></td>
|
573 |
-
<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-blue" title="Add new option">+</a></td>
|
574 |
-
<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-red" title="Remove option">x</a></td>
|
575 |
-
<td class="action-cell sort ui-sortable-handle"></td>
|
576 |
-
</tr>
|
577 |
-
</tbody></table>
|
578 |
-
</td>
|
579 |
-
</tr>
|
580 |
-
<?php
|
581 |
-
}
|
582 |
-
|
583 |
-
public function render_form_element_h_spacing($padding = 5, $colspan = 2){
|
584 |
-
?>
|
585 |
-
<tr><td colspan="<?php echo $colspan; ?>" style="padding-top:<?php echo $padding ?>px;"></td></tr>
|
586 |
-
<?php
|
587 |
-
}
|
588 |
-
|
589 |
/******* Display & Update Field Values *******/
|
590 |
/*********************************************/
|
591 |
public function order_data_after_order_details($order){
|
@@ -657,6 +417,11 @@ class THWCFD_Settings_General {
|
|
657 |
}
|
658 |
|
659 |
public function output_sections() {
|
|
|
|
|
|
|
|
|
|
|
660 |
$current_tab = $this->get_current_tab();
|
661 |
$current_section = $this->get_current_section();
|
662 |
|
@@ -673,6 +438,10 @@ class THWCFD_Settings_General {
|
|
673 |
echo '<li><a href="'. $url .'" class="'. ( $current_section == $id ? 'current' : '' ) .'">'. $label .'</a> '. (end( $array_keys ) == $id ? '' : '|') .' </li>';
|
674 |
}
|
675 |
echo '</ul>';
|
|
|
|
|
|
|
|
|
676 |
}
|
677 |
|
678 |
public function get_admin_url($tab = false, $section = false){
|
11 |
|
12 |
defined( 'ABSPATH' ) || exit;
|
13 |
|
14 |
+
if(!class_exists('THWCFD_Admin_Settings_General')):
|
15 |
|
16 |
+
class THWCFD_Admin_Settings_General extends THWCFD_Admin_Settings{
|
17 |
protected static $_instance = null;
|
18 |
|
19 |
+
private $field_form = null;
|
20 |
+
private $field_form_props = array();
|
21 |
+
|
22 |
protected $tabs = '';
|
23 |
protected $sections = '';
|
24 |
|
25 |
public function __construct() {
|
26 |
+
parent::__construct();
|
27 |
+
$this->page_id = 'fields';
|
28 |
+
$this->section_id = 'billing';
|
29 |
+
|
30 |
$this->tabs = array( 'fields' => 'Checkout Fields', 'advanced_settings' => 'Advanced Settings');
|
31 |
$this->sections = array('billing' => 'Billing Fields', 'shipping' => 'Shipping Fields', 'additional' => 'Additional Fields');
|
32 |
}
|
45 |
add_action('woocommerce_admin_order_data_after_shipping_address', array($this, 'order_data_after_shipping_address'), 20, 1);
|
46 |
}
|
47 |
|
48 |
+
public function init(){
|
49 |
+
$this->field_form = new THWCFD_Admin_Form_Field();
|
50 |
+
$this->field_form_props = $this->field_form->get_field_form_props();
|
51 |
+
|
52 |
+
$this->render_page();
|
53 |
+
}
|
54 |
+
|
55 |
public function reset_to_default() {
|
56 |
delete_option('wc_fields_billing');
|
57 |
delete_option('wc_fields_shipping');
|
58 |
delete_option('wc_fields_additional');
|
59 |
+
|
60 |
+
return $this->print_notices('Checkout fields successfully reset', 'updated', true);
|
61 |
}
|
62 |
|
63 |
public function render_page(){
|
|
|
|
|
|
|
64 |
$this->output_tabs();
|
65 |
$this->output_sections();
|
66 |
$this->output_content();
|
114 |
|
115 |
?>
|
116 |
<div class="wrap woocommerce"><div class="icon32 icon32-attributes" id="icon-woocommerce"><br /></div>
|
117 |
+
<form method="post" id="thwcfd_checkout_fields_form" action="">
|
118 |
+
<table id="thwcfd_checkout_fields" class="wc_gateways widefat thpladmin_fields_table" cellspacing="0">
|
119 |
<thead>
|
120 |
<tr><?php $this->render_actions_row($section); ?></tr>
|
121 |
<tr><?php $this->render_checkout_fields_heading_row(); ?></tr>
|
181 |
</table>
|
182 |
</form>
|
183 |
<?php
|
184 |
+
$this->field_form->output_field_forms();
|
|
|
|
|
185 |
}
|
186 |
|
187 |
public function get_property_set_json($name, $field){
|
225 |
$result = THWCFD_Utils::update_fields($section, $fields);
|
226 |
|
227 |
if($result == true) {
|
228 |
+
$this->print_notices('Your changes were saved.', 'updated');
|
229 |
}else {
|
230 |
+
$this->print_notices('Your changes were not saved due to an error (or you made none!).', 'error');
|
231 |
}
|
232 |
} catch (Exception $e) {
|
233 |
+
$this->print_notices('Your changes were not saved due to an error.', 'error');
|
234 |
}
|
235 |
}
|
236 |
|
238 |
try {
|
239 |
$f_names = !empty( $_POST['f_name'] ) ? $_POST['f_name'] : array();
|
240 |
if(empty($f_names)){
|
241 |
+
$this->print_notices('Your changes were not saved due to no fields found.', 'error');
|
242 |
return;
|
243 |
}
|
244 |
|
275 |
$result = THWCFD_Utils::update_fields($section, $fields);
|
276 |
|
277 |
if($result == true) {
|
278 |
+
$this->print_notices('Your changes were saved.', 'updated');
|
279 |
}else {
|
280 |
+
$this->print_notices('Your changes were not saved due to an error (or you made none!).', 'error');
|
281 |
}
|
282 |
} catch (Exception $e) {
|
283 |
+
$this->print_notices('Your changes were not saved due to an error.', 'error');
|
284 |
}
|
285 |
}
|
286 |
|
287 |
private function prepare_field_from_posted_data($posted){
|
288 |
+
$field_props = $this->field_form_props;
|
289 |
$field = array();
|
290 |
|
291 |
foreach ($field_props as $pname => $prop) {
|
346 |
return $field;
|
347 |
}
|
348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
/******* Display & Update Field Values *******/
|
350 |
/*********************************************/
|
351 |
public function order_data_after_order_details($order){
|
417 |
}
|
418 |
|
419 |
public function output_sections() {
|
420 |
+
$result = false;
|
421 |
+
|
422 |
+
if(isset($_POST['reset_fields']))
|
423 |
+
$result = $this->reset_to_default();
|
424 |
+
|
425 |
$current_tab = $this->get_current_tab();
|
426 |
$current_section = $this->get_current_section();
|
427 |
|
438 |
echo '<li><a href="'. $url .'" class="'. ( $current_section == $id ? 'current' : '' ) .'">'. $label .'</a> '. (end( $array_keys ) == $id ? '' : '|') .' </li>';
|
439 |
}
|
440 |
echo '</ul>';
|
441 |
+
|
442 |
+
if($result){
|
443 |
+
echo $result;
|
444 |
+
}
|
445 |
}
|
446 |
|
447 |
public function get_admin_url($tab = false, $section = false){
|
admin/class-thwcfd-admin-settings.php
ADDED
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The admin settings page functionality of the plugin.
|
4 |
+
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
*
|
7 |
+
* @package woo-checkout-field-editor-pro
|
8 |
+
* @subpackage woo-checkout-field-editor-pro/admin
|
9 |
+
*/
|
10 |
+
|
11 |
+
if(!defined('WPINC')){ die; }
|
12 |
+
|
13 |
+
if(!class_exists('THWCFD_Admin_Settings')):
|
14 |
+
|
15 |
+
abstract class THWCFD_Admin_Settings{
|
16 |
+
protected $page_id = '';
|
17 |
+
protected $section_id = '';
|
18 |
+
|
19 |
+
protected $tabs = '';
|
20 |
+
protected $sections = '';
|
21 |
+
|
22 |
+
public function __construct() {
|
23 |
+
$this->tabs = array( 'fields' => 'Checkout Fields', 'advanced_settings' => 'Advanced Settings');
|
24 |
+
}
|
25 |
+
|
26 |
+
public function get_tabs(){
|
27 |
+
return $this->tabs;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function get_current_tab(){
|
31 |
+
return $this->page_id;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function get_current_section(){
|
35 |
+
return isset( $_GET['section'] ) ? esc_attr( $_GET['section'] ) : $this->section_id;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function render_tabs(){
|
39 |
+
$current_tab = $this->get_current_tab();
|
40 |
+
$tabs = $this->get_tabs();
|
41 |
+
|
42 |
+
if(empty($tabs)){
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
echo '<h2 class="thpladmin-tabs nav-tab-wrapper woo-nav-tab-wrapper">';
|
47 |
+
foreach( $tabs as $id => $label ){
|
48 |
+
$active = ( $current_tab == $id ) ? 'nav-tab-active' : '';
|
49 |
+
$label = __($label, 'woo-checkout-field-editor-pro');
|
50 |
+
echo '<a class="nav-tab '.$active.'" href="'. $this->get_admin_url($id) .'">'.$label.'</a>';
|
51 |
+
}
|
52 |
+
echo '</h2>';
|
53 |
+
}
|
54 |
+
|
55 |
+
// public function render_sections() {
|
56 |
+
// $current_section = $this->get_current_section();
|
57 |
+
// $sections = $this->get_sections();
|
58 |
+
|
59 |
+
// if(empty($sections)){
|
60 |
+
// return;
|
61 |
+
// }
|
62 |
+
|
63 |
+
// $array_keys = array_keys( $sections );
|
64 |
+
|
65 |
+
// echo '<ul class="thpladmin-sections">';
|
66 |
+
// foreach( $sections as $id => $label ){
|
67 |
+
// $label = wp_strip_all_tags(__($label, 'woo-checkout-field-editor-pro'));
|
68 |
+
// $url = $this->get_admin_url($this->page_id, sanitize_title($id));
|
69 |
+
// echo '<li><a href="'. $url .'" class="'. ( $current_section == $id ? 'current' : '' ) .'">'. $label .'</a> '. (end( $array_keys ) == $id ? '' : '|') .' </li>';
|
70 |
+
// }
|
71 |
+
// echo '</ul>';
|
72 |
+
// }
|
73 |
+
|
74 |
+
public function get_admin_url($tab = false, $section = false){
|
75 |
+
$url = 'admin.php?page=checkout_form_designer';
|
76 |
+
if($tab && !empty($tab)){
|
77 |
+
$url .= '&tab='. $tab;
|
78 |
+
}
|
79 |
+
if($section && !empty($section)){
|
80 |
+
$url .= '§ion='. $section;
|
81 |
+
}
|
82 |
+
return admin_url($url);
|
83 |
+
}
|
84 |
+
|
85 |
+
public function print_notices($msg, $type='updated', $return=false){
|
86 |
+
$notice = '<div class="thwcfd-notice '. $type .'"><p>'. __($msg, 'woo-checkout-field-editor-pro') .'</p></div>';
|
87 |
+
if(!$return){
|
88 |
+
echo $notice;
|
89 |
+
}
|
90 |
+
return $notice;
|
91 |
+
}
|
92 |
+
|
93 |
+
/*******************************************
|
94 |
+
*-------- HTML FORM FRAGMENTS - START -----
|
95 |
+
*******************************************/
|
96 |
+
|
97 |
+
public function render_form_element_tooltip($tooltip=''){
|
98 |
+
$tooltip_html = '';
|
99 |
+
|
100 |
+
if($tooltip){
|
101 |
+
// $icon = THWCFD_ASSETS_URL_ADMIN.'/css/help.png';
|
102 |
+
// $tooltip_html = '<a href="javascript:void(0)" title="'. $tooltip .'" class="thpladmin_tooltip"><img src="'. $icon .'" alt="" title=""/></a>';
|
103 |
+
}
|
104 |
+
?>
|
105 |
+
<td style="width: 26px; padding:0px;"><?php echo $tooltip_html; ?></td>
|
106 |
+
<?php
|
107 |
+
}
|
108 |
+
|
109 |
+
public function render_form_element_empty_cell(){
|
110 |
+
?>
|
111 |
+
<td width="13%"> </td>
|
112 |
+
<?php $this->render_form_element_tooltip(false); ?>
|
113 |
+
<td width="34%"> </td>
|
114 |
+
<?php
|
115 |
+
}
|
116 |
+
|
117 |
+
public function render_form_element_h_separator($padding = 5, $colspan = 6){
|
118 |
+
?>
|
119 |
+
<tr><td colspan="<?php echo $colspan; ?>" style="border-bottom: 1px dashed #e6e6e6; padding-top: <?php echo $padding ?>px;"></td></tr>
|
120 |
+
<?php
|
121 |
+
}
|
122 |
+
|
123 |
+
public function render_form_element_h_spacing($padding = 5, $colspan = 6){
|
124 |
+
?>
|
125 |
+
<tr><td colspan="<?php echo $colspan; ?>" style="padding-top:<?php echo $padding ?>px;"></td></tr>
|
126 |
+
<?php
|
127 |
+
}
|
128 |
+
|
129 |
+
public function render_form_field_element($field, $atts = array(), $render_cell = true){
|
130 |
+
if($field && is_array($field)){
|
131 |
+
$args = shortcode_atts( array(
|
132 |
+
'label_cell_props' => '',
|
133 |
+
'input_cell_props' => '',
|
134 |
+
'label_cell_colspan' => '',
|
135 |
+
'input_cell_colspan' => '',
|
136 |
+
), $atts );
|
137 |
+
|
138 |
+
$ftype = isset($field['type']) ? $field['type'] : 'text';
|
139 |
+
$flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : '';
|
140 |
+
$sub_label = isset($field['sub_label']) && !empty($field['sub_label']) ? __($field['sub_label'], 'woo-checkout-field-editor-pro') : '';
|
141 |
+
$tooltip = isset($field['hint_text']) && !empty($field['hint_text']) ? __($field['hint_text'], 'woo-checkout-field-editor-pro') : '';
|
142 |
+
|
143 |
+
$field_html = '';
|
144 |
+
|
145 |
+
if($ftype == 'text'){
|
146 |
+
$field_html = $this->render_form_field_element_inputtext($field, $atts);
|
147 |
+
|
148 |
+
}else if($ftype == 'textarea'){
|
149 |
+
$field_html = $this->render_form_field_element_textarea($field, $atts);
|
150 |
+
|
151 |
+
}else if($ftype == 'checkbox'){
|
152 |
+
$field_html = $this->render_form_field_element_checkbox($field, $atts, $render_cell);
|
153 |
+
$flabel = ' ';
|
154 |
+
}
|
155 |
+
|
156 |
+
if($render_cell){
|
157 |
+
$required_html = isset($field['required']) && $field['required'] ? '<abbr class="required" title="required">*</abbr>' : '';
|
158 |
+
|
159 |
+
$label_cell_props = !empty($args['label_cell_props']) ? $args['label_cell_props'] : '';
|
160 |
+
$input_cell_props = !empty($args['input_cell_props']) ? $args['input_cell_props'] : '';
|
161 |
+
|
162 |
+
?>
|
163 |
+
<td <?php echo $label_cell_props ?> >
|
164 |
+
<?php echo $flabel; echo $required_html;
|
165 |
+
if($sub_label){
|
166 |
+
?>
|
167 |
+
<br/><span class="thpladmin-subtitle"><?php echo $sub_label; ?></span>
|
168 |
+
<?php
|
169 |
+
}
|
170 |
+
?>
|
171 |
+
</td>
|
172 |
+
<?php $this->render_form_fragment_tooltip($tooltip); ?>
|
173 |
+
<td <?php echo $input_cell_props ?> ><?php echo $field_html; ?></td>
|
174 |
+
<?php
|
175 |
+
}else{
|
176 |
+
echo $field_html;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
private function prepare_form_field_props($field, $atts = array()){
|
182 |
+
$field_props = '';
|
183 |
+
$args = shortcode_atts( array(
|
184 |
+
'input_width' => '',
|
185 |
+
'input_name_prefix' => 'i_',
|
186 |
+
'input_name_suffix' => '',
|
187 |
+
), $atts );
|
188 |
+
|
189 |
+
$ftype = isset($field['type']) ? $field['type'] : 'text';
|
190 |
+
|
191 |
+
if($ftype == 'multiselect'){
|
192 |
+
$args['input_name_suffix'] = $args['input_name_suffix'].'[]';
|
193 |
+
}
|
194 |
+
|
195 |
+
$fname = $args['input_name_prefix'].$field['name'].$args['input_name_suffix'];
|
196 |
+
$fvalue = isset($field['value']) ? esc_html($field['value']) : '';
|
197 |
+
|
198 |
+
$input_width = $args['input_width'] ? 'width:'.$args['input_width'].';' : '';
|
199 |
+
$field_props = 'name="'. $fname .'" value="'. $fvalue .'" style="'. $input_width .'"';
|
200 |
+
$field_props .= ( isset($field['placeholder']) && !empty($field['placeholder']) ) ? ' placeholder="'.$field['placeholder'].'"' : '';
|
201 |
+
$field_props .= ( isset($field['onchange']) && !empty($field['onchange']) ) ? ' onchange="'.$field['onchange'].'"' : '';
|
202 |
+
|
203 |
+
return $field_props;
|
204 |
+
}
|
205 |
+
|
206 |
+
private function render_form_field_element_inputtext($field, $atts = array()){
|
207 |
+
$field_html = '';
|
208 |
+
if($field && is_array($field)){
|
209 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
210 |
+
$field_html = '<input type="text" '. $field_props .' />';
|
211 |
+
}
|
212 |
+
return $field_html;
|
213 |
+
}
|
214 |
+
|
215 |
+
private function render_form_field_element_textarea($field, $atts = array()){
|
216 |
+
$field_html = '';
|
217 |
+
if($field && is_array($field)){
|
218 |
+
$args = shortcode_atts( array(
|
219 |
+
'rows' => '5',
|
220 |
+
'cols' => '100',
|
221 |
+
), $atts );
|
222 |
+
|
223 |
+
$fvalue = isset($field['value']) ? $field['value'] : '';
|
224 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
225 |
+
$field_html = '<textarea '. $field_props .' rows="'.$args['rows'].'" cols="'.$args['cols'].'" >'.$fvalue.'</textarea>';
|
226 |
+
}
|
227 |
+
return $field_html;
|
228 |
+
}
|
229 |
+
|
230 |
+
private function render_form_field_element_checkbox($field, $atts = array(), $render_cell = true){
|
231 |
+
$field_html = '';
|
232 |
+
if($field && is_array($field)){
|
233 |
+
$args = shortcode_atts( array(
|
234 |
+
'label_props' => '',
|
235 |
+
'cell_props' => 3,
|
236 |
+
'render_input_cell' => false,
|
237 |
+
), $atts );
|
238 |
+
|
239 |
+
$fid = 'a_f'. $field['name'];
|
240 |
+
$flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : '';
|
241 |
+
|
242 |
+
$field_props = $this->prepare_form_field_props($field, $atts);
|
243 |
+
$field_props .= isset($field['checked']) && $field['checked'] === 1 ? ' checked' : '';
|
244 |
+
|
245 |
+
$field_html = '<input type="checkbox" id="'. $fid .'" '. $field_props .' />';
|
246 |
+
$field_html .= '<label for="'. $fid .'" '. $args['label_props'] .' > '. $flabel .'</label>';
|
247 |
+
}
|
248 |
+
if(!$render_cell && $args['render_input_cell']){
|
249 |
+
return '<td '. $args['cell_props'] .' >'. $field_html .'</td>';
|
250 |
+
}else{
|
251 |
+
return $field_html;
|
252 |
+
}
|
253 |
+
}
|
254 |
+
/*******************************************
|
255 |
+
*-------- HTML FORM FRAGMENTS - END -----
|
256 |
+
*******************************************/
|
257 |
+
}
|
258 |
+
|
259 |
+
endif;
|
classes/class-thwcfd-settings.php → admin/class-thwcfd-admin.php
RENAMED
@@ -1,33 +1,54 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @
|
6 |
-
*
|
|
|
|
|
7 |
*/
|
8 |
|
9 |
-
defined(
|
10 |
-
|
11 |
-
if(!class_exists('
|
12 |
-
|
13 |
-
class
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
|
18 |
public function enqueue_styles_and_scripts($hook) {
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
24 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
|
|
26 |
$deps = array('jquery', 'jquery-ui-dialog', 'jquery-ui-sortable', 'jquery-tiptip', 'woocommerce_admin', 'selectWoo', 'wp-color-picker');
|
27 |
-
|
28 |
-
|
29 |
-
wp_enqueue_style('thwcfd-admin-style', THWCFD_ASSETS_URL . 'css/thwcfd-admin.css', THWCFD_VERSION);
|
30 |
-
wp_enqueue_script('thwcfd-admin-script', THWCFD_ASSETS_URL . 'js/thwcfd-admin.js', $deps, THWCFD_VERSION, true);
|
31 |
}
|
32 |
|
33 |
public function wcfd_capability() {
|
@@ -42,9 +63,7 @@ class THWCFD_Settings {
|
|
42 |
|
43 |
public function admin_menu() {
|
44 |
$capability = $this->wcfd_capability();
|
45 |
-
$this->screen_id = add_submenu_page('woocommerce', __('WooCommerce Checkout
|
46 |
-
|
47 |
-
//add_action('admin_print_scripts-'. $this->screen_id, array($this, 'enqueue_admin_scripts'));
|
48 |
}
|
49 |
|
50 |
public function add_screen_id($ids){
|
@@ -60,24 +79,13 @@ class THWCFD_Settings {
|
|
60 |
return $links;
|
61 |
}
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
$row_meta = array(
|
69 |
-
'docs' => '<a href="'.$doc_link.'" target="_blank" aria-label="'.__('View plugin documentation', 'woo-checkout-field-editor-pro').'">'.__('Docs', 'woo-checkout-field-editor-pro').'</a>',
|
70 |
-
'support' => '<a href="'.$support_link.'" target="_blank" aria-label="'. __('Visit premium customer support', 'woo-checkout-field-editor-pro') .'">'. __('Premium support', 'woo-checkout-field-editor-pro') .'</a>',
|
71 |
-
);
|
72 |
-
|
73 |
-
return array_merge( $links, $row_meta );
|
74 |
}
|
75 |
-
return (array) $links;
|
76 |
-
}*/
|
77 |
-
|
78 |
-
private function output_premium_version_notice(){
|
79 |
?>
|
80 |
-
<div id="message" class="
|
81 |
<div class="squeezer">
|
82 |
<table>
|
83 |
<tr>
|
@@ -93,7 +101,7 @@ class THWCFD_Settings {
|
|
93 |
</td>
|
94 |
<td>
|
95 |
<a target="_blank" href="https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/">
|
96 |
-
<img src="<?php echo
|
97 |
</a>
|
98 |
</td>
|
99 |
</tr>
|
@@ -106,7 +114,13 @@ class THWCFD_Settings {
|
|
106 |
private function output_review_request_link(){
|
107 |
?>
|
108 |
<p>If you like our <strong>Checkout Field Editor</strong> plugin please leave us a <a href="https://wordpress.org/support/plugin/woo-checkout-field-editor-pro/reviews?rate=5#new-post" target="_blank" aria-label="five star" data-rated="Thanks :)">★★★★★</a> rating. A huge thanks in advance!</p>
|
109 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
|
112 |
public function output_settings(){
|
@@ -117,19 +131,21 @@ class THWCFD_Settings {
|
|
117 |
|
118 |
echo '<div class="thwcfd-wrap">';
|
119 |
if($tab === 'advanced_settings'){
|
120 |
-
$advanced_settings =
|
121 |
$advanced_settings->render_page();
|
122 |
}else{
|
123 |
-
$general_settings =
|
124 |
-
$general_settings->
|
125 |
}
|
126 |
echo '</div">';
|
127 |
}
|
128 |
|
129 |
-
public function
|
130 |
-
|
|
|
|
|
|
|
131 |
}
|
132 |
}
|
133 |
|
134 |
-
endif;
|
135 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* The admin-specific functionality of the plugin.
|
4 |
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
*
|
7 |
+
* @package woo-checkout-field-editor-pro
|
8 |
+
* @subpackage woo-checkout-field-editor-pro/admin
|
9 |
*/
|
10 |
|
11 |
+
if(!defined('WPINC')){ die; }
|
12 |
+
|
13 |
+
if(!class_exists('THWCFD_Admin')):
|
14 |
+
|
15 |
+
class THWCFD_Admin {
|
16 |
+
private $plugin_name;
|
17 |
+
private $version;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Initialize the class and set its properties.
|
21 |
+
*
|
22 |
+
* @since 2.9.0
|
23 |
+
* @param string $plugin_name The name of this plugin.
|
24 |
+
* @param string $version The version of this plugin.
|
25 |
+
*/
|
26 |
+
public function __construct( $plugin_name, $version ) {
|
27 |
+
$this->plugin_name = $plugin_name;
|
28 |
+
$this->version = $version;
|
29 |
+
|
30 |
+
//add_action('admin_notices', array($this, 'output_premium_version_notice'));
|
31 |
}
|
32 |
|
33 |
public function enqueue_styles_and_scripts($hook) {
|
34 |
+
if(strpos($hook, 'page_checkout_form_designer') !== false) {
|
35 |
+
$debug_mode = apply_filters('thwcfd_debug_mode', false);
|
36 |
+
$suffix = $debug_mode ? '' : '.min';
|
37 |
+
|
38 |
+
$this->enqueue_styles($suffix);
|
39 |
+
$this->enqueue_scripts($suffix);
|
40 |
}
|
41 |
+
}
|
42 |
+
|
43 |
+
private function enqueue_styles($suffix) {
|
44 |
+
wp_enqueue_style('woocommerce_admin_styles');
|
45 |
+
wp_enqueue_style('thwcfd-admin-style', THWCFD_ASSETS_URL_ADMIN . 'css/thwcfd-admin'. $suffix .'.css', $this->version);
|
46 |
+
}
|
47 |
|
48 |
+
private function enqueue_scripts($suffix) {
|
49 |
$deps = array('jquery', 'jquery-ui-dialog', 'jquery-ui-sortable', 'jquery-tiptip', 'woocommerce_admin', 'selectWoo', 'wp-color-picker');
|
50 |
+
|
51 |
+
wp_enqueue_script('thwcfd-admin-script', THWCFD_ASSETS_URL_ADMIN . 'js/thwcfd-admin'. $suffix .'.js', $deps, $this->version, false);
|
|
|
|
|
52 |
}
|
53 |
|
54 |
public function wcfd_capability() {
|
63 |
|
64 |
public function admin_menu() {
|
65 |
$capability = $this->wcfd_capability();
|
66 |
+
$this->screen_id = add_submenu_page('woocommerce', __('WooCommerce Checkout Field Editor', 'woo-checkout-field-editor-pro'), __('Checkout Form', 'woo-checkout-field-editor-pro'), $capability, 'checkout_form_designer', array($this, 'output_settings'));
|
|
|
|
|
67 |
}
|
68 |
|
69 |
public function add_screen_id($ids){
|
79 |
return $links;
|
80 |
}
|
81 |
|
82 |
+
public function output_premium_version_notice(){
|
83 |
+
$is_dismissed = get_transient('thwcfd_upgrade_notice_dismissed');
|
84 |
+
if($is_dismissed){
|
85 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
}
|
|
|
|
|
|
|
|
|
87 |
?>
|
88 |
+
<div id="message" class="notice notice-success is-dismissible thpladmin-notice" data-nonce="<?php echo wp_create_nonce( 'thwcfd_upgrade_notice'); ?>">
|
89 |
<div class="squeezer">
|
90 |
<table>
|
91 |
<tr>
|
101 |
</td>
|
102 |
<td>
|
103 |
<a target="_blank" href="https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/">
|
104 |
+
<img src="<?php echo THWCFD_ASSETS_URL_ADMIN ?>css/upgrade-btn.png" />
|
105 |
</a>
|
106 |
</td>
|
107 |
</tr>
|
114 |
private function output_review_request_link(){
|
115 |
?>
|
116 |
<p>If you like our <strong>Checkout Field Editor</strong> plugin please leave us a <a href="https://wordpress.org/support/plugin/woo-checkout-field-editor-pro/reviews?rate=5#new-post" target="_blank" aria-label="five star" data-rated="Thanks :)">★★★★★</a> rating. A huge thanks in advance!</p>
|
117 |
+
<?php
|
118 |
+
|
119 |
+
//If you find this plugin useful please show your support and rate it ★★★★★ on WordPress.org - much appreciated! :)
|
120 |
+
}
|
121 |
+
|
122 |
+
public function get_current_tab(){
|
123 |
+
return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
124 |
}
|
125 |
|
126 |
public function output_settings(){
|
131 |
|
132 |
echo '<div class="thwcfd-wrap">';
|
133 |
if($tab === 'advanced_settings'){
|
134 |
+
$advanced_settings = THWCFD_Admin_Settings_Advanced::instance();
|
135 |
$advanced_settings->render_page();
|
136 |
}else{
|
137 |
+
$general_settings = THWCFD_Admin_Settings_General::instance();
|
138 |
+
$general_settings->init();
|
139 |
}
|
140 |
echo '</div">';
|
141 |
}
|
142 |
|
143 |
+
public function dismiss_thwcfd_upgrade_notice(){
|
144 |
+
if(! check_ajax_referer( 'thwcfd_upgrade_notice', 'security' )){
|
145 |
+
die();
|
146 |
+
}
|
147 |
+
set_transient('thwcfd_upgrade_notice_dismissed', true, 4 * WEEK_IN_SECONDS);
|
148 |
}
|
149 |
}
|
150 |
|
151 |
+
endif;
|
|
assets/css/thwcfd-admin.css
DELETED
@@ -1,550 +0,0 @@
|
|
1 |
-
|
2 |
-
/***** TABS & SECTIONS ******
|
3 |
-
****************************/
|
4 |
-
.thpladmin-tabs a{
|
5 |
-
font-size: 16px;
|
6 |
-
}
|
7 |
-
.thpladmin-sections {
|
8 |
-
list-style: outside none none;
|
9 |
-
margin: 8px 0 0;
|
10 |
-
padding: 0;
|
11 |
-
font-size: 15px;
|
12 |
-
color: #666;
|
13 |
-
}
|
14 |
-
.thpladmin-sections li {
|
15 |
-
display: inline-block;
|
16 |
-
margin: 0px;
|
17 |
-
padding: 0px;
|
18 |
-
white-space: nowrap;
|
19 |
-
}
|
20 |
-
.thpladmin-sections a {
|
21 |
-
line-height: 2;
|
22 |
-
padding: 0.2em;
|
23 |
-
text-decoration: none;
|
24 |
-
}
|
25 |
-
.thpladmin-sections a.current {
|
26 |
-
font-weight: 600;
|
27 |
-
border: medium none;
|
28 |
-
color: #000;
|
29 |
-
}
|
30 |
-
|
31 |
-
/***** FIELDS TABLE ******
|
32 |
-
*************************/
|
33 |
-
.err_msgs{
|
34 |
-
color: #FF0000;
|
35 |
-
}
|
36 |
-
|
37 |
-
table.thpladmin_fields_table{
|
38 |
-
position: relative;
|
39 |
-
background: #fff;
|
40 |
-
border: 1px solid #e5e5e5;
|
41 |
-
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
42 |
-
border-spacing: 0;
|
43 |
-
width: 100%;
|
44 |
-
clear: both;
|
45 |
-
margin: 0;
|
46 |
-
}
|
47 |
-
|
48 |
-
table.thpladmin_fields_table thead th,
|
49 |
-
table.thpladmin_fields_table tfoot th {
|
50 |
-
color: #32373c;
|
51 |
-
font-weight: 400;
|
52 |
-
text-align: left;
|
53 |
-
font-size: 14px;
|
54 |
-
}
|
55 |
-
table.thpladmin_fields_table thead th {
|
56 |
-
border-bottom: 1px solid #e1e1e1;
|
57 |
-
border-bottom-color: rgb(225, 225, 225);
|
58 |
-
border-bottom-style: solid;
|
59 |
-
border-bottom-width: 1px;
|
60 |
-
}
|
61 |
-
|
62 |
-
.thpladmin_fields_table tfoot td,
|
63 |
-
.thpladmin_fields_table tfoot th {
|
64 |
-
border-top: 1px solid #e1e1e1;
|
65 |
-
border-bottom: none;
|
66 |
-
}
|
67 |
-
|
68 |
-
table.thpladmin_fields_table td{
|
69 |
-
color: #555;
|
70 |
-
}
|
71 |
-
table.thpladmin_fields_table tr:nth-child(2n+1) td{
|
72 |
-
background: #f9f9f9;
|
73 |
-
}
|
74 |
-
|
75 |
-
table.thpladmin_fields_table td,
|
76 |
-
table.thpladmin_fields_table th{
|
77 |
-
display: table-cell !important;
|
78 |
-
padding: 13px !important;
|
79 |
-
vertical-align: top;
|
80 |
-
line-height: 22px;
|
81 |
-
}
|
82 |
-
|
83 |
-
table.thpladmin_fields_table thead th.status,
|
84 |
-
table.thpladmin_fields_table tfoot th.status,
|
85 |
-
table.thpladmin_fields_table tbody td.status {
|
86 |
-
text-align: center;
|
87 |
-
}
|
88 |
-
|
89 |
-
table.thpladmin_fields_table td.sort{
|
90 |
-
cursor: move;
|
91 |
-
font-size: 20px !important;
|
92 |
-
padding: 13px !important;
|
93 |
-
text-align: center;
|
94 |
-
}
|
95 |
-
table.thpladmin_fields_table td.sort::before{
|
96 |
-
content: '\f333';
|
97 |
-
font-family: Dashicons;
|
98 |
-
text-align: center;
|
99 |
-
line-height: 1;
|
100 |
-
color: #999;
|
101 |
-
display: block;
|
102 |
-
width: 17px;
|
103 |
-
float: left;
|
104 |
-
height: 100%;
|
105 |
-
line-height: 24px;
|
106 |
-
}
|
107 |
-
|
108 |
-
table.thpladmin_fields_table td.action{
|
109 |
-
padding: 10px 12px !important;
|
110 |
-
}
|
111 |
-
table.thpladmin_fields_table td.action .action-btn{
|
112 |
-
padding: 2px 4px;
|
113 |
-
line-height: 15px;
|
114 |
-
height: 22px;
|
115 |
-
/*background-color: #f7f7f7;*/
|
116 |
-
}
|
117 |
-
|
118 |
-
table.thpladmin_fields_table tr.thpladmin-strikeout td {
|
119 |
-
background: rgba(255, 0, 0, .4)!important;
|
120 |
-
opacity: 0.6;
|
121 |
-
text-decoration: line-through;
|
122 |
-
}
|
123 |
-
|
124 |
-
table.thpladmin_fields_table tr.thpladmin-disabled td {
|
125 |
-
opacity: 0.4;
|
126 |
-
}
|
127 |
-
table.thpladmin_fields_table tr.thpladmin-disabled td.td_select {
|
128 |
-
opacity: 1;
|
129 |
-
}
|
130 |
-
|
131 |
-
.thpladmin-dynamic-row-table .action-cell{
|
132 |
-
width: 30px;
|
133 |
-
text-align: center;
|
134 |
-
}
|
135 |
-
.thpladmin-dynamic-row-table .action-cell a.btn{
|
136 |
-
background-color:#00A0D2;
|
137 |
-
border:1px solid #0073AA;
|
138 |
-
color:#FFFFFF;
|
139 |
-
padding:2px 5px;
|
140 |
-
border-radius: 3px;
|
141 |
-
font-size:12px;
|
142 |
-
text-decoration:none;
|
143 |
-
}
|
144 |
-
.thpladmin-dynamic-row-table .action-cell a.btn-blue{
|
145 |
-
background-color:#00A0D2;
|
146 |
-
border:1px solid #0073AA;
|
147 |
-
}
|
148 |
-
.thpladmin-dynamic-row-table .action-cell a.btn-red{
|
149 |
-
background-color:#ff6666;
|
150 |
-
border:1px solid #ff4c4c;
|
151 |
-
}
|
152 |
-
|
153 |
-
.thpladmin-dynamic-row-table .action-cell a.dashicons{
|
154 |
-
line-height: inherit;
|
155 |
-
font-size: 18px;
|
156 |
-
color: #fff;
|
157 |
-
border-radius: 3px;
|
158 |
-
box-shadow: 0 1px 0 #ccc;
|
159 |
-
}
|
160 |
-
.thpladmin-dynamic-row-table .action-cell a.dashicons-plus{
|
161 |
-
background-color:#00A0D2;
|
162 |
-
border:1px solid #0073AA;
|
163 |
-
}
|
164 |
-
.thpladmin-dynamic-row-table .action-cell a.dashicons-no-alt{
|
165 |
-
background-color:#ff6666;
|
166 |
-
border:1px solid #ff4c4c;
|
167 |
-
}
|
168 |
-
|
169 |
-
/***** PREMIUM NOTICE ******
|
170 |
-
****************************/
|
171 |
-
.thpladmin-notice a {
|
172 |
-
display:block;
|
173 |
-
padding:0;
|
174 |
-
height: 63px;
|
175 |
-
}
|
176 |
-
.thpladmin-notice p {
|
177 |
-
margin-bottom:0px;
|
178 |
-
}
|
179 |
-
.thpladmin-notice ul {
|
180 |
-
list-style-type: none;
|
181 |
-
margin: 0px;
|
182 |
-
}
|
183 |
-
.thpladmin-notice ul li {
|
184 |
-
background:url("tick.png") no-repeat 0 50%;
|
185 |
-
padding-left: 20px;
|
186 |
-
}
|
187 |
-
|
188 |
-
/***** SELECT2 OVERRIDE ******
|
189 |
-
****************************/
|
190 |
-
.select2-drop-mask {
|
191 |
-
z-index: 99999998!important;
|
192 |
-
}
|
193 |
-
.select2-drop {
|
194 |
-
z-index: 99999999!important;
|
195 |
-
}
|
196 |
-
.select2-container {
|
197 |
-
z-index: 99999999!important;
|
198 |
-
}
|
199 |
-
.select2-container .select2-search--inline .select2-search__field {
|
200 |
-
margin-top: 0px !important;
|
201 |
-
margin-bottom: 0px !important;
|
202 |
-
}
|
203 |
-
.select2-container .select2-search__field{
|
204 |
-
min-width: 0 !important;
|
205 |
-
}
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
.woocommerce-message {
|
210 |
-
margin-top: 10px;
|
211 |
-
}
|
212 |
-
#wc_checkout_fields {
|
213 |
-
margin-top: 10px;
|
214 |
-
}
|
215 |
-
#wc_checkout_fields thead th input {
|
216 |
-
margin: 2px 0 0 0 !important;
|
217 |
-
}
|
218 |
-
#wc_checkout_fields tbody .description {
|
219 |
-
display: none;
|
220 |
-
color: #999;
|
221 |
-
}
|
222 |
-
#wc_checkout_fields tbody td {
|
223 |
-
overflow: visible !important;
|
224 |
-
padding: 7px;
|
225 |
-
cursor: move;
|
226 |
-
vertical-align: middle;
|
227 |
-
}
|
228 |
-
#wc_checkout_fields tbody td:last-child,
|
229 |
-
#wc_checkout_fields tbody th:last-child {
|
230 |
-
padding-right: 14px;
|
231 |
-
}
|
232 |
-
#wc_checkout_fields tbody input.input-text,
|
233 |
-
#wc_checkout_fields tbody td select {
|
234 |
-
width: 100%;
|
235 |
-
}
|
236 |
-
#wc_checkout_fields tfoot .description {
|
237 |
-
color: #999;
|
238 |
-
}
|
239 |
-
#wc_checkout_fields .check-column {
|
240 |
-
padding: 7px 0 7px 14px;
|
241 |
-
}
|
242 |
-
#wc_checkout_fields strong.core-field {
|
243 |
-
color: #a4688d;
|
244 |
-
}
|
245 |
-
#wc_checkout_fields .field-type,
|
246 |
-
#wc_checkout_fields .field-options,
|
247 |
-
#wc_checkout_fields span.na,
|
248 |
-
#wc_checkout_fields .field-validation {
|
249 |
-
text-align: center;
|
250 |
-
color: #aaa;
|
251 |
-
}
|
252 |
-
#wc_checkout_fields .field-type select,
|
253 |
-
#wc_checkout_fields .field-options select,
|
254 |
-
#wc_checkout_fields span.na select,
|
255 |
-
#wc_checkout_fields .field-validation select,
|
256 |
-
#wc_checkout_fields .field-type div,
|
257 |
-
#wc_checkout_fields .field-options div,
|
258 |
-
#wc_checkout_fields span.na div,
|
259 |
-
#wc_checkout_fields .field-validation div,
|
260 |
-
#wc_checkout_fields .field-type input,
|
261 |
-
#wc_checkout_fields .field-options input,
|
262 |
-
#wc_checkout_fields span.na input,
|
263 |
-
#wc_checkout_fields .field-validation input {
|
264 |
-
text-align: left;
|
265 |
-
}
|
266 |
-
#wc_checkout_fields span.na {
|
267 |
-
display: block;
|
268 |
-
}
|
269 |
-
#wc_checkout_fields .clear {
|
270 |
-
text-align: center;
|
271 |
-
}
|
272 |
-
#wc_checkout_fields tr.disabled td {
|
273 |
-
opacity: 0.3;
|
274 |
-
text-decoration: line-through;
|
275 |
-
}
|
276 |
-
#wc_checkout_fields tr.disabled td:first-child {
|
277 |
-
opacity:1;
|
278 |
-
}
|
279 |
-
tr.strikeout1 td:before {
|
280 |
-
content: " ";
|
281 |
-
position: absolute;
|
282 |
-
top: 50%;
|
283 |
-
left: 0;
|
284 |
-
border-bottom: 1px solid #FF0000;
|
285 |
-
width: 100%;
|
286 |
-
}
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
.wcfd_popup_wrapper input[type="text"]:disabled, .wcfd_popup_wrapper select:disabled {
|
297 |
-
background: #f6f6f6;
|
298 |
-
}
|
299 |
-
|
300 |
-
h1.nav-tab-wrapper, h2.nav-tab-wrapper, h3.nav-tab-wrapper {
|
301 |
-
border-bottom: 1px solid #CCC;
|
302 |
-
padding-bottom: 0px;
|
303 |
-
padding-left: 10px;
|
304 |
-
}
|
305 |
-
|
306 |
-
/*---------------------------------------
|
307 |
-
*----- POPUP & FORM STYLES - START -----
|
308 |
-
*---------------------------------------*/
|
309 |
-
.woocommerce_page_checkout_form_designer .ui-dialog {
|
310 |
-
z-index: 9990;
|
311 |
-
height: auto !important;
|
312 |
-
padding: 0;
|
313 |
-
border-color: #0071a1;
|
314 |
-
border-top-left-radius: 0;
|
315 |
-
border-top-right-radius: 0;
|
316 |
-
border-bottom-left-radius: 0;
|
317 |
-
border-bottom-right-radius: 0;
|
318 |
-
}
|
319 |
-
.woocommerce_page_checkout_form_designer .ui-widget-overlay {
|
320 |
-
position: fixed;
|
321 |
-
}
|
322 |
-
|
323 |
-
.woocommerce_page_checkout_form_designer .ui-dialog .ui-widget-header{
|
324 |
-
color: #fff;
|
325 |
-
background: #004f70;
|
326 |
-
background-image: linear-gradient(#004f70, #005a80);
|
327 |
-
}
|
328 |
-
.woocommerce_page_checkout_form_designer .ui-dialog .ui-dialog-titlebar{
|
329 |
-
height: 30px;
|
330 |
-
padding: .6em 1em .4em 1em;
|
331 |
-
border: 0;
|
332 |
-
border-top-left-radius: 0;
|
333 |
-
border-top-right-radius: 0;
|
334 |
-
border-bottom-left-radius: 0;
|
335 |
-
border-bottom-right-radius: 0;
|
336 |
-
}
|
337 |
-
.woocommerce_page_checkout_form_designer .ui-dialog .ui-dialog-title {
|
338 |
-
line-height: 20px;
|
339 |
-
font-weight: 400;
|
340 |
-
}
|
341 |
-
.woocommerce_page_checkout_form_designer .ui-dialog .ui-dialog-titlebar-close{
|
342 |
-
border: 1px solid #fff;
|
343 |
-
background-color: #fff;
|
344 |
-
right: 0.6em;
|
345 |
-
text-indent: -9999999px;
|
346 |
-
}
|
347 |
-
.woocommerce_page_checkout_form_designer .ui-dialog .ui-dialog-titlebar-close:before{
|
348 |
-
display:none;
|
349 |
-
}
|
350 |
-
.woocommerce_page_checkout_form_designer .ui-dialog .ui-dialog-titlebar-close .ui-icon{
|
351 |
-
background-color: #fff;
|
352 |
-
}
|
353 |
-
|
354 |
-
.woocommerce_page_checkout_form_designer .ui-dialog .ui-dialog-buttonpane{
|
355 |
-
border-color: #0071a1;
|
356 |
-
}
|
357 |
-
.woocommerce_page_checkout_form_designer .ui-dialog .ui-dialog-buttonpane button{
|
358 |
-
color: #0071a1;
|
359 |
-
border-color: #0071a1;
|
360 |
-
background: #f3f5f6;
|
361 |
-
vertical-align: top;
|
362 |
-
height: auto;
|
363 |
-
padding: .4em 1em;
|
364 |
-
border: 1px solid #0071a1;
|
365 |
-
}
|
366 |
-
|
367 |
-
/*.select2-drop {
|
368 |
-
z-index: 999999!important;
|
369 |
-
}*/
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
:root {
|
374 |
-
/*--primary-bg-color: #561849;
|
375 |
-
--primary-text-color: #561849;
|
376 |
-
--primary-border-color: #3b80ee;*/
|
377 |
-
|
378 |
-
--primary-bg-color: #007cba;
|
379 |
-
--primary-text-color: #0071a1;
|
380 |
-
--primary-border-color: #0071a1;
|
381 |
-
|
382 |
-
--primary-alt-bg-color: #f3f5f6;
|
383 |
-
--primary-alt-text-color: #0071a1;
|
384 |
-
--primary-alt-border-color: #0071a1;
|
385 |
-
}
|
386 |
-
|
387 |
-
/**************************************
|
388 |
-
***** Button Styles - START ***********
|
389 |
-
***************************************/
|
390 |
-
.thwcfd-wrap .btn{
|
391 |
-
display: inline-block;
|
392 |
-
background-image: none;
|
393 |
-
font-size: 14px;
|
394 |
-
font-weight: normal;
|
395 |
-
text-align: center;
|
396 |
-
vertical-align: middle;
|
397 |
-
white-space: nowrap;
|
398 |
-
cursor: pointer;
|
399 |
-
touch-action: manipulation;
|
400 |
-
line-height: 1;
|
401 |
-
border-width: 1px;
|
402 |
-
border-style: solid;
|
403 |
-
border-radius: 2px;
|
404 |
-
outline: 0;
|
405 |
-
margin: 0;
|
406 |
-
padding: 12px 20px;
|
407 |
-
box-sizing: border-box;
|
408 |
-
-webkit-appearance: none;
|
409 |
-
-webkit-box-sizing: border-box;
|
410 |
-
transition: .1s;
|
411 |
-
-webkit-transition: .1s;
|
412 |
-
-ms-user-select: none;
|
413 |
-
-moz-user-select: none;
|
414 |
-
-webkit-user-select: none;
|
415 |
-
|
416 |
-
color: var(--primary-alt-text-color);
|
417 |
-
background-color: var(--primary-alt-bg-color);
|
418 |
-
border-color: var(--primary-alt-border-color);
|
419 |
-
}
|
420 |
-
.thwcfd-wrap .btn:hover{
|
421 |
-
opacity: 0.9;
|
422 |
-
}
|
423 |
-
.thwcfd-wrap .btn-small{
|
424 |
-
font-size: 13px;
|
425 |
-
padding: 8px 10px;
|
426 |
-
border-radius: 2px;
|
427 |
-
}
|
428 |
-
.thwcfd-wrap .btn-tiny{
|
429 |
-
font-size: 13px;
|
430 |
-
padding: 5px 5px;
|
431 |
-
border-radius: 2px;
|
432 |
-
}
|
433 |
-
|
434 |
-
.thwcfd-wrap .btn-primary{
|
435 |
-
color: #fff;
|
436 |
-
background-color: var(--primary-bg-color);
|
437 |
-
border-color: var(--primary-border-color);
|
438 |
-
}
|
439 |
-
.thwcfd-wrap .btn-primary-alt{
|
440 |
-
color: var(--primary-alt-text-color);
|
441 |
-
background-color: var(--primary-alt-bg-color);
|
442 |
-
border-color: var(--primary-alt-border-color);
|
443 |
-
}
|
444 |
-
.thwcfd-wrap .btn-danger{
|
445 |
-
color: #fff;
|
446 |
-
background-color: #f44336;
|
447 |
-
border-color: #c3352b;
|
448 |
-
}
|
449 |
-
|
450 |
-
.thwcfd-wrap .btn:disabled,
|
451 |
-
.thwcfd-wrap .btn[disabled]{
|
452 |
-
color: #cbcbcb;
|
453 |
-
border-color: #cbcbcb;
|
454 |
-
background-color: #fcfcfc;
|
455 |
-
cursor: default;
|
456 |
-
}
|
457 |
-
/**************************************
|
458 |
-
***** Button Styles - END *************
|
459 |
-
***************************************/
|
460 |
-
|
461 |
-
/**************************************
|
462 |
-
***** Help Tooltip - START ************
|
463 |
-
***************************************/
|
464 |
-
.thwcfd_tooltip{
|
465 |
-
float:right;
|
466 |
-
display: inline;
|
467 |
-
position: relative;
|
468 |
-
font-size: 12px;
|
469 |
-
height: 100%;
|
470 |
-
}
|
471 |
-
|
472 |
-
.thwcfd_tooltip img{
|
473 |
-
padding: 0px;
|
474 |
-
vertical-align: middle;
|
475 |
-
cursor: help;
|
476 |
-
border: medium none;
|
477 |
-
height: 16px;
|
478 |
-
width: 16px;
|
479 |
-
}
|
480 |
-
|
481 |
-
.thwcfd_tooltip:hover:after{
|
482 |
-
background: #333;
|
483 |
-
background: rgba(0,0,0,1);
|
484 |
-
border-radius: 5px;
|
485 |
-
bottom: 26px;
|
486 |
-
color: #fff;
|
487 |
-
content: attr(title);
|
488 |
-
left: -100px;
|
489 |
-
padding: 10px 15px;
|
490 |
-
position: absolute;
|
491 |
-
z-index: 9998;
|
492 |
-
width: 350px;
|
493 |
-
}
|
494 |
-
|
495 |
-
.thwcfd_tooltip:hover:before{
|
496 |
-
border: solid;
|
497 |
-
border-color: #000 transparent;
|
498 |
-
border-width: 6px 6px 0 6px;
|
499 |
-
bottom: 20px;
|
500 |
-
content: "";
|
501 |
-
left: 50%;
|
502 |
-
position: absolute;
|
503 |
-
z-index: 9999;
|
504 |
-
}
|
505 |
-
/**************************************
|
506 |
-
***** Help Tooltip - END **************
|
507 |
-
***************************************/
|
508 |
-
|
509 |
-
/*****************************************************
|
510 |
-
********* WEPO ADVANCE SETTINGS - START *************
|
511 |
-
*****************************************************/
|
512 |
-
.thwcfd-settings-table{
|
513 |
-
width: 100%;
|
514 |
-
}
|
515 |
-
.thwcfd-settings-table td{
|
516 |
-
padding: 5px 0px;
|
517 |
-
}
|
518 |
-
.thwcfd-settings-table td.section-title{
|
519 |
-
padding: 30px 0px 5px 0px;
|
520 |
-
text-align: left;
|
521 |
-
font-weight: bold;
|
522 |
-
text-transform: capitalize;
|
523 |
-
border-bottom: 1px dashed #cecece;
|
524 |
-
}
|
525 |
-
.thwcfd-settings-table td.label{
|
526 |
-
width: 22%;
|
527 |
-
text-align: left;
|
528 |
-
padding-right: 0;
|
529 |
-
font-weight: normal;
|
530 |
-
}
|
531 |
-
.thwcfd-settings-table td.tip{
|
532 |
-
width: 16px;
|
533 |
-
text-align: center;
|
534 |
-
padding: 0;
|
535 |
-
}
|
536 |
-
.thwcfd-settings-table td.field{
|
537 |
-
padding-left: 0;
|
538 |
-
}
|
539 |
-
.thwcfd-settings-table textarea {
|
540 |
-
width: 90%;
|
541 |
-
font-size: 0.9em;
|
542 |
-
}
|
543 |
-
|
544 |
-
.thwcfd-subtitle{
|
545 |
-
font-size:11px;
|
546 |
-
color:#666666;
|
547 |
-
}
|
548 |
-
/*****************************************************
|
549 |
-
********* WEPO ADVANCE SETTINGS - END ***************
|
550 |
-
*****************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/css/thwcfd-public.css
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
.thwcfd-field-radio label.radio{
|
2 |
-
display: inline-block;
|
3 |
-
margin-right: 15px;
|
4 |
-
}
|
5 |
-
|
6 |
-
.thwcfd-optional .required{
|
7 |
-
display: none;
|
8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/thwcfd-admin.js
DELETED
@@ -1,499 +0,0 @@
|
|
1 |
-
var thwcfd_settings = (function($, window, document) {
|
2 |
-
'use strict';
|
3 |
-
|
4 |
-
var MSG_INVALID_NAME = 'NAME/ID must begin with a lowercase letter ([a-z]) and may be followed by any number of lowercase letters, digits ([0-9]) and underscores ("_")';
|
5 |
-
var OPTION_ROW_HTML = '<tr>';
|
6 |
-
OPTION_ROW_HTML += '<td style="width:150px;"><input type="text" name="i_options_key[]" placeholder="Option Value" style="width:140px;"/></td>';
|
7 |
-
OPTION_ROW_HTML += '<td style="width:190px;"><input type="text" name="i_options_text[]" placeholder="Option Text" style="width:180px;"/></td>';
|
8 |
-
OPTION_ROW_HTML += '<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-blue" title="Add new option">+</a></td>';
|
9 |
-
OPTION_ROW_HTML += '<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-red" title="Remove option">x</a></td>';
|
10 |
-
OPTION_ROW_HTML += '<td class="action-cell sort ui-sortable-handle"></td>';
|
11 |
-
OPTION_ROW_HTML += '</tr>';
|
12 |
-
|
13 |
-
$(function() {
|
14 |
-
$( "#thwcfd_new_field_form_pp" ).dialog({
|
15 |
-
modal: true,
|
16 |
-
width: 600,
|
17 |
-
resizable: false,
|
18 |
-
autoOpen: false,
|
19 |
-
buttons: [{
|
20 |
-
text: "Save",
|
21 |
-
click: function() {
|
22 |
-
var form = $("#thwcfd_new_field_form");
|
23 |
-
var valid = validate_field_form(form);
|
24 |
-
if(valid){
|
25 |
-
prepare_field_form(form);
|
26 |
-
form.submit();
|
27 |
-
}
|
28 |
-
}
|
29 |
-
}]
|
30 |
-
});
|
31 |
-
|
32 |
-
$( "#thwcfd_edit_field_form_pp" ).dialog({
|
33 |
-
modal: true,
|
34 |
-
width: 600,
|
35 |
-
resizable: false,
|
36 |
-
autoOpen: false,
|
37 |
-
buttons: [{
|
38 |
-
text: "Save",
|
39 |
-
click: function() {
|
40 |
-
var form = $("#thwcfd_edit_field_form");
|
41 |
-
var valid = validate_field_form(form);
|
42 |
-
if(valid){
|
43 |
-
prepare_field_form(form);
|
44 |
-
form.submit();
|
45 |
-
}
|
46 |
-
}
|
47 |
-
}]
|
48 |
-
});
|
49 |
-
|
50 |
-
$('select.thwcfd-enhanced-multi-select').selectWoo({
|
51 |
-
//minimumResultsForSearch: 10,
|
52 |
-
allowClear : true,
|
53 |
-
placeholder: $(this).data('placeholder')
|
54 |
-
}).addClass('enhanced');
|
55 |
-
|
56 |
-
$('#thwcfd_checkout_fields tbody').sortable({
|
57 |
-
items:'tr',
|
58 |
-
cursor:'move',
|
59 |
-
axis:'y',
|
60 |
-
handle: 'td.sort',
|
61 |
-
scrollSensitivity:40,
|
62 |
-
helper:function(e,ui){
|
63 |
-
ui.children().each(function(){
|
64 |
-
$(this).width($(this).width());
|
65 |
-
});
|
66 |
-
ui.css('left', '0');
|
67 |
-
return ui;
|
68 |
-
}
|
69 |
-
});
|
70 |
-
|
71 |
-
$("#thwcfd_checkout_fields tbody").on("sortstart", function( event, ui ){
|
72 |
-
ui.item.css('background-color','#f6f6f6');
|
73 |
-
});
|
74 |
-
$("#thwcfd_checkout_fields tbody").on("sortstop", function( event, ui ){
|
75 |
-
ui.item.removeAttr('style');
|
76 |
-
prepare_field_order_indexes();
|
77 |
-
});
|
78 |
-
});
|
79 |
-
|
80 |
-
function isHtmlIdValid(id) {
|
81 |
-
var re = /^[a-z\_]+[a-z0-9\_]*$/;
|
82 |
-
return re.test(id.trim());
|
83 |
-
}
|
84 |
-
|
85 |
-
function decodeHtml(str) {
|
86 |
-
if($.type(str)=== "string"){
|
87 |
-
var map = {
|
88 |
-
'&': '&',
|
89 |
-
'<': '<',
|
90 |
-
'>': '>',
|
91 |
-
'"': '"',
|
92 |
-
''': "'"
|
93 |
-
};
|
94 |
-
return str.replace(/&|<|>|"|'/g, function(m) {return map[m];});
|
95 |
-
}
|
96 |
-
return str;
|
97 |
-
}
|
98 |
-
|
99 |
-
function get_property_field_value(form, type, name){
|
100 |
-
var value = '';
|
101 |
-
|
102 |
-
switch(type) {
|
103 |
-
case 'select':
|
104 |
-
value = form.find("select[name=i_"+name+"]").val();
|
105 |
-
value = value == null ? '' : value;
|
106 |
-
break;
|
107 |
-
|
108 |
-
case 'checkbox':
|
109 |
-
value = form.find("input[name=i_"+name+"]").prop('checked');
|
110 |
-
value = value ? 1 : 0;
|
111 |
-
break;
|
112 |
-
|
113 |
-
case 'textarea':
|
114 |
-
value = form.find("textarea[name=i_"+name+"]").val();
|
115 |
-
value = value == null ? '' : value;
|
116 |
-
|
117 |
-
default:
|
118 |
-
value = form.find("input[name=i_"+name+"]").val();
|
119 |
-
value = value == null ? '' : value;
|
120 |
-
}
|
121 |
-
|
122 |
-
return value;
|
123 |
-
}
|
124 |
-
|
125 |
-
function set_property_field_value(form, type, name, value, multiple){
|
126 |
-
switch(type) {
|
127 |
-
case 'select':
|
128 |
-
if(multiple == 1){
|
129 |
-
value = typeof(value) === 'string' ? value.split(",") : value;
|
130 |
-
name = name+"[]";
|
131 |
-
form.find('select[name="i_'+name+'"]').val(value).trigger("change");
|
132 |
-
}else{
|
133 |
-
form.find('select[name="i_'+name+'"]').val(value);
|
134 |
-
}
|
135 |
-
break;
|
136 |
-
|
137 |
-
case 'checkbox':
|
138 |
-
value = value == 1 ? true : false;
|
139 |
-
form.find("input[name=i_"+name+"]").prop('checked', value);
|
140 |
-
break;
|
141 |
-
|
142 |
-
case 'textarea':
|
143 |
-
value = value ? decodeHtml(value) : value;
|
144 |
-
form.find("textarea[name=i_"+name+"]").val(value);
|
145 |
-
break;
|
146 |
-
|
147 |
-
default:
|
148 |
-
value = value ? decodeHtml(value) : value;
|
149 |
-
form.find("input[name=i_"+name+"]").val(value);
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
function openNewFieldForm(sname){
|
154 |
-
if(sname == 'billing' || sname == 'shipping' || sname == 'additional'){
|
155 |
-
sname = sname+'_';
|
156 |
-
}
|
157 |
-
|
158 |
-
var form = $("#thwcfd_new_field_form");
|
159 |
-
clear_field_form(form);
|
160 |
-
form.find("select[name=i_type]").change();
|
161 |
-
|
162 |
-
set_property_field_value(form, 'text', 'name', sname, 0);
|
163 |
-
set_property_field_value(form, 'text', 'class', 'form-row-wide', 0);
|
164 |
-
|
165 |
-
$("#thwcfd_new_field_form_pp").dialog("open");
|
166 |
-
}
|
167 |
-
|
168 |
-
function openEditFieldForm(elm, rowId){
|
169 |
-
var row = $(elm).closest('tr');
|
170 |
-
var form = $("#thwcfd_edit_field_form");
|
171 |
-
|
172 |
-
var props_json = row.find(".f_props").val();
|
173 |
-
//props_json = decodeHtml(props_json);
|
174 |
-
var props = JSON.parse(props_json);
|
175 |
-
//var type = props.type;
|
176 |
-
|
177 |
-
populate_field_form_general(form, props)
|
178 |
-
form.find("select[name=i_type]").change();
|
179 |
-
populate_field_form(row, form, props);
|
180 |
-
|
181 |
-
$("#thwcfd_edit_field_form_pp").dialog("open");
|
182 |
-
}
|
183 |
-
|
184 |
-
function clear_field_form( form ){
|
185 |
-
form.find('.err_msgs').html('');
|
186 |
-
|
187 |
-
set_property_field_value(form, 'hidden', 'autocomplete', '', 0);
|
188 |
-
set_property_field_value(form, 'hidden', 'priority', '', 0);
|
189 |
-
set_property_field_value(form, 'hidden', 'custom', '', 0);
|
190 |
-
set_property_field_value(form, 'hidden', 'oname', '', 0);
|
191 |
-
set_property_field_value(form, 'hidden', 'otype', '', 0);
|
192 |
-
|
193 |
-
set_property_field_value(form, 'select', 'type', 'text', 0);
|
194 |
-
set_property_field_value(form, 'text', 'name', '', 0);
|
195 |
-
set_property_field_value(form, 'text', 'label', '', 0);
|
196 |
-
set_property_field_value(form, 'text', 'placeholder', '', 0);
|
197 |
-
set_property_field_value(form, 'text', 'default', '', 0);
|
198 |
-
//set_property_field_value(form, 'text', 'options', '', 0);
|
199 |
-
set_property_field_value(form, 'text', 'class', '', 0);
|
200 |
-
set_property_field_value(form, 'select', 'validate', '', 1);
|
201 |
-
|
202 |
-
set_property_field_value(form, 'checkbox', 'required', 1, 0);
|
203 |
-
//set_property_field_value(form, 'checkbox', 'clear', 1, 0);
|
204 |
-
set_property_field_value(form, 'checkbox', 'enabled', 1, 0);
|
205 |
-
set_property_field_value(form, 'checkbox', 'show_in_email', 1, 0);
|
206 |
-
set_property_field_value(form, 'checkbox', 'show_in_order', 1, 0);
|
207 |
-
|
208 |
-
populate_options_list(form, false);
|
209 |
-
}
|
210 |
-
|
211 |
-
function populate_field_form_general(form, props){
|
212 |
-
var autocomplete = props['autocomplete'] ? props['autocomplete'] : '';
|
213 |
-
var priority = props['priority'] ? props['priority'] : '';
|
214 |
-
var custom = props['custom'] ? props['custom'] : '';
|
215 |
-
|
216 |
-
var type = props['type'] ? props['type'] : 'text';
|
217 |
-
var name = props['name'] ? props['name'] : '';
|
218 |
-
|
219 |
-
set_property_field_value(form, 'hidden', 'autocomplete', autocomplete, 0);
|
220 |
-
set_property_field_value(form, 'hidden', 'priority', priority, 0);
|
221 |
-
set_property_field_value(form, 'hidden', 'custom', custom, 0);
|
222 |
-
set_property_field_value(form, 'hidden', 'oname', name, 0);
|
223 |
-
set_property_field_value(form, 'hidden', 'otype', type, 0);
|
224 |
-
|
225 |
-
set_property_field_value(form, 'select', 'type', type, 0);
|
226 |
-
set_property_field_value(form, 'text', 'name', name, 0);
|
227 |
-
}
|
228 |
-
|
229 |
-
function populate_field_form(row, form, props, custom){
|
230 |
-
var custom = props['custom'] ? props['custom'] : '';
|
231 |
-
|
232 |
-
var label = props['label'] ? props['label'] : '';
|
233 |
-
var placeholder = props['placeholder'] ? props['placeholder'] : '';
|
234 |
-
var default_val = props['default'] ? props['default'] : '';
|
235 |
-
//var options = props['options'] ? props['options'] : '';
|
236 |
-
var cssclass = props['class'] ? props['class'] : '';
|
237 |
-
var validate = props['validate'] ? props['validate'] : '';
|
238 |
-
|
239 |
-
var required = props['required'] && (props['required'] || props['required'] === 'yes') ? 1 : 0;
|
240 |
-
//var clear = props['clear'] && (props['clear'] || props['clear'] === 'yes') ? 1 : 0;
|
241 |
-
var enabled = props['enabled'] && (props['enabled'] || props['enabled'] === 'yes') ? 1 : 0;
|
242 |
-
var show_in_email = props['show_in_email'] && (props['show_in_email'] || props['show_in_email'] === 'yes') ? 1 : 0;
|
243 |
-
var show_in_order = props['show_in_order'] && (props['show_in_order'] || props['show_in_order'] === 'yes') ? 1 : 0;
|
244 |
-
|
245 |
-
show_in_email = custom == 1 ? show_in_email : true;
|
246 |
-
show_in_order = custom == 1 ? show_in_order : true;
|
247 |
-
|
248 |
-
set_property_field_value(form, 'text', 'label', label, 0);
|
249 |
-
set_property_field_value(form, 'text', 'placeholder', placeholder, 0);
|
250 |
-
set_property_field_value(form, 'text', 'default', default_val, 0);
|
251 |
-
//set_property_field_value(form, 'text', 'options', options, 0);
|
252 |
-
set_property_field_value(form, 'text', 'class', cssclass, 0);
|
253 |
-
set_property_field_value(form, 'select', 'validate', validate, 1);
|
254 |
-
|
255 |
-
set_property_field_value(form, 'checkbox', 'required', required, 0);
|
256 |
-
//set_property_field_value(form, 'checkbox', 'clear', clear, 0);
|
257 |
-
set_property_field_value(form, 'checkbox', 'enabled', enabled, 0);
|
258 |
-
set_property_field_value(form, 'checkbox', 'show_in_email', show_in_email, 0);
|
259 |
-
set_property_field_value(form, 'checkbox', 'show_in_order', show_in_order, 0);
|
260 |
-
|
261 |
-
var optionsJson = row.find(".f_options").val();
|
262 |
-
populate_options_list(form, optionsJson);
|
263 |
-
|
264 |
-
if(custom == 1){
|
265 |
-
form.find("input[name=i_name]").prop('disabled', false);
|
266 |
-
form.find("select[name=i_type]").prop('disabled', false);
|
267 |
-
form.find("input[name=i_show_in_email]").prop('disabled', false);
|
268 |
-
form.find("input[name=i_show_in_order]").prop('disabled', false);
|
269 |
-
}else{
|
270 |
-
form.find("input[name=i_name]").prop('disabled', true);
|
271 |
-
form.find("select[name=i_type]").prop('disabled', true);
|
272 |
-
form.find("input[name=i_show_in_email]").prop('disabled', true);
|
273 |
-
form.find("input[name=i_show_in_order]").prop('disabled', true);
|
274 |
-
form.find("input[name=i_label]").focus();
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
function prepare_field_form(form){
|
279 |
-
var options_json = get_options(form);
|
280 |
-
set_property_field_value(form, 'hidden', 'options_json', options_json, 0);
|
281 |
-
}
|
282 |
-
|
283 |
-
function validate_field_form(form){
|
284 |
-
var err_msgs = '';
|
285 |
-
var name = get_property_field_value(form, 'text', 'name');
|
286 |
-
var type = get_property_field_value(form, 'select', 'type');
|
287 |
-
var otype = get_property_field_value(form, 'select', 'otype');
|
288 |
-
|
289 |
-
if(type == '' && otype != 'country' && otype == 'state'){
|
290 |
-
err_msgs = 'Type is required';
|
291 |
-
}else if(name == ''){
|
292 |
-
err_msgs = 'Name is required';
|
293 |
-
}else if(!isHtmlIdValid(name)){
|
294 |
-
err_msgs = MSG_INVALID_NAME;
|
295 |
-
}
|
296 |
-
|
297 |
-
if(err_msgs != ''){
|
298 |
-
form.find('.err_msgs').html(err_msgs);
|
299 |
-
return false;
|
300 |
-
}
|
301 |
-
return true;
|
302 |
-
}
|
303 |
-
|
304 |
-
function fieldTypeChangeListner(elm){
|
305 |
-
var type = $(elm).val();
|
306 |
-
var form = $(elm).closest('form');
|
307 |
-
|
308 |
-
showAllFields(form);
|
309 |
-
|
310 |
-
if(type === 'select'){
|
311 |
-
form.find('.row-validate').hide();
|
312 |
-
|
313 |
-
}else if(type === 'radio'){
|
314 |
-
form.find('.row-validate').hide();
|
315 |
-
form.find('.row-placeholder').hide();
|
316 |
-
|
317 |
-
}else{
|
318 |
-
form.find('.row-options').hide();
|
319 |
-
}
|
320 |
-
}
|
321 |
-
|
322 |
-
function showAllFields(form){
|
323 |
-
form.find('.row-options').show();
|
324 |
-
form.find('.row-placeholder').show();
|
325 |
-
form.find('.row-validate').show();
|
326 |
-
}
|
327 |
-
|
328 |
-
/*------------------------------------
|
329 |
-
*---- OPTIONS FUNCTIONS - SATRT ------
|
330 |
-
*------------------------------------*/
|
331 |
-
function get_options(form){
|
332 |
-
var optionsKey = form.find("input[name='i_options_key[]']").map(function(){ return $(this).val(); }).get();
|
333 |
-
var optionsText = form.find("input[name='i_options_text[]']").map(function(){ return $(this).val(); }).get();
|
334 |
-
|
335 |
-
var optionsSize = optionsText.length;
|
336 |
-
var optionsArr = [];
|
337 |
-
|
338 |
-
for(var i=0; i<optionsSize; i++){
|
339 |
-
var optionDetails = {};
|
340 |
-
optionDetails["key"] = optionsKey[i];
|
341 |
-
optionDetails["text"] = optionsText[i];
|
342 |
-
|
343 |
-
optionsArr.push(optionDetails);
|
344 |
-
}
|
345 |
-
|
346 |
-
var optionsJson = optionsArr.length > 0 ? JSON.stringify(optionsArr) : '';
|
347 |
-
optionsJson = encodeURIComponent(optionsJson);
|
348 |
-
return optionsJson;
|
349 |
-
}
|
350 |
-
|
351 |
-
function populate_options_list(form, optionsJson){
|
352 |
-
var optionsHtml = "";
|
353 |
-
|
354 |
-
if(optionsJson){
|
355 |
-
try{
|
356 |
-
optionsJson = decodeURIComponent(optionsJson);
|
357 |
-
var optionsList = $.parseJSON(optionsJson);
|
358 |
-
if(optionsList){
|
359 |
-
jQuery.each(optionsList, function() {
|
360 |
-
var html = '<tr>';
|
361 |
-
html += '<td style="width:150px;"><input type="text" name="i_options_key[]" value="'+this.key+'" placeholder="Option Value" style="width:140px;"/></td>';
|
362 |
-
html += '<td style="width:190px;"><input type="text" name="i_options_text[]" value="'+this.text+'" placeholder="Option Text" style="width:180px;"/></td>';
|
363 |
-
html += '<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdAddNewOptionRow(this)" class="btn btn-blue" title="Add new option">+</a></td>';
|
364 |
-
html += '<td class="action-cell"><a href="javascript:void(0)" onclick="thwcfdRemoveOptionRow(this)" class="btn btn-red" title="Remove option">x</a></td>';
|
365 |
-
html += '<td class="action-cell sort ui-sortable-handle"></td>';
|
366 |
-
html += '</tr>';
|
367 |
-
|
368 |
-
optionsHtml += html;
|
369 |
-
});
|
370 |
-
}
|
371 |
-
}catch(err) {
|
372 |
-
console.log(err);
|
373 |
-
}
|
374 |
-
}
|
375 |
-
|
376 |
-
var optionsTable = form.find(".thwcfd-option-list tbody");
|
377 |
-
if(optionsHtml){
|
378 |
-
optionsTable.html(optionsHtml);
|
379 |
-
}else{
|
380 |
-
optionsTable.html(OPTION_ROW_HTML);
|
381 |
-
}
|
382 |
-
}
|
383 |
-
|
384 |
-
function add_new_option_row(elm){
|
385 |
-
var ptable = $(elm).closest('table');
|
386 |
-
var optionsSize = ptable.find('tbody tr').size();
|
387 |
-
|
388 |
-
if(optionsSize > 0){
|
389 |
-
ptable.find('tbody tr:last').after(OPTION_ROW_HTML);
|
390 |
-
}else{
|
391 |
-
ptable.find('tbody').append(OPTION_ROW_HTML);
|
392 |
-
}
|
393 |
-
}
|
394 |
-
|
395 |
-
function remove_option_row(elm){
|
396 |
-
var ptable = $(elm).closest('table');
|
397 |
-
$(elm).closest('tr').remove();
|
398 |
-
var optionsSize = ptable.find('tbody tr').size();
|
399 |
-
|
400 |
-
if(optionsSize == 0){
|
401 |
-
ptable.find('tbody').append(OPTION_ROW_HTML);
|
402 |
-
}
|
403 |
-
}
|
404 |
-
/*------------------------------------
|
405 |
-
*---- OPTIONS FUNCTIONS - END --------
|
406 |
-
*------------------------------------*/
|
407 |
-
|
408 |
-
function prepare_field_order_indexes() {
|
409 |
-
$('#thwcfd_checkout_fields tbody tr').each(function(index, el){
|
410 |
-
$('input.f_order', el).val( parseInt( $(el).index('#thwcfd_checkout_fields tbody tr') ) );
|
411 |
-
});
|
412 |
-
};
|
413 |
-
|
414 |
-
function selectAllCheckoutFields(elm){
|
415 |
-
var checkAll = $(elm).prop('checked');
|
416 |
-
$('#thwcfd_checkout_fields tbody input:checkbox[name=select_field]').prop('checked', checkAll);
|
417 |
-
}
|
418 |
-
|
419 |
-
function removeSelectedFields(){
|
420 |
-
$('#thwcfd_checkout_fields tbody tr').removeClass('thpladmin-strikeout');
|
421 |
-
$('#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked').each(function () {
|
422 |
-
var row = $(this).closest('tr');
|
423 |
-
|
424 |
-
if(!row.hasClass("thpladmin-strikeout")){
|
425 |
-
row.addClass("thpladmin-strikeout");
|
426 |
-
}
|
427 |
-
|
428 |
-
row.find(".f_deleted").val(1);
|
429 |
-
row.find(".f_edit_btn").prop('disabled', true);
|
430 |
-
});
|
431 |
-
}
|
432 |
-
|
433 |
-
function enableDisableSelectedFields(enabled){
|
434 |
-
$('#thwcfd_checkout_fields tbody input:checkbox[name=select_field]:checked').each(function () {
|
435 |
-
var row = $(this).closest('tr');
|
436 |
-
row.find(".f_enabled").val(enabled);
|
437 |
-
|
438 |
-
if(enabled == 0){
|
439 |
-
if(!row.hasClass("thpladmin-disabled")){
|
440 |
-
row.addClass("thpladmin-disabled");
|
441 |
-
}
|
442 |
-
|
443 |
-
row.find(".f_edit_btn").prop('disabled', true);
|
444 |
-
row.find(".td_enabled").html('-');
|
445 |
-
}else{
|
446 |
-
row.removeClass("thpladmin-disabled");
|
447 |
-
|
448 |
-
row.find(".f_edit_btn").prop('disabled', false);
|
449 |
-
row.find(".td_enabled").html('<span class="dashicons dashicons-yes"></span>');
|
450 |
-
}
|
451 |
-
});
|
452 |
-
}
|
453 |
-
|
454 |
-
return {
|
455 |
-
openNewFieldForm : openNewFieldForm,
|
456 |
-
openEditFieldForm : openEditFieldForm,
|
457 |
-
selectAllCheckoutFields : selectAllCheckoutFields,
|
458 |
-
removeSelectedFields : removeSelectedFields,
|
459 |
-
enableDisableSelectedFields : enableDisableSelectedFields,
|
460 |
-
fieldTypeChangeListner : fieldTypeChangeListner,
|
461 |
-
addNewOptionRow : add_new_option_row,
|
462 |
-
removeOptionRow : remove_option_row,
|
463 |
-
};
|
464 |
-
}(window.jQuery, window, document));
|
465 |
-
|
466 |
-
function thwcfdOpenNewFieldForm(tabName){
|
467 |
-
thwcfd_settings.openNewFieldForm(tabName);
|
468 |
-
}
|
469 |
-
|
470 |
-
function thwcfdOpenEditFieldForm(elm, rowId){
|
471 |
-
thwcfd_settings.openEditFieldForm(elm, rowId);
|
472 |
-
}
|
473 |
-
|
474 |
-
function thwcfdRemoveSelectedFields(){
|
475 |
-
thwcfd_settings.removeSelectedFields();
|
476 |
-
}
|
477 |
-
|
478 |
-
function thwcfdEnableSelectedFields(){
|
479 |
-
thwcfd_settings.enableDisableSelectedFields(1);
|
480 |
-
}
|
481 |
-
|
482 |
-
function thwcfdDisableSelectedFields(){
|
483 |
-
thwcfd_settings.enableDisableSelectedFields(0);
|
484 |
-
}
|
485 |
-
|
486 |
-
function thwcfdFieldTypeChangeListner(elm){
|
487 |
-
thwcfd_settings.fieldTypeChangeListner(elm);
|
488 |
-
}
|
489 |
-
|
490 |
-
function thwcfdSelectAllCheckoutFields(elm){
|
491 |
-
thwcfd_settings.selectAllCheckoutFields(elm);
|
492 |
-
}
|
493 |
-
|
494 |
-
function thwcfdAddNewOptionRow(elm){
|
495 |
-
thwcfd_settings.addNewOptionRow(elm);
|
496 |
-
}
|
497 |
-
function thwcfdRemoveOptionRow(elm){
|
498 |
-
thwcfd_settings.removeOptionRow(elm);
|
499 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/thwcfd-checkout.js
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function($) {
|
2 |
-
$('select.thwcfd-enhanced-select').selectWoo({
|
3 |
-
//minimumResultsForSearch: 10,
|
4 |
-
allowClear : true,
|
5 |
-
placeholder: $(this).data('placeholder')
|
6 |
-
}).addClass('enhanced');
|
7 |
-
|
8 |
-
//Copied from WooCommerce address-i18n.js. Do not change
|
9 |
-
function field_is_required( field, is_required ) {
|
10 |
-
if ( is_required ) {
|
11 |
-
field.find( 'label .optional' ).remove();
|
12 |
-
field.addClass( 'validate-required' );
|
13 |
-
|
14 |
-
field_label_white_space_fix(field);
|
15 |
-
|
16 |
-
if ( field.find( 'label .required' ).length === 0 ) {
|
17 |
-
field.find( 'label' ).append(
|
18 |
-
' <abbr class="required" title="' +
|
19 |
-
wc_address_i18n_params.i18n_required_text +
|
20 |
-
'">*</abbr>'
|
21 |
-
);
|
22 |
-
}
|
23 |
-
} else {
|
24 |
-
field.find( 'label .required' ).remove();
|
25 |
-
field.removeClass( 'validate-required woocommerce-invalid woocommerce-invalid-required-field' );
|
26 |
-
|
27 |
-
field_label_white_space_fix(field);
|
28 |
-
|
29 |
-
if ( field.find( 'label .optional' ).length === 0 ) {
|
30 |
-
field.find( 'label' ).append( ' <span class="optional">(' + wc_address_i18n_params.i18n_optional_text + ')</span>' );
|
31 |
-
}
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
$( document.body ).bind( 'country_to_state_changing', function( event, country, wrapper ) {
|
36 |
-
if(thwcfd_public_var.is_override_required){
|
37 |
-
setTimeout(address_fields_required_validation_fix, 500);
|
38 |
-
}
|
39 |
-
});
|
40 |
-
|
41 |
-
function address_fields_required_validation_fix(){
|
42 |
-
var thisform = $('.woocommerce-checkout');
|
43 |
-
var locale_fields = $.parseJSON( wc_address_i18n_params.locale_fields );
|
44 |
-
|
45 |
-
if(locale_fields){
|
46 |
-
$.each( locale_fields, function( key, value ) {
|
47 |
-
var fids = value.split(',');
|
48 |
-
|
49 |
-
$.each( fids, function( index, fid ) {
|
50 |
-
var field = thisform.find( fid.trim() );
|
51 |
-
|
52 |
-
if(field.hasClass('thwcfd-required')){
|
53 |
-
field_is_required( field, true );
|
54 |
-
}else if(field.hasClass('thwcfd-optional')){
|
55 |
-
field_is_required( field, false );
|
56 |
-
}
|
57 |
-
});
|
58 |
-
});
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
//White space fix. Should be removed once fixed by WooCommerec.
|
63 |
-
function field_label_white_space_fix(field){
|
64 |
-
var label = field.find( 'label' ).html();
|
65 |
-
if(label){
|
66 |
-
label = label.replace(/(?:^(?: )+)|(?:(?: )+$)/g, '');
|
67 |
-
field.find( 'label' ).html( label.trim() );
|
68 |
-
}
|
69 |
-
}
|
70 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkout-form-designer.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
* Plugin Name: Checkout Field Editor for WooCommerce
|
4 |
* Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
|
5 |
* Author: ThemeHigh
|
6 |
-
* Version: 1.4.
|
7 |
* Author URI: https://www.themehigh.com
|
8 |
* Plugin URI: https://www.themehigh.com
|
9 |
* Text Domain: woo-checkout-field-editor-pro
|
10 |
* Domain Path: /languages
|
11 |
* WC requires at least: 3.0.0
|
12 |
-
* WC tested up to:
|
13 |
*/
|
14 |
|
15 |
if(!defined( 'ABSPATH' )) exit;
|
@@ -25,13 +25,13 @@ if (!function_exists('is_woocommerce_active')){
|
|
25 |
}
|
26 |
|
27 |
if(is_woocommerce_active()) {
|
28 |
-
define('THWCFD_VERSION', '1.4.
|
29 |
!defined('THWCFD_BASE_NAME') && define('THWCFD_BASE_NAME', plugin_basename( __FILE__ ));
|
30 |
!defined('THWCFD_PATH') && define('THWCFD_PATH', plugin_dir_path( __FILE__ ));
|
31 |
!defined('THWCFD_URL') && define('THWCFD_URL', plugins_url( '/', __FILE__ ));
|
32 |
-
!defined('THWCFD_ASSETS_URL') && define('THWCFD_ASSETS_URL', THWCFD_URL .'assets/');
|
33 |
|
34 |
-
require THWCFD_PATH . 'classes/class-thwcfd.php';
|
|
|
35 |
|
36 |
function run_thwcfd() {
|
37 |
$plugin = new THWCFD();
|
3 |
* Plugin Name: Checkout Field Editor for WooCommerce
|
4 |
* Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
|
5 |
* Author: ThemeHigh
|
6 |
+
* Version: 1.4.6
|
7 |
* Author URI: https://www.themehigh.com
|
8 |
* Plugin URI: https://www.themehigh.com
|
9 |
* Text Domain: woo-checkout-field-editor-pro
|
10 |
* Domain Path: /languages
|
11 |
* WC requires at least: 3.0.0
|
12 |
+
* WC tested up to: 5.0.0
|
13 |
*/
|
14 |
|
15 |
if(!defined( 'ABSPATH' )) exit;
|
25 |
}
|
26 |
|
27 |
if(is_woocommerce_active()) {
|
28 |
+
define('THWCFD_VERSION', '1.4.6');
|
29 |
!defined('THWCFD_BASE_NAME') && define('THWCFD_BASE_NAME', plugin_basename( __FILE__ ));
|
30 |
!defined('THWCFD_PATH') && define('THWCFD_PATH', plugin_dir_path( __FILE__ ));
|
31 |
!defined('THWCFD_URL') && define('THWCFD_URL', plugins_url( '/', __FILE__ ));
|
|
|
32 |
|
33 |
+
#require THWCFD_PATH . 'classes/class-thwcfd.php';
|
34 |
+
require plugin_dir_path( __FILE__ ) . 'includes/class-thwcfd.php';
|
35 |
|
36 |
function run_thwcfd() {
|
37 |
$plugin = new THWCFD();
|
classes/class-thwcfd-settings-advanced.php
DELETED
@@ -1,390 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Woo Checkout Field Editor Settings Advanced
|
4 |
-
*
|
5 |
-
* @link https://themehigh.com
|
6 |
-
* @since 1.4.4
|
7 |
-
*
|
8 |
-
* @package woo-checkout-field-editor-pro
|
9 |
-
* @subpackage woo-checkout-field-editor-pro/classes
|
10 |
-
*/
|
11 |
-
|
12 |
-
defined( 'ABSPATH' ) || exit;
|
13 |
-
|
14 |
-
if(!class_exists('THWCFD_Settings_Advanced')):
|
15 |
-
|
16 |
-
class THWCFD_Settings_Advanced {
|
17 |
-
protected static $_instance = null;
|
18 |
-
protected $tabs = '';
|
19 |
-
|
20 |
-
private $settings_fields = NULL;
|
21 |
-
private $cell_props = array();
|
22 |
-
private $cell_props_CB = array();
|
23 |
-
private $cell_props_TA = array();
|
24 |
-
|
25 |
-
public function __construct() {
|
26 |
-
$this->tabs = array( 'fields' => 'Checkout Fields', 'advanced_settings' => 'Advanced Settings');
|
27 |
-
$this->init_constants();
|
28 |
-
}
|
29 |
-
|
30 |
-
public static function instance() {
|
31 |
-
if(is_null(self::$_instance)){
|
32 |
-
self::$_instance = new self();
|
33 |
-
}
|
34 |
-
return self::$_instance;
|
35 |
-
}
|
36 |
-
|
37 |
-
public function init_constants(){
|
38 |
-
$this->cell_props = array(
|
39 |
-
'label_cell_props' => 'class="label"',
|
40 |
-
'input_cell_props' => 'class="field"',
|
41 |
-
'input_width' => '260px',
|
42 |
-
'label_cell_th' => true
|
43 |
-
);
|
44 |
-
|
45 |
-
$this->cell_props_TA = array(
|
46 |
-
'label_cell_props' => 'class="label"',
|
47 |
-
'input_cell_props' => 'class="field"',
|
48 |
-
'rows' => 10,
|
49 |
-
'cols' => 100,
|
50 |
-
);
|
51 |
-
|
52 |
-
$this->cell_props_CB = array(
|
53 |
-
'label_props' => 'style="margin-right: 40px;"',
|
54 |
-
);
|
55 |
-
|
56 |
-
$this->settings_fields = $this->get_advanced_settings_fields();
|
57 |
-
}
|
58 |
-
|
59 |
-
public function get_advanced_settings_fields(){
|
60 |
-
return array(
|
61 |
-
'enable_label_override' => array(
|
62 |
-
'name'=>'enable_label_override', 'label'=>'Enable label override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>1
|
63 |
-
),
|
64 |
-
'enable_placeholder_override' => array(
|
65 |
-
'name'=>'enable_placeholder_override', 'label'=>'Enable placeholder override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>1
|
66 |
-
),
|
67 |
-
'enable_class_override' => array(
|
68 |
-
'name'=>'enable_class_override', 'label'=>'Enable class override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>0
|
69 |
-
),
|
70 |
-
'enable_priority_override' => array(
|
71 |
-
'name'=>'enable_priority_override', 'label'=>'Enable priority override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>1
|
72 |
-
),
|
73 |
-
'enable_required_override' => array(
|
74 |
-
'name'=>'enable_required_override', 'label'=>'Enable required validation override for address fields.', 'type'=>'checkbox', 'value'=>'1', 'checked'=>0
|
75 |
-
),
|
76 |
-
);
|
77 |
-
}
|
78 |
-
|
79 |
-
public function render_page(){
|
80 |
-
$this->render_tabs();
|
81 |
-
$this->render_content();
|
82 |
-
}
|
83 |
-
|
84 |
-
public function save_advanced_settings($settings){
|
85 |
-
$result = update_option(THWCFD_Utils::OPTION_KEY_ADVANCED_SETTINGS, $settings);
|
86 |
-
return $result;
|
87 |
-
}
|
88 |
-
|
89 |
-
private function reset_settings(){
|
90 |
-
delete_option(THWCFD_Utils::OPTION_KEY_ADVANCED_SETTINGS);
|
91 |
-
$this->print_notices('Settings successfully reset.', 'updated', false);
|
92 |
-
}
|
93 |
-
|
94 |
-
private function save_settings(){
|
95 |
-
$settings = array();
|
96 |
-
|
97 |
-
foreach( $this->settings_fields as $name => $field ) {
|
98 |
-
$value = '';
|
99 |
-
|
100 |
-
if($field['type'] === 'checkbox'){
|
101 |
-
$value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
|
102 |
-
|
103 |
-
}else if($field['type'] === 'multiselect_grouped'){
|
104 |
-
$value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
|
105 |
-
$value = is_array($value) ? implode(',', wc_clean(wp_unslash($value))) : wc_clean(wp_unslash($value));
|
106 |
-
|
107 |
-
}else if($field['type'] === 'text' || $field['type'] === 'textarea'){
|
108 |
-
$value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
|
109 |
-
$value = !empty($value) ? wc_clean( wp_unslash($value)) : '';
|
110 |
-
|
111 |
-
}else{
|
112 |
-
$value = !empty( $_POST['i_'.$name] ) ? $_POST['i_'.$name] : '';
|
113 |
-
$value = !empty($value) ? wc_clean( wp_unslash($value)) : '';
|
114 |
-
}
|
115 |
-
|
116 |
-
$settings[$name] = $value;
|
117 |
-
}
|
118 |
-
|
119 |
-
$result = $this->save_advanced_settings($settings);
|
120 |
-
if ($result == true) {
|
121 |
-
$this->print_notices('Your changes were saved.', 'updated', false);
|
122 |
-
} else {
|
123 |
-
$this->print_notices('Your changes were not saved due to an error (or you made none!).', 'error', false);
|
124 |
-
}
|
125 |
-
}
|
126 |
-
|
127 |
-
private function render_content(){
|
128 |
-
if(isset($_POST['reset_settings']))
|
129 |
-
$this->reset_settings();
|
130 |
-
|
131 |
-
if(isset($_POST['save_settings']))
|
132 |
-
$this->save_settings();
|
133 |
-
|
134 |
-
/*if(isset($_POST['save_plugin_settings']))
|
135 |
-
$result = $this->save_plugin_settings();*/
|
136 |
-
|
137 |
-
$this->render_plugin_settings();
|
138 |
-
//$this->render_import_export_settings();
|
139 |
-
}
|
140 |
-
|
141 |
-
private function render_plugin_settings(){
|
142 |
-
$settings = THWCFD_Utils::get_advanced_settings();
|
143 |
-
?>
|
144 |
-
<div style="padding-left: 30px;">
|
145 |
-
<form id="advanced_settings_form" method="post" action="">
|
146 |
-
<table class="thwcfd-settings-table thpladmin-form-table">
|
147 |
-
<tbody>
|
148 |
-
<?php
|
149 |
-
$this->render_locale_override_settings($settings);
|
150 |
-
?>
|
151 |
-
</tbody>
|
152 |
-
</table>
|
153 |
-
<p class="submit">
|
154 |
-
<input type="submit" name="save_settings" class="btn btn-small btn-primary" value="Save changes">
|
155 |
-
<input type="submit" name="reset_settings" class="btn btn-small" value="Reset to default"
|
156 |
-
onclick="return confirm('Are you sure you want to reset to default settings? all your changes will be deleted.');">
|
157 |
-
</p>
|
158 |
-
</form>
|
159 |
-
</div>
|
160 |
-
<?php
|
161 |
-
}
|
162 |
-
|
163 |
-
private function render_locale_override_settings($settings){
|
164 |
-
$this->render_form_elm_row_title('Locale override settings');
|
165 |
-
$this->render_form_elm_row_cb($this->settings_fields['enable_label_override'], $settings, true);
|
166 |
-
$this->render_form_elm_row_cb($this->settings_fields['enable_placeholder_override'], $settings, true);
|
167 |
-
$this->render_form_elm_row_cb($this->settings_fields['enable_class_override'], $settings, true);
|
168 |
-
$this->render_form_elm_row_cb($this->settings_fields['enable_priority_override'], $settings, true);
|
169 |
-
$this->render_form_elm_row_cb($this->settings_fields['enable_required_override'], $settings, true);
|
170 |
-
}
|
171 |
-
|
172 |
-
public function render_form_elm_row_title($title=''){
|
173 |
-
?>
|
174 |
-
<tr>
|
175 |
-
<td colspan="3" class="section-title" ><?php echo $title; ?></td>
|
176 |
-
</tr>
|
177 |
-
<?php
|
178 |
-
}
|
179 |
-
|
180 |
-
private function render_form_elm_row_cb($field, $settings=false, $merge_cells=false){
|
181 |
-
$name = $field['name'];
|
182 |
-
if(is_array($settings) && isset($settings[$name])){
|
183 |
-
if($field['value'] === $settings[$name]){
|
184 |
-
$field['checked'] = 1;
|
185 |
-
}else{
|
186 |
-
$field['checked'] = 0;
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
190 |
-
if($merge_cells){
|
191 |
-
?>
|
192 |
-
<tr>
|
193 |
-
<td colspan="3">
|
194 |
-
<?php $this->render_form_field_element($field, $this->cell_props_CB, false); ?>
|
195 |
-
</td>
|
196 |
-
</tr>
|
197 |
-
<?php
|
198 |
-
}else{
|
199 |
-
?>
|
200 |
-
<tr>
|
201 |
-
<td colspan="2"></td>
|
202 |
-
<td class="field">
|
203 |
-
<?php $this->render_form_field_element($field, $this->cell_props_CB, false); ?>
|
204 |
-
</td>
|
205 |
-
</tr>
|
206 |
-
<?php
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
210 |
-
public function render_form_field_element($field, $atts = array(), $render_cell = true){
|
211 |
-
if($field && is_array($field)){
|
212 |
-
$args = shortcode_atts( array(
|
213 |
-
'label_cell_props' => '',
|
214 |
-
'input_cell_props' => '',
|
215 |
-
'label_cell_colspan' => '',
|
216 |
-
'input_cell_colspan' => '',
|
217 |
-
), $atts );
|
218 |
-
|
219 |
-
$ftype = isset($field['type']) ? $field['type'] : 'text';
|
220 |
-
$flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : '';
|
221 |
-
$sub_label = isset($field['sub_label']) && !empty($field['sub_label']) ? __($field['sub_label'], 'woo-checkout-field-editor-pro') : '';
|
222 |
-
$tooltip = isset($field['hint_text']) && !empty($field['hint_text']) ? __($field['hint_text'], 'woo-checkout-field-editor-pro') : '';
|
223 |
-
|
224 |
-
$field_html = '';
|
225 |
-
|
226 |
-
if($ftype == 'text'){
|
227 |
-
$field_html = $this->render_form_field_element_inputtext($field, $atts);
|
228 |
-
|
229 |
-
}else if($ftype == 'textarea'){
|
230 |
-
$field_html = $this->render_form_field_element_textarea($field, $atts);
|
231 |
-
|
232 |
-
}else if($ftype == 'checkbox'){
|
233 |
-
$field_html = $this->render_form_field_element_checkbox($field, $atts, $render_cell);
|
234 |
-
$flabel = ' ';
|
235 |
-
}
|
236 |
-
|
237 |
-
if($render_cell){
|
238 |
-
$required_html = isset($field['required']) && $field['required'] ? '<abbr class="required" title="required">*</abbr>' : '';
|
239 |
-
|
240 |
-
$label_cell_props = !empty($args['label_cell_props']) ? $args['label_cell_props'] : '';
|
241 |
-
$input_cell_props = !empty($args['input_cell_props']) ? $args['input_cell_props'] : '';
|
242 |
-
|
243 |
-
?>
|
244 |
-
<td <?php echo $label_cell_props ?> >
|
245 |
-
<?php echo $flabel; echo $required_html;
|
246 |
-
if($sub_label){
|
247 |
-
?>
|
248 |
-
<br/><span class="thpladmin-subtitle"><?php echo $sub_label; ?></span>
|
249 |
-
<?php
|
250 |
-
}
|
251 |
-
?>
|
252 |
-
</td>
|
253 |
-
<?php $this->render_form_fragment_tooltip($tooltip); ?>
|
254 |
-
<td <?php echo $input_cell_props ?> ><?php echo $field_html; ?></td>
|
255 |
-
<?php
|
256 |
-
}else{
|
257 |
-
echo $field_html;
|
258 |
-
}
|
259 |
-
}
|
260 |
-
}
|
261 |
-
|
262 |
-
private function prepare_form_field_props($field, $atts = array()){
|
263 |
-
$field_props = '';
|
264 |
-
$args = shortcode_atts( array(
|
265 |
-
'input_width' => '',
|
266 |
-
'input_name_prefix' => 'i_',
|
267 |
-
'input_name_suffix' => '',
|
268 |
-
), $atts );
|
269 |
-
|
270 |
-
$ftype = isset($field['type']) ? $field['type'] : 'text';
|
271 |
-
|
272 |
-
if($ftype == 'multiselect'){
|
273 |
-
$args['input_name_suffix'] = $args['input_name_suffix'].'[]';
|
274 |
-
}
|
275 |
-
|
276 |
-
$fname = $args['input_name_prefix'].$field['name'].$args['input_name_suffix'];
|
277 |
-
$fvalue = isset($field['value']) ? esc_html($field['value']) : '';
|
278 |
-
|
279 |
-
$input_width = $args['input_width'] ? 'width:'.$args['input_width'].';' : '';
|
280 |
-
$field_props = 'name="'. $fname .'" value="'. $fvalue .'" style="'. $input_width .'"';
|
281 |
-
$field_props .= ( isset($field['placeholder']) && !empty($field['placeholder']) ) ? ' placeholder="'.$field['placeholder'].'"' : '';
|
282 |
-
$field_props .= ( isset($field['onchange']) && !empty($field['onchange']) ) ? ' onchange="'.$field['onchange'].'"' : '';
|
283 |
-
|
284 |
-
return $field_props;
|
285 |
-
}
|
286 |
-
|
287 |
-
private function render_form_field_element_inputtext($field, $atts = array()){
|
288 |
-
$field_html = '';
|
289 |
-
if($field && is_array($field)){
|
290 |
-
$field_props = $this->prepare_form_field_props($field, $atts);
|
291 |
-
$field_html = '<input type="text" '. $field_props .' />';
|
292 |
-
}
|
293 |
-
return $field_html;
|
294 |
-
}
|
295 |
-
|
296 |
-
private function render_form_field_element_textarea($field, $atts = array()){
|
297 |
-
$field_html = '';
|
298 |
-
if($field && is_array($field)){
|
299 |
-
$args = shortcode_atts( array(
|
300 |
-
'rows' => '5',
|
301 |
-
'cols' => '100',
|
302 |
-
), $atts );
|
303 |
-
|
304 |
-
$fvalue = isset($field['value']) ? $field['value'] : '';
|
305 |
-
$field_props = $this->prepare_form_field_props($field, $atts);
|
306 |
-
$field_html = '<textarea '. $field_props .' rows="'.$args['rows'].'" cols="'.$args['cols'].'" >'.$fvalue.'</textarea>';
|
307 |
-
}
|
308 |
-
return $field_html;
|
309 |
-
}
|
310 |
-
|
311 |
-
private function render_form_field_element_checkbox($field, $atts = array(), $render_cell = true){
|
312 |
-
$field_html = '';
|
313 |
-
if($field && is_array($field)){
|
314 |
-
$args = shortcode_atts( array(
|
315 |
-
'label_props' => '',
|
316 |
-
'cell_props' => 3,
|
317 |
-
'render_input_cell' => false,
|
318 |
-
), $atts );
|
319 |
-
|
320 |
-
$fid = 'a_f'. $field['name'];
|
321 |
-
$flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : '';
|
322 |
-
|
323 |
-
$field_props = $this->prepare_form_field_props($field, $atts);
|
324 |
-
$field_props .= isset($field['checked']) && $field['checked'] === 1 ? ' checked' : '';
|
325 |
-
|
326 |
-
$field_html = '<input type="checkbox" id="'. $fid .'" '. $field_props .' />';
|
327 |
-
$field_html .= '<label for="'. $fid .'" '. $args['label_props'] .' > '. $flabel .'</label>';
|
328 |
-
}
|
329 |
-
if(!$render_cell && $args['render_input_cell']){
|
330 |
-
return '<td '. $args['cell_props'] .' >'. $field_html .'</td>';
|
331 |
-
}else{
|
332 |
-
return $field_html;
|
333 |
-
}
|
334 |
-
}
|
335 |
-
|
336 |
-
public function render_form_fragment_tooltip($tooltip = false){
|
337 |
-
$tooltip_html = '';
|
338 |
-
|
339 |
-
if($tooltip){
|
340 |
-
//$tooltip_html = '<a href="javascript:void(0)" title="'. $tooltip .'" class="thwcfd_tooltip"><img src="'. THWCFD_ASSETS_URL.'css/help.png" title=""/></a>';
|
341 |
-
}
|
342 |
-
?>
|
343 |
-
<td style="width: 26px; padding:0px;"><?php echo $tooltip_html; ?></td>
|
344 |
-
<?php
|
345 |
-
}
|
346 |
-
|
347 |
-
|
348 |
-
public function print_notices($msg, $type='updated', $return=false){
|
349 |
-
$notice = '<div class="thwcfd-notice '. $type .'"><p>'. __($msg, 'woo-checkout-field-editor-pro') .'</p></div>';
|
350 |
-
if(!$return){
|
351 |
-
echo $notice;
|
352 |
-
}
|
353 |
-
return $notice;
|
354 |
-
}
|
355 |
-
|
356 |
-
/******* TABS & SECTIONS *******/
|
357 |
-
/*******************************/
|
358 |
-
public function get_current_tab(){
|
359 |
-
return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
360 |
-
}
|
361 |
-
|
362 |
-
public function render_tabs(){
|
363 |
-
$current_tab = $this->get_current_tab();
|
364 |
-
|
365 |
-
if(empty($this->tabs)){
|
366 |
-
return;
|
367 |
-
}
|
368 |
-
|
369 |
-
echo '<h2 class="thpladmin-tabs nav-tab-wrapper woo-nav-tab-wrapper">';
|
370 |
-
foreach( $this->tabs as $id => $label ){
|
371 |
-
$active = ( $current_tab == $id ) ? 'nav-tab-active' : '';
|
372 |
-
$label = __($label, 'woo-checkout-field-editor-pro');
|
373 |
-
echo '<a class="nav-tab '.$active.'" href="'. $this->get_admin_url($id) .'">'.$label.'</a>';
|
374 |
-
}
|
375 |
-
echo '</h2>';
|
376 |
-
}
|
377 |
-
|
378 |
-
public function get_admin_url($tab = false, $section = false){
|
379 |
-
$url = 'admin.php?page=checkout_form_designer';
|
380 |
-
if($tab && !empty($tab)){
|
381 |
-
$url .= '&tab='. $tab;
|
382 |
-
}
|
383 |
-
if($section && !empty($section)){
|
384 |
-
$url .= '§ion='. $section;
|
385 |
-
}
|
386 |
-
return admin_url($url);
|
387 |
-
}
|
388 |
-
}
|
389 |
-
|
390 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/class-thwcfd.php
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The file that defines the core plugin class.
|
4 |
-
*
|
5 |
-
* @link https://themehigh.com
|
6 |
-
* @since 1.3.6
|
7 |
-
*
|
8 |
-
* @package woo-checkout-field-editor-pro
|
9 |
-
* @subpackage woo-checkout-field-editor-pro/classes
|
10 |
-
*/
|
11 |
-
|
12 |
-
defined( 'ABSPATH' ) || exit;
|
13 |
-
|
14 |
-
if(!class_exists('THWCFD')):
|
15 |
-
|
16 |
-
class THWCFD {
|
17 |
-
const TEXT_DOMAIN = 'woo-checkout-field-editor-pro';
|
18 |
-
|
19 |
-
public function __construct() {
|
20 |
-
$this->load_dependencies();
|
21 |
-
$this->set_locale();
|
22 |
-
$this->define_admin_hooks();
|
23 |
-
$this->define_public_hooks();
|
24 |
-
}
|
25 |
-
|
26 |
-
private function load_dependencies() {
|
27 |
-
if(!function_exists('is_plugin_active')){
|
28 |
-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
29 |
-
}
|
30 |
-
require_once THWCFD_PATH . 'classes/class-thwcfd-utils.php';
|
31 |
-
require_once THWCFD_PATH . 'classes/class-thwcfd-settings.php';
|
32 |
-
require_once THWCFD_PATH . 'classes/class-thwcfd-settings-general.php';
|
33 |
-
require_once THWCFD_PATH . 'classes/class-thwcfd-settings-advanced.php';
|
34 |
-
require_once THWCFD_PATH . 'classes/class-thwcfd-checkout.php';
|
35 |
-
}
|
36 |
-
|
37 |
-
private function set_locale() {
|
38 |
-
add_action('plugins_loaded', array($this, 'load_plugin_textdomain'));
|
39 |
-
}
|
40 |
-
|
41 |
-
public function load_plugin_textdomain(){
|
42 |
-
$locale = apply_filters('plugin_locale', get_locale(), self::TEXT_DOMAIN);
|
43 |
-
|
44 |
-
load_textdomain(self::TEXT_DOMAIN, WP_LANG_DIR.'/woo-checkout-field-editor-pro/'.self::TEXT_DOMAIN.'-'.$locale.'.mo');
|
45 |
-
load_plugin_textdomain(self::TEXT_DOMAIN, false, dirname(THWCFD_BASE_NAME) . '/languages/');
|
46 |
-
}
|
47 |
-
|
48 |
-
private function define_admin_hooks() {
|
49 |
-
$plugin_admin = new THWCFD_Settings();
|
50 |
-
|
51 |
-
add_action('admin_enqueue_scripts', array($plugin_admin, 'enqueue_styles_and_scripts'));
|
52 |
-
add_action('admin_menu', array($plugin_admin, 'admin_menu'));
|
53 |
-
add_filter('woocommerce_screen_ids', array($plugin_admin, 'add_screen_id'));
|
54 |
-
add_filter('plugin_action_links_'.THWCFD_BASE_NAME, array($plugin_admin, 'plugin_action_links'));
|
55 |
-
//add_filter('plugin_row_meta', array($plugin_admin, 'plugin_row_meta'), 10, 2);
|
56 |
-
|
57 |
-
$general_settings = new THWCFD_Settings_General();
|
58 |
-
add_action('after_setup_theme', array($general_settings, 'define_admin_hooks'));
|
59 |
-
}
|
60 |
-
|
61 |
-
private function define_public_hooks() {
|
62 |
-
//if(!is_admin() || (defined( 'DOING_AJAX' ) && DOING_AJAX)){
|
63 |
-
$plugin_checkout = new THWCFD_Checkout();
|
64 |
-
add_action('wp_enqueue_scripts', array($plugin_checkout, 'enqueue_styles_and_scripts'));
|
65 |
-
add_action('after_setup_theme', array($plugin_checkout, 'define_public_hooks'));
|
66 |
-
//}
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-thwcfd-autoloader.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Auto-loads the required dependencies for this plugin.
|
4 |
+
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
* @since 1.5.0
|
7 |
+
*
|
8 |
+
* @package woo-checkout-field-editor-pro
|
9 |
+
* @subpackage woo-checkout-field-editor-pro/includes
|
10 |
+
*/
|
11 |
+
if(!defined('WPINC')){ die; }
|
12 |
+
|
13 |
+
if(!class_exists('THWCFD_Autoloader')):
|
14 |
+
|
15 |
+
class THWCFD_Autoloader {
|
16 |
+
private $include_path = '';
|
17 |
+
|
18 |
+
private $class_path = array();
|
19 |
+
|
20 |
+
public function __construct() {
|
21 |
+
$this->include_path = untrailingslashit(THWCFD_PATH);
|
22 |
+
|
23 |
+
if(function_exists("__autoload")){
|
24 |
+
spl_autoload_register("__autoload");
|
25 |
+
}
|
26 |
+
spl_autoload_register(array($this, 'autoload'));
|
27 |
+
}
|
28 |
+
|
29 |
+
/** Include a class file. */
|
30 |
+
private function load_file( $path ) {
|
31 |
+
if ( $path && is_readable( $path ) ) {
|
32 |
+
require_once( $path );
|
33 |
+
return true;
|
34 |
+
}
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
+
/** Class name to file name. */
|
39 |
+
private function get_file_name_from_class( $class ) {
|
40 |
+
return 'class-' . str_replace( '_', '-', $class ) . '.php';
|
41 |
+
}
|
42 |
+
|
43 |
+
public function autoload( $class ) {
|
44 |
+
$class = strtolower( $class );
|
45 |
+
$file = $this->get_file_name_from_class( $class );
|
46 |
+
$path = '';
|
47 |
+
$file_path = '';
|
48 |
+
|
49 |
+
if(isset($this->class_path[$class])){
|
50 |
+
$file_path = $this->include_path . '/' . $this->class_path[$class];
|
51 |
+
|
52 |
+
} else {
|
53 |
+
if (strpos($class, 'thwcfd_admin') === 0){
|
54 |
+
$path = $this->include_path . '/admin/';
|
55 |
+
|
56 |
+
} elseif (strpos($class, 'thwcfd_public') === 0){
|
57 |
+
$path = $this->include_path . '/public/';
|
58 |
+
|
59 |
+
} elseif (strpos($class, 'thwcfd_utils') === 0){
|
60 |
+
$path = $this->include_path . '/includes/utils/';
|
61 |
+
|
62 |
+
} elseif (strpos($class, 'wcfe_checkout_field') === 0){
|
63 |
+
$path = $this->include_path . '/includes/model/fields/';
|
64 |
+
|
65 |
+
} elseif (strpos($class, 'wcfe_checkout_section') === 0){
|
66 |
+
$path = $this->include_path . '/includes/model/';
|
67 |
+
|
68 |
+
} else{
|
69 |
+
$path = $this->include_path . '/includes/';
|
70 |
+
}
|
71 |
+
$file_path = $path . $file;
|
72 |
+
}
|
73 |
+
|
74 |
+
if( empty($file_path) || (!$this->load_file($file_path) && strpos($class, 'thwcfd_') === 0) ) {
|
75 |
+
$this->load_file( $this->include_path . $file );
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
endif;
|
81 |
+
|
82 |
+
new THWCFD_Autoloader();
|
includes/class-thwcfd.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The file that defines the core plugin class.
|
4 |
+
*
|
5 |
+
* @link https://themehigh.com
|
6 |
+
* @since 1.5.0
|
7 |
+
*
|
8 |
+
* @package woo-checkout-field-editor-pro
|
9 |
+
* @subpackage woo-checkout-field-editor-pro/includes
|
10 |
+
*/
|
11 |
+
if(!defined('WPINC')){ die; }
|
12 |
+
|
13 |
+
if(!class_exists('THWCFD')):
|
14 |
+
|
15 |
+
class THWCFD {
|
16 |
+
protected $plugin_name;
|
17 |
+
protected $version;
|
18 |
+
const TEXT_DOMAIN = 'woo-checkout-field-editor-pro';
|
19 |
+
|
20 |
+
public function __construct() {
|
21 |
+
if(defined( 'THWCFD_VERSION')){
|
22 |
+
$this->version = THWCFD_VERSION;
|
23 |
+
} else {
|
24 |
+
$this->version = '1.0.0';
|
25 |
+
}
|
26 |
+
$this->plugin_name = 'woo-checkout-field-editor-pro';
|
27 |
+
|
28 |
+
$this->load_dependencies();
|
29 |
+
$this->set_locale();
|
30 |
+
$this->define_admin_hooks();
|
31 |
+
$this->define_public_hooks();
|
32 |
+
|
33 |
+
add_action('init', array($this, 'init'));
|
34 |
+
}
|
35 |
+
|
36 |
+
private function load_dependencies() {
|
37 |
+
if(!function_exists('is_plugin_active')){
|
38 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
39 |
+
}
|
40 |
+
|
41 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-thwcfd-autoloader.php';
|
42 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-thwcfd-admin.php';
|
43 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-thwcfd-public-checkout.php';
|
44 |
+
|
45 |
+
// require_once THWCFD_PATH . 'classes/class-thwcfd-utils.php';
|
46 |
+
// require_once THWCFD_PATH . 'classes/class-thwcfd-settings.php';
|
47 |
+
// require_once THWCFD_PATH . 'classes/class-thwcfd-settings-general.php';
|
48 |
+
// require_once THWCFD_PATH . 'classes/class-thwcfd-settings-advanced.php';
|
49 |
+
// require_once THWCFD_PATH . 'classes/class-thwcfd-checkout.php';
|
50 |
+
}
|
51 |
+
|
52 |
+
private function set_locale() {
|
53 |
+
add_action('plugins_loaded', array($this, 'load_plugin_textdomain'));
|
54 |
+
}
|
55 |
+
|
56 |
+
public function load_plugin_textdomain(){
|
57 |
+
$locale = apply_filters('plugin_locale', get_locale(), self::TEXT_DOMAIN);
|
58 |
+
|
59 |
+
load_textdomain(self::TEXT_DOMAIN, WP_LANG_DIR.'/woo-checkout-field-editor-pro/'.self::TEXT_DOMAIN.'-'.$locale.'.mo');
|
60 |
+
load_plugin_textdomain(self::TEXT_DOMAIN, false, dirname(THWCFD_BASE_NAME) . '/languages/');
|
61 |
+
}
|
62 |
+
|
63 |
+
private function define_admin_hooks() {
|
64 |
+
$plugin_admin = new THWCFD_Admin( $this->get_plugin_name(), $this->get_version() );
|
65 |
+
|
66 |
+
add_action('admin_enqueue_scripts', array($plugin_admin, 'enqueue_styles_and_scripts'));
|
67 |
+
add_action('admin_menu', array($plugin_admin, 'admin_menu'));
|
68 |
+
add_filter('woocommerce_screen_ids', array($plugin_admin, 'add_screen_id'));
|
69 |
+
add_filter('plugin_action_links_'.THWCFD_BASE_NAME, array($plugin_admin, 'plugin_action_links'));
|
70 |
+
//add_filter('plugin_row_meta', array($plugin_admin, 'plugin_row_meta'), 10, 2);
|
71 |
+
add_action('wp_ajax_dismiss_thwcfd_upgrade_notice', array($plugin_admin, 'dismiss_thwcfd_upgrade_notice'));
|
72 |
+
|
73 |
+
$general_settings = new THWCFD_Admin_Settings_General();
|
74 |
+
add_action('after_setup_theme', array($general_settings, 'define_admin_hooks'));
|
75 |
+
}
|
76 |
+
|
77 |
+
private function define_public_hooks() {
|
78 |
+
//if(!is_admin() || (defined( 'DOING_AJAX' ) && DOING_AJAX)){
|
79 |
+
$plugin_checkout = new THWCFD_Public_Checkout( $this->get_plugin_name(), $this->get_version() );
|
80 |
+
add_action('wp_enqueue_scripts', array($plugin_checkout, 'enqueue_styles_and_scripts'));
|
81 |
+
add_action('after_setup_theme', array($plugin_checkout, 'define_public_hooks'));
|
82 |
+
//}
|
83 |
+
}
|
84 |
+
|
85 |
+
public function init(){
|
86 |
+
$this->define_constants();
|
87 |
+
}
|
88 |
+
|
89 |
+
private function define_constants(){
|
90 |
+
!defined('THWCFD_ASSETS_URL_ADMIN') && define('THWCFD_ASSETS_URL_ADMIN', THWCFD_URL . 'admin/assets/');
|
91 |
+
!defined('THWCFD_ASSETS_URL_PUBLIC') && define('THWCFD_ASSETS_URL_PUBLIC', THWCFD_URL . 'public/assets/');
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* The name of the plugin used to uniquely identify it within the context of
|
96 |
+
* WordPress and to define internationalization functionality.
|
97 |
+
*
|
98 |
+
* @return string The name of the plugin.
|
99 |
+
*/
|
100 |
+
public function get_plugin_name() {
|
101 |
+
return $this->plugin_name;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Retrieve the version number of the plugin.
|
106 |
+
*
|
107 |
+
* @return string The version number of the plugin.
|
108 |
+
*/
|
109 |
+
public function get_version() {
|
110 |
+
return $this->version;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
endif;
|
{classes → includes/utils}/class-thwcfd-utils.php
RENAMED
@@ -1,19 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
* @link https://themehigh.com
|
6 |
-
* @since 1.
|
7 |
*
|
8 |
* @package woo-checkout-field-editor-pro
|
9 |
-
* @subpackage woo-checkout-field-editor-pro/
|
10 |
*/
|
11 |
-
|
12 |
-
defined( 'ABSPATH' ) || exit;
|
13 |
|
14 |
if(!class_exists('THWCFD_Utils')):
|
15 |
|
16 |
-
class THWCFD_Utils {
|
17 |
const OPTION_KEY_ADVANCED_SETTINGS = 'thwcfd_advanced_settings';
|
18 |
|
19 |
public function __construct() {
|
@@ -350,4 +349,4 @@ class THWCFD_Utils {
|
|
350 |
}
|
351 |
}
|
352 |
|
353 |
-
endif;
|
1 |
<?php
|
2 |
/**
|
3 |
+
* The common utility functionalities for the plugin.
|
4 |
*
|
5 |
* @link https://themehigh.com
|
6 |
+
* @since 1.5.0
|
7 |
*
|
8 |
* @package woo-checkout-field-editor-pro
|
9 |
+
* @subpackage woo-checkout-field-editor-pro/public
|
10 |
*/
|
11 |
+
if(!defined('WPINC')){ die; }
|
|
|
12 |
|
13 |
if(!class_exists('THWCFD_Utils')):
|
14 |
|
15 |
+
class THWCFD_Utils {
|
16 |
const OPTION_KEY_ADVANCED_SETTINGS = 'thwcfd_advanced_settings';
|
17 |
|
18 |
public function __construct() {
|
349 |
}
|
350 |
}
|
351 |
|
352 |
+
endif;
|
public/assets/css/thwcfd-public.min.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.thwcfd-field-radio label.radio{display:inline-block;margin-right:15px}.thwcfd-optional .required{display:none}
|
public/assets/js/thwcfd-public.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
jQuery(document).ready(function($){function field_is_required(field,is_required){is_required?(field.find("label .optional").remove(),field.addClass("validate-required"),field_label_white_space_fix(field),0===field.find("label .required").length&&field.find("label").append(' <abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>')):(field.find("label .required").remove(),field.removeClass("validate-required woocommerce-invalid woocommerce-invalid-required-field"),field_label_white_space_fix(field),0===field.find("label .optional").length&&field.find("label").append(' <span class="optional">('+wc_address_i18n_params.i18n_optional_text+")</span>"))}function address_fields_required_validation_fix(){var thisform=$(".woocommerce-checkout"),locale_fields=$.parseJSON(wc_address_i18n_params.locale_fields);locale_fields&&$.each(locale_fields,function(key,value){var fids=value.split(",");$.each(fids,function(index,fid){var field=thisform.find(fid.trim());field.hasClass("thwcfd-required")?field_is_required(field,!0):field.hasClass("thwcfd-optional")&&field_is_required(field,!1)})})}function field_label_white_space_fix(field){var label=field.find("label").html();label&&(label=label.replace(/(?:^(?: )+)|(?:(?: )+$)/g,""),field.find("label").html(label.trim()))}$("select.thwcfd-enhanced-select").selectWoo({allowClear:!0,placeholder:$(this).data("placeholder")}).addClass("enhanced"),$(document.body).bind("country_to_state_changing",function(event,country,wrapper){thwcfd_public_var.is_override_required&&setTimeout(address_fields_required_validation_fix,500)})});
|
classes/class-thwcfd-checkout.php → public/class-thwcfd-public-checkout.php
RENAMED
@@ -6,14 +6,14 @@
|
|
6 |
* @since 1.3.6
|
7 |
*
|
8 |
* @package woo-checkout-field-editor-pro
|
9 |
-
* @subpackage woo-checkout-field-editor-pro/
|
10 |
*/
|
11 |
|
12 |
defined( 'ABSPATH' ) || exit;
|
13 |
|
14 |
-
if(!class_exists('
|
15 |
|
16 |
-
class
|
17 |
public function __construct() {
|
18 |
|
19 |
}
|
@@ -22,10 +22,12 @@ class THWCFD_Checkout {
|
|
22 |
if(is_checkout()){
|
23 |
$in_footer = apply_filters( 'thwcfd_enqueue_script_in_footer', true );
|
24 |
$deps = array('jquery', 'selectWoo');
|
25 |
-
|
26 |
-
|
|
|
|
|
27 |
wp_enqueue_script('thwcfd-checkout-script');
|
28 |
-
wp_enqueue_style('thwcfd-checkout-style',
|
29 |
|
30 |
$wcfd_var = array(
|
31 |
'is_override_required' => $this->is_override_required_prop(),
|
@@ -500,4 +502,3 @@ class THWCFD_Checkout {
|
|
500 |
}
|
501 |
|
502 |
endif;
|
503 |
-
|
6 |
* @since 1.3.6
|
7 |
*
|
8 |
* @package woo-checkout-field-editor-pro
|
9 |
+
* @subpackage woo-checkout-field-editor-pro/public
|
10 |
*/
|
11 |
|
12 |
defined( 'ABSPATH' ) || exit;
|
13 |
|
14 |
+
if(!class_exists('THWCFD_Public_Checkout')) :
|
15 |
|
16 |
+
class THWCFD_Public_Checkout {
|
17 |
public function __construct() {
|
18 |
|
19 |
}
|
22 |
if(is_checkout()){
|
23 |
$in_footer = apply_filters( 'thwcfd_enqueue_script_in_footer', true );
|
24 |
$deps = array('jquery', 'selectWoo');
|
25 |
+
|
26 |
+
$debug_mode = apply_filters('thwcfd_debug_mode', false);
|
27 |
+
$suffix = $debug_mode ? '' : '.min';
|
28 |
+
wp_register_script('thwcfd-checkout-script', THWCFD_ASSETS_URL_PUBLIC.'js/thwcfd-public' . $suffix . '.js', $deps, THWCFD_VERSION, $in_footer);
|
29 |
wp_enqueue_script('thwcfd-checkout-script');
|
30 |
+
wp_enqueue_style('thwcfd-checkout-style', THWCFD_ASSETS_URL_PUBLIC . 'css/thwcfd-public' . $suffix . '.css', THWCFD_VERSION);
|
31 |
|
32 |
$wcfd_var = array(
|
33 |
'is_override_required' => $this->is_override_required_prop(),
|
502 |
}
|
503 |
|
504 |
endif;
|
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: ThemeHigh
|
|
3 |
Donate link: https://themehigh.com/
|
4 |
Tags: checkout field editor, woocommerce checkout field editor, checkout manager, woocommerce checkout manager, checkout field customizer, checkout form editor, checkout form customizer, checkout, WooCommerce checkout, checkout form designer, woocommerce checkout fields, woocommerce checkout addons
|
5 |
Requires at least: 4.9
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 1.4.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -59,7 +59,8 @@ The premium version of [Checkout Field Editor for WooCommerce](https://www.theme
|
|
59 |
|
60 |
You can check out the demo for a more detailed overview of the features.
|
61 |
|
62 |
-
[Live Demo](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
|
|
|
63 |
|
64 |
= ☞ 17 field types are available =
|
65 |
In Add New Field form and Edit Field form you can choose field type from a list of 17 including 15 input fields and one field for title/heading and one for label.
|
@@ -122,7 +123,7 @@ Delete custom added section(s).
|
|
122 |
--------------------------------------------
|
123 |
*For the complete list of features, Please visit [WooCommerce Checkout Field Editor (Checkout Manager)](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) plugin's official page.*
|
124 |
|
125 |
-
Check how it works (
|
126 |
--------------------------------------------
|
127 |
|
128 |
== Why ThemeHigh ==
|
@@ -196,16 +197,20 @@ With the free plugin, the fields can be displayed and edited only from the Check
|
|
196 |
Yes. There is a button 'reset to default fields' to go back to the WooCommerce default fields.
|
197 |
|
198 |
== Screenshots ==
|
199 |
-
1. WooCommerce > Checkout Form
|
200 |
-
2.
|
201 |
-
3.
|
202 |
-
4.
|
203 |
-
5.
|
204 |
-
6.
|
205 |
-
7.
|
206 |
-
8.
|
207 |
|
208 |
== Changelog ==
|
|
|
|
|
|
|
|
|
209 |
= 1.4.5 =
|
210 |
* Enhanced Select(Select2) style issues fixed.
|
211 |
* Settings screen popup button style issues fixed.
|
3 |
Donate link: https://themehigh.com/
|
4 |
Tags: checkout field editor, woocommerce checkout field editor, checkout manager, woocommerce checkout manager, checkout field customizer, checkout form editor, checkout form customizer, checkout, WooCommerce checkout, checkout form designer, woocommerce checkout fields, woocommerce checkout addons
|
5 |
Requires at least: 4.9
|
6 |
+
Tested up to: 5.7
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 1.4.6
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
59 |
|
60 |
You can check out the demo for a more detailed overview of the features.
|
61 |
|
62 |
+
[Live Demo - Front End](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
|
63 |
+
[Live Demo - Back End](https://flydemos.com/wcfe/wp-admin/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
|
64 |
|
65 |
= ☞ 17 field types are available =
|
66 |
In Add New Field form and Edit Field form you can choose field type from a list of 17 including 15 input fields and one field for title/heading and one for label.
|
123 |
--------------------------------------------
|
124 |
*For the complete list of features, Please visit [WooCommerce Checkout Field Editor (Checkout Manager)](https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) plugin's official page.*
|
125 |
|
126 |
+
Check how it works (Live Demo): 🔗 [Front End](https://flydemos.com/wcfe/?utm_source=wordpress&utm_medium=referral&utm_content=tracking) | 🔗 [Back End](https://flydemos.com/wcfe/wp-admin/?utm_source=wordpress&utm_medium=referral&utm_content=tracking)
|
127 |
--------------------------------------------
|
128 |
|
129 |
== Why ThemeHigh ==
|
197 |
Yes. There is a button 'reset to default fields' to go back to the WooCommerce default fields.
|
198 |
|
199 |
== Screenshots ==
|
200 |
+
1. WooCommerce > Checkout Form
|
201 |
+
2. Add new field
|
202 |
+
3. New field popup form
|
203 |
+
4. Edit existing field
|
204 |
+
5. Edit field popup form
|
205 |
+
6. Rearrange fields (change field's display order)
|
206 |
+
7. Reset to default settings
|
207 |
+
8. Save changes.
|
208 |
|
209 |
== Changelog ==
|
210 |
+
= 1.4.6 =
|
211 |
+
* Settings screen UI improved.
|
212 |
+
* WordPress and WooCommerce compatible version updated.
|
213 |
+
|
214 |
= 1.4.5 =
|
215 |
* Enhanced Select(Select2) style issues fixed.
|
216 |
* Settings screen popup button style issues fixed.
|