PluginProbe ʕ •ᴥ•ʔ
Checkout Field Editor (Checkout Manager) for WooCommerce / 2.0.5
Checkout Field Editor (Checkout Manager) for WooCommerce v2.0.5
1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.0.9 1.2.0 1.2.5 1.2.8 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8
woo-checkout-field-editor-pro / admin / class-thwcfd-admin-settings.php
woo-checkout-field-editor-pro / admin Last commit date
assets 1 year ago class-thwcfd-admin-form-field.php 1 year ago class-thwcfd-admin-form.php 1 year ago class-thwcfd-admin-settings-advanced.php 1 year ago class-thwcfd-admin-settings-general.php 1 year ago class-thwcfd-admin-settings-pro.php 1 year ago class-thwcfd-admin-settings-themehigh-plugins.php 1 year ago class-thwcfd-admin-settings.php 1 year ago class-thwcfd-admin.php 1 year ago
class-thwcfd-admin-settings.php
270 lines
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(
24 'fields' => __('Checkout Fields', 'woo-checkout-field-editor-pro'),
25 'advanced_settings' => __('Advanced Settings', 'woo-checkout-field-editor-pro'),
26 'pro' => __('Premium Features', 'woo-checkout-field-editor-pro'),
27 'themehigh_plugins' => __('Other Free Plugins', 'woo-checkout-field-editor-pro'),
28 );
29 }
30
31 public function get_tabs(){
32 return $this->tabs;
33 }
34
35 public function get_current_tab(){
36 return $this->page_id;
37 }
38
39 public function get_current_section(){
40 return isset( $_GET['section'] ) ? sanitize_key( $_GET['section'] ) : $this->section_id;
41 }
42
43 public function render_tabs(){
44 $current_tab = $this->get_current_tab();
45 $tabs = $this->get_tabs();
46
47 if(empty($tabs)){
48 return;
49 }
50
51 echo '<h2 class="thpladmin-tabs nav-tab-wrapper woo-nav-tab-wrapper">';
52 foreach( $tabs as $id => $label ){
53 $active = ( $current_tab == $id ) ? 'nav-tab-active' : '';
54 //$label = esc_html__($label, 'woo-checkout-field-editor-pro');
55 echo '<a class="nav-tab '.esc_attr($active).'" href="'. esc_url($this->get_admin_url($id)) .'">'.esc_html($label).'</a>';
56 }
57 echo '</h2>';
58 }
59
60 // public function render_sections() {
61 // $current_section = $this->get_current_section();
62 // $sections = $this->get_sections();
63
64 // if(empty($sections)){
65 // return;
66 // }
67
68 // $array_keys = array_keys( $sections );
69
70 // echo '<ul class="thpladmin-sections">';
71 // foreach( $sections as $id => $label ){
72 // $label = wp_strip_all_tags(__($label, 'woo-checkout-field-editor-pro'));
73 // $url = $this->get_admin_url($this->page_id, sanitize_title($id));
74 // echo '<li><a href="'. $url .'" class="'. ( $current_section == $id ? 'current' : '' ) .'">'. $label .'</a> '. (end( $array_keys ) == $id ? '' : '|') .' </li>';
75 // }
76 // echo '</ul>';
77 // }
78
79 public function get_admin_url($tab = false, $section = false){
80 $url = 'admin.php?page=checkout_form_designer';
81 if($tab && !empty($tab)){
82 $url .= '&tab='. $tab;
83 }
84 if($section && !empty($section)){
85 $url .= '&section='. $section;
86 }
87 return admin_url($url);
88 }
89
90 public function print_notices($msg, $type='updated', $return=false){
91
92 // $notice = '<div class="thwcfd-notice '. $type .'"><p>'. $msg .'</p></div>';
93 // if(!$return){
94 // echo $notice;
95 // }
96 // return $notice;
97 ?>
98 <div class="thwcfd-notice <?php echo esc_attr($type); ?>"><p><?php echo esc_html($msg); ?></p></div>
99 <?php
100
101 }
102
103 /*******************************************
104 *-------- HTML FORM FRAGMENTS - START -----
105 *******************************************/
106
107 public function render_form_element_tooltip($tooltip=''){
108 $tooltip_html = '';
109
110 if($tooltip){
111 // $icon = THWCFD_ASSETS_URL_ADMIN.'/images/help.png';
112 // $tooltip_html = '<a href="javascript:void(0)" title="'. $tooltip .'" class="thpladmin_tooltip"><img src="'. $icon .'" alt="" title=""/></a>';
113 }
114 ?>
115 <td style="width: 26px; padding:0px;"><?php esc_html($tooltip_html); ?></td>
116 <?php
117 }
118
119 public function render_form_element_empty_cell(){
120 ?>
121 <td width="13%">&nbsp;</td>
122 <?php $this->render_form_element_tooltip(false); ?>
123 <td width="34%">&nbsp;</td>
124 <?php
125 }
126
127 public function render_form_element_h_separator($padding = 5, $colspan = 6){
128 ?>
129 <tr><td colspan="<?php echo esc_attr($colspan); ?>" style="border-bottom: 1px dashed #e6e6e6; padding-top: <?php echo esc_attr($padding) ?>px;"></td></tr>
130 <?php
131 }
132
133 public function render_form_element_h_spacing($padding = 5, $colspan = 6){
134 ?>
135 <tr><td colspan="<?php echo esc_attr($colspan); ?>" style="padding-top:<?php echo esc_attr($padding) ?>px;"></td></tr>
136 <?php
137 }
138
139 public function render_form_field_element($field, $atts = array(), $render_cell = true){
140
141 if($field && is_array($field)){
142 $args = shortcode_atts( array(
143 'label_cell_props' => '',
144 'input_cell_props' => '',
145 'label_cell_colspan' => '',
146 'input_cell_colspan' => '',
147 ), $atts );
148
149 $ftype = isset($field['type']) ? $field['type'] : 'text';
150 $flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : '';
151 $sub_label = isset($field['sub_label']) && !empty($field['sub_label']) ? __($field['sub_label'], 'woo-checkout-field-editor-pro') : '';
152 $tooltip = isset($field['hint_text']) && !empty($field['hint_text']) ? __($field['hint_text'], 'woo-checkout-field-editor-pro') : '';
153
154 $field_html = '';
155
156 if($ftype == 'text'){
157 $field_html = $this->render_form_field_element_inputtext($field, $atts);
158
159 }else if($ftype == 'textarea'){
160 $field_html = $this->render_form_field_element_textarea($field, $atts);
161
162 }else if($ftype == 'checkbox'){
163 $field_html = $this->render_form_field_element_checkbox($field, $atts, $render_cell);
164 $flabel = '&nbsp;';
165 }
166
167 if($render_cell){
168 $required_html = isset($field['required']) && $field['required'] ? '<abbr class="required" title="required">*</abbr>' : '';
169
170 $label_cell_props = !empty($args['label_cell_props']) ? $args['label_cell_props'] : '';
171 $input_cell_props = !empty($args['input_cell_props']) ? $args['input_cell_props'] : '';
172 ?>
173 <td <?php echo wp_kses($label_cell_props, array('class' => true)) ?> >
174 <?php echo esc_html($flabel); echo wp_kses($required_html, array('abbr' => true));
175 if($sub_label){
176 ?>
177 <br/><span class="thpladmin-subtitle"><?php echo esc_html($sub_label); ?></span>
178 <?php
179 }
180 ?>
181 </td>
182 <?php $this->render_form_element_tooltip($tooltip); ?>
183 <td <?php echo wp_kses($input_cell_props, array('class' => true)) ?> ><?php echo wp_kses($field_html, THWCFD_Utils::get_allowed_html()); ?></td>
184 <?php
185 }else{
186 echo wp_kses($field_html, THWCFD_Utils::get_allowed_html());
187 }
188 }
189 }
190
191 private function prepare_form_field_props($field, $atts = array()){
192 $field_props = '';
193 $args = shortcode_atts( array(
194 'input_width' => '',
195 'input_name_prefix' => 'i_',
196 'input_name_suffix' => '',
197 ), $atts );
198
199 $ftype = isset($field['type']) ? $field['type'] : 'text';
200
201 if($ftype == 'multiselect'){
202 $args['input_name_suffix'] = $args['input_name_suffix'].'[]';
203 }
204
205 $fname = $args['input_name_prefix'].$field['name'].$args['input_name_suffix'];
206 $fvalue = isset($field['value']) ? esc_html($field['value']) : '';
207
208 $input_width = $args['input_width'] ? 'width:'.$args['input_width'].';' : '';
209 $field_props = 'name="'. $fname .'" value="'. $fvalue .'" style="'. $input_width .'"';
210 $field_props .= ( isset($field['placeholder']) && !empty($field['placeholder']) ) ? ' placeholder="'.$field['placeholder'].'"' : '';
211 $field_props .= ( isset($field['onchange']) && !empty($field['onchange']) ) ? ' onchange="'.$field['onchange'].'"' : '';
212
213 return $field_props;
214 }
215
216 private function render_form_field_element_inputtext($field, $atts = array()){
217 $field_html = '';
218 if($field && is_array($field)){
219 $field_props = $this->prepare_form_field_props($field, $atts);
220 $field_html = '<input type="text" '. wp_kses_post($field_props) .' />';
221 }
222 return $field_html;
223 }
224
225 private function render_form_field_element_textarea($field, $atts = array()){
226 $field_html = '';
227 if($field && is_array($field)){
228 $args = shortcode_atts( array(
229 'rows' => '5',
230 'cols' => '100',
231 ), $atts );
232
233 $fvalue = isset($field['value']) ? $field['value'] : '';
234 $field_props = $this->prepare_form_field_props($field, $atts);
235 $field_html = '<textarea '. wp_kses_post($field_props) .' rows="'.esc_attr($args['rows']).'" cols="'.esc_attr($args['cols']).'" >'.esc_html($fvalue).'</textarea>';
236 }
237 return $field_html;
238 }
239
240 private function render_form_field_element_checkbox($field, $atts = array(), $render_cell = true){
241
242 $field_html = '';
243 if($field && is_array($field)){
244 $args = shortcode_atts( array(
245 'label_props' => '',
246 'cell_props' => 3,
247 'render_input_cell' => false,
248 ), $atts );
249
250 $fid = 'a_f'. $field['name'];
251 $flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : '';
252
253 $field_props = $this->prepare_form_field_props($field, $atts);
254 $field_props .= isset($field['checked']) && $field['checked'] === 1 ? ' checked' : '';
255
256 $field_html = '<input type="checkbox" id="'. esc_attr($fid) .'" '. wp_kses_post($field_props) .' />';
257 $field_html .= '<label for="'. esc_attr($fid) .'" '. wp_kses_post($args['label_props']) .' > '. esc_html($flabel) .'</label>';
258 }
259 if(!$render_cell && $args['render_input_cell']){
260 return '<td '. wp_kses_post($args['cell_props']) .' >'. wp_kses($field_html, THWCFD_Utils::get_allowed_html()) .'</td>';
261 }else{
262 return wp_kses($field_html,THWCFD_Utils::get_allowed_html());
263 }
264 }
265 /*******************************************
266 *-------- HTML FORM FRAGMENTS - END -----
267 *******************************************/
268 }
269
270 endif;