@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * remove param |
343 | 343 | * |
344 | 344 | * @access public |
345 | - * @param $key |
|
345 | + * @param string $key |
|
346 | 346 | * @return void |
347 | 347 | */ |
348 | 348 | public function un_set( $key ) { |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * add_output |
383 | 383 | * |
384 | 384 | * @access public |
385 | - * @param $string |
|
385 | + * @param string $string |
|
386 | 386 | * @return void |
387 | 387 | */ |
388 | 388 | public function add_output( $string ) { |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | if ( ! $this->get( 'post_name' ) ) { |
239 | 239 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
240 | 240 | $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) |
241 | - ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] |
|
242 | - : ''; |
|
241 | + ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] |
|
242 | + : ''; |
|
243 | 243 | // if the post type matches on of our then set the endpoint |
244 | 244 | if ( $post_name ) { |
245 | 245 | $this->set( 'post_name', $post_name ); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @return void |
262 | 262 | */ |
263 | 263 | public function set_espresso_page( $value = null ) { |
264 | - $this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page(); |
|
264 | + $this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page(); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * class EE_Request_Handler |
4 | 4 | * |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @access public |
50 | 50 | * @param EE_Request $request |
51 | 51 | */ |
52 | - public function __construct( EE_Request $request ) { |
|
52 | + public function __construct(EE_Request $request) { |
|
53 | 53 | // grab request vars |
54 | 54 | $this->_params = $request->params(); |
55 | 55 | // AJAX ??? |
56 | - $this->ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false; |
|
57 | - $this->front_ajax = defined( 'EE_FRONT_AJAX' ) && EE_FRONT_AJAX ? true : false; |
|
58 | - do_action( 'AHEE__EE_Request_Handler__construct__complete' ); |
|
56 | + $this->ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false; |
|
57 | + $this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX ? true : false; |
|
58 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | * @param WP $wp |
68 | 68 | * @return void |
69 | 69 | */ |
70 | - public function parse_request( $wp = null ) { |
|
70 | + public function parse_request($wp = null) { |
|
71 | 71 | //if somebody forgot to provide us with WP, that's ok because its global |
72 | - if ( ! $wp instanceof WP ) { |
|
72 | + if ( ! $wp instanceof WP) { |
|
73 | 73 | global $wp; |
74 | 74 | } |
75 | - $this->set_request_vars( $wp ); |
|
75 | + $this->set_request_vars($wp); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | * @param WP $wp |
85 | 85 | * @return void |
86 | 86 | */ |
87 | - public function set_request_vars( $wp = null ) { |
|
88 | - if ( ! is_admin() ) { |
|
87 | + public function set_request_vars($wp = null) { |
|
88 | + if ( ! is_admin()) { |
|
89 | 89 | // set request post_id |
90 | - $this->set( 'post_id', $this->get_post_id_from_request( $wp )); |
|
90 | + $this->set('post_id', $this->get_post_id_from_request($wp)); |
|
91 | 91 | // set request post name |
92 | - $this->set( 'post_name', $this->get_post_name_from_request( $wp )); |
|
92 | + $this->set('post_name', $this->get_post_name_from_request($wp)); |
|
93 | 93 | // set request post_type |
94 | - $this->set( 'post_type', $this->get_post_type_from_request( $wp )); |
|
94 | + $this->set('post_type', $this->get_post_type_from_request($wp)); |
|
95 | 95 | // true or false ? is this page being used by EE ? |
96 | 96 | $this->set_espresso_page(); |
97 | 97 | } |
@@ -106,19 +106,19 @@ discard block |
||
106 | 106 | * @param WP $wp |
107 | 107 | * @return int |
108 | 108 | */ |
109 | - public function get_post_id_from_request( $wp = null ) { |
|
110 | - if ( ! $wp instanceof WP ){ |
|
109 | + public function get_post_id_from_request($wp = null) { |
|
110 | + if ( ! $wp instanceof WP) { |
|
111 | 111 | global $wp; |
112 | 112 | } |
113 | 113 | $post_id = null; |
114 | - if ( isset( $wp->query_vars['p'] )) { |
|
114 | + if (isset($wp->query_vars['p'])) { |
|
115 | 115 | $post_id = $wp->query_vars['p']; |
116 | 116 | } |
117 | - if ( ! $post_id && isset( $wp->query_vars['page_id'] )) { |
|
117 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
118 | 118 | $post_id = $wp->query_vars['page_id']; |
119 | 119 | } |
120 | - if ( ! $post_id && isset( $wp->request ) && is_numeric( basename( $wp->request ))) { |
|
121 | - $post_id = basename( $wp->request ); |
|
120 | + if ( ! $post_id && isset($wp->request) && is_numeric(basename($wp->request))) { |
|
121 | + $post_id = basename($wp->request); |
|
122 | 122 | } |
123 | 123 | return $post_id; |
124 | 124 | } |
@@ -132,35 +132,35 @@ discard block |
||
132 | 132 | * @param WP $wp |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - public function get_post_name_from_request( $wp = null ) { |
|
136 | - if ( ! $wp instanceof WP ){ |
|
135 | + public function get_post_name_from_request($wp = null) { |
|
136 | + if ( ! $wp instanceof WP) { |
|
137 | 137 | global $wp; |
138 | 138 | } |
139 | 139 | $post_name = null; |
140 | - if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) { |
|
140 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
141 | 141 | $post_name = $wp->query_vars['name']; |
142 | 142 | } |
143 | - if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) { |
|
143 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
144 | 144 | $post_name = $wp->query_vars['pagename']; |
145 | 145 | } |
146 | - if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) { |
|
147 | - $possible_post_name = basename( $wp->request ); |
|
148 | - if ( ! is_numeric( $possible_post_name )) { |
|
146 | + if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) { |
|
147 | + $possible_post_name = basename($wp->request); |
|
148 | + if ( ! is_numeric($possible_post_name)) { |
|
149 | 149 | /** @type WPDB $wpdb */ |
150 | 150 | global $wpdb; |
151 | 151 | $SQL = "SELECT ID from {$wpdb->posts} WHERE post_status='publish' AND post_name=%s"; |
152 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name )); |
|
153 | - if ( $possible_post_name ) { |
|
152 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
153 | + if ($possible_post_name) { |
|
154 | 154 | $post_name = $possible_post_name; |
155 | 155 | } |
156 | 156 | } |
157 | 157 | } |
158 | - if ( ! $post_name && $this->get( 'post_id' )) { |
|
158 | + if ( ! $post_name && $this->get('post_id')) { |
|
159 | 159 | /** @type WPDB $wpdb */ |
160 | 160 | global $wpdb; |
161 | 161 | $SQL = "SELECT post_name from {$wpdb->posts} WHERE post_status='publish' AND ID=%d"; |
162 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' ))); |
|
163 | - if( $possible_post_name ) { |
|
162 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
163 | + if ($possible_post_name) { |
|
164 | 164 | $post_name = $possible_post_name; |
165 | 165 | } |
166 | 166 | } |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | * @param WP $wp |
177 | 177 | * @return mixed |
178 | 178 | */ |
179 | - public function get_post_type_from_request( $wp = null ) { |
|
180 | - if ( ! $wp instanceof WP ){ |
|
179 | + public function get_post_type_from_request($wp = null) { |
|
180 | + if ( ! $wp instanceof WP) { |
|
181 | 181 | global $wp; |
182 | 182 | } |
183 | - return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null; |
|
183 | + return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | |
@@ -190,18 +190,18 @@ discard block |
||
190 | 190 | * @param WP $wp |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - public function get_current_page_permalink( $wp = null ) { |
|
194 | - $post_id = $this->get_post_id_from_request( $wp ); |
|
195 | - if ( $post_id ) { |
|
196 | - $current_page_permalink = get_permalink( $post_id ); |
|
193 | + public function get_current_page_permalink($wp = null) { |
|
194 | + $post_id = $this->get_post_id_from_request($wp); |
|
195 | + if ($post_id) { |
|
196 | + $current_page_permalink = get_permalink($post_id); |
|
197 | 197 | } else { |
198 | - if ( ! $wp instanceof WP ) { |
|
198 | + if ( ! $wp instanceof WP) { |
|
199 | 199 | global $wp; |
200 | 200 | } |
201 | - if ( $wp->request ) { |
|
202 | - $current_page_permalink = site_url( $wp->request ); |
|
201 | + if ($wp->request) { |
|
202 | + $current_page_permalink = site_url($wp->request); |
|
203 | 203 | } else { |
204 | - $current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) ); |
|
204 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | return $current_page_permalink; |
@@ -218,31 +218,31 @@ discard block |
||
218 | 218 | public function test_for_espresso_page() { |
219 | 219 | global $wp; |
220 | 220 | /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
221 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
221 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
222 | 222 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
223 | - if ( is_array( $espresso_CPT_taxonomies ) ) { |
|
224 | - foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) { |
|
225 | - if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) { |
|
223 | + if (is_array($espresso_CPT_taxonomies)) { |
|
224 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) { |
|
225 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
226 | 226 | return true; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | 230 | // load espresso CPT endpoints |
231 | 231 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
232 | - $post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints ); |
|
233 | - $post_types = (array)$this->get( 'post_type' ); |
|
234 | - foreach ( $post_types as $post_type ) { |
|
232 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
233 | + $post_types = (array) $this->get('post_type'); |
|
234 | + foreach ($post_types as $post_type) { |
|
235 | 235 | // was a post name passed ? |
236 | - if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) { |
|
236 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
237 | 237 | // kk we know this is an espresso page, but is it a specific post ? |
238 | - if ( ! $this->get( 'post_name' ) ) { |
|
238 | + if ( ! $this->get('post_name')) { |
|
239 | 239 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
240 | - $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) |
|
241 | - ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] |
|
240 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) |
|
241 | + ? $post_type_CPT_endpoints[$this->get('post_type')] |
|
242 | 242 | : ''; |
243 | 243 | // if the post type matches on of our then set the endpoint |
244 | - if ( $post_name ) { |
|
245 | - $this->set( 'post_name', $post_name ); |
|
244 | + if ($post_name) { |
|
245 | + $this->set('post_name', $post_name); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | return true; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param null|bool $value |
261 | 261 | * @return void |
262 | 262 | */ |
263 | - public function set_espresso_page( $value = null ) { |
|
263 | + public function set_espresso_page($value = null) { |
|
264 | 264 | $this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page(); |
265 | 265 | } |
266 | 266 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return mixed |
274 | 274 | */ |
275 | 275 | public function is_espresso_page() { |
276 | - return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false; |
|
276 | + return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -297,14 +297,14 @@ discard block |
||
297 | 297 | * @param bool $override_ee |
298 | 298 | * @return void |
299 | 299 | */ |
300 | - public function set( $key, $value, $override_ee = false ) { |
|
300 | + public function set($key, $value, $override_ee = false) { |
|
301 | 301 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
302 | 302 | if ( |
303 | 303 | $key !== 'ee' || |
304 | - ( $key === 'ee' && empty( $this->_params['ee'] )) |
|
305 | - || ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee ) |
|
304 | + ($key === 'ee' && empty($this->_params['ee'])) |
|
305 | + || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee) |
|
306 | 306 | ) { |
307 | - $this->_params[ $key ] = $value; |
|
307 | + $this->_params[$key] = $value; |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * @param null $default |
319 | 319 | * @return mixed |
320 | 320 | */ |
321 | - public function get( $key, $default = null ) { |
|
322 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
321 | + public function get($key, $default = null) { |
|
322 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | * @param $key |
332 | 332 | * @return boolean |
333 | 333 | */ |
334 | - public function is_set( $key ) { |
|
335 | - return isset( $this->_params[ $key ] ) ? true : false; |
|
334 | + public function is_set($key) { |
|
335 | + return isset($this->_params[$key]) ? true : false; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | * @param $key |
345 | 345 | * @return void |
346 | 346 | */ |
347 | - public function un_set( $key ) { |
|
348 | - unset( $this->_params[ $key ] ); |
|
347 | + public function un_set($key) { |
|
348 | + unset($this->_params[$key]); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | * @param $value |
359 | 359 | * @return void |
360 | 360 | */ |
361 | - public function set_notice( $key, $value ) { |
|
362 | - $this->_notice[ $key ] = $value; |
|
361 | + public function set_notice($key, $value) { |
|
362 | + $this->_notice[$key] = $value; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | * @param $key |
372 | 372 | * @return mixed |
373 | 373 | */ |
374 | - public function get_notice( $key ) { |
|
375 | - return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null; |
|
374 | + public function get_notice($key) { |
|
375 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param $string |
385 | 385 | * @return void |
386 | 386 | */ |
387 | - public function add_output( $string ) { |
|
387 | + public function add_output($string) { |
|
388 | 388 | $this->_output .= $string; |
389 | 389 | } |
390 | 390 | |
@@ -406,8 +406,8 @@ discard block |
||
406 | 406 | * @param $item |
407 | 407 | * @param $key |
408 | 408 | */ |
409 | - public function sanitize_text_field_for_array_walk( &$item, &$key ) { |
|
410 | - $item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item ); |
|
409 | + public function sanitize_text_field_for_array_walk(&$item, &$key) { |
|
410 | + $item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param $b |
418 | 418 | * @return bool |
419 | 419 | */ |
420 | - public function __set($a,$b) { return false; } |
|
420 | + public function __set($a, $b) { return false; } |
|
421 | 421 | |
422 | 422 | |
423 | 423 |
@@ -1,6 +1,8 @@ discard block |
||
1 | 1 | <?php use EventEspresso\widgets\EspressoWidget; |
2 | 2 | |
3 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | +} |
|
4 | 6 | /** |
5 | 7 | * Event Espresso |
6 | 8 | * |
@@ -356,7 +358,7 @@ discard block |
||
356 | 358 | $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', get_option( 'time_format' )); |
357 | 359 | if ( $date_range == TRUE ) { |
358 | 360 | echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() ); |
359 | - }else{ |
|
361 | + } else{ |
|
360 | 362 | echo espresso_list_of_event_dates( $event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit ); |
361 | 363 | } |
362 | 364 | } |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct() { |
33 | 33 | parent::__construct( |
34 | - __( 'Event Espresso Upcoming Events', 'event_espresso' ), |
|
35 | - array( 'description' => __( 'A widget to display your upcoming events.', 'event_espresso' )) |
|
34 | + __('Event Espresso Upcoming Events', 'event_espresso'), |
|
35 | + array('description' => __('A widget to display your upcoming events.', 'event_espresso')) |
|
36 | 36 | ); |
37 | 37 | } |
38 | 38 | |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param array $instance Previously saved values from database. |
46 | 46 | * @return string|void |
47 | 47 | */ |
48 | - public function form( $instance ) { |
|
48 | + public function form($instance) { |
|
49 | 49 | |
50 | - EE_Registry::instance()->load_class( 'Question_Option', array(), FALSE, FALSE, TRUE ); |
|
50 | + EE_Registry::instance()->load_class('Question_Option', array(), FALSE, FALSE, TRUE); |
|
51 | 51 | // Set up some default widget settings. |
52 | 52 | $defaults = array( |
53 | 53 | 'title' => __('Upcoming Events', 'event_espresso'), |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | 'image_size' => 'medium' |
63 | 63 | ); |
64 | 64 | |
65 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
65 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
66 | 66 | // don't add HTML labels for EE_Form_Fields generated inputs |
67 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', '__return_empty_string' ); |
|
67 | + add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
|
68 | 68 | $yes_no_values = array( |
69 | - EE_Question_Option::new_instance( array( 'QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))), |
|
70 | - EE_Question_Option::new_instance( array( 'QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso'))) |
|
69 | + EE_Question_Option::new_instance(array('QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))), |
|
70 | + EE_Question_Option::new_instance(array('QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso'))) |
|
71 | 71 | ); |
72 | 72 | |
73 | 73 | ?> |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | <label for="<?php echo $this->get_field_id('title'); ?>"> |
79 | 79 | <?php _e('Title:', 'event_espresso'); ?> |
80 | 80 | </label> |
81 | - <input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" type="text" /> |
|
81 | + <input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" type="text" /> |
|
82 | 82 | </p> |
83 | 83 | <p> |
84 | 84 | <label for="<?php echo $this->get_field_id('category_name'); ?>"> |
@@ -87,16 +87,16 @@ discard block |
||
87 | 87 | <?php |
88 | 88 | $event_categories = array(); |
89 | 89 | /** @type EEM_Term $EEM_Term */ |
90 | - $EEM_Term = EE_Registry::instance()->load_model( 'Term' ); |
|
91 | - $categories = $EEM_Term->get_all_ee_categories( TRUE ); |
|
92 | - if ( $categories ) { |
|
93 | - foreach ( $categories as $category ) { |
|
94 | - if ( $category instanceof EE_Term ) { |
|
95 | - $event_categories[] = EE_Question_Option::new_instance( array( 'QSO_value' => $category->get( 'slug' ), 'QSO_desc' => $category->get( 'name' ))); |
|
90 | + $EEM_Term = EE_Registry::instance()->load_model('Term'); |
|
91 | + $categories = $EEM_Term->get_all_ee_categories(TRUE); |
|
92 | + if ($categories) { |
|
93 | + foreach ($categories as $category) { |
|
94 | + if ($category instanceof EE_Term) { |
|
95 | + $event_categories[] = EE_Question_Option::new_instance(array('QSO_value' => $category->get('slug'), 'QSO_desc' => $category->get('name'))); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
99 | - array_unshift( $event_categories, EE_Question_Option::new_instance( array( 'QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso')))); |
|
99 | + array_unshift($event_categories, EE_Question_Option::new_instance(array('QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso')))); |
|
100 | 100 | echo EEH_Form_Fields::select( |
101 | 101 | __('Event Category:', 'event_espresso'), |
102 | 102 | $instance['category_name'], |
@@ -133,16 +133,16 @@ discard block |
||
133 | 133 | <?php |
134 | 134 | $image_sizes = array(); |
135 | 135 | $sizes = get_intermediate_image_sizes(); |
136 | - if ( $sizes ) { |
|
136 | + if ($sizes) { |
|
137 | 137 | // loop thru images and create option objects out of them |
138 | - foreach ( $sizes as $image_size ) { |
|
139 | - $image_size = trim( $image_size ); |
|
138 | + foreach ($sizes as $image_size) { |
|
139 | + $image_size = trim($image_size); |
|
140 | 140 | // no big images plz |
141 | - if ( ! in_array( $image_size, array( 'large', 'post-thumbnail' ))) { |
|
142 | - $image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => $image_size, 'QSO_desc' => $image_size )); |
|
141 | + if ( ! in_array($image_size, array('large', 'post-thumbnail'))) { |
|
142 | + $image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => $image_size, 'QSO_desc' => $image_size)); |
|
143 | 143 | } |
144 | 144 | } |
145 | - $image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => 'none', 'QSO_desc' => __('don\'t show images', 'event_espresso') )); |
|
145 | + $image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => 'none', 'QSO_desc' => __('don\'t show images', 'event_espresso'))); |
|
146 | 146 | } |
147 | 147 | echo EEH_Form_Fields::select( |
148 | 148 | __('Image Size:', 'event_espresso'), |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | <label for="<?php echo $this->get_field_id('date_limit'); ?>"> |
201 | 201 | <?php _e('Number of Dates to Display:', 'event_espresso'); ?> |
202 | 202 | </label> |
203 | - <input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr( $instance['date_limit'] ); ?>" size="3" type="text" /> |
|
203 | + <input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr($instance['date_limit']); ?>" size="3" type="text" /> |
|
204 | 204 | </p> |
205 | 205 | <p> |
206 | 206 | <label for="<?php echo $this->get_field_id('date_range'); ?>"> |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return array Updated safe values to be saved. |
234 | 234 | */ |
235 | - public function update( $new_instance, $old_instance ) { |
|
235 | + public function update($new_instance, $old_instance) { |
|
236 | 236 | $instance = $old_instance; |
237 | - $instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : ''; |
|
237 | + $instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; |
|
238 | 238 | $instance['category_name'] = $new_instance['category_name']; |
239 | 239 | $instance['show_expired'] = $new_instance['show_expired']; |
240 | 240 | $instance['limit'] = $new_instance['limit']; |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | * @param array $args Widget arguments. |
258 | 258 | * @param array $instance Saved values from database. |
259 | 259 | */ |
260 | - public function widget( $args, $instance ) { |
|
260 | + public function widget($args, $instance) { |
|
261 | 261 | |
262 | 262 | global $post; |
263 | 263 | // make sure there is some kinda post object |
264 | - if ( $post instanceof WP_Post ) { |
|
264 | + if ($post instanceof WP_Post) { |
|
265 | 265 | $before_widget = ''; |
266 | 266 | $before_title = ''; |
267 | 267 | $after_title = ''; |
268 | 268 | $after_widget = ''; |
269 | 269 | // but NOT an events archives page, cuz that would be like two event lists on the same page |
270 | - $show_everywhere = isset( $instance['show_everywhere'] ) ? (bool) absint( $instance['show_everywhere'] ) : TRUE; |
|
271 | - if ( $show_everywhere || ! ( $post->post_type == 'espresso_events' && is_archive() )) { |
|
270 | + $show_everywhere = isset($instance['show_everywhere']) ? (bool) absint($instance['show_everywhere']) : TRUE; |
|
271 | + if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) { |
|
272 | 272 | // let's use some of the event helper functions' |
273 | 273 | // make separate vars out of attributes |
274 | 274 | |
@@ -287,83 +287,83 @@ discard block |
||
287 | 287 | // Before widget (defined by themes). |
288 | 288 | echo $before_widget; |
289 | 289 | // Display the widget title if one was input (before and after defined by themes). |
290 | - if ( ! empty( $title )) { |
|
291 | - echo $before_title . $title . $after_title; |
|
290 | + if ( ! empty($title)) { |
|
291 | + echo $before_title.$title.$after_title; |
|
292 | 292 | } |
293 | 293 | // grab widget settings |
294 | - $category = isset( $instance['category_name'] ) && ! empty( $instance['category_name'] ) ? $instance['category_name'] : FALSE; |
|
295 | - $show_expired = isset( $instance['show_expired'] ) ? (bool) absint( $instance['show_expired'] ) : FALSE; |
|
296 | - $image_size = isset( $instance['image_size'] ) && ! empty( $instance['image_size'] ) ? $instance['image_size'] : 'medium'; |
|
297 | - $show_desc = isset( $instance['show_desc'] ) ? (bool) absint( $instance['show_desc'] ) : TRUE; |
|
298 | - $show_dates = isset( $instance['show_dates'] ) ? (bool) absint( $instance['show_dates'] ) : TRUE; |
|
299 | - $date_limit = isset( $instance['date_limit'] ) && ! empty( $instance['date_limit'] ) ? $instance['date_limit'] : NULL; |
|
300 | - $date_range = isset( $instance['date_range'] ) && ! empty( $instance['date_range'] ) ? $instance['date_range'] : FALSE; |
|
294 | + $category = isset($instance['category_name']) && ! empty($instance['category_name']) ? $instance['category_name'] : FALSE; |
|
295 | + $show_expired = isset($instance['show_expired']) ? (bool) absint($instance['show_expired']) : FALSE; |
|
296 | + $image_size = isset($instance['image_size']) && ! empty($instance['image_size']) ? $instance['image_size'] : 'medium'; |
|
297 | + $show_desc = isset($instance['show_desc']) ? (bool) absint($instance['show_desc']) : TRUE; |
|
298 | + $show_dates = isset($instance['show_dates']) ? (bool) absint($instance['show_dates']) : TRUE; |
|
299 | + $date_limit = isset($instance['date_limit']) && ! empty($instance['date_limit']) ? $instance['date_limit'] : NULL; |
|
300 | + $date_range = isset($instance['date_range']) && ! empty($instance['date_range']) ? $instance['date_range'] : FALSE; |
|
301 | 301 | // start to build our where clause |
302 | 302 | $where = array( |
303 | 303 | // 'Datetime.DTT_is_primary' => 1, |
304 | - 'status' => array( 'IN', array( 'publish', 'sold_out' ) ) |
|
304 | + 'status' => array('IN', array('publish', 'sold_out')) |
|
305 | 305 | ); |
306 | 306 | // add category |
307 | - if ( $category ) { |
|
307 | + if ($category) { |
|
308 | 308 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
309 | 309 | $where['Term_Taxonomy.Term.slug'] = $category; |
310 | 310 | } |
311 | 311 | // if NOT expired then we want events that start today or in the future |
312 | - if ( ! $show_expired ) { |
|
313 | - $where['Datetime.DTT_EVT_end'] = array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ); |
|
312 | + if ( ! $show_expired) { |
|
313 | + $where['Datetime.DTT_EVT_end'] = array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); |
|
314 | 314 | } |
315 | 315 | // allow $where to be filtered |
316 | - $where = apply_filters( 'FHEE__EEW_Upcoming_Events__widget__where', $where, $category, $show_expired ); |
|
316 | + $where = apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $category, $show_expired); |
|
317 | 317 | // run the query |
318 | - $events = EE_Registry::instance()->load_model( 'Event' )->get_all( array( |
|
318 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array( |
|
319 | 319 | $where, |
320 | - 'limit' => $instance['limit'] > 0 ? '0,' . $instance['limit'] : '0,10', |
|
320 | + 'limit' => $instance['limit'] > 0 ? '0,'.$instance['limit'] : '0,10', |
|
321 | 321 | 'order_by' => 'Datetime.DTT_EVT_start', |
322 | 322 | 'order' => 'ASC', |
323 | 323 | 'group_by' => 'EVT_ID' |
324 | 324 | )); |
325 | 325 | |
326 | - if ( ! empty( $events )) { |
|
326 | + if ( ! empty($events)) { |
|
327 | 327 | echo '<ul class="ee-upcoming-events-widget-ul">'; |
328 | - foreach ( $events as $event ) { |
|
329 | - if ( $event instanceof EE_Event && ( !is_single() || $post->ID != $event->ID() ) ) { |
|
328 | + foreach ($events as $event) { |
|
329 | + if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) { |
|
330 | 330 | //printr( $event, '$event <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
331 | - echo '<li id="ee-upcoming-events-widget-li-' . $event->ID() . '" class="ee-upcoming-events-widget-li">'; |
|
331 | + echo '<li id="ee-upcoming-events-widget-li-'.$event->ID().'" class="ee-upcoming-events-widget-li">'; |
|
332 | 332 | // how big is the event name ? |
333 | - $name_length = strlen( $event->name() ); |
|
334 | - switch( $name_length ) { |
|
333 | + $name_length = strlen($event->name()); |
|
334 | + switch ($name_length) { |
|
335 | 335 | case $name_length > 70 : |
336 | - $len_class = ' three-line'; |
|
336 | + $len_class = ' three-line'; |
|
337 | 337 | break; |
338 | 338 | case $name_length > 35 : |
339 | - $len_class = ' two-line'; |
|
339 | + $len_class = ' two-line'; |
|
340 | 340 | break; |
341 | 341 | default : |
342 | - $len_class = ' one-line'; |
|
342 | + $len_class = ' one-line'; |
|
343 | 343 | } |
344 | - $event_url = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event ); |
|
345 | - echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a' . $len_class . '" href="' . $event_url . '">' . $event->name() . '</a></h5>'; |
|
346 | - if ( post_password_required( $event->ID() ) ) { |
|
347 | - $pswd_form = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form( $event->ID() ), $event ); |
|
344 | + $event_url = apply_filters('FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event); |
|
345 | + echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a'.$len_class.'" href="'.$event_url.'">'.$event->name().'</a></h5>'; |
|
346 | + if (post_password_required($event->ID())) { |
|
347 | + $pswd_form = apply_filters('FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form($event->ID()), $event); |
|
348 | 348 | echo $pswd_form; |
349 | 349 | } else { |
350 | - if ( has_post_thumbnail( $event->ID() ) && $image_size != 'none' ) { |
|
351 | - echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="' . $event_url . '">' . get_the_post_thumbnail( $event->ID(), $image_size ) . '</a></div>'; |
|
350 | + if (has_post_thumbnail($event->ID()) && $image_size != 'none') { |
|
351 | + echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="'.$event_url.'">'.get_the_post_thumbnail($event->ID(), $image_size).'</a></div>'; |
|
352 | 352 | } |
353 | - $desc = $event->short_description( 25 ); |
|
354 | - if ( $show_dates ) { |
|
355 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', get_option( 'date_format' )); |
|
356 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', get_option( 'time_format' )); |
|
357 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', get_option( 'date_format' )); |
|
358 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', get_option( 'time_format' )); |
|
359 | - if ( $date_range == TRUE ) { |
|
360 | - echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() ); |
|
361 | - }else{ |
|
362 | - echo espresso_list_of_event_dates( $event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit ); |
|
353 | + $desc = $event->short_description(25); |
|
354 | + if ($show_dates) { |
|
355 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', get_option('date_format')); |
|
356 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', get_option('time_format')); |
|
357 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', get_option('date_format')); |
|
358 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', get_option('time_format')); |
|
359 | + if ($date_range == TRUE) { |
|
360 | + echo espresso_event_date_range($date_format, $time_format, $single_date_format, $single_time_format, $event->ID()); |
|
361 | + } else { |
|
362 | + echo espresso_list_of_event_dates($event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit); |
|
363 | 363 | } |
364 | 364 | } |
365 | - if ( $show_desc && $desc ) { |
|
366 | - echo '<p style="margin-top: .5em">' . $desc . '</p>'; |
|
365 | + if ($show_desc && $desc) { |
|
366 | + echo '<p style="margin-top: .5em">'.$desc.'</p>'; |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | echo '</li>'; |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @return string |
388 | 388 | */ |
389 | 389 | public function make_the_title_a_link($title) { |
390 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
390 | + return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>'; |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | } |
@@ -18,31 +18,31 @@ |
||
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @param string $name |
|
23 | - * @param array $widget_options |
|
24 | - * @param array $control_options |
|
25 | - */ |
|
26 | - public function __construct($name = '', array $widget_options = array(), array $control_options = array()) |
|
27 | - { |
|
28 | - $id_base = EspressoWidget::getIdBase(get_class($this)); |
|
29 | - $control_options['id_base'] = $id_base; |
|
30 | - $control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300; |
|
31 | - $control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350; |
|
32 | - // Register widget with WordPress |
|
33 | - parent::__construct($id_base, $name, $widget_options, $control_options); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @param string $widget_class |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public static function getIdBase($widget_class) |
|
43 | - { |
|
44 | - return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
45 | - } |
|
21 | + /** |
|
22 | + * @param string $name |
|
23 | + * @param array $widget_options |
|
24 | + * @param array $control_options |
|
25 | + */ |
|
26 | + public function __construct($name = '', array $widget_options = array(), array $control_options = array()) |
|
27 | + { |
|
28 | + $id_base = EspressoWidget::getIdBase(get_class($this)); |
|
29 | + $control_options['id_base'] = $id_base; |
|
30 | + $control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300; |
|
31 | + $control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350; |
|
32 | + // Register widget with WordPress |
|
33 | + parent::__construct($id_base, $name, $widget_options, $control_options); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @param string $widget_class |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public static function getIdBase($widget_class) |
|
43 | + { |
|
44 | + return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | 48 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | */ |
42 | 42 | public static function getIdBase($widget_class) |
43 | 43 | { |
44 | - return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
44 | + return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)).'-widget'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 |
@@ -2,8 +2,7 @@ |
||
2 | 2 | |
3 | 3 | /** |
4 | 4 | * Goes through all the posts and pages, and converts old shortcodes to new ones |
5 | - |
|
6 | -*/ |
|
5 | + */ |
|
7 | 6 | |
8 | 7 | class EE_DMS_4_1_0_shortcodes extends EE_Data_Migration_Script_Stage{ |
9 | 8 | function __construct() { |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | */ |
7 | 7 | |
8 | -class EE_DMS_4_1_0_shortcodes extends EE_Data_Migration_Script_Stage{ |
|
8 | +class EE_DMS_4_1_0_shortcodes extends EE_Data_Migration_Script_Stage { |
|
9 | 9 | function __construct() { |
10 | 10 | global $wpdb; |
11 | 11 | $this->_pretty_name = __("Shortcodes", "event_espresso"); |
@@ -15,27 +15,27 @@ discard block |
||
15 | 15 | protected function _migrate_old_row($old_row) { |
16 | 16 | $new_post_content = $this->_change_event_list_shortcode($old_row['post_content']); |
17 | 17 | global $wpdb; |
18 | - $wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d",$new_post_content,$old_row['ID'])); |
|
18 | + $wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID'])); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
22 | 22 | * replaces [EVENT_LIST... with [ESPRESSO_EVENTS...] |
23 | 23 | * @param string $old_content |
24 | 24 | */ |
25 | - private function _change_event_list_shortcode($old_content){ |
|
26 | - return str_replace("[EVENT_LIST","[ESPRESSO_EVENTS",$old_content); |
|
25 | + private function _change_event_list_shortcode($old_content) { |
|
26 | + return str_replace("[EVENT_LIST", "[ESPRESSO_EVENTS", $old_content); |
|
27 | 27 | } |
28 | 28 | |
29 | - function _migration_step($num_items=50){ |
|
29 | + function _migration_step($num_items = 50) { |
|
30 | 30 | global $wpdb; |
31 | 31 | $start_at_record = $this->count_records_migrated(); |
32 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d",$start_at_record,$num_items),ARRAY_A); |
|
32 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
33 | 33 | $items_actually_migrated = 0; |
34 | - foreach($rows as $old_row){ |
|
34 | + foreach ($rows as $old_row) { |
|
35 | 35 | $this->_migrate_old_row($old_row); |
36 | 36 | $items_actually_migrated++; |
37 | 37 | } |
38 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
38 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
39 | 39 | $this->set_completed(); |
40 | 40 | } |
41 | 41 | return $items_actually_migrated; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | return $count; |
47 | 47 | } |
48 | 48 | |
49 | - private function _sql_to_only_select_non_drafts(){ |
|
49 | + private function _sql_to_only_select_non_drafts() { |
|
50 | 50 | return " WHERE post_type NOT IN ('revision','auto-draft') "; |
51 | 51 | } |
52 | 52 |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | $stages = glob(EE_CORE . 'data_migration_scripts/4_3_0_stages/*'); |
15 | 15 | $class_to_filepath = array(); |
16 | 16 | if ( ! empty($stages)) { |
17 | - foreach ($stages as $filepath) { |
|
18 | - $matches = array(); |
|
19 | - preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
20 | - $class_to_filepath[$matches[1]] = $filepath; |
|
21 | - } |
|
17 | + foreach ($stages as $filepath) { |
|
18 | + $matches = array(); |
|
19 | + preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
20 | + $class_to_filepath[$matches[1]] = $filepath; |
|
21 | + } |
|
22 | 22 | } |
23 | 23 | //give addons a chance to autoload their stages too |
24 | 24 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_3_0__autoloaded_stages', $class_to_filepath); |
@@ -31,56 +31,56 @@ discard block |
||
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * EE_DMS_Core_4_3_0 constructor. |
|
36 | - * |
|
37 | - * @param TableManager $table_manager |
|
38 | - * @param TableAnalysis $table_analysis |
|
39 | - */ |
|
40 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
41 | - { |
|
42 | - $this->_pretty_name = __("Data Update to Event Espresso 4.3.0", "event_espresso"); |
|
43 | - $this->_priority = 10; |
|
44 | - $this->_migration_stages = array( |
|
45 | - new EE_DMS_4_3_0_question_option_order(), |
|
46 | - new EE_DMS_4_3_0_event_message_templates(), |
|
47 | - ); |
|
48 | - parent::__construct($table_manager, $table_analysis); |
|
49 | - } |
|
34 | + /** |
|
35 | + * EE_DMS_Core_4_3_0 constructor. |
|
36 | + * |
|
37 | + * @param TableManager $table_manager |
|
38 | + * @param TableAnalysis $table_analysis |
|
39 | + */ |
|
40 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
41 | + { |
|
42 | + $this->_pretty_name = __("Data Update to Event Espresso 4.3.0", "event_espresso"); |
|
43 | + $this->_priority = 10; |
|
44 | + $this->_migration_stages = array( |
|
45 | + new EE_DMS_4_3_0_question_option_order(), |
|
46 | + new EE_DMS_4_3_0_event_message_templates(), |
|
47 | + ); |
|
48 | + parent::__construct($table_manager, $table_analysis); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | 52 | |
53 | - public function can_migrate_from_version($version_array) |
|
54 | - { |
|
55 | - $version_string = $version_array['Core']; |
|
56 | - if (version_compare($version_string, '4.3.0', '<=') && version_compare($version_string, '4.2.0', '>=')) { |
|
53 | + public function can_migrate_from_version($version_array) |
|
54 | + { |
|
55 | + $version_string = $version_array['Core']; |
|
56 | + if (version_compare($version_string, '4.3.0', '<=') && version_compare($version_string, '4.2.0', '>=')) { |
|
57 | 57 | // echo "$version_string can be migrated fro"; |
58 | - return true; |
|
59 | - } elseif ( ! $version_string) { |
|
58 | + return true; |
|
59 | + } elseif ( ! $version_string) { |
|
60 | 60 | // echo "no version string provided: $version_string"; |
61 | - //no version string provided... this must be pre 4.2 |
|
62 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
63 | - } else { |
|
61 | + //no version string provided... this must be pre 4.2 |
|
62 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
63 | + } else { |
|
64 | 64 | // echo "$version_string doesnt apply"; |
65 | - return false; |
|
66 | - } |
|
67 | - } |
|
65 | + return false; |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | - public function schema_changes_before_migration() |
|
72 | - { |
|
73 | - //relies on 4.1's EEH_Activation::create_table |
|
74 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
75 | - $table_name = 'esp_answer'; |
|
76 | - $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
71 | + public function schema_changes_before_migration() |
|
72 | + { |
|
73 | + //relies on 4.1's EEH_Activation::create_table |
|
74 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
75 | + $table_name = 'esp_answer'; |
|
76 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
77 | 77 | REG_ID INT UNSIGNED NOT NULL, |
78 | 78 | QST_ID INT UNSIGNED NOT NULL, |
79 | 79 | ANS_value TEXT NOT NULL, |
80 | 80 | PRIMARY KEY (ANS_ID)"; |
81 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
82 | - $table_name = 'esp_attendee_meta'; |
|
83 | - $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
81 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
82 | + $table_name = 'esp_attendee_meta'; |
|
83 | + $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
84 | 84 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
85 | 85 | ATT_fname VARCHAR(45) NOT NULL, |
86 | 86 | ATT_lname VARCHAR(45) NOT NULL, |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | KEY ATT_fname (ATT_fname), |
97 | 97 | KEY ATT_lname (ATT_lname), |
98 | 98 | KEY ATT_email (ATT_email)"; |
99 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
100 | - $table_name = 'esp_country'; |
|
101 | - $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
99 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
100 | + $table_name = 'esp_country'; |
|
101 | + $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
102 | 102 | CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL, |
103 | 103 | RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL, |
104 | 104 | CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL, |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | CNT_is_EU TINYINT(1) DEFAULT '0', |
115 | 115 | CNT_active TINYINT(1) DEFAULT '0', |
116 | 116 | PRIMARY KEY (CNT_ISO)"; |
117 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
118 | - $table_name = 'esp_datetime'; |
|
119 | - $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
117 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
118 | + $table_name = 'esp_datetime'; |
|
119 | + $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
120 | 120 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
121 | 121 | DTT_name VARCHAR(255) NOT NULL DEFAULT '', |
122 | 122 | DTT_description TEXT NOT NULL, |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | PRIMARY KEY (DTT_ID), |
132 | 132 | KEY EVT_ID (EVT_ID), |
133 | 133 | KEY DTT_is_primary (DTT_is_primary)"; |
134 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | - $table_name = 'esp_event_meta'; |
|
136 | - $sql = " |
|
134 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | + $table_name = 'esp_event_meta'; |
|
136 | + $sql = " |
|
137 | 137 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
138 | 138 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
139 | 139 | EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -148,31 +148,31 @@ discard block |
||
148 | 148 | EVT_external_URL VARCHAR(200) NULL, |
149 | 149 | EVT_donations TINYINT(1) NULL, |
150 | 150 | PRIMARY KEY (EVTM_ID)"; |
151 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - $table_name = 'esp_event_question_group'; |
|
153 | - $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
151 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + $table_name = 'esp_event_question_group'; |
|
153 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
154 | 154 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
155 | 155 | QSG_ID INT UNSIGNED NOT NULL, |
156 | 156 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
157 | 157 | PRIMARY KEY (EQG_ID)"; |
158 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
159 | - $table_name = 'esp_event_venue'; |
|
160 | - $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
158 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
159 | + $table_name = 'esp_event_venue'; |
|
160 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
161 | 161 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
162 | 162 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
163 | 163 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
164 | 164 | PRIMARY KEY (EVV_ID)"; |
165 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
166 | - $table_name = 'esp_extra_meta'; |
|
167 | - $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
165 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
166 | + $table_name = 'esp_extra_meta'; |
|
167 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
168 | 168 | OBJ_ID INT(11) DEFAULT NULL, |
169 | 169 | EXM_type VARCHAR(45) DEFAULT NULL, |
170 | 170 | EXM_key VARCHAR(45) DEFAULT NULL, |
171 | 171 | EXM_value TEXT, |
172 | 172 | PRIMARY KEY (EXM_ID)"; |
173 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
174 | - $table_name = 'esp_line_item'; |
|
175 | - $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
173 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
174 | + $table_name = 'esp_line_item'; |
|
175 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
176 | 176 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
177 | 177 | TXN_ID INT(11) DEFAULT NULL, |
178 | 178 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -188,19 +188,19 @@ discard block |
||
188 | 188 | OBJ_ID INT(11) DEFAULT NULL, |
189 | 189 | OBJ_type VARCHAR(45)DEFAULT NULL, |
190 | 190 | PRIMARY KEY (LIN_ID)"; |
191 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
192 | - $table_name = 'esp_message_template'; |
|
193 | - $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
191 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
192 | + $table_name = 'esp_message_template'; |
|
193 | + $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
194 | 194 | GRP_ID INT(10) UNSIGNED NOT NULL, |
195 | 195 | MTP_context VARCHAR(50) NOT NULL, |
196 | 196 | MTP_template_field VARCHAR(30) NOT NULL, |
197 | 197 | MTP_content TEXT NOT NULL, |
198 | 198 | PRIMARY KEY (MTP_ID), |
199 | 199 | KEY GRP_ID (GRP_ID)"; |
200 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
201 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
202 | - $table_name = 'esp_message_template_group'; |
|
203 | - $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
200 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
201 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
202 | + $table_name = 'esp_message_template_group'; |
|
203 | + $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
204 | 204 | MTP_user_id INT(10) NOT NULL DEFAULT '1', |
205 | 205 | MTP_name VARCHAR(245) NOT NULL DEFAULT '', |
206 | 206 | MTP_description VARCHAR(245) NOT NULL DEFAULT '', |
@@ -212,17 +212,17 @@ discard block |
||
212 | 212 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
213 | 213 | PRIMARY KEY (GRP_ID), |
214 | 214 | KEY MTP_user_id (MTP_user_id)"; |
215 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | - $table_name = 'esp_event_message_template'; |
|
217 | - $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
215 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | + $table_name = 'esp_event_message_template'; |
|
217 | + $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
218 | 218 | EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
219 | 219 | GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0, |
220 | 220 | PRIMARY KEY (EMT_ID), |
221 | 221 | KEY EVT_ID (EVT_ID), |
222 | 222 | KEY GRP_ID (GRP_ID)"; |
223 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | - $table_name = 'esp_payment'; |
|
225 | - $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
223 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | + $table_name = 'esp_payment'; |
|
225 | + $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
226 | 226 | TXN_ID INT(10) UNSIGNED DEFAULT NULL, |
227 | 227 | STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL, |
228 | 228 | PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | PRIMARY KEY (PAY_ID), |
239 | 239 | KEY TXN_ID (TXN_ID), |
240 | 240 | KEY PAY_timestamp (PAY_timestamp)"; |
241 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
242 | - $table_name = "esp_ticket"; |
|
243 | - $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
241 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
242 | + $table_name = "esp_ticket"; |
|
243 | + $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
244 | 244 | TTM_ID INT(10) UNSIGNED NOT NULL, |
245 | 245 | TKT_name VARCHAR(245) NOT NULL DEFAULT '', |
246 | 246 | TKT_description TEXT NOT NULL, |
@@ -260,28 +260,28 @@ discard block |
||
260 | 260 | TKT_parent INT(10) UNSIGNED DEFAULT '0', |
261 | 261 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
262 | 262 | PRIMARY KEY (TKT_ID)"; |
263 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
264 | - $table_name = "esp_ticket_price"; |
|
265 | - $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
263 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
264 | + $table_name = "esp_ticket_price"; |
|
265 | + $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
266 | 266 | TKT_ID INT(10) UNSIGNED NOT NULL, |
267 | 267 | PRC_ID INT(10) UNSIGNED NOT NULL, |
268 | 268 | PRIMARY KEY (TKP_ID)"; |
269 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
270 | - $table_name = "esp_datetime_ticket"; |
|
271 | - $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
269 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
270 | + $table_name = "esp_datetime_ticket"; |
|
271 | + $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
272 | 272 | DTT_ID INT(10) UNSIGNED NOT NULL, |
273 | 273 | TKT_ID INT(10) UNSIGNED NOT NULL, |
274 | 274 | PRIMARY KEY (DTK_ID)"; |
275 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
276 | - $table_name = "esp_ticket_template"; |
|
277 | - $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
275 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
276 | + $table_name = "esp_ticket_template"; |
|
277 | + $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
278 | 278 | TTM_name VARCHAR(45) NOT NULL, |
279 | 279 | TTM_description TEXT, |
280 | 280 | TTM_file VARCHAR(45), |
281 | 281 | PRIMARY KEY (TTM_ID)"; |
282 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
283 | - $table_name = "esp_price"; |
|
284 | - $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
282 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
283 | + $table_name = "esp_price"; |
|
284 | + $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
285 | 285 | PRT_ID TINYINT(3) UNSIGNED NOT NULL, |
286 | 286 | PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
287 | 287 | PRC_name VARCHAR(245) NOT NULL, |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | PRC_order TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', |
293 | 293 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
294 | 294 | PRIMARY KEY (PRC_ID)"; |
295 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
296 | - $table_name = "esp_price_type"; |
|
297 | - $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
295 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
296 | + $table_name = "esp_price_type"; |
|
297 | + $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
298 | 298 | PRT_name VARCHAR(45) NOT NULL, |
299 | 299 | PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1', |
300 | 300 | PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0', |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | PRT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
303 | 303 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
304 | 304 | PRIMARY KEY (PRT_ID)"; |
305 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
306 | - $table_name = 'esp_question'; |
|
307 | - $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
305 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
306 | + $table_name = 'esp_question'; |
|
307 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
308 | 308 | QST_display_text TEXT NOT NULL, |
309 | 309 | QST_admin_label VARCHAR(255) NOT NULL, |
310 | 310 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -316,10 +316,10 @@ discard block |
||
316 | 316 | QST_wp_user BIGINT UNSIGNED NULL, |
317 | 317 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
318 | 318 | PRIMARY KEY (QST_ID)'; |
319 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
320 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
321 | - $table_name = 'esp_question_group'; |
|
322 | - $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
319 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
320 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
321 | + $table_name = 'esp_question_group'; |
|
322 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
323 | 323 | QSG_name VARCHAR(255) NOT NULL, |
324 | 324 | QSG_identifier VARCHAR(100) NOT NULL, |
325 | 325 | QSG_desc TEXT NULL, |
@@ -330,25 +330,25 @@ discard block |
||
330 | 330 | QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
331 | 331 | PRIMARY KEY (QSG_ID), |
332 | 332 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
333 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
334 | - $table_name = 'esp_question_group_question'; |
|
335 | - $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
333 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
334 | + $table_name = 'esp_question_group_question'; |
|
335 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
336 | 336 | QSG_ID INT UNSIGNED NOT NULL, |
337 | 337 | QST_ID INT UNSIGNED NOT NULL, |
338 | 338 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
339 | 339 | PRIMARY KEY (QGQ_ID) "; |
340 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
341 | - $table_name = 'esp_question_option'; |
|
342 | - $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
340 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
341 | + $table_name = 'esp_question_option'; |
|
342 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
343 | 343 | QSO_value VARCHAR(255) NOT NULL, |
344 | 344 | QSO_desc TEXT NOT NULL, |
345 | 345 | QST_ID INT UNSIGNED NOT NULL, |
346 | 346 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
347 | 347 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
348 | 348 | PRIMARY KEY (QSO_ID)"; |
349 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
350 | - $table_name = 'esp_registration'; |
|
351 | - $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
349 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
350 | + $table_name = 'esp_registration'; |
|
351 | + $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
352 | 352 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
353 | 353 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
354 | 354 | TXN_ID INT(10) UNSIGNED NOT NULL, |
@@ -371,25 +371,25 @@ discard block |
||
371 | 371 | KEY STS_ID (STS_ID), |
372 | 372 | KEY REG_url_link (REG_url_link), |
373 | 373 | KEY REG_code (REG_code)"; |
374 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
375 | - $table_name = 'esp_checkin'; |
|
376 | - $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
374 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
375 | + $table_name = 'esp_checkin'; |
|
376 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
377 | 377 | REG_ID INT(10) UNSIGNED NOT NULL, |
378 | 378 | DTT_ID INT(10) UNSIGNED NOT NULL, |
379 | 379 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
380 | 380 | CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
381 | 381 | PRIMARY KEY (CHK_ID)"; |
382 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
383 | - $table_name = 'esp_state'; |
|
384 | - $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
382 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
383 | + $table_name = 'esp_state'; |
|
384 | + $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
385 | 385 | CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
386 | 386 | STA_abbrev VARCHAR(6) COLLATE utf8_bin NOT NULL, |
387 | 387 | STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL, |
388 | 388 | STA_active TINYINT(1) DEFAULT '1', |
389 | 389 | PRIMARY KEY (STA_ID)"; |
390 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
391 | - $table_name = 'esp_status'; |
|
392 | - $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
390 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
391 | + $table_name = 'esp_status'; |
|
392 | + $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
393 | 393 | STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL, |
394 | 394 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
395 | 395 | STS_can_edit TINYINT(1) NOT NULL DEFAULT 0, |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | STS_open TINYINT(1) NOT NULL DEFAULT 1, |
398 | 398 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
399 | 399 | KEY STS_type (STS_type)"; |
400 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
401 | - $table_name = 'esp_transaction'; |
|
402 | - $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
400 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
401 | + $table_name = 'esp_transaction'; |
|
402 | + $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
403 | 403 | TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
404 | 404 | TXN_total DECIMAL(10,3) DEFAULT '0.00', |
405 | 405 | TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
@@ -409,9 +409,9 @@ discard block |
||
409 | 409 | PRIMARY KEY (TXN_ID), |
410 | 410 | KEY TXN_timestamp (TXN_timestamp), |
411 | 411 | KEY STS_ID (STS_ID)"; |
412 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
413 | - $table_name = 'esp_venue_meta'; |
|
414 | - $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
412 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
413 | + $table_name = 'esp_venue_meta'; |
|
414 | + $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
415 | 415 | VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
416 | 416 | VNU_address VARCHAR(255) DEFAULT NULL, |
417 | 417 | VNU_address2 VARCHAR(255) DEFAULT NULL, |
@@ -429,79 +429,79 @@ discard block |
||
429 | 429 | PRIMARY KEY (VNUM_ID), |
430 | 430 | KEY STA_ID (STA_ID), |
431 | 431 | KEY CNT_ISO (CNT_ISO)"; |
432 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | - $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
434 | - //setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
435 | - //(because many need to convert old string states to foreign keys into the states table) |
|
436 | - $script_with_defaults->insert_default_states(); |
|
437 | - $script_with_defaults->insert_default_countries(); |
|
438 | - //setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
439 | - $script_with_defaults->insert_default_price_types(); |
|
440 | - $script_with_defaults->insert_default_prices(); |
|
441 | - //but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's |
|
442 | - $this->insert_default_tickets(); |
|
443 | - //setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
444 | - EE_Config::instance()->update_espresso_config(false, true); |
|
445 | - return true; |
|
446 | - } |
|
447 | - |
|
448 | - |
|
449 | - |
|
450 | - /** |
|
451 | - * @return boolean |
|
452 | - */ |
|
453 | - public function schema_changes_after_migration() |
|
454 | - { |
|
455 | - return true; |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - |
|
460 | - public function migration_page_hooks() |
|
461 | - { |
|
462 | - } |
|
463 | - |
|
464 | - |
|
465 | - |
|
466 | - /** |
|
467 | - * insert DEFAULT ticket |
|
468 | - * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field |
|
469 | - * |
|
470 | - * @access public |
|
471 | - * @static |
|
472 | - * @return void |
|
473 | - */ |
|
474 | - public function insert_default_tickets() |
|
475 | - { |
|
476 | - global $wpdb; |
|
477 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
478 | - if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
479 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
480 | - $tickets_exist = $wpdb->get_var($SQL); |
|
481 | - if ( ! $tickets_exist) { |
|
482 | - $SQL = "INSERT INTO $ticket_table |
|
432 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | + $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
434 | + //setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
435 | + //(because many need to convert old string states to foreign keys into the states table) |
|
436 | + $script_with_defaults->insert_default_states(); |
|
437 | + $script_with_defaults->insert_default_countries(); |
|
438 | + //setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
439 | + $script_with_defaults->insert_default_price_types(); |
|
440 | + $script_with_defaults->insert_default_prices(); |
|
441 | + //but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's |
|
442 | + $this->insert_default_tickets(); |
|
443 | + //setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
444 | + EE_Config::instance()->update_espresso_config(false, true); |
|
445 | + return true; |
|
446 | + } |
|
447 | + |
|
448 | + |
|
449 | + |
|
450 | + /** |
|
451 | + * @return boolean |
|
452 | + */ |
|
453 | + public function schema_changes_after_migration() |
|
454 | + { |
|
455 | + return true; |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + |
|
460 | + public function migration_page_hooks() |
|
461 | + { |
|
462 | + } |
|
463 | + |
|
464 | + |
|
465 | + |
|
466 | + /** |
|
467 | + * insert DEFAULT ticket |
|
468 | + * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field |
|
469 | + * |
|
470 | + * @access public |
|
471 | + * @static |
|
472 | + * @return void |
|
473 | + */ |
|
474 | + public function insert_default_tickets() |
|
475 | + { |
|
476 | + global $wpdb; |
|
477 | + $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
478 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
479 | + $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
480 | + $tickets_exist = $wpdb->get_var($SQL); |
|
481 | + if ( ! $tickets_exist) { |
|
482 | + $SQL = "INSERT INTO $ticket_table |
|
483 | 483 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
484 | 484 | ( 1, 0, '" |
485 | - . __("Free Ticket", "event_espresso") |
|
486 | - . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
487 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
488 | - $wpdb->query($SQL); |
|
489 | - } |
|
490 | - } |
|
491 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
492 | - if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
493 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
494 | - $ticket_prc_exist = $wpdb->get_var($SQL); |
|
495 | - if ( ! $ticket_prc_exist) { |
|
496 | - $SQL = "INSERT INTO $ticket_price_table |
|
485 | + . __("Free Ticket", "event_espresso") |
|
486 | + . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
487 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
488 | + $wpdb->query($SQL); |
|
489 | + } |
|
490 | + } |
|
491 | + $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
492 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
493 | + $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
494 | + $ticket_prc_exist = $wpdb->get_var($SQL); |
|
495 | + if ( ! $ticket_prc_exist) { |
|
496 | + $SQL = "INSERT INTO $ticket_price_table |
|
497 | 497 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
498 | 498 | ( 1, 1, 1 ) |
499 | 499 | "; |
500 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
501 | - $wpdb->query($SQL); |
|
502 | - } |
|
503 | - } |
|
504 | - } |
|
500 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
501 | + $wpdb->query($SQL); |
|
502 | + } |
|
503 | + } |
|
504 | + } |
|
505 | 505 | |
506 | 506 | } |
507 | 507 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -14,602 +14,602 @@ discard block |
||
14 | 14 | class EE_Register_CPTs |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * This property is used to hold an array of EE_default_term objects assigned to a custom post type when the post |
|
19 | - * for that post type is published with no terms set for the taxonomy. |
|
20 | - * |
|
21 | - * @var array of EE_Default_Term objects |
|
22 | - */ |
|
23 | - protected $_default_terms = array(); |
|
24 | - |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * constructor |
|
29 | - * instantiated at init priority 5 |
|
30 | - */ |
|
31 | - public function __construct() |
|
32 | - { |
|
33 | - // register taxonomies |
|
34 | - $taxonomies = self::get_taxonomies(); |
|
35 | - foreach ($taxonomies as $taxonomy => $tax) { |
|
36 | - $this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']); |
|
37 | - } |
|
38 | - // register CPTs |
|
39 | - $CPTs = self::get_CPTs(); |
|
40 | - foreach ($CPTs as $CPT_name => $CPT) { |
|
41 | - $this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'], |
|
42 | - $CPT['singular_slug'], $CPT['plural_slug']); |
|
43 | - } |
|
44 | - // setup default terms in any of our taxonomies (but only if we're in admin). |
|
45 | - // Why not added via register_activation_hook? |
|
46 | - // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies |
|
47 | - // (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
|
48 | - // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
|
49 | - // if ( is_admin() ) { |
|
50 | - // $this->set_must_use_event_types(); |
|
51 | - // } |
|
52 | - //set default terms |
|
53 | - $this->set_default_term('espresso_event_type', 'single-event', array('espresso_events')); |
|
54 | - add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10); |
|
55 | - // hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts |
|
56 | - // IF they don't have a term for that taxonomy set. |
|
57 | - add_action('save_post', array($this, 'save_default_term'), 100, 2); |
|
58 | - // remove no html restrictions from core wp saving of term descriptions. |
|
59 | - // Note. this will affect only registered EE taxonomies. |
|
60 | - $this->_allow_html_descriptions_for_ee_taxonomies(); |
|
61 | - do_action('AHEE__EE_Register_CPTs__construct_end', $this); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
68 | - * |
|
69 | - * @since 4.5.0 |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public static function maybe_flush_rewrite_rules() |
|
73 | - { |
|
74 | - if (get_option('ee_flush_rewrite_rules', true)) { |
|
75 | - flush_rewrite_rules(); |
|
76 | - update_option('ee_flush_rewrite_rules', false); |
|
77 | - } |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * By default, WordPress strips all html from term taxonomy description content. The purpose of this method is to |
|
84 | - * remove that restriction and ensure that we still run ee term taxonomy descriptions through some full html |
|
85 | - * sanitization equivalent to the post content field. |
|
86 | - * |
|
87 | - * @since 4.7.8 |
|
88 | - */ |
|
89 | - protected function _allow_html_descriptions_for_ee_taxonomies() |
|
90 | - { |
|
91 | - // first remove default filter for term description but we have to do this earlier |
|
92 | - // before wp sets their own filter |
|
93 | - // because they just set a global filter on all term descriptions before the custom term description filter. |
|
94 | - // Really sux. |
|
95 | - add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * Callback for pre_term_description hook. |
|
102 | - * |
|
103 | - * @param string $description The description content. |
|
104 | - * @param string $taxonomy The taxonomy name for the taxonomy being filtered. |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - public function ee_filter_ee_term_description_not_wp($description, $taxonomy) |
|
108 | - { |
|
109 | - //get a list of EE taxonomies |
|
110 | - $ee_taxonomies = array_keys(self::get_taxonomies()); |
|
111 | - //only do our own thing if the taxonomy listed is an ee taxonomy. |
|
112 | - if (in_array($taxonomy, $ee_taxonomies, true)) { |
|
113 | - //remove default wp filter |
|
114 | - remove_filter('pre_term_description', 'wp_filter_kses'); |
|
115 | - //sanitize THIS content. |
|
116 | - $description = wp_kses($description, wp_kses_allowed_html('post')); |
|
117 | - } |
|
118 | - return $description; |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * get_taxonomies |
|
125 | - * |
|
126 | - * @access public |
|
127 | - * @return array |
|
128 | - */ |
|
129 | - public static function get_taxonomies() |
|
130 | - { |
|
131 | - // define taxonomies |
|
132 | - return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( |
|
133 | - 'espresso_event_categories' => array( |
|
134 | - 'singular_name' => __("Event Category", "event_espresso"), |
|
135 | - 'plural_name' => __("Event Categories", "event_espresso"), |
|
136 | - 'args' => array( |
|
137 | - 'public' => true, |
|
138 | - 'show_in_nav_menus' => true, |
|
139 | - 'show_in_rest' => true, |
|
140 | - 'capabilities' => array( |
|
141 | - 'manage_terms' => 'ee_manage_event_categories', |
|
142 | - 'edit_terms' => 'ee_edit_event_category', |
|
143 | - 'delete_terms' => 'ee_delete_event_category', |
|
144 | - 'assign_terms' => 'ee_assign_event_category', |
|
145 | - ), |
|
146 | - 'rewrite' => array('slug' => __('event-category', 'event_espresso')), |
|
147 | - ), |
|
148 | - ), |
|
149 | - 'espresso_venue_categories' => array( |
|
150 | - 'singular_name' => __("Venue Category", "event_espresso"), |
|
151 | - 'plural_name' => __("Venue Categories", "event_espresso"), |
|
152 | - 'args' => array( |
|
153 | - 'public' => true, |
|
154 | - 'show_in_nav_menus' => false, //by default this doesn't show for decaf |
|
155 | - 'show_in_rest' => true, |
|
156 | - 'capabilities' => array( |
|
157 | - 'manage_terms' => 'ee_manage_venue_categories', |
|
158 | - 'edit_terms' => 'ee_edit_venue_category', |
|
159 | - 'delete_terms' => 'ee_delete_venue_category', |
|
160 | - 'assign_terms' => 'ee_assign_venue_category', |
|
161 | - ), |
|
162 | - 'rewrite' => array('slug' => __('venue-category', 'event_espresso')), |
|
163 | - ), |
|
164 | - ), |
|
165 | - 'espresso_event_type' => array( |
|
166 | - 'singular_name' => __("Event Type", "event_espresso"), |
|
167 | - 'plural_name' => __("Event Types", "event_espresso"), |
|
168 | - 'args' => array( |
|
169 | - 'public' => true, |
|
170 | - 'show_ui' => false, |
|
171 | - 'show_in_rest' => true, |
|
172 | - 'capabilities' => array( |
|
173 | - 'manage_terms' => 'ee_read_event_type', |
|
174 | - 'edit_terms' => 'ee_edit_event_type', |
|
175 | - 'delete_terms' => 'ee_delete_event_type', |
|
176 | - 'assign_terms' => 'ee_assign_event_type', |
|
177 | - ), |
|
178 | - 'rewrite' => array('slug' => __('event-type', 'event_espresso')), |
|
179 | - 'hierarchical' => true, |
|
180 | - ), |
|
181 | - ), |
|
182 | - )); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * This returns the corresponding model name for cpts registered by EE. |
|
189 | - * |
|
190 | - * @since 4.6.16.rc.000 |
|
191 | - * @param string $post_type_slug If a slug is included, then attempt to retrieve the model name for |
|
192 | - * the given cpt slug. Otherwise if empty, then we'll return all cpt |
|
193 | - * model names for cpts registered in EE. |
|
194 | - * @return array Empty array if no matching model names for the given slug or an array of model |
|
195 | - * names indexed by post type slug. |
|
196 | - */ |
|
197 | - public static function get_cpt_model_names($post_type_slug = '') |
|
198 | - { |
|
199 | - $cpts = self::get_CPTs(); |
|
200 | - //first if slug passed in... |
|
201 | - if ( ! empty($post_type_slug)) { |
|
202 | - //match? |
|
203 | - if ( |
|
204 | - ! isset($cpts[$post_type_slug]) |
|
205 | - || (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name'])) |
|
206 | - ) { |
|
207 | - return array(); |
|
208 | - } |
|
209 | - //k let's get the model name for this cpt. |
|
210 | - return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name'])); |
|
211 | - } |
|
212 | - //if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
|
213 | - $cpt_models = array(); |
|
214 | - foreach ($cpts as $slug => $args) { |
|
215 | - if ( ! empty($args['class_name'])) { |
|
216 | - $cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']); |
|
217 | - } |
|
218 | - } |
|
219 | - return $cpt_models; |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * This instantiates cpt models related to the cpts registered via EE. |
|
226 | - * |
|
227 | - * @since 4.6.16.rc.000 |
|
228 | - * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
229 | - * the cpt matching the given slug. Otherwise all cpt models will be |
|
230 | - * instantiated (if possible). |
|
231 | - * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
232 | - * EEM models indexed by post slug. |
|
233 | - */ |
|
234 | - public static function instantiate_cpt_models($post_type_slug = '') |
|
235 | - { |
|
236 | - $cpt_model_names = self::get_cpt_model_names($post_type_slug); |
|
237 | - $instantiated = array(); |
|
238 | - foreach ($cpt_model_names as $slug => $model_name) { |
|
239 | - $instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name)); |
|
240 | - if ($instance instanceof EEM_CPT_Base) { |
|
241 | - $instantiated[$slug] = $instance; |
|
242 | - } |
|
243 | - } |
|
244 | - return $instantiated; |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - |
|
249 | - /** |
|
250 | - * get_CPTs |
|
251 | - * |
|
252 | - * @access public |
|
253 | - * @return array |
|
254 | - */ |
|
255 | - public static function get_CPTs() |
|
256 | - { |
|
257 | - // define CPTs |
|
258 | - // NOTE the ['args']['page_templates'] array index is something specific to our CPTs |
|
259 | - // and not part of the WP custom post type api. |
|
260 | - return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array( |
|
261 | - 'espresso_events' => array( |
|
262 | - 'singular_name' => __("Event", "event_espresso"), |
|
263 | - 'plural_name' => __("Events", "event_espresso"), |
|
264 | - 'singular_slug' => __("event", "event_espresso"), |
|
265 | - 'plural_slug' => EE_Registry::instance()->CFG->core->event_cpt_slug, |
|
266 | - 'class_name' => 'EE_Event', |
|
267 | - 'args' => array( |
|
268 | - 'public' => true, |
|
269 | - 'show_in_nav_menus' => true, |
|
270 | - 'capability_type' => 'event', |
|
271 | - 'capabilities' => array( |
|
272 | - 'edit_post' => 'ee_edit_event', |
|
273 | - 'read_post' => 'ee_read_event', |
|
274 | - 'delete_post' => 'ee_delete_event', |
|
275 | - 'edit_posts' => 'ee_edit_events', |
|
276 | - 'edit_others_posts' => 'ee_edit_others_events', |
|
277 | - 'publish_posts' => 'ee_publish_events', |
|
278 | - 'read_private_posts' => 'ee_read_private_events', |
|
279 | - 'delete_posts' => 'ee_delete_events', |
|
280 | - 'delete_private_posts' => 'ee_delete_private_events', |
|
281 | - 'delete_published_posts' => 'ee_delete_published_events', |
|
282 | - 'delete_others_posts' => 'ee_delete_others_events', |
|
283 | - 'edit_private_posts' => 'ee_edit_private_events', |
|
284 | - 'edit_published_posts' => 'ee_edit_published_events', |
|
285 | - ), |
|
286 | - 'taxonomies' => array( |
|
287 | - 'espresso_event_categories', |
|
288 | - 'espresso_event_type', |
|
289 | - 'post_tag', |
|
290 | - ), |
|
291 | - 'page_templates' => true, |
|
292 | - ), |
|
293 | - ), |
|
294 | - 'espresso_venues' => array( |
|
295 | - 'singular_name' => __("Venue", "event_espresso"), |
|
296 | - 'plural_name' => __("Venues", "event_espresso"), |
|
297 | - 'singular_slug' => __("venue", "event_espresso"), |
|
298 | - 'plural_slug' => __("venues", "event_espresso"), |
|
299 | - 'class_name' => 'EE_Venue', |
|
300 | - 'args' => array( |
|
301 | - 'public' => true, |
|
302 | - 'show_in_nav_menus' => false, //by default this doesn't show for decaf, |
|
303 | - 'capability_type' => 'venue', |
|
304 | - 'capabilities' => array( |
|
305 | - 'edit_post' => 'ee_edit_venue', |
|
306 | - 'read_post' => 'ee_read_venue', |
|
307 | - 'delete_post' => 'ee_delete_venue', |
|
308 | - 'edit_posts' => 'ee_edit_venues', |
|
309 | - 'edit_others_posts' => 'ee_edit_others_venues', |
|
310 | - 'publish_posts' => 'ee_publish_venues', |
|
311 | - 'read_private_posts' => 'ee_read_private_venues', |
|
312 | - 'delete_posts' => 'ee_delete_venues', |
|
313 | - 'delete_private_posts' => 'ee_delete_private_venues', |
|
314 | - 'delete_published_posts' => 'ee_delete_published_venues', |
|
315 | - 'delete_others_posts' => 'ee_edit_others_venues', |
|
316 | - 'edit_private_posts' => 'ee_edit_private_venues', |
|
317 | - 'edit_published_posts' => 'ee_edit_published_venues', |
|
318 | - ), |
|
319 | - 'taxonomies' => array( |
|
320 | - 'espresso_venue_categories', |
|
321 | - 'post_tag', |
|
322 | - ), |
|
323 | - 'page_templates' => true, |
|
324 | - ), |
|
325 | - ), |
|
326 | - 'espresso_attendees' => array( |
|
327 | - 'singular_name' => __("Contact", "event_espresso"), |
|
328 | - 'plural_name' => __("Contacts", "event_espresso"), |
|
329 | - 'singular_slug' => __("contact", "event_espresso"), |
|
330 | - 'plural_slug' => __("contacts", "event_espresso"), |
|
331 | - 'class_name' => 'EE_Attendee', |
|
332 | - 'args' => array( |
|
333 | - 'public' => false, |
|
334 | - 'publicly_queryable' => false, |
|
335 | - 'hierarchical' => false, |
|
336 | - 'has_archive' => false, |
|
337 | - 'taxonomies' => array('post_tag'), |
|
338 | - 'capability_type' => 'contact', |
|
339 | - 'capabilities' => array( |
|
340 | - 'edit_post' => 'ee_edit_contact', |
|
341 | - 'read_post' => 'ee_read_contact', |
|
342 | - 'delete_post' => 'ee_delete_contact', |
|
343 | - 'edit_posts' => 'ee_edit_contacts', |
|
344 | - 'edit_others_posts' => 'ee_edit_contacts', |
|
345 | - 'publish_posts' => 'ee_edit_contacts', |
|
346 | - 'read_private_posts' => 'ee_edit_contacts', |
|
347 | - 'delete_posts' => 'ee_delete_contacts', |
|
348 | - 'delete_private_posts' => 'ee_delete_contacts', |
|
349 | - 'delete_published_posts' => 'ee_delete_contacts', |
|
350 | - 'delete_others_posts' => 'ee_delete_contacts', |
|
351 | - 'edit_private_posts' => 'ee_edit_contacts', |
|
352 | - 'edit_published_posts' => 'ee_edit_contacts', |
|
353 | - ), |
|
354 | - 'supports' => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'), |
|
355 | - ), |
|
356 | - ), |
|
357 | - )); |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * This basically goes through the CPT array and returns only CPT's |
|
364 | - * that have the ['args']['public'] option set as false |
|
365 | - * |
|
366 | - * @return array |
|
367 | - */ |
|
368 | - public static function get_private_CPTs() |
|
369 | - { |
|
370 | - $CPTs = self::get_CPTs(); |
|
371 | - $private_CPTs = array(); |
|
372 | - foreach ($CPTs as $CPT => $details) { |
|
373 | - if (empty($details['args']['public'])) { |
|
374 | - $private_CPTs[$CPT] = $details; |
|
375 | - } |
|
376 | - } |
|
377 | - return $private_CPTs; |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - |
|
382 | - /** |
|
383 | - * Registers a custom taxonomy. Should be called before registering custom post types, |
|
384 | - * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'. |
|
385 | - * |
|
386 | - * @param string $taxonomy_name , eg 'books' |
|
387 | - * @param string $singular_name internationalized singular name |
|
388 | - * @param string $plural_name internationalized plural name |
|
389 | - * @param array $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
|
390 | - */ |
|
391 | - public function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array()) |
|
392 | - { |
|
393 | - $args = array( |
|
394 | - 'hierarchical' => true, |
|
395 | - 'labels' => array( |
|
396 | - 'name' => $plural_name, |
|
397 | - 'singular_name' => $singular_name, |
|
398 | - ), |
|
399 | - 'show_ui' => true, |
|
400 | - 'show_ee_ui' => true, |
|
401 | - 'show_admin_column' => true, |
|
402 | - 'query_var' => true, |
|
403 | - 'show_in_nav_menus' => false, |
|
404 | - 'map_meta_cap' => true |
|
405 | - //'rewrite' => array( 'slug' => 'genre' ), |
|
406 | - ); |
|
407 | - if ($override_args) { |
|
408 | - if (isset($override_args['labels'])) { |
|
409 | - $labels = array_merge($args['labels'], $override_args['labels']); |
|
410 | - $args['labels'] = $labels; |
|
411 | - } |
|
412 | - $args = array_merge($args, $override_args); |
|
413 | - } |
|
414 | - register_taxonomy($taxonomy_name, null, $args); |
|
415 | - } |
|
416 | - |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * Registers a new custom post type. Sets default settings given only the following params. |
|
421 | - * |
|
422 | - * @param string $post_type the actual post type name |
|
423 | - * (VERY IMPORTANT: this much match what the slug is for admin pages related to this |
|
424 | - * cpt Also any models must use this slug as well) |
|
425 | - * @param string $singular_name a pre-internationalized string for the singular name of the objects |
|
426 | - * @param string $plural_name a pre-internalized string for the plural name of the objects |
|
427 | - * @param array $override_args exactly like $args as described in |
|
428 | - * http://codex.wordpress.org/Function_Reference/register_post_type The default values |
|
429 | - * set in this function will be overridden by whatever you set in $override_args |
|
430 | - * @param string $singular_slug |
|
431 | - * @param string $plural_slug |
|
432 | - * @return void , but registers the custom post type |
|
433 | - */ |
|
434 | - public function register_CPT( |
|
435 | - $post_type, |
|
436 | - $singular_name, |
|
437 | - $plural_name, |
|
438 | - $override_args = array(), |
|
439 | - $singular_slug = '', |
|
440 | - $plural_slug = '' |
|
441 | - ) { |
|
442 | - $labels = array( |
|
443 | - 'name' => $plural_name, |
|
444 | - 'singular_name' => $singular_name, |
|
445 | - 'add_new' => sprintf(__("Add %s", "event_espresso"), $singular_name), |
|
446 | - 'add_new_item' => sprintf(__("Add New %s", "event_espresso"), $singular_name), |
|
447 | - 'edit_item' => sprintf(__("Edit %s", "event_espresso"), $singular_name), |
|
448 | - 'new_item' => sprintf(__("New %s", "event_espresso"), $singular_name), |
|
449 | - 'all_items' => sprintf(__("All %s", "event_espresso"), $plural_name), |
|
450 | - 'view_item' => sprintf(__("View %s", "event_espresso"), $singular_name), |
|
451 | - 'search_items' => sprintf(__("Search %s", "event_espresso"), $plural_name), |
|
452 | - 'not_found' => sprintf(__("No %s found", "event_espresso"), $plural_name), |
|
453 | - 'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name), |
|
454 | - 'parent_item_colon' => '', |
|
455 | - 'menu_name' => sprintf(__("%s", "event_espresso"), $plural_name), |
|
456 | - ); |
|
457 | - //verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name |
|
458 | - // $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name; |
|
459 | - $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name; |
|
460 | - //note the page_templates arg in the supports index is something specific to EE. |
|
461 | - // WordPress doesn't actually have that in their register_post_type api. |
|
462 | - $args = array( |
|
463 | - 'labels' => $labels, |
|
464 | - 'public' => true, |
|
465 | - 'publicly_queryable' => true, |
|
466 | - 'show_ui' => false, |
|
467 | - 'show_ee_ui' => true, |
|
468 | - 'show_in_menu' => false, |
|
469 | - 'show_in_nav_menus' => false, |
|
470 | - 'query_var' => true, |
|
471 | - 'rewrite' => apply_filters( |
|
472 | - 'FHEE__EE_Register_CPTs__register_CPT__rewrite', |
|
473 | - array('slug' => $plural_slug), |
|
474 | - $post_type |
|
475 | - ), |
|
476 | - 'capability_type' => 'post', |
|
477 | - 'map_meta_cap' => true, |
|
478 | - 'has_archive' => true, |
|
479 | - 'hierarchical' => false, |
|
480 | - 'menu_position' => null, |
|
481 | - 'supports' => array( |
|
482 | - 'title', |
|
483 | - 'editor', |
|
484 | - 'author', |
|
485 | - 'thumbnail', |
|
486 | - 'excerpt', |
|
487 | - 'custom-fields', |
|
488 | - 'comments', |
|
489 | - ), |
|
490 | - ); |
|
491 | - if ($override_args) { |
|
492 | - if (isset($override_args['labels'])) { |
|
493 | - $labels = array_merge($args['labels'], $override_args['labels']); |
|
494 | - } |
|
495 | - $args = array_merge($args, $override_args); |
|
496 | - $args['labels'] = $labels; |
|
497 | - } |
|
498 | - register_post_type($post_type, $args); |
|
499 | - } |
|
500 | - |
|
501 | - |
|
502 | - |
|
503 | - public function set_must_use_event_types() |
|
504 | - { |
|
505 | - $term_details = array( |
|
506 | - //Attendee's register for the first date-time only |
|
507 | - 'single-event' => array( |
|
508 | - __('Single Event', 'event_espresso'), |
|
509 | - __('A single event that spans one or more consecutive days.', 'event_espresso'), |
|
510 | - ), |
|
511 | - //example: a party or two-day long workshop |
|
512 | - //Attendee's can register for any of the date-times |
|
513 | - 'multi-event' => array( |
|
514 | - __('Multi Event', 'event_espresso'), |
|
515 | - __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso'), |
|
516 | - ), |
|
517 | - //example: a three day music festival or week long conference |
|
518 | - //Attendee's register for the first date-time only |
|
519 | - 'event-series' => array( |
|
520 | - __('Event Series', 'event_espresso'), |
|
521 | - __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso'), |
|
522 | - ), |
|
523 | - //example: an 8 week introduction to basket weaving course |
|
524 | - //Attendee's can register for any of the date-times. |
|
525 | - 'recurring-event' => array( |
|
526 | - __('Recurring Event', 'event_espresso'), |
|
527 | - __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso'), |
|
528 | - ), |
|
529 | - //example: a yoga class |
|
530 | - 'ongoing' => array( |
|
531 | - __('Ongoing Event', 'event_espresso'), |
|
532 | - __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', |
|
533 | - 'event_espresso'), |
|
534 | - ) |
|
535 | - //example: access to a museum |
|
536 | - //'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
|
537 | - //'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
538 | - // 'multiple-session' => array( __('Multiple Session', 'event_espresso'), __('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
539 | - //'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
|
540 | - ); |
|
541 | - $this->set_must_use_terms('espresso_event_type', $term_details); |
|
542 | - } |
|
543 | - |
|
544 | - |
|
545 | - |
|
546 | - /** |
|
547 | - * wrapper method for handling the setting up of initial terms in the db (if they don't already exist). |
|
548 | - * Note this should ONLY be used for terms that always must be present. Be aware that if an initial term is |
|
549 | - * deleted then it WILL be recreated. |
|
550 | - * |
|
551 | - * @param string $taxonomy The name of the taxonomy |
|
552 | - * @param array $term_details An array of term details indexed by slug and containing Name of term, and |
|
553 | - * description as the elements in the array |
|
554 | - * @return void |
|
555 | - */ |
|
556 | - public function set_must_use_terms($taxonomy, $term_details) |
|
557 | - { |
|
558 | - $term_details = (array)$term_details; |
|
559 | - foreach ($term_details as $slug => $details) { |
|
560 | - if ( ! term_exists($slug, $taxonomy)) { |
|
561 | - $insert_arr = array( |
|
562 | - 'slug' => $slug, |
|
563 | - 'description' => $details[1], |
|
564 | - ); |
|
565 | - wp_insert_term($details[0], $taxonomy, $insert_arr); |
|
566 | - } |
|
567 | - } |
|
568 | - } |
|
569 | - |
|
570 | - |
|
571 | - |
|
572 | - /** |
|
573 | - * Allows us to set what the default will be for terms when a cpt is PUBLISHED. |
|
574 | - * |
|
575 | - * @param string $taxonomy The taxonomy we're using for the default term |
|
576 | - * @param string $term_slug The slug of the term that will be the default. |
|
577 | - * @param array $cpt_slugs An array of custom post types we want the default assigned to |
|
578 | - */ |
|
579 | - public function set_default_term($taxonomy, $term_slug, $cpt_slugs = array()) |
|
580 | - { |
|
581 | - $this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs); |
|
582 | - } |
|
583 | - |
|
584 | - |
|
585 | - |
|
586 | - /** |
|
587 | - * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property |
|
588 | - * |
|
589 | - * @param int $post_id ID of CPT being saved |
|
590 | - * @param object $post Post object |
|
591 | - * @return void |
|
592 | - */ |
|
593 | - public function save_default_term($post_id, $post) |
|
594 | - { |
|
595 | - if (empty($this->_default_terms)) { |
|
596 | - return; |
|
597 | - } //no default terms set so lets just exit. |
|
598 | - foreach ($this->_default_terms as $defaults) { |
|
599 | - foreach ($defaults as $default_obj) { |
|
600 | - if ($post->post_status === 'publish' && in_array($post->post_type, $default_obj->cpt_slugs, true)) { |
|
601 | - //note some error proofing going on here to save unnecessary db queries |
|
602 | - $taxonomies = get_object_taxonomies($post->post_type); |
|
603 | - foreach ((array)$taxonomies as $taxonomy) { |
|
604 | - $terms = wp_get_post_terms($post_id, $taxonomy); |
|
605 | - if (empty($terms) && $taxonomy === $default_obj->taxonomy) { |
|
606 | - wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy); |
|
607 | - } |
|
608 | - } |
|
609 | - } |
|
610 | - } |
|
611 | - } |
|
612 | - } |
|
17 | + /** |
|
18 | + * This property is used to hold an array of EE_default_term objects assigned to a custom post type when the post |
|
19 | + * for that post type is published with no terms set for the taxonomy. |
|
20 | + * |
|
21 | + * @var array of EE_Default_Term objects |
|
22 | + */ |
|
23 | + protected $_default_terms = array(); |
|
24 | + |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * constructor |
|
29 | + * instantiated at init priority 5 |
|
30 | + */ |
|
31 | + public function __construct() |
|
32 | + { |
|
33 | + // register taxonomies |
|
34 | + $taxonomies = self::get_taxonomies(); |
|
35 | + foreach ($taxonomies as $taxonomy => $tax) { |
|
36 | + $this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']); |
|
37 | + } |
|
38 | + // register CPTs |
|
39 | + $CPTs = self::get_CPTs(); |
|
40 | + foreach ($CPTs as $CPT_name => $CPT) { |
|
41 | + $this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'], |
|
42 | + $CPT['singular_slug'], $CPT['plural_slug']); |
|
43 | + } |
|
44 | + // setup default terms in any of our taxonomies (but only if we're in admin). |
|
45 | + // Why not added via register_activation_hook? |
|
46 | + // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies |
|
47 | + // (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
|
48 | + // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
|
49 | + // if ( is_admin() ) { |
|
50 | + // $this->set_must_use_event_types(); |
|
51 | + // } |
|
52 | + //set default terms |
|
53 | + $this->set_default_term('espresso_event_type', 'single-event', array('espresso_events')); |
|
54 | + add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10); |
|
55 | + // hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts |
|
56 | + // IF they don't have a term for that taxonomy set. |
|
57 | + add_action('save_post', array($this, 'save_default_term'), 100, 2); |
|
58 | + // remove no html restrictions from core wp saving of term descriptions. |
|
59 | + // Note. this will affect only registered EE taxonomies. |
|
60 | + $this->_allow_html_descriptions_for_ee_taxonomies(); |
|
61 | + do_action('AHEE__EE_Register_CPTs__construct_end', $this); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
68 | + * |
|
69 | + * @since 4.5.0 |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public static function maybe_flush_rewrite_rules() |
|
73 | + { |
|
74 | + if (get_option('ee_flush_rewrite_rules', true)) { |
|
75 | + flush_rewrite_rules(); |
|
76 | + update_option('ee_flush_rewrite_rules', false); |
|
77 | + } |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * By default, WordPress strips all html from term taxonomy description content. The purpose of this method is to |
|
84 | + * remove that restriction and ensure that we still run ee term taxonomy descriptions through some full html |
|
85 | + * sanitization equivalent to the post content field. |
|
86 | + * |
|
87 | + * @since 4.7.8 |
|
88 | + */ |
|
89 | + protected function _allow_html_descriptions_for_ee_taxonomies() |
|
90 | + { |
|
91 | + // first remove default filter for term description but we have to do this earlier |
|
92 | + // before wp sets their own filter |
|
93 | + // because they just set a global filter on all term descriptions before the custom term description filter. |
|
94 | + // Really sux. |
|
95 | + add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * Callback for pre_term_description hook. |
|
102 | + * |
|
103 | + * @param string $description The description content. |
|
104 | + * @param string $taxonomy The taxonomy name for the taxonomy being filtered. |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + public function ee_filter_ee_term_description_not_wp($description, $taxonomy) |
|
108 | + { |
|
109 | + //get a list of EE taxonomies |
|
110 | + $ee_taxonomies = array_keys(self::get_taxonomies()); |
|
111 | + //only do our own thing if the taxonomy listed is an ee taxonomy. |
|
112 | + if (in_array($taxonomy, $ee_taxonomies, true)) { |
|
113 | + //remove default wp filter |
|
114 | + remove_filter('pre_term_description', 'wp_filter_kses'); |
|
115 | + //sanitize THIS content. |
|
116 | + $description = wp_kses($description, wp_kses_allowed_html('post')); |
|
117 | + } |
|
118 | + return $description; |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * get_taxonomies |
|
125 | + * |
|
126 | + * @access public |
|
127 | + * @return array |
|
128 | + */ |
|
129 | + public static function get_taxonomies() |
|
130 | + { |
|
131 | + // define taxonomies |
|
132 | + return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( |
|
133 | + 'espresso_event_categories' => array( |
|
134 | + 'singular_name' => __("Event Category", "event_espresso"), |
|
135 | + 'plural_name' => __("Event Categories", "event_espresso"), |
|
136 | + 'args' => array( |
|
137 | + 'public' => true, |
|
138 | + 'show_in_nav_menus' => true, |
|
139 | + 'show_in_rest' => true, |
|
140 | + 'capabilities' => array( |
|
141 | + 'manage_terms' => 'ee_manage_event_categories', |
|
142 | + 'edit_terms' => 'ee_edit_event_category', |
|
143 | + 'delete_terms' => 'ee_delete_event_category', |
|
144 | + 'assign_terms' => 'ee_assign_event_category', |
|
145 | + ), |
|
146 | + 'rewrite' => array('slug' => __('event-category', 'event_espresso')), |
|
147 | + ), |
|
148 | + ), |
|
149 | + 'espresso_venue_categories' => array( |
|
150 | + 'singular_name' => __("Venue Category", "event_espresso"), |
|
151 | + 'plural_name' => __("Venue Categories", "event_espresso"), |
|
152 | + 'args' => array( |
|
153 | + 'public' => true, |
|
154 | + 'show_in_nav_menus' => false, //by default this doesn't show for decaf |
|
155 | + 'show_in_rest' => true, |
|
156 | + 'capabilities' => array( |
|
157 | + 'manage_terms' => 'ee_manage_venue_categories', |
|
158 | + 'edit_terms' => 'ee_edit_venue_category', |
|
159 | + 'delete_terms' => 'ee_delete_venue_category', |
|
160 | + 'assign_terms' => 'ee_assign_venue_category', |
|
161 | + ), |
|
162 | + 'rewrite' => array('slug' => __('venue-category', 'event_espresso')), |
|
163 | + ), |
|
164 | + ), |
|
165 | + 'espresso_event_type' => array( |
|
166 | + 'singular_name' => __("Event Type", "event_espresso"), |
|
167 | + 'plural_name' => __("Event Types", "event_espresso"), |
|
168 | + 'args' => array( |
|
169 | + 'public' => true, |
|
170 | + 'show_ui' => false, |
|
171 | + 'show_in_rest' => true, |
|
172 | + 'capabilities' => array( |
|
173 | + 'manage_terms' => 'ee_read_event_type', |
|
174 | + 'edit_terms' => 'ee_edit_event_type', |
|
175 | + 'delete_terms' => 'ee_delete_event_type', |
|
176 | + 'assign_terms' => 'ee_assign_event_type', |
|
177 | + ), |
|
178 | + 'rewrite' => array('slug' => __('event-type', 'event_espresso')), |
|
179 | + 'hierarchical' => true, |
|
180 | + ), |
|
181 | + ), |
|
182 | + )); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * This returns the corresponding model name for cpts registered by EE. |
|
189 | + * |
|
190 | + * @since 4.6.16.rc.000 |
|
191 | + * @param string $post_type_slug If a slug is included, then attempt to retrieve the model name for |
|
192 | + * the given cpt slug. Otherwise if empty, then we'll return all cpt |
|
193 | + * model names for cpts registered in EE. |
|
194 | + * @return array Empty array if no matching model names for the given slug or an array of model |
|
195 | + * names indexed by post type slug. |
|
196 | + */ |
|
197 | + public static function get_cpt_model_names($post_type_slug = '') |
|
198 | + { |
|
199 | + $cpts = self::get_CPTs(); |
|
200 | + //first if slug passed in... |
|
201 | + if ( ! empty($post_type_slug)) { |
|
202 | + //match? |
|
203 | + if ( |
|
204 | + ! isset($cpts[$post_type_slug]) |
|
205 | + || (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name'])) |
|
206 | + ) { |
|
207 | + return array(); |
|
208 | + } |
|
209 | + //k let's get the model name for this cpt. |
|
210 | + return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name'])); |
|
211 | + } |
|
212 | + //if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
|
213 | + $cpt_models = array(); |
|
214 | + foreach ($cpts as $slug => $args) { |
|
215 | + if ( ! empty($args['class_name'])) { |
|
216 | + $cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']); |
|
217 | + } |
|
218 | + } |
|
219 | + return $cpt_models; |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * This instantiates cpt models related to the cpts registered via EE. |
|
226 | + * |
|
227 | + * @since 4.6.16.rc.000 |
|
228 | + * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
229 | + * the cpt matching the given slug. Otherwise all cpt models will be |
|
230 | + * instantiated (if possible). |
|
231 | + * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
232 | + * EEM models indexed by post slug. |
|
233 | + */ |
|
234 | + public static function instantiate_cpt_models($post_type_slug = '') |
|
235 | + { |
|
236 | + $cpt_model_names = self::get_cpt_model_names($post_type_slug); |
|
237 | + $instantiated = array(); |
|
238 | + foreach ($cpt_model_names as $slug => $model_name) { |
|
239 | + $instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name)); |
|
240 | + if ($instance instanceof EEM_CPT_Base) { |
|
241 | + $instantiated[$slug] = $instance; |
|
242 | + } |
|
243 | + } |
|
244 | + return $instantiated; |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + |
|
249 | + /** |
|
250 | + * get_CPTs |
|
251 | + * |
|
252 | + * @access public |
|
253 | + * @return array |
|
254 | + */ |
|
255 | + public static function get_CPTs() |
|
256 | + { |
|
257 | + // define CPTs |
|
258 | + // NOTE the ['args']['page_templates'] array index is something specific to our CPTs |
|
259 | + // and not part of the WP custom post type api. |
|
260 | + return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array( |
|
261 | + 'espresso_events' => array( |
|
262 | + 'singular_name' => __("Event", "event_espresso"), |
|
263 | + 'plural_name' => __("Events", "event_espresso"), |
|
264 | + 'singular_slug' => __("event", "event_espresso"), |
|
265 | + 'plural_slug' => EE_Registry::instance()->CFG->core->event_cpt_slug, |
|
266 | + 'class_name' => 'EE_Event', |
|
267 | + 'args' => array( |
|
268 | + 'public' => true, |
|
269 | + 'show_in_nav_menus' => true, |
|
270 | + 'capability_type' => 'event', |
|
271 | + 'capabilities' => array( |
|
272 | + 'edit_post' => 'ee_edit_event', |
|
273 | + 'read_post' => 'ee_read_event', |
|
274 | + 'delete_post' => 'ee_delete_event', |
|
275 | + 'edit_posts' => 'ee_edit_events', |
|
276 | + 'edit_others_posts' => 'ee_edit_others_events', |
|
277 | + 'publish_posts' => 'ee_publish_events', |
|
278 | + 'read_private_posts' => 'ee_read_private_events', |
|
279 | + 'delete_posts' => 'ee_delete_events', |
|
280 | + 'delete_private_posts' => 'ee_delete_private_events', |
|
281 | + 'delete_published_posts' => 'ee_delete_published_events', |
|
282 | + 'delete_others_posts' => 'ee_delete_others_events', |
|
283 | + 'edit_private_posts' => 'ee_edit_private_events', |
|
284 | + 'edit_published_posts' => 'ee_edit_published_events', |
|
285 | + ), |
|
286 | + 'taxonomies' => array( |
|
287 | + 'espresso_event_categories', |
|
288 | + 'espresso_event_type', |
|
289 | + 'post_tag', |
|
290 | + ), |
|
291 | + 'page_templates' => true, |
|
292 | + ), |
|
293 | + ), |
|
294 | + 'espresso_venues' => array( |
|
295 | + 'singular_name' => __("Venue", "event_espresso"), |
|
296 | + 'plural_name' => __("Venues", "event_espresso"), |
|
297 | + 'singular_slug' => __("venue", "event_espresso"), |
|
298 | + 'plural_slug' => __("venues", "event_espresso"), |
|
299 | + 'class_name' => 'EE_Venue', |
|
300 | + 'args' => array( |
|
301 | + 'public' => true, |
|
302 | + 'show_in_nav_menus' => false, //by default this doesn't show for decaf, |
|
303 | + 'capability_type' => 'venue', |
|
304 | + 'capabilities' => array( |
|
305 | + 'edit_post' => 'ee_edit_venue', |
|
306 | + 'read_post' => 'ee_read_venue', |
|
307 | + 'delete_post' => 'ee_delete_venue', |
|
308 | + 'edit_posts' => 'ee_edit_venues', |
|
309 | + 'edit_others_posts' => 'ee_edit_others_venues', |
|
310 | + 'publish_posts' => 'ee_publish_venues', |
|
311 | + 'read_private_posts' => 'ee_read_private_venues', |
|
312 | + 'delete_posts' => 'ee_delete_venues', |
|
313 | + 'delete_private_posts' => 'ee_delete_private_venues', |
|
314 | + 'delete_published_posts' => 'ee_delete_published_venues', |
|
315 | + 'delete_others_posts' => 'ee_edit_others_venues', |
|
316 | + 'edit_private_posts' => 'ee_edit_private_venues', |
|
317 | + 'edit_published_posts' => 'ee_edit_published_venues', |
|
318 | + ), |
|
319 | + 'taxonomies' => array( |
|
320 | + 'espresso_venue_categories', |
|
321 | + 'post_tag', |
|
322 | + ), |
|
323 | + 'page_templates' => true, |
|
324 | + ), |
|
325 | + ), |
|
326 | + 'espresso_attendees' => array( |
|
327 | + 'singular_name' => __("Contact", "event_espresso"), |
|
328 | + 'plural_name' => __("Contacts", "event_espresso"), |
|
329 | + 'singular_slug' => __("contact", "event_espresso"), |
|
330 | + 'plural_slug' => __("contacts", "event_espresso"), |
|
331 | + 'class_name' => 'EE_Attendee', |
|
332 | + 'args' => array( |
|
333 | + 'public' => false, |
|
334 | + 'publicly_queryable' => false, |
|
335 | + 'hierarchical' => false, |
|
336 | + 'has_archive' => false, |
|
337 | + 'taxonomies' => array('post_tag'), |
|
338 | + 'capability_type' => 'contact', |
|
339 | + 'capabilities' => array( |
|
340 | + 'edit_post' => 'ee_edit_contact', |
|
341 | + 'read_post' => 'ee_read_contact', |
|
342 | + 'delete_post' => 'ee_delete_contact', |
|
343 | + 'edit_posts' => 'ee_edit_contacts', |
|
344 | + 'edit_others_posts' => 'ee_edit_contacts', |
|
345 | + 'publish_posts' => 'ee_edit_contacts', |
|
346 | + 'read_private_posts' => 'ee_edit_contacts', |
|
347 | + 'delete_posts' => 'ee_delete_contacts', |
|
348 | + 'delete_private_posts' => 'ee_delete_contacts', |
|
349 | + 'delete_published_posts' => 'ee_delete_contacts', |
|
350 | + 'delete_others_posts' => 'ee_delete_contacts', |
|
351 | + 'edit_private_posts' => 'ee_edit_contacts', |
|
352 | + 'edit_published_posts' => 'ee_edit_contacts', |
|
353 | + ), |
|
354 | + 'supports' => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'), |
|
355 | + ), |
|
356 | + ), |
|
357 | + )); |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * This basically goes through the CPT array and returns only CPT's |
|
364 | + * that have the ['args']['public'] option set as false |
|
365 | + * |
|
366 | + * @return array |
|
367 | + */ |
|
368 | + public static function get_private_CPTs() |
|
369 | + { |
|
370 | + $CPTs = self::get_CPTs(); |
|
371 | + $private_CPTs = array(); |
|
372 | + foreach ($CPTs as $CPT => $details) { |
|
373 | + if (empty($details['args']['public'])) { |
|
374 | + $private_CPTs[$CPT] = $details; |
|
375 | + } |
|
376 | + } |
|
377 | + return $private_CPTs; |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + |
|
382 | + /** |
|
383 | + * Registers a custom taxonomy. Should be called before registering custom post types, |
|
384 | + * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'. |
|
385 | + * |
|
386 | + * @param string $taxonomy_name , eg 'books' |
|
387 | + * @param string $singular_name internationalized singular name |
|
388 | + * @param string $plural_name internationalized plural name |
|
389 | + * @param array $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
|
390 | + */ |
|
391 | + public function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array()) |
|
392 | + { |
|
393 | + $args = array( |
|
394 | + 'hierarchical' => true, |
|
395 | + 'labels' => array( |
|
396 | + 'name' => $plural_name, |
|
397 | + 'singular_name' => $singular_name, |
|
398 | + ), |
|
399 | + 'show_ui' => true, |
|
400 | + 'show_ee_ui' => true, |
|
401 | + 'show_admin_column' => true, |
|
402 | + 'query_var' => true, |
|
403 | + 'show_in_nav_menus' => false, |
|
404 | + 'map_meta_cap' => true |
|
405 | + //'rewrite' => array( 'slug' => 'genre' ), |
|
406 | + ); |
|
407 | + if ($override_args) { |
|
408 | + if (isset($override_args['labels'])) { |
|
409 | + $labels = array_merge($args['labels'], $override_args['labels']); |
|
410 | + $args['labels'] = $labels; |
|
411 | + } |
|
412 | + $args = array_merge($args, $override_args); |
|
413 | + } |
|
414 | + register_taxonomy($taxonomy_name, null, $args); |
|
415 | + } |
|
416 | + |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * Registers a new custom post type. Sets default settings given only the following params. |
|
421 | + * |
|
422 | + * @param string $post_type the actual post type name |
|
423 | + * (VERY IMPORTANT: this much match what the slug is for admin pages related to this |
|
424 | + * cpt Also any models must use this slug as well) |
|
425 | + * @param string $singular_name a pre-internationalized string for the singular name of the objects |
|
426 | + * @param string $plural_name a pre-internalized string for the plural name of the objects |
|
427 | + * @param array $override_args exactly like $args as described in |
|
428 | + * http://codex.wordpress.org/Function_Reference/register_post_type The default values |
|
429 | + * set in this function will be overridden by whatever you set in $override_args |
|
430 | + * @param string $singular_slug |
|
431 | + * @param string $plural_slug |
|
432 | + * @return void , but registers the custom post type |
|
433 | + */ |
|
434 | + public function register_CPT( |
|
435 | + $post_type, |
|
436 | + $singular_name, |
|
437 | + $plural_name, |
|
438 | + $override_args = array(), |
|
439 | + $singular_slug = '', |
|
440 | + $plural_slug = '' |
|
441 | + ) { |
|
442 | + $labels = array( |
|
443 | + 'name' => $plural_name, |
|
444 | + 'singular_name' => $singular_name, |
|
445 | + 'add_new' => sprintf(__("Add %s", "event_espresso"), $singular_name), |
|
446 | + 'add_new_item' => sprintf(__("Add New %s", "event_espresso"), $singular_name), |
|
447 | + 'edit_item' => sprintf(__("Edit %s", "event_espresso"), $singular_name), |
|
448 | + 'new_item' => sprintf(__("New %s", "event_espresso"), $singular_name), |
|
449 | + 'all_items' => sprintf(__("All %s", "event_espresso"), $plural_name), |
|
450 | + 'view_item' => sprintf(__("View %s", "event_espresso"), $singular_name), |
|
451 | + 'search_items' => sprintf(__("Search %s", "event_espresso"), $plural_name), |
|
452 | + 'not_found' => sprintf(__("No %s found", "event_espresso"), $plural_name), |
|
453 | + 'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name), |
|
454 | + 'parent_item_colon' => '', |
|
455 | + 'menu_name' => sprintf(__("%s", "event_espresso"), $plural_name), |
|
456 | + ); |
|
457 | + //verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name |
|
458 | + // $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name; |
|
459 | + $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name; |
|
460 | + //note the page_templates arg in the supports index is something specific to EE. |
|
461 | + // WordPress doesn't actually have that in their register_post_type api. |
|
462 | + $args = array( |
|
463 | + 'labels' => $labels, |
|
464 | + 'public' => true, |
|
465 | + 'publicly_queryable' => true, |
|
466 | + 'show_ui' => false, |
|
467 | + 'show_ee_ui' => true, |
|
468 | + 'show_in_menu' => false, |
|
469 | + 'show_in_nav_menus' => false, |
|
470 | + 'query_var' => true, |
|
471 | + 'rewrite' => apply_filters( |
|
472 | + 'FHEE__EE_Register_CPTs__register_CPT__rewrite', |
|
473 | + array('slug' => $plural_slug), |
|
474 | + $post_type |
|
475 | + ), |
|
476 | + 'capability_type' => 'post', |
|
477 | + 'map_meta_cap' => true, |
|
478 | + 'has_archive' => true, |
|
479 | + 'hierarchical' => false, |
|
480 | + 'menu_position' => null, |
|
481 | + 'supports' => array( |
|
482 | + 'title', |
|
483 | + 'editor', |
|
484 | + 'author', |
|
485 | + 'thumbnail', |
|
486 | + 'excerpt', |
|
487 | + 'custom-fields', |
|
488 | + 'comments', |
|
489 | + ), |
|
490 | + ); |
|
491 | + if ($override_args) { |
|
492 | + if (isset($override_args['labels'])) { |
|
493 | + $labels = array_merge($args['labels'], $override_args['labels']); |
|
494 | + } |
|
495 | + $args = array_merge($args, $override_args); |
|
496 | + $args['labels'] = $labels; |
|
497 | + } |
|
498 | + register_post_type($post_type, $args); |
|
499 | + } |
|
500 | + |
|
501 | + |
|
502 | + |
|
503 | + public function set_must_use_event_types() |
|
504 | + { |
|
505 | + $term_details = array( |
|
506 | + //Attendee's register for the first date-time only |
|
507 | + 'single-event' => array( |
|
508 | + __('Single Event', 'event_espresso'), |
|
509 | + __('A single event that spans one or more consecutive days.', 'event_espresso'), |
|
510 | + ), |
|
511 | + //example: a party or two-day long workshop |
|
512 | + //Attendee's can register for any of the date-times |
|
513 | + 'multi-event' => array( |
|
514 | + __('Multi Event', 'event_espresso'), |
|
515 | + __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso'), |
|
516 | + ), |
|
517 | + //example: a three day music festival or week long conference |
|
518 | + //Attendee's register for the first date-time only |
|
519 | + 'event-series' => array( |
|
520 | + __('Event Series', 'event_espresso'), |
|
521 | + __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso'), |
|
522 | + ), |
|
523 | + //example: an 8 week introduction to basket weaving course |
|
524 | + //Attendee's can register for any of the date-times. |
|
525 | + 'recurring-event' => array( |
|
526 | + __('Recurring Event', 'event_espresso'), |
|
527 | + __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso'), |
|
528 | + ), |
|
529 | + //example: a yoga class |
|
530 | + 'ongoing' => array( |
|
531 | + __('Ongoing Event', 'event_espresso'), |
|
532 | + __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', |
|
533 | + 'event_espresso'), |
|
534 | + ) |
|
535 | + //example: access to a museum |
|
536 | + //'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
|
537 | + //'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
538 | + // 'multiple-session' => array( __('Multiple Session', 'event_espresso'), __('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
539 | + //'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
|
540 | + ); |
|
541 | + $this->set_must_use_terms('espresso_event_type', $term_details); |
|
542 | + } |
|
543 | + |
|
544 | + |
|
545 | + |
|
546 | + /** |
|
547 | + * wrapper method for handling the setting up of initial terms in the db (if they don't already exist). |
|
548 | + * Note this should ONLY be used for terms that always must be present. Be aware that if an initial term is |
|
549 | + * deleted then it WILL be recreated. |
|
550 | + * |
|
551 | + * @param string $taxonomy The name of the taxonomy |
|
552 | + * @param array $term_details An array of term details indexed by slug and containing Name of term, and |
|
553 | + * description as the elements in the array |
|
554 | + * @return void |
|
555 | + */ |
|
556 | + public function set_must_use_terms($taxonomy, $term_details) |
|
557 | + { |
|
558 | + $term_details = (array)$term_details; |
|
559 | + foreach ($term_details as $slug => $details) { |
|
560 | + if ( ! term_exists($slug, $taxonomy)) { |
|
561 | + $insert_arr = array( |
|
562 | + 'slug' => $slug, |
|
563 | + 'description' => $details[1], |
|
564 | + ); |
|
565 | + wp_insert_term($details[0], $taxonomy, $insert_arr); |
|
566 | + } |
|
567 | + } |
|
568 | + } |
|
569 | + |
|
570 | + |
|
571 | + |
|
572 | + /** |
|
573 | + * Allows us to set what the default will be for terms when a cpt is PUBLISHED. |
|
574 | + * |
|
575 | + * @param string $taxonomy The taxonomy we're using for the default term |
|
576 | + * @param string $term_slug The slug of the term that will be the default. |
|
577 | + * @param array $cpt_slugs An array of custom post types we want the default assigned to |
|
578 | + */ |
|
579 | + public function set_default_term($taxonomy, $term_slug, $cpt_slugs = array()) |
|
580 | + { |
|
581 | + $this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs); |
|
582 | + } |
|
583 | + |
|
584 | + |
|
585 | + |
|
586 | + /** |
|
587 | + * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property |
|
588 | + * |
|
589 | + * @param int $post_id ID of CPT being saved |
|
590 | + * @param object $post Post object |
|
591 | + * @return void |
|
592 | + */ |
|
593 | + public function save_default_term($post_id, $post) |
|
594 | + { |
|
595 | + if (empty($this->_default_terms)) { |
|
596 | + return; |
|
597 | + } //no default terms set so lets just exit. |
|
598 | + foreach ($this->_default_terms as $defaults) { |
|
599 | + foreach ($defaults as $default_obj) { |
|
600 | + if ($post->post_status === 'publish' && in_array($post->post_type, $default_obj->cpt_slugs, true)) { |
|
601 | + //note some error proofing going on here to save unnecessary db queries |
|
602 | + $taxonomies = get_object_taxonomies($post->post_type); |
|
603 | + foreach ((array)$taxonomies as $taxonomy) { |
|
604 | + $terms = wp_get_post_terms($post_id, $taxonomy); |
|
605 | + if (empty($terms) && $taxonomy === $default_obj->taxonomy) { |
|
606 | + wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy); |
|
607 | + } |
|
608 | + } |
|
609 | + } |
|
610 | + } |
|
611 | + } |
|
612 | + } |
|
613 | 613 | |
614 | 614 | } |
615 | 615 | |
@@ -623,27 +623,27 @@ discard block |
||
623 | 623 | { |
624 | 624 | |
625 | 625 | |
626 | - //props holding the items |
|
627 | - public $taxonomy = ''; |
|
626 | + //props holding the items |
|
627 | + public $taxonomy = ''; |
|
628 | 628 | |
629 | - public $cpt_slugs = array(); |
|
629 | + public $cpt_slugs = array(); |
|
630 | 630 | |
631 | - public $term_slug = ''; |
|
631 | + public $term_slug = ''; |
|
632 | 632 | |
633 | 633 | |
634 | 634 | |
635 | - /** |
|
636 | - * constructor |
|
637 | - * |
|
638 | - * @param string $taxonomy The taxonomy the default term belongs to |
|
639 | - * @param string $term_slug The slug of the term that will be the default. |
|
640 | - * @param array $cpt_slugs The custom post type the default term gets saved with |
|
641 | - */ |
|
642 | - public function __construct($taxonomy, $term_slug, $cpt_slugs = array()) |
|
643 | - { |
|
644 | - $this->taxonomy = $taxonomy; |
|
645 | - $this->cpt_slugs = (array)$cpt_slugs; |
|
646 | - $this->term_slug = $term_slug; |
|
647 | - } |
|
635 | + /** |
|
636 | + * constructor |
|
637 | + * |
|
638 | + * @param string $taxonomy The taxonomy the default term belongs to |
|
639 | + * @param string $term_slug The slug of the term that will be the default. |
|
640 | + * @param array $cpt_slugs The custom post type the default term gets saved with |
|
641 | + */ |
|
642 | + public function __construct($taxonomy, $term_slug, $cpt_slugs = array()) |
|
643 | + { |
|
644 | + $this->taxonomy = $taxonomy; |
|
645 | + $this->cpt_slugs = (array)$cpt_slugs; |
|
646 | + $this->term_slug = $term_slug; |
|
647 | + } |
|
648 | 648 | |
649 | 649 | } |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | */ |
556 | 556 | public function set_must_use_terms($taxonomy, $term_details) |
557 | 557 | { |
558 | - $term_details = (array)$term_details; |
|
558 | + $term_details = (array) $term_details; |
|
559 | 559 | foreach ($term_details as $slug => $details) { |
560 | 560 | if ( ! term_exists($slug, $taxonomy)) { |
561 | 561 | $insert_arr = array( |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | if ($post->post_status === 'publish' && in_array($post->post_type, $default_obj->cpt_slugs, true)) { |
601 | 601 | //note some error proofing going on here to save unnecessary db queries |
602 | 602 | $taxonomies = get_object_taxonomies($post->post_type); |
603 | - foreach ((array)$taxonomies as $taxonomy) { |
|
603 | + foreach ((array) $taxonomies as $taxonomy) { |
|
604 | 604 | $terms = wp_get_post_terms($post_id, $taxonomy); |
605 | 605 | if (empty($terms) && $taxonomy === $default_obj->taxonomy) { |
606 | 606 | wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy); |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | public function __construct($taxonomy, $term_slug, $cpt_slugs = array()) |
643 | 643 | { |
644 | 644 | $this->taxonomy = $taxonomy; |
645 | - $this->cpt_slugs = (array)$cpt_slugs; |
|
645 | + $this->cpt_slugs = (array) $cpt_slugs; |
|
646 | 646 | $this->term_slug = $term_slug; |
647 | 647 | } |
648 | 648 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\admin_pages\general_settings\AdminOptionsSettings; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('NO direct script access allowed'); |
|
5 | + exit('NO direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -22,1137 +22,1137 @@ discard block |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * _question_group |
|
27 | - * holds the specific question group object for the question group details screen |
|
28 | - * @var object |
|
29 | - */ |
|
30 | - protected $_question_group; |
|
31 | - |
|
32 | - |
|
33 | - public function __construct($routing = true) |
|
34 | - { |
|
35 | - parent::__construct($routing); |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - protected function _init_page_props() |
|
40 | - { |
|
41 | - $this->page_slug = GEN_SET_PG_SLUG; |
|
42 | - $this->page_label = GEN_SET_LABEL; |
|
43 | - $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
44 | - $this->_admin_base_path = GEN_SET_ADMIN; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - protected function _ajax_hooks() |
|
49 | - { |
|
50 | - add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings')); |
|
51 | - add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states')); |
|
52 | - add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3); |
|
53 | - add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state')); |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - protected function _define_page_props() |
|
58 | - { |
|
59 | - $this->_admin_page_title = GEN_SET_LABEL; |
|
60 | - $this->_labels = array( |
|
61 | - 'publishbox' => __('Update Settings', 'event_espresso') |
|
62 | - ); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - protected function _set_page_routes() |
|
67 | - { |
|
68 | - $this->_page_routes = array( |
|
69 | - |
|
70 | - 'critical_pages' => array( |
|
71 | - 'func' => '_espresso_page_settings', |
|
72 | - 'capability' => 'manage_options' |
|
73 | - ), |
|
74 | - 'update_espresso_page_settings' => array( |
|
75 | - 'func' => '_update_espresso_page_settings', |
|
76 | - 'capability' => 'manage_options', |
|
77 | - 'noheader' => true, |
|
78 | - ), |
|
79 | - 'default' => array( |
|
80 | - 'func' => '_your_organization_settings', |
|
81 | - 'capability' => 'manage_options', |
|
82 | - ), |
|
83 | - |
|
84 | - 'update_your_organization_settings' => array( |
|
85 | - 'func' => '_update_your_organization_settings', |
|
86 | - 'capability' => 'manage_options', |
|
87 | - 'noheader' => true, |
|
88 | - ), |
|
89 | - |
|
90 | - 'admin_option_settings' => array( |
|
91 | - 'func' => '_admin_option_settings', |
|
92 | - 'capability' => 'manage_options', |
|
93 | - ), |
|
94 | - |
|
95 | - 'update_admin_option_settings' => array( |
|
96 | - 'func' => '_update_admin_option_settings', |
|
97 | - 'capability' => 'manage_options', |
|
98 | - 'noheader' => true, |
|
99 | - ), |
|
100 | - |
|
101 | - 'country_settings' => array( |
|
102 | - 'func' => '_country_settings', |
|
103 | - 'capability' => 'manage_options' |
|
104 | - ), |
|
105 | - |
|
106 | - 'update_country_settings' => array( |
|
107 | - 'func' => '_update_country_settings', |
|
108 | - 'capability' => 'manage_options', |
|
109 | - 'noheader' => true, |
|
110 | - ), |
|
111 | - |
|
112 | - 'display_country_settings' => array( |
|
113 | - 'func' => 'display_country_settings', |
|
114 | - 'capability' => 'manage_options', |
|
115 | - 'noheader' => true, |
|
116 | - ), |
|
117 | - |
|
118 | - 'add_new_state' => array( |
|
119 | - 'func' => 'add_new_state', |
|
120 | - 'capability' => 'manage_options', |
|
121 | - 'noheader' => true, |
|
122 | - ), |
|
123 | - |
|
124 | - 'delete_state' => array( |
|
125 | - 'func' => 'delete_state', |
|
126 | - 'capability' => 'manage_options', |
|
127 | - 'noheader' => true, |
|
128 | - ) |
|
129 | - ); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - protected function _set_page_config() |
|
134 | - { |
|
135 | - $this->_page_config = array( |
|
136 | - 'critical_pages' => array( |
|
137 | - 'nav' => array( |
|
138 | - 'label' => __('Critical Pages', 'event_espresso'), |
|
139 | - 'order' => 50 |
|
140 | - ), |
|
141 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
142 | - 'help_tabs' => array( |
|
143 | - 'general_settings_critical_pages_help_tab' => array( |
|
144 | - 'title' => __('Critical Pages', 'event_espresso'), |
|
145 | - 'filename' => 'general_settings_critical_pages' |
|
146 | - ) |
|
147 | - ), |
|
148 | - 'help_tour' => array('Critical_Pages_Help_Tour'), |
|
149 | - 'require_nonce' => false |
|
150 | - ), |
|
151 | - 'default' => array( |
|
152 | - 'nav' => array( |
|
153 | - 'label' => __('Your Organization', 'event_espresso'), |
|
154 | - 'order' => 20 |
|
155 | - ), |
|
156 | - 'help_tabs' => array( |
|
157 | - 'general_settings_your_organization_help_tab' => array( |
|
158 | - 'title' => __('Your Organization', 'event_espresso'), |
|
159 | - 'filename' => 'general_settings_your_organization' |
|
160 | - ) |
|
161 | - ), |
|
162 | - 'help_tour' => array('Your_Organization_Help_Tour'), |
|
163 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
164 | - 'require_nonce' => false |
|
165 | - ), |
|
166 | - 'admin_option_settings' => array( |
|
167 | - 'nav' => array( |
|
168 | - 'label' => __('Admin Options', 'event_espresso'), |
|
169 | - 'order' => 60 |
|
170 | - ), |
|
171 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
172 | - 'help_tabs' => array( |
|
173 | - 'general_settings_admin_options_help_tab' => array( |
|
174 | - 'title' => __('Admin Options', 'event_espresso'), |
|
175 | - 'filename' => 'general_settings_admin_options' |
|
176 | - ) |
|
177 | - ), |
|
178 | - 'help_tour' => array('Admin_Options_Help_Tour'), |
|
179 | - 'require_nonce' => false |
|
180 | - ), |
|
181 | - 'country_settings' => array( |
|
182 | - 'nav' => array( |
|
183 | - 'label' => __('Countries', 'event_espresso'), |
|
184 | - 'order' => 70 |
|
185 | - ), |
|
186 | - 'help_tabs' => array( |
|
187 | - 'general_settings_countries_help_tab' => array( |
|
188 | - 'title' => __('Countries', 'event_espresso'), |
|
189 | - 'filename' => 'general_settings_countries' |
|
190 | - ) |
|
191 | - ), |
|
192 | - 'help_tour' => array('Countries_Help_Tour'), |
|
193 | - 'require_nonce' => false |
|
194 | - ) |
|
195 | - ); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - protected function _add_screen_options() |
|
200 | - { |
|
201 | - } |
|
202 | - |
|
203 | - protected function _add_feature_pointers() |
|
204 | - { |
|
205 | - } |
|
206 | - |
|
207 | - public function load_scripts_styles() |
|
208 | - { |
|
209 | - //styles |
|
210 | - wp_enqueue_style('espresso-ui-theme'); |
|
211 | - //scripts |
|
212 | - wp_enqueue_script('ee_admin_js'); |
|
213 | - } |
|
214 | - |
|
215 | - public function admin_init() |
|
216 | - { |
|
217 | - EE_Registry::$i18n_js_strings['invalid_server_response'] = __('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
218 | - 'event_espresso'); |
|
219 | - EE_Registry::$i18n_js_strings['error_occurred'] = __('An error occurred! Please refresh the page and try again.', |
|
220 | - 'event_espresso'); |
|
221 | - EE_Registry::$i18n_js_strings['confirm_delete_state'] = __('Are you sure you want to delete this State / Province?', |
|
222 | - 'event_espresso'); |
|
223 | - $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
224 | - EE_Registry::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php?page=espresso_general_settings', |
|
225 | - $protocol); |
|
226 | - } |
|
227 | - |
|
228 | - public function admin_notices() |
|
229 | - { |
|
230 | - } |
|
231 | - |
|
232 | - public function admin_footer_scripts() |
|
233 | - { |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - public function load_scripts_styles_default() |
|
238 | - { |
|
239 | - //styles |
|
240 | - wp_enqueue_style('thickbox'); |
|
241 | - //scripts |
|
242 | - wp_enqueue_script('media-upload'); |
|
243 | - wp_enqueue_script('thickbox'); |
|
244 | - wp_register_script('organization_settings', GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
245 | - array('jquery', 'media-upload', 'thickbox'), EVENT_ESPRESSO_VERSION, true); |
|
246 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
247 | - wp_enqueue_script('organization_settings'); |
|
248 | - wp_enqueue_style('organization-css'); |
|
249 | - $confirm_image_delete = array( |
|
250 | - 'text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
251 | - 'event_espresso') |
|
252 | - ); |
|
253 | - wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
254 | - |
|
255 | - } |
|
256 | - |
|
257 | - public function load_scripts_styles_country_settings() |
|
258 | - { |
|
259 | - //scripts |
|
260 | - wp_register_script('gen_settings_countries', GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
261 | - array('ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
|
262 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
263 | - wp_enqueue_script('gen_settings_countries'); |
|
264 | - wp_enqueue_style('organization-css'); |
|
265 | - |
|
266 | - } |
|
267 | - |
|
268 | - |
|
269 | - /************* Espresso Pages *************/ |
|
270 | - /** |
|
271 | - * _espresso_page_settings |
|
272 | - * |
|
273 | - * @throws \EE_Error |
|
274 | - */ |
|
275 | - protected function _espresso_page_settings() |
|
276 | - { |
|
277 | - // Check to make sure all of the main pages are setup properly, |
|
278 | - // if not create the default pages and display an admin notice |
|
279 | - EEH_Activation::verify_default_pages_exist(); |
|
280 | - $this->_transient_garbage_collection(); |
|
281 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
282 | - $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
283 | - ? EE_Registry::instance()->CFG->core->reg_page_id |
|
284 | - : null; |
|
285 | - $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
286 | - ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) |
|
287 | - : false; |
|
288 | - $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
289 | - ? EE_Registry::instance()->CFG->core->txn_page_id |
|
290 | - : null; |
|
291 | - $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
292 | - ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) |
|
293 | - : false; |
|
294 | - $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
295 | - ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
296 | - : null; |
|
297 | - $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
298 | - ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
299 | - : false; |
|
300 | - $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
301 | - ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
302 | - : null; |
|
303 | - $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
304 | - ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
305 | - : false; |
|
306 | - $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
307 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
308 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
309 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
310 | - $this->_template_args, |
|
311 | - true |
|
312 | - ); |
|
313 | - $this->display_admin_page_with_sidebar(); |
|
314 | - |
|
315 | - } |
|
316 | - |
|
317 | - protected function _update_espresso_page_settings() |
|
318 | - { |
|
319 | - // capture incoming request data && set page IDs |
|
320 | - EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
321 | - ? absint($this->_req_data['reg_page_id']) |
|
322 | - : EE_Registry::instance()->CFG->core->reg_page_id; |
|
323 | - EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
324 | - ? absint($this->_req_data['txn_page_id']) |
|
325 | - : EE_Registry::instance()->CFG->core->txn_page_id; |
|
326 | - EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
327 | - ? absint($this->_req_data['thank_you_page_id']) |
|
328 | - : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
329 | - EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
330 | - ? absint($this->_req_data['cancel_page_id']) |
|
331 | - : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
332 | - |
|
333 | - EE_Registry::instance()->CFG->core = apply_filters( |
|
334 | - 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
335 | - EE_Registry::instance()->CFG->core, |
|
336 | - $this->_req_data |
|
337 | - ); |
|
338 | - $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
339 | - $this->_redirect_after_action( |
|
340 | - // success |
|
341 | - $this->_update_espresso_configuration( |
|
342 | - $what, |
|
343 | - EE_Registry::instance()->CFG->core, |
|
344 | - __FILE__, |
|
345 | - __FUNCTION__, |
|
346 | - __LINE__ |
|
347 | - ), |
|
348 | - // what |
|
349 | - $what |
|
350 | - , |
|
351 | - // action desc |
|
352 | - '', |
|
353 | - // query args |
|
354 | - array( |
|
355 | - 'action' => 'critical_pages' |
|
356 | - ), |
|
357 | - true |
|
358 | - ); |
|
359 | - |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - /************* Your Organization *************/ |
|
364 | - |
|
365 | - |
|
366 | - protected function _your_organization_settings() |
|
367 | - { |
|
368 | - |
|
369 | - $this->_template_args['site_license_key'] = isset(EE_Registry::instance()->NET_CFG->core->site_license_key) ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') : ''; |
|
370 | - $this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : ''; |
|
371 | - $this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') : ''; |
|
372 | - $this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') : ''; |
|
373 | - $this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city) ? EE_Registry::instance()->CFG->organization->get_pretty('city') : ''; |
|
374 | - $this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip) ? EE_Registry::instance()->CFG->organization->get_pretty('zip') : ''; |
|
375 | - $this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : ''; |
|
376 | - $this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone) ? EE_Registry::instance()->CFG->organization->get_pretty('phone') : ''; |
|
377 | - $this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat) ? EE_Registry::instance()->CFG->organization->get_pretty('vat') : ''; |
|
378 | - $this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign) ? EE_Registry::instance()->CFG->currency->get_pretty('sign') : '$'; |
|
379 | - $this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url) ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') : false; |
|
380 | - $this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : ''; |
|
381 | - $this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : ''; |
|
382 | - $this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin) ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') : ''; |
|
383 | - $this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') : ''; |
|
384 | - $this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google) ? EE_Registry::instance()->CFG->organization->get_pretty('google') : ''; |
|
385 | - $this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') : ''; |
|
386 | - //UXIP settings |
|
387 | - $this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') : true; |
|
388 | - |
|
389 | - $STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID) ? EE_Registry::instance()->CFG->organization->STA_ID : 4; |
|
390 | - $this->_template_args['states'] = new EE_Question_Form_Input( |
|
391 | - EE_Question::new_instance(array( |
|
392 | - 'QST_ID' => 0, |
|
393 | - 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
394 | - 'QST_system' => 'admin-state' |
|
395 | - )), |
|
396 | - EE_Answer::new_instance(array( |
|
397 | - 'ANS_ID' => 0, |
|
398 | - 'ANS_value' => $STA_ID |
|
399 | - )), |
|
400 | - array( |
|
401 | - 'input_id' => 'organization_state', |
|
402 | - 'input_name' => 'organization_state', |
|
403 | - 'input_prefix' => '', |
|
404 | - 'append_qstn_id' => false |
|
405 | - ) |
|
406 | - ); |
|
407 | - |
|
408 | - $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US'; |
|
409 | - $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
410 | - EE_Question::new_instance(array( |
|
411 | - 'QST_ID' => 0, |
|
412 | - 'QST_display_text' => __('Country', 'event_espresso'), |
|
413 | - 'QST_system' => 'admin-country' |
|
414 | - )), |
|
415 | - EE_Answer::new_instance(array( |
|
416 | - 'ANS_ID' => 0, |
|
417 | - 'ANS_value' => $CNT_ISO |
|
418 | - )), |
|
419 | - array( |
|
420 | - 'input_id' => 'organization_country', |
|
421 | - 'input_name' => 'organization_country', |
|
422 | - 'input_prefix' => '', |
|
423 | - 'append_qstn_id' => false |
|
424 | - ) |
|
425 | - ); |
|
426 | - |
|
427 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
428 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
429 | - |
|
430 | - //PUE verification stuff |
|
431 | - $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
432 | - $verify_fail = get_option($ver_option_key); |
|
433 | - $this->_template_args['site_license_key_verified'] = $verify_fail || ! empty($verify_fail) || (empty($this->_template_args['site_license_key']) && empty($verify_fail)) ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>'; |
|
434 | - |
|
435 | - $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
436 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
437 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', |
|
438 | - $this->_template_args, true); |
|
439 | - |
|
440 | - $this->display_admin_page_with_sidebar(); |
|
441 | - } |
|
442 | - |
|
443 | - protected function _update_your_organization_settings() |
|
444 | - { |
|
445 | - if (is_main_site()) { |
|
446 | - EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) ? sanitize_text_field($this->_req_data['site_license_key']) : EE_Registry::instance()->NET_CFG->core->site_license_key; |
|
447 | - } |
|
448 | - EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name']) ? sanitize_text_field($this->_req_data['organization_name']) : EE_Registry::instance()->CFG->organization->name; |
|
449 | - EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) ? sanitize_text_field($this->_req_data['organization_address_1']) : EE_Registry::instance()->CFG->organization->address_1; |
|
450 | - EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) ? sanitize_text_field($this->_req_data['organization_address_2']) : EE_Registry::instance()->CFG->organization->address_2; |
|
451 | - EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city']) ? sanitize_text_field($this->_req_data['organization_city']) : EE_Registry::instance()->CFG->organization->city; |
|
452 | - EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state']) ? absint($this->_req_data['organization_state']) : EE_Registry::instance()->CFG->organization->STA_ID; |
|
453 | - EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country']) ? sanitize_text_field($this->_req_data['organization_country']) : EE_Registry::instance()->CFG->organization->CNT_ISO; |
|
454 | - EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip']) ? sanitize_text_field($this->_req_data['organization_zip']) : EE_Registry::instance()->CFG->organization->zip; |
|
455 | - EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email']) ? sanitize_email($this->_req_data['organization_email']) : EE_Registry::instance()->CFG->organization->email; |
|
456 | - EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat']) ? sanitize_text_field($this->_req_data['organization_vat']) : EE_Registry::instance()->CFG->organization->vat; |
|
457 | - EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone']) ? sanitize_text_field($this->_req_data['organization_phone']) : EE_Registry::instance()->CFG->organization->phone; |
|
458 | - EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url']) ? esc_url_raw($this->_req_data['organization_logo_url']) : EE_Registry::instance()->CFG->organization->logo_url; |
|
459 | - EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook']) ? esc_url_raw($this->_req_data['organization_facebook']) : EE_Registry::instance()->CFG->organization->facebook; |
|
460 | - EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter']) ? esc_url_raw($this->_req_data['organization_twitter']) : EE_Registry::instance()->CFG->organization->twitter; |
|
461 | - EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin']) ? esc_url_raw($this->_req_data['organization_linkedin']) : EE_Registry::instance()->CFG->organization->linkedin; |
|
462 | - EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) ? esc_url_raw($this->_req_data['organization_pinterest']) : EE_Registry::instance()->CFG->organization->pinterest; |
|
463 | - EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google']) ? esc_url_raw($this->_req_data['organization_google']) : EE_Registry::instance()->CFG->organization->google; |
|
464 | - EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) ? esc_url_raw($this->_req_data['organization_instagram']) : EE_Registry::instance()->CFG->organization->instagram; |
|
465 | - EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin']) && ! empty($this->_req_data['ueip_optin']) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin; |
|
466 | - |
|
467 | - EE_Registry::instance()->CFG->currency = new EE_Currency_Config(EE_Registry::instance()->CFG->organization->CNT_ISO); |
|
468 | - |
|
469 | - EE_Registry::instance()->CFG = apply_filters('FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
470 | - EE_Registry::instance()->CFG); |
|
471 | - |
|
472 | - $what = 'Your Organization Settings'; |
|
473 | - $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, |
|
474 | - __LINE__); |
|
475 | - |
|
476 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default')); |
|
477 | - |
|
478 | - } |
|
479 | - |
|
480 | - |
|
481 | - |
|
482 | - /************* Admin Options *************/ |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * _admin_option_settings |
|
487 | - * |
|
488 | - * @throws \EE_Error |
|
489 | - * @throws \LogicException |
|
490 | - */ |
|
491 | - protected function _admin_option_settings() |
|
492 | - { |
|
493 | - $this->_template_args['admin_page_content'] = ''; |
|
494 | - try { |
|
495 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
496 | - // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
497 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
498 | - // also need to account for the do_action that was in the old template |
|
499 | - $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
500 | - $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
501 | - } catch (Exception $e) { |
|
502 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
503 | - } |
|
504 | - $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
505 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
506 | - $this->display_admin_page_with_sidebar(); |
|
507 | - } |
|
508 | - |
|
509 | - |
|
510 | - /** |
|
511 | - * _update_admin_option_settings |
|
512 | - * |
|
513 | - * @throws \EE_Error |
|
514 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
515 | - * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException |
|
516 | - * @throws \InvalidArgumentException |
|
517 | - * @throws \LogicException |
|
518 | - */ |
|
519 | - protected function _update_admin_option_settings() |
|
520 | - { |
|
521 | - try { |
|
522 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
523 | - $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]); |
|
524 | - EE_Registry::instance()->CFG->admin = apply_filters( |
|
525 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
526 | - EE_Registry::instance()->CFG->admin |
|
527 | - ); |
|
528 | - } catch (Exception $e) { |
|
529 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
530 | - } |
|
531 | - $this->_redirect_after_action( |
|
532 | - apply_filters( |
|
533 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
534 | - $this->_update_espresso_configuration( |
|
535 | - 'Admin Options', |
|
536 | - EE_Registry::instance()->CFG->admin, |
|
537 | - __FILE__, __FUNCTION__, __LINE__ |
|
538 | - ) |
|
539 | - ), |
|
540 | - 'Admin Options', |
|
541 | - 'updated', |
|
542 | - array('action' => 'admin_option_settings') |
|
543 | - ); |
|
544 | - |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /************* Countries *************/ |
|
549 | - |
|
550 | - |
|
551 | - protected function _country_settings() |
|
552 | - { |
|
553 | - |
|
554 | - $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US'; |
|
555 | - $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO; |
|
556 | - |
|
557 | - //load field generator helper |
|
558 | - |
|
559 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
560 | - |
|
561 | - $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
562 | - EE_Question::new_instance(array( |
|
563 | - 'QST_ID' => 0, |
|
564 | - 'QST_display_text' => __('Select Country', 'event_espresso'), |
|
565 | - 'QST_system' => 'admin-country' |
|
566 | - )), |
|
567 | - EE_Answer::new_instance(array( |
|
568 | - 'ANS_ID' => 0, |
|
569 | - 'ANS_value' => $CNT_ISO |
|
570 | - )), |
|
571 | - array( |
|
572 | - 'input_id' => 'country', |
|
573 | - 'input_name' => 'country', |
|
574 | - 'input_prefix' => '', |
|
575 | - 'append_qstn_id' => false |
|
576 | - ) |
|
577 | - ); |
|
25 | + /** |
|
26 | + * _question_group |
|
27 | + * holds the specific question group object for the question group details screen |
|
28 | + * @var object |
|
29 | + */ |
|
30 | + protected $_question_group; |
|
31 | + |
|
32 | + |
|
33 | + public function __construct($routing = true) |
|
34 | + { |
|
35 | + parent::__construct($routing); |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + protected function _init_page_props() |
|
40 | + { |
|
41 | + $this->page_slug = GEN_SET_PG_SLUG; |
|
42 | + $this->page_label = GEN_SET_LABEL; |
|
43 | + $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
44 | + $this->_admin_base_path = GEN_SET_ADMIN; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + protected function _ajax_hooks() |
|
49 | + { |
|
50 | + add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings')); |
|
51 | + add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states')); |
|
52 | + add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3); |
|
53 | + add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state')); |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + protected function _define_page_props() |
|
58 | + { |
|
59 | + $this->_admin_page_title = GEN_SET_LABEL; |
|
60 | + $this->_labels = array( |
|
61 | + 'publishbox' => __('Update Settings', 'event_espresso') |
|
62 | + ); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + protected function _set_page_routes() |
|
67 | + { |
|
68 | + $this->_page_routes = array( |
|
69 | + |
|
70 | + 'critical_pages' => array( |
|
71 | + 'func' => '_espresso_page_settings', |
|
72 | + 'capability' => 'manage_options' |
|
73 | + ), |
|
74 | + 'update_espresso_page_settings' => array( |
|
75 | + 'func' => '_update_espresso_page_settings', |
|
76 | + 'capability' => 'manage_options', |
|
77 | + 'noheader' => true, |
|
78 | + ), |
|
79 | + 'default' => array( |
|
80 | + 'func' => '_your_organization_settings', |
|
81 | + 'capability' => 'manage_options', |
|
82 | + ), |
|
83 | + |
|
84 | + 'update_your_organization_settings' => array( |
|
85 | + 'func' => '_update_your_organization_settings', |
|
86 | + 'capability' => 'manage_options', |
|
87 | + 'noheader' => true, |
|
88 | + ), |
|
89 | + |
|
90 | + 'admin_option_settings' => array( |
|
91 | + 'func' => '_admin_option_settings', |
|
92 | + 'capability' => 'manage_options', |
|
93 | + ), |
|
94 | + |
|
95 | + 'update_admin_option_settings' => array( |
|
96 | + 'func' => '_update_admin_option_settings', |
|
97 | + 'capability' => 'manage_options', |
|
98 | + 'noheader' => true, |
|
99 | + ), |
|
100 | + |
|
101 | + 'country_settings' => array( |
|
102 | + 'func' => '_country_settings', |
|
103 | + 'capability' => 'manage_options' |
|
104 | + ), |
|
105 | + |
|
106 | + 'update_country_settings' => array( |
|
107 | + 'func' => '_update_country_settings', |
|
108 | + 'capability' => 'manage_options', |
|
109 | + 'noheader' => true, |
|
110 | + ), |
|
111 | + |
|
112 | + 'display_country_settings' => array( |
|
113 | + 'func' => 'display_country_settings', |
|
114 | + 'capability' => 'manage_options', |
|
115 | + 'noheader' => true, |
|
116 | + ), |
|
117 | + |
|
118 | + 'add_new_state' => array( |
|
119 | + 'func' => 'add_new_state', |
|
120 | + 'capability' => 'manage_options', |
|
121 | + 'noheader' => true, |
|
122 | + ), |
|
123 | + |
|
124 | + 'delete_state' => array( |
|
125 | + 'func' => 'delete_state', |
|
126 | + 'capability' => 'manage_options', |
|
127 | + 'noheader' => true, |
|
128 | + ) |
|
129 | + ); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + protected function _set_page_config() |
|
134 | + { |
|
135 | + $this->_page_config = array( |
|
136 | + 'critical_pages' => array( |
|
137 | + 'nav' => array( |
|
138 | + 'label' => __('Critical Pages', 'event_espresso'), |
|
139 | + 'order' => 50 |
|
140 | + ), |
|
141 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
142 | + 'help_tabs' => array( |
|
143 | + 'general_settings_critical_pages_help_tab' => array( |
|
144 | + 'title' => __('Critical Pages', 'event_espresso'), |
|
145 | + 'filename' => 'general_settings_critical_pages' |
|
146 | + ) |
|
147 | + ), |
|
148 | + 'help_tour' => array('Critical_Pages_Help_Tour'), |
|
149 | + 'require_nonce' => false |
|
150 | + ), |
|
151 | + 'default' => array( |
|
152 | + 'nav' => array( |
|
153 | + 'label' => __('Your Organization', 'event_espresso'), |
|
154 | + 'order' => 20 |
|
155 | + ), |
|
156 | + 'help_tabs' => array( |
|
157 | + 'general_settings_your_organization_help_tab' => array( |
|
158 | + 'title' => __('Your Organization', 'event_espresso'), |
|
159 | + 'filename' => 'general_settings_your_organization' |
|
160 | + ) |
|
161 | + ), |
|
162 | + 'help_tour' => array('Your_Organization_Help_Tour'), |
|
163 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
164 | + 'require_nonce' => false |
|
165 | + ), |
|
166 | + 'admin_option_settings' => array( |
|
167 | + 'nav' => array( |
|
168 | + 'label' => __('Admin Options', 'event_espresso'), |
|
169 | + 'order' => 60 |
|
170 | + ), |
|
171 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
172 | + 'help_tabs' => array( |
|
173 | + 'general_settings_admin_options_help_tab' => array( |
|
174 | + 'title' => __('Admin Options', 'event_espresso'), |
|
175 | + 'filename' => 'general_settings_admin_options' |
|
176 | + ) |
|
177 | + ), |
|
178 | + 'help_tour' => array('Admin_Options_Help_Tour'), |
|
179 | + 'require_nonce' => false |
|
180 | + ), |
|
181 | + 'country_settings' => array( |
|
182 | + 'nav' => array( |
|
183 | + 'label' => __('Countries', 'event_espresso'), |
|
184 | + 'order' => 70 |
|
185 | + ), |
|
186 | + 'help_tabs' => array( |
|
187 | + 'general_settings_countries_help_tab' => array( |
|
188 | + 'title' => __('Countries', 'event_espresso'), |
|
189 | + 'filename' => 'general_settings_countries' |
|
190 | + ) |
|
191 | + ), |
|
192 | + 'help_tour' => array('Countries_Help_Tour'), |
|
193 | + 'require_nonce' => false |
|
194 | + ) |
|
195 | + ); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + protected function _add_screen_options() |
|
200 | + { |
|
201 | + } |
|
202 | + |
|
203 | + protected function _add_feature_pointers() |
|
204 | + { |
|
205 | + } |
|
206 | + |
|
207 | + public function load_scripts_styles() |
|
208 | + { |
|
209 | + //styles |
|
210 | + wp_enqueue_style('espresso-ui-theme'); |
|
211 | + //scripts |
|
212 | + wp_enqueue_script('ee_admin_js'); |
|
213 | + } |
|
214 | + |
|
215 | + public function admin_init() |
|
216 | + { |
|
217 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = __('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
218 | + 'event_espresso'); |
|
219 | + EE_Registry::$i18n_js_strings['error_occurred'] = __('An error occurred! Please refresh the page and try again.', |
|
220 | + 'event_espresso'); |
|
221 | + EE_Registry::$i18n_js_strings['confirm_delete_state'] = __('Are you sure you want to delete this State / Province?', |
|
222 | + 'event_espresso'); |
|
223 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
224 | + EE_Registry::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php?page=espresso_general_settings', |
|
225 | + $protocol); |
|
226 | + } |
|
227 | + |
|
228 | + public function admin_notices() |
|
229 | + { |
|
230 | + } |
|
231 | + |
|
232 | + public function admin_footer_scripts() |
|
233 | + { |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + public function load_scripts_styles_default() |
|
238 | + { |
|
239 | + //styles |
|
240 | + wp_enqueue_style('thickbox'); |
|
241 | + //scripts |
|
242 | + wp_enqueue_script('media-upload'); |
|
243 | + wp_enqueue_script('thickbox'); |
|
244 | + wp_register_script('organization_settings', GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
245 | + array('jquery', 'media-upload', 'thickbox'), EVENT_ESPRESSO_VERSION, true); |
|
246 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
247 | + wp_enqueue_script('organization_settings'); |
|
248 | + wp_enqueue_style('organization-css'); |
|
249 | + $confirm_image_delete = array( |
|
250 | + 'text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
251 | + 'event_espresso') |
|
252 | + ); |
|
253 | + wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
254 | + |
|
255 | + } |
|
256 | + |
|
257 | + public function load_scripts_styles_country_settings() |
|
258 | + { |
|
259 | + //scripts |
|
260 | + wp_register_script('gen_settings_countries', GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
261 | + array('ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
|
262 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
263 | + wp_enqueue_script('gen_settings_countries'); |
|
264 | + wp_enqueue_style('organization-css'); |
|
265 | + |
|
266 | + } |
|
267 | + |
|
268 | + |
|
269 | + /************* Espresso Pages *************/ |
|
270 | + /** |
|
271 | + * _espresso_page_settings |
|
272 | + * |
|
273 | + * @throws \EE_Error |
|
274 | + */ |
|
275 | + protected function _espresso_page_settings() |
|
276 | + { |
|
277 | + // Check to make sure all of the main pages are setup properly, |
|
278 | + // if not create the default pages and display an admin notice |
|
279 | + EEH_Activation::verify_default_pages_exist(); |
|
280 | + $this->_transient_garbage_collection(); |
|
281 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
282 | + $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
283 | + ? EE_Registry::instance()->CFG->core->reg_page_id |
|
284 | + : null; |
|
285 | + $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
286 | + ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) |
|
287 | + : false; |
|
288 | + $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
289 | + ? EE_Registry::instance()->CFG->core->txn_page_id |
|
290 | + : null; |
|
291 | + $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
292 | + ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) |
|
293 | + : false; |
|
294 | + $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
295 | + ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
296 | + : null; |
|
297 | + $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
298 | + ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
299 | + : false; |
|
300 | + $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
301 | + ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
302 | + : null; |
|
303 | + $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
304 | + ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
305 | + : false; |
|
306 | + $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
307 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
308 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
309 | + GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
310 | + $this->_template_args, |
|
311 | + true |
|
312 | + ); |
|
313 | + $this->display_admin_page_with_sidebar(); |
|
314 | + |
|
315 | + } |
|
316 | + |
|
317 | + protected function _update_espresso_page_settings() |
|
318 | + { |
|
319 | + // capture incoming request data && set page IDs |
|
320 | + EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
321 | + ? absint($this->_req_data['reg_page_id']) |
|
322 | + : EE_Registry::instance()->CFG->core->reg_page_id; |
|
323 | + EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
324 | + ? absint($this->_req_data['txn_page_id']) |
|
325 | + : EE_Registry::instance()->CFG->core->txn_page_id; |
|
326 | + EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
327 | + ? absint($this->_req_data['thank_you_page_id']) |
|
328 | + : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
329 | + EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
330 | + ? absint($this->_req_data['cancel_page_id']) |
|
331 | + : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
332 | + |
|
333 | + EE_Registry::instance()->CFG->core = apply_filters( |
|
334 | + 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
335 | + EE_Registry::instance()->CFG->core, |
|
336 | + $this->_req_data |
|
337 | + ); |
|
338 | + $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
339 | + $this->_redirect_after_action( |
|
340 | + // success |
|
341 | + $this->_update_espresso_configuration( |
|
342 | + $what, |
|
343 | + EE_Registry::instance()->CFG->core, |
|
344 | + __FILE__, |
|
345 | + __FUNCTION__, |
|
346 | + __LINE__ |
|
347 | + ), |
|
348 | + // what |
|
349 | + $what |
|
350 | + , |
|
351 | + // action desc |
|
352 | + '', |
|
353 | + // query args |
|
354 | + array( |
|
355 | + 'action' => 'critical_pages' |
|
356 | + ), |
|
357 | + true |
|
358 | + ); |
|
359 | + |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + /************* Your Organization *************/ |
|
364 | + |
|
365 | + |
|
366 | + protected function _your_organization_settings() |
|
367 | + { |
|
368 | + |
|
369 | + $this->_template_args['site_license_key'] = isset(EE_Registry::instance()->NET_CFG->core->site_license_key) ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') : ''; |
|
370 | + $this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : ''; |
|
371 | + $this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') : ''; |
|
372 | + $this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') : ''; |
|
373 | + $this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city) ? EE_Registry::instance()->CFG->organization->get_pretty('city') : ''; |
|
374 | + $this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip) ? EE_Registry::instance()->CFG->organization->get_pretty('zip') : ''; |
|
375 | + $this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : ''; |
|
376 | + $this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone) ? EE_Registry::instance()->CFG->organization->get_pretty('phone') : ''; |
|
377 | + $this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat) ? EE_Registry::instance()->CFG->organization->get_pretty('vat') : ''; |
|
378 | + $this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign) ? EE_Registry::instance()->CFG->currency->get_pretty('sign') : '$'; |
|
379 | + $this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url) ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') : false; |
|
380 | + $this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : ''; |
|
381 | + $this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : ''; |
|
382 | + $this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin) ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') : ''; |
|
383 | + $this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') : ''; |
|
384 | + $this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google) ? EE_Registry::instance()->CFG->organization->get_pretty('google') : ''; |
|
385 | + $this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') : ''; |
|
386 | + //UXIP settings |
|
387 | + $this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') : true; |
|
388 | + |
|
389 | + $STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID) ? EE_Registry::instance()->CFG->organization->STA_ID : 4; |
|
390 | + $this->_template_args['states'] = new EE_Question_Form_Input( |
|
391 | + EE_Question::new_instance(array( |
|
392 | + 'QST_ID' => 0, |
|
393 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
394 | + 'QST_system' => 'admin-state' |
|
395 | + )), |
|
396 | + EE_Answer::new_instance(array( |
|
397 | + 'ANS_ID' => 0, |
|
398 | + 'ANS_value' => $STA_ID |
|
399 | + )), |
|
400 | + array( |
|
401 | + 'input_id' => 'organization_state', |
|
402 | + 'input_name' => 'organization_state', |
|
403 | + 'input_prefix' => '', |
|
404 | + 'append_qstn_id' => false |
|
405 | + ) |
|
406 | + ); |
|
407 | + |
|
408 | + $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US'; |
|
409 | + $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
410 | + EE_Question::new_instance(array( |
|
411 | + 'QST_ID' => 0, |
|
412 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
413 | + 'QST_system' => 'admin-country' |
|
414 | + )), |
|
415 | + EE_Answer::new_instance(array( |
|
416 | + 'ANS_ID' => 0, |
|
417 | + 'ANS_value' => $CNT_ISO |
|
418 | + )), |
|
419 | + array( |
|
420 | + 'input_id' => 'organization_country', |
|
421 | + 'input_name' => 'organization_country', |
|
422 | + 'input_prefix' => '', |
|
423 | + 'append_qstn_id' => false |
|
424 | + ) |
|
425 | + ); |
|
426 | + |
|
427 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
428 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
429 | + |
|
430 | + //PUE verification stuff |
|
431 | + $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
432 | + $verify_fail = get_option($ver_option_key); |
|
433 | + $this->_template_args['site_license_key_verified'] = $verify_fail || ! empty($verify_fail) || (empty($this->_template_args['site_license_key']) && empty($verify_fail)) ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>'; |
|
434 | + |
|
435 | + $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
436 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
437 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', |
|
438 | + $this->_template_args, true); |
|
439 | + |
|
440 | + $this->display_admin_page_with_sidebar(); |
|
441 | + } |
|
442 | + |
|
443 | + protected function _update_your_organization_settings() |
|
444 | + { |
|
445 | + if (is_main_site()) { |
|
446 | + EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) ? sanitize_text_field($this->_req_data['site_license_key']) : EE_Registry::instance()->NET_CFG->core->site_license_key; |
|
447 | + } |
|
448 | + EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name']) ? sanitize_text_field($this->_req_data['organization_name']) : EE_Registry::instance()->CFG->organization->name; |
|
449 | + EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) ? sanitize_text_field($this->_req_data['organization_address_1']) : EE_Registry::instance()->CFG->organization->address_1; |
|
450 | + EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) ? sanitize_text_field($this->_req_data['organization_address_2']) : EE_Registry::instance()->CFG->organization->address_2; |
|
451 | + EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city']) ? sanitize_text_field($this->_req_data['organization_city']) : EE_Registry::instance()->CFG->organization->city; |
|
452 | + EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state']) ? absint($this->_req_data['organization_state']) : EE_Registry::instance()->CFG->organization->STA_ID; |
|
453 | + EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country']) ? sanitize_text_field($this->_req_data['organization_country']) : EE_Registry::instance()->CFG->organization->CNT_ISO; |
|
454 | + EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip']) ? sanitize_text_field($this->_req_data['organization_zip']) : EE_Registry::instance()->CFG->organization->zip; |
|
455 | + EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email']) ? sanitize_email($this->_req_data['organization_email']) : EE_Registry::instance()->CFG->organization->email; |
|
456 | + EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat']) ? sanitize_text_field($this->_req_data['organization_vat']) : EE_Registry::instance()->CFG->organization->vat; |
|
457 | + EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone']) ? sanitize_text_field($this->_req_data['organization_phone']) : EE_Registry::instance()->CFG->organization->phone; |
|
458 | + EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url']) ? esc_url_raw($this->_req_data['organization_logo_url']) : EE_Registry::instance()->CFG->organization->logo_url; |
|
459 | + EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook']) ? esc_url_raw($this->_req_data['organization_facebook']) : EE_Registry::instance()->CFG->organization->facebook; |
|
460 | + EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter']) ? esc_url_raw($this->_req_data['organization_twitter']) : EE_Registry::instance()->CFG->organization->twitter; |
|
461 | + EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin']) ? esc_url_raw($this->_req_data['organization_linkedin']) : EE_Registry::instance()->CFG->organization->linkedin; |
|
462 | + EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) ? esc_url_raw($this->_req_data['organization_pinterest']) : EE_Registry::instance()->CFG->organization->pinterest; |
|
463 | + EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google']) ? esc_url_raw($this->_req_data['organization_google']) : EE_Registry::instance()->CFG->organization->google; |
|
464 | + EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) ? esc_url_raw($this->_req_data['organization_instagram']) : EE_Registry::instance()->CFG->organization->instagram; |
|
465 | + EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin']) && ! empty($this->_req_data['ueip_optin']) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin; |
|
466 | + |
|
467 | + EE_Registry::instance()->CFG->currency = new EE_Currency_Config(EE_Registry::instance()->CFG->organization->CNT_ISO); |
|
468 | + |
|
469 | + EE_Registry::instance()->CFG = apply_filters('FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
470 | + EE_Registry::instance()->CFG); |
|
471 | + |
|
472 | + $what = 'Your Organization Settings'; |
|
473 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, |
|
474 | + __LINE__); |
|
475 | + |
|
476 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default')); |
|
477 | + |
|
478 | + } |
|
479 | + |
|
480 | + |
|
481 | + |
|
482 | + /************* Admin Options *************/ |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * _admin_option_settings |
|
487 | + * |
|
488 | + * @throws \EE_Error |
|
489 | + * @throws \LogicException |
|
490 | + */ |
|
491 | + protected function _admin_option_settings() |
|
492 | + { |
|
493 | + $this->_template_args['admin_page_content'] = ''; |
|
494 | + try { |
|
495 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
496 | + // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
497 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
498 | + // also need to account for the do_action that was in the old template |
|
499 | + $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
500 | + $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
501 | + } catch (Exception $e) { |
|
502 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
503 | + } |
|
504 | + $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
505 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
506 | + $this->display_admin_page_with_sidebar(); |
|
507 | + } |
|
508 | + |
|
509 | + |
|
510 | + /** |
|
511 | + * _update_admin_option_settings |
|
512 | + * |
|
513 | + * @throws \EE_Error |
|
514 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
515 | + * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException |
|
516 | + * @throws \InvalidArgumentException |
|
517 | + * @throws \LogicException |
|
518 | + */ |
|
519 | + protected function _update_admin_option_settings() |
|
520 | + { |
|
521 | + try { |
|
522 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
523 | + $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]); |
|
524 | + EE_Registry::instance()->CFG->admin = apply_filters( |
|
525 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
526 | + EE_Registry::instance()->CFG->admin |
|
527 | + ); |
|
528 | + } catch (Exception $e) { |
|
529 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
530 | + } |
|
531 | + $this->_redirect_after_action( |
|
532 | + apply_filters( |
|
533 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
534 | + $this->_update_espresso_configuration( |
|
535 | + 'Admin Options', |
|
536 | + EE_Registry::instance()->CFG->admin, |
|
537 | + __FILE__, __FUNCTION__, __LINE__ |
|
538 | + ) |
|
539 | + ), |
|
540 | + 'Admin Options', |
|
541 | + 'updated', |
|
542 | + array('action' => 'admin_option_settings') |
|
543 | + ); |
|
544 | + |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /************* Countries *************/ |
|
549 | + |
|
550 | + |
|
551 | + protected function _country_settings() |
|
552 | + { |
|
553 | + |
|
554 | + $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US'; |
|
555 | + $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO; |
|
556 | + |
|
557 | + //load field generator helper |
|
558 | + |
|
559 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
560 | + |
|
561 | + $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
562 | + EE_Question::new_instance(array( |
|
563 | + 'QST_ID' => 0, |
|
564 | + 'QST_display_text' => __('Select Country', 'event_espresso'), |
|
565 | + 'QST_system' => 'admin-country' |
|
566 | + )), |
|
567 | + EE_Answer::new_instance(array( |
|
568 | + 'ANS_ID' => 0, |
|
569 | + 'ANS_value' => $CNT_ISO |
|
570 | + )), |
|
571 | + array( |
|
572 | + 'input_id' => 'country', |
|
573 | + 'input_name' => 'country', |
|
574 | + 'input_prefix' => '', |
|
575 | + 'append_qstn_id' => false |
|
576 | + ) |
|
577 | + ); |
|
578 | 578 | // EEH_Debug_Tools::printr( $this->_template_args['countries'], 'countries <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
579 | 579 | |
580 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
581 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
582 | - $this->_template_args['country_details_settings'] = $this->display_country_settings(); |
|
583 | - $this->_template_args['country_states_settings'] = $this->display_country_states(); |
|
584 | - |
|
585 | - $this->_set_add_edit_form_tags('update_country_settings'); |
|
586 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
587 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
588 | - $this->_template_args, true); |
|
589 | - $this->display_admin_page_with_no_sidebar(); |
|
590 | - } |
|
591 | - |
|
592 | - |
|
593 | - /** |
|
594 | - * display_country_settings |
|
595 | - * |
|
596 | - * @access public |
|
597 | - * |
|
598 | - * @param string $CNT_ISO |
|
599 | - * |
|
600 | - * @return mixed string | array |
|
601 | - */ |
|
602 | - public function display_country_settings($CNT_ISO = '') |
|
603 | - { |
|
604 | - |
|
605 | - $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO; |
|
606 | - if ( ! $CNT_ISO) { |
|
607 | - return ''; |
|
608 | - } |
|
609 | - |
|
610 | - // for ajax |
|
611 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
612 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
613 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
614 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
615 | - $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
616 | - //EEH_Debug_Tools::printr( $country, '$country <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
617 | - $country_input_types = array( |
|
618 | - 'CNT_active' => array( |
|
619 | - 'type' => 'RADIO_BTN', |
|
620 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
621 | - 'class' => '', |
|
622 | - 'options' => $this->_yes_no_values, |
|
623 | - 'use_desc_4_label' => true |
|
624 | - ), |
|
625 | - 'CNT_ISO' => array( |
|
626 | - 'type' => 'TEXT', |
|
627 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
628 | - 'class' => 'small-text' |
|
629 | - ), |
|
630 | - 'CNT_ISO3' => array( |
|
631 | - 'type' => 'TEXT', |
|
632 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
633 | - 'class' => 'small-text' |
|
634 | - ), |
|
635 | - 'RGN_ID' => array( |
|
636 | - 'type' => 'TEXT', |
|
637 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
638 | - 'class' => 'small-text' |
|
639 | - ), |
|
640 | - 'CNT_name' => array( |
|
641 | - 'type' => 'TEXT', |
|
642 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
643 | - 'class' => 'regular-text' |
|
644 | - ), |
|
645 | - 'CNT_cur_code' => array( |
|
646 | - 'type' => 'TEXT', |
|
647 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
648 | - 'class' => 'small-text' |
|
649 | - ), |
|
650 | - 'CNT_cur_single' => array( |
|
651 | - 'type' => 'TEXT', |
|
652 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
653 | - 'class' => 'medium-text' |
|
654 | - ), |
|
655 | - 'CNT_cur_plural' => array( |
|
656 | - 'type' => 'TEXT', |
|
657 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
658 | - 'class' => 'medium-text' |
|
659 | - ), |
|
660 | - 'CNT_cur_sign' => array( |
|
661 | - 'type' => 'TEXT', |
|
662 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
663 | - 'class' => 'small-text', |
|
664 | - 'htmlentities' => false |
|
665 | - ), |
|
666 | - 'CNT_cur_sign_b4' => array( |
|
667 | - 'type' => 'RADIO_BTN', |
|
668 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
669 | - 'class' => '', |
|
670 | - 'options' => $this->_yes_no_values, |
|
671 | - 'use_desc_4_label' => true |
|
672 | - ), |
|
673 | - 'CNT_cur_dec_plc' => array( |
|
674 | - 'type' => 'RADIO_BTN', |
|
675 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
676 | - 'class' => '', |
|
677 | - 'options' => array( |
|
678 | - array('id' => 0, 'text' => ''), |
|
679 | - array('id' => 1, 'text' => ''), |
|
680 | - array('id' => 2, 'text' => ''), |
|
681 | - array('id' => 3, 'text' => '') |
|
682 | - ) |
|
683 | - ), |
|
684 | - 'CNT_cur_dec_mrk' => array( |
|
685 | - 'type' => 'RADIO_BTN', |
|
686 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
687 | - 'class' => '', |
|
688 | - 'options' => array( |
|
689 | - array( |
|
690 | - 'id' => ',', |
|
691 | - 'text' => __(', (comma)', 'event_espresso') |
|
692 | - ), |
|
693 | - array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')) |
|
694 | - ), |
|
695 | - 'use_desc_4_label' => true |
|
696 | - ), |
|
697 | - 'CNT_cur_thsnds' => array( |
|
698 | - 'type' => 'RADIO_BTN', |
|
699 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
700 | - 'class' => '', |
|
701 | - 'options' => array( |
|
702 | - array( |
|
703 | - 'id' => ',', |
|
704 | - 'text' => __(', (comma)', 'event_espresso') |
|
705 | - ), |
|
706 | - array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')) |
|
707 | - ), |
|
708 | - 'use_desc_4_label' => true |
|
709 | - ), |
|
710 | - 'CNT_tel_code' => array( |
|
711 | - 'type' => 'TEXT', |
|
712 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
713 | - 'class' => 'small-text' |
|
714 | - ), |
|
715 | - 'CNT_is_EU' => array( |
|
716 | - 'type' => 'RADIO_BTN', |
|
717 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
718 | - 'class' => '', |
|
719 | - 'options' => $this->_yes_no_values, |
|
720 | - 'use_desc_4_label' => true |
|
721 | - ) |
|
722 | - ); |
|
723 | - $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($country, |
|
724 | - $country_input_types); |
|
725 | - $country_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
726 | - $this->_template_args, true); |
|
727 | - |
|
728 | - if (defined('DOING_AJAX')) { |
|
729 | - $notices = EE_Error::get_notices(false, false, false); |
|
730 | - echo wp_json_encode(array( |
|
731 | - 'return_data' => $country_details_settings, |
|
732 | - 'success' => $notices['success'], |
|
733 | - 'errors' => $notices['errors'] |
|
734 | - )); |
|
735 | - die(); |
|
736 | - } else { |
|
737 | - return $country_details_settings; |
|
738 | - } |
|
739 | - |
|
740 | - } |
|
741 | - |
|
742 | - |
|
743 | - /** |
|
744 | - * display_country_states |
|
745 | - * |
|
746 | - * @access public |
|
747 | - * |
|
748 | - * @param string $CNT_ISO |
|
749 | - * |
|
750 | - * @return string |
|
751 | - */ |
|
752 | - public function display_country_states($CNT_ISO = '') |
|
753 | - { |
|
754 | - |
|
755 | - $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
|
756 | - |
|
757 | - if ( ! $CNT_ISO) { |
|
758 | - return ''; |
|
759 | - } |
|
760 | - // for ajax |
|
761 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
762 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
763 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); |
|
764 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); |
|
765 | - $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); |
|
580 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
581 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
582 | + $this->_template_args['country_details_settings'] = $this->display_country_settings(); |
|
583 | + $this->_template_args['country_states_settings'] = $this->display_country_states(); |
|
584 | + |
|
585 | + $this->_set_add_edit_form_tags('update_country_settings'); |
|
586 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
587 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
588 | + $this->_template_args, true); |
|
589 | + $this->display_admin_page_with_no_sidebar(); |
|
590 | + } |
|
591 | + |
|
592 | + |
|
593 | + /** |
|
594 | + * display_country_settings |
|
595 | + * |
|
596 | + * @access public |
|
597 | + * |
|
598 | + * @param string $CNT_ISO |
|
599 | + * |
|
600 | + * @return mixed string | array |
|
601 | + */ |
|
602 | + public function display_country_settings($CNT_ISO = '') |
|
603 | + { |
|
604 | + |
|
605 | + $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO; |
|
606 | + if ( ! $CNT_ISO) { |
|
607 | + return ''; |
|
608 | + } |
|
609 | + |
|
610 | + // for ajax |
|
611 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
612 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
613 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
614 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
615 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
616 | + //EEH_Debug_Tools::printr( $country, '$country <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
617 | + $country_input_types = array( |
|
618 | + 'CNT_active' => array( |
|
619 | + 'type' => 'RADIO_BTN', |
|
620 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
621 | + 'class' => '', |
|
622 | + 'options' => $this->_yes_no_values, |
|
623 | + 'use_desc_4_label' => true |
|
624 | + ), |
|
625 | + 'CNT_ISO' => array( |
|
626 | + 'type' => 'TEXT', |
|
627 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
628 | + 'class' => 'small-text' |
|
629 | + ), |
|
630 | + 'CNT_ISO3' => array( |
|
631 | + 'type' => 'TEXT', |
|
632 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
633 | + 'class' => 'small-text' |
|
634 | + ), |
|
635 | + 'RGN_ID' => array( |
|
636 | + 'type' => 'TEXT', |
|
637 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
638 | + 'class' => 'small-text' |
|
639 | + ), |
|
640 | + 'CNT_name' => array( |
|
641 | + 'type' => 'TEXT', |
|
642 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
643 | + 'class' => 'regular-text' |
|
644 | + ), |
|
645 | + 'CNT_cur_code' => array( |
|
646 | + 'type' => 'TEXT', |
|
647 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
648 | + 'class' => 'small-text' |
|
649 | + ), |
|
650 | + 'CNT_cur_single' => array( |
|
651 | + 'type' => 'TEXT', |
|
652 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
653 | + 'class' => 'medium-text' |
|
654 | + ), |
|
655 | + 'CNT_cur_plural' => array( |
|
656 | + 'type' => 'TEXT', |
|
657 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
658 | + 'class' => 'medium-text' |
|
659 | + ), |
|
660 | + 'CNT_cur_sign' => array( |
|
661 | + 'type' => 'TEXT', |
|
662 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
663 | + 'class' => 'small-text', |
|
664 | + 'htmlentities' => false |
|
665 | + ), |
|
666 | + 'CNT_cur_sign_b4' => array( |
|
667 | + 'type' => 'RADIO_BTN', |
|
668 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
669 | + 'class' => '', |
|
670 | + 'options' => $this->_yes_no_values, |
|
671 | + 'use_desc_4_label' => true |
|
672 | + ), |
|
673 | + 'CNT_cur_dec_plc' => array( |
|
674 | + 'type' => 'RADIO_BTN', |
|
675 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
676 | + 'class' => '', |
|
677 | + 'options' => array( |
|
678 | + array('id' => 0, 'text' => ''), |
|
679 | + array('id' => 1, 'text' => ''), |
|
680 | + array('id' => 2, 'text' => ''), |
|
681 | + array('id' => 3, 'text' => '') |
|
682 | + ) |
|
683 | + ), |
|
684 | + 'CNT_cur_dec_mrk' => array( |
|
685 | + 'type' => 'RADIO_BTN', |
|
686 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
687 | + 'class' => '', |
|
688 | + 'options' => array( |
|
689 | + array( |
|
690 | + 'id' => ',', |
|
691 | + 'text' => __(', (comma)', 'event_espresso') |
|
692 | + ), |
|
693 | + array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')) |
|
694 | + ), |
|
695 | + 'use_desc_4_label' => true |
|
696 | + ), |
|
697 | + 'CNT_cur_thsnds' => array( |
|
698 | + 'type' => 'RADIO_BTN', |
|
699 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
700 | + 'class' => '', |
|
701 | + 'options' => array( |
|
702 | + array( |
|
703 | + 'id' => ',', |
|
704 | + 'text' => __(', (comma)', 'event_espresso') |
|
705 | + ), |
|
706 | + array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')) |
|
707 | + ), |
|
708 | + 'use_desc_4_label' => true |
|
709 | + ), |
|
710 | + 'CNT_tel_code' => array( |
|
711 | + 'type' => 'TEXT', |
|
712 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
713 | + 'class' => 'small-text' |
|
714 | + ), |
|
715 | + 'CNT_is_EU' => array( |
|
716 | + 'type' => 'RADIO_BTN', |
|
717 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
718 | + 'class' => '', |
|
719 | + 'options' => $this->_yes_no_values, |
|
720 | + 'use_desc_4_label' => true |
|
721 | + ) |
|
722 | + ); |
|
723 | + $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($country, |
|
724 | + $country_input_types); |
|
725 | + $country_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
726 | + $this->_template_args, true); |
|
727 | + |
|
728 | + if (defined('DOING_AJAX')) { |
|
729 | + $notices = EE_Error::get_notices(false, false, false); |
|
730 | + echo wp_json_encode(array( |
|
731 | + 'return_data' => $country_details_settings, |
|
732 | + 'success' => $notices['success'], |
|
733 | + 'errors' => $notices['errors'] |
|
734 | + )); |
|
735 | + die(); |
|
736 | + } else { |
|
737 | + return $country_details_settings; |
|
738 | + } |
|
739 | + |
|
740 | + } |
|
741 | + |
|
742 | + |
|
743 | + /** |
|
744 | + * display_country_states |
|
745 | + * |
|
746 | + * @access public |
|
747 | + * |
|
748 | + * @param string $CNT_ISO |
|
749 | + * |
|
750 | + * @return string |
|
751 | + */ |
|
752 | + public function display_country_states($CNT_ISO = '') |
|
753 | + { |
|
754 | + |
|
755 | + $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
|
756 | + |
|
757 | + if ( ! $CNT_ISO) { |
|
758 | + return ''; |
|
759 | + } |
|
760 | + // for ajax |
|
761 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
762 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
763 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); |
|
764 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); |
|
765 | + $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); |
|
766 | 766 | |
767 | 767 | // echo '<h4>$CNT_ISO : ' . $CNT_ISO . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
768 | 768 | // global $wpdb; |
769 | 769 | // echo '<h4>' . $wpdb->last_query . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
770 | 770 | // EEH_Debug_Tools::printr( $states, '$states <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
771 | - if ($states) { |
|
772 | - foreach ($states as $STA_ID => $state) { |
|
773 | - if ($state instanceof EE_State) { |
|
774 | - //STA_abbrev STA_name STA_active |
|
775 | - $state_input_types = array( |
|
776 | - 'STA_abbrev' => array( |
|
777 | - 'type' => 'TEXT', |
|
778 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
779 | - 'class' => 'mid-text' |
|
780 | - ), |
|
781 | - 'STA_name' => array( |
|
782 | - 'type' => 'TEXT', |
|
783 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
784 | - 'class' => 'regular-text' |
|
785 | - ), |
|
786 | - 'STA_active' => array( |
|
787 | - 'type' => 'RADIO_BTN', |
|
788 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
789 | - 'options' => $this->_yes_no_values, |
|
790 | - 'use_desc_4_label' => true |
|
791 | - ) |
|
792 | - ); |
|
793 | - $this->_template_args['states'][$STA_ID]['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($state, |
|
794 | - $state_input_types); |
|
795 | - $query_args = array( |
|
796 | - 'action' => 'delete_state', |
|
797 | - 'STA_ID' => $STA_ID, |
|
798 | - 'CNT_ISO' => $CNT_ISO, |
|
799 | - 'STA_abbrev' => $state->abbrev() |
|
800 | - ); |
|
801 | - $this->_template_args['states'][$STA_ID]['delete_state_url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, |
|
802 | - GEN_SET_ADMIN_URL); |
|
803 | - } |
|
804 | - } |
|
805 | - } else { |
|
806 | - $this->_template_args['states'] = false; |
|
807 | - } |
|
771 | + if ($states) { |
|
772 | + foreach ($states as $STA_ID => $state) { |
|
773 | + if ($state instanceof EE_State) { |
|
774 | + //STA_abbrev STA_name STA_active |
|
775 | + $state_input_types = array( |
|
776 | + 'STA_abbrev' => array( |
|
777 | + 'type' => 'TEXT', |
|
778 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
779 | + 'class' => 'mid-text' |
|
780 | + ), |
|
781 | + 'STA_name' => array( |
|
782 | + 'type' => 'TEXT', |
|
783 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
784 | + 'class' => 'regular-text' |
|
785 | + ), |
|
786 | + 'STA_active' => array( |
|
787 | + 'type' => 'RADIO_BTN', |
|
788 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
789 | + 'options' => $this->_yes_no_values, |
|
790 | + 'use_desc_4_label' => true |
|
791 | + ) |
|
792 | + ); |
|
793 | + $this->_template_args['states'][$STA_ID]['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($state, |
|
794 | + $state_input_types); |
|
795 | + $query_args = array( |
|
796 | + 'action' => 'delete_state', |
|
797 | + 'STA_ID' => $STA_ID, |
|
798 | + 'CNT_ISO' => $CNT_ISO, |
|
799 | + 'STA_abbrev' => $state->abbrev() |
|
800 | + ); |
|
801 | + $this->_template_args['states'][$STA_ID]['delete_state_url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, |
|
802 | + GEN_SET_ADMIN_URL); |
|
803 | + } |
|
804 | + } |
|
805 | + } else { |
|
806 | + $this->_template_args['states'] = false; |
|
807 | + } |
|
808 | 808 | // EEH_Debug_Tools::printr( $this->_template_args['states'], 'states <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
809 | - $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'add_new_state'), |
|
810 | - GEN_SET_ADMIN_URL); |
|
811 | - |
|
812 | - $state_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
813 | - $this->_template_args, true); |
|
814 | - |
|
815 | - if (defined('DOING_AJAX')) { |
|
816 | - $notices = EE_Error::get_notices(false, false, false); |
|
817 | - echo wp_json_encode(array( |
|
818 | - 'return_data' => $state_details_settings, |
|
819 | - 'success' => $notices['success'], |
|
820 | - 'errors' => $notices['errors'] |
|
821 | - )); |
|
822 | - die(); |
|
823 | - } else { |
|
824 | - return $state_details_settings; |
|
825 | - } |
|
826 | - |
|
827 | - } |
|
828 | - |
|
829 | - |
|
830 | - /** |
|
831 | - * add_new_state |
|
832 | - * |
|
833 | - * @access public |
|
834 | - * @return void |
|
835 | - */ |
|
836 | - public function add_new_state() |
|
837 | - { |
|
838 | - |
|
839 | - $success = true; |
|
840 | - |
|
841 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : false; |
|
842 | - if ( ! $CNT_ISO) { |
|
843 | - EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', |
|
844 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
845 | - $success = false; |
|
846 | - } |
|
847 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : false; |
|
848 | - if ( ! $STA_abbrev) { |
|
849 | - EE_Error::add_error(__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
850 | - __FILE__, __FUNCTION__, __LINE__); |
|
851 | - $success = false; |
|
852 | - } |
|
853 | - $STA_name = isset($this->_req_data['STA_name']) ? sanitize_text_field($this->_req_data['STA_name']) : |
|
854 | - false; |
|
855 | - if ( ! $STA_name) { |
|
856 | - EE_Error::add_error(__('No State name or an invalid State name was received.', 'event_espresso'), __FILE__, |
|
857 | - __FUNCTION__, __LINE__); |
|
858 | - $success = false; |
|
859 | - } |
|
860 | - |
|
861 | - if ($success) { |
|
862 | - $cols_n_values = array( |
|
863 | - 'CNT_ISO' => $CNT_ISO, |
|
864 | - 'STA_abbrev' => $STA_abbrev, |
|
865 | - 'STA_name' => $STA_name, |
|
866 | - 'STA_active' => true |
|
867 | - ); |
|
868 | - $success = EEM_State::instance()->insert($cols_n_values); |
|
869 | - EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
|
870 | - } |
|
871 | - |
|
872 | - if (defined('DOING_AJAX')) { |
|
873 | - $notices = EE_Error::get_notices(false, false, false); |
|
874 | - echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO))); |
|
875 | - die(); |
|
876 | - } else { |
|
877 | - $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings')); |
|
878 | - } |
|
879 | - } |
|
880 | - |
|
881 | - |
|
882 | - /** |
|
883 | - * delete_state |
|
884 | - * |
|
885 | - * @access public |
|
886 | - * @return boolean | void |
|
887 | - */ |
|
888 | - public function delete_state() |
|
889 | - { |
|
890 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : false; |
|
891 | - $STA_ID = isset($this->_req_data['STA_ID']) ? sanitize_text_field($this->_req_data['STA_ID']) : false; |
|
892 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : false; |
|
893 | - if ( ! $STA_ID) { |
|
894 | - EE_Error::add_error(__('No State ID or an invalid State ID was received.', 'event_espresso'), __FILE__, |
|
895 | - __FUNCTION__, __LINE__); |
|
896 | - |
|
897 | - return false; |
|
898 | - } |
|
899 | - $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
900 | - if ($success !== false) { |
|
901 | - do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID, |
|
902 | - array('STA_abbrev' => $STA_abbrev)); |
|
903 | - EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso')); |
|
904 | - } |
|
905 | - if (defined('DOING_AJAX')) { |
|
906 | - $notices = EE_Error::get_notices(false, false); |
|
907 | - $notices['return_data'] = true; |
|
908 | - echo wp_json_encode($notices); |
|
909 | - die(); |
|
910 | - } else { |
|
911 | - $this->_redirect_after_action($success, 'State', 'deleted', array('action' => 'country_settings')); |
|
912 | - } |
|
913 | - } |
|
914 | - |
|
915 | - |
|
916 | - /** |
|
917 | - * _update_country_settings |
|
918 | - * |
|
919 | - * @access protected |
|
920 | - * @return void |
|
921 | - */ |
|
922 | - protected function _update_country_settings() |
|
923 | - { |
|
809 | + $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'add_new_state'), |
|
810 | + GEN_SET_ADMIN_URL); |
|
811 | + |
|
812 | + $state_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
813 | + $this->_template_args, true); |
|
814 | + |
|
815 | + if (defined('DOING_AJAX')) { |
|
816 | + $notices = EE_Error::get_notices(false, false, false); |
|
817 | + echo wp_json_encode(array( |
|
818 | + 'return_data' => $state_details_settings, |
|
819 | + 'success' => $notices['success'], |
|
820 | + 'errors' => $notices['errors'] |
|
821 | + )); |
|
822 | + die(); |
|
823 | + } else { |
|
824 | + return $state_details_settings; |
|
825 | + } |
|
826 | + |
|
827 | + } |
|
828 | + |
|
829 | + |
|
830 | + /** |
|
831 | + * add_new_state |
|
832 | + * |
|
833 | + * @access public |
|
834 | + * @return void |
|
835 | + */ |
|
836 | + public function add_new_state() |
|
837 | + { |
|
838 | + |
|
839 | + $success = true; |
|
840 | + |
|
841 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : false; |
|
842 | + if ( ! $CNT_ISO) { |
|
843 | + EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', |
|
844 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
845 | + $success = false; |
|
846 | + } |
|
847 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : false; |
|
848 | + if ( ! $STA_abbrev) { |
|
849 | + EE_Error::add_error(__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
850 | + __FILE__, __FUNCTION__, __LINE__); |
|
851 | + $success = false; |
|
852 | + } |
|
853 | + $STA_name = isset($this->_req_data['STA_name']) ? sanitize_text_field($this->_req_data['STA_name']) : |
|
854 | + false; |
|
855 | + if ( ! $STA_name) { |
|
856 | + EE_Error::add_error(__('No State name or an invalid State name was received.', 'event_espresso'), __FILE__, |
|
857 | + __FUNCTION__, __LINE__); |
|
858 | + $success = false; |
|
859 | + } |
|
860 | + |
|
861 | + if ($success) { |
|
862 | + $cols_n_values = array( |
|
863 | + 'CNT_ISO' => $CNT_ISO, |
|
864 | + 'STA_abbrev' => $STA_abbrev, |
|
865 | + 'STA_name' => $STA_name, |
|
866 | + 'STA_active' => true |
|
867 | + ); |
|
868 | + $success = EEM_State::instance()->insert($cols_n_values); |
|
869 | + EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
|
870 | + } |
|
871 | + |
|
872 | + if (defined('DOING_AJAX')) { |
|
873 | + $notices = EE_Error::get_notices(false, false, false); |
|
874 | + echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO))); |
|
875 | + die(); |
|
876 | + } else { |
|
877 | + $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings')); |
|
878 | + } |
|
879 | + } |
|
880 | + |
|
881 | + |
|
882 | + /** |
|
883 | + * delete_state |
|
884 | + * |
|
885 | + * @access public |
|
886 | + * @return boolean | void |
|
887 | + */ |
|
888 | + public function delete_state() |
|
889 | + { |
|
890 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : false; |
|
891 | + $STA_ID = isset($this->_req_data['STA_ID']) ? sanitize_text_field($this->_req_data['STA_ID']) : false; |
|
892 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : false; |
|
893 | + if ( ! $STA_ID) { |
|
894 | + EE_Error::add_error(__('No State ID or an invalid State ID was received.', 'event_espresso'), __FILE__, |
|
895 | + __FUNCTION__, __LINE__); |
|
896 | + |
|
897 | + return false; |
|
898 | + } |
|
899 | + $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
900 | + if ($success !== false) { |
|
901 | + do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID, |
|
902 | + array('STA_abbrev' => $STA_abbrev)); |
|
903 | + EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso')); |
|
904 | + } |
|
905 | + if (defined('DOING_AJAX')) { |
|
906 | + $notices = EE_Error::get_notices(false, false); |
|
907 | + $notices['return_data'] = true; |
|
908 | + echo wp_json_encode($notices); |
|
909 | + die(); |
|
910 | + } else { |
|
911 | + $this->_redirect_after_action($success, 'State', 'deleted', array('action' => 'country_settings')); |
|
912 | + } |
|
913 | + } |
|
914 | + |
|
915 | + |
|
916 | + /** |
|
917 | + * _update_country_settings |
|
918 | + * |
|
919 | + * @access protected |
|
920 | + * @return void |
|
921 | + */ |
|
922 | + protected function _update_country_settings() |
|
923 | + { |
|
924 | 924 | // EEH_Debug_Tools::printr( $this->_req_data, '$this->_req_data <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
925 | - // grab the country ISO code |
|
926 | - $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : false; |
|
927 | - if ( ! $CNT_ISO) { |
|
928 | - EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', |
|
929 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
930 | - |
|
931 | - return; |
|
932 | - } |
|
933 | - $cols_n_values = array(); |
|
934 | - $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) : false; |
|
935 | - $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) : null; |
|
936 | - $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) : null; |
|
937 | - $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) : 'USD'; |
|
938 | - $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) : 'dollar'; |
|
939 | - $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) : 'dollars'; |
|
940 | - $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) : '$'; |
|
941 | - $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) : true; |
|
942 | - $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) : 2; |
|
943 | - $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) : '.'; |
|
944 | - $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) : ','; |
|
945 | - $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) : null; |
|
946 | - $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) : false; |
|
947 | - $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) : false; |
|
948 | - // allow filtering of country data |
|
949 | - $cols_n_values = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
950 | - $cols_n_values); |
|
951 | - //EEH_Debug_Tools::printr( $cols_n_values, '$cols_n_values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
952 | - // where values |
|
953 | - $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO)); |
|
954 | - // run the update |
|
955 | - $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
925 | + // grab the country ISO code |
|
926 | + $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : false; |
|
927 | + if ( ! $CNT_ISO) { |
|
928 | + EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', |
|
929 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
930 | + |
|
931 | + return; |
|
932 | + } |
|
933 | + $cols_n_values = array(); |
|
934 | + $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) : false; |
|
935 | + $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) : null; |
|
936 | + $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) : null; |
|
937 | + $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) : 'USD'; |
|
938 | + $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) : 'dollar'; |
|
939 | + $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) : 'dollars'; |
|
940 | + $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) : '$'; |
|
941 | + $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) : true; |
|
942 | + $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) : 2; |
|
943 | + $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) : '.'; |
|
944 | + $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) : ','; |
|
945 | + $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) : null; |
|
946 | + $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) : false; |
|
947 | + $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) : false; |
|
948 | + // allow filtering of country data |
|
949 | + $cols_n_values = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
950 | + $cols_n_values); |
|
951 | + //EEH_Debug_Tools::printr( $cols_n_values, '$cols_n_values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
952 | + // where values |
|
953 | + $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO)); |
|
954 | + // run the update |
|
955 | + $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
956 | 956 | // global $wpdb; |
957 | 957 | // echo '<h4>' . $wpdb->last_query . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
958 | 958 | // echo '<h4>$success : ' . $success . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
959 | - if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
960 | - // allow filtering of states data |
|
961 | - $states = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
962 | - $this->_req_data['states']); |
|
959 | + if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
960 | + // allow filtering of states data |
|
961 | + $states = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
962 | + $this->_req_data['states']); |
|
963 | 963 | // EEH_Debug_Tools::printr( $states, '$states <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
964 | - // loop thru state data ( looks like : states[75][STA_name] ) |
|
965 | - foreach ($states as $STA_ID => $state) { |
|
966 | - $cols_n_values = array( |
|
967 | - 'CNT_ISO' => $CNT_ISO, |
|
968 | - 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
969 | - 'STA_name' => sanitize_text_field($state['STA_name']), |
|
970 | - 'STA_active' => (bool)absint($state['STA_active']) |
|
971 | - ); |
|
972 | - // where values |
|
973 | - $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
974 | - // run the update |
|
975 | - $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
976 | - if ($success !== false) { |
|
977 | - do_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO, |
|
978 | - $STA_ID, $cols_n_values); |
|
979 | - } |
|
980 | - } |
|
981 | - } |
|
982 | - // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
983 | - if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO) { |
|
984 | - EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
985 | - EE_Registry::instance()->CFG->update_espresso_config(); |
|
986 | - } |
|
987 | - $this->_redirect_after_action($success, 'Countries', 'updated', |
|
988 | - array('action' => 'country_settings', 'country' => $CNT_ISO)); |
|
989 | - } |
|
990 | - |
|
991 | - |
|
992 | - /** |
|
993 | - * form_form_field_label_wrap |
|
994 | - * |
|
995 | - * @access public |
|
996 | - * |
|
997 | - * @param string $label |
|
998 | - * |
|
999 | - * @return string |
|
1000 | - */ |
|
1001 | - public function country_form_field_label_wrap($label, $required_text) |
|
1002 | - { |
|
1003 | - return ' |
|
964 | + // loop thru state data ( looks like : states[75][STA_name] ) |
|
965 | + foreach ($states as $STA_ID => $state) { |
|
966 | + $cols_n_values = array( |
|
967 | + 'CNT_ISO' => $CNT_ISO, |
|
968 | + 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
969 | + 'STA_name' => sanitize_text_field($state['STA_name']), |
|
970 | + 'STA_active' => (bool)absint($state['STA_active']) |
|
971 | + ); |
|
972 | + // where values |
|
973 | + $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
974 | + // run the update |
|
975 | + $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
976 | + if ($success !== false) { |
|
977 | + do_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO, |
|
978 | + $STA_ID, $cols_n_values); |
|
979 | + } |
|
980 | + } |
|
981 | + } |
|
982 | + // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
983 | + if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO) { |
|
984 | + EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
985 | + EE_Registry::instance()->CFG->update_espresso_config(); |
|
986 | + } |
|
987 | + $this->_redirect_after_action($success, 'Countries', 'updated', |
|
988 | + array('action' => 'country_settings', 'country' => $CNT_ISO)); |
|
989 | + } |
|
990 | + |
|
991 | + |
|
992 | + /** |
|
993 | + * form_form_field_label_wrap |
|
994 | + * |
|
995 | + * @access public |
|
996 | + * |
|
997 | + * @param string $label |
|
998 | + * |
|
999 | + * @return string |
|
1000 | + */ |
|
1001 | + public function country_form_field_label_wrap($label, $required_text) |
|
1002 | + { |
|
1003 | + return ' |
|
1004 | 1004 | <tr> |
1005 | 1005 | <th> |
1006 | 1006 | ' . $label . ' |
1007 | 1007 | </th>'; |
1008 | - } |
|
1009 | - |
|
1010 | - |
|
1011 | - /** |
|
1012 | - * form_form_field_input__wrap |
|
1013 | - * |
|
1014 | - * @access public |
|
1015 | - * |
|
1016 | - * @param string $label |
|
1017 | - * |
|
1018 | - * @return string |
|
1019 | - */ |
|
1020 | - public function country_form_field_input__wrap($input, $label) |
|
1021 | - { |
|
1022 | - return ' |
|
1008 | + } |
|
1009 | + |
|
1010 | + |
|
1011 | + /** |
|
1012 | + * form_form_field_input__wrap |
|
1013 | + * |
|
1014 | + * @access public |
|
1015 | + * |
|
1016 | + * @param string $label |
|
1017 | + * |
|
1018 | + * @return string |
|
1019 | + */ |
|
1020 | + public function country_form_field_input__wrap($input, $label) |
|
1021 | + { |
|
1022 | + return ' |
|
1023 | 1023 | <td class="general-settings-country-input-td"> |
1024 | 1024 | ' . $input . ' |
1025 | 1025 | </td> |
1026 | 1026 | </tr>'; |
1027 | - } |
|
1028 | - |
|
1029 | - |
|
1030 | - /** |
|
1031 | - * form_form_field_label_wrap |
|
1032 | - * |
|
1033 | - * @access public |
|
1034 | - * |
|
1035 | - * @param string $label |
|
1036 | - * @param string $required_text |
|
1037 | - * |
|
1038 | - * @return string |
|
1039 | - */ |
|
1040 | - public function state_form_field_label_wrap($label, $required_text) |
|
1041 | - { |
|
1042 | - return $required_text; |
|
1043 | - } |
|
1044 | - |
|
1045 | - |
|
1046 | - /** |
|
1047 | - * form_form_field_input__wrap |
|
1048 | - * |
|
1049 | - * @access public |
|
1050 | - * |
|
1051 | - * @param string $label |
|
1052 | - * |
|
1053 | - * @return string |
|
1054 | - */ |
|
1055 | - public function state_form_field_input__wrap($input, $label) |
|
1056 | - { |
|
1057 | - return ' |
|
1027 | + } |
|
1028 | + |
|
1029 | + |
|
1030 | + /** |
|
1031 | + * form_form_field_label_wrap |
|
1032 | + * |
|
1033 | + * @access public |
|
1034 | + * |
|
1035 | + * @param string $label |
|
1036 | + * @param string $required_text |
|
1037 | + * |
|
1038 | + * @return string |
|
1039 | + */ |
|
1040 | + public function state_form_field_label_wrap($label, $required_text) |
|
1041 | + { |
|
1042 | + return $required_text; |
|
1043 | + } |
|
1044 | + |
|
1045 | + |
|
1046 | + /** |
|
1047 | + * form_form_field_input__wrap |
|
1048 | + * |
|
1049 | + * @access public |
|
1050 | + * |
|
1051 | + * @param string $label |
|
1052 | + * |
|
1053 | + * @return string |
|
1054 | + */ |
|
1055 | + public function state_form_field_input__wrap($input, $label) |
|
1056 | + { |
|
1057 | + return ' |
|
1058 | 1058 | <td class="general-settings-country-state-input-td"> |
1059 | 1059 | ' . $input . ' |
1060 | 1060 | </td>'; |
1061 | 1061 | |
1062 | - } |
|
1063 | - |
|
1064 | - |
|
1065 | - |
|
1066 | - |
|
1067 | - |
|
1068 | - |
|
1069 | - /***********/ |
|
1070 | - |
|
1071 | - |
|
1072 | - /** |
|
1073 | - * displays edit and view links for critical EE pages |
|
1074 | - * |
|
1075 | - * @access public |
|
1076 | - * |
|
1077 | - * @param int $ee_page_id |
|
1078 | - * |
|
1079 | - * @return string |
|
1080 | - */ |
|
1081 | - public static function edit_view_links($ee_page_id) |
|
1082 | - { |
|
1083 | - $links = '<a href="' . add_query_arg(array('post' => $ee_page_id, 'action' => 'edit'), |
|
1084 | - admin_url('post.php')) . '" >' . __('Edit', 'event_espresso') . '</a>'; |
|
1085 | - $links .= ' | '; |
|
1086 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1087 | - |
|
1088 | - return $links; |
|
1089 | - } |
|
1090 | - |
|
1091 | - |
|
1092 | - /** |
|
1093 | - * displays page and shortcode status for critical EE pages |
|
1094 | - * |
|
1095 | - * @param WP page object $ee_page |
|
1096 | - * |
|
1097 | - * @return string |
|
1098 | - */ |
|
1099 | - public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1100 | - { |
|
1101 | - |
|
1102 | - // page status |
|
1103 | - if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1104 | - $pg_colour = 'green'; |
|
1105 | - $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1106 | - } else { |
|
1107 | - $pg_colour = 'red'; |
|
1108 | - $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1109 | - } |
|
1110 | - |
|
1111 | - // shortcode status |
|
1112 | - if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1113 | - $sc_colour = 'green'; |
|
1114 | - $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1115 | - } else { |
|
1116 | - $sc_colour = 'red'; |
|
1117 | - $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1118 | - } |
|
1119 | - |
|
1120 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' . $pg_status . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1121 | - |
|
1122 | - } |
|
1123 | - |
|
1124 | - |
|
1125 | - /** |
|
1126 | - * generates a dropdown of all parent pages - copied from WP core |
|
1127 | - * |
|
1128 | - * @param unknown_type $default |
|
1129 | - * @param unknown_type $parent |
|
1130 | - * @param unknown_type $level |
|
1131 | - * |
|
1132 | - * @return unknown |
|
1133 | - */ |
|
1134 | - public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) |
|
1135 | - { |
|
1136 | - global $wpdb; |
|
1137 | - $items = $wpdb->get_results($wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", |
|
1138 | - $parent)); |
|
1139 | - |
|
1140 | - if ($items) { |
|
1141 | - foreach ($items as $item) { |
|
1142 | - $pad = str_repeat(' ', $level * 3); |
|
1143 | - if ($item->ID == $default) { |
|
1144 | - $current = ' selected="selected"'; |
|
1145 | - } else { |
|
1146 | - $current = ''; |
|
1147 | - } |
|
1148 | - |
|
1149 | - echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>"; |
|
1150 | - parent_dropdown($default, $item->ID, $level + 1); |
|
1151 | - } |
|
1152 | - } else { |
|
1153 | - return false; |
|
1154 | - } |
|
1155 | - } |
|
1062 | + } |
|
1063 | + |
|
1064 | + |
|
1065 | + |
|
1066 | + |
|
1067 | + |
|
1068 | + |
|
1069 | + /***********/ |
|
1070 | + |
|
1071 | + |
|
1072 | + /** |
|
1073 | + * displays edit and view links for critical EE pages |
|
1074 | + * |
|
1075 | + * @access public |
|
1076 | + * |
|
1077 | + * @param int $ee_page_id |
|
1078 | + * |
|
1079 | + * @return string |
|
1080 | + */ |
|
1081 | + public static function edit_view_links($ee_page_id) |
|
1082 | + { |
|
1083 | + $links = '<a href="' . add_query_arg(array('post' => $ee_page_id, 'action' => 'edit'), |
|
1084 | + admin_url('post.php')) . '" >' . __('Edit', 'event_espresso') . '</a>'; |
|
1085 | + $links .= ' | '; |
|
1086 | + $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1087 | + |
|
1088 | + return $links; |
|
1089 | + } |
|
1090 | + |
|
1091 | + |
|
1092 | + /** |
|
1093 | + * displays page and shortcode status for critical EE pages |
|
1094 | + * |
|
1095 | + * @param WP page object $ee_page |
|
1096 | + * |
|
1097 | + * @return string |
|
1098 | + */ |
|
1099 | + public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1100 | + { |
|
1101 | + |
|
1102 | + // page status |
|
1103 | + if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1104 | + $pg_colour = 'green'; |
|
1105 | + $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1106 | + } else { |
|
1107 | + $pg_colour = 'red'; |
|
1108 | + $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1109 | + } |
|
1110 | + |
|
1111 | + // shortcode status |
|
1112 | + if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1113 | + $sc_colour = 'green'; |
|
1114 | + $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1115 | + } else { |
|
1116 | + $sc_colour = 'red'; |
|
1117 | + $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1118 | + } |
|
1119 | + |
|
1120 | + return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' . $pg_status . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1121 | + |
|
1122 | + } |
|
1123 | + |
|
1124 | + |
|
1125 | + /** |
|
1126 | + * generates a dropdown of all parent pages - copied from WP core |
|
1127 | + * |
|
1128 | + * @param unknown_type $default |
|
1129 | + * @param unknown_type $parent |
|
1130 | + * @param unknown_type $level |
|
1131 | + * |
|
1132 | + * @return unknown |
|
1133 | + */ |
|
1134 | + public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) |
|
1135 | + { |
|
1136 | + global $wpdb; |
|
1137 | + $items = $wpdb->get_results($wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", |
|
1138 | + $parent)); |
|
1139 | + |
|
1140 | + if ($items) { |
|
1141 | + foreach ($items as $item) { |
|
1142 | + $pad = str_repeat(' ', $level * 3); |
|
1143 | + if ($item->ID == $default) { |
|
1144 | + $current = ' selected="selected"'; |
|
1145 | + } else { |
|
1146 | + $current = ''; |
|
1147 | + } |
|
1148 | + |
|
1149 | + echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>"; |
|
1150 | + parent_dropdown($default, $item->ID, $level + 1); |
|
1151 | + } |
|
1152 | + } else { |
|
1153 | + return false; |
|
1154 | + } |
|
1155 | + } |
|
1156 | 1156 | |
1157 | 1157 | |
1158 | 1158 | } //ends Forms_Admin_Page class |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | { |
183 | 183 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
184 | 184 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
185 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
185 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
186 | 186 | //load and setup EE_Capabilities |
187 | 187 | $this->registry->load_core('Capabilities'); |
188 | 188 | //caps need to be initialized on every request so that capability maps are set. |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | && $_GET['activate'] === 'true' |
206 | 206 | ) |
207 | 207 | ) { |
208 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
208 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
209 | 209 | } |
210 | 210 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
211 | 211 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | private function _parse_model_names() |
688 | 688 | { |
689 | 689 | //get all the files in the EE_MODELS folder that end in .model.php |
690 | - $models = glob(EE_MODELS . '*.model.php'); |
|
690 | + $models = glob(EE_MODELS.'*.model.php'); |
|
691 | 691 | $model_names = array(); |
692 | 692 | $non_abstract_db_models = array(); |
693 | 693 | foreach ($models as $model) { |
@@ -715,8 +715,8 @@ discard block |
||
715 | 715 | */ |
716 | 716 | private function _maybe_brew_regular() |
717 | 717 | { |
718 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
719 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
718 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
719 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
720 | 720 | } |
721 | 721 | } |
722 | 722 | |
@@ -757,8 +757,8 @@ discard block |
||
757 | 757 | 'event_espresso'); |
758 | 758 | $msg .= '<ul>'; |
759 | 759 | foreach ($class_names as $class_name) { |
760 | - $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
761 | - $class_name) . '</b></li>'; |
|
760 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
761 | + $class_name).'</b></li>'; |
|
762 | 762 | } |
763 | 763 | $msg .= '</ul>'; |
764 | 764 | $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
@@ -910,8 +910,8 @@ discard block |
||
910 | 910 | { |
911 | 911 | do_action('AHEE__EE_System__core_loaded_and_ready'); |
912 | 912 | // load_espresso_template_tags |
913 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
914 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
913 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
914 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
915 | 915 | } |
916 | 916 | do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
917 | 917 | $this->registry->load_core('Session'); |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | 'href' => $events_admin_url, |
1057 | 1057 | 'meta' => array( |
1058 | 1058 | 'title' => __('Event Espresso', 'event_espresso'), |
1059 | - 'class' => $menu_class . 'first', |
|
1059 | + 'class' => $menu_class.'first', |
|
1060 | 1060 | ), |
1061 | 1061 | )); |
1062 | 1062 | //Events |
@@ -1433,10 +1433,10 @@ discard block |
||
1433 | 1433 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1434 | 1434 | if (apply_filters('FHEE_load_jquery_validate', false)) { |
1435 | 1435 | // register jQuery Validate and additional methods |
1436 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1436 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
1437 | 1437 | array('jquery'), '1.15.0', true); |
1438 | 1438 | wp_register_script('jquery-validate-extra-methods', |
1439 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1439 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
1440 | 1440 | array('jquery', 'jquery-validate'), '1.15.0', true); |
1441 | 1441 | } |
1442 | 1442 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\services\shortcodes\ShortcodesManager; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -19,1440 +19,1440 @@ discard block |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
24 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
25 | - */ |
|
26 | - const req_type_normal = 0; |
|
27 | - |
|
28 | - /** |
|
29 | - * Indicates this is a brand new installation of EE so we should install |
|
30 | - * tables and default data etc |
|
31 | - */ |
|
32 | - const req_type_new_activation = 1; |
|
33 | - |
|
34 | - /** |
|
35 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
36 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
37 | - * and that default data is setup too |
|
38 | - */ |
|
39 | - const req_type_reactivation = 2; |
|
40 | - |
|
41 | - /** |
|
42 | - * indicates that EE has been upgraded since its previous request. |
|
43 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
44 | - */ |
|
45 | - const req_type_upgrade = 3; |
|
46 | - |
|
47 | - /** |
|
48 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
49 | - */ |
|
50 | - const req_type_downgrade = 4; |
|
51 | - |
|
52 | - /** |
|
53 | - * @deprecated since version 4.6.0.dev.006 |
|
54 | - * Now whenever a new_activation is detected the request type is still just |
|
55 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
56 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
57 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
58 | - * (Specifically, when the migration manager indicates migrations are finished |
|
59 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
60 | - */ |
|
61 | - const req_type_activation_but_not_installed = 5; |
|
62 | - |
|
63 | - /** |
|
64 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
65 | - */ |
|
66 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * instance of the EE_System object |
|
71 | - * |
|
72 | - * @var $_instance |
|
73 | - * @access private |
|
74 | - */ |
|
75 | - private static $_instance = null; |
|
76 | - |
|
77 | - /** |
|
78 | - * @type EE_Registry $Registry |
|
79 | - * @access protected |
|
80 | - */ |
|
81 | - protected $registry; |
|
82 | - |
|
83 | - /** |
|
84 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
85 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
86 | - * |
|
87 | - * @var int |
|
88 | - */ |
|
89 | - private $_req_type; |
|
90 | - |
|
91 | - /** |
|
92 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
93 | - * |
|
94 | - * @var boolean |
|
95 | - */ |
|
96 | - private $_major_version_change = false; |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @singleton method used to instantiate class object |
|
102 | - * @access public |
|
103 | - * @param \EE_Registry $Registry |
|
104 | - * @return \EE_System |
|
105 | - */ |
|
106 | - public static function instance(EE_Registry $Registry = null) |
|
107 | - { |
|
108 | - // check if class object is instantiated |
|
109 | - if ( ! self::$_instance instanceof EE_System) { |
|
110 | - self::$_instance = new self($Registry); |
|
111 | - } |
|
112 | - return self::$_instance; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * resets the instance and returns it |
|
119 | - * |
|
120 | - * @return EE_System |
|
121 | - */ |
|
122 | - public static function reset() |
|
123 | - { |
|
124 | - self::$_instance->_req_type = null; |
|
125 | - //make sure none of the old hooks are left hanging around |
|
126 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
127 | - //we need to reset the migration manager in order for it to detect DMSs properly |
|
128 | - EE_Data_Migration_Manager::reset(); |
|
129 | - self::instance()->detect_activations_or_upgrades(); |
|
130 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
131 | - return self::instance(); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * sets hooks for running rest of system |
|
138 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
139 | - * starting EE Addons from any other point may lead to problems |
|
140 | - * |
|
141 | - * @access private |
|
142 | - * @param \EE_Registry $Registry |
|
143 | - */ |
|
144 | - private function __construct(EE_Registry $Registry) |
|
145 | - { |
|
146 | - $this->registry = $Registry; |
|
147 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
148 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
149 | - add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
150 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
151 | - // because the newly-activated addon didn't get a chance to run at all |
|
152 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
153 | - // detect whether install or upgrade |
|
154 | - add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
155 | - 3); |
|
156 | - // load EE_Config, EE_Textdomain, etc |
|
157 | - add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
158 | - // load EE_Config, EE_Textdomain, etc |
|
159 | - add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
160 | - array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
161 | - // you wanna get going? I wanna get going... let's get going! |
|
162 | - add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
163 | - //other housekeeping |
|
164 | - //exclude EE critical pages from wp_list_pages |
|
165 | - add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
166 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
167 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
168 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * load_espresso_addons |
|
175 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
176 | - * this is hooked into both: |
|
177 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
178 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
179 | - * and the WP 'activate_plugin' hookpoint |
|
180 | - * |
|
181 | - * @access public |
|
182 | - * @return void |
|
183 | - */ |
|
184 | - public function load_espresso_addons() |
|
185 | - { |
|
186 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
187 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
188 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
189 | - //load and setup EE_Capabilities |
|
190 | - $this->registry->load_core('Capabilities'); |
|
191 | - //caps need to be initialized on every request so that capability maps are set. |
|
192 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
193 | - $this->registry->CAP->init_caps(); |
|
194 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
195 | - //if the WP API basic auth plugin isn't already loaded, load it now. |
|
196 | - //We want it for mobile apps. Just include the entire plugin |
|
197 | - //also, don't load the basic auth when a plugin is getting activated, because |
|
198 | - //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
199 | - //and causes a fatal error |
|
200 | - if ( ! function_exists('json_basic_auth_handler') |
|
201 | - && ! function_exists('json_basic_auth_error') |
|
202 | - && ! ( |
|
203 | - isset($_GET['action']) |
|
204 | - && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
205 | - ) |
|
206 | - && ! ( |
|
207 | - isset($_GET['activate']) |
|
208 | - && $_GET['activate'] === 'true' |
|
209 | - ) |
|
210 | - ) { |
|
211 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
212 | - } |
|
213 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * detect_activations_or_upgrades |
|
220 | - * Checks for activation or upgrade of core first; |
|
221 | - * then also checks if any registered addons have been activated or upgraded |
|
222 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
223 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
224 | - * |
|
225 | - * @access public |
|
226 | - * @return void |
|
227 | - */ |
|
228 | - public function detect_activations_or_upgrades() |
|
229 | - { |
|
230 | - //first off: let's make sure to handle core |
|
231 | - $this->detect_if_activation_or_upgrade(); |
|
232 | - foreach ($this->registry->addons as $addon) { |
|
233 | - //detect teh request type for that addon |
|
234 | - $addon->detect_activation_or_upgrade(); |
|
235 | - } |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * detect_if_activation_or_upgrade |
|
242 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
243 | - * and either setting up the DB or setting up maintenance mode etc. |
|
244 | - * |
|
245 | - * @access public |
|
246 | - * @return void |
|
247 | - */ |
|
248 | - public function detect_if_activation_or_upgrade() |
|
249 | - { |
|
250 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
251 | - // load M-Mode class |
|
252 | - $this->registry->load_core('Maintenance_Mode'); |
|
253 | - // check if db has been updated, or if its a brand-new installation |
|
254 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
255 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
256 | - //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
257 | - switch ($request_type) { |
|
258 | - case EE_System::req_type_new_activation: |
|
259 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
260 | - $this->_handle_core_version_change($espresso_db_update); |
|
261 | - break; |
|
262 | - case EE_System::req_type_reactivation: |
|
263 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
264 | - $this->_handle_core_version_change($espresso_db_update); |
|
265 | - break; |
|
266 | - case EE_System::req_type_upgrade: |
|
267 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
268 | - //migrations may be required now that we've upgraded |
|
269 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
270 | - $this->_handle_core_version_change($espresso_db_update); |
|
271 | - // echo "done upgrade";die; |
|
272 | - break; |
|
273 | - case EE_System::req_type_downgrade: |
|
274 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
275 | - //its possible migrations are no longer required |
|
276 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
277 | - $this->_handle_core_version_change($espresso_db_update); |
|
278 | - break; |
|
279 | - case EE_System::req_type_normal: |
|
280 | - default: |
|
281 | - // $this->_maybe_redirect_to_ee_about(); |
|
282 | - break; |
|
283 | - } |
|
284 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * Updates the list of installed versions and sets hooks for |
|
291 | - * initializing the database later during the request |
|
292 | - * |
|
293 | - * @param array $espresso_db_update |
|
294 | - */ |
|
295 | - protected function _handle_core_version_change($espresso_db_update) |
|
296 | - { |
|
297 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
298 | - //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
299 | - add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
300 | - array($this, 'initialize_db_if_no_migrations_required')); |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
307 | - * information about what versions of EE have been installed and activated, |
|
308 | - * NOT necessarily the state of the database |
|
309 | - * |
|
310 | - * @param null $espresso_db_update |
|
311 | - * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
312 | - * from the options table |
|
313 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
314 | - */ |
|
315 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
316 | - { |
|
317 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
318 | - if ( ! $espresso_db_update) { |
|
319 | - $espresso_db_update = get_option('espresso_db_update'); |
|
320 | - } |
|
321 | - // check that option is an array |
|
322 | - if ( ! is_array($espresso_db_update)) { |
|
323 | - // if option is FALSE, then it never existed |
|
324 | - if ($espresso_db_update === false) { |
|
325 | - // make $espresso_db_update an array and save option with autoload OFF |
|
326 | - $espresso_db_update = array(); |
|
327 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
328 | - } else { |
|
329 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
330 | - $espresso_db_update = array($espresso_db_update => array()); |
|
331 | - update_option('espresso_db_update', $espresso_db_update); |
|
332 | - } |
|
333 | - } else { |
|
334 | - $corrected_db_update = array(); |
|
335 | - //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
336 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
337 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
338 | - //the key is an int, and the value IS NOT an array |
|
339 | - //so it must be numerically-indexed, where values are versions installed... |
|
340 | - //fix it! |
|
341 | - $version_string = $should_be_array; |
|
342 | - $corrected_db_update[$version_string] = array('unknown-date'); |
|
343 | - } else { |
|
344 | - //ok it checks out |
|
345 | - $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
346 | - } |
|
347 | - } |
|
348 | - $espresso_db_update = $corrected_db_update; |
|
349 | - update_option('espresso_db_update', $espresso_db_update); |
|
350 | - } |
|
351 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
352 | - return $espresso_db_update; |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
359 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
360 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
361 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
362 | - * so that it will be done when migrations are finished |
|
363 | - * |
|
364 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
365 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
366 | - * This is a resource-intensive job |
|
367 | - * so we prefer to only do it when necessary |
|
368 | - * @return void |
|
369 | - */ |
|
370 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
371 | - { |
|
372 | - $request_type = $this->detect_req_type(); |
|
373 | - //only initialize system if we're not in maintenance mode. |
|
374 | - if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
375 | - update_option('ee_flush_rewrite_rules', true); |
|
376 | - if ($verify_schema) { |
|
377 | - EEH_Activation::initialize_db_and_folders(); |
|
378 | - } |
|
379 | - EEH_Activation::initialize_db_content(); |
|
380 | - EEH_Activation::system_initialization(); |
|
381 | - if ($initialize_addons_too) { |
|
382 | - $this->initialize_addons(); |
|
383 | - } |
|
384 | - } else { |
|
385 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
386 | - } |
|
387 | - if ($request_type === EE_System::req_type_new_activation |
|
388 | - || $request_type === EE_System::req_type_reactivation |
|
389 | - || ( |
|
390 | - $request_type === EE_System::req_type_upgrade |
|
391 | - && $this->is_major_version_change() |
|
392 | - ) |
|
393 | - ) { |
|
394 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * Initializes the db for all registered addons |
|
402 | - */ |
|
403 | - public function initialize_addons() |
|
404 | - { |
|
405 | - //foreach registered addon, make sure its db is up-to-date too |
|
406 | - foreach ($this->registry->addons as $addon) { |
|
407 | - $addon->initialize_db_if_no_migrations_required(); |
|
408 | - } |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - |
|
413 | - /** |
|
414 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
415 | - * |
|
416 | - * @param array $version_history |
|
417 | - * @param string $current_version_to_add version to be added to the version history |
|
418 | - * @return boolean success as to whether or not this option was changed |
|
419 | - */ |
|
420 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
421 | - { |
|
422 | - if ( ! $version_history) { |
|
423 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
424 | - } |
|
425 | - if ($current_version_to_add == null) { |
|
426 | - $current_version_to_add = espresso_version(); |
|
427 | - } |
|
428 | - $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
429 | - // re-save |
|
430 | - return update_option('espresso_db_update', $version_history); |
|
431 | - } |
|
432 | - |
|
433 | - |
|
434 | - |
|
435 | - /** |
|
436 | - * Detects if the current version indicated in the has existed in the list of |
|
437 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
438 | - * |
|
439 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
440 | - * If not supplied, fetches it from the options table. |
|
441 | - * Also, caches its result so later parts of the code can also know whether |
|
442 | - * there's been an update or not. This way we can add the current version to |
|
443 | - * espresso_db_update, but still know if this is a new install or not |
|
444 | - * @return int one of the constants on EE_System::req_type_ |
|
445 | - */ |
|
446 | - public function detect_req_type($espresso_db_update = null) |
|
447 | - { |
|
448 | - if ($this->_req_type === null) { |
|
449 | - $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
450 | - : $this->fix_espresso_db_upgrade_option(); |
|
451 | - $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
452 | - 'ee_espresso_activation', espresso_version()); |
|
453 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
454 | - } |
|
455 | - return $this->_req_type; |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - |
|
460 | - /** |
|
461 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
462 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
463 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
464 | - * |
|
465 | - * @param $activation_history |
|
466 | - * @return bool |
|
467 | - */ |
|
468 | - protected function _detect_major_version_change($activation_history) |
|
469 | - { |
|
470 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
471 | - $previous_version_parts = explode('.', $previous_version); |
|
472 | - $current_version_parts = explode('.', espresso_version()); |
|
473 | - return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
474 | - && ($previous_version_parts[0] !== $current_version_parts[0] |
|
475 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
476 | - ); |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - |
|
481 | - /** |
|
482 | - * Returns true if either the major or minor version of EE changed during this request. |
|
483 | - * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
484 | - * |
|
485 | - * @return bool |
|
486 | - */ |
|
487 | - public function is_major_version_change() |
|
488 | - { |
|
489 | - return $this->_major_version_change; |
|
490 | - } |
|
491 | - |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
496 | - * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
497 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
498 | - * just activated to (for core that will always be espresso_version()) |
|
499 | - * |
|
500 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
501 | - * ee plugin. for core that's 'espresso_db_update' |
|
502 | - * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
503 | - * indicate that this plugin was just activated |
|
504 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
505 | - * espresso_version()) |
|
506 | - * @return int one of the constants on EE_System::req_type_* |
|
507 | - */ |
|
508 | - public static function detect_req_type_given_activation_history( |
|
509 | - $activation_history_for_addon, |
|
510 | - $activation_indicator_option_name, |
|
511 | - $version_to_upgrade_to |
|
512 | - ) { |
|
513 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
514 | - if ($activation_history_for_addon) { |
|
515 | - //it exists, so this isn't a completely new install |
|
516 | - //check if this version already in that list of previously installed versions |
|
517 | - if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
518 | - //it a version we haven't seen before |
|
519 | - if ($version_is_higher === 1) { |
|
520 | - $req_type = EE_System::req_type_upgrade; |
|
521 | - } else { |
|
522 | - $req_type = EE_System::req_type_downgrade; |
|
523 | - } |
|
524 | - delete_option($activation_indicator_option_name); |
|
525 | - } else { |
|
526 | - // its not an update. maybe a reactivation? |
|
527 | - if (get_option($activation_indicator_option_name, false)) { |
|
528 | - if ($version_is_higher === -1) { |
|
529 | - $req_type = EE_System::req_type_downgrade; |
|
530 | - } elseif ($version_is_higher === 0) { |
|
531 | - //we've seen this version before, but it's an activation. must be a reactivation |
|
532 | - $req_type = EE_System::req_type_reactivation; |
|
533 | - } else {//$version_is_higher === 1 |
|
534 | - $req_type = EE_System::req_type_upgrade; |
|
535 | - } |
|
536 | - delete_option($activation_indicator_option_name); |
|
537 | - } else { |
|
538 | - //we've seen this version before and the activation indicate doesn't show it was just activated |
|
539 | - if ($version_is_higher === -1) { |
|
540 | - $req_type = EE_System::req_type_downgrade; |
|
541 | - } elseif ($version_is_higher === 0) { |
|
542 | - //we've seen this version before and it's not an activation. its normal request |
|
543 | - $req_type = EE_System::req_type_normal; |
|
544 | - } else {//$version_is_higher === 1 |
|
545 | - $req_type = EE_System::req_type_upgrade; |
|
546 | - } |
|
547 | - } |
|
548 | - } |
|
549 | - } else { |
|
550 | - //brand new install |
|
551 | - $req_type = EE_System::req_type_new_activation; |
|
552 | - delete_option($activation_indicator_option_name); |
|
553 | - } |
|
554 | - return $req_type; |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - |
|
559 | - /** |
|
560 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
561 | - * the $activation_history_for_addon |
|
562 | - * |
|
563 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
564 | - * sometimes containing 'unknown-date' |
|
565 | - * @param string $version_to_upgrade_to (current version) |
|
566 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
567 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
568 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
569 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
570 | - */ |
|
571 | - protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
572 | - { |
|
573 | - //find the most recently-activated version |
|
574 | - $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
575 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
576 | - } |
|
577 | - |
|
578 | - |
|
579 | - |
|
580 | - /** |
|
581 | - * Gets the most recently active version listed in the activation history, |
|
582 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
583 | - * |
|
584 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
585 | - * sometimes containing 'unknown-date' |
|
586 | - * @return string |
|
587 | - */ |
|
588 | - protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
589 | - { |
|
590 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
591 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
592 | - if (is_array($activation_history)) { |
|
593 | - foreach ($activation_history as $version => $times_activated) { |
|
594 | - //check there is a record of when this version was activated. Otherwise, |
|
595 | - //mark it as unknown |
|
596 | - if ( ! $times_activated) { |
|
597 | - $times_activated = array('unknown-date'); |
|
598 | - } |
|
599 | - if (is_string($times_activated)) { |
|
600 | - $times_activated = array($times_activated); |
|
601 | - } |
|
602 | - foreach ($times_activated as $an_activation) { |
|
603 | - if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
604 | - $most_recently_active_version = $version; |
|
605 | - $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
606 | - ? '1970-01-01 00:00:00' : $an_activation; |
|
607 | - } |
|
608 | - } |
|
609 | - } |
|
610 | - } |
|
611 | - return $most_recently_active_version; |
|
612 | - } |
|
613 | - |
|
614 | - |
|
615 | - |
|
616 | - /** |
|
617 | - * This redirects to the about EE page after activation |
|
618 | - * |
|
619 | - * @return void |
|
620 | - */ |
|
621 | - public function redirect_to_about_ee() |
|
622 | - { |
|
623 | - $notices = EE_Error::get_notices(false); |
|
624 | - //if current user is an admin and it's not an ajax or rest request |
|
625 | - if ( |
|
626 | - ! (defined('DOING_AJAX') && DOING_AJAX) |
|
627 | - && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
628 | - && ! isset($notices['errors']) |
|
629 | - && apply_filters( |
|
630 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
631 | - $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
632 | - ) |
|
633 | - ) { |
|
634 | - $query_params = array('page' => 'espresso_about'); |
|
635 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
636 | - $query_params['new_activation'] = true; |
|
637 | - } |
|
638 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
639 | - $query_params['reactivation'] = true; |
|
640 | - } |
|
641 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
642 | - wp_safe_redirect($url); |
|
643 | - exit(); |
|
644 | - } |
|
645 | - } |
|
646 | - |
|
647 | - |
|
648 | - |
|
649 | - /** |
|
650 | - * load_core_configuration |
|
651 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
652 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
653 | - * |
|
654 | - * @return void |
|
655 | - */ |
|
656 | - public function load_core_configuration() |
|
657 | - { |
|
658 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
659 | - $this->registry->load_core('EE_Load_Textdomain'); |
|
660 | - //load textdomain |
|
661 | - EE_Load_Textdomain::load_textdomain(); |
|
662 | - // load and setup EE_Config and EE_Network_Config |
|
663 | - $this->registry->load_core('Config'); |
|
664 | - $this->registry->load_core('Network_Config'); |
|
665 | - // setup autoloaders |
|
666 | - // enable logging? |
|
667 | - if ($this->registry->CFG->admin->use_full_logging) { |
|
668 | - $this->registry->load_core('Log'); |
|
669 | - } |
|
670 | - // check for activation errors |
|
671 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
672 | - if ($activation_errors) { |
|
673 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
674 | - update_option('ee_plugin_activation_errors', false); |
|
675 | - } |
|
676 | - // get model names |
|
677 | - $this->_parse_model_names(); |
|
678 | - //load caf stuff a chance to play during the activation process too. |
|
679 | - $this->_maybe_brew_regular(); |
|
680 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
681 | - } |
|
682 | - |
|
683 | - |
|
684 | - |
|
685 | - /** |
|
686 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
687 | - * |
|
688 | - * @return void |
|
689 | - */ |
|
690 | - private function _parse_model_names() |
|
691 | - { |
|
692 | - //get all the files in the EE_MODELS folder that end in .model.php |
|
693 | - $models = glob(EE_MODELS . '*.model.php'); |
|
694 | - $model_names = array(); |
|
695 | - $non_abstract_db_models = array(); |
|
696 | - foreach ($models as $model) { |
|
697 | - // get model classname |
|
698 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
699 | - $short_name = str_replace('EEM_', '', $classname); |
|
700 | - $reflectionClass = new ReflectionClass($classname); |
|
701 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
702 | - $non_abstract_db_models[$short_name] = $classname; |
|
703 | - } |
|
704 | - $model_names[$short_name] = $classname; |
|
705 | - } |
|
706 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
707 | - $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', |
|
708 | - $non_abstract_db_models); |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
715 | - * that need to be setup before our EE_System launches. |
|
716 | - * |
|
717 | - * @return void |
|
718 | - */ |
|
719 | - private function _maybe_brew_regular() |
|
720 | - { |
|
721 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
722 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
723 | - } |
|
724 | - } |
|
725 | - |
|
726 | - |
|
727 | - |
|
728 | - /** |
|
729 | - * register_shortcodes_modules_and_widgets |
|
730 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
731 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
732 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
733 | - * |
|
734 | - * @access public |
|
735 | - * @return void |
|
736 | - */ |
|
737 | - public function register_shortcodes_modules_and_widgets() |
|
738 | - { |
|
739 | - try { |
|
740 | - // load, register, and add shortcodes the new way |
|
741 | - new ShortcodesManager( |
|
742 | - // and the old way, but we'll put it under control of the new system |
|
743 | - EE_Config::getLegacyShortcodesManager() |
|
744 | - ); |
|
745 | - } catch (Exception $exception) { |
|
746 | - new ExceptionStackTraceDisplay($exception); |
|
747 | - } |
|
748 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
749 | - // check for addons using old hookpoint |
|
750 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
751 | - $this->_incompatible_addon_error(); |
|
752 | - } |
|
753 | - } |
|
754 | - |
|
755 | - |
|
756 | - |
|
757 | - /** |
|
758 | - * _incompatible_addon_error |
|
759 | - * |
|
760 | - * @access public |
|
761 | - * @return void |
|
762 | - */ |
|
763 | - private function _incompatible_addon_error() |
|
764 | - { |
|
765 | - // get array of classes hooking into here |
|
766 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
767 | - if ( ! empty($class_names)) { |
|
768 | - $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
769 | - 'event_espresso'); |
|
770 | - $msg .= '<ul>'; |
|
771 | - foreach ($class_names as $class_name) { |
|
772 | - $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
773 | - $class_name) . '</b></li>'; |
|
774 | - } |
|
775 | - $msg .= '</ul>'; |
|
776 | - $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
777 | - 'event_espresso'); |
|
778 | - // save list of incompatible addons to wp-options for later use |
|
779 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
780 | - if (is_admin()) { |
|
781 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
782 | - } |
|
783 | - } |
|
784 | - } |
|
785 | - |
|
786 | - |
|
787 | - |
|
788 | - /** |
|
789 | - * brew_espresso |
|
790 | - * begins the process of setting hooks for initializing EE in the correct order |
|
791 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
792 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
793 | - * |
|
794 | - * @return void |
|
795 | - */ |
|
796 | - public function brew_espresso() |
|
797 | - { |
|
798 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
799 | - // load some final core systems |
|
800 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
801 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
802 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
803 | - add_action('init', array($this, 'load_controllers'), 7); |
|
804 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
805 | - add_action('init', array($this, 'initialize'), 10); |
|
806 | - add_action('init', array($this, 'initialize_last'), 100); |
|
807 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
808 | - add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
809 | - add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
810 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
811 | - // pew pew pew |
|
812 | - $this->registry->load_core('PUE'); |
|
813 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
814 | - } |
|
815 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
816 | - } |
|
817 | - |
|
818 | - |
|
819 | - |
|
820 | - /** |
|
821 | - * set_hooks_for_core |
|
822 | - * |
|
823 | - * @access public |
|
824 | - * @return void |
|
825 | - */ |
|
826 | - public function set_hooks_for_core() |
|
827 | - { |
|
828 | - $this->_deactivate_incompatible_addons(); |
|
829 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
830 | - } |
|
831 | - |
|
832 | - |
|
833 | - |
|
834 | - /** |
|
835 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
836 | - * deactivates any addons considered incompatible with the current version of EE |
|
837 | - */ |
|
838 | - private function _deactivate_incompatible_addons() |
|
839 | - { |
|
840 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
841 | - if ( ! empty($incompatible_addons)) { |
|
842 | - $active_plugins = get_option('active_plugins', array()); |
|
843 | - foreach ($active_plugins as $active_plugin) { |
|
844 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
845 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
846 | - unset($_GET['activate']); |
|
847 | - espresso_deactivate_plugin($active_plugin); |
|
848 | - } |
|
849 | - } |
|
850 | - } |
|
851 | - } |
|
852 | - } |
|
853 | - |
|
854 | - |
|
855 | - |
|
856 | - /** |
|
857 | - * perform_activations_upgrades_and_migrations |
|
858 | - * |
|
859 | - * @access public |
|
860 | - * @return void |
|
861 | - */ |
|
862 | - public function perform_activations_upgrades_and_migrations() |
|
863 | - { |
|
864 | - //first check if we had previously attempted to setup EE's directories but failed |
|
865 | - if (EEH_Activation::upload_directories_incomplete()) { |
|
866 | - EEH_Activation::create_upload_directories(); |
|
867 | - } |
|
868 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
869 | - } |
|
870 | - |
|
871 | - |
|
872 | - |
|
873 | - /** |
|
874 | - * load_CPTs_and_session |
|
875 | - * |
|
876 | - * @access public |
|
877 | - * @return void |
|
878 | - */ |
|
879 | - public function load_CPTs_and_session() |
|
880 | - { |
|
881 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
882 | - // register Custom Post Types |
|
883 | - $this->registry->load_core('Register_CPTs'); |
|
884 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
885 | - } |
|
886 | - |
|
887 | - |
|
888 | - |
|
889 | - /** |
|
890 | - * load_controllers |
|
891 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
892 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
893 | - * time |
|
894 | - * |
|
895 | - * @access public |
|
896 | - * @return void |
|
897 | - */ |
|
898 | - public function load_controllers() |
|
899 | - { |
|
900 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
901 | - // let's get it started |
|
902 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
903 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
904 | - $this->registry->load_core('Front_Controller'); |
|
905 | - } else if ( ! EE_FRONT_AJAX) { |
|
906 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
907 | - EE_Registry::instance()->load_core('Admin'); |
|
908 | - } |
|
909 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
910 | - } |
|
911 | - |
|
912 | - |
|
913 | - |
|
914 | - /** |
|
915 | - * core_loaded_and_ready |
|
916 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
917 | - * |
|
918 | - * @access public |
|
919 | - * @return void |
|
920 | - */ |
|
921 | - public function core_loaded_and_ready() |
|
922 | - { |
|
923 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
924 | - // load_espresso_template_tags |
|
925 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
926 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
927 | - } |
|
928 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
929 | - $this->registry->load_core('Session'); |
|
930 | - } |
|
931 | - |
|
932 | - |
|
933 | - |
|
934 | - /** |
|
935 | - * initialize |
|
936 | - * this is the best place to begin initializing client code |
|
937 | - * |
|
938 | - * @access public |
|
939 | - * @return void |
|
940 | - */ |
|
941 | - public function initialize() |
|
942 | - { |
|
943 | - do_action('AHEE__EE_System__initialize'); |
|
944 | - } |
|
945 | - |
|
946 | - |
|
947 | - |
|
948 | - /** |
|
949 | - * initialize_last |
|
950 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
951 | - * initialize has done so |
|
952 | - * |
|
953 | - * @access public |
|
954 | - * @return void |
|
955 | - */ |
|
956 | - public function initialize_last() |
|
957 | - { |
|
958 | - do_action('AHEE__EE_System__initialize_last'); |
|
959 | - } |
|
960 | - |
|
961 | - |
|
962 | - |
|
963 | - /** |
|
964 | - * set_hooks_for_shortcodes_modules_and_addons |
|
965 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
966 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
967 | - * |
|
968 | - * @access public |
|
969 | - * @return void |
|
970 | - */ |
|
971 | - public function set_hooks_for_shortcodes_modules_and_addons() |
|
972 | - { |
|
973 | - // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
974 | - } |
|
975 | - |
|
976 | - |
|
977 | - |
|
978 | - /** |
|
979 | - * do_not_cache |
|
980 | - * sets no cache headers and defines no cache constants for WP plugins |
|
981 | - * |
|
982 | - * @access public |
|
983 | - * @return void |
|
984 | - */ |
|
985 | - public static function do_not_cache() |
|
986 | - { |
|
987 | - // set no cache constants |
|
988 | - if ( ! defined('DONOTCACHEPAGE')) { |
|
989 | - define('DONOTCACHEPAGE', true); |
|
990 | - } |
|
991 | - if ( ! defined('DONOTCACHCEOBJECT')) { |
|
992 | - define('DONOTCACHCEOBJECT', true); |
|
993 | - } |
|
994 | - if ( ! defined('DONOTCACHEDB')) { |
|
995 | - define('DONOTCACHEDB', true); |
|
996 | - } |
|
997 | - // add no cache headers |
|
998 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
999 | - // plus a little extra for nginx and Google Chrome |
|
1000 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1001 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1002 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1003 | - } |
|
1004 | - |
|
1005 | - |
|
1006 | - |
|
1007 | - /** |
|
1008 | - * extra_nocache_headers |
|
1009 | - * |
|
1010 | - * @access public |
|
1011 | - * @param $headers |
|
1012 | - * @return array |
|
1013 | - */ |
|
1014 | - public static function extra_nocache_headers($headers) |
|
1015 | - { |
|
1016 | - // for NGINX |
|
1017 | - $headers['X-Accel-Expires'] = 0; |
|
1018 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1019 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1020 | - return $headers; |
|
1021 | - } |
|
1022 | - |
|
1023 | - |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * nocache_headers |
|
1027 | - * |
|
1028 | - * @access public |
|
1029 | - * @return void |
|
1030 | - */ |
|
1031 | - public static function nocache_headers() |
|
1032 | - { |
|
1033 | - nocache_headers(); |
|
1034 | - } |
|
1035 | - |
|
1036 | - |
|
1037 | - |
|
1038 | - /** |
|
1039 | - * espresso_toolbar_items |
|
1040 | - * |
|
1041 | - * @access public |
|
1042 | - * @param WP_Admin_Bar $admin_bar |
|
1043 | - * @return void |
|
1044 | - */ |
|
1045 | - public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1046 | - { |
|
1047 | - // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1048 | - if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1049 | - || defined('DOING_AJAX') |
|
1050 | - || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1051 | - ) { |
|
1052 | - return; |
|
1053 | - } |
|
1054 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1055 | - $menu_class = 'espresso_menu_item_class'; |
|
1056 | - //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1057 | - //because they're only defined in each of their respective constructors |
|
1058 | - //and this might be a frontend request, in which case they aren't available |
|
1059 | - $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1060 | - $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1061 | - $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1062 | - //Top Level |
|
1063 | - $admin_bar->add_menu(array( |
|
1064 | - 'id' => 'espresso-toolbar', |
|
1065 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1066 | - . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1067 | - . '</span>', |
|
1068 | - 'href' => $events_admin_url, |
|
1069 | - 'meta' => array( |
|
1070 | - 'title' => __('Event Espresso', 'event_espresso'), |
|
1071 | - 'class' => $menu_class . 'first', |
|
1072 | - ), |
|
1073 | - )); |
|
1074 | - //Events |
|
1075 | - if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1076 | - $admin_bar->add_menu(array( |
|
1077 | - 'id' => 'espresso-toolbar-events', |
|
1078 | - 'parent' => 'espresso-toolbar', |
|
1079 | - 'title' => __('Events', 'event_espresso'), |
|
1080 | - 'href' => $events_admin_url, |
|
1081 | - 'meta' => array( |
|
1082 | - 'title' => __('Events', 'event_espresso'), |
|
1083 | - 'target' => '', |
|
1084 | - 'class' => $menu_class, |
|
1085 | - ), |
|
1086 | - )); |
|
1087 | - } |
|
1088 | - if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1089 | - //Events Add New |
|
1090 | - $admin_bar->add_menu(array( |
|
1091 | - 'id' => 'espresso-toolbar-events-new', |
|
1092 | - 'parent' => 'espresso-toolbar-events', |
|
1093 | - 'title' => __('Add New', 'event_espresso'), |
|
1094 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1095 | - 'meta' => array( |
|
1096 | - 'title' => __('Add New', 'event_espresso'), |
|
1097 | - 'target' => '', |
|
1098 | - 'class' => $menu_class, |
|
1099 | - ), |
|
1100 | - )); |
|
1101 | - } |
|
1102 | - if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1103 | - //Current post |
|
1104 | - global $post; |
|
1105 | - if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1106 | - 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1107 | - ) { |
|
1108 | - //Events Edit Current Event |
|
1109 | - $admin_bar->add_menu(array( |
|
1110 | - 'id' => 'espresso-toolbar-events-edit', |
|
1111 | - 'parent' => 'espresso-toolbar-events', |
|
1112 | - 'title' => __('Edit Event', 'event_espresso'), |
|
1113 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1114 | - $events_admin_url), |
|
1115 | - 'meta' => array( |
|
1116 | - 'title' => __('Edit Event', 'event_espresso'), |
|
1117 | - 'target' => '', |
|
1118 | - 'class' => $menu_class, |
|
1119 | - ), |
|
1120 | - )); |
|
1121 | - } |
|
1122 | - } |
|
1123 | - //Events View |
|
1124 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1125 | - 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1126 | - ) { |
|
1127 | - $admin_bar->add_menu(array( |
|
1128 | - 'id' => 'espresso-toolbar-events-view', |
|
1129 | - 'parent' => 'espresso-toolbar-events', |
|
1130 | - 'title' => __('View', 'event_espresso'), |
|
1131 | - 'href' => $events_admin_url, |
|
1132 | - 'meta' => array( |
|
1133 | - 'title' => __('View', 'event_espresso'), |
|
1134 | - 'target' => '', |
|
1135 | - 'class' => $menu_class, |
|
1136 | - ), |
|
1137 | - )); |
|
1138 | - } |
|
1139 | - if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1140 | - //Events View All |
|
1141 | - $admin_bar->add_menu(array( |
|
1142 | - 'id' => 'espresso-toolbar-events-all', |
|
1143 | - 'parent' => 'espresso-toolbar-events-view', |
|
1144 | - 'title' => __('All', 'event_espresso'), |
|
1145 | - 'href' => $events_admin_url, |
|
1146 | - 'meta' => array( |
|
1147 | - 'title' => __('All', 'event_espresso'), |
|
1148 | - 'target' => '', |
|
1149 | - 'class' => $menu_class, |
|
1150 | - ), |
|
1151 | - )); |
|
1152 | - } |
|
1153 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1154 | - 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1155 | - ) { |
|
1156 | - //Events View Today |
|
1157 | - $admin_bar->add_menu(array( |
|
1158 | - 'id' => 'espresso-toolbar-events-today', |
|
1159 | - 'parent' => 'espresso-toolbar-events-view', |
|
1160 | - 'title' => __('Today', 'event_espresso'), |
|
1161 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1162 | - $events_admin_url), |
|
1163 | - 'meta' => array( |
|
1164 | - 'title' => __('Today', 'event_espresso'), |
|
1165 | - 'target' => '', |
|
1166 | - 'class' => $menu_class, |
|
1167 | - ), |
|
1168 | - )); |
|
1169 | - } |
|
1170 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1171 | - 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1172 | - ) { |
|
1173 | - //Events View This Month |
|
1174 | - $admin_bar->add_menu(array( |
|
1175 | - 'id' => 'espresso-toolbar-events-month', |
|
1176 | - 'parent' => 'espresso-toolbar-events-view', |
|
1177 | - 'title' => __('This Month', 'event_espresso'), |
|
1178 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1179 | - $events_admin_url), |
|
1180 | - 'meta' => array( |
|
1181 | - 'title' => __('This Month', 'event_espresso'), |
|
1182 | - 'target' => '', |
|
1183 | - 'class' => $menu_class, |
|
1184 | - ), |
|
1185 | - )); |
|
1186 | - } |
|
1187 | - //Registration Overview |
|
1188 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1189 | - 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1190 | - ) { |
|
1191 | - $admin_bar->add_menu(array( |
|
1192 | - 'id' => 'espresso-toolbar-registrations', |
|
1193 | - 'parent' => 'espresso-toolbar', |
|
1194 | - 'title' => __('Registrations', 'event_espresso'), |
|
1195 | - 'href' => $reg_admin_url, |
|
1196 | - 'meta' => array( |
|
1197 | - 'title' => __('Registrations', 'event_espresso'), |
|
1198 | - 'target' => '', |
|
1199 | - 'class' => $menu_class, |
|
1200 | - ), |
|
1201 | - )); |
|
1202 | - } |
|
1203 | - //Registration Overview Today |
|
1204 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1205 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1206 | - ) { |
|
1207 | - $admin_bar->add_menu(array( |
|
1208 | - 'id' => 'espresso-toolbar-registrations-today', |
|
1209 | - 'parent' => 'espresso-toolbar-registrations', |
|
1210 | - 'title' => __('Today', 'event_espresso'), |
|
1211 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1212 | - $reg_admin_url), |
|
1213 | - 'meta' => array( |
|
1214 | - 'title' => __('Today', 'event_espresso'), |
|
1215 | - 'target' => '', |
|
1216 | - 'class' => $menu_class, |
|
1217 | - ), |
|
1218 | - )); |
|
1219 | - } |
|
1220 | - //Registration Overview Today Completed |
|
1221 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1222 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1223 | - ) { |
|
1224 | - $admin_bar->add_menu(array( |
|
1225 | - 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1226 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1227 | - 'title' => __('Approved', 'event_espresso'), |
|
1228 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1229 | - 'action' => 'default', |
|
1230 | - 'status' => 'today', |
|
1231 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1232 | - ), $reg_admin_url), |
|
1233 | - 'meta' => array( |
|
1234 | - 'title' => __('Approved', 'event_espresso'), |
|
1235 | - 'target' => '', |
|
1236 | - 'class' => $menu_class, |
|
1237 | - ), |
|
1238 | - )); |
|
1239 | - } |
|
1240 | - //Registration Overview Today Pending\ |
|
1241 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1242 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1243 | - ) { |
|
1244 | - $admin_bar->add_menu(array( |
|
1245 | - 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1246 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1247 | - 'title' => __('Pending', 'event_espresso'), |
|
1248 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1249 | - 'action' => 'default', |
|
1250 | - 'status' => 'today', |
|
1251 | - 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1252 | - ), $reg_admin_url), |
|
1253 | - 'meta' => array( |
|
1254 | - 'title' => __('Pending Payment', 'event_espresso'), |
|
1255 | - 'target' => '', |
|
1256 | - 'class' => $menu_class, |
|
1257 | - ), |
|
1258 | - )); |
|
1259 | - } |
|
1260 | - //Registration Overview Today Incomplete |
|
1261 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1262 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1263 | - ) { |
|
1264 | - $admin_bar->add_menu(array( |
|
1265 | - 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1266 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1267 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1268 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1269 | - 'action' => 'default', |
|
1270 | - 'status' => 'today', |
|
1271 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1272 | - ), $reg_admin_url), |
|
1273 | - 'meta' => array( |
|
1274 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1275 | - 'target' => '', |
|
1276 | - 'class' => $menu_class, |
|
1277 | - ), |
|
1278 | - )); |
|
1279 | - } |
|
1280 | - //Registration Overview Today Incomplete |
|
1281 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1282 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1283 | - ) { |
|
1284 | - $admin_bar->add_menu(array( |
|
1285 | - 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1286 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1287 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1288 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1289 | - 'action' => 'default', |
|
1290 | - 'status' => 'today', |
|
1291 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1292 | - ), $reg_admin_url), |
|
1293 | - 'meta' => array( |
|
1294 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1295 | - 'target' => '', |
|
1296 | - 'class' => $menu_class, |
|
1297 | - ), |
|
1298 | - )); |
|
1299 | - } |
|
1300 | - //Registration Overview This Month |
|
1301 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1302 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1303 | - ) { |
|
1304 | - $admin_bar->add_menu(array( |
|
1305 | - 'id' => 'espresso-toolbar-registrations-month', |
|
1306 | - 'parent' => 'espresso-toolbar-registrations', |
|
1307 | - 'title' => __('This Month', 'event_espresso'), |
|
1308 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1309 | - $reg_admin_url), |
|
1310 | - 'meta' => array( |
|
1311 | - 'title' => __('This Month', 'event_espresso'), |
|
1312 | - 'target' => '', |
|
1313 | - 'class' => $menu_class, |
|
1314 | - ), |
|
1315 | - )); |
|
1316 | - } |
|
1317 | - //Registration Overview This Month Approved |
|
1318 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1319 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1320 | - ) { |
|
1321 | - $admin_bar->add_menu(array( |
|
1322 | - 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1323 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1324 | - 'title' => __('Approved', 'event_espresso'), |
|
1325 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1326 | - 'action' => 'default', |
|
1327 | - 'status' => 'month', |
|
1328 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1329 | - ), $reg_admin_url), |
|
1330 | - 'meta' => array( |
|
1331 | - 'title' => __('Approved', 'event_espresso'), |
|
1332 | - 'target' => '', |
|
1333 | - 'class' => $menu_class, |
|
1334 | - ), |
|
1335 | - )); |
|
1336 | - } |
|
1337 | - //Registration Overview This Month Pending |
|
1338 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1339 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1340 | - ) { |
|
1341 | - $admin_bar->add_menu(array( |
|
1342 | - 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1343 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1344 | - 'title' => __('Pending', 'event_espresso'), |
|
1345 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1346 | - 'action' => 'default', |
|
1347 | - 'status' => 'month', |
|
1348 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1349 | - ), $reg_admin_url), |
|
1350 | - 'meta' => array( |
|
1351 | - 'title' => __('Pending', 'event_espresso'), |
|
1352 | - 'target' => '', |
|
1353 | - 'class' => $menu_class, |
|
1354 | - ), |
|
1355 | - )); |
|
1356 | - } |
|
1357 | - //Registration Overview This Month Not Approved |
|
1358 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1359 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1360 | - ) { |
|
1361 | - $admin_bar->add_menu(array( |
|
1362 | - 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1363 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1364 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1365 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1366 | - 'action' => 'default', |
|
1367 | - 'status' => 'month', |
|
1368 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1369 | - ), $reg_admin_url), |
|
1370 | - 'meta' => array( |
|
1371 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1372 | - 'target' => '', |
|
1373 | - 'class' => $menu_class, |
|
1374 | - ), |
|
1375 | - )); |
|
1376 | - } |
|
1377 | - //Registration Overview This Month Cancelled |
|
1378 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1379 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1380 | - ) { |
|
1381 | - $admin_bar->add_menu(array( |
|
1382 | - 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1383 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1384 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1385 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1386 | - 'action' => 'default', |
|
1387 | - 'status' => 'month', |
|
1388 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1389 | - ), $reg_admin_url), |
|
1390 | - 'meta' => array( |
|
1391 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1392 | - 'target' => '', |
|
1393 | - 'class' => $menu_class, |
|
1394 | - ), |
|
1395 | - )); |
|
1396 | - } |
|
1397 | - //Extensions & Services |
|
1398 | - if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1399 | - 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1400 | - ) { |
|
1401 | - $admin_bar->add_menu(array( |
|
1402 | - 'id' => 'espresso-toolbar-extensions-and-services', |
|
1403 | - 'parent' => 'espresso-toolbar', |
|
1404 | - 'title' => __('Extensions & Services', 'event_espresso'), |
|
1405 | - 'href' => $extensions_admin_url, |
|
1406 | - 'meta' => array( |
|
1407 | - 'title' => __('Extensions & Services', 'event_espresso'), |
|
1408 | - 'target' => '', |
|
1409 | - 'class' => $menu_class, |
|
1410 | - ), |
|
1411 | - )); |
|
1412 | - } |
|
1413 | - } |
|
1414 | - |
|
1415 | - |
|
1416 | - |
|
1417 | - /** |
|
1418 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1419 | - * never returned with the function. |
|
1420 | - * |
|
1421 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
1422 | - * @return array |
|
1423 | - */ |
|
1424 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
1425 | - { |
|
1426 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1427 | - } |
|
1428 | - |
|
1429 | - |
|
1430 | - |
|
1431 | - |
|
1432 | - |
|
1433 | - |
|
1434 | - /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
|
1435 | - /** |
|
1436 | - * wp_enqueue_scripts |
|
1437 | - * |
|
1438 | - * @access public |
|
1439 | - * @return void |
|
1440 | - */ |
|
1441 | - public function wp_enqueue_scripts() |
|
1442 | - { |
|
1443 | - // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
|
1444 | - if (apply_filters('FHEE_load_EE_System_scripts', true)) { |
|
1445 | - // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1446 | - if (apply_filters('FHEE_load_jquery_validate', false)) { |
|
1447 | - // register jQuery Validate and additional methods |
|
1448 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1449 | - array('jquery'), '1.15.0', true); |
|
1450 | - wp_register_script('jquery-validate-extra-methods', |
|
1451 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1452 | - array('jquery', 'jquery-validate'), '1.15.0', true); |
|
1453 | - } |
|
1454 | - } |
|
1455 | - } |
|
22 | + /** |
|
23 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
24 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
25 | + */ |
|
26 | + const req_type_normal = 0; |
|
27 | + |
|
28 | + /** |
|
29 | + * Indicates this is a brand new installation of EE so we should install |
|
30 | + * tables and default data etc |
|
31 | + */ |
|
32 | + const req_type_new_activation = 1; |
|
33 | + |
|
34 | + /** |
|
35 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
36 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
37 | + * and that default data is setup too |
|
38 | + */ |
|
39 | + const req_type_reactivation = 2; |
|
40 | + |
|
41 | + /** |
|
42 | + * indicates that EE has been upgraded since its previous request. |
|
43 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
44 | + */ |
|
45 | + const req_type_upgrade = 3; |
|
46 | + |
|
47 | + /** |
|
48 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
49 | + */ |
|
50 | + const req_type_downgrade = 4; |
|
51 | + |
|
52 | + /** |
|
53 | + * @deprecated since version 4.6.0.dev.006 |
|
54 | + * Now whenever a new_activation is detected the request type is still just |
|
55 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
56 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
57 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
58 | + * (Specifically, when the migration manager indicates migrations are finished |
|
59 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
60 | + */ |
|
61 | + const req_type_activation_but_not_installed = 5; |
|
62 | + |
|
63 | + /** |
|
64 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
65 | + */ |
|
66 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * instance of the EE_System object |
|
71 | + * |
|
72 | + * @var $_instance |
|
73 | + * @access private |
|
74 | + */ |
|
75 | + private static $_instance = null; |
|
76 | + |
|
77 | + /** |
|
78 | + * @type EE_Registry $Registry |
|
79 | + * @access protected |
|
80 | + */ |
|
81 | + protected $registry; |
|
82 | + |
|
83 | + /** |
|
84 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
85 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
86 | + * |
|
87 | + * @var int |
|
88 | + */ |
|
89 | + private $_req_type; |
|
90 | + |
|
91 | + /** |
|
92 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
93 | + * |
|
94 | + * @var boolean |
|
95 | + */ |
|
96 | + private $_major_version_change = false; |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @singleton method used to instantiate class object |
|
102 | + * @access public |
|
103 | + * @param \EE_Registry $Registry |
|
104 | + * @return \EE_System |
|
105 | + */ |
|
106 | + public static function instance(EE_Registry $Registry = null) |
|
107 | + { |
|
108 | + // check if class object is instantiated |
|
109 | + if ( ! self::$_instance instanceof EE_System) { |
|
110 | + self::$_instance = new self($Registry); |
|
111 | + } |
|
112 | + return self::$_instance; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * resets the instance and returns it |
|
119 | + * |
|
120 | + * @return EE_System |
|
121 | + */ |
|
122 | + public static function reset() |
|
123 | + { |
|
124 | + self::$_instance->_req_type = null; |
|
125 | + //make sure none of the old hooks are left hanging around |
|
126 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
127 | + //we need to reset the migration manager in order for it to detect DMSs properly |
|
128 | + EE_Data_Migration_Manager::reset(); |
|
129 | + self::instance()->detect_activations_or_upgrades(); |
|
130 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
131 | + return self::instance(); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * sets hooks for running rest of system |
|
138 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
139 | + * starting EE Addons from any other point may lead to problems |
|
140 | + * |
|
141 | + * @access private |
|
142 | + * @param \EE_Registry $Registry |
|
143 | + */ |
|
144 | + private function __construct(EE_Registry $Registry) |
|
145 | + { |
|
146 | + $this->registry = $Registry; |
|
147 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
148 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
149 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
150 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
151 | + // because the newly-activated addon didn't get a chance to run at all |
|
152 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
153 | + // detect whether install or upgrade |
|
154 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
155 | + 3); |
|
156 | + // load EE_Config, EE_Textdomain, etc |
|
157 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
158 | + // load EE_Config, EE_Textdomain, etc |
|
159 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
160 | + array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
161 | + // you wanna get going? I wanna get going... let's get going! |
|
162 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
163 | + //other housekeeping |
|
164 | + //exclude EE critical pages from wp_list_pages |
|
165 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
166 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
167 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
168 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * load_espresso_addons |
|
175 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
176 | + * this is hooked into both: |
|
177 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
178 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
179 | + * and the WP 'activate_plugin' hookpoint |
|
180 | + * |
|
181 | + * @access public |
|
182 | + * @return void |
|
183 | + */ |
|
184 | + public function load_espresso_addons() |
|
185 | + { |
|
186 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
187 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
188 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
189 | + //load and setup EE_Capabilities |
|
190 | + $this->registry->load_core('Capabilities'); |
|
191 | + //caps need to be initialized on every request so that capability maps are set. |
|
192 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
193 | + $this->registry->CAP->init_caps(); |
|
194 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
195 | + //if the WP API basic auth plugin isn't already loaded, load it now. |
|
196 | + //We want it for mobile apps. Just include the entire plugin |
|
197 | + //also, don't load the basic auth when a plugin is getting activated, because |
|
198 | + //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
199 | + //and causes a fatal error |
|
200 | + if ( ! function_exists('json_basic_auth_handler') |
|
201 | + && ! function_exists('json_basic_auth_error') |
|
202 | + && ! ( |
|
203 | + isset($_GET['action']) |
|
204 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
205 | + ) |
|
206 | + && ! ( |
|
207 | + isset($_GET['activate']) |
|
208 | + && $_GET['activate'] === 'true' |
|
209 | + ) |
|
210 | + ) { |
|
211 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
212 | + } |
|
213 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * detect_activations_or_upgrades |
|
220 | + * Checks for activation or upgrade of core first; |
|
221 | + * then also checks if any registered addons have been activated or upgraded |
|
222 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
223 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
224 | + * |
|
225 | + * @access public |
|
226 | + * @return void |
|
227 | + */ |
|
228 | + public function detect_activations_or_upgrades() |
|
229 | + { |
|
230 | + //first off: let's make sure to handle core |
|
231 | + $this->detect_if_activation_or_upgrade(); |
|
232 | + foreach ($this->registry->addons as $addon) { |
|
233 | + //detect teh request type for that addon |
|
234 | + $addon->detect_activation_or_upgrade(); |
|
235 | + } |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * detect_if_activation_or_upgrade |
|
242 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
243 | + * and either setting up the DB or setting up maintenance mode etc. |
|
244 | + * |
|
245 | + * @access public |
|
246 | + * @return void |
|
247 | + */ |
|
248 | + public function detect_if_activation_or_upgrade() |
|
249 | + { |
|
250 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
251 | + // load M-Mode class |
|
252 | + $this->registry->load_core('Maintenance_Mode'); |
|
253 | + // check if db has been updated, or if its a brand-new installation |
|
254 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
255 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
256 | + //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
257 | + switch ($request_type) { |
|
258 | + case EE_System::req_type_new_activation: |
|
259 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
260 | + $this->_handle_core_version_change($espresso_db_update); |
|
261 | + break; |
|
262 | + case EE_System::req_type_reactivation: |
|
263 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
264 | + $this->_handle_core_version_change($espresso_db_update); |
|
265 | + break; |
|
266 | + case EE_System::req_type_upgrade: |
|
267 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
268 | + //migrations may be required now that we've upgraded |
|
269 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
270 | + $this->_handle_core_version_change($espresso_db_update); |
|
271 | + // echo "done upgrade";die; |
|
272 | + break; |
|
273 | + case EE_System::req_type_downgrade: |
|
274 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
275 | + //its possible migrations are no longer required |
|
276 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
277 | + $this->_handle_core_version_change($espresso_db_update); |
|
278 | + break; |
|
279 | + case EE_System::req_type_normal: |
|
280 | + default: |
|
281 | + // $this->_maybe_redirect_to_ee_about(); |
|
282 | + break; |
|
283 | + } |
|
284 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * Updates the list of installed versions and sets hooks for |
|
291 | + * initializing the database later during the request |
|
292 | + * |
|
293 | + * @param array $espresso_db_update |
|
294 | + */ |
|
295 | + protected function _handle_core_version_change($espresso_db_update) |
|
296 | + { |
|
297 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
298 | + //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
299 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
300 | + array($this, 'initialize_db_if_no_migrations_required')); |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
307 | + * information about what versions of EE have been installed and activated, |
|
308 | + * NOT necessarily the state of the database |
|
309 | + * |
|
310 | + * @param null $espresso_db_update |
|
311 | + * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
312 | + * from the options table |
|
313 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
314 | + */ |
|
315 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
316 | + { |
|
317 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
318 | + if ( ! $espresso_db_update) { |
|
319 | + $espresso_db_update = get_option('espresso_db_update'); |
|
320 | + } |
|
321 | + // check that option is an array |
|
322 | + if ( ! is_array($espresso_db_update)) { |
|
323 | + // if option is FALSE, then it never existed |
|
324 | + if ($espresso_db_update === false) { |
|
325 | + // make $espresso_db_update an array and save option with autoload OFF |
|
326 | + $espresso_db_update = array(); |
|
327 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
328 | + } else { |
|
329 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
330 | + $espresso_db_update = array($espresso_db_update => array()); |
|
331 | + update_option('espresso_db_update', $espresso_db_update); |
|
332 | + } |
|
333 | + } else { |
|
334 | + $corrected_db_update = array(); |
|
335 | + //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
336 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
337 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
338 | + //the key is an int, and the value IS NOT an array |
|
339 | + //so it must be numerically-indexed, where values are versions installed... |
|
340 | + //fix it! |
|
341 | + $version_string = $should_be_array; |
|
342 | + $corrected_db_update[$version_string] = array('unknown-date'); |
|
343 | + } else { |
|
344 | + //ok it checks out |
|
345 | + $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
346 | + } |
|
347 | + } |
|
348 | + $espresso_db_update = $corrected_db_update; |
|
349 | + update_option('espresso_db_update', $espresso_db_update); |
|
350 | + } |
|
351 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
352 | + return $espresso_db_update; |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
359 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
360 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
361 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
362 | + * so that it will be done when migrations are finished |
|
363 | + * |
|
364 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
365 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
366 | + * This is a resource-intensive job |
|
367 | + * so we prefer to only do it when necessary |
|
368 | + * @return void |
|
369 | + */ |
|
370 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
371 | + { |
|
372 | + $request_type = $this->detect_req_type(); |
|
373 | + //only initialize system if we're not in maintenance mode. |
|
374 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
375 | + update_option('ee_flush_rewrite_rules', true); |
|
376 | + if ($verify_schema) { |
|
377 | + EEH_Activation::initialize_db_and_folders(); |
|
378 | + } |
|
379 | + EEH_Activation::initialize_db_content(); |
|
380 | + EEH_Activation::system_initialization(); |
|
381 | + if ($initialize_addons_too) { |
|
382 | + $this->initialize_addons(); |
|
383 | + } |
|
384 | + } else { |
|
385 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
386 | + } |
|
387 | + if ($request_type === EE_System::req_type_new_activation |
|
388 | + || $request_type === EE_System::req_type_reactivation |
|
389 | + || ( |
|
390 | + $request_type === EE_System::req_type_upgrade |
|
391 | + && $this->is_major_version_change() |
|
392 | + ) |
|
393 | + ) { |
|
394 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * Initializes the db for all registered addons |
|
402 | + */ |
|
403 | + public function initialize_addons() |
|
404 | + { |
|
405 | + //foreach registered addon, make sure its db is up-to-date too |
|
406 | + foreach ($this->registry->addons as $addon) { |
|
407 | + $addon->initialize_db_if_no_migrations_required(); |
|
408 | + } |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + |
|
413 | + /** |
|
414 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
415 | + * |
|
416 | + * @param array $version_history |
|
417 | + * @param string $current_version_to_add version to be added to the version history |
|
418 | + * @return boolean success as to whether or not this option was changed |
|
419 | + */ |
|
420 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
421 | + { |
|
422 | + if ( ! $version_history) { |
|
423 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
424 | + } |
|
425 | + if ($current_version_to_add == null) { |
|
426 | + $current_version_to_add = espresso_version(); |
|
427 | + } |
|
428 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
429 | + // re-save |
|
430 | + return update_option('espresso_db_update', $version_history); |
|
431 | + } |
|
432 | + |
|
433 | + |
|
434 | + |
|
435 | + /** |
|
436 | + * Detects if the current version indicated in the has existed in the list of |
|
437 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
438 | + * |
|
439 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
440 | + * If not supplied, fetches it from the options table. |
|
441 | + * Also, caches its result so later parts of the code can also know whether |
|
442 | + * there's been an update or not. This way we can add the current version to |
|
443 | + * espresso_db_update, but still know if this is a new install or not |
|
444 | + * @return int one of the constants on EE_System::req_type_ |
|
445 | + */ |
|
446 | + public function detect_req_type($espresso_db_update = null) |
|
447 | + { |
|
448 | + if ($this->_req_type === null) { |
|
449 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
450 | + : $this->fix_espresso_db_upgrade_option(); |
|
451 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
452 | + 'ee_espresso_activation', espresso_version()); |
|
453 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
454 | + } |
|
455 | + return $this->_req_type; |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + |
|
460 | + /** |
|
461 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
462 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
463 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
464 | + * |
|
465 | + * @param $activation_history |
|
466 | + * @return bool |
|
467 | + */ |
|
468 | + protected function _detect_major_version_change($activation_history) |
|
469 | + { |
|
470 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
471 | + $previous_version_parts = explode('.', $previous_version); |
|
472 | + $current_version_parts = explode('.', espresso_version()); |
|
473 | + return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
474 | + && ($previous_version_parts[0] !== $current_version_parts[0] |
|
475 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
476 | + ); |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + |
|
481 | + /** |
|
482 | + * Returns true if either the major or minor version of EE changed during this request. |
|
483 | + * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
484 | + * |
|
485 | + * @return bool |
|
486 | + */ |
|
487 | + public function is_major_version_change() |
|
488 | + { |
|
489 | + return $this->_major_version_change; |
|
490 | + } |
|
491 | + |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
496 | + * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
497 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
498 | + * just activated to (for core that will always be espresso_version()) |
|
499 | + * |
|
500 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
501 | + * ee plugin. for core that's 'espresso_db_update' |
|
502 | + * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
503 | + * indicate that this plugin was just activated |
|
504 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
505 | + * espresso_version()) |
|
506 | + * @return int one of the constants on EE_System::req_type_* |
|
507 | + */ |
|
508 | + public static function detect_req_type_given_activation_history( |
|
509 | + $activation_history_for_addon, |
|
510 | + $activation_indicator_option_name, |
|
511 | + $version_to_upgrade_to |
|
512 | + ) { |
|
513 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
514 | + if ($activation_history_for_addon) { |
|
515 | + //it exists, so this isn't a completely new install |
|
516 | + //check if this version already in that list of previously installed versions |
|
517 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
518 | + //it a version we haven't seen before |
|
519 | + if ($version_is_higher === 1) { |
|
520 | + $req_type = EE_System::req_type_upgrade; |
|
521 | + } else { |
|
522 | + $req_type = EE_System::req_type_downgrade; |
|
523 | + } |
|
524 | + delete_option($activation_indicator_option_name); |
|
525 | + } else { |
|
526 | + // its not an update. maybe a reactivation? |
|
527 | + if (get_option($activation_indicator_option_name, false)) { |
|
528 | + if ($version_is_higher === -1) { |
|
529 | + $req_type = EE_System::req_type_downgrade; |
|
530 | + } elseif ($version_is_higher === 0) { |
|
531 | + //we've seen this version before, but it's an activation. must be a reactivation |
|
532 | + $req_type = EE_System::req_type_reactivation; |
|
533 | + } else {//$version_is_higher === 1 |
|
534 | + $req_type = EE_System::req_type_upgrade; |
|
535 | + } |
|
536 | + delete_option($activation_indicator_option_name); |
|
537 | + } else { |
|
538 | + //we've seen this version before and the activation indicate doesn't show it was just activated |
|
539 | + if ($version_is_higher === -1) { |
|
540 | + $req_type = EE_System::req_type_downgrade; |
|
541 | + } elseif ($version_is_higher === 0) { |
|
542 | + //we've seen this version before and it's not an activation. its normal request |
|
543 | + $req_type = EE_System::req_type_normal; |
|
544 | + } else {//$version_is_higher === 1 |
|
545 | + $req_type = EE_System::req_type_upgrade; |
|
546 | + } |
|
547 | + } |
|
548 | + } |
|
549 | + } else { |
|
550 | + //brand new install |
|
551 | + $req_type = EE_System::req_type_new_activation; |
|
552 | + delete_option($activation_indicator_option_name); |
|
553 | + } |
|
554 | + return $req_type; |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + |
|
559 | + /** |
|
560 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
561 | + * the $activation_history_for_addon |
|
562 | + * |
|
563 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
564 | + * sometimes containing 'unknown-date' |
|
565 | + * @param string $version_to_upgrade_to (current version) |
|
566 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
567 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
568 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
569 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
570 | + */ |
|
571 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
572 | + { |
|
573 | + //find the most recently-activated version |
|
574 | + $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
575 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
576 | + } |
|
577 | + |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * Gets the most recently active version listed in the activation history, |
|
582 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
583 | + * |
|
584 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
585 | + * sometimes containing 'unknown-date' |
|
586 | + * @return string |
|
587 | + */ |
|
588 | + protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
589 | + { |
|
590 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
591 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
592 | + if (is_array($activation_history)) { |
|
593 | + foreach ($activation_history as $version => $times_activated) { |
|
594 | + //check there is a record of when this version was activated. Otherwise, |
|
595 | + //mark it as unknown |
|
596 | + if ( ! $times_activated) { |
|
597 | + $times_activated = array('unknown-date'); |
|
598 | + } |
|
599 | + if (is_string($times_activated)) { |
|
600 | + $times_activated = array($times_activated); |
|
601 | + } |
|
602 | + foreach ($times_activated as $an_activation) { |
|
603 | + if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
604 | + $most_recently_active_version = $version; |
|
605 | + $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
606 | + ? '1970-01-01 00:00:00' : $an_activation; |
|
607 | + } |
|
608 | + } |
|
609 | + } |
|
610 | + } |
|
611 | + return $most_recently_active_version; |
|
612 | + } |
|
613 | + |
|
614 | + |
|
615 | + |
|
616 | + /** |
|
617 | + * This redirects to the about EE page after activation |
|
618 | + * |
|
619 | + * @return void |
|
620 | + */ |
|
621 | + public function redirect_to_about_ee() |
|
622 | + { |
|
623 | + $notices = EE_Error::get_notices(false); |
|
624 | + //if current user is an admin and it's not an ajax or rest request |
|
625 | + if ( |
|
626 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
627 | + && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
628 | + && ! isset($notices['errors']) |
|
629 | + && apply_filters( |
|
630 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
631 | + $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
632 | + ) |
|
633 | + ) { |
|
634 | + $query_params = array('page' => 'espresso_about'); |
|
635 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
636 | + $query_params['new_activation'] = true; |
|
637 | + } |
|
638 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
639 | + $query_params['reactivation'] = true; |
|
640 | + } |
|
641 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
642 | + wp_safe_redirect($url); |
|
643 | + exit(); |
|
644 | + } |
|
645 | + } |
|
646 | + |
|
647 | + |
|
648 | + |
|
649 | + /** |
|
650 | + * load_core_configuration |
|
651 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
652 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
653 | + * |
|
654 | + * @return void |
|
655 | + */ |
|
656 | + public function load_core_configuration() |
|
657 | + { |
|
658 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
659 | + $this->registry->load_core('EE_Load_Textdomain'); |
|
660 | + //load textdomain |
|
661 | + EE_Load_Textdomain::load_textdomain(); |
|
662 | + // load and setup EE_Config and EE_Network_Config |
|
663 | + $this->registry->load_core('Config'); |
|
664 | + $this->registry->load_core('Network_Config'); |
|
665 | + // setup autoloaders |
|
666 | + // enable logging? |
|
667 | + if ($this->registry->CFG->admin->use_full_logging) { |
|
668 | + $this->registry->load_core('Log'); |
|
669 | + } |
|
670 | + // check for activation errors |
|
671 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
672 | + if ($activation_errors) { |
|
673 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
674 | + update_option('ee_plugin_activation_errors', false); |
|
675 | + } |
|
676 | + // get model names |
|
677 | + $this->_parse_model_names(); |
|
678 | + //load caf stuff a chance to play during the activation process too. |
|
679 | + $this->_maybe_brew_regular(); |
|
680 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
681 | + } |
|
682 | + |
|
683 | + |
|
684 | + |
|
685 | + /** |
|
686 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
687 | + * |
|
688 | + * @return void |
|
689 | + */ |
|
690 | + private function _parse_model_names() |
|
691 | + { |
|
692 | + //get all the files in the EE_MODELS folder that end in .model.php |
|
693 | + $models = glob(EE_MODELS . '*.model.php'); |
|
694 | + $model_names = array(); |
|
695 | + $non_abstract_db_models = array(); |
|
696 | + foreach ($models as $model) { |
|
697 | + // get model classname |
|
698 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
699 | + $short_name = str_replace('EEM_', '', $classname); |
|
700 | + $reflectionClass = new ReflectionClass($classname); |
|
701 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
702 | + $non_abstract_db_models[$short_name] = $classname; |
|
703 | + } |
|
704 | + $model_names[$short_name] = $classname; |
|
705 | + } |
|
706 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
707 | + $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', |
|
708 | + $non_abstract_db_models); |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
715 | + * that need to be setup before our EE_System launches. |
|
716 | + * |
|
717 | + * @return void |
|
718 | + */ |
|
719 | + private function _maybe_brew_regular() |
|
720 | + { |
|
721 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
722 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
723 | + } |
|
724 | + } |
|
725 | + |
|
726 | + |
|
727 | + |
|
728 | + /** |
|
729 | + * register_shortcodes_modules_and_widgets |
|
730 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
731 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
732 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
733 | + * |
|
734 | + * @access public |
|
735 | + * @return void |
|
736 | + */ |
|
737 | + public function register_shortcodes_modules_and_widgets() |
|
738 | + { |
|
739 | + try { |
|
740 | + // load, register, and add shortcodes the new way |
|
741 | + new ShortcodesManager( |
|
742 | + // and the old way, but we'll put it under control of the new system |
|
743 | + EE_Config::getLegacyShortcodesManager() |
|
744 | + ); |
|
745 | + } catch (Exception $exception) { |
|
746 | + new ExceptionStackTraceDisplay($exception); |
|
747 | + } |
|
748 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
749 | + // check for addons using old hookpoint |
|
750 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
751 | + $this->_incompatible_addon_error(); |
|
752 | + } |
|
753 | + } |
|
754 | + |
|
755 | + |
|
756 | + |
|
757 | + /** |
|
758 | + * _incompatible_addon_error |
|
759 | + * |
|
760 | + * @access public |
|
761 | + * @return void |
|
762 | + */ |
|
763 | + private function _incompatible_addon_error() |
|
764 | + { |
|
765 | + // get array of classes hooking into here |
|
766 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
767 | + if ( ! empty($class_names)) { |
|
768 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
769 | + 'event_espresso'); |
|
770 | + $msg .= '<ul>'; |
|
771 | + foreach ($class_names as $class_name) { |
|
772 | + $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
773 | + $class_name) . '</b></li>'; |
|
774 | + } |
|
775 | + $msg .= '</ul>'; |
|
776 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
777 | + 'event_espresso'); |
|
778 | + // save list of incompatible addons to wp-options for later use |
|
779 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
780 | + if (is_admin()) { |
|
781 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
782 | + } |
|
783 | + } |
|
784 | + } |
|
785 | + |
|
786 | + |
|
787 | + |
|
788 | + /** |
|
789 | + * brew_espresso |
|
790 | + * begins the process of setting hooks for initializing EE in the correct order |
|
791 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
792 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
793 | + * |
|
794 | + * @return void |
|
795 | + */ |
|
796 | + public function brew_espresso() |
|
797 | + { |
|
798 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
799 | + // load some final core systems |
|
800 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
801 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
802 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
803 | + add_action('init', array($this, 'load_controllers'), 7); |
|
804 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
805 | + add_action('init', array($this, 'initialize'), 10); |
|
806 | + add_action('init', array($this, 'initialize_last'), 100); |
|
807 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
808 | + add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
809 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
810 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
811 | + // pew pew pew |
|
812 | + $this->registry->load_core('PUE'); |
|
813 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
814 | + } |
|
815 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
816 | + } |
|
817 | + |
|
818 | + |
|
819 | + |
|
820 | + /** |
|
821 | + * set_hooks_for_core |
|
822 | + * |
|
823 | + * @access public |
|
824 | + * @return void |
|
825 | + */ |
|
826 | + public function set_hooks_for_core() |
|
827 | + { |
|
828 | + $this->_deactivate_incompatible_addons(); |
|
829 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
830 | + } |
|
831 | + |
|
832 | + |
|
833 | + |
|
834 | + /** |
|
835 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
836 | + * deactivates any addons considered incompatible with the current version of EE |
|
837 | + */ |
|
838 | + private function _deactivate_incompatible_addons() |
|
839 | + { |
|
840 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
841 | + if ( ! empty($incompatible_addons)) { |
|
842 | + $active_plugins = get_option('active_plugins', array()); |
|
843 | + foreach ($active_plugins as $active_plugin) { |
|
844 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
845 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
846 | + unset($_GET['activate']); |
|
847 | + espresso_deactivate_plugin($active_plugin); |
|
848 | + } |
|
849 | + } |
|
850 | + } |
|
851 | + } |
|
852 | + } |
|
853 | + |
|
854 | + |
|
855 | + |
|
856 | + /** |
|
857 | + * perform_activations_upgrades_and_migrations |
|
858 | + * |
|
859 | + * @access public |
|
860 | + * @return void |
|
861 | + */ |
|
862 | + public function perform_activations_upgrades_and_migrations() |
|
863 | + { |
|
864 | + //first check if we had previously attempted to setup EE's directories but failed |
|
865 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
866 | + EEH_Activation::create_upload_directories(); |
|
867 | + } |
|
868 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
869 | + } |
|
870 | + |
|
871 | + |
|
872 | + |
|
873 | + /** |
|
874 | + * load_CPTs_and_session |
|
875 | + * |
|
876 | + * @access public |
|
877 | + * @return void |
|
878 | + */ |
|
879 | + public function load_CPTs_and_session() |
|
880 | + { |
|
881 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
882 | + // register Custom Post Types |
|
883 | + $this->registry->load_core('Register_CPTs'); |
|
884 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
885 | + } |
|
886 | + |
|
887 | + |
|
888 | + |
|
889 | + /** |
|
890 | + * load_controllers |
|
891 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
892 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
893 | + * time |
|
894 | + * |
|
895 | + * @access public |
|
896 | + * @return void |
|
897 | + */ |
|
898 | + public function load_controllers() |
|
899 | + { |
|
900 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
901 | + // let's get it started |
|
902 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
903 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
904 | + $this->registry->load_core('Front_Controller'); |
|
905 | + } else if ( ! EE_FRONT_AJAX) { |
|
906 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
907 | + EE_Registry::instance()->load_core('Admin'); |
|
908 | + } |
|
909 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
910 | + } |
|
911 | + |
|
912 | + |
|
913 | + |
|
914 | + /** |
|
915 | + * core_loaded_and_ready |
|
916 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
917 | + * |
|
918 | + * @access public |
|
919 | + * @return void |
|
920 | + */ |
|
921 | + public function core_loaded_and_ready() |
|
922 | + { |
|
923 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
924 | + // load_espresso_template_tags |
|
925 | + if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
926 | + require_once(EE_PUBLIC . 'template_tags.php'); |
|
927 | + } |
|
928 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
929 | + $this->registry->load_core('Session'); |
|
930 | + } |
|
931 | + |
|
932 | + |
|
933 | + |
|
934 | + /** |
|
935 | + * initialize |
|
936 | + * this is the best place to begin initializing client code |
|
937 | + * |
|
938 | + * @access public |
|
939 | + * @return void |
|
940 | + */ |
|
941 | + public function initialize() |
|
942 | + { |
|
943 | + do_action('AHEE__EE_System__initialize'); |
|
944 | + } |
|
945 | + |
|
946 | + |
|
947 | + |
|
948 | + /** |
|
949 | + * initialize_last |
|
950 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
951 | + * initialize has done so |
|
952 | + * |
|
953 | + * @access public |
|
954 | + * @return void |
|
955 | + */ |
|
956 | + public function initialize_last() |
|
957 | + { |
|
958 | + do_action('AHEE__EE_System__initialize_last'); |
|
959 | + } |
|
960 | + |
|
961 | + |
|
962 | + |
|
963 | + /** |
|
964 | + * set_hooks_for_shortcodes_modules_and_addons |
|
965 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
966 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
967 | + * |
|
968 | + * @access public |
|
969 | + * @return void |
|
970 | + */ |
|
971 | + public function set_hooks_for_shortcodes_modules_and_addons() |
|
972 | + { |
|
973 | + // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
974 | + } |
|
975 | + |
|
976 | + |
|
977 | + |
|
978 | + /** |
|
979 | + * do_not_cache |
|
980 | + * sets no cache headers and defines no cache constants for WP plugins |
|
981 | + * |
|
982 | + * @access public |
|
983 | + * @return void |
|
984 | + */ |
|
985 | + public static function do_not_cache() |
|
986 | + { |
|
987 | + // set no cache constants |
|
988 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
989 | + define('DONOTCACHEPAGE', true); |
|
990 | + } |
|
991 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
992 | + define('DONOTCACHCEOBJECT', true); |
|
993 | + } |
|
994 | + if ( ! defined('DONOTCACHEDB')) { |
|
995 | + define('DONOTCACHEDB', true); |
|
996 | + } |
|
997 | + // add no cache headers |
|
998 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
999 | + // plus a little extra for nginx and Google Chrome |
|
1000 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1001 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1002 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1003 | + } |
|
1004 | + |
|
1005 | + |
|
1006 | + |
|
1007 | + /** |
|
1008 | + * extra_nocache_headers |
|
1009 | + * |
|
1010 | + * @access public |
|
1011 | + * @param $headers |
|
1012 | + * @return array |
|
1013 | + */ |
|
1014 | + public static function extra_nocache_headers($headers) |
|
1015 | + { |
|
1016 | + // for NGINX |
|
1017 | + $headers['X-Accel-Expires'] = 0; |
|
1018 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1019 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1020 | + return $headers; |
|
1021 | + } |
|
1022 | + |
|
1023 | + |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * nocache_headers |
|
1027 | + * |
|
1028 | + * @access public |
|
1029 | + * @return void |
|
1030 | + */ |
|
1031 | + public static function nocache_headers() |
|
1032 | + { |
|
1033 | + nocache_headers(); |
|
1034 | + } |
|
1035 | + |
|
1036 | + |
|
1037 | + |
|
1038 | + /** |
|
1039 | + * espresso_toolbar_items |
|
1040 | + * |
|
1041 | + * @access public |
|
1042 | + * @param WP_Admin_Bar $admin_bar |
|
1043 | + * @return void |
|
1044 | + */ |
|
1045 | + public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1046 | + { |
|
1047 | + // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1048 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1049 | + || defined('DOING_AJAX') |
|
1050 | + || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1051 | + ) { |
|
1052 | + return; |
|
1053 | + } |
|
1054 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1055 | + $menu_class = 'espresso_menu_item_class'; |
|
1056 | + //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1057 | + //because they're only defined in each of their respective constructors |
|
1058 | + //and this might be a frontend request, in which case they aren't available |
|
1059 | + $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1060 | + $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1061 | + $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1062 | + //Top Level |
|
1063 | + $admin_bar->add_menu(array( |
|
1064 | + 'id' => 'espresso-toolbar', |
|
1065 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1066 | + . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1067 | + . '</span>', |
|
1068 | + 'href' => $events_admin_url, |
|
1069 | + 'meta' => array( |
|
1070 | + 'title' => __('Event Espresso', 'event_espresso'), |
|
1071 | + 'class' => $menu_class . 'first', |
|
1072 | + ), |
|
1073 | + )); |
|
1074 | + //Events |
|
1075 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1076 | + $admin_bar->add_menu(array( |
|
1077 | + 'id' => 'espresso-toolbar-events', |
|
1078 | + 'parent' => 'espresso-toolbar', |
|
1079 | + 'title' => __('Events', 'event_espresso'), |
|
1080 | + 'href' => $events_admin_url, |
|
1081 | + 'meta' => array( |
|
1082 | + 'title' => __('Events', 'event_espresso'), |
|
1083 | + 'target' => '', |
|
1084 | + 'class' => $menu_class, |
|
1085 | + ), |
|
1086 | + )); |
|
1087 | + } |
|
1088 | + if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1089 | + //Events Add New |
|
1090 | + $admin_bar->add_menu(array( |
|
1091 | + 'id' => 'espresso-toolbar-events-new', |
|
1092 | + 'parent' => 'espresso-toolbar-events', |
|
1093 | + 'title' => __('Add New', 'event_espresso'), |
|
1094 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1095 | + 'meta' => array( |
|
1096 | + 'title' => __('Add New', 'event_espresso'), |
|
1097 | + 'target' => '', |
|
1098 | + 'class' => $menu_class, |
|
1099 | + ), |
|
1100 | + )); |
|
1101 | + } |
|
1102 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1103 | + //Current post |
|
1104 | + global $post; |
|
1105 | + if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1106 | + 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1107 | + ) { |
|
1108 | + //Events Edit Current Event |
|
1109 | + $admin_bar->add_menu(array( |
|
1110 | + 'id' => 'espresso-toolbar-events-edit', |
|
1111 | + 'parent' => 'espresso-toolbar-events', |
|
1112 | + 'title' => __('Edit Event', 'event_espresso'), |
|
1113 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1114 | + $events_admin_url), |
|
1115 | + 'meta' => array( |
|
1116 | + 'title' => __('Edit Event', 'event_espresso'), |
|
1117 | + 'target' => '', |
|
1118 | + 'class' => $menu_class, |
|
1119 | + ), |
|
1120 | + )); |
|
1121 | + } |
|
1122 | + } |
|
1123 | + //Events View |
|
1124 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1125 | + 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1126 | + ) { |
|
1127 | + $admin_bar->add_menu(array( |
|
1128 | + 'id' => 'espresso-toolbar-events-view', |
|
1129 | + 'parent' => 'espresso-toolbar-events', |
|
1130 | + 'title' => __('View', 'event_espresso'), |
|
1131 | + 'href' => $events_admin_url, |
|
1132 | + 'meta' => array( |
|
1133 | + 'title' => __('View', 'event_espresso'), |
|
1134 | + 'target' => '', |
|
1135 | + 'class' => $menu_class, |
|
1136 | + ), |
|
1137 | + )); |
|
1138 | + } |
|
1139 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1140 | + //Events View All |
|
1141 | + $admin_bar->add_menu(array( |
|
1142 | + 'id' => 'espresso-toolbar-events-all', |
|
1143 | + 'parent' => 'espresso-toolbar-events-view', |
|
1144 | + 'title' => __('All', 'event_espresso'), |
|
1145 | + 'href' => $events_admin_url, |
|
1146 | + 'meta' => array( |
|
1147 | + 'title' => __('All', 'event_espresso'), |
|
1148 | + 'target' => '', |
|
1149 | + 'class' => $menu_class, |
|
1150 | + ), |
|
1151 | + )); |
|
1152 | + } |
|
1153 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1154 | + 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1155 | + ) { |
|
1156 | + //Events View Today |
|
1157 | + $admin_bar->add_menu(array( |
|
1158 | + 'id' => 'espresso-toolbar-events-today', |
|
1159 | + 'parent' => 'espresso-toolbar-events-view', |
|
1160 | + 'title' => __('Today', 'event_espresso'), |
|
1161 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1162 | + $events_admin_url), |
|
1163 | + 'meta' => array( |
|
1164 | + 'title' => __('Today', 'event_espresso'), |
|
1165 | + 'target' => '', |
|
1166 | + 'class' => $menu_class, |
|
1167 | + ), |
|
1168 | + )); |
|
1169 | + } |
|
1170 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1171 | + 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1172 | + ) { |
|
1173 | + //Events View This Month |
|
1174 | + $admin_bar->add_menu(array( |
|
1175 | + 'id' => 'espresso-toolbar-events-month', |
|
1176 | + 'parent' => 'espresso-toolbar-events-view', |
|
1177 | + 'title' => __('This Month', 'event_espresso'), |
|
1178 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1179 | + $events_admin_url), |
|
1180 | + 'meta' => array( |
|
1181 | + 'title' => __('This Month', 'event_espresso'), |
|
1182 | + 'target' => '', |
|
1183 | + 'class' => $menu_class, |
|
1184 | + ), |
|
1185 | + )); |
|
1186 | + } |
|
1187 | + //Registration Overview |
|
1188 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1189 | + 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1190 | + ) { |
|
1191 | + $admin_bar->add_menu(array( |
|
1192 | + 'id' => 'espresso-toolbar-registrations', |
|
1193 | + 'parent' => 'espresso-toolbar', |
|
1194 | + 'title' => __('Registrations', 'event_espresso'), |
|
1195 | + 'href' => $reg_admin_url, |
|
1196 | + 'meta' => array( |
|
1197 | + 'title' => __('Registrations', 'event_espresso'), |
|
1198 | + 'target' => '', |
|
1199 | + 'class' => $menu_class, |
|
1200 | + ), |
|
1201 | + )); |
|
1202 | + } |
|
1203 | + //Registration Overview Today |
|
1204 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1205 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1206 | + ) { |
|
1207 | + $admin_bar->add_menu(array( |
|
1208 | + 'id' => 'espresso-toolbar-registrations-today', |
|
1209 | + 'parent' => 'espresso-toolbar-registrations', |
|
1210 | + 'title' => __('Today', 'event_espresso'), |
|
1211 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1212 | + $reg_admin_url), |
|
1213 | + 'meta' => array( |
|
1214 | + 'title' => __('Today', 'event_espresso'), |
|
1215 | + 'target' => '', |
|
1216 | + 'class' => $menu_class, |
|
1217 | + ), |
|
1218 | + )); |
|
1219 | + } |
|
1220 | + //Registration Overview Today Completed |
|
1221 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1222 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1223 | + ) { |
|
1224 | + $admin_bar->add_menu(array( |
|
1225 | + 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1226 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1227 | + 'title' => __('Approved', 'event_espresso'), |
|
1228 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1229 | + 'action' => 'default', |
|
1230 | + 'status' => 'today', |
|
1231 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1232 | + ), $reg_admin_url), |
|
1233 | + 'meta' => array( |
|
1234 | + 'title' => __('Approved', 'event_espresso'), |
|
1235 | + 'target' => '', |
|
1236 | + 'class' => $menu_class, |
|
1237 | + ), |
|
1238 | + )); |
|
1239 | + } |
|
1240 | + //Registration Overview Today Pending\ |
|
1241 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1242 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1243 | + ) { |
|
1244 | + $admin_bar->add_menu(array( |
|
1245 | + 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1246 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1247 | + 'title' => __('Pending', 'event_espresso'), |
|
1248 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1249 | + 'action' => 'default', |
|
1250 | + 'status' => 'today', |
|
1251 | + 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1252 | + ), $reg_admin_url), |
|
1253 | + 'meta' => array( |
|
1254 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1255 | + 'target' => '', |
|
1256 | + 'class' => $menu_class, |
|
1257 | + ), |
|
1258 | + )); |
|
1259 | + } |
|
1260 | + //Registration Overview Today Incomplete |
|
1261 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1262 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1263 | + ) { |
|
1264 | + $admin_bar->add_menu(array( |
|
1265 | + 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1266 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1267 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1268 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1269 | + 'action' => 'default', |
|
1270 | + 'status' => 'today', |
|
1271 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1272 | + ), $reg_admin_url), |
|
1273 | + 'meta' => array( |
|
1274 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1275 | + 'target' => '', |
|
1276 | + 'class' => $menu_class, |
|
1277 | + ), |
|
1278 | + )); |
|
1279 | + } |
|
1280 | + //Registration Overview Today Incomplete |
|
1281 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1282 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1283 | + ) { |
|
1284 | + $admin_bar->add_menu(array( |
|
1285 | + 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1286 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1287 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1288 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1289 | + 'action' => 'default', |
|
1290 | + 'status' => 'today', |
|
1291 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1292 | + ), $reg_admin_url), |
|
1293 | + 'meta' => array( |
|
1294 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1295 | + 'target' => '', |
|
1296 | + 'class' => $menu_class, |
|
1297 | + ), |
|
1298 | + )); |
|
1299 | + } |
|
1300 | + //Registration Overview This Month |
|
1301 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1302 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1303 | + ) { |
|
1304 | + $admin_bar->add_menu(array( |
|
1305 | + 'id' => 'espresso-toolbar-registrations-month', |
|
1306 | + 'parent' => 'espresso-toolbar-registrations', |
|
1307 | + 'title' => __('This Month', 'event_espresso'), |
|
1308 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1309 | + $reg_admin_url), |
|
1310 | + 'meta' => array( |
|
1311 | + 'title' => __('This Month', 'event_espresso'), |
|
1312 | + 'target' => '', |
|
1313 | + 'class' => $menu_class, |
|
1314 | + ), |
|
1315 | + )); |
|
1316 | + } |
|
1317 | + //Registration Overview This Month Approved |
|
1318 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1319 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1320 | + ) { |
|
1321 | + $admin_bar->add_menu(array( |
|
1322 | + 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1323 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1324 | + 'title' => __('Approved', 'event_espresso'), |
|
1325 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1326 | + 'action' => 'default', |
|
1327 | + 'status' => 'month', |
|
1328 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1329 | + ), $reg_admin_url), |
|
1330 | + 'meta' => array( |
|
1331 | + 'title' => __('Approved', 'event_espresso'), |
|
1332 | + 'target' => '', |
|
1333 | + 'class' => $menu_class, |
|
1334 | + ), |
|
1335 | + )); |
|
1336 | + } |
|
1337 | + //Registration Overview This Month Pending |
|
1338 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1339 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1340 | + ) { |
|
1341 | + $admin_bar->add_menu(array( |
|
1342 | + 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1343 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1344 | + 'title' => __('Pending', 'event_espresso'), |
|
1345 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1346 | + 'action' => 'default', |
|
1347 | + 'status' => 'month', |
|
1348 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1349 | + ), $reg_admin_url), |
|
1350 | + 'meta' => array( |
|
1351 | + 'title' => __('Pending', 'event_espresso'), |
|
1352 | + 'target' => '', |
|
1353 | + 'class' => $menu_class, |
|
1354 | + ), |
|
1355 | + )); |
|
1356 | + } |
|
1357 | + //Registration Overview This Month Not Approved |
|
1358 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1359 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1360 | + ) { |
|
1361 | + $admin_bar->add_menu(array( |
|
1362 | + 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1363 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1364 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1365 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1366 | + 'action' => 'default', |
|
1367 | + 'status' => 'month', |
|
1368 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1369 | + ), $reg_admin_url), |
|
1370 | + 'meta' => array( |
|
1371 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1372 | + 'target' => '', |
|
1373 | + 'class' => $menu_class, |
|
1374 | + ), |
|
1375 | + )); |
|
1376 | + } |
|
1377 | + //Registration Overview This Month Cancelled |
|
1378 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1379 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1380 | + ) { |
|
1381 | + $admin_bar->add_menu(array( |
|
1382 | + 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1383 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1384 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1385 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1386 | + 'action' => 'default', |
|
1387 | + 'status' => 'month', |
|
1388 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1389 | + ), $reg_admin_url), |
|
1390 | + 'meta' => array( |
|
1391 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1392 | + 'target' => '', |
|
1393 | + 'class' => $menu_class, |
|
1394 | + ), |
|
1395 | + )); |
|
1396 | + } |
|
1397 | + //Extensions & Services |
|
1398 | + if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1399 | + 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1400 | + ) { |
|
1401 | + $admin_bar->add_menu(array( |
|
1402 | + 'id' => 'espresso-toolbar-extensions-and-services', |
|
1403 | + 'parent' => 'espresso-toolbar', |
|
1404 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1405 | + 'href' => $extensions_admin_url, |
|
1406 | + 'meta' => array( |
|
1407 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1408 | + 'target' => '', |
|
1409 | + 'class' => $menu_class, |
|
1410 | + ), |
|
1411 | + )); |
|
1412 | + } |
|
1413 | + } |
|
1414 | + |
|
1415 | + |
|
1416 | + |
|
1417 | + /** |
|
1418 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1419 | + * never returned with the function. |
|
1420 | + * |
|
1421 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
1422 | + * @return array |
|
1423 | + */ |
|
1424 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
1425 | + { |
|
1426 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1427 | + } |
|
1428 | + |
|
1429 | + |
|
1430 | + |
|
1431 | + |
|
1432 | + |
|
1433 | + |
|
1434 | + /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
|
1435 | + /** |
|
1436 | + * wp_enqueue_scripts |
|
1437 | + * |
|
1438 | + * @access public |
|
1439 | + * @return void |
|
1440 | + */ |
|
1441 | + public function wp_enqueue_scripts() |
|
1442 | + { |
|
1443 | + // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
|
1444 | + if (apply_filters('FHEE_load_EE_System_scripts', true)) { |
|
1445 | + // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1446 | + if (apply_filters('FHEE_load_jquery_validate', false)) { |
|
1447 | + // register jQuery Validate and additional methods |
|
1448 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1449 | + array('jquery'), '1.15.0', true); |
|
1450 | + wp_register_script('jquery-validate-extra-methods', |
|
1451 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1452 | + array('jquery', 'jquery-validate'), '1.15.0', true); |
|
1453 | + } |
|
1454 | + } |
|
1455 | + } |
|
1456 | 1456 | |
1457 | 1457 | |
1458 | 1458 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @var integer $limit |
29 | 29 | */ |
30 | - private $limit = 10; |
|
30 | + private $limit = 10; |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @var string $css_class |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function __construct($args = array()) |
70 | 70 | { |
71 | - $args = $this->parseArgs((array)$args); |
|
71 | + $args = $this->parseArgs((array) $args); |
|
72 | 72 | $this->setupEventQueryHelper(); |
73 | 73 | $this->setupFilters(); |
74 | 74 | $args = $this->getQueryArgs($args); |
@@ -19,206 +19,206 @@ |
||
19 | 19 | class EventListQuery extends WP_Query |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var string $title |
|
24 | - */ |
|
25 | - private $title; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var integer $limit |
|
29 | - */ |
|
30 | - private $limit = 10; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string $css_class |
|
34 | - */ |
|
35 | - private $css_class; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var boolean $show_expired |
|
39 | - */ |
|
40 | - private $show_expired = false; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string $month |
|
44 | - */ |
|
45 | - private $month; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var string $category_slug |
|
49 | - */ |
|
50 | - private $category_slug; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var string $order_by |
|
54 | - */ |
|
55 | - private $order_by; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var string $sort |
|
59 | - */ |
|
60 | - private $sort; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var boolean $show_title |
|
64 | - */ |
|
65 | - private $show_title = true; |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * EE_Event_List_Query Constructor * |
|
71 | - * |
|
72 | - * @param array $args |
|
73 | - */ |
|
74 | - public function __construct($args = array()) |
|
75 | - { |
|
76 | - $args = $this->parseArgs((array)$args); |
|
77 | - $this->setupEventQueryHelper(); |
|
78 | - $this->setupFilters(); |
|
79 | - $args = $this->getQueryArgs($args); |
|
80 | - // run the query |
|
81 | - parent::__construct($args); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @param array $args |
|
88 | - * @return array |
|
89 | - */ |
|
90 | - private function parseArgs(array $args) |
|
91 | - { |
|
92 | - // incoming args could be a mix of WP query args + EE shortcode args |
|
93 | - foreach ($args as $property => $value) { |
|
94 | - // if the arg is a property of this class, then it's an EE shortcode arg |
|
95 | - if (property_exists($this, $property)) { |
|
96 | - // set the property value |
|
97 | - $this->{$property} = $value; |
|
98 | - // then remove it from the array of args that will later be passed to WP_Query() |
|
99 | - unset($args[$property]); |
|
100 | - } |
|
101 | - } |
|
102 | - return $args; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - private function setupEventQueryHelper() |
|
108 | - { |
|
109 | - //add query filters |
|
110 | - EEH_Event_Query::add_query_filters(); |
|
111 | - // set params that will get used by the filters |
|
112 | - EEH_Event_Query::set_query_params( |
|
113 | - $this->month, |
|
114 | - $this->category_slug, |
|
115 | - $this->show_expired, |
|
116 | - $this->order_by, |
|
117 | - $this->sort |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - |
|
123 | - private function setupFilters() |
|
124 | - { |
|
125 | - // first off, let's remove any filters from previous queries |
|
126 | - remove_filter( |
|
127 | - 'FHEE__archive_espresso_events_template__show_header', |
|
128 | - array($this, 'show_event_list_title') |
|
129 | - ); |
|
130 | - remove_filter( |
|
131 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
132 | - array($this, 'event_list_title') |
|
133 | - ); |
|
134 | - remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
135 | - // Event List Title ? |
|
136 | - add_filter( |
|
137 | - 'FHEE__archive_espresso_events_template__show_header', |
|
138 | - array($this, 'show_event_list_title') |
|
139 | - ); |
|
140 | - add_filter( |
|
141 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
142 | - array($this, 'event_list_title'), |
|
143 | - 10, |
|
144 | - 1 |
|
145 | - ); |
|
146 | - // add the css class |
|
147 | - add_filter( |
|
148 | - 'FHEE__content_espresso_events__event_class', |
|
149 | - array($this, 'event_list_css'), |
|
150 | - 10, |
|
151 | - 1 |
|
152 | - ); |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - |
|
157 | - private function getQueryArgs(array $args) |
|
158 | - { |
|
159 | - // the current "page" we are viewing |
|
160 | - $paged = max(1, get_query_var('paged')); |
|
161 | - // Force these args |
|
162 | - return array_merge( |
|
163 | - $args, |
|
164 | - array( |
|
165 | - 'post_type' => 'espresso_events', |
|
166 | - 'posts_per_page' => $this->limit, |
|
167 | - 'update_post_term_cache' => false, |
|
168 | - 'update_post_meta_cache' => false, |
|
169 | - 'paged' => $paged, |
|
170 | - 'offset' => ($paged - 1) * $this->limit, |
|
171 | - ) |
|
172 | - ); |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * show_event_list_title |
|
179 | - * |
|
180 | - * @return boolean |
|
181 | - */ |
|
182 | - public function show_event_list_title() |
|
183 | - { |
|
184 | - return filter_var( |
|
185 | - $this->show_title, |
|
186 | - FILTER_VALIDATE_BOOLEAN |
|
187 | - ); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * callback for FHEE__archive_espresso_events_template__upcoming_events_h1 filter |
|
194 | - * |
|
195 | - * @param string $event_list_title |
|
196 | - * @return string |
|
197 | - */ |
|
198 | - public function event_list_title($event_list_title = '') |
|
199 | - { |
|
200 | - if ( ! empty($this->title)) { |
|
201 | - return $this->title; |
|
202 | - } |
|
203 | - return $event_list_title; |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * callback for FHEE__content_espresso_events__event_class filter |
|
210 | - * |
|
211 | - * @param string $event_list_css |
|
212 | - * @return string |
|
213 | - */ |
|
214 | - public function event_list_css($event_list_css = '') |
|
215 | - { |
|
216 | - $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
217 | - $event_list_css .= ! empty($this->css_class) ? $this->css_class : ''; |
|
218 | - $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
219 | - $event_list_css .= ! empty($this->category_slug) ? $this->category_slug : ''; |
|
220 | - return $event_list_css; |
|
221 | - } |
|
22 | + /** |
|
23 | + * @var string $title |
|
24 | + */ |
|
25 | + private $title; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var integer $limit |
|
29 | + */ |
|
30 | + private $limit = 10; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string $css_class |
|
34 | + */ |
|
35 | + private $css_class; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var boolean $show_expired |
|
39 | + */ |
|
40 | + private $show_expired = false; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string $month |
|
44 | + */ |
|
45 | + private $month; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var string $category_slug |
|
49 | + */ |
|
50 | + private $category_slug; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var string $order_by |
|
54 | + */ |
|
55 | + private $order_by; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var string $sort |
|
59 | + */ |
|
60 | + private $sort; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var boolean $show_title |
|
64 | + */ |
|
65 | + private $show_title = true; |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * EE_Event_List_Query Constructor * |
|
71 | + * |
|
72 | + * @param array $args |
|
73 | + */ |
|
74 | + public function __construct($args = array()) |
|
75 | + { |
|
76 | + $args = $this->parseArgs((array)$args); |
|
77 | + $this->setupEventQueryHelper(); |
|
78 | + $this->setupFilters(); |
|
79 | + $args = $this->getQueryArgs($args); |
|
80 | + // run the query |
|
81 | + parent::__construct($args); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @param array $args |
|
88 | + * @return array |
|
89 | + */ |
|
90 | + private function parseArgs(array $args) |
|
91 | + { |
|
92 | + // incoming args could be a mix of WP query args + EE shortcode args |
|
93 | + foreach ($args as $property => $value) { |
|
94 | + // if the arg is a property of this class, then it's an EE shortcode arg |
|
95 | + if (property_exists($this, $property)) { |
|
96 | + // set the property value |
|
97 | + $this->{$property} = $value; |
|
98 | + // then remove it from the array of args that will later be passed to WP_Query() |
|
99 | + unset($args[$property]); |
|
100 | + } |
|
101 | + } |
|
102 | + return $args; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + private function setupEventQueryHelper() |
|
108 | + { |
|
109 | + //add query filters |
|
110 | + EEH_Event_Query::add_query_filters(); |
|
111 | + // set params that will get used by the filters |
|
112 | + EEH_Event_Query::set_query_params( |
|
113 | + $this->month, |
|
114 | + $this->category_slug, |
|
115 | + $this->show_expired, |
|
116 | + $this->order_by, |
|
117 | + $this->sort |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + |
|
123 | + private function setupFilters() |
|
124 | + { |
|
125 | + // first off, let's remove any filters from previous queries |
|
126 | + remove_filter( |
|
127 | + 'FHEE__archive_espresso_events_template__show_header', |
|
128 | + array($this, 'show_event_list_title') |
|
129 | + ); |
|
130 | + remove_filter( |
|
131 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
132 | + array($this, 'event_list_title') |
|
133 | + ); |
|
134 | + remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
135 | + // Event List Title ? |
|
136 | + add_filter( |
|
137 | + 'FHEE__archive_espresso_events_template__show_header', |
|
138 | + array($this, 'show_event_list_title') |
|
139 | + ); |
|
140 | + add_filter( |
|
141 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
142 | + array($this, 'event_list_title'), |
|
143 | + 10, |
|
144 | + 1 |
|
145 | + ); |
|
146 | + // add the css class |
|
147 | + add_filter( |
|
148 | + 'FHEE__content_espresso_events__event_class', |
|
149 | + array($this, 'event_list_css'), |
|
150 | + 10, |
|
151 | + 1 |
|
152 | + ); |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + |
|
157 | + private function getQueryArgs(array $args) |
|
158 | + { |
|
159 | + // the current "page" we are viewing |
|
160 | + $paged = max(1, get_query_var('paged')); |
|
161 | + // Force these args |
|
162 | + return array_merge( |
|
163 | + $args, |
|
164 | + array( |
|
165 | + 'post_type' => 'espresso_events', |
|
166 | + 'posts_per_page' => $this->limit, |
|
167 | + 'update_post_term_cache' => false, |
|
168 | + 'update_post_meta_cache' => false, |
|
169 | + 'paged' => $paged, |
|
170 | + 'offset' => ($paged - 1) * $this->limit, |
|
171 | + ) |
|
172 | + ); |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * show_event_list_title |
|
179 | + * |
|
180 | + * @return boolean |
|
181 | + */ |
|
182 | + public function show_event_list_title() |
|
183 | + { |
|
184 | + return filter_var( |
|
185 | + $this->show_title, |
|
186 | + FILTER_VALIDATE_BOOLEAN |
|
187 | + ); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * callback for FHEE__archive_espresso_events_template__upcoming_events_h1 filter |
|
194 | + * |
|
195 | + * @param string $event_list_title |
|
196 | + * @return string |
|
197 | + */ |
|
198 | + public function event_list_title($event_list_title = '') |
|
199 | + { |
|
200 | + if ( ! empty($this->title)) { |
|
201 | + return $this->title; |
|
202 | + } |
|
203 | + return $event_list_title; |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * callback for FHEE__content_espresso_events__event_class filter |
|
210 | + * |
|
211 | + * @param string $event_list_css |
|
212 | + * @return string |
|
213 | + */ |
|
214 | + public function event_list_css($event_list_css = '') |
|
215 | + { |
|
216 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
217 | + $event_list_css .= ! empty($this->css_class) ? $this->css_class : ''; |
|
218 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
219 | + $event_list_css .= ! empty($this->category_slug) ? $this->category_slug : ''; |
|
220 | + return $event_list_css; |
|
221 | + } |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | // End of file EventListQuery.php |