1
|
|
|
<?php |
2
|
|
|
if (!defined('EVENT_ESPRESSO_VERSION') ) |
3
|
|
|
exit('NO direct script access allowed'); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Event Espresso |
7
|
|
|
* |
8
|
|
|
* Event Registration and Management Plugin for Wordpress |
9
|
|
|
* |
10
|
|
|
* @package Event Espresso |
11
|
|
|
* @author Seth Shoultes |
12
|
|
|
* @copyright (c)2009-2012 Event Espresso All Rights Reserved. |
13
|
|
|
* @license http://eventespresso.com/support/terms-conditions/ ** see Plugin Licensing ** |
14
|
|
|
* @link http://www.eventespresso.com |
15
|
|
|
* @version 4.0 |
16
|
|
|
* |
17
|
|
|
* ------------------------------------------------------------------------ |
18
|
|
|
* |
19
|
|
|
* General_Settings_Admin_Page |
20
|
|
|
* |
21
|
|
|
* This contains the logic for setting up the Custom General_Settings related pages. Any methods without phpdoc comments have inline docs with parent class. |
22
|
|
|
* |
23
|
|
|
* NOTE: TODO: This is a straight conversion from the legacy 3.1 settings page. It is NOT optimized and will need modification to fully use the new system (and also will need adjusted when Questions and Questions groups model is implemented) |
24
|
|
|
* |
25
|
|
|
* @package General_Settings_Admin_Page |
26
|
|
|
* @subpackage includes/core/admin/general_settings/General_Settings_Admin_Page.core.php |
27
|
|
|
* @author Brent Christensen |
28
|
|
|
* |
29
|
|
|
* ------------------------------------------------------------------------ |
30
|
|
|
*/ |
31
|
|
|
class General_Settings_Admin_Page extends EE_Admin_Page { |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* _question_group |
36
|
|
|
* holds the specific question group object for the question group details screen |
37
|
|
|
* @var object |
38
|
|
|
*/ |
39
|
|
|
protected $_question_group; |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function __construct( $routing = TRUE ) { |
44
|
|
|
parent::__construct( $routing ); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
|
49
|
|
|
protected function _init_page_props() { |
50
|
|
|
$this->page_slug = GEN_SET_PG_SLUG; |
51
|
|
|
$this->page_label = GEN_SET_LABEL; |
52
|
|
|
$this->_admin_base_url = GEN_SET_ADMIN_URL; |
53
|
|
|
$this->_admin_base_path = GEN_SET_ADMIN; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
|
58
|
|
|
|
59
|
|
|
protected function _ajax_hooks() { |
60
|
|
|
add_action('wp_ajax_espresso_display_country_settings', array( $this, 'display_country_settings')); |
61
|
|
|
add_action('wp_ajax_espresso_display_country_states', array( $this, 'display_country_states')); |
62
|
|
|
add_action('wp_ajax_espresso_delete_state', array( $this, 'delete_state'), 10, 3 ); |
63
|
|
|
add_action('wp_ajax_espresso_add_new_state', array( $this, 'add_new_state')); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
|
68
|
|
|
|
69
|
|
|
|
70
|
|
|
protected function _define_page_props() { |
71
|
|
|
$this->_admin_page_title = GEN_SET_LABEL; |
72
|
|
|
$this->_labels = array( |
73
|
|
|
'publishbox' => __('Update Settings', 'event_espresso') |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
|
79
|
|
|
|
80
|
|
|
protected function _set_page_routes() { |
81
|
|
|
$this->_page_routes = array( |
82
|
|
|
|
83
|
|
|
'critical_pages' => array( |
84
|
|
|
'func' => '_espresso_page_settings', |
85
|
|
|
'capability' => 'manage_options' |
86
|
|
|
), |
87
|
|
|
'update_espresso_page_settings' => array( |
88
|
|
|
'func' => '_update_espresso_page_settings', |
89
|
|
|
'capability' => 'manage_options', |
90
|
|
|
'noheader' => TRUE, |
91
|
|
|
), |
92
|
|
|
'default' => array( |
93
|
|
|
'func' => '_your_organization_settings', |
94
|
|
|
'capability' => 'manage_options', |
95
|
|
|
), |
96
|
|
|
|
97
|
|
|
'update_your_organization_settings' => array( |
98
|
|
|
'func' => '_update_your_organization_settings', |
99
|
|
|
'capability' => 'manage_options', |
100
|
|
|
'noheader' => TRUE, |
101
|
|
|
), |
102
|
|
|
|
103
|
|
|
'admin_option_settings' => array( |
104
|
|
|
'func' => '_admin_option_settings', |
105
|
|
|
'capability' => 'manage_options', |
106
|
|
|
), |
107
|
|
|
|
108
|
|
|
'update_admin_option_settings' => array( |
109
|
|
|
'func' => '_update_admin_option_settings', |
110
|
|
|
'capability' => 'manage_options', |
111
|
|
|
'noheader' => TRUE, |
112
|
|
|
), |
113
|
|
|
|
114
|
|
|
'country_settings' => array( |
115
|
|
|
'func' => '_country_settings', |
116
|
|
|
'capability' => 'manage_options' |
117
|
|
|
), |
118
|
|
|
|
119
|
|
|
'update_country_settings' => array( |
120
|
|
|
'func' => '_update_country_settings', |
121
|
|
|
'capability' => 'manage_options', |
122
|
|
|
'noheader' => TRUE, |
123
|
|
|
), |
124
|
|
|
|
125
|
|
|
'display_country_settings' => array( |
126
|
|
|
'func' => 'display_country_settings', |
127
|
|
|
'capability' => 'manage_options', |
128
|
|
|
'noheader' => TRUE, |
129
|
|
|
), |
130
|
|
|
|
131
|
|
|
'add_new_state' => array( |
132
|
|
|
'func' => 'add_new_state', |
133
|
|
|
'capability' => 'manage_options', |
134
|
|
|
'noheader' => TRUE, |
135
|
|
|
), |
136
|
|
|
|
137
|
|
|
'delete_state' => array( |
138
|
|
|
'func' => 'delete_state', |
139
|
|
|
'capability' => 'manage_options', |
140
|
|
|
'noheader' => TRUE, |
141
|
|
|
) |
142
|
|
|
); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
|
146
|
|
|
|
147
|
|
|
|
148
|
|
|
|
149
|
|
|
protected function _set_page_config() { |
150
|
|
|
$this->_page_config = array( |
151
|
|
|
'critical_pages' => array( |
152
|
|
|
'nav' => array( |
153
|
|
|
'label' => __('Critical Pages', 'event_espresso'), |
154
|
|
|
'order' => 50 |
155
|
|
|
), |
156
|
|
|
'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
157
|
|
|
'help_tabs' => array( |
158
|
|
|
'general_settings_critical_pages_help_tab' => array( |
159
|
|
|
'title' => __('Critical Pages', 'event_espresso'), |
160
|
|
|
'filename' => 'general_settings_critical_pages' |
161
|
|
|
) |
162
|
|
|
), |
163
|
|
|
'help_tour' => array( 'Critical_Pages_Help_Tour' ), |
164
|
|
|
'require_nonce' => FALSE |
165
|
|
|
), |
166
|
|
|
'default' => array( |
167
|
|
|
'nav' => array( |
168
|
|
|
'label' => __('Your Organization', 'event_espresso'), |
169
|
|
|
'order' => 20 |
170
|
|
|
), |
171
|
|
|
'help_tabs' => array( |
172
|
|
|
'general_settings_your_organization_help_tab' => array( |
173
|
|
|
'title' => __('Your Organization', 'event_espresso'), |
174
|
|
|
'filename' => 'general_settings_your_organization' |
175
|
|
|
) |
176
|
|
|
), |
177
|
|
|
'help_tour' => array( 'Your_Organization_Help_Tour' ), |
178
|
|
|
'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
179
|
|
|
'require_nonce' => FALSE |
180
|
|
|
), |
181
|
|
|
'admin_option_settings' => array( |
182
|
|
|
'nav' => array( |
183
|
|
|
'label' => __('Admin Options', 'event_espresso'), |
184
|
|
|
'order' => 60 |
185
|
|
|
), |
186
|
|
|
'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
187
|
|
|
'help_tabs' => array( |
188
|
|
|
'general_settings_admin_options_help_tab' => array( |
189
|
|
|
'title' => __('Admin Options', 'event_espresso'), |
190
|
|
|
'filename' => 'general_settings_admin_options' |
191
|
|
|
) |
192
|
|
|
), |
193
|
|
|
'help_tour' => array( 'Admin_Options_Help_Tour' ), |
194
|
|
|
'require_nonce' => FALSE |
195
|
|
|
), |
196
|
|
|
'country_settings' => array( |
197
|
|
|
'nav' => array( |
198
|
|
|
'label' => __('Countries', 'event_espresso'), |
199
|
|
|
'order' => 70 |
200
|
|
|
), |
201
|
|
|
'help_tabs' => array( |
202
|
|
|
'general_settings_countries_help_tab' => array( |
203
|
|
|
'title' => __('Countries', 'event_espresso'), |
204
|
|
|
'filename' => 'general_settings_countries' |
205
|
|
|
) |
206
|
|
|
), |
207
|
|
|
'help_tour' => array( 'Countries_Help_Tour' ), |
208
|
|
|
'require_nonce' => FALSE |
209
|
|
|
) |
210
|
|
|
); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
|
214
|
|
|
protected function _add_screen_options() {} |
215
|
|
|
|
216
|
|
|
protected function _add_feature_pointers() {} |
217
|
|
|
public function load_scripts_styles() { |
218
|
|
|
//styles |
219
|
|
|
wp_enqueue_style('espresso-ui-theme'); |
220
|
|
|
//scripts |
221
|
|
|
wp_enqueue_script('ee_admin_js'); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
public function admin_init() { |
225
|
|
|
EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = __( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' ); |
226
|
|
|
EE_Registry::$i18n_js_strings[ 'error_occurred' ] = __( 'An error occurred! Please refresh the page and try again.', 'event_espresso' ); |
227
|
|
|
EE_Registry::$i18n_js_strings[ 'confirm_delete_state' ] = __( 'Are you sure you want to delete this State / Province?', 'event_espresso' ); |
228
|
|
|
$protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
229
|
|
|
EE_Registry::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php?page=espresso_general_settings', $protocol ); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
public function admin_notices() {} |
233
|
|
|
public function admin_footer_scripts() {} |
234
|
|
|
|
235
|
|
|
|
236
|
|
|
public function load_scripts_styles_default() { |
237
|
|
|
//styles |
238
|
|
|
wp_enqueue_style('thickbox'); |
239
|
|
|
//scripts |
240
|
|
|
wp_enqueue_script('media-upload'); |
241
|
|
|
wp_enqueue_script('thickbox'); |
242
|
|
|
wp_register_script( 'organization_settings', GEN_SET_ASSETS_URL . 'your_organization_settings.js', array( 'jquery','media-upload','thickbox' ), EVENT_ESPRESSO_VERSION, TRUE ); |
243
|
|
|
wp_register_style( 'organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION ); |
244
|
|
|
wp_enqueue_script( 'organization_settings' ); |
245
|
|
|
wp_enqueue_style( 'organization-css' ); |
246
|
|
|
$confirm_image_delete = array( 'text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.', 'event_espresso')); |
247
|
|
|
wp_localize_script( 'organization_settings', 'confirm_image_delete', $confirm_image_delete ); |
248
|
|
|
|
249
|
|
|
} |
250
|
|
|
|
251
|
|
View Code Duplication |
public function load_scripts_styles_country_settings() { |
|
|
|
|
252
|
|
|
//scripts |
253
|
|
|
wp_register_script( 'gen_settings_countries', GEN_SET_ASSETS_URL . 'gen_settings_countries.js', array( 'ee_admin_js' ), EVENT_ESPRESSO_VERSION, TRUE ); |
254
|
|
|
wp_register_style( 'organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION ); |
255
|
|
|
wp_enqueue_script( 'gen_settings_countries' ); |
256
|
|
|
wp_enqueue_style( 'organization-css' ); |
257
|
|
|
|
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
|
261
|
|
|
/************* Espresso Pages *************/ |
262
|
|
|
|
263
|
|
|
|
264
|
|
|
protected function _espresso_page_settings() { |
265
|
|
|
|
266
|
|
|
// Check to make sure all of the main pages are setup properly, |
267
|
|
|
// if not create the default pages and display an admin notice |
268
|
|
|
EEH_Activation::verify_default_pages_exist(); |
269
|
|
|
|
270
|
|
|
$this->_transient_garbage_collection(); |
271
|
|
|
$this->_template_args['values'] = $this->_yes_no_values; |
272
|
|
|
|
273
|
|
|
$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id ) ?EE_Registry::instance()->CFG->core->reg_page_id : NULL; |
274
|
|
|
$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id ) ? get_page(EE_Registry::instance()->CFG->core->reg_page_id ) : FALSE; |
275
|
|
|
|
276
|
|
|
$this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) ?EE_Registry::instance()->CFG->core->txn_page_id : NULL; |
277
|
|
|
$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id ) ? get_page(EE_Registry::instance()->CFG->core->txn_page_id ) : FALSE; |
278
|
|
|
|
279
|
|
|
$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id ) ?EE_Registry::instance()->CFG->core->thank_you_page_id : NULL; |
280
|
|
|
$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id ) ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id ) : FALSE; |
281
|
|
|
|
282
|
|
|
$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id ) ?EE_Registry::instance()->CFG->core->cancel_page_id : NULL; |
283
|
|
|
$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id ) ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id ) : FALSE; |
284
|
|
|
|
285
|
|
|
$this->_set_add_edit_form_tags( 'update_espresso_page_settings' ); |
286
|
|
|
$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
287
|
|
|
$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', $this->_template_args, TRUE ); |
288
|
|
|
$this->display_admin_page_with_sidebar(); |
289
|
|
|
|
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
protected function _update_espresso_page_settings() { |
293
|
|
|
// capture incoming request data |
294
|
|
|
$reg_page_id = isset( $this->_req_data['reg_page_id'] ) ? absint( $this->_req_data['reg_page_id'] ) : EE_Registry::instance()->CFG->core->reg_page_id; |
295
|
|
|
$txn_page_id = isset( $this->_req_data['txn_page_id'] ) ? absint( $this->_req_data['txn_page_id'] ) : EE_Registry::instance()->CFG->core->txn_page_id; |
296
|
|
|
$thank_you_page_id = isset( $this->_req_data['thank_you_page_id'] ) ? absint( $this->_req_data['thank_you_page_id'] ) : EE_Registry::instance()->CFG->core->thank_you_page_id; |
297
|
|
|
$cancel_page_id = isset( $this->_req_data['cancel_page_id'] ) ? absint( $this->_req_data['cancel_page_id'] ) : EE_Registry::instance()->CFG->core->cancel_page_id; |
298
|
|
|
// pack critical_pages into an array |
299
|
|
|
$critical_pages = array( |
300
|
|
|
'reg_page_id' => $reg_page_id, |
301
|
|
|
'txn_page_id' => $txn_page_id, |
302
|
|
|
'thank_you_page_id' => $thank_you_page_id, |
303
|
|
|
'cancel_page_id' => $cancel_page_id |
304
|
|
|
); |
305
|
|
|
foreach ( $critical_pages as $critical_page_name => $critical_page_id ) { |
306
|
|
|
// has the page changed ? |
307
|
|
|
if ( EE_Registry::instance()->CFG->core->{$critical_page_name} !== $critical_page_id ) { |
308
|
|
|
// grab post object for old page |
309
|
|
|
$post = get_post( EE_Registry::instance()->CFG->core->{$critical_page_name} ); |
310
|
|
|
// update post shortcodes for old page |
311
|
|
|
EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save( $critical_page_id, $post ); |
312
|
|
|
// grab post object for new page |
313
|
|
|
$post = get_post( $critical_page_id ); |
314
|
|
|
// update post shortcodes for new page |
315
|
|
|
EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save( $critical_page_id, $post ); |
316
|
|
|
} |
317
|
|
|
} |
318
|
|
|
// set page IDs |
319
|
|
|
EE_Registry::instance()->CFG->core->reg_page_id = $reg_page_id; |
320
|
|
|
EE_Registry::instance()->CFG->core->txn_page_id = $txn_page_id; |
321
|
|
|
EE_Registry::instance()->CFG->core->thank_you_page_id = $thank_you_page_id; |
322
|
|
|
EE_Registry::instance()->CFG->core->cancel_page_id = $cancel_page_id; |
323
|
|
|
|
324
|
|
|
EE_Registry::instance()->CFG->core = apply_filters( 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', EE_Registry::instance()->CFG->core, $this->_req_data ); |
325
|
|
|
|
326
|
|
|
$what = __('Critical Pages & Shortcodes', 'event_espresso'); |
327
|
|
|
$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->core, __FILE__, __FUNCTION__, __LINE__ ); |
|
|
|
|
328
|
|
|
$query_args = array( |
329
|
|
|
'action' => 'critical_pages' |
330
|
|
|
); |
331
|
|
|
$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
|
|
|
332
|
|
|
|
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
|
336
|
|
|
|
337
|
|
|
|
338
|
|
|
|
339
|
|
|
|
340
|
|
|
|
341
|
|
|
/************* Your Organization *************/ |
342
|
|
|
|
343
|
|
|
|
344
|
|
|
protected function _your_organization_settings() { |
345
|
|
|
|
346
|
|
|
$this->_template_args['site_license_key'] = isset( EE_Registry::instance()->NET_CFG->core->site_license_key ) ? EE_Registry::instance()->NET_CFG->core->get_pretty( 'site_license_key' ) : ''; |
347
|
|
|
$this->_template_args['organization_name'] = isset( EE_Registry::instance()->CFG->organization->name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : ''; |
348
|
|
|
$this->_template_args['organization_address_1'] = isset( EE_Registry::instance()->CFG->organization->address_1 ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'address_1' ) : ''; |
349
|
|
|
$this->_template_args['organization_address_2'] = isset( EE_Registry::instance()->CFG->organization->address_2 ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'address_2' ) : ''; |
350
|
|
|
$this->_template_args['organization_city'] = isset( EE_Registry::instance()->CFG->organization->city ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'city' ) : ''; |
351
|
|
|
$this->_template_args['organization_zip'] = isset( EE_Registry::instance()->CFG->organization->zip ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'zip' ) : ''; |
352
|
|
|
$this->_template_args['organization_email'] = isset( EE_Registry::instance()->CFG->organization->email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : ''; |
353
|
|
|
$this->_template_args['organization_phone'] = isset( EE_Registry::instance()->CFG->organization->phone ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'phone' ) : ''; |
354
|
|
|
$this->_template_args['organization_vat'] = isset( EE_Registry::instance()->CFG->organization->vat ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'vat' ) : ''; |
355
|
|
|
$this->_template_args['currency_sign'] = isset( EE_Registry::instance()->CFG->currency->sign ) ? EE_Registry::instance()->CFG->currency->get_pretty( 'sign' ) : '$'; |
356
|
|
|
$this->_template_args['organization_logo_url'] = isset( EE_Registry::instance()->CFG->organization->logo_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ) : FALSE; |
357
|
|
|
$this->_template_args['organization_facebook'] = isset( EE_Registry::instance()->CFG->organization->facebook ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ) : ''; |
358
|
|
|
$this->_template_args['organization_twitter'] = isset( EE_Registry::instance()->CFG->organization->twitter ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ) : ''; |
359
|
|
|
$this->_template_args['organization_linkedin'] = isset( EE_Registry::instance()->CFG->organization->linkedin ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ) : ''; |
360
|
|
|
$this->_template_args['organization_pinterest'] = isset( EE_Registry::instance()->CFG->organization->pinterest ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ) : ''; |
361
|
|
|
$this->_template_args['organization_google'] = isset( EE_Registry::instance()->CFG->organization->google ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'google' ) : ''; |
362
|
|
|
$this->_template_args['organization_instagram'] = isset( EE_Registry::instance()->CFG->organization->instagram ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ) : ''; |
363
|
|
|
//UXIP settings |
364
|
|
|
$this->_template_args['ee_ueip_optin'] = isset( EE_Registry::instance()->CFG->core->ee_ueip_optin ) ? EE_Registry::instance()->CFG->core->get_pretty( 'ee_ueip_optin' ) : TRUE; |
365
|
|
|
|
366
|
|
|
$STA_ID = isset( EE_Registry::instance()->CFG->organization->STA_ID ) ? EE_Registry::instance()->CFG->organization->STA_ID : 4; |
367
|
|
|
$this->_template_args['states'] = new EE_Question_Form_Input( |
368
|
|
|
EE_Question::new_instance ( array( |
369
|
|
|
'QST_ID'=> 0, |
370
|
|
|
'QST_display_text'=> __('State/Province', 'event_espresso'), |
371
|
|
|
'QST_system'=>'admin-state' |
372
|
|
|
)), |
373
|
|
|
EE_Answer::new_instance ( array( |
374
|
|
|
'ANS_ID' => 0, |
375
|
|
|
'ANS_value' => $STA_ID |
376
|
|
|
)), |
377
|
|
|
array( |
378
|
|
|
'input_id' => 'organization_state', |
379
|
|
|
'input_name' => 'organization_state', |
380
|
|
|
'input_prefix' => '', |
381
|
|
|
'append_qstn_id' => FALSE |
382
|
|
|
) |
383
|
|
|
); |
384
|
|
|
|
385
|
|
|
$CNT_ISO = isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US'; |
386
|
|
|
$this->_template_args['countries'] = new EE_Question_Form_Input( |
387
|
|
|
EE_Question::new_instance ( array( |
388
|
|
|
'QST_ID'=> 0, |
389
|
|
|
'QST_display_text'=> __('Country', 'event_espresso'), |
390
|
|
|
'QST_system'=>'admin-country' |
391
|
|
|
)), |
392
|
|
|
EE_Answer::new_instance ( array( |
393
|
|
|
'ANS_ID' => 0, |
394
|
|
|
'ANS_value' => $CNT_ISO |
395
|
|
|
)), |
396
|
|
|
array( |
397
|
|
|
'input_id' => 'organization_country', |
398
|
|
|
'input_name' => 'organization_country', |
399
|
|
|
'input_prefix' => '', |
400
|
|
|
'append_qstn_id' => FALSE |
401
|
|
|
) |
402
|
|
|
); |
403
|
|
|
|
404
|
|
|
add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 ); |
405
|
|
|
add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 ); |
406
|
|
|
|
407
|
|
|
//PUE verification stuff |
408
|
|
|
$ver_option_key = 'puvererr_' . basename( EE_PLUGIN_BASENAME ); |
409
|
|
|
$verify_fail = get_option( $ver_option_key ); |
410
|
|
|
$this->_template_args['site_license_key_verified'] = $verify_fail || !empty( $verify_fail ) || ( empty( $this->_template_args['site_license_key'] ) && empty( $verify_fail ) )? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>'; |
411
|
|
|
|
412
|
|
|
$this->_set_add_edit_form_tags( 'update_your_organization_settings' ); |
413
|
|
|
$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
414
|
|
|
$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', $this->_template_args, TRUE ); |
415
|
|
|
|
416
|
|
|
$this->display_admin_page_with_sidebar(); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
protected function _update_your_organization_settings() { |
420
|
|
|
if ( is_main_site() ) |
421
|
|
|
EE_Registry::instance()->NET_CFG->core->site_license_key = isset( $this->_req_data['site_license_key'] ) ? sanitize_text_field( $this->_req_data['site_license_key'] ) : EE_Registry::instance()->NET_CFG->core->site_license_key; |
422
|
|
|
EE_Registry::instance()->CFG->organization->name = isset( $this->_req_data['organization_name'] ) ? sanitize_text_field( $this->_req_data['organization_name'] ) : EE_Registry::instance()->CFG->organization->name; |
423
|
|
|
EE_Registry::instance()->CFG->organization->address_1 = isset( $this->_req_data['organization_address_1'] ) ? sanitize_text_field( $this->_req_data['organization_address_1'] ) : EE_Registry::instance()->CFG->organization->address_1; |
424
|
|
|
EE_Registry::instance()->CFG->organization->address_2 = isset( $this->_req_data['organization_address_2'] ) ? sanitize_text_field( $this->_req_data['organization_address_2'] ) : EE_Registry::instance()->CFG->organization->address_2; |
425
|
|
|
EE_Registry::instance()->CFG->organization->city = isset( $this->_req_data['organization_city'] ) ? sanitize_text_field( $this->_req_data['organization_city'] ) : EE_Registry::instance()->CFG->organization->city; |
426
|
|
|
EE_Registry::instance()->CFG->organization->STA_ID = isset( $this->_req_data['organization_state'] ) ? absint( $this->_req_data['organization_state'] ) : EE_Registry::instance()->CFG->organization->STA_ID; |
427
|
|
|
EE_Registry::instance()->CFG->organization->CNT_ISO = isset( $this->_req_data['organization_country'] ) ? sanitize_text_field( $this->_req_data['organization_country'] ) : EE_Registry::instance()->CFG->organization->CNT_ISO; |
428
|
|
|
EE_Registry::instance()->CFG->organization->zip = isset( $this->_req_data['organization_zip'] ) ? sanitize_text_field( $this->_req_data['organization_zip'] ) : EE_Registry::instance()->CFG->organization->zip; |
429
|
|
|
EE_Registry::instance()->CFG->organization->email = isset( $this->_req_data['organization_email'] ) ? sanitize_email( $this->_req_data['organization_email'] ) : EE_Registry::instance()->CFG->organization->email; |
430
|
|
|
EE_Registry::instance()->CFG->organization->vat = isset( $this->_req_data['organization_vat'] ) ? sanitize_text_field( $this->_req_data['organization_vat'] ) : EE_Registry::instance()->CFG->organization->vat; |
431
|
|
|
EE_Registry::instance()->CFG->organization->phone = isset( $this->_req_data['organization_phone'] ) ? sanitize_text_field( $this->_req_data['organization_phone'] ) : EE_Registry::instance()->CFG->organization->phone; |
432
|
|
|
EE_Registry::instance()->CFG->organization->logo_url = isset( $this->_req_data['organization_logo_url'] ) ? esc_url_raw( $this->_req_data['organization_logo_url'] ) : EE_Registry::instance()->CFG->organization->logo_url; |
433
|
|
|
EE_Registry::instance()->CFG->organization->facebook = isset( $this->_req_data['organization_facebook'] ) ? esc_url_raw( $this->_req_data['organization_facebook'] ) : EE_Registry::instance()->CFG->organization->facebook; |
434
|
|
|
EE_Registry::instance()->CFG->organization->twitter = isset( $this->_req_data['organization_twitter'] ) ? esc_url_raw( $this->_req_data['organization_twitter'] ) : EE_Registry::instance()->CFG->organization->twitter; |
435
|
|
|
EE_Registry::instance()->CFG->organization->linkedin = isset( $this->_req_data['organization_linkedin'] ) ? esc_url_raw( $this->_req_data['organization_linkedin'] ) : EE_Registry::instance()->CFG->organization->linkedin; |
436
|
|
|
EE_Registry::instance()->CFG->organization->pinterest = isset( $this->_req_data['organization_pinterest'] ) ? esc_url_raw( $this->_req_data['organization_pinterest'] ) : EE_Registry::instance()->CFG->organization->pinterest; |
437
|
|
|
EE_Registry::instance()->CFG->organization->google = isset( $this->_req_data['organization_google'] ) ? esc_url_raw( $this->_req_data['organization_google'] ) : EE_Registry::instance()->CFG->organization->google; |
438
|
|
|
EE_Registry::instance()->CFG->organization->instagram = isset( $this->_req_data['organization_instagram'] ) ? esc_url_raw( $this->_req_data['organization_instagram'] ) : EE_Registry::instance()->CFG->organization->instagram; |
439
|
|
|
EE_Registry::instance()->CFG->core->ee_ueip_optin = isset( $this->_req_data['ueip_optin'] ) && !empty( $this->_req_data['ueip_optin'] ) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin; |
440
|
|
|
|
441
|
|
|
EE_Registry::instance()->CFG->currency = new EE_Currency_Config( EE_Registry::instance()->CFG->organization->CNT_ISO ); |
442
|
|
|
|
443
|
|
|
EE_Registry::instance()->CFG = apply_filters( 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', EE_Registry::instance()->CFG ); |
444
|
|
|
|
445
|
|
|
$what = 'Your Organization Settings'; |
446
|
|
|
$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ ); |
447
|
|
|
|
448
|
|
|
$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'default' ) ); |
|
|
|
|
449
|
|
|
|
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
|
453
|
|
|
/************* Admin Options *************/ |
454
|
|
|
|
455
|
|
|
|
456
|
|
|
protected function _admin_option_settings() { |
457
|
|
|
|
458
|
|
|
$this->_template_args['values'] = $this->_yes_no_values; |
459
|
|
|
$this->_template_args['use_personnel_manager'] = isset( EE_Registry::instance()->CFG->admin->use_personnel_manager ) ? absint( EE_Registry::instance()->CFG->admin->use_personnel_manager ) : FALSE; |
460
|
|
|
$this->_template_args['use_dashboard_widget'] = isset( EE_Registry::instance()->CFG->admin->use_dashboard_widget ) ? absint( EE_Registry::instance()->CFG->admin->use_dashboard_widget ) : TRUE; |
461
|
|
|
$this->_template_args['events_in_dashboard'] = isset( EE_Registry::instance()->CFG->admin->events_in_dashboard ) ? absint( EE_Registry::instance()->CFG->admin->events_in_dashboard ) : 30; |
462
|
|
|
$this->_template_args['use_event_timezones'] = isset( EE_Registry::instance()->CFG->admin->use_event_timezones ) ? absint( EE_Registry::instance()->CFG->admin->use_event_timezones ) : FALSE; |
463
|
|
|
$this->_template_args['show_reg_footer'] = isset( EE_Registry::instance()->CFG->admin->show_reg_footer ) ? absint( EE_Registry::instance()->CFG->admin->show_reg_footer ) : TRUE; |
464
|
|
|
$this->_template_args['affiliate_id'] = isset( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->get_pretty('affiliate_id') : ''; |
465
|
|
|
$this->_template_args['help_tour_activation'] = isset( EE_Registry::instance()->CFG->admin->help_tour_activation ) ? absint( EE_Registry::instance()->CFG->admin->help_tour_activation ): 1; |
466
|
|
|
|
467
|
|
|
$this->_set_add_edit_form_tags( 'update_admin_option_settings' ); |
468
|
|
|
$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
469
|
|
|
$this->_template_args['template_args'] = $this->_template_args; |
470
|
|
|
$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'admin_option_settings.template.php', $this->_template_args, TRUE ); |
471
|
|
|
$this->display_admin_page_with_sidebar(); |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
protected function _update_admin_option_settings() { |
475
|
|
|
EE_Registry::instance()->CFG->admin->use_personnel_manager = isset( $this->_req_data['use_personnel_manager'] ) ? absint( $this->_req_data['use_personnel_manager'] ) : EE_Registry::instance()->CFG->admin->use_personnel_manager; |
476
|
|
|
EE_Registry::instance()->CFG->admin->use_dashboard_widget = isset( $this->_req_data['use_dashboard_widget'] ) ? absint( $this->_req_data['use_dashboard_widget'] ) : EE_Registry::instance()->CFG->admin->use_dashboard_widget; |
477
|
|
|
EE_Registry::instance()->CFG->admin->events_in_dashboard = isset( $this->_req_data['events_in_dashboard'] ) ? absint( $this->_req_data['events_in_dashboard'] ) : EE_Registry::instance()->CFG->admin->events_in_dashboard; |
478
|
|
|
EE_Registry::instance()->CFG->admin->use_event_timezones = isset( $this->_req_data['use_event_timezones'] ) ? absint( $this->_req_data['use_event_timezones'] ) : EE_Registry::instance()->CFG->admin->use_event_timezones; |
479
|
|
|
EE_Registry::instance()->CFG->admin->show_reg_footer = isset( $this->_req_data['show_reg_footer'] ) ? absint( $this->_req_data['show_reg_footer'] ) : EE_Registry::instance()->CFG->admin->show_reg_footer; |
480
|
|
|
EE_Registry::instance()->CFG->admin->affiliate_id = isset( $this->_req_data['affiliate_id'] ) ? sanitize_text_field( $this->_req_data['affiliate_id'] ) : EE_Registry::instance()->CFG->admin->affiliate_id; |
481
|
|
|
EE_Registry::instance()->CFG->admin->help_tour_activation = isset( $this->_req_data['help_tour_activation'] ) ? absint( $this->_req_data['help_tour_activation'] ) : EE_Registry::instance()->CFG->admin->help_tour_activation; |
482
|
|
|
|
483
|
|
|
EE_Registry::instance()->CFG->admin = apply_filters( 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', EE_Registry::instance()->CFG->admin ); |
484
|
|
|
|
485
|
|
|
$what = 'Admin Options'; |
486
|
|
|
$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->admin, __FILE__, __FUNCTION__, __LINE__ ); |
487
|
|
|
$success = apply_filters( 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', $success ); |
488
|
|
|
$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'admin_option_settings' ) ); |
489
|
|
|
|
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
|
493
|
|
|
|
494
|
|
|
|
495
|
|
|
|
496
|
|
|
/************* Countries *************/ |
497
|
|
|
|
498
|
|
|
|
499
|
|
|
protected function _country_settings() { |
500
|
|
|
|
501
|
|
|
$CNT_ISO = isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US'; |
502
|
|
|
$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : $CNT_ISO; |
503
|
|
|
|
504
|
|
|
//load field generator helper |
505
|
|
|
|
506
|
|
|
$this->_template_args['values'] = $this->_yes_no_values; |
507
|
|
|
|
508
|
|
|
$this->_template_args['countries'] = new EE_Question_Form_Input( |
509
|
|
|
EE_Question::new_instance ( array( |
510
|
|
|
'QST_ID'=> 0, |
511
|
|
|
'QST_display_text'=> __('Select Country', 'event_espresso'), |
512
|
|
|
'QST_system'=>'admin-country' |
513
|
|
|
)), |
514
|
|
|
EE_Answer::new_instance ( array( |
515
|
|
|
'ANS_ID' => 0, |
516
|
|
|
'ANS_value' => $CNT_ISO |
517
|
|
|
)), |
518
|
|
|
array( |
519
|
|
|
'input_id' => 'country', |
520
|
|
|
'input_name' => 'country', |
521
|
|
|
'input_prefix' => '', |
522
|
|
|
'append_qstn_id' => FALSE |
523
|
|
|
) |
524
|
|
|
); |
525
|
|
|
// EEH_Debug_Tools::printr( $this->_template_args['countries'], 'countries <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
526
|
|
|
|
527
|
|
|
add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 ); |
528
|
|
|
add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 ); |
529
|
|
|
$this->_template_args['country_details_settings'] = $this->display_country_settings(); |
530
|
|
|
$this->_template_args['country_states_settings'] = $this->display_country_states(); |
531
|
|
|
|
532
|
|
|
$this->_set_add_edit_form_tags( 'update_country_settings' ); |
533
|
|
|
$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
534
|
|
|
$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', $this->_template_args, TRUE ); |
535
|
|
|
$this->display_admin_page_with_no_sidebar(); |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
|
539
|
|
|
|
540
|
|
|
/** |
541
|
|
|
* display_country_settings |
542
|
|
|
* |
543
|
|
|
* @access public |
544
|
|
|
* @param string $CNT_ISO |
545
|
|
|
* @return mixed string | array |
546
|
|
|
*/ |
547
|
|
|
public function display_country_settings( $CNT_ISO = '' ) { |
548
|
|
|
|
549
|
|
|
$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : $CNT_ISO; |
550
|
|
|
if ( ! $CNT_ISO ) { |
551
|
|
|
return ''; |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
// for ajax |
555
|
|
|
remove_all_filters( 'FHEE__EEH_Form_Fields__label_html' ); |
556
|
|
|
remove_all_filters( 'FHEE__EEH_Form_Fields__input_html' ); |
557
|
|
|
add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 ); |
558
|
|
|
add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 ); |
559
|
|
|
$country = EEM_Country::instance()->get_one_by_ID( $CNT_ISO ); |
560
|
|
|
//EEH_Debug_Tools::printr( $country, '$country <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
561
|
|
|
$country_input_types = array( |
562
|
|
|
'CNT_active' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE ), |
563
|
|
|
'CNT_ISO' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ), |
564
|
|
|
'CNT_ISO3' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ), |
565
|
|
|
'RGN_ID' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ), |
566
|
|
|
'CNT_name' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'regular-text' ), |
567
|
|
|
'CNT_cur_code' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ), |
568
|
|
|
'CNT_cur_single' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'medium-text' ), |
569
|
|
|
'CNT_cur_plural' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'medium-text' ), |
570
|
|
|
'CNT_cur_sign' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text', 'htmlentities' => FALSE ), |
571
|
|
|
'CNT_cur_sign_b4' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE ), |
572
|
|
|
'CNT_cur_dec_plc' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => 0, 'text' => '' ), array( 'id' => 1, 'text' => '' ), array( 'id' => 2, 'text' => '' ), array( 'id' => 3, 'text' => '' ))), |
573
|
|
|
'CNT_cur_dec_mrk' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => ',', 'text' => __(', (comma)', 'event_espresso')), array( 'id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE ), |
574
|
|
|
'CNT_cur_thsnds' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => ',', 'text' => __(', (comma)', 'event_espresso')), array( 'id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE ), |
575
|
|
|
'CNT_tel_code' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ), |
576
|
|
|
'CNT_is_EU' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE ) |
577
|
|
|
); |
578
|
|
|
$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( $country, $country_input_types ); |
|
|
|
|
579
|
|
|
$country_details_settings = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', $this->_template_args, TRUE ); |
580
|
|
|
|
581
|
|
View Code Duplication |
if ( defined( 'DOING_AJAX' )) { |
582
|
|
|
$notices = EE_Error::get_notices( FALSE, FALSE, FALSE ); |
583
|
|
|
echo json_encode( array( 'return_data' => $country_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors'] )); |
584
|
|
|
die(); |
585
|
|
|
} else { |
586
|
|
|
return $country_details_settings; |
587
|
|
|
} |
588
|
|
|
|
589
|
|
|
} |
590
|
|
|
|
591
|
|
|
|
592
|
|
|
|
593
|
|
|
|
594
|
|
|
/** |
595
|
|
|
* display_country_states |
596
|
|
|
* |
597
|
|
|
* @access public |
598
|
|
|
* @param string $CNT_ISO |
599
|
|
|
* @return string |
600
|
|
|
*/ |
601
|
|
|
public function display_country_states( $CNT_ISO = '' ) { |
602
|
|
|
|
603
|
|
|
$CNT_ISO = isset( $this->_req_data['country'] ) ? sanitize_text_field( $this->_req_data['country'] ) : $CNT_ISO; |
604
|
|
|
|
605
|
|
|
if ( ! $CNT_ISO ) { |
606
|
|
|
return ''; |
607
|
|
|
} |
608
|
|
|
// for ajax |
609
|
|
|
remove_all_filters( 'FHEE__EEH_Form_Fields__label_html' ); |
610
|
|
|
remove_all_filters( 'FHEE__EEH_Form_Fields__input_html' ); |
611
|
|
|
add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'state_form_field_label_wrap' ), 10, 2 ); |
612
|
|
|
add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'state_form_field_input__wrap' ), 10, 2 ); |
613
|
|
|
$states = EEM_State::instance()->get_all_states_for_these_countries( array( $CNT_ISO => $CNT_ISO )); |
614
|
|
|
|
615
|
|
|
// echo '<h4>$CNT_ISO : ' . $CNT_ISO . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
616
|
|
|
// global $wpdb; |
617
|
|
|
// echo '<h4>' . $wpdb->last_query . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
618
|
|
|
// EEH_Debug_Tools::printr( $states, '$states <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
619
|
|
|
if ( $states ) { |
620
|
|
|
foreach ( $states as $STA_ID => $state ) { |
621
|
|
|
if ( $state instanceof EE_State ) { |
622
|
|
|
//STA_abbrev STA_name STA_active |
623
|
|
|
$state_input_types = array( |
624
|
|
|
'STA_abbrev' => array( 'type' => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'mid-text' ), |
625
|
|
|
'STA_name' => array( 'type' => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'regular-text' ), |
626
|
|
|
'STA_active' => array( 'type' => 'RADIO_BTN', 'input_name' => 'states[' . $STA_ID . ']', 'options' => $this->_yes_no_values, 'use_desc_4_label' => true ) |
627
|
|
|
); |
628
|
|
|
$this->_template_args[ 'states' ][ $STA_ID ][ 'inputs' ] = EE_Question_Form_Input::generate_question_form_inputs_for_object( $state, $state_input_types ); |
629
|
|
|
$query_args = array( 'action' => 'delete_state', 'STA_ID' => $STA_ID, 'CNT_ISO' => $CNT_ISO, 'STA_abbrev' => $state->abbrev() ); |
630
|
|
|
$this->_template_args[ 'states' ][ $STA_ID ][ 'delete_state_url' ] = EE_Admin_Page::add_query_args_and_nonce( $query_args, GEN_SET_ADMIN_URL ); |
631
|
|
|
} |
632
|
|
|
} |
633
|
|
|
} else { |
634
|
|
|
$this->_template_args['states'] = FALSE; |
635
|
|
|
} |
636
|
|
|
// EEH_Debug_Tools::printr( $this->_template_args['states'], 'states <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
637
|
|
|
$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'add_new_state' ), GEN_SET_ADMIN_URL ); |
638
|
|
|
|
639
|
|
|
$state_details_settings = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', $this->_template_args, TRUE ); |
640
|
|
|
|
641
|
|
View Code Duplication |
if ( defined( 'DOING_AJAX' )) { |
642
|
|
|
$notices = EE_Error::get_notices( FALSE, FALSE, FALSE ); |
643
|
|
|
echo json_encode( array( 'return_data' => $state_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors'] )); |
644
|
|
|
die(); |
645
|
|
|
} else { |
646
|
|
|
return $state_details_settings; |
647
|
|
|
} |
648
|
|
|
|
649
|
|
|
} |
650
|
|
|
|
651
|
|
|
|
652
|
|
|
|
653
|
|
|
|
654
|
|
|
/** |
655
|
|
|
* add_new_state |
656
|
|
|
* |
657
|
|
|
* @access public |
658
|
|
|
* @return void |
659
|
|
|
*/ |
660
|
|
|
public function add_new_state() { |
661
|
|
|
|
662
|
|
|
$success = TRUE; |
663
|
|
|
|
664
|
|
|
$CNT_ISO = isset( $this->_req_data['CNT_ISO'] ) ? strtoupper( sanitize_text_field( $this->_req_data['CNT_ISO'] )) : FALSE; |
665
|
|
|
if ( ! $CNT_ISO ) { |
|
|
|
|
666
|
|
|
EE_Error::add_error( __( 'No Country ISO code or an invalid Country ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
667
|
|
|
$success = FALSE; |
668
|
|
|
} |
669
|
|
|
$STA_abbrev = isset( $this->_req_data['STA_abbrev'] ) ? sanitize_text_field( $this->_req_data['STA_abbrev'] ) : FALSE; |
670
|
|
|
if ( ! $STA_abbrev ) { |
671
|
|
|
EE_Error::add_error( __( 'No State ISO code or an invalid State ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
672
|
|
|
$success = FALSE; |
673
|
|
|
} |
674
|
|
|
$STA_name = isset( $this->_req_data['STA_name'] ) ? sanitize_text_field( $this->_req_data['STA_name'] ) : |
675
|
|
|
FALSE; |
676
|
|
|
if ( ! $STA_name ) { |
677
|
|
|
EE_Error::add_error( __( 'No State name or an invalid State name was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
678
|
|
|
$success = FALSE; |
679
|
|
|
} |
680
|
|
|
|
681
|
|
|
if ( $success ) { |
682
|
|
|
$cols_n_values = array( |
683
|
|
|
'CNT_ISO' => $CNT_ISO, |
684
|
|
|
'STA_abbrev' => $STA_abbrev, |
685
|
|
|
'STA_name' => $STA_name, |
686
|
|
|
'STA_active' => TRUE |
687
|
|
|
); |
688
|
|
|
$success = EEM_State::instance()->insert ( $cols_n_values ); |
689
|
|
|
EE_Error::add_success( __( 'The State was added successfully.', 'event_espresso' ) ); |
690
|
|
|
} |
691
|
|
|
|
692
|
|
View Code Duplication |
if ( defined( 'DOING_AJAX' )) { |
693
|
|
|
$notices = EE_Error::get_notices( FALSE, FALSE, FALSE ); |
694
|
|
|
echo json_encode( array_merge( $notices, array( 'return_data' => $CNT_ISO ) ) ); |
695
|
|
|
die(); |
696
|
|
|
} else { |
697
|
|
|
$this->_redirect_after_action( $success, 'State', 'added', array( 'action' => 'country_settings' ) ); |
|
|
|
|
698
|
|
|
} |
699
|
|
|
} |
700
|
|
|
|
701
|
|
|
|
702
|
|
|
|
703
|
|
|
/** |
704
|
|
|
* delete_state |
705
|
|
|
* |
706
|
|
|
* @access public |
707
|
|
|
* @return boolean | void |
708
|
|
|
*/ |
709
|
|
|
public function delete_state() { |
710
|
|
|
$CNT_ISO = isset( $this->_req_data['CNT_ISO'] ) ? strtoupper( sanitize_text_field( $this->_req_data['CNT_ISO'] )) : FALSE; |
711
|
|
|
$STA_ID = isset( $this->_req_data['STA_ID'] ) ? sanitize_text_field( $this->_req_data['STA_ID'] ) : FALSE; |
712
|
|
|
$STA_abbrev = isset( $this->_req_data['STA_abbrev'] ) ? sanitize_text_field( $this->_req_data['STA_abbrev'] ) : FALSE; |
713
|
|
|
if ( ! $STA_ID ) { |
714
|
|
|
EE_Error::add_error( __( 'No State ID or an invalid State ID was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
715
|
|
|
return FALSE; |
716
|
|
|
} |
717
|
|
|
$success = EEM_State::instance()->delete_by_ID( $STA_ID ); |
718
|
|
|
if ( $success !== FALSE ) { |
719
|
|
|
do_action( 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID, array( 'STA_abbrev' => $STA_abbrev )); |
720
|
|
|
EE_Error::add_success( __( 'The State was deleted successfully.', 'event_espresso' )); |
721
|
|
|
} |
722
|
|
View Code Duplication |
if ( defined( 'DOING_AJAX' )) { |
723
|
|
|
$notices = EE_Error::get_notices( FALSE, FALSE ); |
724
|
|
|
$notices['return_data'] = TRUE; |
725
|
|
|
echo json_encode( $notices ); |
726
|
|
|
die(); |
727
|
|
|
} else { |
728
|
|
|
$this->_redirect_after_action( $success, 'State', 'deleted', array( 'action' => 'country_settings' ) ); |
|
|
|
|
729
|
|
|
} |
730
|
|
|
} |
731
|
|
|
|
732
|
|
|
|
733
|
|
|
|
734
|
|
|
|
735
|
|
|
/** |
736
|
|
|
* _update_country_settings |
737
|
|
|
* |
738
|
|
|
* @access protected |
739
|
|
|
* @return void |
740
|
|
|
*/ |
741
|
|
|
protected function _update_country_settings() { |
742
|
|
|
// EEH_Debug_Tools::printr( $this->_req_data, '$this->_req_data <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
743
|
|
|
// grab the country ISO code |
744
|
|
|
$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : FALSE; |
745
|
|
|
if ( ! $CNT_ISO ) { |
|
|
|
|
746
|
|
|
EE_Error::add_error( __( 'No Country ISO code or an invalid Country ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
747
|
|
|
return; |
748
|
|
|
} |
749
|
|
|
$cols_n_values = array(); |
750
|
|
|
$cols_n_values['CNT_ISO3'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'] ) ? strtoupper( sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'] )) : FALSE; |
751
|
|
|
$cols_n_values['RGN_ID'] = isset( $this->_req_data['cntry'][$CNT_ISO]['RGN_ID'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['RGN_ID'] ) : NULL; |
752
|
|
|
$cols_n_values['CNT_name'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_name'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_name'] ) : NULL; |
753
|
|
|
$cols_n_values['CNT_cur_code'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'] ) ? strtoupper( sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'] )) : 'USD'; |
754
|
|
|
$cols_n_values['CNT_cur_single'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'] ) : 'dollar'; |
755
|
|
|
$cols_n_values['CNT_cur_plural'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'] ) : 'dollars'; |
756
|
|
|
$cols_n_values['CNT_cur_sign'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'] ) : '$'; |
757
|
|
|
$cols_n_values['CNT_cur_sign_b4'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'] ) : TRUE; |
758
|
|
|
$cols_n_values['CNT_cur_dec_plc'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'] ) : 2; |
759
|
|
|
$cols_n_values['CNT_cur_dec_mrk'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'] ) : '.'; |
760
|
|
|
$cols_n_values['CNT_cur_thsnds'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'] ) : ','; |
761
|
|
|
$cols_n_values['CNT_tel_code'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'] ) : NULL; |
762
|
|
|
$cols_n_values['CNT_is_EU'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'] ) : FALSE; |
763
|
|
|
$cols_n_values['CNT_active'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_active'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_active'] ) : FALSE; |
764
|
|
|
// allow filtering of country data |
765
|
|
|
$cols_n_values = apply_filters( 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', $cols_n_values ); |
766
|
|
|
//EEH_Debug_Tools::printr( $cols_n_values, '$cols_n_values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
767
|
|
|
// where values |
768
|
|
|
$where_cols_n_values = array( array( 'CNT_ISO' => $CNT_ISO )); |
769
|
|
|
// run the update |
770
|
|
|
$success = EEM_Country::instance()->update( $cols_n_values, $where_cols_n_values ); |
771
|
|
|
// global $wpdb; |
772
|
|
|
// echo '<h4>' . $wpdb->last_query . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
773
|
|
|
// echo '<h4>$success : ' . $success . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
774
|
|
|
if ( isset( $this->_req_data['states'] ) && is_array( $this->_req_data['states'] ) && $success !== FALSE ) { |
775
|
|
|
// allow filtering of states data |
776
|
|
|
$states = apply_filters( 'FHEE__General_Settings_Admin_Page___update_country_settings__states', $this->_req_data['states'] ); |
777
|
|
|
// EEH_Debug_Tools::printr( $states, '$states <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
778
|
|
|
// loop thru state data ( looks like : states[75][STA_name] ) |
779
|
|
|
foreach( $states as $STA_ID => $state ) { |
780
|
|
|
$cols_n_values = array( |
781
|
|
|
'CNT_ISO' => $CNT_ISO, |
782
|
|
|
'STA_abbrev' => sanitize_text_field( $state['STA_abbrev'] ), |
783
|
|
|
'STA_name' => sanitize_text_field( $state['STA_name'] ), |
784
|
|
|
'STA_active' => (bool)absint( $state['STA_active'] ) |
785
|
|
|
); |
786
|
|
|
// where values |
787
|
|
|
$where_cols_n_values = array( array( 'STA_ID' => $STA_ID )); |
788
|
|
|
// run the update |
789
|
|
|
$success = EEM_State::instance()->update( $cols_n_values, $where_cols_n_values ); |
790
|
|
|
if ( $success !== FALSE ) { |
791
|
|
|
do_action( 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO, $STA_ID, $cols_n_values ); |
792
|
|
|
} |
793
|
|
|
} |
794
|
|
|
} |
795
|
|
|
// check if country being edited matches org option country, and if so, then update EE_Config with new settings |
796
|
|
|
if ( isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO ) { |
797
|
|
|
EE_Registry::instance()->CFG->currency = new EE_Currency_Config( $CNT_ISO ); |
798
|
|
|
EE_Registry::instance()->CFG->update_espresso_config(); |
799
|
|
|
} |
800
|
|
|
$this->_redirect_after_action( $success, 'Countries', 'updated', array( 'action' => 'country_settings', 'country' => $CNT_ISO )); |
801
|
|
|
} |
802
|
|
|
|
803
|
|
|
|
804
|
|
|
|
805
|
|
|
|
806
|
|
|
|
807
|
|
|
/** |
808
|
|
|
* form_form_field_label_wrap |
809
|
|
|
* |
810
|
|
|
* @access public |
811
|
|
|
* @param string $label |
812
|
|
|
* @return string |
813
|
|
|
*/ |
814
|
|
|
public function country_form_field_label_wrap( $label, $required_text ) { |
|
|
|
|
815
|
|
|
return ' |
816
|
|
|
<tr> |
817
|
|
|
<th> |
818
|
|
|
' . $label . ' |
819
|
|
|
</th>'; |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
|
823
|
|
|
|
824
|
|
|
|
825
|
|
|
/** |
826
|
|
|
* form_form_field_input__wrap |
827
|
|
|
* |
828
|
|
|
* @access public |
829
|
|
|
* @param string $label |
830
|
|
|
* @return string |
831
|
|
|
*/ |
832
|
|
|
public function country_form_field_input__wrap( $input, $label ) { |
|
|
|
|
833
|
|
|
return ' |
834
|
|
|
<td class="general-settings-country-input-td"> |
835
|
|
|
' . $input . ' |
836
|
|
|
</td> |
837
|
|
|
</tr>'; |
838
|
|
|
} |
839
|
|
|
|
840
|
|
|
|
841
|
|
|
|
842
|
|
|
|
843
|
|
|
/** |
844
|
|
|
* form_form_field_label_wrap |
845
|
|
|
* |
846
|
|
|
* @access public |
847
|
|
|
* @param string $label |
848
|
|
|
* @param string $required_text |
849
|
|
|
* @return string |
850
|
|
|
*/ |
851
|
|
|
public function state_form_field_label_wrap( $label, $required_text ) { |
852
|
|
|
return $required_text; |
853
|
|
|
} |
854
|
|
|
|
855
|
|
|
|
856
|
|
|
|
857
|
|
|
|
858
|
|
|
/** |
859
|
|
|
* form_form_field_input__wrap |
860
|
|
|
* |
861
|
|
|
* @access public |
862
|
|
|
* @param string $label |
863
|
|
|
* @return string |
864
|
|
|
*/ |
865
|
|
|
public function state_form_field_input__wrap( $input, $label ) { |
|
|
|
|
866
|
|
|
return ' |
867
|
|
|
<td class="general-settings-country-state-input-td"> |
868
|
|
|
' . $input . ' |
869
|
|
|
</td>'; |
870
|
|
|
|
871
|
|
|
} |
872
|
|
|
|
873
|
|
|
|
874
|
|
|
|
875
|
|
|
|
876
|
|
|
|
877
|
|
|
|
878
|
|
|
/***********/ |
879
|
|
|
|
880
|
|
|
|
881
|
|
|
|
882
|
|
|
|
883
|
|
|
|
884
|
|
|
/** |
885
|
|
|
* displays edit and view links for critical EE pages |
886
|
|
|
* |
887
|
|
|
* @access public |
888
|
|
|
* @param int $ee_page_id |
889
|
|
|
* @return string |
890
|
|
|
*/ |
891
|
|
|
public static function edit_view_links( $ee_page_id ) { |
892
|
|
|
$links = '<a href="' . add_query_arg( array( 'post' => $ee_page_id, 'action' => 'edit' ), admin_url( 'post.php' )) . '" >' . __('Edit', 'event_espresso') . '</a>'; |
893
|
|
|
$links .= ' | '; |
894
|
|
|
$links .= '<a href="' . get_permalink( $ee_page_id ) . '" >' . __('View', 'event_espresso') . '</a>'; |
895
|
|
|
return $links; |
896
|
|
|
} |
897
|
|
|
|
898
|
|
|
|
899
|
|
|
|
900
|
|
|
|
901
|
|
|
/** |
902
|
|
|
* displays page and shortcode status for critical EE pages |
903
|
|
|
* |
904
|
|
|
* @param WP page object $ee_page |
905
|
|
|
* @return string |
906
|
|
|
*/ |
907
|
|
|
public static function page_and_shortcode_status( $ee_page, $shortcode ) { |
908
|
|
|
|
909
|
|
|
// page status |
910
|
|
|
if ( isset( $ee_page->post_status ) && $ee_page->post_status == 'publish') { |
911
|
|
|
$pg_colour = 'green'; |
912
|
|
|
$pg_status = sprintf( __('Page%sStatus%sOK', 'event_espresso'), ' ' , ' ' ); |
913
|
|
|
} else { |
914
|
|
|
$pg_colour = 'red'; |
915
|
|
|
$pg_status = sprintf( __('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' ' ); |
916
|
|
|
} |
917
|
|
|
|
918
|
|
|
// shortcode status |
919
|
|
|
if ( isset( $ee_page->post_content ) && strpos( $ee_page->post_content, $shortcode ) !== FALSE ) { |
920
|
|
|
$sc_colour = 'green'; |
921
|
|
|
$sc_status = sprintf( __('Shortcode%sOK', 'event_espresso'), ' ' ); |
922
|
|
|
} else { |
923
|
|
|
$sc_colour = 'red'; |
924
|
|
|
$sc_status = sprintf( __('Shortcode%sProblem', 'event_espresso'), ' ' ); |
925
|
|
|
} |
926
|
|
|
|
927
|
|
|
return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' . $pg_status . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
928
|
|
|
|
929
|
|
|
} |
930
|
|
|
|
931
|
|
|
|
932
|
|
|
|
933
|
|
|
|
934
|
|
|
/** |
935
|
|
|
* generates a dropdown of all parent pages - copied from WP core |
936
|
|
|
* |
937
|
|
|
* @param unknown_type $default |
938
|
|
|
* @param unknown_type $parent |
939
|
|
|
* @param unknown_type $level |
940
|
|
|
* @return unknown |
941
|
|
|
*/ |
942
|
|
|
public static function page_settings_dropdown( $default = 0, $parent = 0, $level = 0 ) { |
943
|
|
|
global $wpdb; |
944
|
|
|
$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", $parent) ); |
945
|
|
|
|
946
|
|
|
if ( $items ) { |
947
|
|
|
foreach ( $items as $item ) { |
948
|
|
|
$pad = str_repeat( ' ', $level * 3 ); |
949
|
|
|
if ( $item->ID == $default) |
950
|
|
|
$current = ' selected="selected"'; |
951
|
|
|
else |
952
|
|
|
$current = ''; |
953
|
|
|
|
954
|
|
|
echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>"; |
955
|
|
|
parent_dropdown( $default, $item->ID, $level +1 ); |
956
|
|
|
} |
957
|
|
|
} else { |
958
|
|
|
return false; |
959
|
|
|
} |
960
|
|
|
} |
961
|
|
|
|
962
|
|
|
|
963
|
|
|
} //ends Forms_Admin_Page class |
964
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.