@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * @access public |
| 51 | 51 | * @param \WP $WP |
| 52 | 52 | */ |
| 53 | - public function run( WP $WP ) { |
|
| 54 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
| 53 | + public function run(WP $WP) { |
|
| 54 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | * @param array $attributes |
| 63 | 63 | * @return string |
| 64 | 64 | */ |
| 65 | - public function process_shortcode( $attributes = array() ) { |
|
| 66 | - extract( $attributes ); |
|
| 67 | - $event_id = isset( $event_id ) ? $event_id : 0; |
|
| 68 | - $event = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $event_id ); |
|
| 65 | + public function process_shortcode($attributes = array()) { |
|
| 66 | + extract($attributes); |
|
| 67 | + $event_id = isset($event_id) ? $event_id : 0; |
|
| 68 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
| 69 | 69 | ob_start(); |
| 70 | - do_action( 'AHEE__EES_Espresso_Ticket_Selector__process_shortcode__begin', $event_id ); |
|
| 71 | - espresso_ticket_selector( $event ); |
|
| 72 | - do_action( 'AHEE__EES_Espresso_Ticket_Selector__process_shortcode__end', $event_id ); |
|
| 70 | + do_action('AHEE__EES_Espresso_Ticket_Selector__process_shortcode__begin', $event_id); |
|
| 71 | + espresso_ticket_selector($event); |
|
| 72 | + do_action('AHEE__EES_Espresso_Ticket_Selector__process_shortcode__end', $event_id); |
|
| 73 | 73 | return ob_get_clean(); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | class EED_Ticket_Selector extends EED_Module { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector |
|
| 27 | - */ |
|
| 28 | - private static $ticket_selector; |
|
| 25 | + /** |
|
| 26 | + * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector |
|
| 27 | + */ |
|
| 28 | + private static $ticket_selector; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button |
|
| 32 | - */ |
|
| 33 | - private static $iframe_embed_button; |
|
| 30 | + /** |
|
| 31 | + * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button |
|
| 32 | + */ |
|
| 33 | + private static $iframe_embed_button; |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | // routing |
| 62 | 62 | EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
| 63 | 63 | EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
| 64 | - EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections'); |
|
| 65 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
| 64 | + EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections'); |
|
| 65 | + add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
| 66 | 66 | add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
| 67 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 ); |
|
| 68 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
| 69 | - EED_Ticket_Selector::loadIframeAssets(); |
|
| 70 | - } |
|
| 67 | + add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 ); |
|
| 68 | + add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
| 69 | + EED_Ticket_Selector::loadIframeAssets(); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | 10 |
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Make sure assets for the ticket selector are loaded on the espresso registrations route so admin side |
|
| 91 | - * registrations work. |
|
| 92 | - */ |
|
| 89 | + /** |
|
| 90 | + * Make sure assets for the ticket selector are loaded on the espresso registrations route so admin side |
|
| 91 | + * registrations work. |
|
| 92 | + */ |
|
| 93 | 93 | add_action( |
| 94 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration', |
|
| 95 | - array('EED_Ticket_Selector', 'set_definitions'), |
|
| 96 | - 10 |
|
| 97 | - ); |
|
| 98 | - } |
|
| 94 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration', |
|
| 95 | + array('EED_Ticket_Selector', 'set_definitions'), |
|
| 96 | + 10 |
|
| 97 | + ); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | |
@@ -111,23 +111,23 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | //if config is not set, initialize |
| 113 | 113 | if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
| 114 | - \EED_Ticket_Selector::instance()->set_config(); |
|
| 115 | - \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
| 114 | + \EED_Ticket_Selector::instance()->set_config(); |
|
| 115 | + \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | - * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector |
|
| 123 | - */ |
|
| 124 | - public static function ticketSelector() |
|
| 125 | - { |
|
| 126 | - if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
| 127 | - EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(); |
|
| 128 | - } |
|
| 129 | - return EED_Ticket_Selector::$ticket_selector; |
|
| 130 | - } |
|
| 122 | + * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector |
|
| 123 | + */ |
|
| 124 | + public static function ticketSelector() |
|
| 125 | + { |
|
| 126 | + if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
| 127 | + EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(); |
|
| 128 | + } |
|
| 129 | + return EED_Ticket_Selector::$ticket_selector; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | |
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * creates buttons for selecting number of attendees for an event |
|
| 185 | - * |
|
| 186 | - * @access public |
|
| 187 | - * @param WP_Post|int $event |
|
| 188 | - * @param bool $view_details |
|
| 189 | - * @return string |
|
| 190 | - * @throws \EE_Error |
|
| 191 | - */ |
|
| 183 | + /** |
|
| 184 | + * creates buttons for selecting number of attendees for an event |
|
| 185 | + * |
|
| 186 | + * @access public |
|
| 187 | + * @param WP_Post|int $event |
|
| 188 | + * @param bool $view_details |
|
| 189 | + * @return string |
|
| 190 | + * @throws \EE_Error |
|
| 191 | + */ |
|
| 192 | 192 | public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
| 193 | 193 | return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details ); |
| 194 | 194 | } |
@@ -209,244 +209,244 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | |
| 211 | 211 | |
| 212 | - /** |
|
| 213 | - * cancel_ticket_selections |
|
| 214 | - * |
|
| 215 | - * @access public |
|
| 216 | - * @return string |
|
| 217 | - */ |
|
| 218 | - public static function cancel_ticket_selections() |
|
| 219 | - { |
|
| 220 | - $form = new ProcessTicketSelector(); |
|
| 221 | - return $form->cancelTicketSelections(); |
|
| 222 | - } |
|
| 212 | + /** |
|
| 213 | + * cancel_ticket_selections |
|
| 214 | + * |
|
| 215 | + * @access public |
|
| 216 | + * @return string |
|
| 217 | + */ |
|
| 218 | + public static function cancel_ticket_selections() |
|
| 219 | + { |
|
| 220 | + $form = new ProcessTicketSelector(); |
|
| 221 | + return $form->cancelTicketSelections(); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | - * @return void |
|
| 228 | - */ |
|
| 227 | + * @return void |
|
| 228 | + */ |
|
| 229 | 229 | public static function translate_js_strings() { |
| 230 | - EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__( |
|
| 231 | - 'please select a datetime', 'event_espresso' |
|
| 232 | - ); |
|
| 233 | - } |
|
| 230 | + EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__( |
|
| 231 | + 'please select a datetime', 'event_espresso' |
|
| 232 | + ); |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | - * load js |
|
| 239 | - * |
|
| 240 | - * @access public |
|
| 241 | - * @return void |
|
| 242 | - */ |
|
| 238 | + * load js |
|
| 239 | + * |
|
| 240 | + * @access public |
|
| 241 | + * @return void |
|
| 242 | + */ |
|
| 243 | 243 | public static function load_tckt_slctr_assets() { |
| 244 | 244 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
| 245 | - // add some style |
|
| 246 | - wp_register_style( |
|
| 247 | - 'ticket_selector', |
|
| 248 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css', |
|
| 249 | - array(), |
|
| 250 | - EVENT_ESPRESSO_VERSION |
|
| 251 | - ); |
|
| 252 | - wp_enqueue_style('ticket_selector'); |
|
| 253 | - // make it dance |
|
| 254 | - wp_register_script( |
|
| 255 | - 'ticket_selector', |
|
| 256 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', |
|
| 257 | - array('espresso_core'), |
|
| 258 | - EVENT_ESPRESSO_VERSION, |
|
| 259 | - TRUE |
|
| 260 | - ); |
|
| 245 | + // add some style |
|
| 246 | + wp_register_style( |
|
| 247 | + 'ticket_selector', |
|
| 248 | + TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css', |
|
| 249 | + array(), |
|
| 250 | + EVENT_ESPRESSO_VERSION |
|
| 251 | + ); |
|
| 252 | + wp_enqueue_style('ticket_selector'); |
|
| 253 | + // make it dance |
|
| 254 | + wp_register_script( |
|
| 255 | + 'ticket_selector', |
|
| 256 | + TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', |
|
| 257 | + array('espresso_core'), |
|
| 258 | + EVENT_ESPRESSO_VERSION, |
|
| 259 | + TRUE |
|
| 260 | + ); |
|
| 261 | 261 | wp_enqueue_script('ticket_selector'); |
| 262 | - require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'); |
|
| 263 | - \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
| 264 | - } |
|
| 262 | + require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'); |
|
| 263 | + \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * @return void |
|
| 271 | + */ |
|
| 272 | + public static function loadIframeAssets() |
|
| 273 | + { |
|
| 274 | + // for event lists |
|
| 275 | + add_filter( |
|
| 276 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
| 277 | + array('EED_Ticket_Selector', 'iframeCss') |
|
| 278 | + ); |
|
| 279 | + add_filter( |
|
| 280 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
| 281 | + array('EED_Ticket_Selector', 'iframeJs') |
|
| 282 | + ); |
|
| 283 | + // for ticket selectors |
|
| 284 | + add_filter( |
|
| 285 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
| 286 | + array('EED_Ticket_Selector', 'iframeCss') |
|
| 287 | + ); |
|
| 288 | + add_filter( |
|
| 289 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
| 290 | + array('EED_Ticket_Selector', 'iframeJs') |
|
| 291 | + ); |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
| 298 | + * |
|
| 299 | + * @param array $iframe_css |
|
| 300 | + * @return array |
|
| 301 | + */ |
|
| 302 | + public static function iframeCss(array $iframe_css) |
|
| 303 | + { |
|
| 304 | + $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
| 305 | + return $iframe_css; |
|
| 265 | 306 | } |
| 266 | 307 | |
| 267 | 308 | |
| 268 | 309 | |
| 269 | - /** |
|
| 270 | - * @return void |
|
| 271 | - */ |
|
| 272 | - public static function loadIframeAssets() |
|
| 273 | - { |
|
| 274 | - // for event lists |
|
| 275 | - add_filter( |
|
| 276 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
| 277 | - array('EED_Ticket_Selector', 'iframeCss') |
|
| 278 | - ); |
|
| 279 | - add_filter( |
|
| 280 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
| 281 | - array('EED_Ticket_Selector', 'iframeJs') |
|
| 282 | - ); |
|
| 283 | - // for ticket selectors |
|
| 284 | - add_filter( |
|
| 285 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
| 286 | - array('EED_Ticket_Selector', 'iframeCss') |
|
| 287 | - ); |
|
| 288 | - add_filter( |
|
| 289 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
| 290 | - array('EED_Ticket_Selector', 'iframeJs') |
|
| 291 | - ); |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
| 298 | - * |
|
| 299 | - * @param array $iframe_css |
|
| 300 | - * @return array |
|
| 301 | - */ |
|
| 302 | - public static function iframeCss(array $iframe_css) |
|
| 303 | - { |
|
| 304 | - $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
| 305 | - return $iframe_css; |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
| 312 | - * |
|
| 313 | - * @param array $iframe_js |
|
| 314 | - * @return array |
|
| 315 | - */ |
|
| 316 | - public static function iframeJs(array $iframe_js) |
|
| 317 | - { |
|
| 318 | - $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
| 319 | - return $iframe_js; |
|
| 320 | - } |
|
| 310 | + /** |
|
| 311 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
| 312 | + * |
|
| 313 | + * @param array $iframe_js |
|
| 314 | + * @return array |
|
| 315 | + */ |
|
| 316 | + public static function iframeJs(array $iframe_js) |
|
| 317 | + { |
|
| 318 | + $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
| 319 | + return $iframe_js; |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | 322 | |
| 323 | 323 | /****************************** DEPRECATED ******************************/ |
| 324 | 324 | |
| 325 | 325 | |
| 326 | 326 | |
| 327 | - /** |
|
| 328 | - * @deprecated |
|
| 329 | - * @return string |
|
| 330 | - * @throws \EE_Error |
|
| 331 | - */ |
|
| 332 | - public static function display_view_details_btn() |
|
| 333 | - { |
|
| 334 | - // todo add doing_it_wrong() notice during next major version |
|
| 335 | - return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * @deprecated |
|
| 342 | - * @return string |
|
| 343 | - * @throws \EE_Error |
|
| 344 | - */ |
|
| 345 | - public static function display_ticket_selector_submit() |
|
| 346 | - { |
|
| 347 | - // todo add doing_it_wrong() notice during next major version |
|
| 348 | - return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * @deprecated |
|
| 355 | - * @param string $permalink_string |
|
| 356 | - * @param int $id |
|
| 357 | - * @param string $new_title |
|
| 358 | - * @param string $new_slug |
|
| 359 | - * @return string |
|
| 360 | - */ |
|
| 361 | - public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
| 362 | - { |
|
| 363 | - // todo add doing_it_wrong() notice during next major version |
|
| 364 | - if ( |
|
| 365 | - \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
| 366 | - && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
| 367 | - ) { |
|
| 368 | - $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
| 369 | - $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
| 370 | - } |
|
| 371 | - return ''; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * @deprecated |
|
| 378 | - * @param int $ID |
|
| 379 | - * @param string $external_url |
|
| 380 | - * @return string |
|
| 381 | - */ |
|
| 382 | - public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
| 383 | - { |
|
| 384 | - // todo add doing_it_wrong() notice during next major version |
|
| 385 | - return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * @deprecated |
|
| 392 | - * @return string |
|
| 393 | - */ |
|
| 394 | - public static function ticket_selector_form_close() |
|
| 395 | - { |
|
| 396 | - // todo add doing_it_wrong() notice during next major version |
|
| 397 | - return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * @deprecated |
|
| 404 | - * @return string |
|
| 405 | - */ |
|
| 406 | - public static function no_tkt_slctr_end_dv() |
|
| 407 | - { |
|
| 408 | - // todo add doing_it_wrong() notice during next major version |
|
| 409 | - return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * @deprecated 4.9.13 |
|
| 416 | - * @return string |
|
| 417 | - */ |
|
| 418 | - public static function tkt_slctr_end_dv() |
|
| 419 | - { |
|
| 420 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * @deprecated |
|
| 427 | - * @return string |
|
| 428 | - */ |
|
| 429 | - public static function clear_tkt_slctr() |
|
| 430 | - { |
|
| 431 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * @deprecated |
|
| 438 | - */ |
|
| 439 | - public static function load_tckt_slctr_assets_admin() |
|
| 440 | - { |
|
| 441 | - // todo add doing_it_wrong() notice during next major version |
|
| 442 | - if ( |
|
| 443 | - \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
| 444 | - && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
| 445 | - ) { |
|
| 446 | - $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
| 447 | - $iframe_embed_button->embedButtonAssets(); |
|
| 448 | - } |
|
| 449 | - } |
|
| 327 | + /** |
|
| 328 | + * @deprecated |
|
| 329 | + * @return string |
|
| 330 | + * @throws \EE_Error |
|
| 331 | + */ |
|
| 332 | + public static function display_view_details_btn() |
|
| 333 | + { |
|
| 334 | + // todo add doing_it_wrong() notice during next major version |
|
| 335 | + return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * @deprecated |
|
| 342 | + * @return string |
|
| 343 | + * @throws \EE_Error |
|
| 344 | + */ |
|
| 345 | + public static function display_ticket_selector_submit() |
|
| 346 | + { |
|
| 347 | + // todo add doing_it_wrong() notice during next major version |
|
| 348 | + return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * @deprecated |
|
| 355 | + * @param string $permalink_string |
|
| 356 | + * @param int $id |
|
| 357 | + * @param string $new_title |
|
| 358 | + * @param string $new_slug |
|
| 359 | + * @return string |
|
| 360 | + */ |
|
| 361 | + public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
| 362 | + { |
|
| 363 | + // todo add doing_it_wrong() notice during next major version |
|
| 364 | + if ( |
|
| 365 | + \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
| 366 | + && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
| 367 | + ) { |
|
| 368 | + $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
| 369 | + $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
| 370 | + } |
|
| 371 | + return ''; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * @deprecated |
|
| 378 | + * @param int $ID |
|
| 379 | + * @param string $external_url |
|
| 380 | + * @return string |
|
| 381 | + */ |
|
| 382 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
| 383 | + { |
|
| 384 | + // todo add doing_it_wrong() notice during next major version |
|
| 385 | + return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * @deprecated |
|
| 392 | + * @return string |
|
| 393 | + */ |
|
| 394 | + public static function ticket_selector_form_close() |
|
| 395 | + { |
|
| 396 | + // todo add doing_it_wrong() notice during next major version |
|
| 397 | + return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * @deprecated |
|
| 404 | + * @return string |
|
| 405 | + */ |
|
| 406 | + public static function no_tkt_slctr_end_dv() |
|
| 407 | + { |
|
| 408 | + // todo add doing_it_wrong() notice during next major version |
|
| 409 | + return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * @deprecated 4.9.13 |
|
| 416 | + * @return string |
|
| 417 | + */ |
|
| 418 | + public static function tkt_slctr_end_dv() |
|
| 419 | + { |
|
| 420 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * @deprecated |
|
| 427 | + * @return string |
|
| 428 | + */ |
|
| 429 | + public static function clear_tkt_slctr() |
|
| 430 | + { |
|
| 431 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + |
|
| 435 | + |
|
| 436 | + /** |
|
| 437 | + * @deprecated |
|
| 438 | + */ |
|
| 439 | + public static function load_tckt_slctr_assets_admin() |
|
| 440 | + { |
|
| 441 | + // todo add doing_it_wrong() notice during next major version |
|
| 442 | + if ( |
|
| 443 | + \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
| 444 | + && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
| 445 | + ) { |
|
| 446 | + $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
| 447 | + $iframe_embed_button->embedButtonAssets(); |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | 451 | |
| 452 | 452 | } |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | use EventEspresso\modules\ticket_selector\TicketSelectorIframe; |
| 4 | 4 | use EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton; |
| 5 | 5 | |
| 6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 7 | - exit( 'No direct script access allowed' ); |
|
| 6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 7 | + exit('No direct script access allowed'); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | * @return EED_Ticket_Selector |
| 39 | 39 | */ |
| 40 | 40 | public static function instance() { |
| 41 | - return parent::get_instance( __CLASS__ ); |
|
| 41 | + return parent::get_instance(__CLASS__); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | |
| 46 | - protected function set_config(){ |
|
| 47 | - $this->set_config_section( 'template_settings' ); |
|
| 48 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
| 49 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
| 46 | + protected function set_config() { |
|
| 47 | + $this->set_config_section('template_settings'); |
|
| 48 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
| 49 | + $this->set_config_name('EED_Ticket_Selector'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public static function set_hooks() { |
| 61 | 61 | // routing |
| 62 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
| 63 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
| 62 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
| 63 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
| 64 | 64 | EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections'); |
| 65 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
| 66 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
| 67 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 ); |
|
| 68 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
| 65 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
| 66 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
| 67 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0); |
|
| 68 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
| 69 | 69 | EED_Ticket_Selector::loadIframeAssets(); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | // to load assets for "espresso_events" page on the "edit" route (action) |
| 83 | 83 | add_action( |
| 84 | 84 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit', |
| 85 | - array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ), |
|
| 85 | + array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'), |
|
| 86 | 86 | 10 |
| 87 | 87 | ); |
| 88 | 88 | |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | * @return void |
| 107 | 107 | */ |
| 108 | 108 | public static function set_definitions() { |
| 109 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
| 110 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
| 109 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
| 110 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
| 111 | 111 | |
| 112 | 112 | //if config is not set, initialize |
| 113 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
| 113 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
| 114 | 114 | \EED_Ticket_Selector::instance()->set_config(); |
| 115 | 115 | \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
| 116 | 116 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param WP $WP |
| 138 | 138 | * @return void |
| 139 | 139 | */ |
| 140 | - public function run( $WP ) {} |
|
| 140 | + public function run($WP) {} |
|
| 141 | 141 | |
| 142 | 142 | |
| 143 | 143 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @return \EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton |
| 146 | 146 | */ |
| 147 | 147 | public static function getIframeEmbedButton() { |
| 148 | - if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton ) { |
|
| 148 | + if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) { |
|
| 149 | 149 | self::$iframe_embed_button = new TicketSelectorIframeEmbedButton(); |
| 150 | 150 | } |
| 151 | 151 | return self::$iframe_embed_button; |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | * @return string |
| 190 | 190 | * @throws \EE_Error |
| 191 | 191 | */ |
| 192 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
| 193 | - return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details ); |
|
| 192 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
| 193 | + return EED_Ticket_Selector::ticketSelector()->display($event, $view_details); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | * @return void |
| 242 | 242 | */ |
| 243 | 243 | public static function load_tckt_slctr_assets() { |
| 244 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
| 244 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
| 245 | 245 | // add some style |
| 246 | 246 | wp_register_style( |
| 247 | 247 | 'ticket_selector', |
| 248 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css', |
|
| 248 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css', |
|
| 249 | 249 | array(), |
| 250 | 250 | EVENT_ESPRESSO_VERSION |
| 251 | 251 | ); |
@@ -253,13 +253,13 @@ discard block |
||
| 253 | 253 | // make it dance |
| 254 | 254 | wp_register_script( |
| 255 | 255 | 'ticket_selector', |
| 256 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', |
|
| 256 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js', |
|
| 257 | 257 | array('espresso_core'), |
| 258 | 258 | EVENT_ESPRESSO_VERSION, |
| 259 | 259 | TRUE |
| 260 | 260 | ); |
| 261 | 261 | wp_enqueue_script('ticket_selector'); |
| 262 | - require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'); |
|
| 262 | + require_once(EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'); |
|
| 263 | 263 | \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | public static function iframeCss(array $iframe_css) |
| 303 | 303 | { |
| 304 | - $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
| 304 | + $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'; |
|
| 305 | 305 | return $iframe_css; |
| 306 | 306 | } |
| 307 | 307 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | public static function iframeJs(array $iframe_js) |
| 317 | 317 | { |
| 318 | - $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
| 318 | + $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js'; |
|
| 319 | 319 | return $iframe_js; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -440,8 +440,8 @@ discard block |
||
| 440 | 440 | { |
| 441 | 441 | // todo add doing_it_wrong() notice during next major version |
| 442 | 442 | if ( |
| 443 | - \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
| 444 | - && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
| 443 | + \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
| 444 | + && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
| 445 | 445 | ) { |
| 446 | 446 | $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
| 447 | 447 | $iframe_embed_button->embedButtonAssets(); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('ABSPATH')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /* |
| 5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
| 40 | 40 | * @since 4.0 |
| 41 | 41 | */ |
| 42 | 42 | if (function_exists('espresso_version')) { |
| 43 | - /** |
|
| 44 | - * espresso_duplicate_plugin_error |
|
| 45 | - * displays if more than one version of EE is activated at the same time |
|
| 46 | - */ |
|
| 47 | - function espresso_duplicate_plugin_error() |
|
| 48 | - { |
|
| 49 | - ?> |
|
| 43 | + /** |
|
| 44 | + * espresso_duplicate_plugin_error |
|
| 45 | + * displays if more than one version of EE is activated at the same time |
|
| 46 | + */ |
|
| 47 | + function espresso_duplicate_plugin_error() |
|
| 48 | + { |
|
| 49 | + ?> |
|
| 50 | 50 | <div class="error"> |
| 51 | 51 | <p> |
| 52 | 52 | <?php echo esc_html__( |
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - /** |
|
| 97 | - * espresso_version |
|
| 98 | - * Returns the plugin version |
|
| 99 | - * |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - function espresso_version() |
|
| 103 | - { |
|
| 104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.37.rc.008'); |
|
| 105 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + /** |
|
| 97 | + * espresso_version |
|
| 98 | + * Returns the plugin version |
|
| 99 | + * |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + function espresso_version() |
|
| 103 | + { |
|
| 104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.37.rc.008'); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // define versions |
|
| 108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | - if ( ! defined('DS')) { |
|
| 115 | - define('DS', '/'); |
|
| 116 | - } |
|
| 117 | - if ( ! defined('PS')) { |
|
| 118 | - define('PS', PATH_SEPARATOR); |
|
| 119 | - } |
|
| 120 | - if ( ! defined('SP')) { |
|
| 121 | - define('SP', ' '); |
|
| 122 | - } |
|
| 123 | - if ( ! defined('EENL')) { |
|
| 124 | - define('EENL', "\n"); |
|
| 125 | - } |
|
| 126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | - // define the plugin directory and URL |
|
| 128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | - // main root folder paths |
|
| 132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | - // core system paths |
|
| 141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | - // gateways |
|
| 154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | - // asset URL paths |
|
| 157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | - // define upload paths |
|
| 164 | - $uploads = wp_upload_dir(); |
|
| 165 | - // define the uploads directory and URL |
|
| 166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | - // define the templates directory and URL |
|
| 169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | - // define the gateway directory and URL |
|
| 172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | - // languages folder/path |
|
| 175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | - //check for dompdf fonts in uploads |
|
| 178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | - } |
|
| 181 | - //ajax constants |
|
| 182 | - define( |
|
| 183 | - 'EE_FRONT_AJAX', |
|
| 184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | - ); |
|
| 186 | - define( |
|
| 187 | - 'EE_ADMIN_AJAX', |
|
| 188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | - ); |
|
| 190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | - //want to change its default value! or find when -1 means infinity |
|
| 193 | - define('EE_INF_IN_DB', -1); |
|
| 194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | - define('EE_DEBUG', false); |
|
| 196 | - // for older WP versions |
|
| 197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | - } |
|
| 200 | - /** |
|
| 201 | - * espresso_plugin_activation |
|
| 202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | - */ |
|
| 204 | - function espresso_plugin_activation() |
|
| 205 | - { |
|
| 206 | - update_option('ee_espresso_activation', true); |
|
| 207 | - } |
|
| 107 | + // define versions |
|
| 108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | + if ( ! defined('DS')) { |
|
| 115 | + define('DS', '/'); |
|
| 116 | + } |
|
| 117 | + if ( ! defined('PS')) { |
|
| 118 | + define('PS', PATH_SEPARATOR); |
|
| 119 | + } |
|
| 120 | + if ( ! defined('SP')) { |
|
| 121 | + define('SP', ' '); |
|
| 122 | + } |
|
| 123 | + if ( ! defined('EENL')) { |
|
| 124 | + define('EENL', "\n"); |
|
| 125 | + } |
|
| 126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | + // define the plugin directory and URL |
|
| 128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | + // main root folder paths |
|
| 132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | + // core system paths |
|
| 141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | + // gateways |
|
| 154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | + // asset URL paths |
|
| 157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | + // define upload paths |
|
| 164 | + $uploads = wp_upload_dir(); |
|
| 165 | + // define the uploads directory and URL |
|
| 166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | + // define the templates directory and URL |
|
| 169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | + // define the gateway directory and URL |
|
| 172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | + // languages folder/path |
|
| 175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | + //check for dompdf fonts in uploads |
|
| 178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | + } |
|
| 181 | + //ajax constants |
|
| 182 | + define( |
|
| 183 | + 'EE_FRONT_AJAX', |
|
| 184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | + ); |
|
| 186 | + define( |
|
| 187 | + 'EE_ADMIN_AJAX', |
|
| 188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | + ); |
|
| 190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | + //want to change its default value! or find when -1 means infinity |
|
| 193 | + define('EE_INF_IN_DB', -1); |
|
| 194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | + define('EE_DEBUG', false); |
|
| 196 | + // for older WP versions |
|
| 197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | + } |
|
| 200 | + /** |
|
| 201 | + * espresso_plugin_activation |
|
| 202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | + */ |
|
| 204 | + function espresso_plugin_activation() |
|
| 205 | + { |
|
| 206 | + update_option('ee_espresso_activation', true); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | - /** |
|
| 211 | - * espresso_load_error_handling |
|
| 212 | - * this function loads EE's class for handling exceptions and errors |
|
| 213 | - */ |
|
| 214 | - function espresso_load_error_handling() |
|
| 215 | - { |
|
| 216 | - // load debugging tools |
|
| 217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | - EEH_Debug_Tools::instance(); |
|
| 220 | - } |
|
| 221 | - // load error handling |
|
| 222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | - } else { |
|
| 225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | - } |
|
| 227 | - } |
|
| 209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | + /** |
|
| 211 | + * espresso_load_error_handling |
|
| 212 | + * this function loads EE's class for handling exceptions and errors |
|
| 213 | + */ |
|
| 214 | + function espresso_load_error_handling() |
|
| 215 | + { |
|
| 216 | + // load debugging tools |
|
| 217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | + EEH_Debug_Tools::instance(); |
|
| 220 | + } |
|
| 221 | + // load error handling |
|
| 222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | + } else { |
|
| 225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * espresso_load_required |
|
| 231 | - * given a class name and path, this function will load that file or throw an exception |
|
| 232 | - * |
|
| 233 | - * @param string $classname |
|
| 234 | - * @param string $full_path_to_file |
|
| 235 | - * @throws EE_Error |
|
| 236 | - */ |
|
| 237 | - function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | - { |
|
| 239 | - static $error_handling_loaded = false; |
|
| 240 | - if ( ! $error_handling_loaded) { |
|
| 241 | - espresso_load_error_handling(); |
|
| 242 | - $error_handling_loaded = true; |
|
| 243 | - } |
|
| 244 | - if (is_readable($full_path_to_file)) { |
|
| 245 | - require_once($full_path_to_file); |
|
| 246 | - } else { |
|
| 247 | - throw new EE_Error ( |
|
| 248 | - sprintf( |
|
| 249 | - esc_html__( |
|
| 250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | - 'event_espresso' |
|
| 252 | - ), |
|
| 253 | - $classname |
|
| 254 | - ) |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - } |
|
| 229 | + /** |
|
| 230 | + * espresso_load_required |
|
| 231 | + * given a class name and path, this function will load that file or throw an exception |
|
| 232 | + * |
|
| 233 | + * @param string $classname |
|
| 234 | + * @param string $full_path_to_file |
|
| 235 | + * @throws EE_Error |
|
| 236 | + */ |
|
| 237 | + function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | + { |
|
| 239 | + static $error_handling_loaded = false; |
|
| 240 | + if ( ! $error_handling_loaded) { |
|
| 241 | + espresso_load_error_handling(); |
|
| 242 | + $error_handling_loaded = true; |
|
| 243 | + } |
|
| 244 | + if (is_readable($full_path_to_file)) { |
|
| 245 | + require_once($full_path_to_file); |
|
| 246 | + } else { |
|
| 247 | + throw new EE_Error ( |
|
| 248 | + sprintf( |
|
| 249 | + esc_html__( |
|
| 250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | + 'event_espresso' |
|
| 252 | + ), |
|
| 253 | + $classname |
|
| 254 | + ) |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | - new EE_Bootstrap(); |
|
| 263 | - } |
|
| 259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | + new EE_Bootstrap(); |
|
| 263 | + } |
|
| 264 | 264 | } |
| 265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
| 266 | - /** |
|
| 267 | - * deactivate_plugin |
|
| 268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | - * |
|
| 270 | - * @access public |
|
| 271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | - * @return void |
|
| 273 | - */ |
|
| 274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | - { |
|
| 276 | - if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | - } |
|
| 279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | - deactivate_plugins($plugin_basename); |
|
| 281 | - } |
|
| 266 | + /** |
|
| 267 | + * deactivate_plugin |
|
| 268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | + * |
|
| 270 | + * @access public |
|
| 271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | + * @return void |
|
| 273 | + */ |
|
| 274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | + { |
|
| 276 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | + } |
|
| 279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | + deactivate_plugins($plugin_basename); |
|
| 281 | + } |
|
| 282 | 282 | } |
| 283 | 283 | \ No newline at end of file |
@@ -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 | |
@@ -15,89 +15,89 @@ discard block |
||
| 15 | 15 | class EE_Int_Normalization extends EE_Normalization_Strategy_Base |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /* |
|
| 18 | + /* |
|
| 19 | 19 | * regex pattern that matches for the following: |
| 20 | 20 | * * optional negative sign |
| 21 | 21 | * * one or more digits |
| 22 | 22 | */ |
| 23 | - const REGEX = '/^(-?)(\d+)$/'; |
|
| 23 | + const REGEX = '/^(-?)(\d+)$/'; |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @param string $value_to_normalize |
|
| 28 | - * @return int|mixed|string |
|
| 29 | - * @throws \EE_Validation_Error |
|
| 30 | - */ |
|
| 31 | - public function normalize($value_to_normalize) |
|
| 32 | - { |
|
| 33 | - if ($value_to_normalize === null) { |
|
| 34 | - return null; |
|
| 35 | - } |
|
| 36 | - if (is_int($value_to_normalize) || is_float($value_to_normalize)) { |
|
| 37 | - return (int)$value_to_normalize; |
|
| 38 | - } |
|
| 39 | - if (! is_string($value_to_normalize)) { |
|
| 40 | - throw new EE_Validation_Error( |
|
| 41 | - sprintf( |
|
| 42 | - __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), |
|
| 43 | - print_r($value_to_normalize, true), |
|
| 44 | - gettype($value_to_normalize) |
|
| 45 | - ) |
|
| 46 | - ); |
|
| 47 | - } |
|
| 48 | - $value_to_normalize = filter_var( |
|
| 49 | - $value_to_normalize, |
|
| 50 | - FILTER_SANITIZE_NUMBER_FLOAT, |
|
| 51 | - FILTER_FLAG_ALLOW_FRACTION |
|
| 52 | - ); |
|
| 53 | - if($value_to_normalize === ''){ |
|
| 54 | - return null; |
|
| 55 | - } |
|
| 56 | - $matches = array(); |
|
| 57 | - if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) { |
|
| 58 | - if (count($matches) === 3) { |
|
| 59 | - // if first match is the negative sign, |
|
| 60 | - // then the number needs to be multiplied by -1 to remain negative |
|
| 61 | - return $matches[1] === '-' |
|
| 62 | - ? (int)$matches[2] * -1 |
|
| 63 | - : (int)$matches[2]; |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - //find if this input has a int validation strategy |
|
| 67 | - //in which case, use its message |
|
| 68 | - $validation_error_message = null; |
|
| 69 | - foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
| 70 | - if ($validation_strategy instanceof EE_Int_Validation_Strategy) { |
|
| 71 | - $validation_error_message = $validation_strategy->get_validation_error_message(); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - //this really shouldn't ever happen because fields with a int normalization strategy |
|
| 75 | - //should also have a int validation strategy, but in case it doesnt use the default |
|
| 76 | - if (! $validation_error_message) { |
|
| 77 | - $default_validation_strategy = new EE_Int_Validation_Strategy(); |
|
| 78 | - $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
|
| 79 | - } |
|
| 80 | - throw new EE_Validation_Error($validation_error_message, 'numeric_only'); |
|
| 81 | - } |
|
| 26 | + /** |
|
| 27 | + * @param string $value_to_normalize |
|
| 28 | + * @return int|mixed|string |
|
| 29 | + * @throws \EE_Validation_Error |
|
| 30 | + */ |
|
| 31 | + public function normalize($value_to_normalize) |
|
| 32 | + { |
|
| 33 | + if ($value_to_normalize === null) { |
|
| 34 | + return null; |
|
| 35 | + } |
|
| 36 | + if (is_int($value_to_normalize) || is_float($value_to_normalize)) { |
|
| 37 | + return (int)$value_to_normalize; |
|
| 38 | + } |
|
| 39 | + if (! is_string($value_to_normalize)) { |
|
| 40 | + throw new EE_Validation_Error( |
|
| 41 | + sprintf( |
|
| 42 | + __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), |
|
| 43 | + print_r($value_to_normalize, true), |
|
| 44 | + gettype($value_to_normalize) |
|
| 45 | + ) |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | + $value_to_normalize = filter_var( |
|
| 49 | + $value_to_normalize, |
|
| 50 | + FILTER_SANITIZE_NUMBER_FLOAT, |
|
| 51 | + FILTER_FLAG_ALLOW_FRACTION |
|
| 52 | + ); |
|
| 53 | + if($value_to_normalize === ''){ |
|
| 54 | + return null; |
|
| 55 | + } |
|
| 56 | + $matches = array(); |
|
| 57 | + if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) { |
|
| 58 | + if (count($matches) === 3) { |
|
| 59 | + // if first match is the negative sign, |
|
| 60 | + // then the number needs to be multiplied by -1 to remain negative |
|
| 61 | + return $matches[1] === '-' |
|
| 62 | + ? (int)$matches[2] * -1 |
|
| 63 | + : (int)$matches[2]; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + //find if this input has a int validation strategy |
|
| 67 | + //in which case, use its message |
|
| 68 | + $validation_error_message = null; |
|
| 69 | + foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
| 70 | + if ($validation_strategy instanceof EE_Int_Validation_Strategy) { |
|
| 71 | + $validation_error_message = $validation_strategy->get_validation_error_message(); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + //this really shouldn't ever happen because fields with a int normalization strategy |
|
| 75 | + //should also have a int validation strategy, but in case it doesnt use the default |
|
| 76 | + if (! $validation_error_message) { |
|
| 77 | + $default_validation_strategy = new EE_Int_Validation_Strategy(); |
|
| 78 | + $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
|
| 79 | + } |
|
| 80 | + throw new EE_Validation_Error($validation_error_message, 'numeric_only'); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Converts the int into a string for use in teh html form |
|
| 87 | - * |
|
| 88 | - * @param int $normalized_value |
|
| 89 | - * @return string |
|
| 90 | - */ |
|
| 91 | - public function unnormalize($normalized_value) |
|
| 92 | - { |
|
| 93 | - if ($normalized_value === null || $normalized_value === '') { |
|
| 94 | - return ''; |
|
| 95 | - } |
|
| 96 | - if (empty($normalized_value)) { |
|
| 97 | - return '0'; |
|
| 98 | - } |
|
| 99 | - return "$normalized_value"; |
|
| 100 | - } |
|
| 85 | + /** |
|
| 86 | + * Converts the int into a string for use in teh html form |
|
| 87 | + * |
|
| 88 | + * @param int $normalized_value |
|
| 89 | + * @return string |
|
| 90 | + */ |
|
| 91 | + public function unnormalize($normalized_value) |
|
| 92 | + { |
|
| 93 | + if ($normalized_value === null || $normalized_value === '') { |
|
| 94 | + return ''; |
|
| 95 | + } |
|
| 96 | + if (empty($normalized_value)) { |
|
| 97 | + return '0'; |
|
| 98 | + } |
|
| 99 | + return "$normalized_value"; |
|
| 100 | + } |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // End of file EE_Int_Normalization.strategy.php |
| 104 | 104 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | return null; |
| 35 | 35 | } |
| 36 | 36 | if (is_int($value_to_normalize) || is_float($value_to_normalize)) { |
| 37 | - return (int)$value_to_normalize; |
|
| 37 | + return (int) $value_to_normalize; |
|
| 38 | 38 | } |
| 39 | - if (! is_string($value_to_normalize)) { |
|
| 39 | + if ( ! is_string($value_to_normalize)) { |
|
| 40 | 40 | throw new EE_Validation_Error( |
| 41 | 41 | sprintf( |
| 42 | 42 | __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | FILTER_SANITIZE_NUMBER_FLOAT, |
| 51 | 51 | FILTER_FLAG_ALLOW_FRACTION |
| 52 | 52 | ); |
| 53 | - if($value_to_normalize === ''){ |
|
| 53 | + if ($value_to_normalize === '') { |
|
| 54 | 54 | return null; |
| 55 | 55 | } |
| 56 | 56 | $matches = array(); |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | // if first match is the negative sign, |
| 60 | 60 | // then the number needs to be multiplied by -1 to remain negative |
| 61 | 61 | return $matches[1] === '-' |
| 62 | - ? (int)$matches[2] * -1 |
|
| 63 | - : (int)$matches[2]; |
|
| 62 | + ? (int) $matches[2] * -1 |
|
| 63 | + : (int) $matches[2]; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | //find if this input has a int validation strategy |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | //this really shouldn't ever happen because fields with a int normalization strategy |
| 75 | 75 | //should also have a int validation strategy, but in case it doesnt use the default |
| 76 | - if (! $validation_error_message) { |
|
| 76 | + if ( ! $validation_error_message) { |
|
| 77 | 77 | $default_validation_strategy = new EE_Int_Validation_Strategy(); |
| 78 | 78 | $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
| 79 | 79 | } |