PluginProbe
Order Tracking – WordPress Status Tracking Plugin / 3.2.2
Order Tracking – WordPress Status Tracking Plugin v3.2.2
3.5.4 3.5.3 3.5.2 3.5.1 3.5.0 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.3.0 3.3.1 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 All 235 releases
order-tracking / includes / AdminCustomFields.class.php

AdminCustomFields.class.php in Order Tracking – WordPress Status Tracking Plugin 3.2.2, at includes/AdminCustomFields.class.php

239 lines 12.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( !defined( 'ABSPATH' ) ) exit;
3
4 if ( !class_exists( 'ewdotpAdminCustomFields' ) ) {
5 /**
6 * Class to handle the admin custom fields page for Order Tracking
7 *
8 * @since 3.0.0
9 */
10 class ewdotpAdminCustomFields {
11
12 public function __construct() {
13
14 // Add the admin menu
15 add_action( 'admin_menu', array( $this, 'add_menu_page' ), 12 );
16 }
17
18 /**
19 * Add the top-level admin menu page
20 * @since 3.0.0
21 */
22 public function add_menu_page() {
23 global $ewd_otp_controller;
24
25 add_submenu_page(
26 'ewd-otp-orders',
27 _x( 'Custom Fields', 'Title of admin page that lets you view and edit all custom fields', 'order-tracking' ),
28 _x( 'Custom Fields', 'Title of the custom fields admin menu item', 'order-tracking' ),
29 $ewd_otp_controller->settings->get_setting( 'access-role' ),
30 'ewd-otp-custom-fields',
31 array( $this, 'show_admin_custom_fields_page' )
32 );
33 }
34
35 /**
36 * Display the admin custom fields page
37 * @since 3.0.0
38 */
39 public function show_admin_custom_fields_page() {
40 global $ewd_otp_controller;
41
42 $permission = ( $ewd_otp_controller->permissions->check_permission( 'custom_fields' ) or get_option( 'ewd-otp-installation-time' ) < 1664742505 ) ? true : false;
43
44 if ( ! empty( $_POST['ewd-otp-custom-fields-submit'] ) ) {
45
46 $this->save_custom_fields();
47 }
48
49 $custom_fields = get_option( 'ewd-otp-custom-fields' );
50
51 $custom_fields[] = (object) array(
52 'id' => 0,
53 'name' => '',
54 'slug' => '',
55 'type' => '',
56 'options' => '',
57 'function' => '',
58 'required' => '',
59 'display' => '',
60 'front_end_display' => '',
61 'equivalent' => ''
62 );
63
64 ?>
65
66 <div class="wrap">
67 <h1>
68 <?php _e( 'Custom Fields', 'order-tracking' ); ?>
69 </h1>
70
71 <?php if ( $permission ) { ?>
72
73 <?php do_action( 'ewd_otp_custom_fields_table_top' ); ?>
74
75 <form id="ewd-otp-custom-fields-table" method="POST" action="">
76
77 <fieldset class="ewd-otp-warning-tip">
78 <div class="ewd-otp-shortcode-reminder">
79 <strong><?php _e( 'FILE AND IMAGE FIELDS', 'order-tracking' ); ?>:</strong> <?php _e( 'For security reasons, file and image type fields are not available for use in the customer order form.', 'order-tracking' ); ?>
80 </div>
81 </fieldset>
82
83 <div id='ewd-otp-custom-fields-table-div'>
84
85 <input type='hidden' name='ewd-otp-custom-field-save-values' />
86
87 <div class='ewd-otp-custom-field-heading-row'>
88 <div class='ewd-otp-custom-field-heading-cell'><?php _e( 'Name', 'order-tracking' ); ?></div>
89 <div class='ewd-otp-custom-field-heading-cell'><?php _e( 'Slug', 'order-tracking' ); ?></div>
90 <div class='ewd-otp-custom-field-heading-cell'><?php _e( 'Type', 'order-tracking' ); ?></div>
91 <div class='ewd-otp-custom-field-heading-cell'><?php _e( 'Input Values', 'order-tracking' ); ?></div>
92 <div class='ewd-otp-custom-field-heading-cell'><?php _e( 'Applicable to', 'order-tracking' ); ?></div>
93 <div class='ewd-otp-custom-field-heading-cell'><?php _e( 'Options', 'order-tracking' ); ?></div>
94 <div class='ewd-otp-custom-field-heading-cell'><?php _e( 'WooCommerce Equivalent', 'order-tracking' ); ?></div>
95 <div class='ewd-otp-custom-field-heading-cell'></div>
96 </div>
97
98 <?php foreach ( $custom_fields as $custom_field ) { ?>
99
100 <div class='ewd-otp-custom-field <?php echo ( empty( $custom_field->id ) ? 'ewd-otp-hidden ewd-otp-custom-field-template' : '' ); ?>'>
101 <input type='hidden' name='ewd_otp_custom_field_id' value='<?php echo esc_attr( $custom_field->id ); ?>' />
102
103 <div class='ewd-otp-custom-field-cell'>
104 <label><?php _e( 'Name', 'order-tracking' ); ?></label>
105 <input type='text' name='ewd_otp_custom_field_name' value='<?php echo esc_attr( $custom_field->name ); ?>' />
106 </div>
107
108 <div class='ewd-otp-custom-field-cell'>
109 <label><?php _e( 'Slug', 'order-tracking' ); ?></label>
110 <input type='text' name='ewd_otp_custom_field_slug' value='<?php echo esc_attr( $custom_field->slug ); ?>' />
111 </div>
112
113 <div class='ewd-otp-custom-field-cell'>
114
115 <label><?php _e( 'Type', 'order-tracking' ); ?></label>
116
117 <select name='ewd_otp_custom_field_type'>
118
119 <option value='text' <?php echo ( $custom_field->type == 'text' ? 'selected' : '' ); ?>><?php _e( 'Text', 'order-tracking' ); ?></option>
120 <option value='number' <?php echo ( $custom_field->type == 'number' ? 'selected' : '' ); ?>><?php _e( 'Number', 'order-tracking' ); ?></option>
121 <option value='textarea' <?php echo ( $custom_field->type == 'textarea' ? 'selected' : '' ); ?>><?php _e( 'Textarea', 'order-tracking' ); ?></option>
122 <option value='select' <?php echo ( $custom_field->type == 'select' ? 'selected' : '' ); ?>><?php _e( 'Dropdown', 'order-tracking' ); ?></option>
123 <option value='radio' <?php echo ( $custom_field->type == 'radio' ? 'selected' : '' ); ?>><?php _e( 'Radio', 'order-tracking' ); ?></option>
124 <option value='checkbox' <?php echo ( $custom_field->type == 'checkbox' ? 'selected' : '' ); ?>><?php _e( 'Checkbox', 'order-tracking' ); ?></option>
125 <option value='file' <?php echo ( $custom_field->type == 'file' ? 'selected' : '' ); ?>><?php _e( 'File', 'order-tracking' ); ?></option>
126 <option value='link' <?php echo ( $custom_field->type == 'link' ? 'selected' : '' ); ?>><?php _e( 'Link', 'order-tracking' ); ?></option>
127 <option value='image' <?php echo ( $custom_field->type == 'image' ? 'selected' : '' ); ?>><?php _e( 'Image', 'order-tracking' ); ?></option>
128 <option value='date' <?php echo ( $custom_field->type == 'date' ? 'selected' : '' ); ?>><?php _e( 'Date', 'order-tracking' ); ?></option>
129 <option value='datetime' <?php echo ( $custom_field->type == 'datetime' ? 'selected' : '' ); ?>><?php _e( 'Datetime', 'order-tracking' ); ?></option>
130
131 </select>
132
133 </div>
134
135 <div class='ewd-otp-custom-field-cell'>
136 <label><?php _e( 'Input Values', 'order-tracking' ); ?></label>
137 <input type='text' name='ewd_otp_custom_field_options' value='<?php echo esc_attr( $custom_field->options ); ?>' />
138 </div>
139
140 <div class='ewd-otp-custom-field-cell'>
141
142 <label><?php _e( 'Applicable to', 'order-tracking' ); ?></label>
143
144 <select name='ewd_otp_custom_field_function'>
145
146 <option value='orders' <?php echo ( $custom_field->function == 'orders' ? 'selected' : '' ); ?>><?php _e( 'Orders', 'order-tracking' ); ?></option>
147 <option value='customers' <?php echo ( $custom_field->function == 'customers' ? 'selected' : '' ); ?>><?php _e( 'Customers', 'order-tracking' ); ?></option>
148 <option value='sales_reps' <?php echo ( $custom_field->function == 'sales_reps' ? 'selected' : '' ); ?>><?php _e( 'Sales Reps', 'order-tracking' ); ?></option>
149
150 </select>
151
152 </div>
153
154 <div class='ewd-otp-custom-field-cell'>
155
156 <label><?php _e( 'Options', 'order-tracking' ); ?></label>
157
158 <div class='ewd-otp-custom-field-cell-checkbox-container'>
159 <input type='checkbox' name='ewd_otp_custom_field_required' value='1' <?php echo ( ! empty( $custom_field->required ) ? 'checked' : '' ); ?> /><?php _e( 'Required', 'order-tracking' ); ?><br />
160 <input type='checkbox' name='ewd_otp_custom_field_display' value='1' <?php echo ( ! empty( $custom_field->display ) ? 'checked' : '' ); ?> /><?php _e( 'Admin Display?', 'order-tracking' ); ?><br />
161 <input type='checkbox' name='ewd_otp_custom_field_front_end_display' value='1' <?php echo ( ! empty( $custom_field->front_end_display ) ? 'checked' : '' ); ?> /><?php _e( 'Front-End Display?', 'order-tracking' ); ?><br />
162 </div>
163
164 </div>
165
166 <div class='ewd-otp-custom-field-cell'>
167
168 <label><?php _e( 'WooCommerce Equivalent', 'order-tracking' ); ?></label>
169
170 <select name='ewd_otp_custom_field_equivalent'>
171
172 <option value='none' <?php echo ( $custom_field->equivalent == 'none' ? 'selected' : '' ); ?>><?php _e( 'None', 'order-tracking' ); ?></option>
173 <option value='_order_total' <?php echo ( $custom_field->equivalent == '_order_total' ? 'selected' : '' ); ?>><?php _e( 'Order Total', 'order-tracking' ); ?></option>
174 <option value='_order_currency' <?php echo ( $custom_field->equivalent == '_order_currency' ? 'selected' : '' ); ?>><?php _e( 'Order Currency', 'order-tracking' ); ?></option>
175 <option value='_billing_first_name' <?php echo ( $custom_field->equivalent == '_billing_first_name' ? 'selected' : '' ); ?>><?php _e( 'Billing First Name', 'order-tracking' ); ?></option>
176 <option value='_billing_last_name' <?php echo ( $custom_field->equivalent == '_billing_last_name' ? 'selected' : '' ); ?>><?php _e( 'Billing Last Name', 'order-tracking' ); ?></option>
177 <option value='_billing_company' <?php echo ( $custom_field->equivalent == '_billing_company' ? 'selected' : '' ); ?>><?php _e( 'Billing Company', 'order-tracking' ); ?></option>
178 <option value='_billing_city' <?php echo ( $custom_field->equivalent == '_billing_city' ? 'selected' : '' ); ?>><?php _e( 'Billing City', 'order-tracking' ); ?></option>
179 <option value='_billing_country' <?php echo ( $custom_field->equivalent == '_billing_country' ? 'selected' : '' ); ?>><?php _e( 'Billing Country', 'order-tracking' ); ?></option>
180 <option value='_billing_email' <?php echo ( $custom_field->equivalent == '_billing_email' ? 'selected' : '' ); ?>><?php _e( 'Billing Email', 'order-tracking' ); ?></option>
181 <option value='_billing_phone' <?php echo ( $custom_field->equivalent == '_billing_phone' ? 'selected' : '' ); ?>><?php _e( 'Billing Phone', 'order-tracking' ); ?></option>
182 <option value='_shipping_first_name' <?php echo ( $custom_field->equivalent == '_shipping_first_name' ? 'selected' : '' ); ?>><?php _e( 'Shipping First Name', 'order-tracking' ); ?></option>
183 <option value='_shipping_last_name' <?php echo ( $custom_field->equivalent == '_shipping_last_name' ? 'selected' : '' ); ?>><?php _e( 'Shipping Last Name', 'order-tracking' ); ?></option>
184 <option value='_shipping_company' <?php echo ( $custom_field->equivalent == '_shipping_company' ? 'selected' : '' ); ?>><?php _e( 'Shipping Company', 'order-tracking' ); ?></option>
185 <option value='_shipping_city' <?php echo ( $custom_field->equivalent == '_shipping_city' ? 'selected' : '' ); ?>><?php _e( 'Shipping City', 'order-tracking' ); ?></option>
186 <option value='_shipping_country' <?php echo ( $custom_field->equivalent == '_shipping_country' ? 'selected' : '' ); ?>><?php _e( 'Shipping Country', 'order-tracking' ); ?></option>
187 <option value='_shipping_email' <?php echo ( $custom_field->equivalent == '_shipping_email' ? 'selected' : '' ); ?>><?php _e( 'Shipping Email', 'order-tracking' ); ?></option>
188 <option value='_shipping_phone' <?php echo ( $custom_field->equivalent == '_shipping_phone' ? 'selected' : '' ); ?>><?php _e( 'Shipping Phone', 'order-tracking' ); ?></option>
189
190 </select>
191
192 </div>
193
194 <div class='ewd-otp-custom-field-cell ewd-otp-custom-field-delete'>
195 <?php _e( 'Delete', 'order-tracking' ); ?>
196 </div>
197
198 </div>
199
200 <?php } ?>
201
202 <div class='ewd-otp-custom-fields-add'>
203 <?php _e( '+ ADD', 'order-tracking' ); ?>
204 </div>
205
206 </div>
207
208 <input type='submit' class='button button-primary' name='ewd-otp-custom-fields-submit' value='<?php _e( 'Update Fields', 'order-tracking' ); ?>' />
209
210 </form>
211 <?php do_action( 'ewd_otp_custom_fields_table_bottom' ); ?>
212
213 <?php } else { ?>
214
215 <div class='ewd-otp-premium-locked'>
216 <a href="https://www.etoilewebdesign.com/license-payment/?Selected=OTP&Quantity=1" target="_blank">Upgrade</a> to the premium version to use this feature
217 </div>
218 <?php } ?>
219 </div>
220
221 <?php
222 }
223
224 /**
225 * Save the custom fields when the form is submitted
226 * @since 3.0.0
227 */
228 public function save_custom_fields() {
229
230 $custom_fields = json_decode( stripslashes( sanitize_text_field( $_POST['ewd-otp-custom-field-save-values'] ) ) );
231
232 if ( ! empty( $custom_fields ) ) {
233
234 update_option( 'ewd-otp-custom-fields', $custom_fields );
235 }
236 }
237 }
238 } // endif;
239