@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\Codeception\helpers; |
3 | 3 | |
4 | -use Page\CoreAdmin; |
|
5 | 4 | use Page\CountrySettingsAdmin as CountrySettings; |
6 | 5 | |
7 | 6 | trait CountrySettingsAdmin |
@@ -6,59 +6,59 @@ |
||
6 | 6 | |
7 | 7 | trait CountrySettingsAdmin |
8 | 8 | { |
9 | - /** |
|
10 | - * Instructs the actor to browse to the country settings page. |
|
11 | - * Assumes the actor is already logged in. |
|
12 | - * @param string $additional_params |
|
13 | - */ |
|
14 | - public function amOnCountrySettingsAdminPage($additional_params = '') |
|
15 | - { |
|
16 | - $this->actor()->amOnAdminPage(CountrySettings::url($additional_params)); |
|
17 | - } |
|
9 | + /** |
|
10 | + * Instructs the actor to browse to the country settings page. |
|
11 | + * Assumes the actor is already logged in. |
|
12 | + * @param string $additional_params |
|
13 | + */ |
|
14 | + public function amOnCountrySettingsAdminPage($additional_params = '') |
|
15 | + { |
|
16 | + $this->actor()->amOnAdminPage(CountrySettings::url($additional_params)); |
|
17 | + } |
|
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * Instructs the actor to select the given decimal places radio option. |
|
22 | - * Assumes the actor is already on the country settings page. |
|
23 | - * @param string $decimal_places |
|
24 | - * @param string $country_code |
|
25 | - */ |
|
26 | - public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US') |
|
27 | - { |
|
28 | - $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code)); |
|
29 | - } |
|
20 | + /** |
|
21 | + * Instructs the actor to select the given decimal places radio option. |
|
22 | + * Assumes the actor is already on the country settings page. |
|
23 | + * @param string $decimal_places |
|
24 | + * @param string $country_code |
|
25 | + */ |
|
26 | + public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US') |
|
27 | + { |
|
28 | + $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code)); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Instructs the actor to select the given decimal mark radio option. |
|
34 | - * Assumes the actor is already on the country settings page. |
|
35 | - * @param string $decimal_mark |
|
36 | - */ |
|
37 | - public function setCurrencyDecimalMarkTo($decimal_mark = '.') |
|
38 | - { |
|
39 | - $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark)); |
|
40 | - } |
|
32 | + /** |
|
33 | + * Instructs the actor to select the given decimal mark radio option. |
|
34 | + * Assumes the actor is already on the country settings page. |
|
35 | + * @param string $decimal_mark |
|
36 | + */ |
|
37 | + public function setCurrencyDecimalMarkTo($decimal_mark = '.') |
|
38 | + { |
|
39 | + $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark)); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * Instructs the actor to select the given thousands separator radio option. |
|
45 | - * Assumes the actor is already on the country settings page. |
|
46 | - * @param string $thousands_seperator |
|
47 | - */ |
|
48 | - public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',') |
|
49 | - { |
|
50 | - $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator)); |
|
51 | - } |
|
43 | + /** |
|
44 | + * Instructs the actor to select the given thousands separator radio option. |
|
45 | + * Assumes the actor is already on the country settings page. |
|
46 | + * @param string $thousands_seperator |
|
47 | + */ |
|
48 | + public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',') |
|
49 | + { |
|
50 | + $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator)); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * Clicks the country settings submit button. |
|
56 | - * Assumes the actor is on the country settings admin page. |
|
57 | - */ |
|
58 | - public function saveCountrySettings() |
|
59 | - { |
|
60 | - $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON); |
|
61 | - //no indicator on the page when stuff has been updated so just give a bit of time for it to finish. |
|
62 | - $this->actor()->wait(10); |
|
63 | - } |
|
54 | + /** |
|
55 | + * Clicks the country settings submit button. |
|
56 | + * Assumes the actor is on the country settings admin page. |
|
57 | + */ |
|
58 | + public function saveCountrySettings() |
|
59 | + { |
|
60 | + $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON); |
|
61 | + //no indicator on the page when stuff has been updated so just give a bit of time for it to finish. |
|
62 | + $this->actor()->wait(10); |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -14,51 +14,51 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2'; |
|
17 | + const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2'; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Return the url for the country settings admin page. |
|
23 | - * @param string $additional_params |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public static function url($additional_params = '') |
|
27 | - { |
|
28 | - return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params); |
|
29 | - } |
|
21 | + /** |
|
22 | + * Return the url for the country settings admin page. |
|
23 | + * @param string $additional_params |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public static function url($additional_params = '') |
|
27 | + { |
|
28 | + return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Return the decimal places (precision) radio field locator for selection. |
|
34 | - * @param int $decimal_place_value |
|
35 | - * @param string $country_code |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US') |
|
39 | - { |
|
40 | - return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']"; |
|
41 | - } |
|
32 | + /** |
|
33 | + * Return the decimal places (precision) radio field locator for selection. |
|
34 | + * @param int $decimal_place_value |
|
35 | + * @param string $country_code |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US') |
|
39 | + { |
|
40 | + return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']"; |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Return the currency decimal mark field locator for selection. |
|
46 | - * @param string $decimal_mark |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public static function currencyDecimalMarkRadioField($decimal_mark = '.') |
|
50 | - { |
|
51 | - return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']"; |
|
52 | - } |
|
44 | + /** |
|
45 | + * Return the currency decimal mark field locator for selection. |
|
46 | + * @param string $decimal_mark |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public static function currencyDecimalMarkRadioField($decimal_mark = '.') |
|
50 | + { |
|
51 | + return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']"; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Return the currency thousands separator field locator for selection. |
|
57 | - * @param string $thousands_separator |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public static function currencyThousandsSeparatorField($thousands_separator = ',') |
|
61 | - { |
|
62 | - return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']"; |
|
63 | - } |
|
55 | + /** |
|
56 | + * Return the currency thousands separator field locator for selection. |
|
57 | + * @param string $thousands_separator |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public static function currencyThousandsSeparatorField($thousands_separator = ',') |
|
61 | + { |
|
62 | + return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']"; |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | * |
749 | 749 | * @access public |
750 | 750 | * @param string $CNT_ISO |
751 | - * @return mixed string | array |
|
751 | + * @return string|null string | array |
|
752 | 752 | * @throws DomainException |
753 | 753 | */ |
754 | 754 | public function display_country_settings($CNT_ISO = '') |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | * delete_state |
1065 | 1065 | * |
1066 | 1066 | * @access public |
1067 | - * @return boolean |
|
1067 | + * @return false|null |
|
1068 | 1068 | */ |
1069 | 1069 | public function delete_state() |
1070 | 1070 | { |
@@ -19,1279 +19,1279 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * _question_group |
|
24 | - * holds the specific question group object for the question group details screen |
|
25 | - * |
|
26 | - * @var object |
|
27 | - */ |
|
28 | - protected $_question_group; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * Initialize basic properties. |
|
33 | - */ |
|
34 | - protected function _init_page_props() |
|
35 | - { |
|
36 | - $this->page_slug = GEN_SET_PG_SLUG; |
|
37 | - $this->page_label = GEN_SET_LABEL; |
|
38 | - $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
39 | - $this->_admin_base_path = GEN_SET_ADMIN; |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * Set ajax hooks |
|
45 | - */ |
|
46 | - protected function _ajax_hooks() |
|
47 | - { |
|
48 | - add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings')); |
|
49 | - add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states')); |
|
50 | - add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3); |
|
51 | - add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state')); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * More page properties initialization. |
|
57 | - */ |
|
58 | - protected function _define_page_props() |
|
59 | - { |
|
60 | - $this->_admin_page_title = GEN_SET_LABEL; |
|
61 | - $this->_labels = array( |
|
62 | - 'publishbox' => __('Update Settings', 'event_espresso'), |
|
63 | - ); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * Set page routes property. |
|
69 | - */ |
|
70 | - protected function _set_page_routes() |
|
71 | - { |
|
72 | - $this->_page_routes = array( |
|
73 | - |
|
74 | - 'critical_pages' => array( |
|
75 | - 'func' => '_espresso_page_settings', |
|
76 | - 'capability' => 'manage_options', |
|
77 | - ), |
|
78 | - 'update_espresso_page_settings' => array( |
|
79 | - 'func' => '_update_espresso_page_settings', |
|
80 | - 'capability' => 'manage_options', |
|
81 | - 'noheader' => true, |
|
82 | - ), |
|
83 | - 'default' => array( |
|
84 | - 'func' => '_your_organization_settings', |
|
85 | - 'capability' => 'manage_options', |
|
86 | - ), |
|
87 | - |
|
88 | - 'update_your_organization_settings' => array( |
|
89 | - 'func' => '_update_your_organization_settings', |
|
90 | - 'capability' => 'manage_options', |
|
91 | - 'noheader' => true, |
|
92 | - ), |
|
93 | - |
|
94 | - 'admin_option_settings' => array( |
|
95 | - 'func' => '_admin_option_settings', |
|
96 | - 'capability' => 'manage_options', |
|
97 | - ), |
|
98 | - |
|
99 | - 'update_admin_option_settings' => array( |
|
100 | - 'func' => '_update_admin_option_settings', |
|
101 | - 'capability' => 'manage_options', |
|
102 | - 'noheader' => true, |
|
103 | - ), |
|
104 | - |
|
105 | - 'country_settings' => array( |
|
106 | - 'func' => '_country_settings', |
|
107 | - 'capability' => 'manage_options', |
|
108 | - ), |
|
109 | - |
|
110 | - 'update_country_settings' => array( |
|
111 | - 'func' => '_update_country_settings', |
|
112 | - 'capability' => 'manage_options', |
|
113 | - 'noheader' => true, |
|
114 | - ), |
|
115 | - |
|
116 | - 'display_country_settings' => array( |
|
117 | - 'func' => 'display_country_settings', |
|
118 | - 'capability' => 'manage_options', |
|
119 | - 'noheader' => true, |
|
120 | - ), |
|
121 | - |
|
122 | - 'add_new_state' => array( |
|
123 | - 'func' => 'add_new_state', |
|
124 | - 'capability' => 'manage_options', |
|
125 | - 'noheader' => true, |
|
126 | - ), |
|
127 | - |
|
128 | - 'delete_state' => array( |
|
129 | - 'func' => 'delete_state', |
|
130 | - 'capability' => 'manage_options', |
|
131 | - 'noheader' => true, |
|
132 | - ), |
|
133 | - 'privacy_settings' => array( |
|
134 | - 'func' => 'privacySettings', |
|
135 | - 'capability' => 'manage_options', |
|
136 | - ), |
|
137 | - 'update_privacy_settings' => array( |
|
138 | - 'func' => 'updatePrivacySettings', |
|
139 | - 'capability' => 'manage_options', |
|
140 | - 'noheader' => true, |
|
141 | - 'headers_sent_route' => 'privacy_settings' |
|
142 | - ) |
|
143 | - ); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * Set page configuration property |
|
149 | - */ |
|
150 | - protected function _set_page_config() |
|
151 | - { |
|
152 | - $this->_page_config = array( |
|
153 | - 'critical_pages' => array( |
|
154 | - 'nav' => array( |
|
155 | - 'label' => __('Critical Pages', 'event_espresso'), |
|
156 | - 'order' => 50, |
|
157 | - ), |
|
158 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
159 | - 'help_tabs' => array( |
|
160 | - 'general_settings_critical_pages_help_tab' => array( |
|
161 | - 'title' => __('Critical Pages', 'event_espresso'), |
|
162 | - 'filename' => 'general_settings_critical_pages', |
|
163 | - ), |
|
164 | - ), |
|
165 | - 'help_tour' => array('Critical_Pages_Help_Tour'), |
|
166 | - 'require_nonce' => false, |
|
167 | - ), |
|
168 | - 'default' => array( |
|
169 | - 'nav' => array( |
|
170 | - 'label' => __('Your Organization', 'event_espresso'), |
|
171 | - 'order' => 20, |
|
172 | - ), |
|
173 | - 'help_tabs' => array( |
|
174 | - 'general_settings_your_organization_help_tab' => array( |
|
175 | - 'title' => __('Your Organization', 'event_espresso'), |
|
176 | - 'filename' => 'general_settings_your_organization', |
|
177 | - ), |
|
178 | - ), |
|
179 | - 'help_tour' => array('Your_Organization_Help_Tour'), |
|
180 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
181 | - 'require_nonce' => false, |
|
182 | - ), |
|
183 | - 'admin_option_settings' => array( |
|
184 | - 'nav' => array( |
|
185 | - 'label' => __('Admin Options', 'event_espresso'), |
|
186 | - 'order' => 60, |
|
187 | - ), |
|
188 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
189 | - 'help_tabs' => array( |
|
190 | - 'general_settings_admin_options_help_tab' => array( |
|
191 | - 'title' => __('Admin Options', 'event_espresso'), |
|
192 | - 'filename' => 'general_settings_admin_options', |
|
193 | - ), |
|
194 | - ), |
|
195 | - 'help_tour' => array('Admin_Options_Help_Tour'), |
|
196 | - 'require_nonce' => false, |
|
197 | - ), |
|
198 | - 'country_settings' => array( |
|
199 | - 'nav' => array( |
|
200 | - 'label' => __('Countries', 'event_espresso'), |
|
201 | - 'order' => 70, |
|
202 | - ), |
|
203 | - 'help_tabs' => array( |
|
204 | - 'general_settings_countries_help_tab' => array( |
|
205 | - 'title' => __('Countries', 'event_espresso'), |
|
206 | - 'filename' => 'general_settings_countries', |
|
207 | - ), |
|
208 | - ), |
|
209 | - 'help_tour' => array('Countries_Help_Tour'), |
|
210 | - 'require_nonce' => false, |
|
211 | - ), |
|
212 | - 'privacy_settings' => array( |
|
213 | - 'nav' => array( |
|
214 | - 'label' => esc_html__('Privacy', 'event_espresso'), |
|
215 | - 'order' => 80 |
|
216 | - ), |
|
217 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
218 | - 'require_nonce' => false |
|
219 | - ) |
|
220 | - ); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - protected function _add_screen_options() |
|
225 | - { |
|
226 | - } |
|
227 | - |
|
228 | - protected function _add_feature_pointers() |
|
229 | - { |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
235 | - */ |
|
236 | - public function load_scripts_styles() |
|
237 | - { |
|
238 | - // styles |
|
239 | - wp_enqueue_style('espresso-ui-theme'); |
|
240 | - // scripts |
|
241 | - wp_enqueue_script('ee_admin_js'); |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * Execute logic running on `admin_init` |
|
247 | - */ |
|
248 | - public function admin_init() |
|
249 | - { |
|
250 | - EE_Registry::$i18n_js_strings['invalid_server_response'] = __( |
|
251 | - '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.', |
|
252 | - 'event_espresso' |
|
253 | - ); |
|
254 | - EE_Registry::$i18n_js_strings['error_occurred'] = __( |
|
255 | - 'An error occurred! Please refresh the page and try again.', |
|
256 | - 'event_espresso' |
|
257 | - ); |
|
258 | - EE_Registry::$i18n_js_strings['confirm_delete_state'] = __( |
|
259 | - 'Are you sure you want to delete this State / Province?', |
|
260 | - 'event_espresso' |
|
261 | - ); |
|
262 | - $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
263 | - EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
264 | - 'admin-ajax.php?page=espresso_general_settings', |
|
265 | - $protocol |
|
266 | - ); |
|
267 | - } |
|
268 | - |
|
269 | - public function admin_notices() |
|
270 | - { |
|
271 | - } |
|
272 | - |
|
273 | - public function admin_footer_scripts() |
|
274 | - { |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * Enqueue scripts and styles for the default route. |
|
280 | - */ |
|
281 | - public function load_scripts_styles_default() |
|
282 | - { |
|
283 | - // styles |
|
284 | - wp_enqueue_style('thickbox'); |
|
285 | - // scripts |
|
286 | - wp_enqueue_script('media-upload'); |
|
287 | - wp_enqueue_script('thickbox'); |
|
288 | - wp_register_script( |
|
289 | - 'organization_settings', |
|
290 | - GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
291 | - array('jquery', 'media-upload', 'thickbox'), |
|
292 | - EVENT_ESPRESSO_VERSION, |
|
293 | - true |
|
294 | - ); |
|
295 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
296 | - wp_enqueue_script('organization_settings'); |
|
297 | - wp_enqueue_style('organization-css'); |
|
298 | - $confirm_image_delete = array( |
|
299 | - 'text' => __( |
|
300 | - 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
301 | - 'event_espresso' |
|
302 | - ), |
|
303 | - ); |
|
304 | - wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * Enqueue scripts and styles for the country settings route. |
|
310 | - */ |
|
311 | - public function load_scripts_styles_country_settings() |
|
312 | - { |
|
313 | - // scripts |
|
314 | - wp_register_script( |
|
315 | - 'gen_settings_countries', |
|
316 | - GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
317 | - array('ee_admin_js'), |
|
318 | - EVENT_ESPRESSO_VERSION, |
|
319 | - true |
|
320 | - ); |
|
321 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
322 | - wp_enqueue_script('gen_settings_countries'); |
|
323 | - wp_enqueue_style('organization-css'); |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - /************* Espresso Pages *************/ |
|
328 | - /** |
|
329 | - * _espresso_page_settings |
|
330 | - * |
|
331 | - * @throws \EE_Error |
|
332 | - */ |
|
333 | - protected function _espresso_page_settings() |
|
334 | - { |
|
335 | - // Check to make sure all of the main pages are setup properly, |
|
336 | - // if not create the default pages and display an admin notice |
|
337 | - EEH_Activation::verify_default_pages_exist(); |
|
338 | - $this->_transient_garbage_collection(); |
|
339 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
340 | - $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
341 | - ? EE_Registry::instance()->CFG->core->reg_page_id |
|
342 | - : null; |
|
343 | - $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
344 | - ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) |
|
345 | - : false; |
|
346 | - $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
347 | - ? EE_Registry::instance()->CFG->core->txn_page_id |
|
348 | - : null; |
|
349 | - $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
350 | - ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) |
|
351 | - : false; |
|
352 | - $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
353 | - ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
354 | - : null; |
|
355 | - $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
356 | - ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
357 | - : false; |
|
358 | - $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
359 | - ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
360 | - : null; |
|
361 | - $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
362 | - ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
363 | - : false; |
|
364 | - $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
365 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
366 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
367 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
368 | - $this->_template_args, |
|
369 | - true |
|
370 | - ); |
|
371 | - $this->display_admin_page_with_sidebar(); |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * Handler for updating espresso page settings. |
|
377 | - */ |
|
378 | - protected function _update_espresso_page_settings() |
|
379 | - { |
|
380 | - // capture incoming request data && set page IDs |
|
381 | - EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
382 | - ? absint($this->_req_data['reg_page_id']) |
|
383 | - : EE_Registry::instance()->CFG->core->reg_page_id; |
|
384 | - EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
385 | - ? absint($this->_req_data['txn_page_id']) |
|
386 | - : EE_Registry::instance()->CFG->core->txn_page_id; |
|
387 | - EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
388 | - ? absint($this->_req_data['thank_you_page_id']) |
|
389 | - : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
390 | - EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
391 | - ? absint($this->_req_data['cancel_page_id']) |
|
392 | - : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
393 | - |
|
394 | - EE_Registry::instance()->CFG->core = apply_filters( |
|
395 | - 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
396 | - EE_Registry::instance()->CFG->core, |
|
397 | - $this->_req_data |
|
398 | - ); |
|
399 | - $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
400 | - $this->_redirect_after_action( |
|
401 | - $this->_update_espresso_configuration( |
|
402 | - $what, |
|
403 | - EE_Registry::instance()->CFG->core, |
|
404 | - __FILE__, |
|
405 | - __FUNCTION__, |
|
406 | - __LINE__ |
|
407 | - ), |
|
408 | - $what, |
|
409 | - '', |
|
410 | - array( |
|
411 | - 'action' => 'critical_pages', |
|
412 | - ), |
|
413 | - true |
|
414 | - ); |
|
415 | - } |
|
416 | - |
|
417 | - |
|
418 | - /************* Your Organization *************/ |
|
419 | - |
|
420 | - |
|
421 | - protected function _your_organization_settings() |
|
422 | - { |
|
423 | - $this->_template_args['admin_page_content'] = ''; |
|
424 | - try { |
|
425 | - $organization_settings_form = new OrganizationSettings(EE_Registry::instance()); |
|
426 | - $this->_template_args['admin_page_content'] = $organization_settings_form->display(); |
|
427 | - } catch (Exception $e) { |
|
428 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
429 | - } |
|
430 | - $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
431 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
432 | - $this->display_admin_page_with_sidebar(); |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - |
|
437 | - /** |
|
438 | - * Handler for updating organization settings. |
|
439 | - * |
|
440 | - * @throws EE_Error |
|
441 | - */ |
|
442 | - protected function _update_your_organization_settings() |
|
443 | - { |
|
444 | - try { |
|
445 | - $organization_settings_form = new OrganizationSettings(EE_Registry::instance()); |
|
446 | - $success = $organization_settings_form->process($this->_req_data); |
|
447 | - EE_Registry::instance()->CFG = apply_filters( |
|
448 | - 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
449 | - EE_Registry::instance()->CFG |
|
450 | - ); |
|
451 | - } catch (Exception $e) { |
|
452 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
453 | - $success = false; |
|
454 | - } |
|
455 | - |
|
456 | - if ($success) { |
|
457 | - $success = $this->_update_espresso_configuration( |
|
458 | - esc_html__('Your Organization Settings', 'event_espresso'), |
|
459 | - EE_Registry::instance()->CFG, |
|
460 | - __FILE__, |
|
461 | - __FUNCTION__, |
|
462 | - __LINE__ |
|
463 | - ); |
|
464 | - } |
|
465 | - |
|
466 | - $this->_redirect_after_action($success, '', '', array('action' => 'default'), true); |
|
467 | - } |
|
468 | - |
|
469 | - |
|
470 | - |
|
471 | - /************* Admin Options *************/ |
|
472 | - |
|
473 | - |
|
474 | - /** |
|
475 | - * _admin_option_settings |
|
476 | - * |
|
477 | - * @throws \EE_Error |
|
478 | - * @throws \LogicException |
|
479 | - */ |
|
480 | - protected function _admin_option_settings() |
|
481 | - { |
|
482 | - $this->_template_args['admin_page_content'] = ''; |
|
483 | - try { |
|
484 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
485 | - // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
486 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
487 | - // also need to account for the do_action that was in the old template |
|
488 | - $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
489 | - $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
490 | - } catch (Exception $e) { |
|
491 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
492 | - } |
|
493 | - $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
494 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
495 | - $this->display_admin_page_with_sidebar(); |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * _update_admin_option_settings |
|
501 | - * |
|
502 | - * @throws \EE_Error |
|
503 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
504 | - * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException |
|
505 | - * @throws \InvalidArgumentException |
|
506 | - * @throws \LogicException |
|
507 | - */ |
|
508 | - protected function _update_admin_option_settings() |
|
509 | - { |
|
510 | - try { |
|
511 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
512 | - $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
513 | - EE_Registry::instance()->CFG->admin = apply_filters( |
|
514 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
515 | - EE_Registry::instance()->CFG->admin |
|
516 | - ); |
|
517 | - } catch (Exception $e) { |
|
518 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
519 | - } |
|
520 | - $this->_redirect_after_action( |
|
521 | - apply_filters( |
|
522 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
523 | - $this->_update_espresso_configuration( |
|
524 | - 'Admin Options', |
|
525 | - EE_Registry::instance()->CFG->admin, |
|
526 | - __FILE__, |
|
527 | - __FUNCTION__, |
|
528 | - __LINE__ |
|
529 | - ) |
|
530 | - ), |
|
531 | - 'Admin Options', |
|
532 | - 'updated', |
|
533 | - array('action' => 'admin_option_settings') |
|
534 | - ); |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - /************* Countries *************/ |
|
539 | - |
|
540 | - |
|
541 | - /** |
|
542 | - * Output Country Settings view. |
|
543 | - * |
|
544 | - * @throws DomainException |
|
545 | - * @throws EE_Error |
|
546 | - */ |
|
547 | - protected function _country_settings() |
|
548 | - { |
|
549 | - $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
550 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
551 | - : 'US'; |
|
552 | - $CNT_ISO = isset($this->_req_data['country']) |
|
553 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
554 | - : $CNT_ISO; |
|
555 | - |
|
556 | - // load field generator helper |
|
557 | - |
|
558 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
559 | - |
|
560 | - $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
561 | - EE_Question::new_instance( |
|
562 | - array( |
|
563 | - 'QST_ID' => 0, |
|
564 | - 'QST_display_text' => __('Select Country', 'event_espresso'), |
|
565 | - 'QST_system' => 'admin-country', |
|
566 | - ) |
|
567 | - ), |
|
568 | - EE_Answer::new_instance( |
|
569 | - array( |
|
570 | - 'ANS_ID' => 0, |
|
571 | - 'ANS_value' => $CNT_ISO, |
|
572 | - ) |
|
573 | - ), |
|
574 | - array( |
|
575 | - 'input_id' => 'country', |
|
576 | - 'input_name' => 'country', |
|
577 | - 'input_prefix' => '', |
|
578 | - 'append_qstn_id' => false, |
|
579 | - ) |
|
580 | - ); |
|
581 | - |
|
582 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
583 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
584 | - $this->_template_args['country_details_settings'] = $this->display_country_settings(); |
|
585 | - $this->_template_args['country_states_settings'] = $this->display_country_states(); |
|
586 | - |
|
587 | - $this->_set_add_edit_form_tags('update_country_settings'); |
|
588 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
589 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
590 | - GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
591 | - $this->_template_args, |
|
592 | - true |
|
593 | - ); |
|
594 | - $this->display_admin_page_with_no_sidebar(); |
|
595 | - } |
|
596 | - |
|
597 | - |
|
598 | - /** |
|
599 | - * display_country_settings |
|
600 | - * |
|
601 | - * @access public |
|
602 | - * @param string $CNT_ISO |
|
603 | - * @return mixed string | array |
|
604 | - * @throws DomainException |
|
605 | - */ |
|
606 | - public function display_country_settings($CNT_ISO = '') |
|
607 | - { |
|
608 | - |
|
609 | - $CNT_ISO = isset($this->_req_data['country']) |
|
610 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
611 | - : $CNT_ISO; |
|
612 | - if (! $CNT_ISO) { |
|
613 | - return ''; |
|
614 | - } |
|
615 | - |
|
616 | - // for ajax |
|
617 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
618 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
619 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
620 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
621 | - $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
622 | - |
|
623 | - $country_input_types = array( |
|
624 | - 'CNT_active' => array( |
|
625 | - 'type' => 'RADIO_BTN', |
|
626 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
627 | - 'class' => '', |
|
628 | - 'options' => $this->_yes_no_values, |
|
629 | - 'use_desc_4_label' => true, |
|
630 | - ), |
|
631 | - 'CNT_ISO' => array( |
|
632 | - 'type' => 'TEXT', |
|
633 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
634 | - 'class' => 'small-text', |
|
635 | - ), |
|
636 | - 'CNT_ISO3' => array( |
|
637 | - 'type' => 'TEXT', |
|
638 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
639 | - 'class' => 'small-text', |
|
640 | - ), |
|
641 | - 'RGN_ID' => array( |
|
642 | - 'type' => 'TEXT', |
|
643 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
644 | - 'class' => 'small-text', |
|
645 | - ), |
|
646 | - 'CNT_name' => array( |
|
647 | - 'type' => 'TEXT', |
|
648 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
649 | - 'class' => 'regular-text', |
|
650 | - ), |
|
651 | - 'CNT_cur_code' => array( |
|
652 | - 'type' => 'TEXT', |
|
653 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
654 | - 'class' => 'small-text', |
|
655 | - ), |
|
656 | - 'CNT_cur_single' => array( |
|
657 | - 'type' => 'TEXT', |
|
658 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
659 | - 'class' => 'medium-text', |
|
660 | - ), |
|
661 | - 'CNT_cur_plural' => array( |
|
662 | - 'type' => 'TEXT', |
|
663 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
664 | - 'class' => 'medium-text', |
|
665 | - ), |
|
666 | - 'CNT_cur_sign' => array( |
|
667 | - 'type' => 'TEXT', |
|
668 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
669 | - 'class' => 'small-text', |
|
670 | - 'htmlentities' => false, |
|
671 | - ), |
|
672 | - 'CNT_cur_sign_b4' => array( |
|
673 | - 'type' => 'RADIO_BTN', |
|
674 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
675 | - 'class' => '', |
|
676 | - 'options' => $this->_yes_no_values, |
|
677 | - 'use_desc_4_label' => true, |
|
678 | - ), |
|
679 | - 'CNT_cur_dec_plc' => array( |
|
680 | - 'type' => 'RADIO_BTN', |
|
681 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
682 | - 'class' => '', |
|
683 | - 'options' => array( |
|
684 | - array('id' => 0, 'text' => ''), |
|
685 | - array('id' => 1, 'text' => ''), |
|
686 | - array('id' => 2, 'text' => ''), |
|
687 | - array('id' => 3, 'text' => ''), |
|
688 | - ), |
|
689 | - ), |
|
690 | - 'CNT_cur_dec_mrk' => array( |
|
691 | - 'type' => 'RADIO_BTN', |
|
692 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
693 | - 'class' => '', |
|
694 | - 'options' => array( |
|
695 | - array( |
|
696 | - 'id' => ',', |
|
697 | - 'text' => __(', (comma)', 'event_espresso'), |
|
698 | - ), |
|
699 | - array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
700 | - ), |
|
701 | - 'use_desc_4_label' => true, |
|
702 | - ), |
|
703 | - 'CNT_cur_thsnds' => array( |
|
704 | - 'type' => 'RADIO_BTN', |
|
705 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
706 | - 'class' => '', |
|
707 | - 'options' => array( |
|
708 | - array( |
|
709 | - 'id' => ',', |
|
710 | - 'text' => __(', (comma)', 'event_espresso'), |
|
711 | - ), |
|
712 | - array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
713 | - ), |
|
714 | - 'use_desc_4_label' => true, |
|
715 | - ), |
|
716 | - 'CNT_tel_code' => array( |
|
717 | - 'type' => 'TEXT', |
|
718 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
719 | - 'class' => 'small-text', |
|
720 | - ), |
|
721 | - 'CNT_is_EU' => array( |
|
722 | - 'type' => 'RADIO_BTN', |
|
723 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
724 | - 'class' => '', |
|
725 | - 'options' => $this->_yes_no_values, |
|
726 | - 'use_desc_4_label' => true, |
|
727 | - ), |
|
728 | - ); |
|
729 | - $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
730 | - $country, |
|
731 | - $country_input_types |
|
732 | - ); |
|
733 | - $country_details_settings = EEH_Template::display_template( |
|
734 | - GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
735 | - $this->_template_args, |
|
736 | - true |
|
737 | - ); |
|
738 | - |
|
739 | - if (defined('DOING_AJAX')) { |
|
740 | - $notices = EE_Error::get_notices(false, false, false); |
|
741 | - echo wp_json_encode( |
|
742 | - array( |
|
743 | - 'return_data' => $country_details_settings, |
|
744 | - 'success' => $notices['success'], |
|
745 | - 'errors' => $notices['errors'], |
|
746 | - ) |
|
747 | - ); |
|
748 | - die(); |
|
749 | - } else { |
|
750 | - return $country_details_settings; |
|
751 | - } |
|
752 | - } |
|
753 | - |
|
754 | - |
|
755 | - /** |
|
756 | - * display_country_states |
|
757 | - * |
|
758 | - * @access public |
|
759 | - * @param string $CNT_ISO |
|
760 | - * @return string |
|
761 | - * @throws DomainException |
|
762 | - */ |
|
763 | - public function display_country_states($CNT_ISO = '') |
|
764 | - { |
|
765 | - |
|
766 | - $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
|
767 | - |
|
768 | - if (! $CNT_ISO) { |
|
769 | - return ''; |
|
770 | - } |
|
771 | - // for ajax |
|
772 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
773 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
774 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); |
|
775 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); |
|
776 | - $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); |
|
777 | - |
|
778 | - if ($states) { |
|
779 | - foreach ($states as $STA_ID => $state) { |
|
780 | - if ($state instanceof EE_State) { |
|
781 | - // STA_abbrev STA_name STA_active |
|
782 | - $state_input_types = array( |
|
783 | - 'STA_abbrev' => array( |
|
784 | - 'type' => 'TEXT', |
|
785 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
786 | - 'class' => 'mid-text', |
|
787 | - ), |
|
788 | - 'STA_name' => array( |
|
789 | - 'type' => 'TEXT', |
|
790 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
791 | - 'class' => 'regular-text', |
|
792 | - ), |
|
793 | - 'STA_active' => array( |
|
794 | - 'type' => 'RADIO_BTN', |
|
795 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
796 | - 'options' => $this->_yes_no_values, |
|
797 | - 'use_desc_4_label' => true, |
|
798 | - ), |
|
799 | - ); |
|
800 | - $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
801 | - EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
802 | - $state, |
|
803 | - $state_input_types |
|
804 | - ); |
|
805 | - $query_args = array( |
|
806 | - 'action' => 'delete_state', |
|
807 | - 'STA_ID' => $STA_ID, |
|
808 | - 'CNT_ISO' => $CNT_ISO, |
|
809 | - 'STA_abbrev' => $state->abbrev(), |
|
810 | - ); |
|
811 | - $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
812 | - EE_Admin_Page::add_query_args_and_nonce( |
|
813 | - $query_args, |
|
814 | - GEN_SET_ADMIN_URL |
|
815 | - ); |
|
816 | - } |
|
817 | - } |
|
818 | - } else { |
|
819 | - $this->_template_args['states'] = false; |
|
820 | - } |
|
821 | - |
|
822 | - $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
823 | - array('action' => 'add_new_state'), |
|
824 | - GEN_SET_ADMIN_URL |
|
825 | - ); |
|
826 | - |
|
827 | - $state_details_settings = EEH_Template::display_template( |
|
828 | - GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
829 | - $this->_template_args, |
|
830 | - true |
|
831 | - ); |
|
832 | - |
|
833 | - if (defined('DOING_AJAX')) { |
|
834 | - $notices = EE_Error::get_notices(false, false, false); |
|
835 | - echo wp_json_encode( |
|
836 | - array( |
|
837 | - 'return_data' => $state_details_settings, |
|
838 | - 'success' => $notices['success'], |
|
839 | - 'errors' => $notices['errors'], |
|
840 | - ) |
|
841 | - ); |
|
842 | - die(); |
|
843 | - } else { |
|
844 | - return $state_details_settings; |
|
845 | - } |
|
846 | - } |
|
847 | - |
|
848 | - |
|
849 | - /** |
|
850 | - * add_new_state |
|
851 | - * |
|
852 | - * @access public |
|
853 | - * @return void |
|
854 | - * @throws EE_Error |
|
855 | - */ |
|
856 | - public function add_new_state() |
|
857 | - { |
|
858 | - |
|
859 | - $success = true; |
|
860 | - |
|
861 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
862 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
863 | - : false; |
|
864 | - if (! $CNT_ISO) { |
|
865 | - EE_Error::add_error( |
|
866 | - __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
867 | - __FILE__, |
|
868 | - __FUNCTION__, |
|
869 | - __LINE__ |
|
870 | - ); |
|
871 | - $success = false; |
|
872 | - } |
|
873 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
874 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
875 | - : false; |
|
876 | - if (! $STA_abbrev) { |
|
877 | - EE_Error::add_error( |
|
878 | - __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
879 | - __FILE__, |
|
880 | - __FUNCTION__, |
|
881 | - __LINE__ |
|
882 | - ); |
|
883 | - $success = false; |
|
884 | - } |
|
885 | - $STA_name = isset($this->_req_data['STA_name']) |
|
886 | - ? sanitize_text_field($this->_req_data['STA_name']) |
|
887 | - : false; |
|
888 | - if (! $STA_name) { |
|
889 | - EE_Error::add_error( |
|
890 | - __('No State name or an invalid State name was received.', 'event_espresso'), |
|
891 | - __FILE__, |
|
892 | - __FUNCTION__, |
|
893 | - __LINE__ |
|
894 | - ); |
|
895 | - $success = false; |
|
896 | - } |
|
897 | - |
|
898 | - if ($success) { |
|
899 | - $cols_n_values = array( |
|
900 | - 'CNT_ISO' => $CNT_ISO, |
|
901 | - 'STA_abbrev' => $STA_abbrev, |
|
902 | - 'STA_name' => $STA_name, |
|
903 | - 'STA_active' => true, |
|
904 | - ); |
|
905 | - $success = EEM_State::instance()->insert($cols_n_values); |
|
906 | - EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
|
907 | - } |
|
908 | - |
|
909 | - if (defined('DOING_AJAX')) { |
|
910 | - $notices = EE_Error::get_notices(false, false, false); |
|
911 | - echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO))); |
|
912 | - die(); |
|
913 | - } else { |
|
914 | - $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings')); |
|
915 | - } |
|
916 | - } |
|
917 | - |
|
918 | - |
|
919 | - /** |
|
920 | - * delete_state |
|
921 | - * |
|
922 | - * @access public |
|
923 | - * @return boolean |
|
924 | - */ |
|
925 | - public function delete_state() |
|
926 | - { |
|
927 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
928 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
929 | - : false; |
|
930 | - $STA_ID = isset($this->_req_data['STA_ID']) |
|
931 | - ? sanitize_text_field($this->_req_data['STA_ID']) |
|
932 | - : false; |
|
933 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
934 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
935 | - : false; |
|
936 | - if (! $STA_ID) { |
|
937 | - EE_Error::add_error( |
|
938 | - __('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
939 | - __FILE__, |
|
940 | - __FUNCTION__, |
|
941 | - __LINE__ |
|
942 | - ); |
|
943 | - return false; |
|
944 | - } |
|
945 | - |
|
946 | - $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
947 | - if ($success !== false) { |
|
948 | - do_action( |
|
949 | - 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
950 | - $CNT_ISO, |
|
951 | - $STA_ID, |
|
952 | - array('STA_abbrev' => $STA_abbrev) |
|
953 | - ); |
|
954 | - EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso')); |
|
955 | - } |
|
956 | - if (defined('DOING_AJAX')) { |
|
957 | - $notices = EE_Error::get_notices(false, false); |
|
958 | - $notices['return_data'] = true; |
|
959 | - echo wp_json_encode($notices); |
|
960 | - die(); |
|
961 | - } else { |
|
962 | - $this->_redirect_after_action( |
|
963 | - $success, |
|
964 | - 'State', |
|
965 | - 'deleted', |
|
966 | - array('action' => 'country_settings') |
|
967 | - ); |
|
968 | - } |
|
969 | - } |
|
970 | - |
|
971 | - |
|
972 | - /** |
|
973 | - * _update_country_settings |
|
974 | - * |
|
975 | - * @access protected |
|
976 | - * @return void |
|
977 | - * @throws EE_Error |
|
978 | - */ |
|
979 | - protected function _update_country_settings() |
|
980 | - { |
|
981 | - // grab the country ISO code |
|
982 | - $CNT_ISO = isset($this->_req_data['country']) |
|
983 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
984 | - : false; |
|
985 | - if (! $CNT_ISO) { |
|
986 | - EE_Error::add_error( |
|
987 | - __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
988 | - __FILE__, |
|
989 | - __FUNCTION__, |
|
990 | - __LINE__ |
|
991 | - ); |
|
992 | - |
|
993 | - return; |
|
994 | - } |
|
995 | - $cols_n_values = array(); |
|
996 | - $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
997 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
998 | - : false; |
|
999 | - $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1000 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1001 | - : null; |
|
1002 | - $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1003 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1004 | - : null; |
|
1005 | - $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
1006 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) |
|
1007 | - : 'USD'; |
|
1008 | - $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1009 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1010 | - : 'dollar'; |
|
1011 | - $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1012 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1013 | - : 'dollars'; |
|
1014 | - $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1015 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1016 | - : '$'; |
|
1017 | - $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1018 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1019 | - : true; |
|
1020 | - $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1021 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1022 | - : 2; |
|
1023 | - $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1024 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1025 | - : '.'; |
|
1026 | - $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1027 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1028 | - : ','; |
|
1029 | - $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1030 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1031 | - : null; |
|
1032 | - $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1033 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1034 | - : false; |
|
1035 | - $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1036 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1037 | - : false; |
|
1038 | - // allow filtering of country data |
|
1039 | - $cols_n_values = apply_filters( |
|
1040 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
1041 | - $cols_n_values |
|
1042 | - ); |
|
1043 | - |
|
1044 | - // where values |
|
1045 | - $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO)); |
|
1046 | - // run the update |
|
1047 | - $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
1048 | - |
|
1049 | - if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
1050 | - // allow filtering of states data |
|
1051 | - $states = apply_filters( |
|
1052 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
1053 | - $this->_req_data['states'] |
|
1054 | - ); |
|
1055 | - |
|
1056 | - // loop thru state data ( looks like : states[75][STA_name] ) |
|
1057 | - foreach ($states as $STA_ID => $state) { |
|
1058 | - $cols_n_values = array( |
|
1059 | - 'CNT_ISO' => $CNT_ISO, |
|
1060 | - 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
1061 | - 'STA_name' => sanitize_text_field($state['STA_name']), |
|
1062 | - 'STA_active' => (bool) absint($state['STA_active']), |
|
1063 | - ); |
|
1064 | - // where values |
|
1065 | - $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
1066 | - // run the update |
|
1067 | - $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
1068 | - if ($success !== false) { |
|
1069 | - do_action( |
|
1070 | - 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
1071 | - $CNT_ISO, |
|
1072 | - $STA_ID, |
|
1073 | - $cols_n_values |
|
1074 | - ); |
|
1075 | - } |
|
1076 | - } |
|
1077 | - } |
|
1078 | - // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
1079 | - if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
1080 | - && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
1081 | - ) { |
|
1082 | - EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
1083 | - EE_Registry::instance()->CFG->update_espresso_config(); |
|
1084 | - } |
|
1085 | - |
|
1086 | - if ($success !== false) { |
|
1087 | - EE_Error::add_success( |
|
1088 | - esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
1089 | - ); |
|
1090 | - } |
|
1091 | - $this->_redirect_after_action( |
|
1092 | - $success, |
|
1093 | - '', |
|
1094 | - '', |
|
1095 | - array('action' => 'country_settings', 'country' => $CNT_ISO), |
|
1096 | - true |
|
1097 | - ); |
|
1098 | - } |
|
1099 | - |
|
1100 | - |
|
1101 | - /** |
|
1102 | - * form_form_field_label_wrap |
|
1103 | - * |
|
1104 | - * @access public |
|
1105 | - * @param string $label |
|
1106 | - * @return string |
|
1107 | - */ |
|
1108 | - public function country_form_field_label_wrap($label, $required_text) |
|
1109 | - { |
|
1110 | - return ' |
|
22 | + /** |
|
23 | + * _question_group |
|
24 | + * holds the specific question group object for the question group details screen |
|
25 | + * |
|
26 | + * @var object |
|
27 | + */ |
|
28 | + protected $_question_group; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * Initialize basic properties. |
|
33 | + */ |
|
34 | + protected function _init_page_props() |
|
35 | + { |
|
36 | + $this->page_slug = GEN_SET_PG_SLUG; |
|
37 | + $this->page_label = GEN_SET_LABEL; |
|
38 | + $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
39 | + $this->_admin_base_path = GEN_SET_ADMIN; |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * Set ajax hooks |
|
45 | + */ |
|
46 | + protected function _ajax_hooks() |
|
47 | + { |
|
48 | + add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings')); |
|
49 | + add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states')); |
|
50 | + add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3); |
|
51 | + add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state')); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * More page properties initialization. |
|
57 | + */ |
|
58 | + protected function _define_page_props() |
|
59 | + { |
|
60 | + $this->_admin_page_title = GEN_SET_LABEL; |
|
61 | + $this->_labels = array( |
|
62 | + 'publishbox' => __('Update Settings', 'event_espresso'), |
|
63 | + ); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * Set page routes property. |
|
69 | + */ |
|
70 | + protected function _set_page_routes() |
|
71 | + { |
|
72 | + $this->_page_routes = array( |
|
73 | + |
|
74 | + 'critical_pages' => array( |
|
75 | + 'func' => '_espresso_page_settings', |
|
76 | + 'capability' => 'manage_options', |
|
77 | + ), |
|
78 | + 'update_espresso_page_settings' => array( |
|
79 | + 'func' => '_update_espresso_page_settings', |
|
80 | + 'capability' => 'manage_options', |
|
81 | + 'noheader' => true, |
|
82 | + ), |
|
83 | + 'default' => array( |
|
84 | + 'func' => '_your_organization_settings', |
|
85 | + 'capability' => 'manage_options', |
|
86 | + ), |
|
87 | + |
|
88 | + 'update_your_organization_settings' => array( |
|
89 | + 'func' => '_update_your_organization_settings', |
|
90 | + 'capability' => 'manage_options', |
|
91 | + 'noheader' => true, |
|
92 | + ), |
|
93 | + |
|
94 | + 'admin_option_settings' => array( |
|
95 | + 'func' => '_admin_option_settings', |
|
96 | + 'capability' => 'manage_options', |
|
97 | + ), |
|
98 | + |
|
99 | + 'update_admin_option_settings' => array( |
|
100 | + 'func' => '_update_admin_option_settings', |
|
101 | + 'capability' => 'manage_options', |
|
102 | + 'noheader' => true, |
|
103 | + ), |
|
104 | + |
|
105 | + 'country_settings' => array( |
|
106 | + 'func' => '_country_settings', |
|
107 | + 'capability' => 'manage_options', |
|
108 | + ), |
|
109 | + |
|
110 | + 'update_country_settings' => array( |
|
111 | + 'func' => '_update_country_settings', |
|
112 | + 'capability' => 'manage_options', |
|
113 | + 'noheader' => true, |
|
114 | + ), |
|
115 | + |
|
116 | + 'display_country_settings' => array( |
|
117 | + 'func' => 'display_country_settings', |
|
118 | + 'capability' => 'manage_options', |
|
119 | + 'noheader' => true, |
|
120 | + ), |
|
121 | + |
|
122 | + 'add_new_state' => array( |
|
123 | + 'func' => 'add_new_state', |
|
124 | + 'capability' => 'manage_options', |
|
125 | + 'noheader' => true, |
|
126 | + ), |
|
127 | + |
|
128 | + 'delete_state' => array( |
|
129 | + 'func' => 'delete_state', |
|
130 | + 'capability' => 'manage_options', |
|
131 | + 'noheader' => true, |
|
132 | + ), |
|
133 | + 'privacy_settings' => array( |
|
134 | + 'func' => 'privacySettings', |
|
135 | + 'capability' => 'manage_options', |
|
136 | + ), |
|
137 | + 'update_privacy_settings' => array( |
|
138 | + 'func' => 'updatePrivacySettings', |
|
139 | + 'capability' => 'manage_options', |
|
140 | + 'noheader' => true, |
|
141 | + 'headers_sent_route' => 'privacy_settings' |
|
142 | + ) |
|
143 | + ); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * Set page configuration property |
|
149 | + */ |
|
150 | + protected function _set_page_config() |
|
151 | + { |
|
152 | + $this->_page_config = array( |
|
153 | + 'critical_pages' => array( |
|
154 | + 'nav' => array( |
|
155 | + 'label' => __('Critical Pages', 'event_espresso'), |
|
156 | + 'order' => 50, |
|
157 | + ), |
|
158 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
159 | + 'help_tabs' => array( |
|
160 | + 'general_settings_critical_pages_help_tab' => array( |
|
161 | + 'title' => __('Critical Pages', 'event_espresso'), |
|
162 | + 'filename' => 'general_settings_critical_pages', |
|
163 | + ), |
|
164 | + ), |
|
165 | + 'help_tour' => array('Critical_Pages_Help_Tour'), |
|
166 | + 'require_nonce' => false, |
|
167 | + ), |
|
168 | + 'default' => array( |
|
169 | + 'nav' => array( |
|
170 | + 'label' => __('Your Organization', 'event_espresso'), |
|
171 | + 'order' => 20, |
|
172 | + ), |
|
173 | + 'help_tabs' => array( |
|
174 | + 'general_settings_your_organization_help_tab' => array( |
|
175 | + 'title' => __('Your Organization', 'event_espresso'), |
|
176 | + 'filename' => 'general_settings_your_organization', |
|
177 | + ), |
|
178 | + ), |
|
179 | + 'help_tour' => array('Your_Organization_Help_Tour'), |
|
180 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
181 | + 'require_nonce' => false, |
|
182 | + ), |
|
183 | + 'admin_option_settings' => array( |
|
184 | + 'nav' => array( |
|
185 | + 'label' => __('Admin Options', 'event_espresso'), |
|
186 | + 'order' => 60, |
|
187 | + ), |
|
188 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
189 | + 'help_tabs' => array( |
|
190 | + 'general_settings_admin_options_help_tab' => array( |
|
191 | + 'title' => __('Admin Options', 'event_espresso'), |
|
192 | + 'filename' => 'general_settings_admin_options', |
|
193 | + ), |
|
194 | + ), |
|
195 | + 'help_tour' => array('Admin_Options_Help_Tour'), |
|
196 | + 'require_nonce' => false, |
|
197 | + ), |
|
198 | + 'country_settings' => array( |
|
199 | + 'nav' => array( |
|
200 | + 'label' => __('Countries', 'event_espresso'), |
|
201 | + 'order' => 70, |
|
202 | + ), |
|
203 | + 'help_tabs' => array( |
|
204 | + 'general_settings_countries_help_tab' => array( |
|
205 | + 'title' => __('Countries', 'event_espresso'), |
|
206 | + 'filename' => 'general_settings_countries', |
|
207 | + ), |
|
208 | + ), |
|
209 | + 'help_tour' => array('Countries_Help_Tour'), |
|
210 | + 'require_nonce' => false, |
|
211 | + ), |
|
212 | + 'privacy_settings' => array( |
|
213 | + 'nav' => array( |
|
214 | + 'label' => esc_html__('Privacy', 'event_espresso'), |
|
215 | + 'order' => 80 |
|
216 | + ), |
|
217 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
218 | + 'require_nonce' => false |
|
219 | + ) |
|
220 | + ); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + protected function _add_screen_options() |
|
225 | + { |
|
226 | + } |
|
227 | + |
|
228 | + protected function _add_feature_pointers() |
|
229 | + { |
|
230 | + } |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
235 | + */ |
|
236 | + public function load_scripts_styles() |
|
237 | + { |
|
238 | + // styles |
|
239 | + wp_enqueue_style('espresso-ui-theme'); |
|
240 | + // scripts |
|
241 | + wp_enqueue_script('ee_admin_js'); |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * Execute logic running on `admin_init` |
|
247 | + */ |
|
248 | + public function admin_init() |
|
249 | + { |
|
250 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = __( |
|
251 | + '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.', |
|
252 | + 'event_espresso' |
|
253 | + ); |
|
254 | + EE_Registry::$i18n_js_strings['error_occurred'] = __( |
|
255 | + 'An error occurred! Please refresh the page and try again.', |
|
256 | + 'event_espresso' |
|
257 | + ); |
|
258 | + EE_Registry::$i18n_js_strings['confirm_delete_state'] = __( |
|
259 | + 'Are you sure you want to delete this State / Province?', |
|
260 | + 'event_espresso' |
|
261 | + ); |
|
262 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
263 | + EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
264 | + 'admin-ajax.php?page=espresso_general_settings', |
|
265 | + $protocol |
|
266 | + ); |
|
267 | + } |
|
268 | + |
|
269 | + public function admin_notices() |
|
270 | + { |
|
271 | + } |
|
272 | + |
|
273 | + public function admin_footer_scripts() |
|
274 | + { |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * Enqueue scripts and styles for the default route. |
|
280 | + */ |
|
281 | + public function load_scripts_styles_default() |
|
282 | + { |
|
283 | + // styles |
|
284 | + wp_enqueue_style('thickbox'); |
|
285 | + // scripts |
|
286 | + wp_enqueue_script('media-upload'); |
|
287 | + wp_enqueue_script('thickbox'); |
|
288 | + wp_register_script( |
|
289 | + 'organization_settings', |
|
290 | + GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
291 | + array('jquery', 'media-upload', 'thickbox'), |
|
292 | + EVENT_ESPRESSO_VERSION, |
|
293 | + true |
|
294 | + ); |
|
295 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
296 | + wp_enqueue_script('organization_settings'); |
|
297 | + wp_enqueue_style('organization-css'); |
|
298 | + $confirm_image_delete = array( |
|
299 | + 'text' => __( |
|
300 | + 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
301 | + 'event_espresso' |
|
302 | + ), |
|
303 | + ); |
|
304 | + wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * Enqueue scripts and styles for the country settings route. |
|
310 | + */ |
|
311 | + public function load_scripts_styles_country_settings() |
|
312 | + { |
|
313 | + // scripts |
|
314 | + wp_register_script( |
|
315 | + 'gen_settings_countries', |
|
316 | + GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
317 | + array('ee_admin_js'), |
|
318 | + EVENT_ESPRESSO_VERSION, |
|
319 | + true |
|
320 | + ); |
|
321 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
322 | + wp_enqueue_script('gen_settings_countries'); |
|
323 | + wp_enqueue_style('organization-css'); |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + /************* Espresso Pages *************/ |
|
328 | + /** |
|
329 | + * _espresso_page_settings |
|
330 | + * |
|
331 | + * @throws \EE_Error |
|
332 | + */ |
|
333 | + protected function _espresso_page_settings() |
|
334 | + { |
|
335 | + // Check to make sure all of the main pages are setup properly, |
|
336 | + // if not create the default pages and display an admin notice |
|
337 | + EEH_Activation::verify_default_pages_exist(); |
|
338 | + $this->_transient_garbage_collection(); |
|
339 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
340 | + $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
341 | + ? EE_Registry::instance()->CFG->core->reg_page_id |
|
342 | + : null; |
|
343 | + $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
344 | + ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) |
|
345 | + : false; |
|
346 | + $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
347 | + ? EE_Registry::instance()->CFG->core->txn_page_id |
|
348 | + : null; |
|
349 | + $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
350 | + ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) |
|
351 | + : false; |
|
352 | + $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
353 | + ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
354 | + : null; |
|
355 | + $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
356 | + ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
357 | + : false; |
|
358 | + $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
359 | + ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
360 | + : null; |
|
361 | + $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
362 | + ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
363 | + : false; |
|
364 | + $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
365 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
366 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
367 | + GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
368 | + $this->_template_args, |
|
369 | + true |
|
370 | + ); |
|
371 | + $this->display_admin_page_with_sidebar(); |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * Handler for updating espresso page settings. |
|
377 | + */ |
|
378 | + protected function _update_espresso_page_settings() |
|
379 | + { |
|
380 | + // capture incoming request data && set page IDs |
|
381 | + EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
382 | + ? absint($this->_req_data['reg_page_id']) |
|
383 | + : EE_Registry::instance()->CFG->core->reg_page_id; |
|
384 | + EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
385 | + ? absint($this->_req_data['txn_page_id']) |
|
386 | + : EE_Registry::instance()->CFG->core->txn_page_id; |
|
387 | + EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
388 | + ? absint($this->_req_data['thank_you_page_id']) |
|
389 | + : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
390 | + EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
391 | + ? absint($this->_req_data['cancel_page_id']) |
|
392 | + : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
393 | + |
|
394 | + EE_Registry::instance()->CFG->core = apply_filters( |
|
395 | + 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
396 | + EE_Registry::instance()->CFG->core, |
|
397 | + $this->_req_data |
|
398 | + ); |
|
399 | + $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
400 | + $this->_redirect_after_action( |
|
401 | + $this->_update_espresso_configuration( |
|
402 | + $what, |
|
403 | + EE_Registry::instance()->CFG->core, |
|
404 | + __FILE__, |
|
405 | + __FUNCTION__, |
|
406 | + __LINE__ |
|
407 | + ), |
|
408 | + $what, |
|
409 | + '', |
|
410 | + array( |
|
411 | + 'action' => 'critical_pages', |
|
412 | + ), |
|
413 | + true |
|
414 | + ); |
|
415 | + } |
|
416 | + |
|
417 | + |
|
418 | + /************* Your Organization *************/ |
|
419 | + |
|
420 | + |
|
421 | + protected function _your_organization_settings() |
|
422 | + { |
|
423 | + $this->_template_args['admin_page_content'] = ''; |
|
424 | + try { |
|
425 | + $organization_settings_form = new OrganizationSettings(EE_Registry::instance()); |
|
426 | + $this->_template_args['admin_page_content'] = $organization_settings_form->display(); |
|
427 | + } catch (Exception $e) { |
|
428 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
429 | + } |
|
430 | + $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
431 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
432 | + $this->display_admin_page_with_sidebar(); |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + |
|
437 | + /** |
|
438 | + * Handler for updating organization settings. |
|
439 | + * |
|
440 | + * @throws EE_Error |
|
441 | + */ |
|
442 | + protected function _update_your_organization_settings() |
|
443 | + { |
|
444 | + try { |
|
445 | + $organization_settings_form = new OrganizationSettings(EE_Registry::instance()); |
|
446 | + $success = $organization_settings_form->process($this->_req_data); |
|
447 | + EE_Registry::instance()->CFG = apply_filters( |
|
448 | + 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
449 | + EE_Registry::instance()->CFG |
|
450 | + ); |
|
451 | + } catch (Exception $e) { |
|
452 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
453 | + $success = false; |
|
454 | + } |
|
455 | + |
|
456 | + if ($success) { |
|
457 | + $success = $this->_update_espresso_configuration( |
|
458 | + esc_html__('Your Organization Settings', 'event_espresso'), |
|
459 | + EE_Registry::instance()->CFG, |
|
460 | + __FILE__, |
|
461 | + __FUNCTION__, |
|
462 | + __LINE__ |
|
463 | + ); |
|
464 | + } |
|
465 | + |
|
466 | + $this->_redirect_after_action($success, '', '', array('action' => 'default'), true); |
|
467 | + } |
|
468 | + |
|
469 | + |
|
470 | + |
|
471 | + /************* Admin Options *************/ |
|
472 | + |
|
473 | + |
|
474 | + /** |
|
475 | + * _admin_option_settings |
|
476 | + * |
|
477 | + * @throws \EE_Error |
|
478 | + * @throws \LogicException |
|
479 | + */ |
|
480 | + protected function _admin_option_settings() |
|
481 | + { |
|
482 | + $this->_template_args['admin_page_content'] = ''; |
|
483 | + try { |
|
484 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
485 | + // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
486 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
487 | + // also need to account for the do_action that was in the old template |
|
488 | + $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
489 | + $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
490 | + } catch (Exception $e) { |
|
491 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
492 | + } |
|
493 | + $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
494 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
495 | + $this->display_admin_page_with_sidebar(); |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * _update_admin_option_settings |
|
501 | + * |
|
502 | + * @throws \EE_Error |
|
503 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
504 | + * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException |
|
505 | + * @throws \InvalidArgumentException |
|
506 | + * @throws \LogicException |
|
507 | + */ |
|
508 | + protected function _update_admin_option_settings() |
|
509 | + { |
|
510 | + try { |
|
511 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
512 | + $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
513 | + EE_Registry::instance()->CFG->admin = apply_filters( |
|
514 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
515 | + EE_Registry::instance()->CFG->admin |
|
516 | + ); |
|
517 | + } catch (Exception $e) { |
|
518 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
519 | + } |
|
520 | + $this->_redirect_after_action( |
|
521 | + apply_filters( |
|
522 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
523 | + $this->_update_espresso_configuration( |
|
524 | + 'Admin Options', |
|
525 | + EE_Registry::instance()->CFG->admin, |
|
526 | + __FILE__, |
|
527 | + __FUNCTION__, |
|
528 | + __LINE__ |
|
529 | + ) |
|
530 | + ), |
|
531 | + 'Admin Options', |
|
532 | + 'updated', |
|
533 | + array('action' => 'admin_option_settings') |
|
534 | + ); |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + /************* Countries *************/ |
|
539 | + |
|
540 | + |
|
541 | + /** |
|
542 | + * Output Country Settings view. |
|
543 | + * |
|
544 | + * @throws DomainException |
|
545 | + * @throws EE_Error |
|
546 | + */ |
|
547 | + protected function _country_settings() |
|
548 | + { |
|
549 | + $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
550 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
551 | + : 'US'; |
|
552 | + $CNT_ISO = isset($this->_req_data['country']) |
|
553 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
554 | + : $CNT_ISO; |
|
555 | + |
|
556 | + // load field generator helper |
|
557 | + |
|
558 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
559 | + |
|
560 | + $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
561 | + EE_Question::new_instance( |
|
562 | + array( |
|
563 | + 'QST_ID' => 0, |
|
564 | + 'QST_display_text' => __('Select Country', 'event_espresso'), |
|
565 | + 'QST_system' => 'admin-country', |
|
566 | + ) |
|
567 | + ), |
|
568 | + EE_Answer::new_instance( |
|
569 | + array( |
|
570 | + 'ANS_ID' => 0, |
|
571 | + 'ANS_value' => $CNT_ISO, |
|
572 | + ) |
|
573 | + ), |
|
574 | + array( |
|
575 | + 'input_id' => 'country', |
|
576 | + 'input_name' => 'country', |
|
577 | + 'input_prefix' => '', |
|
578 | + 'append_qstn_id' => false, |
|
579 | + ) |
|
580 | + ); |
|
581 | + |
|
582 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
583 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
584 | + $this->_template_args['country_details_settings'] = $this->display_country_settings(); |
|
585 | + $this->_template_args['country_states_settings'] = $this->display_country_states(); |
|
586 | + |
|
587 | + $this->_set_add_edit_form_tags('update_country_settings'); |
|
588 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
589 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
590 | + GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
591 | + $this->_template_args, |
|
592 | + true |
|
593 | + ); |
|
594 | + $this->display_admin_page_with_no_sidebar(); |
|
595 | + } |
|
596 | + |
|
597 | + |
|
598 | + /** |
|
599 | + * display_country_settings |
|
600 | + * |
|
601 | + * @access public |
|
602 | + * @param string $CNT_ISO |
|
603 | + * @return mixed string | array |
|
604 | + * @throws DomainException |
|
605 | + */ |
|
606 | + public function display_country_settings($CNT_ISO = '') |
|
607 | + { |
|
608 | + |
|
609 | + $CNT_ISO = isset($this->_req_data['country']) |
|
610 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
611 | + : $CNT_ISO; |
|
612 | + if (! $CNT_ISO) { |
|
613 | + return ''; |
|
614 | + } |
|
615 | + |
|
616 | + // for ajax |
|
617 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
618 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
619 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
620 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
621 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
622 | + |
|
623 | + $country_input_types = array( |
|
624 | + 'CNT_active' => array( |
|
625 | + 'type' => 'RADIO_BTN', |
|
626 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
627 | + 'class' => '', |
|
628 | + 'options' => $this->_yes_no_values, |
|
629 | + 'use_desc_4_label' => true, |
|
630 | + ), |
|
631 | + 'CNT_ISO' => array( |
|
632 | + 'type' => 'TEXT', |
|
633 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
634 | + 'class' => 'small-text', |
|
635 | + ), |
|
636 | + 'CNT_ISO3' => array( |
|
637 | + 'type' => 'TEXT', |
|
638 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
639 | + 'class' => 'small-text', |
|
640 | + ), |
|
641 | + 'RGN_ID' => array( |
|
642 | + 'type' => 'TEXT', |
|
643 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
644 | + 'class' => 'small-text', |
|
645 | + ), |
|
646 | + 'CNT_name' => array( |
|
647 | + 'type' => 'TEXT', |
|
648 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
649 | + 'class' => 'regular-text', |
|
650 | + ), |
|
651 | + 'CNT_cur_code' => array( |
|
652 | + 'type' => 'TEXT', |
|
653 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
654 | + 'class' => 'small-text', |
|
655 | + ), |
|
656 | + 'CNT_cur_single' => array( |
|
657 | + 'type' => 'TEXT', |
|
658 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
659 | + 'class' => 'medium-text', |
|
660 | + ), |
|
661 | + 'CNT_cur_plural' => array( |
|
662 | + 'type' => 'TEXT', |
|
663 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
664 | + 'class' => 'medium-text', |
|
665 | + ), |
|
666 | + 'CNT_cur_sign' => array( |
|
667 | + 'type' => 'TEXT', |
|
668 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
669 | + 'class' => 'small-text', |
|
670 | + 'htmlentities' => false, |
|
671 | + ), |
|
672 | + 'CNT_cur_sign_b4' => array( |
|
673 | + 'type' => 'RADIO_BTN', |
|
674 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
675 | + 'class' => '', |
|
676 | + 'options' => $this->_yes_no_values, |
|
677 | + 'use_desc_4_label' => true, |
|
678 | + ), |
|
679 | + 'CNT_cur_dec_plc' => array( |
|
680 | + 'type' => 'RADIO_BTN', |
|
681 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
682 | + 'class' => '', |
|
683 | + 'options' => array( |
|
684 | + array('id' => 0, 'text' => ''), |
|
685 | + array('id' => 1, 'text' => ''), |
|
686 | + array('id' => 2, 'text' => ''), |
|
687 | + array('id' => 3, 'text' => ''), |
|
688 | + ), |
|
689 | + ), |
|
690 | + 'CNT_cur_dec_mrk' => array( |
|
691 | + 'type' => 'RADIO_BTN', |
|
692 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
693 | + 'class' => '', |
|
694 | + 'options' => array( |
|
695 | + array( |
|
696 | + 'id' => ',', |
|
697 | + 'text' => __(', (comma)', 'event_espresso'), |
|
698 | + ), |
|
699 | + array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
700 | + ), |
|
701 | + 'use_desc_4_label' => true, |
|
702 | + ), |
|
703 | + 'CNT_cur_thsnds' => array( |
|
704 | + 'type' => 'RADIO_BTN', |
|
705 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
706 | + 'class' => '', |
|
707 | + 'options' => array( |
|
708 | + array( |
|
709 | + 'id' => ',', |
|
710 | + 'text' => __(', (comma)', 'event_espresso'), |
|
711 | + ), |
|
712 | + array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
713 | + ), |
|
714 | + 'use_desc_4_label' => true, |
|
715 | + ), |
|
716 | + 'CNT_tel_code' => array( |
|
717 | + 'type' => 'TEXT', |
|
718 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
719 | + 'class' => 'small-text', |
|
720 | + ), |
|
721 | + 'CNT_is_EU' => array( |
|
722 | + 'type' => 'RADIO_BTN', |
|
723 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
724 | + 'class' => '', |
|
725 | + 'options' => $this->_yes_no_values, |
|
726 | + 'use_desc_4_label' => true, |
|
727 | + ), |
|
728 | + ); |
|
729 | + $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
730 | + $country, |
|
731 | + $country_input_types |
|
732 | + ); |
|
733 | + $country_details_settings = EEH_Template::display_template( |
|
734 | + GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
735 | + $this->_template_args, |
|
736 | + true |
|
737 | + ); |
|
738 | + |
|
739 | + if (defined('DOING_AJAX')) { |
|
740 | + $notices = EE_Error::get_notices(false, false, false); |
|
741 | + echo wp_json_encode( |
|
742 | + array( |
|
743 | + 'return_data' => $country_details_settings, |
|
744 | + 'success' => $notices['success'], |
|
745 | + 'errors' => $notices['errors'], |
|
746 | + ) |
|
747 | + ); |
|
748 | + die(); |
|
749 | + } else { |
|
750 | + return $country_details_settings; |
|
751 | + } |
|
752 | + } |
|
753 | + |
|
754 | + |
|
755 | + /** |
|
756 | + * display_country_states |
|
757 | + * |
|
758 | + * @access public |
|
759 | + * @param string $CNT_ISO |
|
760 | + * @return string |
|
761 | + * @throws DomainException |
|
762 | + */ |
|
763 | + public function display_country_states($CNT_ISO = '') |
|
764 | + { |
|
765 | + |
|
766 | + $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
|
767 | + |
|
768 | + if (! $CNT_ISO) { |
|
769 | + return ''; |
|
770 | + } |
|
771 | + // for ajax |
|
772 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
773 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
774 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); |
|
775 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); |
|
776 | + $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); |
|
777 | + |
|
778 | + if ($states) { |
|
779 | + foreach ($states as $STA_ID => $state) { |
|
780 | + if ($state instanceof EE_State) { |
|
781 | + // STA_abbrev STA_name STA_active |
|
782 | + $state_input_types = array( |
|
783 | + 'STA_abbrev' => array( |
|
784 | + 'type' => 'TEXT', |
|
785 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
786 | + 'class' => 'mid-text', |
|
787 | + ), |
|
788 | + 'STA_name' => array( |
|
789 | + 'type' => 'TEXT', |
|
790 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
791 | + 'class' => 'regular-text', |
|
792 | + ), |
|
793 | + 'STA_active' => array( |
|
794 | + 'type' => 'RADIO_BTN', |
|
795 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
796 | + 'options' => $this->_yes_no_values, |
|
797 | + 'use_desc_4_label' => true, |
|
798 | + ), |
|
799 | + ); |
|
800 | + $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
801 | + EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
802 | + $state, |
|
803 | + $state_input_types |
|
804 | + ); |
|
805 | + $query_args = array( |
|
806 | + 'action' => 'delete_state', |
|
807 | + 'STA_ID' => $STA_ID, |
|
808 | + 'CNT_ISO' => $CNT_ISO, |
|
809 | + 'STA_abbrev' => $state->abbrev(), |
|
810 | + ); |
|
811 | + $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
812 | + EE_Admin_Page::add_query_args_and_nonce( |
|
813 | + $query_args, |
|
814 | + GEN_SET_ADMIN_URL |
|
815 | + ); |
|
816 | + } |
|
817 | + } |
|
818 | + } else { |
|
819 | + $this->_template_args['states'] = false; |
|
820 | + } |
|
821 | + |
|
822 | + $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
823 | + array('action' => 'add_new_state'), |
|
824 | + GEN_SET_ADMIN_URL |
|
825 | + ); |
|
826 | + |
|
827 | + $state_details_settings = EEH_Template::display_template( |
|
828 | + GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
829 | + $this->_template_args, |
|
830 | + true |
|
831 | + ); |
|
832 | + |
|
833 | + if (defined('DOING_AJAX')) { |
|
834 | + $notices = EE_Error::get_notices(false, false, false); |
|
835 | + echo wp_json_encode( |
|
836 | + array( |
|
837 | + 'return_data' => $state_details_settings, |
|
838 | + 'success' => $notices['success'], |
|
839 | + 'errors' => $notices['errors'], |
|
840 | + ) |
|
841 | + ); |
|
842 | + die(); |
|
843 | + } else { |
|
844 | + return $state_details_settings; |
|
845 | + } |
|
846 | + } |
|
847 | + |
|
848 | + |
|
849 | + /** |
|
850 | + * add_new_state |
|
851 | + * |
|
852 | + * @access public |
|
853 | + * @return void |
|
854 | + * @throws EE_Error |
|
855 | + */ |
|
856 | + public function add_new_state() |
|
857 | + { |
|
858 | + |
|
859 | + $success = true; |
|
860 | + |
|
861 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
862 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
863 | + : false; |
|
864 | + if (! $CNT_ISO) { |
|
865 | + EE_Error::add_error( |
|
866 | + __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
867 | + __FILE__, |
|
868 | + __FUNCTION__, |
|
869 | + __LINE__ |
|
870 | + ); |
|
871 | + $success = false; |
|
872 | + } |
|
873 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
874 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
875 | + : false; |
|
876 | + if (! $STA_abbrev) { |
|
877 | + EE_Error::add_error( |
|
878 | + __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
879 | + __FILE__, |
|
880 | + __FUNCTION__, |
|
881 | + __LINE__ |
|
882 | + ); |
|
883 | + $success = false; |
|
884 | + } |
|
885 | + $STA_name = isset($this->_req_data['STA_name']) |
|
886 | + ? sanitize_text_field($this->_req_data['STA_name']) |
|
887 | + : false; |
|
888 | + if (! $STA_name) { |
|
889 | + EE_Error::add_error( |
|
890 | + __('No State name or an invalid State name was received.', 'event_espresso'), |
|
891 | + __FILE__, |
|
892 | + __FUNCTION__, |
|
893 | + __LINE__ |
|
894 | + ); |
|
895 | + $success = false; |
|
896 | + } |
|
897 | + |
|
898 | + if ($success) { |
|
899 | + $cols_n_values = array( |
|
900 | + 'CNT_ISO' => $CNT_ISO, |
|
901 | + 'STA_abbrev' => $STA_abbrev, |
|
902 | + 'STA_name' => $STA_name, |
|
903 | + 'STA_active' => true, |
|
904 | + ); |
|
905 | + $success = EEM_State::instance()->insert($cols_n_values); |
|
906 | + EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
|
907 | + } |
|
908 | + |
|
909 | + if (defined('DOING_AJAX')) { |
|
910 | + $notices = EE_Error::get_notices(false, false, false); |
|
911 | + echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO))); |
|
912 | + die(); |
|
913 | + } else { |
|
914 | + $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings')); |
|
915 | + } |
|
916 | + } |
|
917 | + |
|
918 | + |
|
919 | + /** |
|
920 | + * delete_state |
|
921 | + * |
|
922 | + * @access public |
|
923 | + * @return boolean |
|
924 | + */ |
|
925 | + public function delete_state() |
|
926 | + { |
|
927 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
928 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
929 | + : false; |
|
930 | + $STA_ID = isset($this->_req_data['STA_ID']) |
|
931 | + ? sanitize_text_field($this->_req_data['STA_ID']) |
|
932 | + : false; |
|
933 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
934 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
935 | + : false; |
|
936 | + if (! $STA_ID) { |
|
937 | + EE_Error::add_error( |
|
938 | + __('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
939 | + __FILE__, |
|
940 | + __FUNCTION__, |
|
941 | + __LINE__ |
|
942 | + ); |
|
943 | + return false; |
|
944 | + } |
|
945 | + |
|
946 | + $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
947 | + if ($success !== false) { |
|
948 | + do_action( |
|
949 | + 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
950 | + $CNT_ISO, |
|
951 | + $STA_ID, |
|
952 | + array('STA_abbrev' => $STA_abbrev) |
|
953 | + ); |
|
954 | + EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso')); |
|
955 | + } |
|
956 | + if (defined('DOING_AJAX')) { |
|
957 | + $notices = EE_Error::get_notices(false, false); |
|
958 | + $notices['return_data'] = true; |
|
959 | + echo wp_json_encode($notices); |
|
960 | + die(); |
|
961 | + } else { |
|
962 | + $this->_redirect_after_action( |
|
963 | + $success, |
|
964 | + 'State', |
|
965 | + 'deleted', |
|
966 | + array('action' => 'country_settings') |
|
967 | + ); |
|
968 | + } |
|
969 | + } |
|
970 | + |
|
971 | + |
|
972 | + /** |
|
973 | + * _update_country_settings |
|
974 | + * |
|
975 | + * @access protected |
|
976 | + * @return void |
|
977 | + * @throws EE_Error |
|
978 | + */ |
|
979 | + protected function _update_country_settings() |
|
980 | + { |
|
981 | + // grab the country ISO code |
|
982 | + $CNT_ISO = isset($this->_req_data['country']) |
|
983 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
984 | + : false; |
|
985 | + if (! $CNT_ISO) { |
|
986 | + EE_Error::add_error( |
|
987 | + __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
988 | + __FILE__, |
|
989 | + __FUNCTION__, |
|
990 | + __LINE__ |
|
991 | + ); |
|
992 | + |
|
993 | + return; |
|
994 | + } |
|
995 | + $cols_n_values = array(); |
|
996 | + $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
997 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
998 | + : false; |
|
999 | + $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1000 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1001 | + : null; |
|
1002 | + $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1003 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1004 | + : null; |
|
1005 | + $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
1006 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) |
|
1007 | + : 'USD'; |
|
1008 | + $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1009 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1010 | + : 'dollar'; |
|
1011 | + $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1012 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1013 | + : 'dollars'; |
|
1014 | + $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1015 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1016 | + : '$'; |
|
1017 | + $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1018 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1019 | + : true; |
|
1020 | + $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1021 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1022 | + : 2; |
|
1023 | + $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1024 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1025 | + : '.'; |
|
1026 | + $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1027 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1028 | + : ','; |
|
1029 | + $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1030 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1031 | + : null; |
|
1032 | + $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1033 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1034 | + : false; |
|
1035 | + $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1036 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1037 | + : false; |
|
1038 | + // allow filtering of country data |
|
1039 | + $cols_n_values = apply_filters( |
|
1040 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
1041 | + $cols_n_values |
|
1042 | + ); |
|
1043 | + |
|
1044 | + // where values |
|
1045 | + $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO)); |
|
1046 | + // run the update |
|
1047 | + $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
1048 | + |
|
1049 | + if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
1050 | + // allow filtering of states data |
|
1051 | + $states = apply_filters( |
|
1052 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
1053 | + $this->_req_data['states'] |
|
1054 | + ); |
|
1055 | + |
|
1056 | + // loop thru state data ( looks like : states[75][STA_name] ) |
|
1057 | + foreach ($states as $STA_ID => $state) { |
|
1058 | + $cols_n_values = array( |
|
1059 | + 'CNT_ISO' => $CNT_ISO, |
|
1060 | + 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
1061 | + 'STA_name' => sanitize_text_field($state['STA_name']), |
|
1062 | + 'STA_active' => (bool) absint($state['STA_active']), |
|
1063 | + ); |
|
1064 | + // where values |
|
1065 | + $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
1066 | + // run the update |
|
1067 | + $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
1068 | + if ($success !== false) { |
|
1069 | + do_action( |
|
1070 | + 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
1071 | + $CNT_ISO, |
|
1072 | + $STA_ID, |
|
1073 | + $cols_n_values |
|
1074 | + ); |
|
1075 | + } |
|
1076 | + } |
|
1077 | + } |
|
1078 | + // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
1079 | + if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
1080 | + && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
1081 | + ) { |
|
1082 | + EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
1083 | + EE_Registry::instance()->CFG->update_espresso_config(); |
|
1084 | + } |
|
1085 | + |
|
1086 | + if ($success !== false) { |
|
1087 | + EE_Error::add_success( |
|
1088 | + esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
1089 | + ); |
|
1090 | + } |
|
1091 | + $this->_redirect_after_action( |
|
1092 | + $success, |
|
1093 | + '', |
|
1094 | + '', |
|
1095 | + array('action' => 'country_settings', 'country' => $CNT_ISO), |
|
1096 | + true |
|
1097 | + ); |
|
1098 | + } |
|
1099 | + |
|
1100 | + |
|
1101 | + /** |
|
1102 | + * form_form_field_label_wrap |
|
1103 | + * |
|
1104 | + * @access public |
|
1105 | + * @param string $label |
|
1106 | + * @return string |
|
1107 | + */ |
|
1108 | + public function country_form_field_label_wrap($label, $required_text) |
|
1109 | + { |
|
1110 | + return ' |
|
1111 | 1111 | <tr> |
1112 | 1112 | <th> |
1113 | 1113 | ' . $label . ' |
1114 | 1114 | </th>'; |
1115 | - } |
|
1116 | - |
|
1117 | - |
|
1118 | - /** |
|
1119 | - * form_form_field_input__wrap |
|
1120 | - * |
|
1121 | - * @access public |
|
1122 | - * @param string $label |
|
1123 | - * @return string |
|
1124 | - */ |
|
1125 | - public function country_form_field_input__wrap($input, $label) |
|
1126 | - { |
|
1127 | - return ' |
|
1115 | + } |
|
1116 | + |
|
1117 | + |
|
1118 | + /** |
|
1119 | + * form_form_field_input__wrap |
|
1120 | + * |
|
1121 | + * @access public |
|
1122 | + * @param string $label |
|
1123 | + * @return string |
|
1124 | + */ |
|
1125 | + public function country_form_field_input__wrap($input, $label) |
|
1126 | + { |
|
1127 | + return ' |
|
1128 | 1128 | <td class="general-settings-country-input-td"> |
1129 | 1129 | ' . $input . ' |
1130 | 1130 | </td> |
1131 | 1131 | </tr>'; |
1132 | - } |
|
1133 | - |
|
1134 | - |
|
1135 | - /** |
|
1136 | - * form_form_field_label_wrap |
|
1137 | - * |
|
1138 | - * @access public |
|
1139 | - * @param string $label |
|
1140 | - * @param string $required_text |
|
1141 | - * @return string |
|
1142 | - */ |
|
1143 | - public function state_form_field_label_wrap($label, $required_text) |
|
1144 | - { |
|
1145 | - return $required_text; |
|
1146 | - } |
|
1147 | - |
|
1148 | - |
|
1149 | - /** |
|
1150 | - * form_form_field_input__wrap |
|
1151 | - * |
|
1152 | - * @access public |
|
1153 | - * @param string $label |
|
1154 | - * @return string |
|
1155 | - */ |
|
1156 | - public function state_form_field_input__wrap($input, $label) |
|
1157 | - { |
|
1158 | - return ' |
|
1132 | + } |
|
1133 | + |
|
1134 | + |
|
1135 | + /** |
|
1136 | + * form_form_field_label_wrap |
|
1137 | + * |
|
1138 | + * @access public |
|
1139 | + * @param string $label |
|
1140 | + * @param string $required_text |
|
1141 | + * @return string |
|
1142 | + */ |
|
1143 | + public function state_form_field_label_wrap($label, $required_text) |
|
1144 | + { |
|
1145 | + return $required_text; |
|
1146 | + } |
|
1147 | + |
|
1148 | + |
|
1149 | + /** |
|
1150 | + * form_form_field_input__wrap |
|
1151 | + * |
|
1152 | + * @access public |
|
1153 | + * @param string $label |
|
1154 | + * @return string |
|
1155 | + */ |
|
1156 | + public function state_form_field_input__wrap($input, $label) |
|
1157 | + { |
|
1158 | + return ' |
|
1159 | 1159 | <td class="general-settings-country-state-input-td"> |
1160 | 1160 | ' . $input . ' |
1161 | 1161 | </td>'; |
1162 | - } |
|
1163 | - |
|
1164 | - |
|
1165 | - /***********/ |
|
1166 | - |
|
1167 | - |
|
1168 | - /** |
|
1169 | - * displays edit and view links for critical EE pages |
|
1170 | - * |
|
1171 | - * @access public |
|
1172 | - * @param int $ee_page_id |
|
1173 | - * @return string |
|
1174 | - */ |
|
1175 | - public static function edit_view_links($ee_page_id) |
|
1176 | - { |
|
1177 | - $links = '<a href="' |
|
1178 | - . add_query_arg( |
|
1179 | - array('post' => $ee_page_id, 'action' => 'edit'), |
|
1180 | - admin_url('post.php') |
|
1181 | - ) |
|
1182 | - . '" >' |
|
1183 | - . __('Edit', 'event_espresso') |
|
1184 | - . '</a>'; |
|
1185 | - $links .= ' | '; |
|
1186 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1187 | - |
|
1188 | - return $links; |
|
1189 | - } |
|
1190 | - |
|
1191 | - |
|
1192 | - /** |
|
1193 | - * displays page and shortcode status for critical EE pages |
|
1194 | - * |
|
1195 | - * @param WP page object $ee_page |
|
1196 | - * @return string |
|
1197 | - */ |
|
1198 | - public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1199 | - { |
|
1200 | - |
|
1201 | - // page status |
|
1202 | - if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1203 | - $pg_colour = 'green'; |
|
1204 | - $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1205 | - } else { |
|
1206 | - $pg_colour = 'red'; |
|
1207 | - $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1208 | - } |
|
1209 | - |
|
1210 | - // shortcode status |
|
1211 | - if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1212 | - $sc_colour = 'green'; |
|
1213 | - $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1214 | - } else { |
|
1215 | - $sc_colour = 'red'; |
|
1216 | - $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1217 | - } |
|
1218 | - |
|
1219 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1220 | - . $pg_status |
|
1221 | - . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1222 | - } |
|
1223 | - |
|
1224 | - |
|
1225 | - /** |
|
1226 | - * generates a dropdown of all parent pages - copied from WP core |
|
1227 | - * |
|
1228 | - * @param int $default |
|
1229 | - * @param int $parent |
|
1230 | - * @param int $level |
|
1231 | - */ |
|
1232 | - public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) |
|
1233 | - { |
|
1234 | - global $wpdb; |
|
1235 | - $items = $wpdb->get_results( |
|
1236 | - $wpdb->prepare( |
|
1237 | - "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", |
|
1238 | - $parent |
|
1239 | - ) |
|
1240 | - ); |
|
1241 | - |
|
1242 | - if ($items) { |
|
1243 | - foreach ($items as $item) { |
|
1244 | - $pad = str_repeat(' ', $level * 3); |
|
1245 | - if ($item->ID == $default) { |
|
1246 | - $current = ' selected="selected"'; |
|
1247 | - } else { |
|
1248 | - $current = ''; |
|
1249 | - } |
|
1250 | - |
|
1251 | - echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " |
|
1252 | - . esc_html($item->post_title) |
|
1253 | - . "</option>"; |
|
1254 | - parent_dropdown($default, $item->ID, $level + 1); |
|
1255 | - } |
|
1256 | - } |
|
1257 | - } |
|
1258 | - |
|
1259 | - |
|
1260 | - /** |
|
1261 | - * Loads the scripts for the privacy settings form |
|
1262 | - */ |
|
1263 | - public function load_scripts_styles_privacy_settings() |
|
1264 | - { |
|
1265 | - $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1266 | - $form_handler->enqueueStylesAndScripts(); |
|
1267 | - } |
|
1268 | - |
|
1269 | - |
|
1270 | - /** |
|
1271 | - * display the privacy settings form |
|
1272 | - */ |
|
1273 | - public function privacySettings() |
|
1274 | - { |
|
1275 | - $this->_set_add_edit_form_tags('update_privacy_settings'); |
|
1276 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1277 | - $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1278 | - $this->_template_args['admin_page_content'] = $form_handler->display(); |
|
1279 | - $this->display_admin_page_with_sidebar(); |
|
1280 | - } |
|
1281 | - |
|
1282 | - |
|
1283 | - /** |
|
1284 | - * Update the privacy settings from form data |
|
1285 | - */ |
|
1286 | - public function updatePrivacySettings() |
|
1287 | - { |
|
1288 | - $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1289 | - $success = $form_handler->process($this->get_request_data()); |
|
1290 | - $this->_redirect_after_action( |
|
1291 | - $success, |
|
1292 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1293 | - 'updated', |
|
1294 | - array('action' => 'privacy_settings') |
|
1295 | - ); |
|
1296 | - } |
|
1162 | + } |
|
1163 | + |
|
1164 | + |
|
1165 | + /***********/ |
|
1166 | + |
|
1167 | + |
|
1168 | + /** |
|
1169 | + * displays edit and view links for critical EE pages |
|
1170 | + * |
|
1171 | + * @access public |
|
1172 | + * @param int $ee_page_id |
|
1173 | + * @return string |
|
1174 | + */ |
|
1175 | + public static function edit_view_links($ee_page_id) |
|
1176 | + { |
|
1177 | + $links = '<a href="' |
|
1178 | + . add_query_arg( |
|
1179 | + array('post' => $ee_page_id, 'action' => 'edit'), |
|
1180 | + admin_url('post.php') |
|
1181 | + ) |
|
1182 | + . '" >' |
|
1183 | + . __('Edit', 'event_espresso') |
|
1184 | + . '</a>'; |
|
1185 | + $links .= ' | '; |
|
1186 | + $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1187 | + |
|
1188 | + return $links; |
|
1189 | + } |
|
1190 | + |
|
1191 | + |
|
1192 | + /** |
|
1193 | + * displays page and shortcode status for critical EE pages |
|
1194 | + * |
|
1195 | + * @param WP page object $ee_page |
|
1196 | + * @return string |
|
1197 | + */ |
|
1198 | + public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1199 | + { |
|
1200 | + |
|
1201 | + // page status |
|
1202 | + if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1203 | + $pg_colour = 'green'; |
|
1204 | + $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1205 | + } else { |
|
1206 | + $pg_colour = 'red'; |
|
1207 | + $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1208 | + } |
|
1209 | + |
|
1210 | + // shortcode status |
|
1211 | + if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1212 | + $sc_colour = 'green'; |
|
1213 | + $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1214 | + } else { |
|
1215 | + $sc_colour = 'red'; |
|
1216 | + $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1217 | + } |
|
1218 | + |
|
1219 | + return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1220 | + . $pg_status |
|
1221 | + . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1222 | + } |
|
1223 | + |
|
1224 | + |
|
1225 | + /** |
|
1226 | + * generates a dropdown of all parent pages - copied from WP core |
|
1227 | + * |
|
1228 | + * @param int $default |
|
1229 | + * @param int $parent |
|
1230 | + * @param int $level |
|
1231 | + */ |
|
1232 | + public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) |
|
1233 | + { |
|
1234 | + global $wpdb; |
|
1235 | + $items = $wpdb->get_results( |
|
1236 | + $wpdb->prepare( |
|
1237 | + "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", |
|
1238 | + $parent |
|
1239 | + ) |
|
1240 | + ); |
|
1241 | + |
|
1242 | + if ($items) { |
|
1243 | + foreach ($items as $item) { |
|
1244 | + $pad = str_repeat(' ', $level * 3); |
|
1245 | + if ($item->ID == $default) { |
|
1246 | + $current = ' selected="selected"'; |
|
1247 | + } else { |
|
1248 | + $current = ''; |
|
1249 | + } |
|
1250 | + |
|
1251 | + echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " |
|
1252 | + . esc_html($item->post_title) |
|
1253 | + . "</option>"; |
|
1254 | + parent_dropdown($default, $item->ID, $level + 1); |
|
1255 | + } |
|
1256 | + } |
|
1257 | + } |
|
1258 | + |
|
1259 | + |
|
1260 | + /** |
|
1261 | + * Loads the scripts for the privacy settings form |
|
1262 | + */ |
|
1263 | + public function load_scripts_styles_privacy_settings() |
|
1264 | + { |
|
1265 | + $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1266 | + $form_handler->enqueueStylesAndScripts(); |
|
1267 | + } |
|
1268 | + |
|
1269 | + |
|
1270 | + /** |
|
1271 | + * display the privacy settings form |
|
1272 | + */ |
|
1273 | + public function privacySettings() |
|
1274 | + { |
|
1275 | + $this->_set_add_edit_form_tags('update_privacy_settings'); |
|
1276 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1277 | + $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1278 | + $this->_template_args['admin_page_content'] = $form_handler->display(); |
|
1279 | + $this->display_admin_page_with_sidebar(); |
|
1280 | + } |
|
1281 | + |
|
1282 | + |
|
1283 | + /** |
|
1284 | + * Update the privacy settings from form data |
|
1285 | + */ |
|
1286 | + public function updatePrivacySettings() |
|
1287 | + { |
|
1288 | + $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1289 | + $success = $form_handler->process($this->get_request_data()); |
|
1290 | + $this->_redirect_after_action( |
|
1291 | + $success, |
|
1292 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1293 | + 'updated', |
|
1294 | + array('action' => 'privacy_settings') |
|
1295 | + ); |
|
1296 | + } |
|
1297 | 1297 | } |
@@ -287,12 +287,12 @@ discard block |
||
287 | 287 | wp_enqueue_script('thickbox'); |
288 | 288 | wp_register_script( |
289 | 289 | 'organization_settings', |
290 | - GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
290 | + GEN_SET_ASSETS_URL.'your_organization_settings.js', |
|
291 | 291 | array('jquery', 'media-upload', 'thickbox'), |
292 | 292 | EVENT_ESPRESSO_VERSION, |
293 | 293 | true |
294 | 294 | ); |
295 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
295 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
296 | 296 | wp_enqueue_script('organization_settings'); |
297 | 297 | wp_enqueue_style('organization-css'); |
298 | 298 | $confirm_image_delete = array( |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | // scripts |
314 | 314 | wp_register_script( |
315 | 315 | 'gen_settings_countries', |
316 | - GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
316 | + GEN_SET_ASSETS_URL.'gen_settings_countries.js', |
|
317 | 317 | array('ee_admin_js'), |
318 | 318 | EVENT_ESPRESSO_VERSION, |
319 | 319 | true |
320 | 320 | ); |
321 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
321 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
322 | 322 | wp_enqueue_script('gen_settings_countries'); |
323 | 323 | wp_enqueue_style('organization-css'); |
324 | 324 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
365 | 365 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
366 | 366 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
367 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
367 | + GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php', |
|
368 | 368 | $this->_template_args, |
369 | 369 | true |
370 | 370 | ); |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | { |
510 | 510 | try { |
511 | 511 | $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
512 | - $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
512 | + $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]); |
|
513 | 513 | EE_Registry::instance()->CFG->admin = apply_filters( |
514 | 514 | 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
515 | 515 | EE_Registry::instance()->CFG->admin |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | $this->_set_add_edit_form_tags('update_country_settings'); |
588 | 588 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
589 | 589 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
590 | - GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
590 | + GEN_SET_TEMPLATE_PATH.'countries_settings.template.php', |
|
591 | 591 | $this->_template_args, |
592 | 592 | true |
593 | 593 | ); |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | $CNT_ISO = isset($this->_req_data['country']) |
610 | 610 | ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
611 | 611 | : $CNT_ISO; |
612 | - if (! $CNT_ISO) { |
|
612 | + if ( ! $CNT_ISO) { |
|
613 | 613 | return ''; |
614 | 614 | } |
615 | 615 | |
@@ -623,62 +623,62 @@ discard block |
||
623 | 623 | $country_input_types = array( |
624 | 624 | 'CNT_active' => array( |
625 | 625 | 'type' => 'RADIO_BTN', |
626 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
626 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
627 | 627 | 'class' => '', |
628 | 628 | 'options' => $this->_yes_no_values, |
629 | 629 | 'use_desc_4_label' => true, |
630 | 630 | ), |
631 | 631 | 'CNT_ISO' => array( |
632 | 632 | 'type' => 'TEXT', |
633 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
633 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
634 | 634 | 'class' => 'small-text', |
635 | 635 | ), |
636 | 636 | 'CNT_ISO3' => array( |
637 | 637 | 'type' => 'TEXT', |
638 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
638 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
639 | 639 | 'class' => 'small-text', |
640 | 640 | ), |
641 | 641 | 'RGN_ID' => array( |
642 | 642 | 'type' => 'TEXT', |
643 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
643 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
644 | 644 | 'class' => 'small-text', |
645 | 645 | ), |
646 | 646 | 'CNT_name' => array( |
647 | 647 | 'type' => 'TEXT', |
648 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
648 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
649 | 649 | 'class' => 'regular-text', |
650 | 650 | ), |
651 | 651 | 'CNT_cur_code' => array( |
652 | 652 | 'type' => 'TEXT', |
653 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
653 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
654 | 654 | 'class' => 'small-text', |
655 | 655 | ), |
656 | 656 | 'CNT_cur_single' => array( |
657 | 657 | 'type' => 'TEXT', |
658 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
658 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
659 | 659 | 'class' => 'medium-text', |
660 | 660 | ), |
661 | 661 | 'CNT_cur_plural' => array( |
662 | 662 | 'type' => 'TEXT', |
663 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
663 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
664 | 664 | 'class' => 'medium-text', |
665 | 665 | ), |
666 | 666 | 'CNT_cur_sign' => array( |
667 | 667 | 'type' => 'TEXT', |
668 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
668 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
669 | 669 | 'class' => 'small-text', |
670 | 670 | 'htmlentities' => false, |
671 | 671 | ), |
672 | 672 | 'CNT_cur_sign_b4' => array( |
673 | 673 | 'type' => 'RADIO_BTN', |
674 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
674 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
675 | 675 | 'class' => '', |
676 | 676 | 'options' => $this->_yes_no_values, |
677 | 677 | 'use_desc_4_label' => true, |
678 | 678 | ), |
679 | 679 | 'CNT_cur_dec_plc' => array( |
680 | 680 | 'type' => 'RADIO_BTN', |
681 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
681 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
682 | 682 | 'class' => '', |
683 | 683 | 'options' => array( |
684 | 684 | array('id' => 0, 'text' => ''), |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | ), |
690 | 690 | 'CNT_cur_dec_mrk' => array( |
691 | 691 | 'type' => 'RADIO_BTN', |
692 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
692 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
693 | 693 | 'class' => '', |
694 | 694 | 'options' => array( |
695 | 695 | array( |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | ), |
703 | 703 | 'CNT_cur_thsnds' => array( |
704 | 704 | 'type' => 'RADIO_BTN', |
705 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
705 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
706 | 706 | 'class' => '', |
707 | 707 | 'options' => array( |
708 | 708 | array( |
@@ -715,12 +715,12 @@ discard block |
||
715 | 715 | ), |
716 | 716 | 'CNT_tel_code' => array( |
717 | 717 | 'type' => 'TEXT', |
718 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
718 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
719 | 719 | 'class' => 'small-text', |
720 | 720 | ), |
721 | 721 | 'CNT_is_EU' => array( |
722 | 722 | 'type' => 'RADIO_BTN', |
723 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
723 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
724 | 724 | 'class' => '', |
725 | 725 | 'options' => $this->_yes_no_values, |
726 | 726 | 'use_desc_4_label' => true, |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | $country_input_types |
732 | 732 | ); |
733 | 733 | $country_details_settings = EEH_Template::display_template( |
734 | - GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
734 | + GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php', |
|
735 | 735 | $this->_template_args, |
736 | 736 | true |
737 | 737 | ); |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | |
766 | 766 | $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
767 | 767 | |
768 | - if (! $CNT_ISO) { |
|
768 | + if ( ! $CNT_ISO) { |
|
769 | 769 | return ''; |
770 | 770 | } |
771 | 771 | // for ajax |
@@ -782,22 +782,22 @@ discard block |
||
782 | 782 | $state_input_types = array( |
783 | 783 | 'STA_abbrev' => array( |
784 | 784 | 'type' => 'TEXT', |
785 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
785 | + 'input_name' => 'states['.$STA_ID.']', |
|
786 | 786 | 'class' => 'mid-text', |
787 | 787 | ), |
788 | 788 | 'STA_name' => array( |
789 | 789 | 'type' => 'TEXT', |
790 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
790 | + 'input_name' => 'states['.$STA_ID.']', |
|
791 | 791 | 'class' => 'regular-text', |
792 | 792 | ), |
793 | 793 | 'STA_active' => array( |
794 | 794 | 'type' => 'RADIO_BTN', |
795 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
795 | + 'input_name' => 'states['.$STA_ID.']', |
|
796 | 796 | 'options' => $this->_yes_no_values, |
797 | 797 | 'use_desc_4_label' => true, |
798 | 798 | ), |
799 | 799 | ); |
800 | - $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
800 | + $this->_template_args['states'][$STA_ID]['inputs'] = |
|
801 | 801 | EE_Question_Form_Input::generate_question_form_inputs_for_object( |
802 | 802 | $state, |
803 | 803 | $state_input_types |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | 'CNT_ISO' => $CNT_ISO, |
809 | 809 | 'STA_abbrev' => $state->abbrev(), |
810 | 810 | ); |
811 | - $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
811 | + $this->_template_args['states'][$STA_ID]['delete_state_url'] = |
|
812 | 812 | EE_Admin_Page::add_query_args_and_nonce( |
813 | 813 | $query_args, |
814 | 814 | GEN_SET_ADMIN_URL |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | ); |
826 | 826 | |
827 | 827 | $state_details_settings = EEH_Template::display_template( |
828 | - GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
828 | + GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php', |
|
829 | 829 | $this->_template_args, |
830 | 830 | true |
831 | 831 | ); |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
862 | 862 | ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
863 | 863 | : false; |
864 | - if (! $CNT_ISO) { |
|
864 | + if ( ! $CNT_ISO) { |
|
865 | 865 | EE_Error::add_error( |
866 | 866 | __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
867 | 867 | __FILE__, |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
874 | 874 | ? sanitize_text_field($this->_req_data['STA_abbrev']) |
875 | 875 | : false; |
876 | - if (! $STA_abbrev) { |
|
876 | + if ( ! $STA_abbrev) { |
|
877 | 877 | EE_Error::add_error( |
878 | 878 | __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
879 | 879 | __FILE__, |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | $STA_name = isset($this->_req_data['STA_name']) |
886 | 886 | ? sanitize_text_field($this->_req_data['STA_name']) |
887 | 887 | : false; |
888 | - if (! $STA_name) { |
|
888 | + if ( ! $STA_name) { |
|
889 | 889 | EE_Error::add_error( |
890 | 890 | __('No State name or an invalid State name was received.', 'event_espresso'), |
891 | 891 | __FILE__, |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
934 | 934 | ? sanitize_text_field($this->_req_data['STA_abbrev']) |
935 | 935 | : false; |
936 | - if (! $STA_ID) { |
|
936 | + if ( ! $STA_ID) { |
|
937 | 937 | EE_Error::add_error( |
938 | 938 | __('No State ID or an invalid State ID was received.', 'event_espresso'), |
939 | 939 | __FILE__, |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | $CNT_ISO = isset($this->_req_data['country']) |
983 | 983 | ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
984 | 984 | : false; |
985 | - if (! $CNT_ISO) { |
|
985 | + if ( ! $CNT_ISO) { |
|
986 | 986 | EE_Error::add_error( |
987 | 987 | __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
988 | 988 | __FILE__, |
@@ -993,47 +993,47 @@ discard block |
||
993 | 993 | return; |
994 | 994 | } |
995 | 995 | $cols_n_values = array(); |
996 | - $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
997 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
996 | + $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) |
|
997 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) |
|
998 | 998 | : false; |
999 | - $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1000 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
999 | + $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) |
|
1000 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) |
|
1001 | 1001 | : null; |
1002 | - $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1003 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1002 | + $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) |
|
1003 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) |
|
1004 | 1004 | : null; |
1005 | - $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
1006 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) |
|
1005 | + $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) |
|
1006 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) |
|
1007 | 1007 | : 'USD'; |
1008 | - $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1009 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1008 | + $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) |
|
1009 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) |
|
1010 | 1010 | : 'dollar'; |
1011 | - $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1012 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1011 | + $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) |
|
1012 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) |
|
1013 | 1013 | : 'dollars'; |
1014 | - $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1015 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1014 | + $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) |
|
1015 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) |
|
1016 | 1016 | : '$'; |
1017 | - $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1018 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1017 | + $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) |
|
1018 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) |
|
1019 | 1019 | : true; |
1020 | - $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1021 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1020 | + $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) |
|
1021 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) |
|
1022 | 1022 | : 2; |
1023 | - $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1024 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1023 | + $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) |
|
1024 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) |
|
1025 | 1025 | : '.'; |
1026 | - $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1027 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1026 | + $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) |
|
1027 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) |
|
1028 | 1028 | : ','; |
1029 | - $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1030 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1029 | + $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) |
|
1030 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) |
|
1031 | 1031 | : null; |
1032 | - $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1033 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1032 | + $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) |
|
1033 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) |
|
1034 | 1034 | : false; |
1035 | - $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1036 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1035 | + $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) |
|
1036 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) |
|
1037 | 1037 | : false; |
1038 | 1038 | // allow filtering of country data |
1039 | 1039 | $cols_n_values = apply_filters( |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | return ' |
1111 | 1111 | <tr> |
1112 | 1112 | <th> |
1113 | - ' . $label . ' |
|
1113 | + ' . $label.' |
|
1114 | 1114 | </th>'; |
1115 | 1115 | } |
1116 | 1116 | |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | { |
1127 | 1127 | return ' |
1128 | 1128 | <td class="general-settings-country-input-td"> |
1129 | - ' . $input . ' |
|
1129 | + ' . $input.' |
|
1130 | 1130 | </td> |
1131 | 1131 | </tr>'; |
1132 | 1132 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | { |
1158 | 1158 | return ' |
1159 | 1159 | <td class="general-settings-country-state-input-td"> |
1160 | - ' . $input . ' |
|
1160 | + ' . $input.' |
|
1161 | 1161 | </td>'; |
1162 | 1162 | } |
1163 | 1163 | |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | . __('Edit', 'event_espresso') |
1184 | 1184 | . '</a>'; |
1185 | 1185 | $links .= ' | '; |
1186 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1186 | + $links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>'; |
|
1187 | 1187 | |
1188 | 1188 | return $links; |
1189 | 1189 | } |
@@ -1216,9 +1216,9 @@ discard block |
||
1216 | 1216 | $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
1217 | 1217 | } |
1218 | 1218 | |
1219 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1219 | + return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>' |
|
1220 | 1220 | . $pg_status |
1221 | - . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1221 | + . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>'; |
|
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 |
@@ -16,38 +16,38 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @param string $table_column |
|
21 | - * @param string $nice_name |
|
22 | - * @param bool $nullable |
|
23 | - * @param null $default_value |
|
24 | - * @throws InvalidArgumentException |
|
25 | - */ |
|
26 | - public function __construct($table_column, $nice_name, $nullable, $default_value = null) |
|
27 | - { |
|
28 | - parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
29 | - $this->setSchemaFormat('email'); |
|
30 | - } |
|
19 | + /** |
|
20 | + * @param string $table_column |
|
21 | + * @param string $nice_name |
|
22 | + * @param bool $nullable |
|
23 | + * @param null $default_value |
|
24 | + * @throws InvalidArgumentException |
|
25 | + */ |
|
26 | + public function __construct($table_column, $nice_name, $nullable, $default_value = null) |
|
27 | + { |
|
28 | + parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
29 | + $this->setSchemaFormat('email'); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * In form inputs, we should have called htmlentities and addslashes() on form inputs, |
|
36 | - * so we need to undo that on setting of these fields |
|
37 | - * |
|
38 | - * @param string $email_address |
|
39 | - * @return string |
|
40 | - * @throws InvalidArgumentException |
|
41 | - * @throws InvalidInterfaceException |
|
42 | - * @throws InvalidDataTypeException |
|
43 | - */ |
|
44 | - public function prepare_for_set($email_address) |
|
45 | - { |
|
46 | - try { |
|
47 | - $email_address = EmailAddressFactory::create($email_address); |
|
48 | - return $email_address->get(); |
|
49 | - } catch (EmailValidationException $e) { |
|
50 | - return ''; |
|
51 | - } |
|
52 | - } |
|
34 | + /** |
|
35 | + * In form inputs, we should have called htmlentities and addslashes() on form inputs, |
|
36 | + * so we need to undo that on setting of these fields |
|
37 | + * |
|
38 | + * @param string $email_address |
|
39 | + * @return string |
|
40 | + * @throws InvalidArgumentException |
|
41 | + * @throws InvalidInterfaceException |
|
42 | + * @throws InvalidDataTypeException |
|
43 | + */ |
|
44 | + public function prepare_for_set($email_address) |
|
45 | + { |
|
46 | + try { |
|
47 | + $email_address = EmailAddressFactory::create($email_address); |
|
48 | + return $email_address->get(); |
|
49 | + } catch (EmailValidationException $e) { |
|
50 | + return ''; |
|
51 | + } |
|
52 | + } |
|
53 | 53 | } |
@@ -15,11 +15,11 @@ |
||
15 | 15 | interface FactoryInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param mixed $arguments |
|
20 | - * @return mixed |
|
21 | - */ |
|
22 | - public static function create($arguments); |
|
18 | + /** |
|
19 | + * @param mixed $arguments |
|
20 | + * @return mixed |
|
21 | + */ |
|
22 | + public static function create($arguments); |
|
23 | 23 | |
24 | 24 | |
25 | 25 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $email_address, |
35 | 35 | $this->getAtIndex($email_address) |
36 | 36 | ); |
37 | - if (! checkdnsrr($domain, 'MX')) { |
|
37 | + if ( ! checkdnsrr($domain, 'MX')) { |
|
38 | 38 | // domain not found in MX records |
39 | 39 | throw new EmailValidationException( |
40 | 40 | __( |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | ) |
46 | 46 | ); |
47 | 47 | } |
48 | - if (! checkdnsrr($domain, 'A')) { |
|
48 | + if ( ! checkdnsrr($domain, 'A')) { |
|
49 | 49 | // domain not found in A records |
50 | 50 | throw new EmailValidationException( |
51 | 51 | __( |
@@ -15,43 +15,43 @@ |
||
15 | 15 | class InternationalDNS extends International |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Validates the email in teh same way as the parent, but also |
|
20 | - * verifies the domain exists. |
|
21 | - * |
|
22 | - * @param string $email_address |
|
23 | - * @return bool |
|
24 | - * @throws EmailValidationException |
|
25 | - */ |
|
26 | - public function validate($email_address) |
|
27 | - { |
|
28 | - parent::validate($email_address); |
|
29 | - $domain = $this->getDomainPartOfEmail( |
|
30 | - $email_address, |
|
31 | - $this->getAtIndex($email_address) |
|
32 | - ); |
|
33 | - if (! checkdnsrr($domain, 'MX')) { |
|
34 | - // domain not found in MX records |
|
35 | - throw new EmailValidationException( |
|
36 | - __( |
|
37 | - // @codingStandardsIgnoreStart |
|
38 | - 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
39 | - // @codingStandardsIgnoreEnd |
|
40 | - 'event_espresso' |
|
41 | - ) |
|
42 | - ); |
|
43 | - } |
|
44 | - if (! checkdnsrr($domain, 'A')) { |
|
45 | - // domain not found in A records |
|
46 | - throw new EmailValidationException( |
|
47 | - __( |
|
48 | - // @codingStandardsIgnoreStart |
|
49 | - 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
50 | - // @codingStandardsIgnoreEnd |
|
51 | - 'event_espresso' |
|
52 | - ) |
|
53 | - ); |
|
54 | - } |
|
55 | - return true; |
|
56 | - } |
|
18 | + /** |
|
19 | + * Validates the email in teh same way as the parent, but also |
|
20 | + * verifies the domain exists. |
|
21 | + * |
|
22 | + * @param string $email_address |
|
23 | + * @return bool |
|
24 | + * @throws EmailValidationException |
|
25 | + */ |
|
26 | + public function validate($email_address) |
|
27 | + { |
|
28 | + parent::validate($email_address); |
|
29 | + $domain = $this->getDomainPartOfEmail( |
|
30 | + $email_address, |
|
31 | + $this->getAtIndex($email_address) |
|
32 | + ); |
|
33 | + if (! checkdnsrr($domain, 'MX')) { |
|
34 | + // domain not found in MX records |
|
35 | + throw new EmailValidationException( |
|
36 | + __( |
|
37 | + // @codingStandardsIgnoreStart |
|
38 | + 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
39 | + // @codingStandardsIgnoreEnd |
|
40 | + 'event_espresso' |
|
41 | + ) |
|
42 | + ); |
|
43 | + } |
|
44 | + if (! checkdnsrr($domain, 'A')) { |
|
45 | + // domain not found in A records |
|
46 | + throw new EmailValidationException( |
|
47 | + __( |
|
48 | + // @codingStandardsIgnoreStart |
|
49 | + 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
50 | + // @codingStandardsIgnoreEnd |
|
51 | + 'event_espresso' |
|
52 | + ) |
|
53 | + ); |
|
54 | + } |
|
55 | + return true; |
|
56 | + } |
|
57 | 57 | } |
@@ -18,14 +18,14 @@ |
||
18 | 18 | interface EmailValidatorInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Validates the supplied email address. If it is invalid, throws EmailValidationException |
|
23 | - * |
|
24 | - * @param string $email_address |
|
25 | - * @return boolean |
|
26 | - * @throws EmailValidationException |
|
27 | - */ |
|
28 | - public function validate($email_address); |
|
21 | + /** |
|
22 | + * Validates the supplied email address. If it is invalid, throws EmailValidationException |
|
23 | + * |
|
24 | + * @param string $email_address |
|
25 | + * @return boolean |
|
26 | + * @throws EmailValidationException |
|
27 | + */ |
|
28 | + public function validate($email_address); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | } |
@@ -18,72 +18,72 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @param string $validation_error_message |
|
23 | - */ |
|
24 | - public function __construct($validation_error_message = '') |
|
25 | - { |
|
26 | - if (! $validation_error_message) { |
|
27 | - $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
|
28 | - } |
|
29 | - parent::__construct($validation_error_message); |
|
30 | - } |
|
21 | + /** |
|
22 | + * @param string $validation_error_message |
|
23 | + */ |
|
24 | + public function __construct($validation_error_message = '') |
|
25 | + { |
|
26 | + if (! $validation_error_message) { |
|
27 | + $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
|
28 | + } |
|
29 | + parent::__construct($validation_error_message); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * just checks the field isn't blank |
|
36 | - * |
|
37 | - * @param $normalized_value |
|
38 | - * @return bool |
|
39 | - * @throws InvalidArgumentException |
|
40 | - * @throws InvalidInterfaceException |
|
41 | - * @throws InvalidDataTypeException |
|
42 | - * @throws EE_Validation_Error |
|
43 | - */ |
|
44 | - public function validate($normalized_value) |
|
45 | - { |
|
46 | - if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
47 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
48 | - } |
|
49 | - return true; |
|
50 | - } |
|
34 | + /** |
|
35 | + * just checks the field isn't blank |
|
36 | + * |
|
37 | + * @param $normalized_value |
|
38 | + * @return bool |
|
39 | + * @throws InvalidArgumentException |
|
40 | + * @throws InvalidInterfaceException |
|
41 | + * @throws InvalidDataTypeException |
|
42 | + * @throws EE_Validation_Error |
|
43 | + */ |
|
44 | + public function validate($normalized_value) |
|
45 | + { |
|
46 | + if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
47 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
48 | + } |
|
49 | + return true; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * @return array |
|
56 | - */ |
|
57 | - public function get_jquery_validation_rule_array() |
|
58 | - { |
|
59 | - return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
60 | - } |
|
54 | + /** |
|
55 | + * @return array |
|
56 | + */ |
|
57 | + public function get_jquery_validation_rule_array() |
|
58 | + { |
|
59 | + return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * Validate an email address. |
|
66 | - * Provide email address (raw input) |
|
67 | - * |
|
68 | - * @param $email |
|
69 | - * @return bool of whether the email is valid or not |
|
70 | - * @throws InvalidArgumentException |
|
71 | - * @throws InvalidInterfaceException |
|
72 | - * @throws InvalidDataTypeException |
|
73 | - * @throws EE_Validation_Error |
|
74 | - */ |
|
75 | - private function _validate_email($email) |
|
76 | - { |
|
77 | - try { |
|
78 | - EmailAddressFactory::create($email); |
|
79 | - } catch (EmailValidationException $e) { |
|
80 | - throw new EE_Validation_Error( |
|
81 | - $e->getMessage(), |
|
82 | - 'invalid_email', |
|
83 | - $this->_input, |
|
84 | - $e |
|
85 | - ); |
|
86 | - } |
|
87 | - return true; |
|
88 | - } |
|
64 | + /** |
|
65 | + * Validate an email address. |
|
66 | + * Provide email address (raw input) |
|
67 | + * |
|
68 | + * @param $email |
|
69 | + * @return bool of whether the email is valid or not |
|
70 | + * @throws InvalidArgumentException |
|
71 | + * @throws InvalidInterfaceException |
|
72 | + * @throws InvalidDataTypeException |
|
73 | + * @throws EE_Validation_Error |
|
74 | + */ |
|
75 | + private function _validate_email($email) |
|
76 | + { |
|
77 | + try { |
|
78 | + EmailAddressFactory::create($email); |
|
79 | + } catch (EmailValidationException $e) { |
|
80 | + throw new EE_Validation_Error( |
|
81 | + $e->getMessage(), |
|
82 | + 'invalid_email', |
|
83 | + $this->_input, |
|
84 | + $e |
|
85 | + ); |
|
86 | + } |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function __construct($validation_error_message = '') |
25 | 25 | { |
26 | - if (! $validation_error_message) { |
|
26 | + if ( ! $validation_error_message) { |
|
27 | 27 | $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
28 | 28 | } |
29 | 29 | parent::__construct($validation_error_message); |
@@ -351,7 +351,7 @@ |
||
351 | 351 | * retrieve a single attendee from db via their ID |
352 | 352 | * |
353 | 353 | * @param $ATT_ID |
354 | - * @return mixed array on success, FALSE on fail |
|
354 | + * @return EE_Base_Class|null array on success, FALSE on fail |
|
355 | 355 | * @deprecated |
356 | 356 | */ |
357 | 357 | public function get_attendee_by_ID($ATT_ID = false) |
@@ -1,5 +1,4 @@ |
||
1 | 1 | <?php |
2 | -use EventEspresso\core\services\loaders\Loader; |
|
3 | 2 | use EventEspresso\core\services\orm\ModelFieldFactory; |
4 | 3 | |
5 | 4 | /** |
@@ -12,411 +12,411 @@ |
||
12 | 12 | class EEM_Attendee extends EEM_CPT_Base |
13 | 13 | { |
14 | 14 | |
15 | - // private instance of the Attendee object |
|
16 | - protected static $_instance = null; |
|
15 | + // private instance of the Attendee object |
|
16 | + protected static $_instance = null; |
|
17 | 17 | |
18 | - /** |
|
19 | - * QST_system for questions are strings not integers now, |
|
20 | - * so these constants are deprecated. |
|
21 | - * Please instead use the EEM_Attendee::system_question_* constants |
|
22 | - * |
|
23 | - * @deprecated |
|
24 | - */ |
|
25 | - const fname_question_id = 1; |
|
18 | + /** |
|
19 | + * QST_system for questions are strings not integers now, |
|
20 | + * so these constants are deprecated. |
|
21 | + * Please instead use the EEM_Attendee::system_question_* constants |
|
22 | + * |
|
23 | + * @deprecated |
|
24 | + */ |
|
25 | + const fname_question_id = 1; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @deprecated |
|
29 | - */ |
|
30 | - const lname_question_id = 2; |
|
27 | + /** |
|
28 | + * @deprecated |
|
29 | + */ |
|
30 | + const lname_question_id = 2; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @deprecated |
|
35 | - */ |
|
36 | - const email_question_id = 3; |
|
33 | + /** |
|
34 | + * @deprecated |
|
35 | + */ |
|
36 | + const email_question_id = 3; |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @deprecated |
|
41 | - */ |
|
42 | - const address_question_id = 4; |
|
39 | + /** |
|
40 | + * @deprecated |
|
41 | + */ |
|
42 | + const address_question_id = 4; |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @deprecated |
|
47 | - */ |
|
48 | - const address2_question_id = 5; |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * @deprecated |
|
53 | - */ |
|
54 | - const city_question_id = 6; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * @deprecated |
|
59 | - */ |
|
60 | - const state_question_id = 7; |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @deprecated |
|
65 | - */ |
|
66 | - const country_question_id = 8; |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @deprecated |
|
71 | - */ |
|
72 | - const zip_question_id = 9; |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @deprecated |
|
77 | - */ |
|
78 | - const phone_question_id = 10; |
|
79 | - |
|
80 | - /** |
|
81 | - * When looking for questions that correspond to attendee fields, |
|
82 | - * look for the question with this QST_system value. |
|
83 | - * These replace the old constants like EEM_Attendee::*_question_id |
|
84 | - */ |
|
85 | - const system_question_fname = 'fname'; |
|
86 | - |
|
87 | - const system_question_lname = 'lname'; |
|
88 | - |
|
89 | - const system_question_email = 'email'; |
|
90 | - |
|
91 | - const system_question_address = 'address'; |
|
92 | - |
|
93 | - const system_question_address2 = 'address2'; |
|
94 | - |
|
95 | - const system_question_city = 'city'; |
|
96 | - |
|
97 | - const system_question_state = 'state'; |
|
98 | - |
|
99 | - const system_question_country = 'country'; |
|
100 | - |
|
101 | - const system_question_zip = 'zip'; |
|
102 | - |
|
103 | - const system_question_phone = 'phone'; |
|
104 | - |
|
105 | - /** |
|
106 | - * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
107 | - * also all the values of QST_system in the questions table, and values |
|
108 | - * are their corresponding Attendee field names |
|
109 | - * |
|
110 | - * @var array |
|
111 | - */ |
|
112 | - protected $_system_question_to_attendee_field_name = array( |
|
113 | - EEM_Attendee::system_question_fname => 'ATT_fname', |
|
114 | - EEM_Attendee::system_question_lname => 'ATT_lname', |
|
115 | - EEM_Attendee::system_question_email => 'ATT_email', |
|
116 | - EEM_Attendee::system_question_address => 'ATT_address', |
|
117 | - EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
118 | - EEM_Attendee::system_question_city => 'ATT_city', |
|
119 | - EEM_Attendee::system_question_state => 'STA_ID', |
|
120 | - EEM_Attendee::system_question_country => 'CNT_ISO', |
|
121 | - EEM_Attendee::system_question_zip => 'ATT_zip', |
|
122 | - EEM_Attendee::system_question_phone => 'ATT_phone', |
|
123 | - ); |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * EEM_Attendee constructor. |
|
129 | - * |
|
130 | - * @param null $timezone |
|
131 | - * @param ModelFieldFactory $model_field_factory |
|
132 | - * @throws EE_Error |
|
133 | - * @throws InvalidArgumentException |
|
134 | - */ |
|
135 | - protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
136 | - { |
|
137 | - $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
|
138 | - $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
|
139 | - $this->_tables = array( |
|
140 | - 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
141 | - 'Attendee_Meta' => new EE_Secondary_Table( |
|
142 | - 'esp_attendee_meta', |
|
143 | - 'ATTM_ID', |
|
144 | - 'ATT_ID' |
|
145 | - ), |
|
146 | - ); |
|
147 | - $this->_fields = array( |
|
148 | - 'Attendee_CPT' => array( |
|
149 | - 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
|
150 | - 'ID', |
|
151 | - esc_html__('Attendee ID', 'event_espresso') |
|
152 | - ), |
|
153 | - 'ATT_full_name' => $model_field_factory->createPlainTextField( |
|
154 | - 'post_title', |
|
155 | - esc_html__('Attendee Full Name', 'event_espresso'), |
|
156 | - false, |
|
157 | - esc_html__('Unknown', 'event_espresso') |
|
158 | - ), |
|
159 | - 'ATT_bio' => $model_field_factory->createPostContentField( |
|
160 | - 'post_content', |
|
161 | - esc_html__('Attendee Biography', 'event_espresso'), |
|
162 | - false, |
|
163 | - esc_html__('No Biography Provided', 'event_espresso') |
|
164 | - ), |
|
165 | - 'ATT_slug' => $model_field_factory->createSlugField( |
|
166 | - 'post_name', |
|
167 | - esc_html__('Attendee URL Slug', 'event_espresso') |
|
168 | - ), |
|
169 | - 'ATT_created' => $model_field_factory->createDatetimeField( |
|
170 | - 'post_date', |
|
171 | - esc_html__('Time Attendee Created', 'event_espresso') |
|
172 | - ), |
|
173 | - 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
|
174 | - 'post_excerpt', |
|
175 | - esc_html__('Attendee Short Biography', 'event_espresso'), |
|
176 | - true, |
|
177 | - esc_html__('No Biography Provided', 'event_espresso') |
|
178 | - ), |
|
179 | - 'ATT_modified' => $model_field_factory->createDatetimeField( |
|
180 | - 'post_modified', |
|
181 | - esc_html__('Time Attendee Last Modified', 'event_espresso') |
|
182 | - ), |
|
183 | - 'ATT_author' => $model_field_factory->createWpUserField( |
|
184 | - 'post_author', |
|
185 | - esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
|
186 | - false |
|
187 | - ), |
|
188 | - 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
|
189 | - 'post_parent', |
|
190 | - esc_html__('Parent Attendee (unused)', 'event_espresso'), |
|
191 | - false, |
|
192 | - 0 |
|
193 | - ), |
|
194 | - 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
|
195 | - 'status' => $model_field_factory->createWpPostStatusField( |
|
196 | - 'post_status', |
|
197 | - esc_html__('Attendee Status', 'event_espresso'), |
|
198 | - false, |
|
199 | - 'publish' |
|
200 | - ), |
|
201 | - ), |
|
202 | - 'Attendee_Meta' => array( |
|
203 | - 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
|
204 | - 'ATTM_ID', |
|
205 | - esc_html__('Attendee Meta Row ID', 'event_espresso'), |
|
206 | - false |
|
207 | - ), |
|
208 | - 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
|
209 | - 'ATT_ID', |
|
210 | - esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
|
211 | - false |
|
212 | - ), |
|
213 | - 'ATT_fname' => $model_field_factory->createPlainTextField( |
|
214 | - 'ATT_fname', |
|
215 | - esc_html__('First Name', 'event_espresso') |
|
216 | - ), |
|
217 | - 'ATT_lname' => $model_field_factory->createPlainTextField( |
|
218 | - 'ATT_lname', |
|
219 | - esc_html__('Last Name', 'event_espresso') |
|
220 | - ), |
|
221 | - 'ATT_address' => $model_field_factory->createPlainTextField( |
|
222 | - 'ATT_address', |
|
223 | - esc_html__('Address Part 1', 'event_espresso') |
|
224 | - ), |
|
225 | - 'ATT_address2' => $model_field_factory->createPlainTextField( |
|
226 | - 'ATT_address2', |
|
227 | - esc_html__('Address Part 2', 'event_espresso') |
|
228 | - ), |
|
229 | - 'ATT_city' => $model_field_factory->createPlainTextField( |
|
230 | - 'ATT_city', |
|
231 | - esc_html__('City', 'event_espresso') |
|
232 | - ), |
|
233 | - 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
|
234 | - 'STA_ID', |
|
235 | - esc_html__('State', 'event_espresso'), |
|
236 | - true, |
|
237 | - 0, |
|
238 | - 'State' |
|
239 | - ), |
|
240 | - 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
|
241 | - 'CNT_ISO', |
|
242 | - esc_html__('Country', 'event_espresso'), |
|
243 | - true, |
|
244 | - '', |
|
245 | - 'Country' |
|
246 | - ), |
|
247 | - 'ATT_zip' => $model_field_factory->createPlainTextField( |
|
248 | - 'ATT_zip', |
|
249 | - esc_html__('ZIP/Postal Code', 'event_espresso') |
|
250 | - ), |
|
251 | - 'ATT_email' => $model_field_factory->createEmailField( |
|
252 | - 'ATT_email', |
|
253 | - esc_html__('Email Address', 'event_espresso') |
|
254 | - ), |
|
255 | - 'ATT_phone' => $model_field_factory->createPlainTextField( |
|
256 | - 'ATT_phone', |
|
257 | - esc_html__('Phone', 'event_espresso') |
|
258 | - ), |
|
259 | - ), |
|
260 | - ); |
|
261 | - $this->_model_relations = array( |
|
262 | - 'Registration' => new EE_Has_Many_Relation(), |
|
263 | - 'State' => new EE_Belongs_To_Relation(), |
|
264 | - 'Country' => new EE_Belongs_To_Relation(), |
|
265 | - 'Event' => new EE_HABTM_Relation('Registration', false), |
|
266 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
267 | - 'Message' => new EE_Has_Many_Any_Relation(false), |
|
268 | - // allow deletion of attendees even if they have messages in the queue for them. |
|
269 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
270 | - 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
271 | - ); |
|
272 | - $this->_caps_slug = 'contacts'; |
|
273 | - parent::__construct($timezone); |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * Gets the name of the field on the attendee model corresponding to the system question string |
|
280 | - * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
281 | - * |
|
282 | - * @param string $system_question_string |
|
283 | - * @return string|null if not found |
|
284 | - */ |
|
285 | - public function get_attendee_field_for_system_question($system_question_string) |
|
286 | - { |
|
287 | - return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
288 | - ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
289 | - : null; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
296 | - * |
|
297 | - * @return array |
|
298 | - */ |
|
299 | - public function system_question_to_attendee_field_mapping() |
|
300 | - { |
|
301 | - return $this->_system_question_to_attendee_field_name; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
308 | - * |
|
309 | - * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
310 | - * @return EE_Attendee[]|EE_Base_Class[] |
|
311 | - * @throws EE_Error |
|
312 | - */ |
|
313 | - public function get_attendees_for_transaction($transaction_id_or_obj) |
|
314 | - { |
|
315 | - return $this->get_all( |
|
316 | - array( |
|
317 | - array( |
|
318 | - 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
319 | - ? $transaction_id_or_obj->ID() |
|
320 | - : $transaction_id_or_obj, |
|
321 | - ), |
|
322 | - ) |
|
323 | - ); |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - |
|
328 | - /** |
|
329 | - * retrieve a single attendee from db via their ID |
|
330 | - * |
|
331 | - * @param $ATT_ID |
|
332 | - * @return mixed array on success, FALSE on fail |
|
333 | - * @deprecated |
|
334 | - */ |
|
335 | - public function get_attendee_by_ID($ATT_ID = false) |
|
336 | - { |
|
337 | - // retrieve a particular EE_Attendee |
|
338 | - return $this->get_one_by_ID($ATT_ID); |
|
339 | - } |
|
340 | - |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * retrieve a single attendee from db via their ID |
|
345 | - * |
|
346 | - * @param array $where_cols_n_values |
|
347 | - * @return mixed array on success, FALSE on fail |
|
348 | - * @throws EE_Error |
|
349 | - */ |
|
350 | - public function get_attendee($where_cols_n_values = array()) |
|
351 | - { |
|
352 | - if (empty($where_cols_n_values)) { |
|
353 | - return false; |
|
354 | - } |
|
355 | - $attendee = $this->get_all(array($where_cols_n_values)); |
|
356 | - if (! empty($attendee)) { |
|
357 | - return array_shift($attendee); |
|
358 | - } |
|
359 | - return false; |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * Search for an existing Attendee record in the DB |
|
366 | - * |
|
367 | - * @param array $where_cols_n_values |
|
368 | - * @return bool|mixed |
|
369 | - * @throws EE_Error |
|
370 | - */ |
|
371 | - public function find_existing_attendee($where_cols_n_values = null) |
|
372 | - { |
|
373 | - // search by combo of first and last names plus the email address |
|
374 | - $attendee_data_keys = array( |
|
375 | - 'ATT_fname' => $this->_ATT_fname, |
|
376 | - 'ATT_lname' => $this->_ATT_lname, |
|
377 | - 'ATT_email' => $this->_ATT_email, |
|
378 | - ); |
|
379 | - // no search params means attendee object already exists. |
|
380 | - $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) |
|
381 | - ? $where_cols_n_values |
|
382 | - : $attendee_data_keys; |
|
383 | - $valid_data = true; |
|
384 | - // check for required values |
|
385 | - $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
386 | - ? $valid_data |
|
387 | - : false; |
|
388 | - $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
389 | - ? $valid_data |
|
390 | - : false; |
|
391 | - $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
392 | - ? $valid_data |
|
393 | - : false; |
|
394 | - if ($valid_data) { |
|
395 | - $attendee = $this->get_attendee($where_cols_n_values); |
|
396 | - if ($attendee instanceof EE_Attendee) { |
|
397 | - return $attendee; |
|
398 | - } |
|
399 | - } |
|
400 | - return false; |
|
401 | - } |
|
402 | - |
|
403 | - |
|
404 | - |
|
405 | - /** |
|
406 | - * Takes an incoming array of EE_Registration ids |
|
407 | - * and sends back a list of corresponding non duplicate EE_Attendee objects. |
|
408 | - * |
|
409 | - * @since 4.3.0 |
|
410 | - * @param array $ids array of EE_Registration ids |
|
411 | - * @return EE_Attendee[]|EE_Base_Class[] |
|
412 | - * @throws EE_Error |
|
413 | - */ |
|
414 | - public function get_array_of_contacts_from_reg_ids($ids) |
|
415 | - { |
|
416 | - $ids = (array) $ids; |
|
417 | - $_where = array( |
|
418 | - 'Registration.REG_ID' => array('in', $ids), |
|
419 | - ); |
|
420 | - return $this->get_all(array($_where)); |
|
421 | - } |
|
45 | + /** |
|
46 | + * @deprecated |
|
47 | + */ |
|
48 | + const address2_question_id = 5; |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * @deprecated |
|
53 | + */ |
|
54 | + const city_question_id = 6; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * @deprecated |
|
59 | + */ |
|
60 | + const state_question_id = 7; |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @deprecated |
|
65 | + */ |
|
66 | + const country_question_id = 8; |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @deprecated |
|
71 | + */ |
|
72 | + const zip_question_id = 9; |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @deprecated |
|
77 | + */ |
|
78 | + const phone_question_id = 10; |
|
79 | + |
|
80 | + /** |
|
81 | + * When looking for questions that correspond to attendee fields, |
|
82 | + * look for the question with this QST_system value. |
|
83 | + * These replace the old constants like EEM_Attendee::*_question_id |
|
84 | + */ |
|
85 | + const system_question_fname = 'fname'; |
|
86 | + |
|
87 | + const system_question_lname = 'lname'; |
|
88 | + |
|
89 | + const system_question_email = 'email'; |
|
90 | + |
|
91 | + const system_question_address = 'address'; |
|
92 | + |
|
93 | + const system_question_address2 = 'address2'; |
|
94 | + |
|
95 | + const system_question_city = 'city'; |
|
96 | + |
|
97 | + const system_question_state = 'state'; |
|
98 | + |
|
99 | + const system_question_country = 'country'; |
|
100 | + |
|
101 | + const system_question_zip = 'zip'; |
|
102 | + |
|
103 | + const system_question_phone = 'phone'; |
|
104 | + |
|
105 | + /** |
|
106 | + * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
107 | + * also all the values of QST_system in the questions table, and values |
|
108 | + * are their corresponding Attendee field names |
|
109 | + * |
|
110 | + * @var array |
|
111 | + */ |
|
112 | + protected $_system_question_to_attendee_field_name = array( |
|
113 | + EEM_Attendee::system_question_fname => 'ATT_fname', |
|
114 | + EEM_Attendee::system_question_lname => 'ATT_lname', |
|
115 | + EEM_Attendee::system_question_email => 'ATT_email', |
|
116 | + EEM_Attendee::system_question_address => 'ATT_address', |
|
117 | + EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
118 | + EEM_Attendee::system_question_city => 'ATT_city', |
|
119 | + EEM_Attendee::system_question_state => 'STA_ID', |
|
120 | + EEM_Attendee::system_question_country => 'CNT_ISO', |
|
121 | + EEM_Attendee::system_question_zip => 'ATT_zip', |
|
122 | + EEM_Attendee::system_question_phone => 'ATT_phone', |
|
123 | + ); |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * EEM_Attendee constructor. |
|
129 | + * |
|
130 | + * @param null $timezone |
|
131 | + * @param ModelFieldFactory $model_field_factory |
|
132 | + * @throws EE_Error |
|
133 | + * @throws InvalidArgumentException |
|
134 | + */ |
|
135 | + protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
|
136 | + { |
|
137 | + $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
|
138 | + $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
|
139 | + $this->_tables = array( |
|
140 | + 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
141 | + 'Attendee_Meta' => new EE_Secondary_Table( |
|
142 | + 'esp_attendee_meta', |
|
143 | + 'ATTM_ID', |
|
144 | + 'ATT_ID' |
|
145 | + ), |
|
146 | + ); |
|
147 | + $this->_fields = array( |
|
148 | + 'Attendee_CPT' => array( |
|
149 | + 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
|
150 | + 'ID', |
|
151 | + esc_html__('Attendee ID', 'event_espresso') |
|
152 | + ), |
|
153 | + 'ATT_full_name' => $model_field_factory->createPlainTextField( |
|
154 | + 'post_title', |
|
155 | + esc_html__('Attendee Full Name', 'event_espresso'), |
|
156 | + false, |
|
157 | + esc_html__('Unknown', 'event_espresso') |
|
158 | + ), |
|
159 | + 'ATT_bio' => $model_field_factory->createPostContentField( |
|
160 | + 'post_content', |
|
161 | + esc_html__('Attendee Biography', 'event_espresso'), |
|
162 | + false, |
|
163 | + esc_html__('No Biography Provided', 'event_espresso') |
|
164 | + ), |
|
165 | + 'ATT_slug' => $model_field_factory->createSlugField( |
|
166 | + 'post_name', |
|
167 | + esc_html__('Attendee URL Slug', 'event_espresso') |
|
168 | + ), |
|
169 | + 'ATT_created' => $model_field_factory->createDatetimeField( |
|
170 | + 'post_date', |
|
171 | + esc_html__('Time Attendee Created', 'event_espresso') |
|
172 | + ), |
|
173 | + 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
|
174 | + 'post_excerpt', |
|
175 | + esc_html__('Attendee Short Biography', 'event_espresso'), |
|
176 | + true, |
|
177 | + esc_html__('No Biography Provided', 'event_espresso') |
|
178 | + ), |
|
179 | + 'ATT_modified' => $model_field_factory->createDatetimeField( |
|
180 | + 'post_modified', |
|
181 | + esc_html__('Time Attendee Last Modified', 'event_espresso') |
|
182 | + ), |
|
183 | + 'ATT_author' => $model_field_factory->createWpUserField( |
|
184 | + 'post_author', |
|
185 | + esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
|
186 | + false |
|
187 | + ), |
|
188 | + 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
|
189 | + 'post_parent', |
|
190 | + esc_html__('Parent Attendee (unused)', 'event_espresso'), |
|
191 | + false, |
|
192 | + 0 |
|
193 | + ), |
|
194 | + 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
|
195 | + 'status' => $model_field_factory->createWpPostStatusField( |
|
196 | + 'post_status', |
|
197 | + esc_html__('Attendee Status', 'event_espresso'), |
|
198 | + false, |
|
199 | + 'publish' |
|
200 | + ), |
|
201 | + ), |
|
202 | + 'Attendee_Meta' => array( |
|
203 | + 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
|
204 | + 'ATTM_ID', |
|
205 | + esc_html__('Attendee Meta Row ID', 'event_espresso'), |
|
206 | + false |
|
207 | + ), |
|
208 | + 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
|
209 | + 'ATT_ID', |
|
210 | + esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
|
211 | + false |
|
212 | + ), |
|
213 | + 'ATT_fname' => $model_field_factory->createPlainTextField( |
|
214 | + 'ATT_fname', |
|
215 | + esc_html__('First Name', 'event_espresso') |
|
216 | + ), |
|
217 | + 'ATT_lname' => $model_field_factory->createPlainTextField( |
|
218 | + 'ATT_lname', |
|
219 | + esc_html__('Last Name', 'event_espresso') |
|
220 | + ), |
|
221 | + 'ATT_address' => $model_field_factory->createPlainTextField( |
|
222 | + 'ATT_address', |
|
223 | + esc_html__('Address Part 1', 'event_espresso') |
|
224 | + ), |
|
225 | + 'ATT_address2' => $model_field_factory->createPlainTextField( |
|
226 | + 'ATT_address2', |
|
227 | + esc_html__('Address Part 2', 'event_espresso') |
|
228 | + ), |
|
229 | + 'ATT_city' => $model_field_factory->createPlainTextField( |
|
230 | + 'ATT_city', |
|
231 | + esc_html__('City', 'event_espresso') |
|
232 | + ), |
|
233 | + 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
|
234 | + 'STA_ID', |
|
235 | + esc_html__('State', 'event_espresso'), |
|
236 | + true, |
|
237 | + 0, |
|
238 | + 'State' |
|
239 | + ), |
|
240 | + 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
|
241 | + 'CNT_ISO', |
|
242 | + esc_html__('Country', 'event_espresso'), |
|
243 | + true, |
|
244 | + '', |
|
245 | + 'Country' |
|
246 | + ), |
|
247 | + 'ATT_zip' => $model_field_factory->createPlainTextField( |
|
248 | + 'ATT_zip', |
|
249 | + esc_html__('ZIP/Postal Code', 'event_espresso') |
|
250 | + ), |
|
251 | + 'ATT_email' => $model_field_factory->createEmailField( |
|
252 | + 'ATT_email', |
|
253 | + esc_html__('Email Address', 'event_espresso') |
|
254 | + ), |
|
255 | + 'ATT_phone' => $model_field_factory->createPlainTextField( |
|
256 | + 'ATT_phone', |
|
257 | + esc_html__('Phone', 'event_espresso') |
|
258 | + ), |
|
259 | + ), |
|
260 | + ); |
|
261 | + $this->_model_relations = array( |
|
262 | + 'Registration' => new EE_Has_Many_Relation(), |
|
263 | + 'State' => new EE_Belongs_To_Relation(), |
|
264 | + 'Country' => new EE_Belongs_To_Relation(), |
|
265 | + 'Event' => new EE_HABTM_Relation('Registration', false), |
|
266 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
267 | + 'Message' => new EE_Has_Many_Any_Relation(false), |
|
268 | + // allow deletion of attendees even if they have messages in the queue for them. |
|
269 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
270 | + 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
271 | + ); |
|
272 | + $this->_caps_slug = 'contacts'; |
|
273 | + parent::__construct($timezone); |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * Gets the name of the field on the attendee model corresponding to the system question string |
|
280 | + * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
281 | + * |
|
282 | + * @param string $system_question_string |
|
283 | + * @return string|null if not found |
|
284 | + */ |
|
285 | + public function get_attendee_field_for_system_question($system_question_string) |
|
286 | + { |
|
287 | + return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
288 | + ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
289 | + : null; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
296 | + * |
|
297 | + * @return array |
|
298 | + */ |
|
299 | + public function system_question_to_attendee_field_mapping() |
|
300 | + { |
|
301 | + return $this->_system_question_to_attendee_field_name; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
308 | + * |
|
309 | + * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
310 | + * @return EE_Attendee[]|EE_Base_Class[] |
|
311 | + * @throws EE_Error |
|
312 | + */ |
|
313 | + public function get_attendees_for_transaction($transaction_id_or_obj) |
|
314 | + { |
|
315 | + return $this->get_all( |
|
316 | + array( |
|
317 | + array( |
|
318 | + 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
319 | + ? $transaction_id_or_obj->ID() |
|
320 | + : $transaction_id_or_obj, |
|
321 | + ), |
|
322 | + ) |
|
323 | + ); |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * retrieve a single attendee from db via their ID |
|
330 | + * |
|
331 | + * @param $ATT_ID |
|
332 | + * @return mixed array on success, FALSE on fail |
|
333 | + * @deprecated |
|
334 | + */ |
|
335 | + public function get_attendee_by_ID($ATT_ID = false) |
|
336 | + { |
|
337 | + // retrieve a particular EE_Attendee |
|
338 | + return $this->get_one_by_ID($ATT_ID); |
|
339 | + } |
|
340 | + |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * retrieve a single attendee from db via their ID |
|
345 | + * |
|
346 | + * @param array $where_cols_n_values |
|
347 | + * @return mixed array on success, FALSE on fail |
|
348 | + * @throws EE_Error |
|
349 | + */ |
|
350 | + public function get_attendee($where_cols_n_values = array()) |
|
351 | + { |
|
352 | + if (empty($where_cols_n_values)) { |
|
353 | + return false; |
|
354 | + } |
|
355 | + $attendee = $this->get_all(array($where_cols_n_values)); |
|
356 | + if (! empty($attendee)) { |
|
357 | + return array_shift($attendee); |
|
358 | + } |
|
359 | + return false; |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * Search for an existing Attendee record in the DB |
|
366 | + * |
|
367 | + * @param array $where_cols_n_values |
|
368 | + * @return bool|mixed |
|
369 | + * @throws EE_Error |
|
370 | + */ |
|
371 | + public function find_existing_attendee($where_cols_n_values = null) |
|
372 | + { |
|
373 | + // search by combo of first and last names plus the email address |
|
374 | + $attendee_data_keys = array( |
|
375 | + 'ATT_fname' => $this->_ATT_fname, |
|
376 | + 'ATT_lname' => $this->_ATT_lname, |
|
377 | + 'ATT_email' => $this->_ATT_email, |
|
378 | + ); |
|
379 | + // no search params means attendee object already exists. |
|
380 | + $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) |
|
381 | + ? $where_cols_n_values |
|
382 | + : $attendee_data_keys; |
|
383 | + $valid_data = true; |
|
384 | + // check for required values |
|
385 | + $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
386 | + ? $valid_data |
|
387 | + : false; |
|
388 | + $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
389 | + ? $valid_data |
|
390 | + : false; |
|
391 | + $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
392 | + ? $valid_data |
|
393 | + : false; |
|
394 | + if ($valid_data) { |
|
395 | + $attendee = $this->get_attendee($where_cols_n_values); |
|
396 | + if ($attendee instanceof EE_Attendee) { |
|
397 | + return $attendee; |
|
398 | + } |
|
399 | + } |
|
400 | + return false; |
|
401 | + } |
|
402 | + |
|
403 | + |
|
404 | + |
|
405 | + /** |
|
406 | + * Takes an incoming array of EE_Registration ids |
|
407 | + * and sends back a list of corresponding non duplicate EE_Attendee objects. |
|
408 | + * |
|
409 | + * @since 4.3.0 |
|
410 | + * @param array $ids array of EE_Registration ids |
|
411 | + * @return EE_Attendee[]|EE_Base_Class[] |
|
412 | + * @throws EE_Error |
|
413 | + */ |
|
414 | + public function get_array_of_contacts_from_reg_ids($ids) |
|
415 | + { |
|
416 | + $ids = (array) $ids; |
|
417 | + $_where = array( |
|
418 | + 'Registration.REG_ID' => array('in', $ids), |
|
419 | + ); |
|
420 | + return $this->get_all(array($_where)); |
|
421 | + } |
|
422 | 422 | } |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public function get_attendee_field_for_system_question($system_question_string) |
286 | 286 | { |
287 | - return isset($this->_system_question_to_attendee_field_name[ $system_question_string ]) |
|
288 | - ? $this->_system_question_to_attendee_field_name[ $system_question_string ] |
|
287 | + return isset($this->_system_question_to_attendee_field_name[$system_question_string]) |
|
288 | + ? $this->_system_question_to_attendee_field_name[$system_question_string] |
|
289 | 289 | : null; |
290 | 290 | } |
291 | 291 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | return false; |
354 | 354 | } |
355 | 355 | $attendee = $this->get_all(array($where_cols_n_values)); |
356 | - if (! empty($attendee)) { |
|
356 | + if ( ! empty($attendee)) { |
|
357 | 357 | return array_shift($attendee); |
358 | 358 | } |
359 | 359 | return false; |