Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like EED_Ticket_Selector often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EED_Ticket_Selector, and based on these observations, apply Extract Interface, too.
| 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
||
| 27 | class EED_Ticket_Selector extends EED_Module { |
||
| 28 | |||
| 29 | /** |
||
| 30 | * event that ticket selector is being generated for |
||
| 31 | * |
||
| 32 | * @access protected |
||
| 33 | * @var \EE_Event |
||
| 34 | */ |
||
| 35 | protected static $_event = NULL; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * array of datetimes and the spaces available for them |
||
| 39 | * |
||
| 40 | * @access private |
||
| 41 | * @var array |
||
| 42 | */ |
||
| 43 | private static $_available_spaces = array(); |
||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | /** |
||
| 49 | * Used to flag when the ticket selector is being called from an external iframe. |
||
| 50 | * |
||
| 51 | * @var bool |
||
| 52 | */ |
||
| 53 | protected static $_in_iframe = false; |
||
| 54 | |||
| 55 | |||
| 56 | /** |
||
| 57 | * @return EED_Ticket_Selector |
||
| 58 | */ |
||
| 59 | public static function instance() { |
||
| 60 | return parent::get_instance( __CLASS__ ); |
||
|
|
|||
| 61 | } |
||
| 62 | |||
| 63 | |||
| 64 | |||
| 65 | protected function set_config(){ |
||
| 66 | $this->set_config_section( 'template_settings' ); |
||
| 67 | $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
||
| 68 | $this->set_config_name( 'EED_Ticket_Selector' ); |
||
| 69 | } |
||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | /** |
||
| 76 | * set_hooks - for hooking into EE Core, other modules, etc |
||
| 77 | * |
||
| 78 | * @access public |
||
| 79 | * @return void |
||
| 80 | */ |
||
| 81 | public static function set_hooks() { |
||
| 82 | // routing |
||
| 83 | EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
||
| 84 | EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
||
| 85 | add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
||
| 86 | //add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 ); |
||
| 87 | add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
||
| 88 | //add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 ); |
||
| 89 | //add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 ); |
||
| 90 | add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
||
| 91 | } |
||
| 92 | |||
| 93 | |||
| 94 | |||
| 95 | /** |
||
| 96 | * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
||
| 97 | * |
||
| 98 | * @access public |
||
| 99 | * @return void |
||
| 100 | */ |
||
| 101 | public static function set_hooks_admin() { |
||
| 102 | add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
||
| 103 | //add button for iframe code to event editor. |
||
| 104 | add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 ); |
||
| 105 | add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 ); |
||
| 106 | } |
||
| 107 | |||
| 108 | |||
| 109 | |||
| 110 | /** |
||
| 111 | * set_definitions |
||
| 112 | * |
||
| 113 | * @access public |
||
| 114 | * @return void |
||
| 115 | */ |
||
| 116 | public static function set_definitions() { |
||
| 117 | define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
||
| 118 | define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
||
| 119 | |||
| 120 | //if config is not set, initialize |
||
| 121 | //If config is not set, set it. |
||
| 122 | if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) { |
||
| 123 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
||
| 124 | } |
||
| 125 | EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' ); |
||
| 126 | } |
||
| 127 | |||
| 128 | |||
| 129 | /** |
||
| 130 | * gets the ball rolling |
||
| 131 | * |
||
| 132 | * @access public |
||
| 133 | * @param object $WP |
||
| 134 | * @return void |
||
| 135 | */ |
||
| 136 | public function run( $WP ) {} |
||
| 137 | |||
| 138 | |||
| 139 | /** |
||
| 140 | * ticket_selector_iframe |
||
| 141 | * |
||
| 142 | * @access public |
||
| 143 | * @return void |
||
| 144 | */ |
||
| 145 | public function ticket_selector_iframe() { |
||
| 146 | self::$_in_iframe = true; |
||
| 147 | /** @type EEM_Event $EEM_Event */ |
||
| 148 | $EEM_Event = EE_Registry::instance()->load_model( 'Event' ); |
||
| 149 | $event = $EEM_Event->get_one_by_ID( |
||
| 150 | EE_Registry::instance()->REQ->get( 'event', 0 ) |
||
| 151 | ); |
||
| 152 | EE_Registry::instance()->REQ->set_espresso_page( true ); |
||
| 153 | $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event ); |
||
| 154 | $template_args['css'] = apply_filters( |
||
| 155 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
||
| 156 | array( |
||
| 157 | TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION, |
||
| 158 | TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION, |
||
| 159 | includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ), |
||
| 160 | EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
||
| 161 | ) |
||
| 162 | ); |
||
| 163 | EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true; |
||
| 164 | EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' ); |
||
| 165 | $template_args['eei18n'] = apply_filters( |
||
| 166 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings', |
||
| 167 | EE_Registry::localize_i18n_js_strings() |
||
| 168 | ); |
||
| 169 | $template_args['js'] = apply_filters( |
||
| 170 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
||
| 171 | array( |
||
| 172 | includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ), |
||
| 173 | EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
||
| 174 | TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION |
||
| 175 | ) |
||
| 176 | ); |
||
| 177 | EE_Registry::instance()->load_helper('Template'); |
||
| 178 | $template_args[ 'notices' ] = EEH_Template::display_template( |
||
| 179 | EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
||
| 180 | array(), |
||
| 181 | true |
||
| 182 | ); |
||
| 183 | EEH_Template::display_template( |
||
| 184 | TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php', |
||
| 185 | $template_args |
||
| 186 | ); |
||
| 187 | exit; |
||
| 188 | } |
||
| 189 | |||
| 190 | |||
| 191 | |||
| 192 | |||
| 193 | /** |
||
| 194 | * Adds an iframe embed code button to the Event editor. |
||
| 195 | * |
||
| 196 | * @param string $permalink_string The current html string for the permalink section. |
||
| 197 | * @param int $id The post id for the event. |
||
| 198 | * @param string $new_title The for the event |
||
| 199 | * @param string $new_slug The slug for the event. |
||
| 200 | * |
||
| 201 | * @return string The new html string for the permalink area. |
||
| 202 | */ |
||
| 203 | public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) { |
||
| 204 | //make sure this is ONLY when editing and the event id has been set. |
||
| 205 | if ( ! empty( $id ) ) { |
||
| 206 | $post = get_post( $id ); |
||
| 207 | |||
| 208 | //if NOT event then let's get out. |
||
| 209 | if ( $post->post_type !== 'espresso_events' ) { |
||
| 210 | return $permalink_string; |
||
| 211 | } |
||
| 212 | |||
| 213 | $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
||
| 214 | |||
| 215 | $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' . __('Embed', 'event_espresso') . '</a> '; |
||
| 216 | $permalink_string .= ' |
||
| 217 | <div id="js-ts-iframe" style="display:none"> |
||
| 218 | <div style="width:100%; height: 500px;"> |
||
| 219 | <iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe> |
||
| 220 | </div> |
||
| 221 | </div>'; |
||
| 222 | } |
||
| 223 | return $permalink_string; |
||
| 224 | } |
||
| 225 | |||
| 226 | |||
| 227 | |||
| 228 | |||
| 229 | |||
| 230 | |||
| 231 | /** |
||
| 232 | * finds and sets the EE_Event object for use throughout class |
||
| 233 | * |
||
| 234 | * @access public |
||
| 235 | * @param mixed $event |
||
| 236 | * @return bool |
||
| 237 | */ |
||
| 238 | protected static function set_event( $event = null ) { |
||
| 239 | if( $event === null ) { |
||
| 240 | global $post; |
||
| 241 | $event = $post; |
||
| 242 | } |
||
| 243 | if ( $event instanceof EE_Event ) { |
||
| 244 | self::$_event = $event; |
||
| 245 | } else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
||
| 246 | self::$_event = $event->EE_Event; |
||
| 247 | } else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) { |
||
| 248 | $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
||
| 249 | self::$_event = $event->EE_Event; |
||
| 250 | View Code Duplication | } else { |
|
| 251 | $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
||
| 252 | $dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' ); |
||
| 253 | EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
||
| 254 | return false; |
||
| 255 | } |
||
| 256 | return true; |
||
| 257 | } |
||
| 258 | |||
| 259 | |||
| 260 | |||
| 261 | |||
| 262 | |||
| 263 | |||
| 264 | /** |
||
| 265 | * creates buttons for selecting number of attendees for an event |
||
| 266 | * |
||
| 267 | * @access public |
||
| 268 | * @param object $event |
||
| 269 | * @param bool $view_details |
||
| 270 | * @return string |
||
| 271 | */ |
||
| 272 | public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
||
| 273 | // reset filter for displaying submit button |
||
| 274 | remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
||
| 275 | // poke and prod incoming event till it tells us what it is |
||
| 276 | if ( ! EED_Ticket_Selector::set_event( $event )) { |
||
| 277 | return false; |
||
| 278 | } |
||
| 279 | $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event; |
||
| 280 | // grab event status |
||
| 281 | $_event_active_status = self::$_event->get_active_status(); |
||
| 282 | if ( |
||
| 283 | ! is_admin() |
||
| 284 | && ( |
||
| 285 | ! self::$_event->display_ticket_selector() |
||
| 286 | || $view_details |
||
| 287 | || post_password_required( $event_post ) |
||
| 288 | || ( |
||
| 289 | $_event_active_status != EE_Datetime::active |
||
| 290 | && $_event_active_status != EE_Datetime::upcoming |
||
| 291 | && $_event_active_status != EE_Datetime::sold_out |
||
| 292 | && ! ( |
||
| 293 | $_event_active_status == EE_Datetime::inactive |
||
| 294 | && is_user_logged_in() |
||
| 295 | ) |
||
| 296 | ) |
||
| 297 | ) |
||
| 298 | ) { |
||
| 299 | return ! is_single() ? EED_Ticket_Selector::display_view_details_btn() : ''; |
||
| 300 | } |
||
| 301 | |||
| 302 | $template_args = array(); |
||
| 303 | $template_args['event_status'] = $_event_active_status; |
||
| 304 | |||
| 305 | $template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) ); |
||
| 306 | $template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) ); |
||
| 307 | |||
| 308 | $template_args['EVT_ID'] = self::$_event->ID(); |
||
| 309 | $template_args['event'] = self::$_event; |
||
| 310 | |||
| 311 | // is the event expired ? |
||
| 312 | $template_args['event_is_expired'] = self::$_event->is_expired(); |
||
| 313 | if ( $template_args['event_is_expired'] ) { |
||
| 314 | return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>'; |
||
| 315 | } |
||
| 316 | |||
| 317 | $ticket_query_args = array( |
||
| 318 | array( 'Datetime.EVT_ID' => self::$_event->ID() ), |
||
| 319 | 'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' ) |
||
| 320 | ); |
||
| 321 | |||
| 322 | if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) { |
||
| 323 | //use the correct applicable time query depending on what version of core is being run. |
||
| 324 | $current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp'); |
||
| 325 | $ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time ); |
||
| 326 | } |
||
| 327 | |||
| 328 | // get all tickets for this event ordered by the datetime |
||
| 329 | $template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args ); |
||
| 330 | |||
| 331 | if ( count( $template_args['tickets'] ) < 1 ) { |
||
| 332 | return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>'; |
||
| 333 | } |
||
| 334 | |||
| 335 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
||
| 336 | $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit() ); |
||
| 337 | if ( $template_args['max_atndz'] < 1 ) { |
||
| 338 | $sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' ); |
||
| 339 | if ( current_user_can( 'edit_post', self::$_event->ID() )) { |
||
| 340 | $sales_closed_msg .= sprintf( |
||
| 341 | __( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ), |
||
| 342 | '<div class="ee-attention" style="text-align: left;"><b>', |
||
| 343 | '</b><br />', |
||
| 344 | $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">', |
||
| 345 | '</a></span></div>' |
||
| 346 | ); |
||
| 347 | } |
||
| 348 | return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
||
| 349 | } |
||
| 350 | |||
| 351 | $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; |
||
| 352 | $templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event ); |
||
| 353 | |||
| 354 | // redirecting to another site for registration ?? |
||
| 355 | $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE; |
||
| 356 | // set up the form (but not for the admin) |
||
| 357 | $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : ''; |
||
| 358 | // if not redirecting to another site for registration |
||
| 359 | if ( ! $external_url ) { |
||
| 360 | EE_Registry::instance()->load_helper( 'Template' ); |
||
| 361 | EE_Registry::instance()->load_helper( 'URL' ); |
||
| 362 | // then display the ticket selector |
||
| 363 | $ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args ); |
||
| 364 | } else { |
||
| 365 | // if not we still need to trigger the display of the submit button |
||
| 366 | add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
||
| 367 | //display notice to admin that registration is external |
||
| 368 | $ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' ); |
||
| 369 | } |
||
| 370 | // submit button and form close tag |
||
| 371 | $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : ''; |
||
| 372 | // set no cache headers and constants |
||
| 373 | EE_System::do_not_cache(); |
||
| 374 | |||
| 375 | return $ticket_selector; |
||
| 376 | } |
||
| 377 | |||
| 378 | |||
| 379 | |||
| 380 | /** |
||
| 381 | * ticket_selector_form_open |
||
| 382 | * |
||
| 383 | * @access public |
||
| 384 | * @param int $ID |
||
| 385 | * @param string $external_url |
||
| 386 | * @return string |
||
| 387 | */ |
||
| 388 | public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) { |
||
| 389 | // if redirecting, we don't need any anything else |
||
| 390 | if ( $external_url ) { |
||
| 391 | EE_Registry::instance()->load_helper( 'URL' ); |
||
| 392 | $html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">'; |
||
| 393 | $query_args = EEH_URL::get_query_string( $external_url ); |
||
| 394 | foreach ( $query_args as $query_arg => $value ) { |
||
| 395 | $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
||
| 396 | } |
||
| 397 | return $html; |
||
| 398 | } |
||
| 399 | EE_Registry::instance()->load_helper( 'Event_View' ); |
||
| 400 | $checkout_url = EEH_Event_View::event_link_url( $ID ); |
||
| 401 | if ( ! $checkout_url ) { |
||
| 402 | EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
||
| 403 | } |
||
| 404 | $extra_params = self::$_in_iframe ? ' target="_blank"' : ''; |
||
| 405 | $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
||
| 406 | $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE ); |
||
| 407 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
||
| 408 | $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event ); |
||
| 409 | return $html; |
||
| 410 | } |
||
| 411 | |||
| 412 | |||
| 413 | |||
| 414 | |||
| 415 | /** |
||
| 416 | * display_ticket_selector_submit |
||
| 417 | * |
||
| 418 | * @access public |
||
| 419 | * @access public |
||
| 420 | * @return string |
||
| 421 | */ |
||
| 422 | public static function display_ticket_selector_submit() { |
||
| 423 | if ( ! is_admin() ) { |
||
| 424 | if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) { |
||
| 425 | $btn_text = apply_filters( |
||
| 426 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
||
| 427 | __('Register Now', 'event_espresso' ), |
||
| 428 | self::$_event |
||
| 429 | ); |
||
| 430 | $external_url = self::$_event->external_url(); |
||
| 431 | $html = '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn"'; |
||
| 432 | $html .= ' class="ticket-selector-submit-btn '; |
||
| 433 | $html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"'; |
||
| 434 | $html .= ' type="submit" value="' . $btn_text . '" />'; |
||
| 435 | $html .= apply_filters( 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event ); |
||
| 436 | $html .= '<div class="clear"><br/></div></form>'; |
||
| 437 | return $html; |
||
| 438 | } else if ( is_archive() ) { |
||
| 439 | return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn(); |
||
| 440 | } |
||
| 441 | } |
||
| 442 | return ''; |
||
| 443 | } |
||
| 444 | |||
| 445 | |||
| 446 | |||
| 447 | |||
| 448 | /** |
||
| 449 | * ticket_selector_form_close |
||
| 450 | * |
||
| 451 | * @access public |
||
| 452 | * @access public |
||
| 453 | * @return string |
||
| 454 | */ |
||
| 455 | public static function ticket_selector_form_close() { |
||
| 456 | return '</form>'; |
||
| 457 | } |
||
| 458 | |||
| 459 | |||
| 460 | |||
| 461 | |||
| 462 | |||
| 463 | /** |
||
| 464 | * display_view_details_btn |
||
| 465 | * |
||
| 466 | * @access public |
||
| 467 | * @access public |
||
| 468 | * @return string |
||
| 469 | */ |
||
| 470 | public static function display_view_details_btn() { |
||
| 471 | if ( ! self::$_event->get_permalink() ) { |
||
| 472 | EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
||
| 473 | } |
||
| 474 | $view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">'; |
||
| 475 | $btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event ); |
||
| 476 | $view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />'; |
||
| 477 | $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event ); |
||
| 478 | $view_details_btn .= '<div class="clear"><br/></div>'; |
||
| 479 | $view_details_btn .= '</form>'; |
||
| 480 | return $view_details_btn; |
||
| 481 | } |
||
| 482 | |||
| 483 | |||
| 484 | |||
| 485 | |||
| 486 | |||
| 487 | |||
| 488 | /** |
||
| 489 | * process_ticket_selections |
||
| 490 | * |
||
| 491 | * @access public |
||
| 492 | * @access public |
||
| 493 | * @return array or FALSE |
||
| 494 | */ |
||
| 495 | public function process_ticket_selections() { |
||
| 631 | |||
| 632 | |||
| 633 | |||
| 634 | /** |
||
| 635 | * validate_post_data |
||
| 636 | * |
||
| 637 | * @access private |
||
| 638 | * @return array or FALSE |
||
| 639 | */ |
||
| 640 | private static function _validate_post_data() { |
||
| 641 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
||
| 642 | |||
| 643 | // start with an empty array() |
||
| 644 | $valid_data = array(); |
||
| 645 | // d( $_POST ); |
||
| 747 | |||
| 748 | |||
| 749 | |||
| 750 | /** |
||
| 751 | * adds a ticket to the cart |
||
| 752 | * @access private |
||
| 753 | * @param EE_Ticket $ticket |
||
| 754 | * @param int $qty |
||
| 755 | * @return TRUE on success, FALSE on fail |
||
| 756 | */ |
||
| 757 | private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
||
| 799 | |||
| 800 | |||
| 801 | |||
| 802 | /** |
||
| 803 | * _ticket_datetime_availability |
||
| 804 | * creates an array of tickets plus all of the datetimes available to each ticket |
||
| 805 | * and tracks the spaces remaining for each of those datetimes |
||
| 806 | * |
||
| 807 | * @access private |
||
| 808 | * @param EE_Ticket $ticket - selected ticket |
||
| 809 | * @param bool $get_original_ticket_spaces |
||
| 810 | * @return int |
||
| 811 | */ |
||
| 812 | private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) { |
||
| 833 | |||
| 834 | |||
| 835 | |||
| 836 | /** |
||
| 837 | * _set_initial_ticket_datetime_availability |
||
| 838 | * |
||
| 839 | * @access private |
||
| 840 | * @param EE_Ticket $ticket |
||
| 841 | * @return int |
||
| 842 | */ |
||
| 843 | private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) { |
||
| 864 | |||
| 865 | |||
| 866 | |||
| 867 | /** |
||
| 868 | * _recalculate_ticket_datetime_availability |
||
| 869 | * |
||
| 870 | * @access private |
||
| 871 | * @param EE_Ticket $ticket |
||
| 872 | * @param int $qty |
||
| 873 | * @return int |
||
| 874 | */ |
||
| 875 | private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) { |
||
| 884 | |||
| 885 | |||
| 886 | |||
| 887 | |||
| 888 | |||
| 889 | /** |
||
| 890 | * load js |
||
| 891 | * |
||
| 892 | * @access public |
||
| 893 | * @return void |
||
| 894 | */ |
||
| 895 | public static function load_tckt_slctr_assets() { |
||
| 905 | |||
| 906 | |||
| 907 | |||
| 908 | |||
| 909 | |||
| 910 | public static function load_tckt_slctr_assets_admin() { |
||
| 917 | |||
| 918 | |||
| 919 | |||
| 920 | public static function no_tkt_slctr_end_dv() { |
||
| 923 | |||
| 924 | |||
| 925 | |||
| 926 | } |
||
| 927 | |||
| 933 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.