@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * finds and sets the EE_Event object for use throughout class |
224 | 224 | * |
225 | 225 | * @access public |
226 | - * @param mixed $event |
|
226 | + * @param EE_Event|null $event |
|
227 | 227 | * @return bool |
228 | 228 | */ |
229 | 229 | protected static function set_event( $event = null ) { |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * process_ticket_selections |
585 | 585 | * |
586 | 586 | * @access public |
587 | - * @return array|boolean |
|
587 | + * @return boolean|null |
|
588 | 588 | */ |
589 | 589 | public function process_ticket_selections() { |
590 | 590 | do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | * |
746 | 746 | * @access private |
747 | 747 | * @param int $id |
748 | - * @return array|FALSE |
|
748 | + * @return string |
|
749 | 749 | */ |
750 | 750 | private static function _validate_post_data( $id = 0 ) { |
751 | 751 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | * @access private |
865 | 865 | * @param EE_Ticket $ticket |
866 | 866 | * @param int $qty |
867 | - * @return TRUE on success, FALSE on fail |
|
867 | + * @return boolean on success, FALSE on fail |
|
868 | 868 | * @throws \EE_Error |
869 | 869 | */ |
870 | 870 | private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
@@ -17,19 +17,19 @@ discard block |
||
17 | 17 | protected static $_event; |
18 | 18 | |
19 | 19 | /** |
20 | - * array of datetimes and the spaces available for them |
|
21 | - * |
|
22 | - * @access private |
|
23 | - * @var array |
|
24 | - */ |
|
20 | + * array of datetimes and the spaces available for them |
|
21 | + * |
|
22 | + * @access private |
|
23 | + * @var array |
|
24 | + */ |
|
25 | 25 | private static $_available_spaces = array(); |
26 | 26 | |
27 | 27 | /** |
28 | - * max attendees that can register for event at one time |
|
29 | - * |
|
30 | - * @access private |
|
31 | - * @var int |
|
32 | - */ |
|
28 | + * max attendees that can register for event at one time |
|
29 | + * |
|
30 | + * @access private |
|
31 | + * @var int |
|
32 | + */ |
|
33 | 33 | private static $_max_atndz = EE_INF; |
34 | 34 | |
35 | 35 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | return $permalink_string; |
198 | 198 | } |
199 | 199 | $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' |
200 | - . __( 'Embed', 'event_espresso' ) |
|
201 | - . '</a> '; |
|
200 | + . __( 'Embed', 'event_espresso' ) |
|
201 | + . '</a> '; |
|
202 | 202 | $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
203 | 203 | $iframe_string = esc_html( |
204 | 204 | '<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>' |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @throws \EE_Error |
425 | 425 | */ |
426 | 426 | public static function display_ticket_selector_submit() { |
427 | - $html = ''; |
|
427 | + $html = ''; |
|
428 | 428 | if ( ! is_admin() ) { |
429 | 429 | // standard TS displayed with submit button, ie: "Register Now" |
430 | 430 | if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
@@ -482,17 +482,17 @@ discard block |
||
482 | 482 | $html .= \EED_Ticket_Selector::ticket_selector_form_close(); |
483 | 483 | } else if ( apply_filters( 'FHEE__EE_Ticket_Selector__no_ticket_selector_submit', false ) ) { |
484 | 484 | // NOT a DWMTS event, TS displayed, BUT no tickets are available, so NO submit button |
485 | - $html = \EED_Ticket_Selector::clear_tkt_slctr() . \EED_Ticket_Selector::ticket_selector_form_close(); |
|
485 | + $html = \EED_Ticket_Selector::clear_tkt_slctr() . \EED_Ticket_Selector::ticket_selector_form_close(); |
|
486 | 486 | } else { |
487 | 487 | // DWMTS event, no TS, no submit or view details button, and no additional content |
488 | - $html = \EED_Ticket_Selector::no_tkt_slctr_end_dv() . \EED_Ticket_Selector::ticket_selector_form_close(); |
|
488 | + $html = \EED_Ticket_Selector::no_tkt_slctr_end_dv() . \EED_Ticket_Selector::ticket_selector_form_close(); |
|
489 | + } |
|
490 | + if ( ! is_archive()) { |
|
491 | + $html .= \EEH_Template::powered_by_event_espresso(); |
|
489 | 492 | } |
490 | - if ( ! is_archive()) { |
|
491 | - $html .= \EEH_Template::powered_by_event_espresso(); |
|
492 | - } |
|
493 | - } |
|
494 | - return $html; |
|
495 | - } |
|
493 | + } |
|
494 | + return $html; |
|
495 | + } |
|
496 | 496 | |
497 | 497 | |
498 | 498 | |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | * @return array|boolean |
587 | 587 | */ |
588 | 588 | public function process_ticket_selections() { |
589 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
589 | + do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
590 | 590 | // do we have an event id? |
591 | 591 | if ( ! EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) { |
592 | 592 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
@@ -1009,11 +1009,11 @@ discard block |
||
1009 | 1009 | |
1010 | 1010 | |
1011 | 1011 | /** |
1012 | - * load js |
|
1013 | - * |
|
1014 | - * @access public |
|
1015 | - * @return void |
|
1016 | - */ |
|
1012 | + * load js |
|
1013 | + * |
|
1014 | + * @access public |
|
1015 | + * @return void |
|
1016 | + */ |
|
1017 | 1017 | public static function load_tckt_slctr_assets() { |
1018 | 1018 | // add some style |
1019 | 1019 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
@@ -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 | * Ticket Selector class |
4 | 4 | * |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | * @return EED_Ticket_Selector |
48 | 48 | */ |
49 | 49 | public static function instance() { |
50 | - return parent::get_instance( __CLASS__ ); |
|
50 | + return parent::get_instance(__CLASS__); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - protected function set_config(){ |
|
56 | - $this->set_config_section( 'template_settings' ); |
|
57 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
58 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
55 | + protected function set_config() { |
|
56 | + $this->set_config_section('template_settings'); |
|
57 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
58 | + $this->set_config_name('EED_Ticket_Selector'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public static function set_hooks() { |
72 | 72 | // routing |
73 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
74 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
75 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
76 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
77 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
73 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
74 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
75 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
76 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
77 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | * @return void |
87 | 87 | */ |
88 | 88 | public static function set_hooks_admin() { |
89 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
89 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
90 | 90 | //add button for iframe code to event editor. |
91 | - add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 ); |
|
92 | - add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 ); |
|
91 | + add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4); |
|
92 | + add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | * @return void |
102 | 102 | */ |
103 | 103 | public static function set_definitions() { |
104 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
105 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
104 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
105 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
106 | 106 | |
107 | 107 | //if config is not set, initialize |
108 | 108 | //If config is not set, set it. |
109 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) { |
|
109 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) { |
|
110 | 110 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
111 | 111 | } |
112 | - EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' ); |
|
112 | + EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso'); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param WP $WP |
121 | 121 | * @return void |
122 | 122 | */ |
123 | - public function run( $WP ) {} |
|
123 | + public function run($WP) {} |
|
124 | 124 | |
125 | 125 | |
126 | 126 | |
@@ -134,23 +134,23 @@ discard block |
||
134 | 134 | public function ticket_selector_iframe() { |
135 | 135 | self::$_in_iframe = true; |
136 | 136 | /** @type EEM_Event $EEM_Event */ |
137 | - $EEM_Event = EE_Registry::instance()->load_model( 'Event' ); |
|
137 | + $EEM_Event = EE_Registry::instance()->load_model('Event'); |
|
138 | 138 | $event = $EEM_Event->get_one_by_ID( |
139 | - EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
139 | + EE_Registry::instance()->REQ->get('event', 0) |
|
140 | 140 | ); |
141 | - EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
142 | - $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event ); |
|
141 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
142 | + $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event); |
|
143 | 143 | $template_args['css'] = apply_filters( |
144 | 144 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
145 | 145 | array( |
146 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
147 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
148 | - includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ), |
|
149 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
146 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION, |
|
147 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION, |
|
148 | + includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']), |
|
149 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION |
|
150 | 150 | ) |
151 | 151 | ); |
152 | - EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true; |
|
153 | - EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = esc_html__( 'Please choose at least one ticket before continuing.', 'event_espresso' ); |
|
152 | + EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true; |
|
153 | + EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = esc_html__('Please choose at least one ticket before continuing.', 'event_espresso'); |
|
154 | 154 | $template_args['eei18n'] = apply_filters( |
155 | 155 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings', |
156 | 156 | EE_Registry::localize_i18n_js_strings() |
@@ -158,18 +158,18 @@ discard block |
||
158 | 158 | $template_args['js'] = apply_filters( |
159 | 159 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
160 | 160 | array( |
161 | - includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ), |
|
162 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
163 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION |
|
161 | + includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']), |
|
162 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
163 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION |
|
164 | 164 | ) |
165 | 165 | ); |
166 | - $template_args[ 'notices' ] = EEH_Template::display_template( |
|
167 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
166 | + $template_args['notices'] = EEH_Template::display_template( |
|
167 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
168 | 168 | array(), |
169 | 169 | true |
170 | 170 | ); |
171 | 171 | EEH_Template::display_template( |
172 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php', |
|
172 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php', |
|
173 | 173 | $template_args |
174 | 174 | ); |
175 | 175 | exit; |
@@ -188,25 +188,25 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return string The new html string for the permalink area. |
190 | 190 | */ |
191 | - public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) { |
|
191 | + public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) { |
|
192 | 192 | //make sure this is ONLY when editing and the event id has been set. |
193 | - if ( ! empty( $id ) ) { |
|
194 | - $post = get_post( $id ); |
|
193 | + if ( ! empty($id)) { |
|
194 | + $post = get_post($id); |
|
195 | 195 | //if NOT event then let's get out. |
196 | - if ( $post->post_type !== 'espresso_events' ) { |
|
196 | + if ($post->post_type !== 'espresso_events') { |
|
197 | 197 | return $permalink_string; |
198 | 198 | } |
199 | 199 | $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' |
200 | - . __( 'Embed', 'event_espresso' ) |
|
200 | + . __('Embed', 'event_espresso') |
|
201 | 201 | . '</a> '; |
202 | - $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
|
202 | + $ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url()); |
|
203 | 203 | $iframe_string = esc_html( |
204 | - '<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>' |
|
204 | + '<iframe src="'.$ticket_selector_url.'" width="100%" height="100%"></iframe>' |
|
205 | 205 | ); |
206 | 206 | $permalink_string .= ' |
207 | 207 | <div id="js-ts-iframe" style="display:none"> |
208 | 208 | <div style="width:100%; height: 500px;"> |
209 | - ' . $iframe_string . ' |
|
209 | + ' . $iframe_string.' |
|
210 | 210 | </div> |
211 | 211 | </div>'; |
212 | 212 | } |
@@ -225,22 +225,22 @@ discard block |
||
225 | 225 | * @param mixed $event |
226 | 226 | * @return bool |
227 | 227 | */ |
228 | - protected static function set_event( $event = null ) { |
|
229 | - if( $event === null ) { |
|
228 | + protected static function set_event($event = null) { |
|
229 | + if ($event === null) { |
|
230 | 230 | global $post; |
231 | 231 | $event = $post; |
232 | 232 | } |
233 | - if ( $event instanceof EE_Event ) { |
|
233 | + if ($event instanceof EE_Event) { |
|
234 | 234 | self::$_event = $event; |
235 | - } else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
|
235 | + } else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) { |
|
236 | 236 | self::$_event = $event->EE_Event; |
237 | - } else if ( $event instanceof WP_Post && $event->post_type === 'espresso_events' ) { |
|
238 | - $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
237 | + } else if ($event instanceof WP_Post && $event->post_type === 'espresso_events') { |
|
238 | + $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
239 | 239 | self::$_event = $event->EE_Event; |
240 | 240 | } else { |
241 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
242 | - $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' ); |
|
243 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
241 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
242 | + $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'); |
|
243 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
244 | 244 | return false; |
245 | 245 | } |
246 | 246 | return true; |
@@ -257,11 +257,11 @@ discard block |
||
257 | 257 | * @return string |
258 | 258 | * @throws \EE_Error |
259 | 259 | */ |
260 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
260 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
261 | 261 | // reset filter for displaying submit button |
262 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
262 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
263 | 263 | // poke and prod incoming event till it tells us what it is |
264 | - if ( ! EED_Ticket_Selector::set_event( $event )) { |
|
264 | + if ( ! EED_Ticket_Selector::set_event($event)) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event; |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | && ( |
273 | 273 | ! self::$_event->display_ticket_selector() |
274 | 274 | || $view_details |
275 | - || post_password_required( $event_post ) |
|
275 | + || post_password_required($event_post) |
|
276 | 276 | || ( |
277 | 277 | $_event_active_status !== EE_Datetime::active |
278 | 278 | && $_event_active_status !== EE_Datetime::upcoming |
@@ -290,34 +290,34 @@ discard block |
||
290 | 290 | $template_args = array(); |
291 | 291 | $template_args['event_status'] = $_event_active_status; |
292 | 292 | |
293 | - $template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) ); |
|
294 | - $template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) ); |
|
293 | + $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format')); |
|
294 | + $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format')); |
|
295 | 295 | |
296 | 296 | $template_args['EVT_ID'] = self::$_event->ID(); |
297 | 297 | $template_args['event'] = self::$_event; |
298 | 298 | |
299 | 299 | // is the event expired ? |
300 | 300 | $template_args['event_is_expired'] = self::$_event->is_expired(); |
301 | - if ( $template_args['event_is_expired'] ) { |
|
302 | - 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>'; |
|
301 | + if ($template_args['event_is_expired']) { |
|
302 | + 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>'; |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | $ticket_query_args = array( |
306 | - array( 'Datetime.EVT_ID' => self::$_event->ID() ), |
|
307 | - 'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' ) |
|
306 | + array('Datetime.EVT_ID' => self::$_event->ID()), |
|
307 | + 'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC') |
|
308 | 308 | ); |
309 | 309 | |
310 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) { |
|
310 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
311 | 311 | //use the correct applicable time query depending on what version of core is being run. |
312 | - $current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp'); |
|
313 | - $ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time ); |
|
312 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp'); |
|
313 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | // get all tickets for this event ordered by the datetime |
317 | - $template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args ); |
|
317 | + $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args); |
|
318 | 318 | |
319 | - if ( count( $template_args['tickets'] ) < 1 ) { |
|
320 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>'; |
|
319 | + if (count($template_args['tickets']) < 1) { |
|
320 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>'; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
@@ -326,41 +326,41 @@ discard block |
||
326 | 326 | self::$_event->additional_limit() |
327 | 327 | ); |
328 | 328 | $template_args['max_atndz'] = \EED_Ticket_Selector::$_max_atndz; |
329 | - if ( $template_args['max_atndz'] < 1 ) { |
|
330 | - $sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' ); |
|
331 | - if ( current_user_can( 'edit_post', self::$_event->ID() )) { |
|
332 | - $sales_closed_msg .= sprintf( |
|
333 | - __( '%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' ), |
|
329 | + if ($template_args['max_atndz'] < 1) { |
|
330 | + $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso'); |
|
331 | + if (current_user_can('edit_post', self::$_event->ID())) { |
|
332 | + $sales_closed_msg .= sprintf( |
|
333 | + __('%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'), |
|
334 | 334 | '<div class="ee-attention" style="text-align: left;"><b>', |
335 | 335 | '</b><br />', |
336 | - $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">', |
|
336 | + $link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">', |
|
337 | 337 | '</a></span></div>' |
338 | 338 | ); |
339 | 339 | } |
340 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
340 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
341 | 341 | } |
342 | 342 | |
343 | - $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; |
|
344 | - $templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event ); |
|
343 | + $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php'; |
|
344 | + $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event); |
|
345 | 345 | |
346 | 346 | // redirecting to another site for registration ?? |
347 | 347 | $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE; |
348 | 348 | // if not redirecting to another site for registration |
349 | - if ( ! $external_url ) { |
|
349 | + if ( ! $external_url) { |
|
350 | 350 | // then display the ticket selector |
351 | - $ticket_selector = EEH_Template::locate_template( $templates['ticket_selector'], $template_args ); |
|
351 | + $ticket_selector = EEH_Template::locate_template($templates['ticket_selector'], $template_args); |
|
352 | 352 | } else { |
353 | 353 | // if not we still need to trigger the display of the submit button |
354 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
354 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
355 | 355 | //display notice to admin that registration is external |
356 | - $ticket_selector = ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' ); |
|
356 | + $ticket_selector = ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso'); |
|
357 | 357 | } |
358 | 358 | // now set up the form (but not for the admin) |
359 | 359 | $ticket_selector = ! is_admin() |
360 | 360 | ? EED_Ticket_Selector::ticket_selector_form_open( |
361 | 361 | self::$_event->ID(), |
362 | 362 | $external_url |
363 | - ) . $ticket_selector |
|
363 | + ).$ticket_selector |
|
364 | 364 | : $ticket_selector; |
365 | 365 | // submit button and form close tag |
366 | 366 | $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : ''; |
@@ -380,14 +380,14 @@ discard block |
||
380 | 380 | * @param string $external_url |
381 | 381 | * @return string |
382 | 382 | */ |
383 | - public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) { |
|
383 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') { |
|
384 | 384 | // if redirecting, we don't need any anything else |
385 | - if ( $external_url ) { |
|
386 | - $html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">'; |
|
387 | - $query_args = (array) EEH_URL::get_query_string( $external_url ); |
|
388 | - foreach ( $query_args as $query_arg => $value ) { |
|
385 | + if ($external_url) { |
|
386 | + $html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">'; |
|
387 | + $query_args = (array) EEH_URL::get_query_string($external_url); |
|
388 | + foreach ($query_args as $query_arg => $value) { |
|
389 | 389 | $html .= ' |
390 | - <input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
390 | + <input type="hidden" name="' . $query_arg.'" value="'.$value.'">'; |
|
391 | 391 | } |
392 | 392 | return $html; |
393 | 393 | } |
@@ -397,19 +397,19 @@ discard block |
||
397 | 397 | if ( |
398 | 398 | EED_Ticket_Selector::$_max_atndz === 1 |
399 | 399 | && is_archive() |
400 | - && ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) |
|
400 | + && ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false) |
|
401 | 401 | ) { |
402 | 402 | return ''; |
403 | 403 | } |
404 | - $checkout_url = EEH_Event_View::event_link_url( $ID ); |
|
405 | - if ( ! $checkout_url ) { |
|
406 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
404 | + $checkout_url = EEH_Event_View::event_link_url($ID); |
|
405 | + if ( ! $checkout_url) { |
|
406 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
407 | 407 | } |
408 | 408 | $extra_params = self::$_in_iframe ? ' target="_blank"' : ''; |
409 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
410 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, TRUE, FALSE ); |
|
409 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
410 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_'.$ID, TRUE, FALSE); |
|
411 | 411 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
412 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event ); |
|
412 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event); |
|
413 | 413 | return $html; |
414 | 414 | } |
415 | 415 | |
@@ -425,19 +425,19 @@ discard block |
||
425 | 425 | */ |
426 | 426 | public static function display_ticket_selector_submit() { |
427 | 427 | $html = ''; |
428 | - if ( ! is_admin() ) { |
|
428 | + if ( ! is_admin()) { |
|
429 | 429 | // standard TS displayed with submit button, ie: "Register Now" |
430 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
430 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
431 | 431 | $btn_text = apply_filters( |
432 | 432 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
433 | - __('Register Now', 'event_espresso' ), |
|
433 | + __('Register Now', 'event_espresso'), |
|
434 | 434 | EED_Ticket_Selector::$_event |
435 | 435 | ); |
436 | 436 | $external_url = EED_Ticket_Selector::$_event->external_url(); |
437 | - $html = '<input id="ticket-selector-submit-'. EED_Ticket_Selector::$_event->ID() .'-btn"'; |
|
437 | + $html = '<input id="ticket-selector-submit-'.EED_Ticket_Selector::$_event->ID().'-btn"'; |
|
438 | 438 | $html .= ' class="ticket-selector-submit-btn '; |
439 | - $html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"'; |
|
440 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
439 | + $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
440 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
441 | 441 | $html .= apply_filters( |
442 | 442 | 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
443 | 443 | '', |
@@ -446,15 +446,15 @@ discard block |
||
446 | 446 | $html .= EED_Ticket_Selector::$_max_atndz === 1 |
447 | 447 | ? \EED_Ticket_Selector::no_tkt_slctr_end_dv() |
448 | 448 | : \EED_Ticket_Selector::clear_tkt_slctr(); |
449 | - $html .= '<br/>' . \EED_Ticket_Selector::ticket_selector_form_close(); |
|
449 | + $html .= '<br/>'.\EED_Ticket_Selector::ticket_selector_form_close(); |
|
450 | 450 | } else if ( |
451 | 451 | is_archive() |
452 | 452 | && EED_Ticket_Selector::$_max_atndz === 1 |
453 | 453 | ) { |
454 | 454 | // event list, no tickets available so display event's "View Details" button, |
455 | 455 | // but this is a "Dude Where's my Ticket Selector?" (DWMTS) type event |
456 | - $html = EED_Ticket_Selector::display_view_details_btn( true ); |
|
457 | - } else if ( is_archive() ) { |
|
456 | + $html = EED_Ticket_Selector::display_view_details_btn(true); |
|
457 | + } else if (is_archive()) { |
|
458 | 458 | // event list, no tickets available so display event's "View Details" button |
459 | 459 | $html = \EED_Ticket_Selector::ticket_selector_form_close(); |
460 | 460 | $html .= EED_Ticket_Selector::display_view_details_btn(); |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | $html = apply_filters( |
470 | 470 | 'FHEE__EE_Ticket_Selector__no_ticket_selector_submit', |
471 | 471 | sprintf( |
472 | - __( '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', 'event_espresso' ), |
|
472 | + __('%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', 'event_espresso'), |
|
473 | 473 | '<p class="no-ticket-selector-msg clear-float">', |
474 | 474 | EED_Ticket_Selector::$_event->name(), |
475 | 475 | '</p>', |
@@ -480,12 +480,12 @@ discard block |
||
480 | 480 | // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
481 | 481 | $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv(); |
482 | 482 | $html .= \EED_Ticket_Selector::ticket_selector_form_close(); |
483 | - } else if ( apply_filters( 'FHEE__EE_Ticket_Selector__no_ticket_selector_submit', false ) ) { |
|
483 | + } else if (apply_filters('FHEE__EE_Ticket_Selector__no_ticket_selector_submit', false)) { |
|
484 | 484 | // NOT a DWMTS event, TS displayed, BUT no tickets are available, so NO submit button |
485 | - $html = \EED_Ticket_Selector::clear_tkt_slctr() . \EED_Ticket_Selector::ticket_selector_form_close(); |
|
485 | + $html = \EED_Ticket_Selector::clear_tkt_slctr().\EED_Ticket_Selector::ticket_selector_form_close(); |
|
486 | 486 | } else { |
487 | 487 | // DWMTS event, no TS, no submit or view details button, and no additional content |
488 | - $html = \EED_Ticket_Selector::no_tkt_slctr_end_dv() . \EED_Ticket_Selector::ticket_selector_form_close(); |
|
488 | + $html = \EED_Ticket_Selector::no_tkt_slctr_end_dv().\EED_Ticket_Selector::ticket_selector_form_close(); |
|
489 | 489 | } |
490 | 490 | if ( ! is_archive()) { |
491 | 491 | $html .= \EEH_Template::powered_by_event_espresso(); |
@@ -550,19 +550,19 @@ discard block |
||
550 | 550 | * @return string |
551 | 551 | * @throws \EE_Error |
552 | 552 | */ |
553 | - public static function display_view_details_btn( $DWMTS = false) { |
|
554 | - if ( ! self::$_event->get_permalink() ) { |
|
555 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
553 | + public static function display_view_details_btn($DWMTS = false) { |
|
554 | + if ( ! self::$_event->get_permalink()) { |
|
555 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
556 | 556 | } |
557 | - $view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">'; |
|
557 | + $view_details_btn = '<form method="POST" action="'.self::$_event->get_permalink().'">'; |
|
558 | 558 | $btn_text = apply_filters( |
559 | 559 | 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
560 | - __( 'View Details', 'event_espresso' ), |
|
560 | + __('View Details', 'event_espresso'), |
|
561 | 561 | self::$_event |
562 | 562 | ); |
563 | - $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 . '" />'; |
|
564 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event ); |
|
565 | - if ( $DWMTS ) { |
|
563 | + $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.'" />'; |
|
564 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event); |
|
565 | + if ($DWMTS) { |
|
566 | 566 | $view_details_btn .= \EED_Ticket_Selector::ticket_selector_form_close(); |
567 | 567 | $view_details_btn .= \EED_Ticket_Selector::no_tkt_slctr_end_dv(); |
568 | 568 | $view_details_btn .= '<br/>'; |
@@ -586,9 +586,9 @@ discard block |
||
586 | 586 | * @return array|boolean |
587 | 587 | */ |
588 | 588 | public function process_ticket_selections() { |
589 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
589 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
590 | 590 | // do we have an event id? |
591 | - if ( ! EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) { |
|
591 | + if ( ! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) { |
|
592 | 592 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
593 | 593 | EE_Error::add_error( |
594 | 594 | sprintf( |
@@ -604,17 +604,17 @@ discard block |
||
604 | 604 | ); |
605 | 605 | } |
606 | 606 | //if event id is valid |
607 | - $id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' ) ); |
|
607 | + $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id')); |
|
608 | 608 | // check nonce |
609 | 609 | if ( |
610 | 610 | ! is_admin() |
611 | 611 | && ( |
612 | - ! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce_' . $id ) |
|
613 | - || ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce_' . $id ), 'process_ticket_selections' ) |
|
612 | + ! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce_'.$id) |
|
613 | + || ! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce_'.$id), 'process_ticket_selections') |
|
614 | 614 | ) |
615 | 615 | ) { |
616 | 616 | EE_Error::add_error( |
617 | - sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
617 | + sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
618 | 618 | __FILE__, __FUNCTION__, __LINE__ |
619 | 619 | ); |
620 | 620 | return FALSE; |
@@ -628,16 +628,16 @@ discard block |
||
628 | 628 | |
629 | 629 | //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart. |
630 | 630 | // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc. |
631 | - EE_Registry::instance()->load_core( 'Session' ); |
|
631 | + EE_Registry::instance()->load_core('Session'); |
|
632 | 632 | // unless otherwise requested, clear the session |
633 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) { |
|
634 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
633 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) { |
|
634 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
635 | 635 | } |
636 | 636 | //d( EE_Registry::instance()->SSN ); |
637 | 637 | |
638 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
638 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
639 | 639 | // validate/sanitize data |
640 | - $valid = self::_validate_post_data( $id ); |
|
640 | + $valid = self::_validate_post_data($id); |
|
641 | 641 | |
642 | 642 | //EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
643 | 643 | //EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ ); |
@@ -645,41 +645,41 @@ discard block |
||
645 | 645 | //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ ); |
646 | 646 | |
647 | 647 | //check total tickets ordered vs max number of attendees that can register |
648 | - if ( $valid['total_tickets'] > $valid['max_atndz'] ) { |
|
648 | + if ($valid['total_tickets'] > $valid['max_atndz']) { |
|
649 | 649 | |
650 | 650 | // ordering too many tickets !!! |
651 | 651 | $total_tickets_string = _n('You have attempted to purchase %s ticket.', 'You have attempted to purchase %s tickets.', $valid['total_tickets'], 'event_espresso'); |
652 | - $limit_error_1 = sprintf( $total_tickets_string, $valid['total_tickets'] ); |
|
652 | + $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
653 | 653 | // dev only message |
654 | 654 | $max_atndz_string = _n('The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', $valid['max_atndz'], 'event_espresso'); |
655 | - $limit_error_2 = sprintf( $max_atndz_string, $valid['max_atndz'], $valid['max_atndz'] ); |
|
656 | - EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ ); |
|
655 | + $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']); |
|
656 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
657 | 657 | } else { |
658 | 658 | |
659 | 659 | // all data appears to be valid |
660 | 660 | $tckts_slctd = FALSE; |
661 | 661 | $success = TRUE; |
662 | 662 | // load cart |
663 | - EE_Registry::instance()->load_core( 'Cart' ); |
|
663 | + EE_Registry::instance()->load_core('Cart'); |
|
664 | 664 | |
665 | 665 | // cycle thru the number of data rows sent from the event listing |
666 | - for ( $x = 0; $x < $valid['rows']; $x++ ) { |
|
666 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
667 | 667 | // does this row actually contain a ticket quantity? |
668 | - if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) { |
|
668 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
669 | 669 | // YES we have a ticket quantity |
670 | 670 | $tckts_slctd = TRUE; |
671 | 671 | // d( $valid['ticket_obj'][$x] ); |
672 | - if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) { |
|
672 | + if ($valid['ticket_obj'][$x] instanceof EE_Ticket) { |
|
673 | 673 | // then add ticket to cart |
674 | - $ticket_added = self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] ); |
|
674 | + $ticket_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]); |
|
675 | 675 | $success = ! $ticket_added ? FALSE : $success; |
676 | - if ( EE_Error::has_error() ) { |
|
676 | + if (EE_Error::has_error()) { |
|
677 | 677 | break; |
678 | 678 | } |
679 | 679 | } else { |
680 | 680 | // nothing added to cart retrieved |
681 | 681 | EE_Error::add_error( |
682 | - sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
682 | + sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
683 | 683 | __FILE__, __FUNCTION__, __LINE__ |
684 | 684 | ); |
685 | 685 | } |
@@ -688,45 +688,45 @@ discard block |
||
688 | 688 | //d( EE_Registry::instance()->CART ); |
689 | 689 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
690 | 690 | |
691 | - if ( $tckts_slctd ) { |
|
692 | - if ( $success ) { |
|
693 | - do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this ); |
|
691 | + if ($tckts_slctd) { |
|
692 | + if ($success) { |
|
693 | + do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this); |
|
694 | 694 | EE_Registry::instance()->CART->recalculate_all_cart_totals(); |
695 | - EE_Registry::instance()->CART->save_cart( FALSE ); |
|
695 | + EE_Registry::instance()->CART->save_cart(FALSE); |
|
696 | 696 | EE_Registry::instance()->SSN->update(); |
697 | 697 | //d( EE_Registry::instance()->CART ); |
698 | 698 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
699 | 699 | // just return TRUE for registrations being made from admin |
700 | - if ( is_admin() ) { |
|
700 | + if (is_admin()) { |
|
701 | 701 | return TRUE; |
702 | 702 | } |
703 | - wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() )); |
|
703 | + wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url())); |
|
704 | 704 | exit(); |
705 | 705 | |
706 | 706 | } else { |
707 | - if ( ! EE_Error::has_error() ) { |
|
707 | + if ( ! EE_Error::has_error()) { |
|
708 | 708 | // nothing added to cart |
709 | - EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
709 | + EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 | |
713 | 713 | } else { |
714 | 714 | // no ticket quantities were selected |
715 | - EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
715 | + EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
716 | 716 | } |
717 | 717 | } |
718 | 718 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
719 | 719 | // at this point, just return if registration is being made from admin |
720 | - if ( is_admin() ) { |
|
720 | + if (is_admin()) { |
|
721 | 721 | return FALSE; |
722 | 722 | } |
723 | - if ( $valid['return_url'] ) { |
|
724 | - EE_Error::get_notices( FALSE, TRUE ); |
|
725 | - wp_safe_redirect( $valid['return_url'] ); |
|
723 | + if ($valid['return_url']) { |
|
724 | + EE_Error::get_notices(FALSE, TRUE); |
|
725 | + wp_safe_redirect($valid['return_url']); |
|
726 | 726 | exit(); |
727 | - } elseif ( isset( $event_to_add['id'] )) { |
|
728 | - EE_Error::get_notices( FALSE, TRUE ); |
|
729 | - wp_safe_redirect( get_permalink( $event_to_add['id'] )); |
|
727 | + } elseif (isset($event_to_add['id'])) { |
|
728 | + EE_Error::get_notices(FALSE, TRUE); |
|
729 | + wp_safe_redirect(get_permalink($event_to_add['id'])); |
|
730 | 730 | exit(); |
731 | 731 | } else { |
732 | 732 | echo EE_Error::get_notices(); |
@@ -746,13 +746,13 @@ discard block |
||
746 | 746 | * @param int $id |
747 | 747 | * @return array|FALSE |
748 | 748 | */ |
749 | - private static function _validate_post_data( $id = 0 ) { |
|
750 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
749 | + private static function _validate_post_data($id = 0) { |
|
750 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
751 | 751 | |
752 | 752 | // d( $_POST ); |
753 | - if ( ! $id ) { |
|
753 | + if ( ! $id) { |
|
754 | 754 | EE_Error::add_error( |
755 | - __( 'The event id provided was not valid.', 'event_espresso' ), |
|
755 | + __('The event id provided was not valid.', 'event_espresso'), |
|
756 | 756 | __FILE__, |
757 | 757 | __FUNCTION__, |
758 | 758 | __LINE__ |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | // grab valid id |
765 | 765 | $valid_data['id'] = $id; |
766 | 766 | // grab and sanitize return-url |
767 | - $valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id )); |
|
767 | + $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id)); |
|
768 | 768 | // array of other form names |
769 | 769 | $inputs_to_clean = array( |
770 | 770 | 'event_id' => 'tkt-slctr-event-id', |
@@ -777,22 +777,22 @@ discard block |
||
777 | 777 | // let's track the total number of tickets ordered.' |
778 | 778 | $valid_data['total_tickets'] = 0; |
779 | 779 | // cycle through $inputs_to_clean array |
780 | - foreach ( $inputs_to_clean as $what => $input_to_clean ) { |
|
780 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
781 | 781 | // check for POST data |
782 | - if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) { |
|
782 | + if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) { |
|
783 | 783 | // grab value |
784 | - $input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id ); |
|
784 | + $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id); |
|
785 | 785 | switch ($what) { |
786 | 786 | |
787 | 787 | // integers |
788 | 788 | case 'event_id': |
789 | - $valid_data[$what] = absint( $input_value ); |
|
789 | + $valid_data[$what] = absint($input_value); |
|
790 | 790 | // get event via the event id we put in the form |
791 | - $valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] ); |
|
791 | + $valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']); |
|
792 | 792 | break; |
793 | 793 | case 'rows': |
794 | 794 | case 'max_atndz': |
795 | - $valid_data[$what] = absint( $input_value ); |
|
795 | + $valid_data[$what] = absint($input_value); |
|
796 | 796 | break; |
797 | 797 | |
798 | 798 | // arrays of integers |
@@ -800,27 +800,27 @@ discard block |
||
800 | 800 | /** @var array $row_qty */ |
801 | 801 | $row_qty = $input_value; |
802 | 802 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
803 | - if( ! is_array( $row_qty )) { |
|
803 | + if ( ! is_array($row_qty)) { |
|
804 | 804 | // get number of rows |
805 | - $rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1; |
|
805 | + $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1; |
|
806 | 806 | // d( $rows ); |
807 | 807 | // explode ints by the dash |
808 | - $row_qty = explode( '-', $row_qty ); |
|
809 | - $row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1; |
|
810 | - $qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0; |
|
811 | - $row_qty = array( $row => $qty ); |
|
808 | + $row_qty = explode('-', $row_qty); |
|
809 | + $row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1; |
|
810 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
811 | + $row_qty = array($row => $qty); |
|
812 | 812 | // d( $row_qty ); |
813 | - for( $x = 1; $x <= $rows; $x++ ) { |
|
814 | - if ( ! isset( $row_qty[$x] )) { |
|
813 | + for ($x = 1; $x <= $rows; $x++) { |
|
814 | + if ( ! isset($row_qty[$x])) { |
|
815 | 815 | $row_qty[$x] = 0; |
816 | 816 | } |
817 | 817 | } |
818 | 818 | } |
819 | - ksort( $row_qty ); |
|
819 | + ksort($row_qty); |
|
820 | 820 | // d( $row_qty ); |
821 | 821 | // cycle thru values |
822 | - foreach ( $row_qty as $qty ) { |
|
823 | - $qty = absint( $qty ); |
|
822 | + foreach ($row_qty as $qty) { |
|
823 | + $qty = absint($qty); |
|
824 | 824 | // sanitize as integers |
825 | 825 | $valid_data[$what][] = $qty; |
826 | 826 | $valid_data['total_tickets'] += $qty; |
@@ -831,19 +831,19 @@ discard block |
||
831 | 831 | case 'ticket_id': |
832 | 832 | $value_array = array(); |
833 | 833 | // cycle thru values |
834 | - foreach ( (array) $input_value as $key => $value ) { |
|
834 | + foreach ((array) $input_value as $key => $value) { |
|
835 | 835 | // allow only numbers, letters, spaces, commas and dashes |
836 | - $value_array[ $key ] = wp_strip_all_tags( $value ); |
|
836 | + $value_array[$key] = wp_strip_all_tags($value); |
|
837 | 837 | // get ticket via the ticket id we put in the form |
838 | - $ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value ); |
|
839 | - $valid_data['ticket_obj'][ $key ] = $ticket_obj; |
|
838 | + $ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value); |
|
839 | + $valid_data['ticket_obj'][$key] = $ticket_obj; |
|
840 | 840 | } |
841 | - $valid_data[ $what ] = $value_array; |
|
841 | + $valid_data[$what] = $value_array; |
|
842 | 842 | break; |
843 | 843 | |
844 | 844 | case 'return_url' : |
845 | 845 | // grab and sanitize return-url |
846 | - $valid_data[$what] = esc_url_raw( $input_value ); |
|
846 | + $valid_data[$what] = esc_url_raw($input_value); |
|
847 | 847 | break; |
848 | 848 | |
849 | 849 | } // end switch $what |
@@ -866,28 +866,28 @@ discard block |
||
866 | 866 | * @return TRUE on success, FALSE on fail |
867 | 867 | * @throws \EE_Error |
868 | 868 | */ |
869 | - private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
|
870 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
869 | + private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) { |
|
870 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
871 | 871 | // get the number of spaces left for this datetime ticket |
872 | - $available_spaces = self::_ticket_datetime_availability( $ticket ); |
|
872 | + $available_spaces = self::_ticket_datetime_availability($ticket); |
|
873 | 873 | // compare available spaces against the number of tickets being purchased |
874 | - if ( $available_spaces >= $qty ) { |
|
874 | + if ($available_spaces >= $qty) { |
|
875 | 875 | // allow addons to prevent a ticket from being added to cart |
876 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces ) ) { |
|
876 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) { |
|
877 | 877 | return false; |
878 | 878 | } |
879 | 879 | // add event to cart |
880 | - if( EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) { |
|
881 | - self::_recalculate_ticket_datetime_availability( $ticket, $qty ); |
|
880 | + if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) { |
|
881 | + self::_recalculate_ticket_datetime_availability($ticket, $qty); |
|
882 | 882 | return true; |
883 | 883 | } else { |
884 | 884 | return false; |
885 | 885 | } |
886 | 886 | } else { |
887 | 887 | // tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets |
888 | - $available_spaces = self::_ticket_datetime_availability( $ticket, true ); |
|
888 | + $available_spaces = self::_ticket_datetime_availability($ticket, true); |
|
889 | 889 | // greedy greedy greedy eh? |
890 | - if ( $available_spaces > 0 ) { |
|
890 | + if ($available_spaces > 0) { |
|
891 | 891 | // add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces |
892 | 892 | EE_Error::add_error( |
893 | 893 | sprintf( |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | __FILE__, __FUNCTION__, __LINE__ |
904 | 904 | ); |
905 | 905 | } else { |
906 | - EE_Error::add_error( __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
906 | + EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
907 | 907 | } |
908 | 908 | return false; |
909 | 909 | } |
@@ -922,22 +922,22 @@ discard block |
||
922 | 922 | * @return int |
923 | 923 | * @throws \EE_Error |
924 | 924 | */ |
925 | - private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) { |
|
925 | + private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) { |
|
926 | 926 | // if the $_available_spaces array has not been set up yet... |
927 | - if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
928 | - self::_set_initial_ticket_datetime_availability( $ticket ); |
|
927 | + if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
928 | + self::_set_initial_ticket_datetime_availability($ticket); |
|
929 | 929 | } |
930 | 930 | $available_spaces = $ticket->qty() - $ticket->sold(); |
931 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
931 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
932 | 932 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
933 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
933 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
934 | 934 | // if we want the original datetime availability BEFORE we started subtracting tickets ? |
935 | - if ( $get_original_ticket_spaces ) { |
|
935 | + if ($get_original_ticket_spaces) { |
|
936 | 936 | // then grab the available spaces from the "tickets" array and compare with the above to get the lowest number |
937 | - $available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] ); |
|
937 | + $available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]); |
|
938 | 938 | } else { |
939 | 939 | // we want the updated ticket availability as stored in the "datetimes" array |
940 | - $available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] ); |
|
940 | + $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]); |
|
941 | 941 | } |
942 | 942 | } |
943 | 943 | } |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | * @return void |
955 | 955 | * @throws \EE_Error |
956 | 956 | */ |
957 | - private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) { |
|
957 | + private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) { |
|
958 | 958 | // first, get all of the datetimes that are available to this ticket |
959 | 959 | $datetimes = $ticket->get_many_related( |
960 | 960 | 'Datetime', |
@@ -962,23 +962,23 @@ discard block |
||
962 | 962 | array( |
963 | 963 | 'DTT_EVT_end' => array( |
964 | 964 | '>=', |
965 | - EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ), |
|
965 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
966 | 966 | ), |
967 | 967 | ), |
968 | - 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), |
|
968 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
969 | 969 | ) |
970 | 970 | ); |
971 | - if ( ! empty( $datetimes )) { |
|
971 | + if ( ! empty($datetimes)) { |
|
972 | 972 | // now loop thru all of the datetimes |
973 | - foreach ( $datetimes as $datetime ) { |
|
974 | - if ( $datetime instanceof EE_Datetime ) { |
|
973 | + foreach ($datetimes as $datetime) { |
|
974 | + if ($datetime instanceof EE_Datetime) { |
|
975 | 975 | // the number of spaces available for the datetime without considering individual ticket quantities |
976 | 976 | $spaces_remaining = $datetime->spaces_remaining(); |
977 | 977 | // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key |
978 | - self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining ); |
|
978 | + self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining); |
|
979 | 979 | // if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number, |
980 | 980 | // else just take the datetime spaces remaining, and assign to the datetimes array |
981 | - self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining; |
|
981 | + self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining; |
|
982 | 982 | } |
983 | 983 | } |
984 | 984 | } |
@@ -994,12 +994,12 @@ discard block |
||
994 | 994 | * @param int $qty |
995 | 995 | * @return void |
996 | 996 | */ |
997 | - private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) { |
|
998 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
997 | + private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) { |
|
998 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
999 | 999 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
1000 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
1000 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
1001 | 1001 | // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
1002 | - self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty; |
|
1002 | + self::$_available_spaces['datetimes'][$DTD_ID] -= $qty; |
|
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | } |
@@ -1016,8 +1016,8 @@ discard block |
||
1016 | 1016 | */ |
1017 | 1017 | public static function load_tckt_slctr_assets() { |
1018 | 1018 | // add some style |
1019 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
1020 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
1019 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
1020 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
1021 | 1021 | wp_enqueue_style('ticket_selector'); |
1022 | 1022 | // make it dance |
1023 | 1023 | // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
@@ -1031,9 +1031,9 @@ discard block |
||
1031 | 1031 | |
1032 | 1032 | public static function load_tckt_slctr_assets_admin() { |
1033 | 1033 | //iframe button js on admin event editor page |
1034 | - if ( EE_Registry::instance()->REQ->get('page') === 'espresso_events' && EE_Registry::instance()->REQ->get('action') === 'edit' ) { |
|
1035 | - wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true ); |
|
1036 | - wp_enqueue_script( 'ticket_selector_embed' ); |
|
1034 | + if (EE_Registry::instance()->REQ->get('page') === 'espresso_events' && EE_Registry::instance()->REQ->get('action') === 'edit') { |
|
1035 | + wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
1036 | + wp_enqueue_script('ticket_selector_embed'); |
|
1037 | 1037 | } |
1038 | 1038 | } |
1039 | 1039 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @return EED_Bot_Trap |
19 | 19 | */ |
20 | 20 | public static function instance() { |
21 | - return parent::get_instance( __CLASS__ ); |
|
21 | + return parent::get_instance(__CLASS__); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public static function set_hooks() { |
33 | 33 | if ( |
34 | - apply_filters( 'FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true ) && |
|
34 | + apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
35 | 35 | \EE_Registry::instance()->CFG->registration->use_bot_trap |
36 | 36 | ) { |
37 | 37 | \EED_Bot_Trap::set_trap(); |
38 | 38 | // redirect bots to bogus success page |
39 | - \EE_Config::register_route( 'ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success' ); |
|
39 | + \EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success'); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public static function set_trap() { |
52 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
52 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS); |
|
53 | 53 | add_action( |
54 | 54 | 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
55 | 55 | array('EED_Bot_Trap', 'generate_bot_trap'), |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | } |
82 | 82 | add_action( |
83 | 83 | 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
84 | - array( 'EED_Bot_Trap', 'bot_trap_settings_form' ), |
|
84 | + array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
85 | 85 | 10 |
86 | 86 | ); |
87 | 87 | add_filter( |
88 | 88 | 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
89 | - array( 'EED_Bot_Trap', 'update_bot_trap_settings_form' ), |
|
89 | + array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
90 | 90 | 10, 1 |
91 | 91 | ); |
92 | 92 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param WP $WP |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - public function run( $WP ) {} |
|
103 | + public function run($WP) {} |
|
104 | 104 | |
105 | 105 | |
106 | 106 | |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | */ |
113 | 113 | public static function generate_bot_trap() { |
114 | - $do_not_enter = esc_html__( 'please do not enter anything in this input', 'event_espresso' ); |
|
114 | + $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
115 | 115 | $time = microtime(true); |
116 | 116 | $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
117 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
118 | - $html .= '<input type="email" id="tkt-slctr-request-processor-email-' . $time .'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
117 | + $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>'; |
|
118 | + $html .= '<input type="email" id="tkt-slctr-request-processor-email-'.$time.'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
119 | 119 | $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="'; |
120 | - if ( EE_Registry::instance()->CFG->registration->use_encryption ) { |
|
121 | - EE_Registry::instance()->load_core( 'EE_Encryption' ); |
|
122 | - $html .= EE_Encryption::instance()->encrypt( $time ); |
|
120 | + if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
121 | + EE_Registry::instance()->load_core('EE_Encryption'); |
|
122 | + $html .= EE_Encryption::instance()->encrypt($time); |
|
123 | 123 | } else { |
124 | 124 | $html .= $time; |
125 | 125 | } |
@@ -137,38 +137,38 @@ discard block |
||
137 | 137 | * It should receive one argument: a boolean indicating |
138 | 138 | * whether the trap was triggered by suspicious timing or not. |
139 | 139 | */ |
140 | - public static function process_bot_trap( $triggered_trap_callback = array() ) { |
|
140 | + public static function process_bot_trap($triggered_trap_callback = array()) { |
|
141 | 141 | // what's your email address Mr. Bot ? |
142 | - $empty_trap = isset( $_REQUEST[ 'tkt-slctr-request-processor-email' ] ) |
|
143 | - && $_REQUEST[ 'tkt-slctr-request-processor-email' ] === '' |
|
142 | + $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
143 | + && $_REQUEST['tkt-slctr-request-processor-email'] === '' |
|
144 | 144 | ? true |
145 | 145 | : false; |
146 | 146 | // get encrypted timestamp for when the form was originally displayed |
147 | - $bot_trap_timestamp = isset( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
|
148 | - ? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
|
147 | + $bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token']) |
|
148 | + ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token']) |
|
149 | 149 | : ''; |
150 | 150 | // decrypt and convert to absolute integer |
151 | - if ( EE_Registry::instance()->CFG->registration->use_encryption ) { |
|
152 | - EE_Registry::instance()->load_core( 'EE_Encryption' ); |
|
153 | - $bot_trap_timestamp = absint( EE_Encryption::instance()->decrypt( $bot_trap_timestamp ) ); |
|
151 | + if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
152 | + EE_Registry::instance()->load_core('EE_Encryption'); |
|
153 | + $bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp)); |
|
154 | 154 | } else { |
155 | - $bot_trap_timestamp = absint( $bot_trap_timestamp ); |
|
155 | + $bot_trap_timestamp = absint($bot_trap_timestamp); |
|
156 | 156 | } |
157 | 157 | // ticket form submitted too impossibly fast ( after now ) or more than an hour later ??? |
158 | - $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < ( time() - HOUR_IN_SECONDS ) |
|
158 | + $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS) |
|
159 | 159 | ? true |
160 | 160 | : false; |
161 | 161 | // are we human ? |
162 | - if ( $empty_trap && ! $suspicious_timing ) { |
|
162 | + if ($empty_trap && ! $suspicious_timing) { |
|
163 | 163 | do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
164 | 164 | return; |
165 | 165 | } |
166 | 166 | // check the given callback is valid first before executing |
167 | - if ( ! is_callable($triggered_trap_callback ) ) { |
|
167 | + if ( ! is_callable($triggered_trap_callback)) { |
|
168 | 168 | // invalid callback so lets just sub in our default. |
169 | - $triggered_trap_callback = array( 'EED_Bot_Trap', 'triggered_trap_response' ); |
|
169 | + $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
170 | 170 | } |
171 | - call_user_func_array($triggered_trap_callback, array( $suspicious_timing ) ); |
|
171 | + call_user_func_array($triggered_trap_callback, array($suspicious_timing)); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test. |
181 | 181 | */ |
182 | - public static function triggered_trap_response( $suspicious_timing ) { |
|
182 | + public static function triggered_trap_response($suspicious_timing) { |
|
183 | 183 | // UH OH... |
184 | 184 | $redirect_url = add_query_arg( |
185 | - array( 'ee' => 'ticket_selection_received' ), |
|
185 | + array('ee' => 'ticket_selection_received'), |
|
186 | 186 | EE_Registry::instance()->CFG->core->reg_page_url() |
187 | 187 | ); |
188 | - if ( $suspicious_timing ) { |
|
188 | + if ($suspicious_timing) { |
|
189 | 189 | $redirect_url = add_query_arg( |
190 | - array( 'ee-notice' => urlencode( esc_html__( 'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', 'event_espresso' ) ) ), |
|
190 | + array('ee-notice' => urlencode(esc_html__('We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', 'event_espresso'))), |
|
191 | 191 | $redirect_url |
192 | 192 | ); |
193 | 193 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * @return void |
219 | 219 | */ |
220 | 220 | public static function display_bot_trap_success() { |
221 | - add_filter( 'FHEE__EED_Single_Page_Checkout__run', '__return_false' ); |
|
222 | - $bot_notice = esc_html__( 'Thank you so much. Your ticket selections have been received for consideration.', 'event_espresso' ); |
|
223 | - $bot_notice = isset( $_REQUEST[ 'ee-notice' ] ) && $_REQUEST[ 'ee-notice' ] !== '' ? sanitize_text_field( stripslashes( $_REQUEST[ 'ee-notice' ] ) ) : $bot_notice; |
|
224 | - EE_Registry::instance()->REQ->add_output( EEH_HTML::div( $bot_notice, '', 'ee-attention' ) ); |
|
221 | + add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
222 | + $bot_notice = esc_html__('Thank you so much. Your ticket selections have been received for consideration.', 'event_espresso'); |
|
223 | + $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) : $bot_notice; |
|
224 | + EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -256,20 +256,20 @@ discard block |
||
256 | 256 | 'html_id' => 'bot_trap_settings', |
257 | 257 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
258 | 258 | 'subsections' => array( |
259 | - 'bot_trap_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( esc_html__( 'Bot Trap Settings', 'event_espresso' ) ) ), |
|
259 | + 'bot_trap_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))), |
|
260 | 260 | 'use_bot_trap' => new EE_Yes_No_Input( |
261 | 261 | array( |
262 | - 'html_label_text' => esc_html__( 'Enable Bot Trap', 'event_espresso' ), |
|
263 | - 'html_help_text' => esc_html__( 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso' ), |
|
264 | - 'default' => isset( EE_Registry::instance()->CFG->registration->use_bot_trap ) ? EE_Registry::instance()->CFG->registration->use_bot_trap : true, |
|
262 | + 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
263 | + 'html_help_text' => esc_html__('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'), |
|
264 | + 'default' => isset(EE_Registry::instance()->CFG->registration->use_bot_trap) ? EE_Registry::instance()->CFG->registration->use_bot_trap : true, |
|
265 | 265 | 'required' => false |
266 | 266 | ) |
267 | 267 | ), |
268 | 268 | 'use_encryption' => new EE_Yes_No_Input( |
269 | 269 | array( |
270 | - 'html_label_text' => esc_html__( 'Encrypt Bot Trap Data', 'event_espresso' ), |
|
271 | - 'html_help_text' => esc_html__( 'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', 'event_espresso' ), |
|
272 | - 'default' => isset( EE_Registry::instance()->CFG->registration->use_encryption ) ? EE_Registry::instance()->CFG->registration->use_encryption : true, |
|
270 | + 'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'), |
|
271 | + 'html_help_text' => esc_html__('One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', 'event_espresso'), |
|
272 | + 'default' => isset(EE_Registry::instance()->CFG->registration->use_encryption) ? EE_Registry::instance()->CFG->registration->use_encryption : true, |
|
273 | 273 | 'required' => false |
274 | 274 | ) |
275 | 275 | ), |
@@ -287,30 +287,30 @@ discard block |
||
287 | 287 | * @param \EE_Registration_Config $EE_Registration_Config |
288 | 288 | * @return \EE_Registration_Config |
289 | 289 | */ |
290 | - public static function update_bot_trap_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
|
290 | + public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) { |
|
291 | 291 | try { |
292 | 292 | $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
293 | 293 | // if not displaying a form, then check for form submission |
294 | - if ( $bot_trap_settings_form->was_submitted() ) { |
|
294 | + if ($bot_trap_settings_form->was_submitted()) { |
|
295 | 295 | // capture form data |
296 | 296 | $bot_trap_settings_form->receive_form_submission(); |
297 | 297 | // validate form data |
298 | - if ( $bot_trap_settings_form->is_valid() ) { |
|
298 | + if ($bot_trap_settings_form->is_valid()) { |
|
299 | 299 | // grab validated data from form |
300 | 300 | $valid_data = $bot_trap_settings_form->valid_data(); |
301 | - if ( isset( $valid_data[ 'use_bot_trap' ], $valid_data[ 'use_encryption' ] ) ) { |
|
302 | - $EE_Registration_Config->use_bot_trap = $valid_data[ 'use_bot_trap' ]; |
|
303 | - $EE_Registration_Config->use_encryption = $valid_data[ 'use_encryption' ]; |
|
301 | + if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) { |
|
302 | + $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
303 | + $EE_Registration_Config->use_encryption = $valid_data['use_encryption']; |
|
304 | 304 | } else { |
305 | - EE_Error::add_error( esc_html__( 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
305 | + EE_Error::add_error(esc_html__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
306 | 306 | } |
307 | 307 | } else { |
308 | - if ( $bot_trap_settings_form->submission_error_message() != '' ) { |
|
309 | - EE_Error::add_error( $bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
308 | + if ($bot_trap_settings_form->submission_error_message() != '') { |
|
309 | + EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | } |
313 | - } catch ( EE_Error $e ) { |
|
313 | + } catch (EE_Error $e) { |
|
314 | 314 | $e->get_error(); |
315 | 315 | } |
316 | 316 | return $EE_Registration_Config; |
@@ -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_event_details_before_post', $event_id ); |
|
71 | - espresso_ticket_selector( $event ); |
|
72 | - do_action( 'AHEE_event_details_after_post' ); |
|
70 | + do_action('AHEE_event_details_before_post', $event_id); |
|
71 | + espresso_ticket_selector($event); |
|
72 | + do_action('AHEE_event_details_after_post'); |
|
73 | 73 | return ob_get_clean(); |
74 | 74 | } |
75 | 75 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return EED_Ticket_Selector_Caff |
17 | 17 | */ |
18 | 18 | public static function instance() { |
19 | - return parent::get_instance( __CLASS__ ); |
|
19 | + return parent::get_instance(__CLASS__); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | * @return void |
38 | 38 | */ |
39 | 39 | public static function set_hooks_admin() { |
40 | - define( 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
41 | - add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Ticket_Selector_Caff', 'template_settings_form' ), 10 ); |
|
42 | - add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Ticket_Selector_Caff', 'update_template_settings' ), 10, 2 ); |
|
40 | + define('TICKET_SELECTOR_CAFF_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
41 | + add_action('AHEE__template_settings__template__before_settings_form', array('EED_Ticket_Selector_Caff', 'template_settings_form'), 10); |
|
42 | + add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Ticket_Selector_Caff', 'update_template_settings'), 10, 2); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | //just required because of abstract declaration |
47 | - public function run( $WP ) { |
|
47 | + public function run($WP) { |
|
48 | 48 | $this->set_config(); |
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - protected function set_config(){ |
|
55 | - $this->set_config_section( 'template_settings' ); |
|
56 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
57 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
54 | + protected function set_config() { |
|
55 | + $this->set_config_section('template_settings'); |
|
56 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
57 | + $this->set_config_name('EED_Ticket_Selector'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
88 | 88 | array( |
89 | 89 | 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
90 | - EEH_HTML::br(2) . |
|
91 | - EEH_HTML::h2( __( 'Ticket Selector Template Settings', 'event_espresso' )) |
|
90 | + EEH_HTML::br(2). |
|
91 | + EEH_HTML::h2(__('Ticket Selector Template Settings', 'event_espresso')) |
|
92 | 92 | ), |
93 | 93 | 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings() |
94 | 94 | ) |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'show_ticket_details' => new EE_Yes_No_Input( |
115 | 115 | array( |
116 | - 'html_label_text' => __('Show Ticket Details?', 'event_espresso' ), |
|
117 | - 'html_help_text' => __( 'This lets you choose whether the extra ticket details section is displayed with the ticket selector.', 'event_espresso'), |
|
118 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details ) |
|
116 | + 'html_label_text' => __('Show Ticket Details?', 'event_espresso'), |
|
117 | + 'html_help_text' => __('This lets you choose whether the extra ticket details section is displayed with the ticket selector.', 'event_espresso'), |
|
118 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details) |
|
119 | 119 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details |
120 | 120 | : true, |
121 | 121 | 'display_html_label_text' => false |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | ), |
124 | 124 | 'show_ticket_sale_columns' => new EE_Yes_No_Input( |
125 | 125 | array( |
126 | - 'html_label_text' => __('Show Ticket Sale Info?', 'event_espresso' ), |
|
127 | - 'html_help_text' => __( 'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', 'event_espresso'), |
|
128 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns ) |
|
126 | + 'html_label_text' => __('Show Ticket Sale Info?', 'event_espresso'), |
|
127 | + 'html_help_text' => __('This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', 'event_espresso'), |
|
128 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns) |
|
129 | 129 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns |
130 | 130 | : true, |
131 | 131 | 'display_html_label_text' => false |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | ), |
134 | 134 | 'show_expired_tickets' => new EE_Yes_No_Input( |
135 | 135 | array( |
136 | - 'html_label_text' => __( 'Show Expired Tickets?', 'event_espresso' ), |
|
137 | - 'html_help_text' => __( 'Indicate whether to show expired tickets in the ticket selector', 'event_espresso' ), |
|
138 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) |
|
136 | + 'html_label_text' => __('Show Expired Tickets?', 'event_espresso'), |
|
137 | + 'html_help_text' => __('Indicate whether to show expired tickets in the ticket selector', 'event_espresso'), |
|
138 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) |
|
139 | 139 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets |
140 | 140 | : true, |
141 | 141 | 'display_html_label_text' => false |
@@ -158,21 +158,21 @@ discard block |
||
158 | 158 | * @param array $REQ incoming request |
159 | 159 | * @return EE_Template_Config |
160 | 160 | */ |
161 | - public static function update_template_settings( EE_Template_Config $CFG, $REQ ) { |
|
162 | - if ( ! isset( $CFG->EED_Ticket_Selector ) ) { |
|
161 | + public static function update_template_settings(EE_Template_Config $CFG, $REQ) { |
|
162 | + if ( ! isset($CFG->EED_Ticket_Selector)) { |
|
163 | 163 | $CFG->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
164 | 164 | } |
165 | 165 | try { |
166 | 166 | $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
167 | 167 | |
168 | 168 | //check for form submission |
169 | - if ( $ticket_selector_form->was_submitted() ) { |
|
169 | + if ($ticket_selector_form->was_submitted()) { |
|
170 | 170 | |
171 | 171 | //capture form data |
172 | 172 | $ticket_selector_form->receive_form_submission(); |
173 | 173 | |
174 | 174 | //validate form data |
175 | - if ( $ticket_selector_form->is_valid() ) { |
|
175 | + if ($ticket_selector_form->is_valid()) { |
|
176 | 176 | |
177 | 177 | //grab validated data from form |
178 | 178 | $valid_data = $ticket_selector_form->valid_data(); |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details']; |
183 | 183 | $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets']; |
184 | 184 | } else { |
185 | - if ( $ticket_selector_form->submission_error_message() !== '' ) { |
|
186 | - EE_Error::add_error( $ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
185 | + if ($ticket_selector_form->submission_error_message() !== '') { |
|
186 | + EE_Error::add_error($ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
191 | - } catch( EE_Error $e ) { |
|
191 | + } catch (EE_Error $e) { |
|
192 | 192 | $e->get_error(); |
193 | 193 | } |
194 | 194 |
@@ -21,8 +21,8 @@ |
||
21 | 21 | |
22 | 22 | |
23 | 23 | <div id="postbox-container-2" class="postbox-container"> |
24 | - <?php do_meta_boxes( $current_page, 'normal', NULL ); ?> |
|
25 | - <?php do_meta_boxes( $current_page, 'advanced', NULL ); ?> |
|
24 | + <?php do_meta_boxes($current_page, 'normal', NULL); ?> |
|
25 | + <?php do_meta_boxes($current_page, 'advanced', NULL); ?> |
|
26 | 26 | </div> |
27 | 27 | <!-- postbox-container-2 --> |
28 | 28 | <div class="clear"></div> |
@@ -9,18 +9,18 @@ discard block |
||
9 | 9 | |
10 | 10 | $row = 1; |
11 | 11 | $max = 1; |
12 | -$ticket_count = count( $tickets ); |
|
12 | +$ticket_count = count($tickets); |
|
13 | 13 | $ticket_status_display = ''; |
14 | -if ( ! $ticket_count ) { |
|
14 | +if ( ! $ticket_count) { |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
18 | 18 | $required_ticket_sold_out = FALSE; |
19 | -$template_settings = isset ( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) |
|
19 | +$template_settings = isset (EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
20 | 20 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
21 | 21 | : new EE_Ticket_Selector_Config(); |
22 | 22 | |
23 | -$tax_settings = isset ( EE_Registry::instance()->CFG->tax_settings ) |
|
23 | +$tax_settings = isset (EE_Registry::instance()->CFG->tax_settings) |
|
24 | 24 | ? EE_Registry::instance()->CFG->tax_settings |
25 | 25 | : new EE_Tax_Config(); |
26 | 26 | |
@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | |
30 | 30 | ob_start(); |
31 | 31 | |
32 | -foreach ( $tickets as $TKT_ID => $ticket ) { |
|
33 | - if ( $ticket instanceof EE_Ticket ) { |
|
32 | +foreach ($tickets as $TKT_ID => $ticket) { |
|
33 | + if ($ticket instanceof EE_Ticket) { |
|
34 | 34 | $cols = 2; |
35 | 35 | $max = $ticket->max(); |
36 | 36 | $min = 0; |
37 | 37 | $remaining = $ticket->remaining(); |
38 | - if ( $ticket->is_on_sale() && $ticket->is_remaining() ) { |
|
38 | + if ($ticket->is_on_sale() && $ticket->is_remaining()) { |
|
39 | 39 | // offer the number of $tickets_remaining or $max_atndz, whichever is smaller |
40 | - $max = min( $remaining, $max_atndz ); |
|
40 | + $max = min($remaining, $max_atndz); |
|
41 | 41 | // but... we also want to restrict the number of tickets by the ticket max setting, |
42 | 42 | // however, the max still can't be higher than what was just set above |
43 | - $max = $ticket->max() > 0 ? min( $ticket->max(), $max ) : $max; |
|
43 | + $max = $ticket->max() > 0 ? min($ticket->max(), $max) : $max; |
|
44 | 44 | // and we also want to restrict the minimum number of tickets by the ticket min setting |
45 | 45 | $min = $ticket->min() > 0 ? $ticket->min() : 0; |
46 | 46 | // and if the ticket is required, then make sure that min qty is at least 1 |
47 | - $min = $ticket->required() ? max( $min, 1 ) : $min; |
|
47 | + $min = $ticket->required() ? max($min, 1) : $min; |
|
48 | 48 | } else { |
49 | 49 | // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
50 | 50 | $required_ticket_sold_out = $ticket->required() && ! $remaining ? $ticket->start_date() : $required_ticket_sold_out; |
@@ -56,41 +56,41 @@ discard block |
||
56 | 56 | $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
57 | 57 | $ticket_bundle = FALSE; |
58 | 58 | // for ticket bundles, set min and max qty the same |
59 | - if ( $ticket->min() !== 0 && $ticket->min() === $ticket->max() ) { |
|
59 | + if ($ticket->min() !== 0 && $ticket->min() === $ticket->max()) { |
|
60 | 60 | $ticket_price *= $ticket->min(); |
61 | 61 | $ticket_bundle = TRUE; |
62 | 62 | } |
63 | - $ticket_price = apply_filters( 'FHEE__ticket_selector_chart_template__ticket_price', $ticket_price, $ticket ); |
|
63 | + $ticket_price = apply_filters('FHEE__ticket_selector_chart_template__ticket_price', $ticket_price, $ticket); |
|
64 | 64 | // if a previous required ticket with the same sale start date is sold out, then mark this ticket as sold out as well. |
65 | 65 | // tickets that go on sale at a later date than the required ticket will NOT be affected |
66 | 66 | $tkt_status = $required_ticket_sold_out !== FALSE && $required_ticket_sold_out === $ticket->start_date() ? EE_Ticket::sold_out : $ticket->ticket_status(); |
67 | 67 | $tkt_status = $event_status === EE_Datetime::sold_out ? EE_Ticket::sold_out : $tkt_status; |
68 | 68 | // check ticket status |
69 | - switch ( $tkt_status ) { |
|
69 | + switch ($tkt_status) { |
|
70 | 70 | // sold_out |
71 | 71 | case EE_Ticket::sold_out : |
72 | - $ticket_status = '<span class="ticket-sales-sold-out">' . $ticket->ticket_status( TRUE ) . '</span>'; |
|
72 | + $ticket_status = '<span class="ticket-sales-sold-out">'.$ticket->ticket_status(TRUE).'</span>'; |
|
73 | 73 | $status_class = 'ticket-sales-sold-out lt-grey-text'; |
74 | 74 | break; |
75 | 75 | // expired |
76 | 76 | case EE_Ticket::expired : |
77 | - $ticket_status = '<span class="ticket-sales-expired">' . $ticket->ticket_status( TRUE ) . '</span>'; |
|
77 | + $ticket_status = '<span class="ticket-sales-expired">'.$ticket->ticket_status(TRUE).'</span>'; |
|
78 | 78 | $status_class = 'ticket-sales-expired lt-grey-text'; |
79 | 79 | break; |
80 | 80 | // archived |
81 | 81 | case EE_Ticket::archived : |
82 | - $ticket_status = '<span class="archived-ticket">' . $ticket->ticket_status( TRUE ) . '</span>'; |
|
82 | + $ticket_status = '<span class="archived-ticket">'.$ticket->ticket_status(TRUE).'</span>'; |
|
83 | 83 | $status_class = 'archived-ticket hidden'; |
84 | 84 | break; |
85 | 85 | // pending |
86 | 86 | case EE_Ticket::pending : |
87 | - $ticket_status = '<span class="ticket-pending">' . $ticket->ticket_status( TRUE ) . '</span>'; |
|
87 | + $ticket_status = '<span class="ticket-pending">'.$ticket->ticket_status(TRUE).'</span>'; |
|
88 | 88 | $status_class = 'ticket-pending'; |
89 | 89 | break; |
90 | 90 | // onsale |
91 | 91 | case EE_Ticket::onsale : |
92 | 92 | default : |
93 | - $ticket_status = '<span class="ticket-on-sale">' . $ticket->ticket_status( TRUE ) . '</span>'; |
|
93 | + $ticket_status = '<span class="ticket-on-sale">'.$ticket->ticket_status(TRUE).'</span>'; |
|
94 | 94 | $status_class = 'ticket-on-sale'; |
95 | 95 | break; |
96 | 96 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | "tckt-slctr-tkt-details-{$EVT_ID}-{$TKT_ID}" |
131 | 131 | ); |
132 | 132 | ?> |
133 | - <tr class="tckt-slctr-tbl-tr <?php echo $status_class . ' ' . espresso_get_object_css_class( $ticket ); ?>"> |
|
133 | + <tr class="tckt-slctr-tbl-tr <?php echo $status_class.' '.espresso_get_object_css_class($ticket); ?>"> |
|
134 | 134 | <?php |
135 | 135 | /** |
136 | 136 | * Allow plugins to hook in and abort the generation and display of the contents of this |
@@ -142,24 +142,24 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @var string|bool |
144 | 144 | */ |
145 | - if ( false !== ( $new_row_cells_content = apply_filters( 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', false, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class ) ) ) { |
|
145 | + if (false !== ($new_row_cells_content = apply_filters('FHEE__ticket_selector_chart_template__do_ticket_inside_row', false, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class))) { |
|
146 | 146 | echo $new_row_cells_content; |
147 | 147 | echo '</tr>'; |
148 | 148 | continue; |
149 | 149 | } |
150 | 150 | ?> |
151 | 151 | <td class="tckt-slctr-tbl-td-name"> |
152 | - <b><?php echo $ticket->get_pretty('TKT_name');?></b> |
|
153 | - <?php if ( $template_settings->show_ticket_details ) : ?> |
|
154 | - <a id="display-<?php echo $ticket_details_css_id; ?>" class="display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr( apply_filters( 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', __( 'click to show additional ticket details', 'event_espresso' )) ); ?>"> |
|
155 | - <?php echo sprintf( __( 'show%1$sdetails%1$s+', 'event_espresso' ), ' ' ); ?> |
|
152 | + <b><?php echo $ticket->get_pretty('TKT_name'); ?></b> |
|
153 | + <?php if ($template_settings->show_ticket_details) : ?> |
|
154 | + <a id="display-<?php echo $ticket_details_css_id; ?>" class="display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr(apply_filters('FHEE__ticket_selector_chart_template__show_ticket_details_link_title', __('click to show additional ticket details', 'event_espresso'))); ?>"> |
|
155 | + <?php echo sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), ' '); ?> |
|
156 | 156 | </a> |
157 | - <a id="hide-<?php echo $ticket_details_css_id; ?>" class="hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr( apply_filters( 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', __( 'click to hide additional ticket details', 'event_espresso' )) ); ?>" style="display:none;"> |
|
158 | - <?php echo sprintf( __( 'hide%1$sdetails%1$s-', 'event_espresso' ), ' ' ); ?> |
|
157 | + <a id="hide-<?php echo $ticket_details_css_id; ?>" class="hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr(apply_filters('FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', __('click to hide additional ticket details', 'event_espresso'))); ?>" style="display:none;"> |
|
158 | + <?php echo sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '); ?> |
|
159 | 159 | </a> |
160 | 160 | <?php endif; //end show details check ?> |
161 | - <?php if ( $ticket->required() ) { ?> |
|
162 | - <p class="ticket-required-pg"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_required_message', __( 'This ticket is required and must be purchased.', 'event_espresso' )); ?></p> |
|
161 | + <?php if ($ticket->required()) { ?> |
|
162 | + <p class="ticket-required-pg"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_required_message', __('This ticket is required and must be purchased.', 'event_espresso')); ?></p> |
|
163 | 163 | <?php } ?> |
164 | 164 | <?php |
165 | 165 | // echo '<br/><b>$max_atndz : ' . $max_atndz . '</b>'; |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | // echo '<br/><b> $ticket->required() : ' . $ticket->uses() . '</b>'; |
174 | 174 | ?> |
175 | 175 | </td> |
176 | - <?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) && $max_atndz > 1 ) { ?> |
|
176 | + <?php if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE) && $max_atndz > 1) { ?> |
|
177 | 177 | <td class="tckt-slctr-tbl-td-price jst-rght"><?php |
178 | - echo EEH_Template::format_currency( $ticket_price ); |
|
178 | + echo EEH_Template::format_currency($ticket_price); |
|
179 | 179 | echo $ticket->taxable() ? '<span class="taxable-tickets-asterisk grey-text">*</span>' : ''; |
180 | 180 | ?> <span class="smaller-text no-bold"><?php |
181 | - if ( $ticket_bundle ) { |
|
182 | - echo apply_filters( 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', __( ' / bundle', 'event_espresso' )); |
|
181 | + if ($ticket_bundle) { |
|
182 | + echo apply_filters('FHEE__ticket_selector_chart_template__per_ticket_bundle_text', __(' / bundle', 'event_espresso')); |
|
183 | 183 | } else { |
184 | - echo apply_filters( 'FHEE__ticket_selector_chart_template__per_ticket_text', __( '', 'event_espresso' )); |
|
184 | + echo apply_filters('FHEE__ticket_selector_chart_template__per_ticket_text', __('', 'event_espresso')); |
|
185 | 185 | }?></span> </td> |
186 | 186 | <?php $cols++; ?> |
187 | 187 | <?php } ?> |
@@ -190,53 +190,53 @@ discard block |
||
190 | 190 | $hidden_input_qty = $max_atndz > 1 ? TRUE : FALSE; |
191 | 191 | $ticket_status_display = ''; |
192 | 192 | // sold out or other status ? |
193 | - if ( $tkt_status === EE_Ticket::sold_out || $remaining === 0 ) { |
|
194 | - $ticket_status_display = '<span class="sold-out">' . apply_filters( 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', __( 'Sold Out', 'event_espresso' )) . '</span>'; |
|
195 | - } else if ( $tkt_status === EE_Ticket::expired || $tkt_status === EE_Ticket::archived ) { |
|
193 | + if ($tkt_status === EE_Ticket::sold_out || $remaining === 0) { |
|
194 | + $ticket_status_display = '<span class="sold-out">'.apply_filters('FHEE__ticket_selector_chart_template__ticket_sold_out_msg', __('Sold Out', 'event_espresso')).'</span>'; |
|
195 | + } else if ($tkt_status === EE_Ticket::expired || $tkt_status === EE_Ticket::archived) { |
|
196 | 196 | $ticket_status_display = $ticket_status; |
197 | - } else if ( $tkt_status === EE_Ticket::pending ) { |
|
197 | + } else if ($tkt_status === EE_Ticket::pending) { |
|
198 | 198 | $ticket_status_display = |
199 | 199 | '<span class="ticket-pending-pg"> |
200 | 200 | <span class="ticket-pending">' |
201 | - . apply_filters( 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', __( 'Goes On Sale', 'event_espresso' )) |
|
201 | + . apply_filters('FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', __('Goes On Sale', 'event_espresso')) |
|
202 | 202 | . '</span><br/> |
203 | 203 | <span class="small-text">' |
204 | - . $ticket->get_i18n_datetime( 'TKT_start_date', apply_filters( 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', $date_format ) ) |
|
204 | + . $ticket->get_i18n_datetime('TKT_start_date', apply_filters('FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', $date_format)) |
|
205 | 205 | . '</span> |
206 | 206 | </span>'; |
207 | 207 | // min qty purchasable is less than tickets available |
208 | - } else if ( $ticket->min() > $remaining ) { |
|
208 | + } else if ($ticket->min() > $remaining) { |
|
209 | 209 | $ticket_status_display = ' |
210 | 210 | <div class="archived-ticket-pg"> |
211 | 211 | <span class="archived-ticket small-text">' |
212 | - . apply_filters( 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', __( 'Not Available', 'event_espresso' )) |
|
212 | + . apply_filters('FHEE__ticket_selector_chart_template__ticket_not_available_msg', __('Not Available', 'event_espresso')) |
|
213 | 213 | . '</span><br/> |
214 | 214 | </div>'; |
215 | 215 | // if only one attendee is allowed to register at a time |
216 | - } else if ( $max_atndz === 1 ) { |
|
216 | + } else if ($max_atndz === 1) { |
|
217 | 217 | // display submit button since we have tickets available |
218 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
218 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
219 | 219 | ?> |
220 | - <input type="radio" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID . '-' . $row; ?>" class="ticket-selector-tbl-qty-slct" value="<?php echo $row . '-'; ?>1" <?php echo $row === 1 ? ' checked="checked"' : ''; ?> title=""/> |
|
220 | + <input type="radio" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID.'-'.$row; ?>" class="ticket-selector-tbl-qty-slct" value="<?php echo $row.'-'; ?>1" <?php echo $row === 1 ? ' checked="checked"' : ''; ?> title=""/> |
|
221 | 221 | <?php |
222 | 222 | $hidden_input_qty = FALSE; |
223 | 223 | |
224 | - } else if ( $max_atndz === 0 ) { |
|
225 | - $ticket_status_display = '<span class="sold-out">' . apply_filters( 'FHEE__ticket_selector_chart_template__ticket_closed_msg', __( 'Closed', 'event_espresso' )) . '</span>'; |
|
226 | - } elseif ( $max > 0 ) { |
|
224 | + } else if ($max_atndz === 0) { |
|
225 | + $ticket_status_display = '<span class="sold-out">'.apply_filters('FHEE__ticket_selector_chart_template__ticket_closed_msg', __('Closed', 'event_espresso')).'</span>'; |
|
226 | + } elseif ($max > 0) { |
|
227 | 227 | // display submit button since we have tickets available |
228 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
228 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
229 | 229 | |
230 | 230 | ?> |
231 | - <select name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID . '-' . $row; ?>" class="ticket-selector-tbl-qty-slct" title=""> |
|
231 | + <select name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID.'-'.$row; ?>" class="ticket-selector-tbl-qty-slct" title=""> |
|
232 | 232 | <?php |
233 | 233 | // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
234 | - if ( ! $ticket->required() && $min !== 0 ) { |
|
234 | + if ( ! $ticket->required() && $min !== 0) { |
|
235 | 235 | ?> |
236 | 236 | <option value="0"> 0 </option> |
237 | 237 | <?php } |
238 | 238 | // offer ticket quantities from the min to the max |
239 | - for ( $i = $min; $i <= $max; $i++) { |
|
239 | + for ($i = $min; $i <= $max; $i++) { |
|
240 | 240 | ?> |
241 | 241 | <option value="<?php echo $i; ?>"> <?php echo $i; ?> </option> |
242 | 242 | <?php } ?> |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | echo $ticket_status_display; |
249 | 249 | // depending on group reg we need to change the format for qty |
250 | - if ( $hidden_input_qty ) { |
|
250 | + if ($hidden_input_qty) { |
|
251 | 251 | ?> |
252 | 252 | <input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="0" /> |
253 | 253 | <?php |
@@ -257,33 +257,33 @@ discard block |
||
257 | 257 | |
258 | 258 | </td> |
259 | 259 | </tr> |
260 | - <?php if ( $template_settings->show_ticket_details ) : ?> |
|
261 | - <tr class="tckt-slctr-tkt-details-tr <?php echo espresso_get_object_css_class( $ticket, '', 'details' );?>"> |
|
260 | + <?php if ($template_settings->show_ticket_details) : ?> |
|
261 | + <tr class="tckt-slctr-tkt-details-tr <?php echo espresso_get_object_css_class($ticket, '', 'details'); ?>"> |
|
262 | 262 | <td class="tckt-slctr-tkt-details-td" colspan="<?php echo $cols; ?>" > |
263 | 263 | <div id="<?php echo $ticket_details_css_id; ?>-dv" class="tckt-slctr-tkt-details-dv" style="display: none;"> |
264 | 264 | |
265 | 265 | <section class="tckt-slctr-tkt-details-sctn"> |
266 | - <h3><?php _e( 'Details', 'event_espresso' ); ?></h3> |
|
266 | + <h3><?php _e('Details', 'event_espresso'); ?></h3> |
|
267 | 267 | <p><?php echo $ticket->description(); ?></p> |
268 | 268 | |
269 | - <?php if ( $ticket_price !== 0 && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?> |
|
269 | + <?php if ($ticket_price !== 0 && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?> |
|
270 | 270 | <section class="tckt-slctr-tkt-price-sctn"> |
271 | - <h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', __( 'Price', 'event_espresso' )); ?></h5> |
|
271 | + <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', __('Price', 'event_espresso')); ?></h5> |
|
272 | 272 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
273 | 273 | <table class="tckt-slctr-tkt-details-tbl"> |
274 | 274 | <thead> |
275 | 275 | <tr> |
276 | - <th class="ee-third-width"><span class="small-text"><?php _e( 'Name', 'event_espresso' ); ?></span></th> |
|
277 | - <th class="jst-cntr"><span class="small-text"><?php _e( 'Description', 'event_espresso' ); ?></span></th> |
|
278 | - <th class="ee-fourth-width jst-rght"><span class="small-text"><?php _e( 'Amount', 'event_espresso' ); ?></span></th> |
|
276 | + <th class="ee-third-width"><span class="small-text"><?php _e('Name', 'event_espresso'); ?></span></th> |
|
277 | + <th class="jst-cntr"><span class="small-text"><?php _e('Description', 'event_espresso'); ?></span></th> |
|
278 | + <th class="ee-fourth-width jst-rght"><span class="small-text"><?php _e('Amount', 'event_espresso'); ?></span></th> |
|
279 | 279 | </tr> |
280 | 280 | </thead> |
281 | 281 | <tbody> |
282 | - <?php if ( $ticket->base_price() instanceof EE_Price ) { ?> |
|
282 | + <?php if ($ticket->base_price() instanceof EE_Price) { ?> |
|
283 | 283 | <tr> |
284 | - <td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="small-text"><b><?php echo $ticket->base_price()->name(); ?></b></td> |
|
285 | - <td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $ticket->base_price()->desc(); ?></td> |
|
286 | - <td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $ticket->base_price()->pretty_price(); ?></td> |
|
284 | + <td data-th="<?php _e('Name', 'event_espresso'); ?>" class="small-text"><b><?php echo $ticket->base_price()->name(); ?></b></td> |
|
285 | + <td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $ticket->base_price()->desc(); ?></td> |
|
286 | + <td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $ticket->base_price()->pretty_price(); ?></td> |
|
287 | 287 | </tr> |
288 | 288 | <?php |
289 | 289 | $running_total = $ticket->base_price()->amount(); |
@@ -291,44 +291,44 @@ discard block |
||
291 | 291 | $running_total = 0; |
292 | 292 | } |
293 | 293 | // now add price modifiers |
294 | - foreach ( $ticket->price_modifiers() as $price_mod ) { ?> |
|
294 | + foreach ($ticket->price_modifiers() as $price_mod) { ?> |
|
295 | 295 | <tr> |
296 | - <td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $price_mod->name(); ?></td> |
|
297 | - <?php if ( $price_mod->is_percent() ) { ?> |
|
298 | - <td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $price_mod->desc(); ?> <?php echo $price_mod->amount(); ?>%</td> |
|
296 | + <td data-th="<?php _e('Name', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $price_mod->name(); ?></td> |
|
297 | + <?php if ($price_mod->is_percent()) { ?> |
|
298 | + <td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $price_mod->desc(); ?> <?php echo $price_mod->amount(); ?>%</td> |
|
299 | 299 | <?php |
300 | - $new_sub_total = $running_total * ( $price_mod->amount() / 100 ); |
|
300 | + $new_sub_total = $running_total * ($price_mod->amount() / 100); |
|
301 | 301 | $new_sub_total = $price_mod->is_discount() ? $new_sub_total * -1 : $new_sub_total; |
302 | 302 | ?> |
303 | 303 | <?php } else { ?> |
304 | 304 | <?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 : $price_mod->amount(); ?> |
305 | - <td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $price_mod->desc(); ?></td> |
|
305 | + <td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $price_mod->desc(); ?></td> |
|
306 | 306 | <?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 : $price_mod->amount(); ?> |
307 | 307 | <?php } ?> |
308 | - <td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency( $new_sub_total ); ?></td> |
|
308 | + <td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency($new_sub_total); ?></td> |
|
309 | 309 | <?php $running_total += $new_sub_total; ?> |
310 | 310 | </tr> |
311 | 311 | <?php } ?> |
312 | - <?php if ( $ticket->taxable() ) { ?> |
|
312 | + <?php if ($ticket->taxable()) { ?> |
|
313 | 313 | <?php //$ticket_subtotal =$ticket->get_ticket_subtotal(); ?> |
314 | 314 | <tr> |
315 | - <td colspan="2" class="jst-rght small-text sbttl"><b><?php _e( 'subtotal', 'event_espresso' ); ?></b></td> |
|
316 | - <td data-th="<?php _e( 'subtotal', 'event_espresso' ); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency( $running_total ); ?></b></td> |
|
315 | + <td colspan="2" class="jst-rght small-text sbttl"><b><?php _e('subtotal', 'event_espresso'); ?></b></td> |
|
316 | + <td data-th="<?php _e('subtotal', 'event_espresso'); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency($running_total); ?></b></td> |
|
317 | 317 | </tr> |
318 | 318 | |
319 | - <?php foreach ( $ticket->get_ticket_taxes_for_admin() as $tax ) { ?> |
|
319 | + <?php foreach ($ticket->get_ticket_taxes_for_admin() as $tax) { ?> |
|
320 | 320 | <tr> |
321 | - <td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $tax->name(); ?></td> |
|
322 | - <td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $tax->amount(); ?>%</td> |
|
323 | - <?php $tax_amount = $running_total * ( $tax->amount() / 100 ); ?> |
|
324 | - <td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency( $tax_amount ); ?></td> |
|
321 | + <td data-th="<?php _e('Name', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $tax->name(); ?></td> |
|
322 | + <td data-th="<?php _e('Description', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $tax->amount(); ?>%</td> |
|
323 | + <?php $tax_amount = $running_total * ($tax->amount() / 100); ?> |
|
324 | + <td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency($tax_amount); ?></td> |
|
325 | 325 | <?php $running_total += $tax_amount; ?> |
326 | 326 | </tr> |
327 | 327 | <?php } ?> |
328 | 328 | <?php } ?> |
329 | 329 | <tr> |
330 | - <td colspan="2" class="jst-rght small-text ttl-lbl-td"><b><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_total_price', __( 'Total', 'event_espresso' )); ?></b></td> |
|
331 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_total_price', __( 'Total', 'event_espresso' )); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency( $running_total ); ?></b></td> |
|
330 | + <td colspan="2" class="jst-rght small-text ttl-lbl-td"><b><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', __('Total', 'event_espresso')); ?></b></td> |
|
331 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', __('Total', 'event_espresso')); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency($running_total); ?></b></td> |
|
332 | 332 | </tr> |
333 | 333 | </tbody> |
334 | 334 | </table> |
@@ -338,106 +338,106 @@ discard block |
||
338 | 338 | <?php } ?> |
339 | 339 | |
340 | 340 | <section class="tckt-slctr-tkt-sale-dates-sctn"> |
341 | - <h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', __( 'Sale Dates', 'event_espresso' )); ?></h5> |
|
342 | - <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', __( 'The dates when this option is available for purchase.', 'event_espresso' )); ?></span><br/> |
|
343 | - <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', __( 'Goes On Sale:', 'event_espresso' )); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime( 'TKT_start_date', $date_format) . ' '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime( 'TKT_start_date', $time_format ) ; ?><br/> |
|
344 | - <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', __( 'Sales End:', 'event_espresso' )); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime( 'TKT_end_date', $date_format ) . ' '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime( 'TKT_end_date', $time_format ) ; ?><br/> |
|
341 | + <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', __('Sale Dates', 'event_espresso')); ?></h5> |
|
342 | + <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', __('The dates when this option is available for purchase.', 'event_espresso')); ?></span><br/> |
|
343 | + <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', __('Goes On Sale:', 'event_espresso')); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime('TKT_start_date', $date_format).' '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime('TKT_start_date', $time_format); ?><br/> |
|
344 | + <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_sales_end', __('Sales End:', 'event_espresso')); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime('TKT_end_date', $date_format).' '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime('TKT_end_date', $time_format); ?><br/> |
|
345 | 345 | </section> |
346 | 346 | <br/> |
347 | 347 | |
348 | - <?php do_action( 'AHEE__ticket_selector_chart_template__after_ticket_date', $ticket ); ?> |
|
348 | + <?php do_action('AHEE__ticket_selector_chart_template__after_ticket_date', $ticket); ?> |
|
349 | 349 | |
350 | - <?php if ( $ticket->min() &&$ticket->max() ) { ?> |
|
350 | + <?php if ($ticket->min() && $ticket->max()) { ?> |
|
351 | 351 | <section class="tckt-slctr-tkt-quantities-sctn"> |
352 | - <h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', __( 'Purchasable Quantities', 'event_espresso' )); ?></h5> |
|
353 | - <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', __( 'The number of tickets that can be purchased per transaction (if available).', 'event_espresso' )); ?></span><br/> |
|
354 | - <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', __( 'Minimum Qty:', 'event_espresso' )); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?> |
|
355 | - <?php if ( $ticket->min() > $remaining ) { ?> <span class="important-notice small-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', __( 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', 'event_espresso' )); ?></span><?php } ?><br/> |
|
352 | + <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', __('Purchasable Quantities', 'event_espresso')); ?></h5> |
|
353 | + <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', __('The number of tickets that can be purchased per transaction (if available).', 'event_espresso')); ?></span><br/> |
|
354 | + <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', __('Minimum Qty:', 'event_espresso')); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?> |
|
355 | + <?php if ($ticket->min() > $remaining) { ?> <span class="important-notice small-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', __('The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', 'event_espresso')); ?></span><?php } ?><br/> |
|
356 | 356 | <?php //$max = min( $max, $max_atndz );?> |
357 | - <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', __( 'Maximum Qty:', 'event_espresso' )); ?></span><?php echo $ticket->max() === EE_INF ? __( 'no limit', 'event_espresso' ) : max( $ticket->max(), 1 ); ?><br/> |
|
357 | + <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', __('Maximum Qty:', 'event_espresso')); ?></span><?php echo $ticket->max() === EE_INF ? __('no limit', 'event_espresso') : max($ticket->max(), 1); ?><br/> |
|
358 | 358 | </section> |
359 | 359 | <br/> |
360 | 360 | <?php } ?> |
361 | 361 | |
362 | - <?php if ( $ticket->uses() !== EE_INF && ( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE )) { ?> |
|
362 | + <?php if ($ticket->uses() !== EE_INF && ( ! defined('EE_DECAF') || EE_DECAF !== TRUE)) { ?> |
|
363 | 363 | <section class="tckt-slctr-tkt-uses-sctn"> |
364 | - <h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', __( 'Event Date Ticket Uses', 'event_espresso' )); ?></h5> |
|
364 | + <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', __('Event Date Ticket Uses', 'event_espresso')); ?></h5> |
|
365 | 365 | <span class="drk-grey-text small-text no-bold"> - <?php |
366 | 366 | echo apply_filters( |
367 | 367 | 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
368 | 368 | sprintf( |
369 | - __( 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', 'event_espresso' ), |
|
369 | + __('The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', 'event_espresso'), |
|
370 | 370 | '<br/>', |
371 | 371 | '<strong>', |
372 | 372 | '</strong>' |
373 | 373 | ) |
374 | 374 | ); |
375 | 375 | ?></span><br/> |
376 | - <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', __( '# Datetimes:', 'event_espresso' )); ?></span><?php echo $ticket->uses();?><br/> |
|
376 | + <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', __('# Datetimes:', 'event_espresso')); ?></span><?php echo $ticket->uses(); ?><br/> |
|
377 | 377 | </section> |
378 | 378 | <?php } ?> |
379 | 379 | |
380 | 380 | <?php |
381 | - $datetimes = $ticket->datetimes_ordered( $event_is_expired, FALSE ); |
|
381 | + $datetimes = $ticket->datetimes_ordered($event_is_expired, FALSE); |
|
382 | 382 | $chart_column_width = $template_settings->show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
383 | - if ( ! empty( $datetimes )) { ?> |
|
383 | + if ( ! empty($datetimes)) { ?> |
|
384 | 384 | <section class="tckt-slctr-tkt-datetimes-sctn"> |
385 | - <h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', __( 'Access', 'event_espresso' )); ?></h5> |
|
386 | - <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', __( 'This option allows access to the following dates and times.', 'event_espresso' )); ?></span> |
|
385 | + <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', __('Access', 'event_espresso')); ?></h5> |
|
386 | + <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_message', __('This option allows access to the following dates and times.', 'event_espresso')); ?></span> |
|
387 | 387 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
388 | 388 | <table class="tckt-slctr-tkt-details-tbl"> |
389 | 389 | <thead> |
390 | 390 | <tr> |
391 | 391 | <th class="tckt-slctr-tkt-details-date-th"> |
392 | - <span class="dashicons dashicons-calendar"></span><span class="small-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __( 'Date ', 'event_espresso' )); ?></span> |
|
392 | + <span class="dashicons dashicons-calendar"></span><span class="small-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __('Date ', 'event_espresso')); ?></span> |
|
393 | 393 | </th> |
394 | 394 | <th class="tckt-slctr-tkt-details-time-th <?php echo $chart_column_width; ?>"> |
395 | - <span class="dashicons dashicons-clock"></span><span class="small-text"><?php _e( 'Time ', 'event_espresso' ); ?></span> |
|
395 | + <span class="dashicons dashicons-clock"></span><span class="small-text"><?php _e('Time ', 'event_espresso'); ?></span> |
|
396 | 396 | </th> |
397 | - <?php if ( $template_settings->show_ticket_sale_columns ) : ?> |
|
397 | + <?php if ($template_settings->show_ticket_sale_columns) : ?> |
|
398 | 398 | <th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr"> |
399 | - <span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', sprintf( __( 'Sold', 'event_espresso' ), '<br/>' )); ?></span> |
|
399 | + <span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', sprintf(__('Sold', 'event_espresso'), '<br/>')); ?></span> |
|
400 | 400 | </th> |
401 | 401 | <th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr"> |
402 | - <span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', sprintf( __( 'Remaining', 'event_espresso' ), '<br/>' )); ?></span> |
|
402 | + <span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', sprintf(__('Remaining', 'event_espresso'), '<br/>')); ?></span> |
|
403 | 403 | </th> |
404 | 404 | <th class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr"> |
405 | - <span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', sprintf( __( 'Total%sSold', 'event_espresso' ), '<br/>' )); ?></span> |
|
405 | + <span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', sprintf(__('Total%sSold', 'event_espresso'), '<br/>')); ?></span> |
|
406 | 406 | </th> |
407 | 407 | <th class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr"> |
408 | - <span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', sprintf( __( 'Total Spaces%sLeft', 'event_espresso' ), '<br/>' )); ?></span> |
|
408 | + <span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', sprintf(__('Total Spaces%sLeft', 'event_espresso'), '<br/>')); ?></span> |
|
409 | 409 | </th> |
410 | 410 | <?php endif; //end $template_settings->show_ticket_sale_columns conditional ?> |
411 | 411 | </tr> |
412 | 412 | </thead> |
413 | 413 | <tbody> |
414 | 414 | <?php |
415 | - foreach ( $datetimes as $datetime ) { |
|
416 | - if ( $datetime instanceof EE_Datetime ) { |
|
415 | + foreach ($datetimes as $datetime) { |
|
416 | + if ($datetime instanceof EE_Datetime) { |
|
417 | 417 | ?> |
418 | 418 | |
419 | 419 | <tr> |
420 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __( 'Event Date ', 'event_espresso' )); ?>" class="small-text"> |
|
420 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __('Event Date ', 'event_espresso')); ?>" class="small-text"> |
|
421 | 421 | <?php $datetime_name = $datetime->name(); ?> |
422 | - <?php echo ! empty( $datetime_name ) ? '<b>' . $datetime_name . '</b><br/>' : ''; ?> |
|
423 | - <?php echo $datetime->date_range( $date_format, __( ' to ', 'event_espresso' )); ?> |
|
422 | + <?php echo ! empty($datetime_name) ? '<b>'.$datetime_name.'</b><br/>' : ''; ?> |
|
423 | + <?php echo $datetime->date_range($date_format, __(' to ', 'event_espresso')); ?> |
|
424 | 424 | </td> |
425 | - <td data-th="<?php _e( 'Time ', 'event_espresso' ); ?>" class="cntr small-text"> |
|
426 | - <?php echo $datetime->time_range( $time_format, __( ' to ', 'event_espresso' )); ?> |
|
425 | + <td data-th="<?php _e('Time ', 'event_espresso'); ?>" class="cntr small-text"> |
|
426 | + <?php echo $datetime->time_range($time_format, __(' to ', 'event_espresso')); ?> |
|
427 | 427 | </td> |
428 | - <?php if ( $template_settings->show_ticket_sale_columns ) : ?> |
|
429 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', __( 'Sold', 'event_espresso' )); ?>" class="cntr small-text"> |
|
428 | + <?php if ($template_settings->show_ticket_sale_columns) : ?> |
|
429 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', __('Sold', 'event_espresso')); ?>" class="cntr small-text"> |
|
430 | 430 | <?php echo $ticket->sold(); ?> |
431 | 431 | </td> |
432 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', __( 'Remaining', 'event_espresso' )); ?>" class="cntr small-text"> |
|
433 | - <?php echo $ticket->qty() === EE_INF ? '<span class="smaller-text">' . __( 'unlimited ', 'event_espresso' ) . '</span>' : $ticket->qty() - $ticket->sold(); ?> |
|
432 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', __('Remaining', 'event_espresso')); ?>" class="cntr small-text"> |
|
433 | + <?php echo $ticket->qty() === EE_INF ? '<span class="smaller-text">'.__('unlimited ', 'event_espresso').'</span>' : $ticket->qty() - $ticket->sold(); ?> |
|
434 | 434 | </td> |
435 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', __( 'Total Sold', 'event_espresso' )); ?>" class="cntr small-text"> |
|
435 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', __('Total Sold', 'event_espresso')); ?>" class="cntr small-text"> |
|
436 | 436 | <?php echo $datetime->sold(); ?> |
437 | 437 | </td> |
438 | - <?php $tkts_left = $datetime->sold_out() ? '<span class="sold-out smaller-text">' . __( 'Sold Out', 'event_espresso' ) . '</span>' : $datetime->spaces_remaining(); ?> |
|
439 | - <td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', __( 'Total Spaces Left', 'event_espresso' )); ?>" class="cntr small-text"> |
|
440 | - <?php echo $tkts_left === EE_INF ? '<span class="smaller-text">' . __( 'unlimited ', 'event_espresso' ) . '</span>' : $tkts_left; ?> |
|
438 | + <?php $tkts_left = $datetime->sold_out() ? '<span class="sold-out smaller-text">'.__('Sold Out', 'event_espresso').'</span>' : $datetime->spaces_remaining(); ?> |
|
439 | + <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', __('Total Spaces Left', 'event_espresso')); ?>" class="cntr small-text"> |
|
440 | + <?php echo $tkts_left === EE_INF ? '<span class="smaller-text">'.__('unlimited ', 'event_espresso').'</span>' : $tkts_left; ?> |
|
441 | 441 | </td> |
442 | 442 | <?php endif; //end $template_settings->show_ticket_sale_columns conditional ?> |
443 | 443 | </tr> |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | </div> |
456 | 456 | </td> |
457 | 457 | </tr> |
458 | - <?php endif; //end template_settings->show_ticket_details check?> |
|
458 | + <?php endif; //end template_settings->show_ticket_details check?> |
|
459 | 459 | <?php |
460 | 460 | $row++; |
461 | 461 | } |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | $ticket_row_html = ob_get_clean(); |
465 | 465 | // if there is only ONE ticket with a max qty of ONE, and it is free... then not much need for the ticket selector |
466 | 466 | $hide_ticket_selector = $ticket_count === 1 && $max_atndz === 1 && $ticket->is_free() ? true : false; |
467 | -$hide_ticket_selector = apply_filters( 'FHEE__ticket_selector_chart_template__hide_ticket_selector', $hide_ticket_selector, $EVT_ID ); |
|
467 | +$hide_ticket_selector = apply_filters('FHEE__ticket_selector_chart_template__hide_ticket_selector', $hide_ticket_selector, $EVT_ID); |
|
468 | 468 | // \EEH_Debug_Tools::printr( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ), 'display submit', __FILE__, __LINE__ ); |
469 | 469 | // EEH_Debug_Tools::printr( (string) $ticket_count, '$ticket_count', __FILE__, __LINE__ ); |
470 | 470 | // EEH_Debug_Tools::printr( (string) $max, '$max', __FILE__, __LINE__ ); |
@@ -479,20 +479,20 @@ discard block |
||
479 | 479 | * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
480 | 480 | * @param int $EVT_ID The Event ID |
481 | 481 | */ |
482 | -$anchor_id = apply_filters( 'FHEE__EE_Ticket_Selector__redirect_anchor_id', '#tkt-slctr-tbl-' . $EVT_ID, $EVT_ID ); |
|
483 | -if ( ! $hide_ticket_selector ) { |
|
482 | +$anchor_id = apply_filters('FHEE__EE_Ticket_Selector__redirect_anchor_id', '#tkt-slctr-tbl-'.$EVT_ID, $EVT_ID); |
|
483 | +if ( ! $hide_ticket_selector) { |
|
484 | 484 | ?> |
485 | 485 | <div id="tkt-slctr-tbl-wrap-dv-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl-wrap-dv"> |
486 | 486 | |
487 | - <?php do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); ?> |
|
487 | + <?php do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); ?> |
|
488 | 488 | |
489 | 489 | <table id="tkt-slctr-tbl-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl"> |
490 | 490 | <thead> |
491 | 491 | <tr> |
492 | 492 | <th scope="col" class="ee-ticket-selector-ticket-details-th"> |
493 | - <?php echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_available_tickets', '', $EVT_ID ) ); ?> |
|
493 | + <?php echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_available_tickets', '', $EVT_ID)); ?> |
|
494 | 494 | </th> |
495 | - <?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) && $max_atndz > 1 ) { ?> |
|
495 | + <?php if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE) && $max_atndz > 1) { ?> |
|
496 | 496 | <th scope="col" class="ee-ticket-selector-ticket-price-th cntr"> |
497 | 497 | <?php |
498 | 498 | /** |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * @param string 'Price' The translatable text to display in the table header for price |
504 | 504 | * @param int $EVT_ID The Event ID |
505 | 505 | */ |
506 | - echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_price', __( 'Price', 'event_espresso' ), $EVT_ID ) ); |
|
506 | + echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_price', __('Price', 'event_espresso'), $EVT_ID)); |
|
507 | 507 | ?> |
508 | 508 | </th> |
509 | 509 | <?php } ?> |
@@ -517,75 +517,75 @@ discard block |
||
517 | 517 | * @param string 'Qty*' The translatable text to display in the table header for the Quantity of tickets |
518 | 518 | * @param int $EVT_ID The Event ID |
519 | 519 | */ |
520 | - echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_qty', __( 'Qty*', 'event_espresso' ), $EVT_ID ) ); |
|
520 | + echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_qty', __('Qty*', 'event_espresso'), $EVT_ID)); |
|
521 | 521 | ?> |
522 | 522 | </th> |
523 | 523 | </tr> |
524 | 524 | </thead> |
525 | 525 | <tbody> |
526 | - <?php echo $ticket_row_html;?> |
|
526 | + <?php echo $ticket_row_html; ?> |
|
527 | 527 | </tbody> |
528 | 528 | </table> |
529 | 529 | <?php |
530 | - if ( $taxable_tickets && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', true ) ) { |
|
531 | - if ( $tax_settings->prices_displayed_including_taxes ) { |
|
532 | - $ticket_price_includes_taxes = __( '* price includes taxes', 'event_espresso' ); |
|
530 | + if ($taxable_tickets && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
531 | + if ($tax_settings->prices_displayed_including_taxes) { |
|
532 | + $ticket_price_includes_taxes = __('* price includes taxes', 'event_espresso'); |
|
533 | 533 | } else { |
534 | - $ticket_price_includes_taxes = __( '* price does not include taxes', 'event_espresso' ); |
|
534 | + $ticket_price_includes_taxes = __('* price does not include taxes', 'event_espresso'); |
|
535 | 535 | } |
536 | - echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">' . $ticket_price_includes_taxes . '</p>'; |
|
536 | + echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">'.$ticket_price_includes_taxes.'</p>'; |
|
537 | 537 | } |
538 | 538 | ?> |
539 | 539 | |
540 | 540 | <input type="hidden" name="noheader" value="true" /> |
541 | - <input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url() . $anchor_id; ?>" /> |
|
541 | + <input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url().$anchor_id; ?>" /> |
|
542 | 542 | <input type="hidden" name="tkt-slctr-rows-<?php echo $EVT_ID; ?>" value="<?php echo $row - 1; ?>" /> |
543 | 543 | <input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?>" value="<?php echo $max_atndz; ?>" /> |
544 | 544 | <input type="hidden" name="tkt-slctr-event-id" value="<?php echo $EVT_ID; ?>" /> |
545 | 545 | |
546 | 546 | <?php |
547 | -if ( $max_atndz > 0 ) { |
|
547 | +if ($max_atndz > 0) { |
|
548 | 548 | echo apply_filters( |
549 | 549 | 'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote', |
550 | 550 | '' |
551 | 551 | ); |
552 | 552 | } |
553 | -if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
554 | - add_filter( 'FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true' ); |
|
553 | +if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
554 | + add_filter('FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true'); |
|
555 | 555 | } |
556 | -do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
556 | +do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); |
|
557 | 557 | ?> |
558 | 558 | |
559 | 559 | </div> |
560 | -<?php } else if ( isset( $TKT_ID ) ) { ?> |
|
560 | +<?php } else if (isset($TKT_ID)) { ?> |
|
561 | 561 | |
562 | 562 | <input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="1"/> |
563 | 563 | <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/> |
564 | 564 | <input type="hidden" name="noheader" value="true"/> |
565 | -<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url() . $anchor_id; ?>"/> |
|
565 | +<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url().$anchor_id; ?>"/> |
|
566 | 566 | <input type="hidden" name="tkt-slctr-rows-<?php echo $EVT_ID; ?>" value="<?php echo $row - 1; ?>"/> |
567 | 567 | <input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?>" value="<?php echo $max_atndz; ?>"/> |
568 | 568 | <input type="hidden" name="tkt-slctr-event-id" value="<?php echo $EVT_ID; ?>"/> |
569 | 569 | <?php |
570 | - if ( $ticket instanceof EE_Ticket ) { |
|
571 | - do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); |
|
570 | + if ($ticket instanceof EE_Ticket) { |
|
571 | + do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); |
|
572 | 572 | $ticket_description = $ticket->description(); |
573 | - $ticket_description .= ! empty( $ticket_description ) |
|
574 | - ? '<br />' . $ticket_status_display |
|
573 | + $ticket_description .= ! empty($ticket_description) |
|
574 | + ? '<br />'.$ticket_status_display |
|
575 | 575 | : $ticket_status_display; |
576 | - if ( ! strpos( $ticket_description, '<div' ) ) { |
|
576 | + if ( ! strpos($ticket_description, '<div')) { |
|
577 | 577 | $ticket_description = "<p>{$ticket_description}</p>"; |
578 | 578 | } |
579 | 579 | ?> |
580 | 580 | <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv"> |
581 | 581 | <div class="no-tkt-slctr-ticket-content-dv"> |
582 | 582 | <h5><?php echo $ticket->name(); ?></h5> |
583 | - <?php if ( ! empty( $ticket_description ) ) { ?> |
|
583 | + <?php if ( ! empty($ticket_description)) { ?> |
|
584 | 584 | <?php echo $ticket_description; ?> |
585 | 585 | <?php } ?> |
586 | 586 | </div> |
587 | 587 | <?php |
588 | - do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
588 | + do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | ?> |
@@ -259,7 +259,7 @@ |
||
259 | 259 | * @param int $ID |
260 | 260 | * @param $shortcode_class |
261 | 261 | * @param $shortcode_posts |
262 | - * @param $page_for_posts |
|
262 | + * @param string $page_for_posts |
|
263 | 263 | * @param bool $update_post_shortcodes |
264 | 264 | * @return bool |
265 | 265 | */ |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\core\admin; |
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,450 +19,450 @@ discard block |
||
19 | 19 | class PostShortcodeTracking |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * set_hooks_admin |
|
24 | - * |
|
25 | - * @access public |
|
26 | - */ |
|
27 | - public static function set_hooks_admin() |
|
28 | - { |
|
29 | - add_action( |
|
30 | - 'save_post', |
|
31 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
32 | - 100, |
|
33 | - 2 |
|
34 | - ); |
|
35 | - add_action( |
|
36 | - 'delete_post', |
|
37 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
38 | - 100, |
|
39 | - 1 |
|
40 | - ); |
|
41 | - add_action( |
|
42 | - 'add_option_page_for_posts', |
|
43 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
44 | - 100, |
|
45 | - 2 |
|
46 | - ); |
|
47 | - add_action( |
|
48 | - 'update_option', |
|
49 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
50 | - 100, |
|
51 | - 3 |
|
52 | - ); |
|
53 | - add_action( |
|
54 | - 'delete_option', |
|
55 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
56 | - 100, |
|
57 | - 1 |
|
58 | - ); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * parse_post_content_on_save |
|
65 | - * any time a post is saved, we need to check for any EE shortcodes that may be embedded in the content, |
|
66 | - * and then track what posts those shortcodes are on, so that we can initialize shortcodes well before |
|
67 | - * the_content() runs. this allows us to do things like enqueue scripts for shortcodes ONLY on the pages the |
|
68 | - * shortcodes are actually used on |
|
69 | - * |
|
70 | - * @access public |
|
71 | - * @param int $post_ID |
|
72 | - * @param \WP_Post $post |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - public static function parse_post_content_on_save( $post_ID, $post ) |
|
76 | - { |
|
77 | - // if the post is trashed, then let's remove our post shortcode tracking |
|
78 | - if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
79 | - PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
80 | - return; |
|
81 | - } |
|
82 | - // default post types |
|
83 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
84 | - // add CPTs |
|
85 | - $CPTs = \EE_Register_CPTs::get_CPTs(); |
|
86 | - $post_types = array_merge( $post_types, $CPTs ); |
|
87 | - // for default or CPT posts... |
|
88 | - if ( isset( $post_types[ $post->post_type ] ) ) { |
|
89 | - // post on frontpage ? |
|
90 | - $page_for_posts = \EE_Config::get_page_for_posts(); |
|
91 | - if ( $post->post_name === $page_for_posts ) { |
|
92 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
93 | - return; |
|
94 | - } |
|
95 | - // array of shortcodes indexed by post name |
|
96 | - \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
97 | - ? \EE_Registry::CFG()->core->post_shortcodes |
|
98 | - : array(); |
|
99 | - // whether to proceed with update |
|
100 | - $update_post_shortcodes = false; |
|
101 | - // empty both arrays |
|
102 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
103 | - // check that posts page is already being tracked |
|
104 | - if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
105 | - // if not, then ensure that it is properly added |
|
106 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
107 | - } |
|
108 | - // loop thru shortcodes |
|
109 | - foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
110 | - // convert to UPPERCASE to get actual shortcode |
|
111 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
112 | - // is the shortcode in the post_content ? |
|
113 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
114 | - // map shortcode to post names and post IDs |
|
115 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
116 | - // and add this shortcode to the tracking for the blog page |
|
117 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, |
|
118 | - $post_ID ); |
|
119 | - $update_post_shortcodes = true; |
|
120 | - } else { |
|
121 | - // shortcode is not present in post content, so check if we were tracking it previously |
|
122 | - // stop tracking if shortcode is not used in this specific post |
|
123 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
124 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
125 | - $update_post_shortcodes = true; |
|
126 | - } |
|
127 | - // make sure that something is set for the shortcode posts (even though we may remove this) |
|
128 | - $shortcode_posts = isset( |
|
129 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
130 | - ) |
|
131 | - ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
132 | - : array(); |
|
133 | - // and stop tracking for this shortcode on the blog page if it is not used |
|
134 | - $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
135 | - $post_ID, |
|
136 | - $EES_Shortcode, |
|
137 | - $shortcode_posts, |
|
138 | - $page_for_posts, |
|
139 | - $update_post_shortcodes |
|
140 | - ) |
|
141 | - ? true |
|
142 | - : $update_post_shortcodes; |
|
143 | - } |
|
144 | - } |
|
145 | - if ( $update_post_shortcodes ) { |
|
146 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
147 | - } |
|
148 | - } |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * set_post_shortcodes_for_posts_page (plz note: shortcodes is plural) |
|
155 | - * called when updating the WordPress Posts Page, |
|
156 | - * and adds shortcode tracking for the Posts Page, for all shortcodes currently tracked on individual posts |
|
157 | - * |
|
158 | - * @access protected |
|
159 | - * @param string $page_for_posts |
|
160 | - * @return void |
|
161 | - */ |
|
162 | - protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) |
|
163 | - { |
|
164 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
165 | - // loop thru shortcodes |
|
166 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
167 | - foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
168 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
169 | - } |
|
170 | - } |
|
171 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * set_post_shortcode_for_posts_page (plz note: shortcode is singular) |
|
178 | - * adds Posts Page shortcode tracking for the supplied shortcode for an individual post |
|
179 | - * |
|
180 | - * @access protected |
|
181 | - * @param string $page_for_posts |
|
182 | - * @param $EES_Shortcode |
|
183 | - * @param $post_ID |
|
184 | - */ |
|
185 | - protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) |
|
186 | - { |
|
187 | - // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
188 | - $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
|
189 | - // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
|
190 | - if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
191 | - return; |
|
192 | - } |
|
193 | - // add shortcode to "Posts page" tracking |
|
194 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
195 | - // make sure tracking is in form of an array |
|
196 | - if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
197 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
198 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true, |
|
199 | - ); |
|
200 | - } |
|
201 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
202 | - } else { |
|
203 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * unset_post_shortcodes_on_delete |
|
211 | - * |
|
212 | - * @access protected |
|
213 | - * @param int $ID |
|
214 | - * @return void |
|
215 | - */ |
|
216 | - public static function unset_post_shortcodes_on_delete( $ID ) |
|
217 | - { |
|
218 | - $update_post_shortcodes = false; |
|
219 | - // post on frontpage ? |
|
220 | - $page_for_posts = \EE_Config::get_page_for_posts(); |
|
221 | - // looking for any references to this post |
|
222 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
223 | - // is this the "Posts Page" (blog) ? |
|
224 | - if ( $post_name === $page_for_posts ) { |
|
225 | - // loop thru shortcodes registered for the posts page |
|
226 | - foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
227 | - $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
228 | - $ID, |
|
229 | - $shortcode_class, |
|
230 | - $shortcode_posts, |
|
231 | - $page_for_posts, |
|
232 | - $update_post_shortcodes |
|
233 | - ) |
|
234 | - ? true |
|
235 | - : $update_post_shortcodes; |
|
236 | - } |
|
237 | - } else { |
|
238 | - // loop thru shortcodes registered for each page |
|
239 | - foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
240 | - // if this is page is being deleted, then don't track any post shortcodes for it |
|
241 | - if ( $post_ID === $ID ) { |
|
242 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
243 | - $update_post_shortcodes = true; |
|
244 | - } |
|
245 | - } |
|
246 | - } |
|
247 | - } |
|
248 | - if ( $update_post_shortcodes ) { |
|
249 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * unset_post_shortcodes_on_delete |
|
257 | - * |
|
258 | - * @access protected |
|
259 | - * @param int $ID |
|
260 | - * @param $shortcode_class |
|
261 | - * @param $shortcode_posts |
|
262 | - * @param $page_for_posts |
|
263 | - * @param bool $update_post_shortcodes |
|
264 | - * @return bool |
|
265 | - */ |
|
266 | - protected static function unset_posts_page_shortcode_for_post( |
|
267 | - $ID, |
|
268 | - $shortcode_class, |
|
269 | - $shortcode_posts, |
|
270 | - $page_for_posts, |
|
271 | - $update_post_shortcodes = false |
|
272 | - ) { |
|
273 | - // make sure that an array of post IDs is being tracked for each shortcode |
|
274 | - if ( ! is_array( $shortcode_posts ) ) { |
|
275 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
276 | - $shortcode_posts => true, |
|
277 | - ); |
|
278 | - $update_post_shortcodes = true; |
|
279 | - } |
|
280 | - // now if the ID of the post being deleted is in the $shortcode_posts array |
|
281 | - if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
282 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
283 | - $update_post_shortcodes = true; |
|
284 | - } |
|
285 | - // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
|
286 | - if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
287 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
288 | - $update_post_shortcodes = true; |
|
289 | - } |
|
290 | - return $update_post_shortcodes; |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * update_post_shortcodes |
|
297 | - * |
|
298 | - * @access public |
|
299 | - * @param $page_for_posts |
|
300 | - * @return void |
|
301 | - */ |
|
302 | - public static function update_post_shortcodes( $page_for_posts = '' ) |
|
303 | - { |
|
304 | - // make sure page_for_posts is set |
|
305 | - $page_for_posts = ! empty( $page_for_posts ) |
|
306 | - ? $page_for_posts |
|
307 | - : \EE_Config::get_page_for_posts(); |
|
308 | - // allow others to mess stuff up :D |
|
309 | - do_action( |
|
310 | - 'AHEE__\EventEspresso\core\admin\PostShortcodeTracking__update_post_shortcodes', |
|
311 | - \EE_Config::instance()->core->post_shortcodes, |
|
312 | - $page_for_posts |
|
313 | - ); |
|
314 | - // keep old hookpoint for now, will deprecate later |
|
315 | - do_action( |
|
316 | - 'AHEE__EE_Config__update_post_shortcodes', |
|
317 | - \EE_Config::instance()->core->post_shortcodes, |
|
318 | - $page_for_posts |
|
319 | - ); |
|
320 | - // verify that post_shortcodes is set |
|
321 | - \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
322 | - && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
323 | - ? \EE_Config::instance()->core->post_shortcodes |
|
324 | - : array(); |
|
325 | - // cycle thru post_shortcodes |
|
326 | - foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
327 | - // are there any shortcodes to track ? |
|
328 | - if ( ! empty( $shortcodes ) ) { |
|
329 | - // skip the posts page, because we want all shortcodes registered for it |
|
330 | - if ( $post_name === $page_for_posts ) { |
|
331 | - continue; |
|
332 | - } |
|
333 | - // loop thru list of tracked shortcodes |
|
334 | - foreach ( $shortcodes as $shortcode => $post_id ) { |
|
335 | - // make sure post still exists |
|
336 | - $post = get_post( $post_id ); |
|
337 | - // check that the post name matches what we have saved |
|
338 | - if ( $post && $post->post_name === $post_name ) { |
|
339 | - // if so, then break before hitting the unset below |
|
340 | - continue; |
|
341 | - } |
|
342 | - // we don't like missing posts around here >:( |
|
343 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
344 | - } |
|
345 | - } else { |
|
346 | - // you got no shortcodes to keep track of ! |
|
347 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
348 | - } |
|
349 | - } |
|
350 | - // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
351 | - $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
|
352 | - $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
353 | - foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
354 | - unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
355 | - } |
|
356 | - //only show errors |
|
357 | - \EE_Config::instance()->update_espresso_config(); |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * reset_page_for_posts_on_initial_set |
|
364 | - * if an admin is on the WP Reading Settings page and sets the option for "Posts page", |
|
365 | - * when it had previously been unset, |
|
366 | - * then we need to attribute any actively used shortcodes to the new blog page |
|
367 | - * |
|
368 | - * @access public |
|
369 | - * @param string $option |
|
370 | - * @param string $value |
|
371 | - * @return void |
|
372 | - */ |
|
373 | - public static function reset_page_for_posts_on_initial_set( $option, $value ) |
|
374 | - { |
|
375 | - PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * reset_page_for_posts_on_change |
|
382 | - * if an admin is on the WP Reading Settings page and changes the option for "Posts page", |
|
383 | - * then we need to attribute any actively used shortcodes for the previous blog page to the new blog page |
|
384 | - * |
|
385 | - * @access public |
|
386 | - * @param string $option |
|
387 | - * @param string $old_value |
|
388 | - * @param string $value |
|
389 | - * @return void |
|
390 | - */ |
|
391 | - public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) |
|
392 | - { |
|
393 | - if ( $option === 'page_for_posts' ) { |
|
394 | - global $wpdb; |
|
395 | - $table = $wpdb->posts; |
|
396 | - $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
397 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
398 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * reset_page_for_posts_on_delete |
|
406 | - * if an admin deletes a page designated as the WP "Posts page", |
|
407 | - * then we need to attribute any actively used shortcodes for that blog page to a generic 'posts' page |
|
408 | - * |
|
409 | - * @access public |
|
410 | - * @param string $option |
|
411 | - * @return void |
|
412 | - */ |
|
413 | - public static function reset_page_for_posts_on_delete( $option ) |
|
414 | - { |
|
415 | - if ( $option === 'page_for_posts' ) { |
|
416 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * @param array|string $shortcodes |
|
424 | - * @param bool $index_results if passing more than one shortcode for the $shortcodes parameter above, |
|
425 | - * then setting this to true, will return as associative array indexed by |
|
426 | - * the shortcodes. If false, then the returned array will be unindexed |
|
427 | - * @return array |
|
428 | - */ |
|
429 | - public static function get_post_ids_for_shortcode( $shortcodes, $index_results = true ) |
|
430 | - { |
|
431 | - $post_ids = array(); |
|
432 | - if ( is_array( $shortcodes ) ) { |
|
433 | - foreach ( $shortcodes as $shortcode ) { |
|
434 | - $new_post_ids = PostShortcodeTracking::get_post_ids_for_shortcode( |
|
435 | - $shortcode, |
|
436 | - $index_results |
|
437 | - ); |
|
438 | - foreach ( $new_post_ids as $new_post_id ) { |
|
439 | - if ( $index_results ) { |
|
440 | - $post_ids[ $shortcode ][ $new_post_id ] = $new_post_id; |
|
441 | - } else { |
|
442 | - $post_ids[ $new_post_id ] = $new_post_id; |
|
443 | - } |
|
444 | - } |
|
445 | - } |
|
446 | - } else { |
|
447 | - $shortcode = strtoupper( $shortcodes ); |
|
448 | - $shortcode = strpos( $shortcode, 'ESPRESSO_' ) !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
449 | - $page_for_posts = \EE_Config::get_page_for_posts(); |
|
450 | - // looking for any references to this post |
|
451 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
452 | - // if this is the "Posts Page" (blog), then skip it |
|
453 | - if ( $post_name === $page_for_posts ) { |
|
454 | - continue; |
|
455 | - } |
|
456 | - // loop thru shortcodes registered for each page, and grab post id for matches |
|
457 | - foreach ( (array) $post_shortcodes as $post_shortcode => $post_ID ) { |
|
458 | - if ( $post_shortcode === $shortcode ) { |
|
459 | - $post_ids[ $post_ID ] = $post_ID; |
|
460 | - } |
|
461 | - } |
|
462 | - } |
|
463 | - } |
|
464 | - return $post_ids; |
|
465 | - } |
|
22 | + /** |
|
23 | + * set_hooks_admin |
|
24 | + * |
|
25 | + * @access public |
|
26 | + */ |
|
27 | + public static function set_hooks_admin() |
|
28 | + { |
|
29 | + add_action( |
|
30 | + 'save_post', |
|
31 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
32 | + 100, |
|
33 | + 2 |
|
34 | + ); |
|
35 | + add_action( |
|
36 | + 'delete_post', |
|
37 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
38 | + 100, |
|
39 | + 1 |
|
40 | + ); |
|
41 | + add_action( |
|
42 | + 'add_option_page_for_posts', |
|
43 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
44 | + 100, |
|
45 | + 2 |
|
46 | + ); |
|
47 | + add_action( |
|
48 | + 'update_option', |
|
49 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
50 | + 100, |
|
51 | + 3 |
|
52 | + ); |
|
53 | + add_action( |
|
54 | + 'delete_option', |
|
55 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
56 | + 100, |
|
57 | + 1 |
|
58 | + ); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * parse_post_content_on_save |
|
65 | + * any time a post is saved, we need to check for any EE shortcodes that may be embedded in the content, |
|
66 | + * and then track what posts those shortcodes are on, so that we can initialize shortcodes well before |
|
67 | + * the_content() runs. this allows us to do things like enqueue scripts for shortcodes ONLY on the pages the |
|
68 | + * shortcodes are actually used on |
|
69 | + * |
|
70 | + * @access public |
|
71 | + * @param int $post_ID |
|
72 | + * @param \WP_Post $post |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + public static function parse_post_content_on_save( $post_ID, $post ) |
|
76 | + { |
|
77 | + // if the post is trashed, then let's remove our post shortcode tracking |
|
78 | + if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
79 | + PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
80 | + return; |
|
81 | + } |
|
82 | + // default post types |
|
83 | + $post_types = array( 'post' => 0, 'page' => 1 ); |
|
84 | + // add CPTs |
|
85 | + $CPTs = \EE_Register_CPTs::get_CPTs(); |
|
86 | + $post_types = array_merge( $post_types, $CPTs ); |
|
87 | + // for default or CPT posts... |
|
88 | + if ( isset( $post_types[ $post->post_type ] ) ) { |
|
89 | + // post on frontpage ? |
|
90 | + $page_for_posts = \EE_Config::get_page_for_posts(); |
|
91 | + if ( $post->post_name === $page_for_posts ) { |
|
92 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
93 | + return; |
|
94 | + } |
|
95 | + // array of shortcodes indexed by post name |
|
96 | + \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
97 | + ? \EE_Registry::CFG()->core->post_shortcodes |
|
98 | + : array(); |
|
99 | + // whether to proceed with update |
|
100 | + $update_post_shortcodes = false; |
|
101 | + // empty both arrays |
|
102 | + \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
103 | + // check that posts page is already being tracked |
|
104 | + if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
105 | + // if not, then ensure that it is properly added |
|
106 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
107 | + } |
|
108 | + // loop thru shortcodes |
|
109 | + foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
110 | + // convert to UPPERCASE to get actual shortcode |
|
111 | + $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
112 | + // is the shortcode in the post_content ? |
|
113 | + if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
114 | + // map shortcode to post names and post IDs |
|
115 | + \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
116 | + // and add this shortcode to the tracking for the blog page |
|
117 | + PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, |
|
118 | + $post_ID ); |
|
119 | + $update_post_shortcodes = true; |
|
120 | + } else { |
|
121 | + // shortcode is not present in post content, so check if we were tracking it previously |
|
122 | + // stop tracking if shortcode is not used in this specific post |
|
123 | + if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
124 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
125 | + $update_post_shortcodes = true; |
|
126 | + } |
|
127 | + // make sure that something is set for the shortcode posts (even though we may remove this) |
|
128 | + $shortcode_posts = isset( |
|
129 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
130 | + ) |
|
131 | + ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
132 | + : array(); |
|
133 | + // and stop tracking for this shortcode on the blog page if it is not used |
|
134 | + $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
135 | + $post_ID, |
|
136 | + $EES_Shortcode, |
|
137 | + $shortcode_posts, |
|
138 | + $page_for_posts, |
|
139 | + $update_post_shortcodes |
|
140 | + ) |
|
141 | + ? true |
|
142 | + : $update_post_shortcodes; |
|
143 | + } |
|
144 | + } |
|
145 | + if ( $update_post_shortcodes ) { |
|
146 | + PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
147 | + } |
|
148 | + } |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * set_post_shortcodes_for_posts_page (plz note: shortcodes is plural) |
|
155 | + * called when updating the WordPress Posts Page, |
|
156 | + * and adds shortcode tracking for the Posts Page, for all shortcodes currently tracked on individual posts |
|
157 | + * |
|
158 | + * @access protected |
|
159 | + * @param string $page_for_posts |
|
160 | + * @return void |
|
161 | + */ |
|
162 | + protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) |
|
163 | + { |
|
164 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
165 | + // loop thru shortcodes |
|
166 | + foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
167 | + foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
168 | + PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
169 | + } |
|
170 | + } |
|
171 | + PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * set_post_shortcode_for_posts_page (plz note: shortcode is singular) |
|
178 | + * adds Posts Page shortcode tracking for the supplied shortcode for an individual post |
|
179 | + * |
|
180 | + * @access protected |
|
181 | + * @param string $page_for_posts |
|
182 | + * @param $EES_Shortcode |
|
183 | + * @param $post_ID |
|
184 | + */ |
|
185 | + protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) |
|
186 | + { |
|
187 | + // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
188 | + $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
|
189 | + // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
|
190 | + if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
191 | + return; |
|
192 | + } |
|
193 | + // add shortcode to "Posts page" tracking |
|
194 | + if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
195 | + // make sure tracking is in form of an array |
|
196 | + if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
197 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
198 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true, |
|
199 | + ); |
|
200 | + } |
|
201 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
202 | + } else { |
|
203 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * unset_post_shortcodes_on_delete |
|
211 | + * |
|
212 | + * @access protected |
|
213 | + * @param int $ID |
|
214 | + * @return void |
|
215 | + */ |
|
216 | + public static function unset_post_shortcodes_on_delete( $ID ) |
|
217 | + { |
|
218 | + $update_post_shortcodes = false; |
|
219 | + // post on frontpage ? |
|
220 | + $page_for_posts = \EE_Config::get_page_for_posts(); |
|
221 | + // looking for any references to this post |
|
222 | + foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
223 | + // is this the "Posts Page" (blog) ? |
|
224 | + if ( $post_name === $page_for_posts ) { |
|
225 | + // loop thru shortcodes registered for the posts page |
|
226 | + foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
227 | + $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
228 | + $ID, |
|
229 | + $shortcode_class, |
|
230 | + $shortcode_posts, |
|
231 | + $page_for_posts, |
|
232 | + $update_post_shortcodes |
|
233 | + ) |
|
234 | + ? true |
|
235 | + : $update_post_shortcodes; |
|
236 | + } |
|
237 | + } else { |
|
238 | + // loop thru shortcodes registered for each page |
|
239 | + foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
240 | + // if this is page is being deleted, then don't track any post shortcodes for it |
|
241 | + if ( $post_ID === $ID ) { |
|
242 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
243 | + $update_post_shortcodes = true; |
|
244 | + } |
|
245 | + } |
|
246 | + } |
|
247 | + } |
|
248 | + if ( $update_post_shortcodes ) { |
|
249 | + PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
250 | + } |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * unset_post_shortcodes_on_delete |
|
257 | + * |
|
258 | + * @access protected |
|
259 | + * @param int $ID |
|
260 | + * @param $shortcode_class |
|
261 | + * @param $shortcode_posts |
|
262 | + * @param $page_for_posts |
|
263 | + * @param bool $update_post_shortcodes |
|
264 | + * @return bool |
|
265 | + */ |
|
266 | + protected static function unset_posts_page_shortcode_for_post( |
|
267 | + $ID, |
|
268 | + $shortcode_class, |
|
269 | + $shortcode_posts, |
|
270 | + $page_for_posts, |
|
271 | + $update_post_shortcodes = false |
|
272 | + ) { |
|
273 | + // make sure that an array of post IDs is being tracked for each shortcode |
|
274 | + if ( ! is_array( $shortcode_posts ) ) { |
|
275 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
276 | + $shortcode_posts => true, |
|
277 | + ); |
|
278 | + $update_post_shortcodes = true; |
|
279 | + } |
|
280 | + // now if the ID of the post being deleted is in the $shortcode_posts array |
|
281 | + if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
282 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
283 | + $update_post_shortcodes = true; |
|
284 | + } |
|
285 | + // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
|
286 | + if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
287 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
288 | + $update_post_shortcodes = true; |
|
289 | + } |
|
290 | + return $update_post_shortcodes; |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * update_post_shortcodes |
|
297 | + * |
|
298 | + * @access public |
|
299 | + * @param $page_for_posts |
|
300 | + * @return void |
|
301 | + */ |
|
302 | + public static function update_post_shortcodes( $page_for_posts = '' ) |
|
303 | + { |
|
304 | + // make sure page_for_posts is set |
|
305 | + $page_for_posts = ! empty( $page_for_posts ) |
|
306 | + ? $page_for_posts |
|
307 | + : \EE_Config::get_page_for_posts(); |
|
308 | + // allow others to mess stuff up :D |
|
309 | + do_action( |
|
310 | + 'AHEE__\EventEspresso\core\admin\PostShortcodeTracking__update_post_shortcodes', |
|
311 | + \EE_Config::instance()->core->post_shortcodes, |
|
312 | + $page_for_posts |
|
313 | + ); |
|
314 | + // keep old hookpoint for now, will deprecate later |
|
315 | + do_action( |
|
316 | + 'AHEE__EE_Config__update_post_shortcodes', |
|
317 | + \EE_Config::instance()->core->post_shortcodes, |
|
318 | + $page_for_posts |
|
319 | + ); |
|
320 | + // verify that post_shortcodes is set |
|
321 | + \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
322 | + && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
323 | + ? \EE_Config::instance()->core->post_shortcodes |
|
324 | + : array(); |
|
325 | + // cycle thru post_shortcodes |
|
326 | + foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
327 | + // are there any shortcodes to track ? |
|
328 | + if ( ! empty( $shortcodes ) ) { |
|
329 | + // skip the posts page, because we want all shortcodes registered for it |
|
330 | + if ( $post_name === $page_for_posts ) { |
|
331 | + continue; |
|
332 | + } |
|
333 | + // loop thru list of tracked shortcodes |
|
334 | + foreach ( $shortcodes as $shortcode => $post_id ) { |
|
335 | + // make sure post still exists |
|
336 | + $post = get_post( $post_id ); |
|
337 | + // check that the post name matches what we have saved |
|
338 | + if ( $post && $post->post_name === $post_name ) { |
|
339 | + // if so, then break before hitting the unset below |
|
340 | + continue; |
|
341 | + } |
|
342 | + // we don't like missing posts around here >:( |
|
343 | + unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
344 | + } |
|
345 | + } else { |
|
346 | + // you got no shortcodes to keep track of ! |
|
347 | + unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
348 | + } |
|
349 | + } |
|
350 | + // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
351 | + $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
|
352 | + $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
353 | + foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
354 | + unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
355 | + } |
|
356 | + //only show errors |
|
357 | + \EE_Config::instance()->update_espresso_config(); |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * reset_page_for_posts_on_initial_set |
|
364 | + * if an admin is on the WP Reading Settings page and sets the option for "Posts page", |
|
365 | + * when it had previously been unset, |
|
366 | + * then we need to attribute any actively used shortcodes to the new blog page |
|
367 | + * |
|
368 | + * @access public |
|
369 | + * @param string $option |
|
370 | + * @param string $value |
|
371 | + * @return void |
|
372 | + */ |
|
373 | + public static function reset_page_for_posts_on_initial_set( $option, $value ) |
|
374 | + { |
|
375 | + PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * reset_page_for_posts_on_change |
|
382 | + * if an admin is on the WP Reading Settings page and changes the option for "Posts page", |
|
383 | + * then we need to attribute any actively used shortcodes for the previous blog page to the new blog page |
|
384 | + * |
|
385 | + * @access public |
|
386 | + * @param string $option |
|
387 | + * @param string $old_value |
|
388 | + * @param string $value |
|
389 | + * @return void |
|
390 | + */ |
|
391 | + public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) |
|
392 | + { |
|
393 | + if ( $option === 'page_for_posts' ) { |
|
394 | + global $wpdb; |
|
395 | + $table = $wpdb->posts; |
|
396 | + $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
397 | + $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
398 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * reset_page_for_posts_on_delete |
|
406 | + * if an admin deletes a page designated as the WP "Posts page", |
|
407 | + * then we need to attribute any actively used shortcodes for that blog page to a generic 'posts' page |
|
408 | + * |
|
409 | + * @access public |
|
410 | + * @param string $option |
|
411 | + * @return void |
|
412 | + */ |
|
413 | + public static function reset_page_for_posts_on_delete( $option ) |
|
414 | + { |
|
415 | + if ( $option === 'page_for_posts' ) { |
|
416 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
417 | + } |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * @param array|string $shortcodes |
|
424 | + * @param bool $index_results if passing more than one shortcode for the $shortcodes parameter above, |
|
425 | + * then setting this to true, will return as associative array indexed by |
|
426 | + * the shortcodes. If false, then the returned array will be unindexed |
|
427 | + * @return array |
|
428 | + */ |
|
429 | + public static function get_post_ids_for_shortcode( $shortcodes, $index_results = true ) |
|
430 | + { |
|
431 | + $post_ids = array(); |
|
432 | + if ( is_array( $shortcodes ) ) { |
|
433 | + foreach ( $shortcodes as $shortcode ) { |
|
434 | + $new_post_ids = PostShortcodeTracking::get_post_ids_for_shortcode( |
|
435 | + $shortcode, |
|
436 | + $index_results |
|
437 | + ); |
|
438 | + foreach ( $new_post_ids as $new_post_id ) { |
|
439 | + if ( $index_results ) { |
|
440 | + $post_ids[ $shortcode ][ $new_post_id ] = $new_post_id; |
|
441 | + } else { |
|
442 | + $post_ids[ $new_post_id ] = $new_post_id; |
|
443 | + } |
|
444 | + } |
|
445 | + } |
|
446 | + } else { |
|
447 | + $shortcode = strtoupper( $shortcodes ); |
|
448 | + $shortcode = strpos( $shortcode, 'ESPRESSO_' ) !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
449 | + $page_for_posts = \EE_Config::get_page_for_posts(); |
|
450 | + // looking for any references to this post |
|
451 | + foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
452 | + // if this is the "Posts Page" (blog), then skip it |
|
453 | + if ( $post_name === $page_for_posts ) { |
|
454 | + continue; |
|
455 | + } |
|
456 | + // loop thru shortcodes registered for each page, and grab post id for matches |
|
457 | + foreach ( (array) $post_shortcodes as $post_shortcode => $post_ID ) { |
|
458 | + if ( $post_shortcode === $shortcode ) { |
|
459 | + $post_ids[ $post_ID ] = $post_ID; |
|
460 | + } |
|
461 | + } |
|
462 | + } |
|
463 | + } |
|
464 | + return $post_ids; |
|
465 | + } |
|
466 | 466 | |
467 | 467 | |
468 | 468 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\admin; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | { |
29 | 29 | add_action( |
30 | 30 | 'save_post', |
31 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
31 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save'), |
|
32 | 32 | 100, |
33 | 33 | 2 |
34 | 34 | ); |
35 | 35 | add_action( |
36 | 36 | 'delete_post', |
37 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
37 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete'), |
|
38 | 38 | 100, |
39 | 39 | 1 |
40 | 40 | ); |
41 | 41 | add_action( |
42 | 42 | 'add_option_page_for_posts', |
43 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
43 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set'), |
|
44 | 44 | 100, |
45 | 45 | 2 |
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'update_option', |
49 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
49 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change'), |
|
50 | 50 | 100, |
51 | 51 | 3 |
52 | 52 | ); |
53 | 53 | add_action( |
54 | 54 | 'delete_option', |
55 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
55 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete'), |
|
56 | 56 | 100, |
57 | 57 | 1 |
58 | 58 | ); |
@@ -72,63 +72,63 @@ discard block |
||
72 | 72 | * @param \WP_Post $post |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public static function parse_post_content_on_save( $post_ID, $post ) |
|
75 | + public static function parse_post_content_on_save($post_ID, $post) |
|
76 | 76 | { |
77 | 77 | // if the post is trashed, then let's remove our post shortcode tracking |
78 | - if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
79 | - PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
78 | + if ($post instanceof \WP_Post && $post->post_status === 'trash') { |
|
79 | + PostShortcodeTracking::unset_post_shortcodes_on_delete($post_ID); |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | // default post types |
83 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
83 | + $post_types = array('post' => 0, 'page' => 1); |
|
84 | 84 | // add CPTs |
85 | 85 | $CPTs = \EE_Register_CPTs::get_CPTs(); |
86 | - $post_types = array_merge( $post_types, $CPTs ); |
|
86 | + $post_types = array_merge($post_types, $CPTs); |
|
87 | 87 | // for default or CPT posts... |
88 | - if ( isset( $post_types[ $post->post_type ] ) ) { |
|
88 | + if (isset($post_types[$post->post_type])) { |
|
89 | 89 | // post on frontpage ? |
90 | 90 | $page_for_posts = \EE_Config::get_page_for_posts(); |
91 | - if ( $post->post_name === $page_for_posts ) { |
|
92 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
91 | + if ($post->post_name === $page_for_posts) { |
|
92 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($page_for_posts); |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | // array of shortcodes indexed by post name |
96 | - \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
96 | + \EE_Registry::CFG()->core->post_shortcodes = isset(\EE_Registry::CFG()->core->post_shortcodes) |
|
97 | 97 | ? \EE_Registry::CFG()->core->post_shortcodes |
98 | 98 | : array(); |
99 | 99 | // whether to proceed with update |
100 | 100 | $update_post_shortcodes = false; |
101 | 101 | // empty both arrays |
102 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
102 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name] = array(); |
|
103 | 103 | // check that posts page is already being tracked |
104 | - if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
104 | + if ( ! isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts])) { |
|
105 | 105 | // if not, then ensure that it is properly added |
106 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
106 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
107 | 107 | } |
108 | 108 | // loop thru shortcodes |
109 | - foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
109 | + foreach (\EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) { |
|
110 | 110 | // convert to UPPERCASE to get actual shortcode |
111 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
111 | + $EES_Shortcode = strtoupper($EES_Shortcode); |
|
112 | 112 | // is the shortcode in the post_content ? |
113 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
113 | + if (strpos($post->post_content, $EES_Shortcode) !== false) { |
|
114 | 114 | // map shortcode to post names and post IDs |
115 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
115 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID; |
|
116 | 116 | // and add this shortcode to the tracking for the blog page |
117 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, |
|
118 | - $post_ID ); |
|
117 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, |
|
118 | + $post_ID); |
|
119 | 119 | $update_post_shortcodes = true; |
120 | 120 | } else { |
121 | 121 | // shortcode is not present in post content, so check if we were tracking it previously |
122 | 122 | // stop tracking if shortcode is not used in this specific post |
123 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
124 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
123 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode])) { |
|
124 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode]); |
|
125 | 125 | $update_post_shortcodes = true; |
126 | 126 | } |
127 | 127 | // make sure that something is set for the shortcode posts (even though we may remove this) |
128 | 128 | $shortcode_posts = isset( |
129 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
129 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
130 | 130 | ) |
131 | - ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
131 | + ? \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
132 | 132 | : array(); |
133 | 133 | // and stop tracking for this shortcode on the blog page if it is not used |
134 | 134 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | : $update_post_shortcodes; |
143 | 143 | } |
144 | 144 | } |
145 | - if ( $update_post_shortcodes ) { |
|
146 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
145 | + if ($update_post_shortcodes) { |
|
146 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -159,16 +159,16 @@ discard block |
||
159 | 159 | * @param string $page_for_posts |
160 | 160 | * @return void |
161 | 161 | */ |
162 | - protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) |
|
162 | + protected static function set_post_shortcodes_for_posts_page($page_for_posts) |
|
163 | 163 | { |
164 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
164 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
165 | 165 | // loop thru shortcodes |
166 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
167 | - foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
168 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
166 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
167 | + foreach ($post_shortcodes as $EES_Shortcode => $post_ID) { |
|
168 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID); |
|
169 | 169 | } |
170 | 170 | } |
171 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
171 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -182,25 +182,25 @@ discard block |
||
182 | 182 | * @param $EES_Shortcode |
183 | 183 | * @param $post_ID |
184 | 184 | */ |
185 | - protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) |
|
185 | + protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID) |
|
186 | 186 | { |
187 | 187 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
188 | 188 | $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
189 | 189 | // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
190 | - if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
190 | + if (in_array($EES_Shortcode, $critical_shortcodes)) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | // add shortcode to "Posts page" tracking |
194 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
194 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
195 | 195 | // make sure tracking is in form of an array |
196 | - if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
197 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
198 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true, |
|
196 | + if ( ! is_array(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
197 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array( |
|
198 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] => true, |
|
199 | 199 | ); |
200 | 200 | } |
201 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
201 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] += array($post_ID => true); |
|
202 | 202 | } else { |
203 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
203 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array($post_ID => true); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | * @param int $ID |
214 | 214 | * @return void |
215 | 215 | */ |
216 | - public static function unset_post_shortcodes_on_delete( $ID ) |
|
216 | + public static function unset_post_shortcodes_on_delete($ID) |
|
217 | 217 | { |
218 | 218 | $update_post_shortcodes = false; |
219 | 219 | // post on frontpage ? |
220 | 220 | $page_for_posts = \EE_Config::get_page_for_posts(); |
221 | 221 | // looking for any references to this post |
222 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
222 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
223 | 223 | // is this the "Posts Page" (blog) ? |
224 | - if ( $post_name === $page_for_posts ) { |
|
224 | + if ($post_name === $page_for_posts) { |
|
225 | 225 | // loop thru shortcodes registered for the posts page |
226 | - foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
226 | + foreach ($post_shortcodes as $shortcode_class => $shortcode_posts) { |
|
227 | 227 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
228 | 228 | $ID, |
229 | 229 | $shortcode_class, |
@@ -236,17 +236,17 @@ discard block |
||
236 | 236 | } |
237 | 237 | } else { |
238 | 238 | // loop thru shortcodes registered for each page |
239 | - foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
239 | + foreach ($post_shortcodes as $shortcode_class => $post_ID) { |
|
240 | 240 | // if this is page is being deleted, then don't track any post shortcodes for it |
241 | - if ( $post_ID === $ID ) { |
|
242 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
241 | + if ($post_ID === $ID) { |
|
242 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post_name]); |
|
243 | 243 | $update_post_shortcodes = true; |
244 | 244 | } |
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
248 | - if ( $update_post_shortcodes ) { |
|
249 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
248 | + if ($update_post_shortcodes) { |
|
249 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -271,20 +271,20 @@ discard block |
||
271 | 271 | $update_post_shortcodes = false |
272 | 272 | ) { |
273 | 273 | // make sure that an array of post IDs is being tracked for each shortcode |
274 | - if ( ! is_array( $shortcode_posts ) ) { |
|
275 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
274 | + if ( ! is_array($shortcode_posts)) { |
|
275 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class] = array( |
|
276 | 276 | $shortcode_posts => true, |
277 | 277 | ); |
278 | 278 | $update_post_shortcodes = true; |
279 | 279 | } |
280 | 280 | // now if the ID of the post being deleted is in the $shortcode_posts array |
281 | - if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
282 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
281 | + if (is_array($shortcode_posts) && isset($shortcode_posts[$ID])) { |
|
282 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class][$ID]); |
|
283 | 283 | $update_post_shortcodes = true; |
284 | 284 | } |
285 | 285 | // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
286 | - if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
287 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
286 | + if (empty(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class])) { |
|
287 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class]); |
|
288 | 288 | $update_post_shortcodes = true; |
289 | 289 | } |
290 | 290 | return $update_post_shortcodes; |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | * @param $page_for_posts |
300 | 300 | * @return void |
301 | 301 | */ |
302 | - public static function update_post_shortcodes( $page_for_posts = '' ) |
|
302 | + public static function update_post_shortcodes($page_for_posts = '') |
|
303 | 303 | { |
304 | 304 | // make sure page_for_posts is set |
305 | - $page_for_posts = ! empty( $page_for_posts ) |
|
305 | + $page_for_posts = ! empty($page_for_posts) |
|
306 | 306 | ? $page_for_posts |
307 | 307 | : \EE_Config::get_page_for_posts(); |
308 | 308 | // allow others to mess stuff up :D |
@@ -318,40 +318,40 @@ discard block |
||
318 | 318 | $page_for_posts |
319 | 319 | ); |
320 | 320 | // verify that post_shortcodes is set |
321 | - \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
322 | - && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
321 | + \EE_Config::instance()->core->post_shortcodes = isset(\EE_Config::instance()->core->post_shortcodes) |
|
322 | + && is_array(\EE_Config::instance()->core->post_shortcodes) |
|
323 | 323 | ? \EE_Config::instance()->core->post_shortcodes |
324 | 324 | : array(); |
325 | 325 | // cycle thru post_shortcodes |
326 | - foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
326 | + foreach (\EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes) { |
|
327 | 327 | // are there any shortcodes to track ? |
328 | - if ( ! empty( $shortcodes ) ) { |
|
328 | + if ( ! empty($shortcodes)) { |
|
329 | 329 | // skip the posts page, because we want all shortcodes registered for it |
330 | - if ( $post_name === $page_for_posts ) { |
|
330 | + if ($post_name === $page_for_posts) { |
|
331 | 331 | continue; |
332 | 332 | } |
333 | 333 | // loop thru list of tracked shortcodes |
334 | - foreach ( $shortcodes as $shortcode => $post_id ) { |
|
334 | + foreach ($shortcodes as $shortcode => $post_id) { |
|
335 | 335 | // make sure post still exists |
336 | - $post = get_post( $post_id ); |
|
336 | + $post = get_post($post_id); |
|
337 | 337 | // check that the post name matches what we have saved |
338 | - if ( $post && $post->post_name === $post_name ) { |
|
338 | + if ($post && $post->post_name === $post_name) { |
|
339 | 339 | // if so, then break before hitting the unset below |
340 | 340 | continue; |
341 | 341 | } |
342 | 342 | // we don't like missing posts around here >:( |
343 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
343 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
344 | 344 | } |
345 | 345 | } else { |
346 | 346 | // you got no shortcodes to keep track of ! |
347 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
347 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
351 | 351 | $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
352 | - $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
353 | - foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
354 | - unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
352 | + $critical_shortcodes = array_flip($critical_shortcodes); |
|
353 | + foreach ($critical_shortcodes as $critical_shortcode) { |
|
354 | + unset(\EE_Config::instance()->core->post_shortcodes[$page_for_posts][$critical_shortcode]); |
|
355 | 355 | } |
356 | 356 | //only show errors |
357 | 357 | \EE_Config::instance()->update_espresso_config(); |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * @param string $value |
371 | 371 | * @return void |
372 | 372 | */ |
373 | - public static function reset_page_for_posts_on_initial_set( $option, $value ) |
|
373 | + public static function reset_page_for_posts_on_initial_set($option, $value) |
|
374 | 374 | { |
375 | - PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
375 | + PostShortcodeTracking::reset_page_for_posts_on_change($option, '', $value); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | * @param string $value |
389 | 389 | * @return void |
390 | 390 | */ |
391 | - public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) |
|
391 | + public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '') |
|
392 | 392 | { |
393 | - if ( $option === 'page_for_posts' ) { |
|
393 | + if ($option === 'page_for_posts') { |
|
394 | 394 | global $wpdb; |
395 | 395 | $table = $wpdb->posts; |
396 | 396 | $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
397 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
398 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
397 | + $new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts'; |
|
398 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($new_page_for_posts); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -410,10 +410,10 @@ discard block |
||
410 | 410 | * @param string $option |
411 | 411 | * @return void |
412 | 412 | */ |
413 | - public static function reset_page_for_posts_on_delete( $option ) |
|
413 | + public static function reset_page_for_posts_on_delete($option) |
|
414 | 414 | { |
415 | - if ( $option === 'page_for_posts' ) { |
|
416 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
415 | + if ($option === 'page_for_posts') { |
|
416 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page('posts'); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
@@ -426,37 +426,37 @@ discard block |
||
426 | 426 | * the shortcodes. If false, then the returned array will be unindexed |
427 | 427 | * @return array |
428 | 428 | */ |
429 | - public static function get_post_ids_for_shortcode( $shortcodes, $index_results = true ) |
|
429 | + public static function get_post_ids_for_shortcode($shortcodes, $index_results = true) |
|
430 | 430 | { |
431 | 431 | $post_ids = array(); |
432 | - if ( is_array( $shortcodes ) ) { |
|
433 | - foreach ( $shortcodes as $shortcode ) { |
|
432 | + if (is_array($shortcodes)) { |
|
433 | + foreach ($shortcodes as $shortcode) { |
|
434 | 434 | $new_post_ids = PostShortcodeTracking::get_post_ids_for_shortcode( |
435 | 435 | $shortcode, |
436 | 436 | $index_results |
437 | 437 | ); |
438 | - foreach ( $new_post_ids as $new_post_id ) { |
|
439 | - if ( $index_results ) { |
|
440 | - $post_ids[ $shortcode ][ $new_post_id ] = $new_post_id; |
|
438 | + foreach ($new_post_ids as $new_post_id) { |
|
439 | + if ($index_results) { |
|
440 | + $post_ids[$shortcode][$new_post_id] = $new_post_id; |
|
441 | 441 | } else { |
442 | - $post_ids[ $new_post_id ] = $new_post_id; |
|
442 | + $post_ids[$new_post_id] = $new_post_id; |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | } |
446 | 446 | } else { |
447 | - $shortcode = strtoupper( $shortcodes ); |
|
448 | - $shortcode = strpos( $shortcode, 'ESPRESSO_' ) !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
447 | + $shortcode = strtoupper($shortcodes); |
|
448 | + $shortcode = strpos($shortcode, 'ESPRESSO_') !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
449 | 449 | $page_for_posts = \EE_Config::get_page_for_posts(); |
450 | 450 | // looking for any references to this post |
451 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
451 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
452 | 452 | // if this is the "Posts Page" (blog), then skip it |
453 | - if ( $post_name === $page_for_posts ) { |
|
453 | + if ($post_name === $page_for_posts) { |
|
454 | 454 | continue; |
455 | 455 | } |
456 | 456 | // loop thru shortcodes registered for each page, and grab post id for matches |
457 | - foreach ( (array) $post_shortcodes as $post_shortcode => $post_ID ) { |
|
458 | - if ( $post_shortcode === $shortcode ) { |
|
459 | - $post_ids[ $post_ID ] = $post_ID; |
|
457 | + foreach ((array) $post_shortcodes as $post_shortcode => $post_ID) { |
|
458 | + if ($post_shortcode === $shortcode) { |
|
459 | + $post_ids[$post_ID] = $post_ID; |
|
460 | 460 | } |
461 | 461 | } |
462 | 462 | } |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | ?> |
6 | 6 | <div class="padding"> |
7 | 7 | |
8 | - <h2 class="ee-admin-settings-hdr"><?php _e('Countries and States/Provinces', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('country_select_info');?></h2> |
|
8 | + <h2 class="ee-admin-settings-hdr"><?php _e('Countries and States/Provinces', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2> |
|
9 | 9 | <table class="form-table"> |
10 | 10 | <tbody> |
11 | - <?php echo EEH_Form_Fields::generate_form_input( $countries ); ?> |
|
11 | + <?php echo EEH_Form_Fields::generate_form_input($countries); ?> |
|
12 | 12 | </tbody> |
13 | 13 | </table> |
14 | 14 | <br/> |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | <?php _e('The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', 'event_espresso'); ?> |
17 | 17 | </p> |
18 | 18 | <div id="country-details-settings-dv"> |
19 | - <h2 class="ee-admin-settings-hdr"><?php _e('Country Details', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('country_details_info');?></h2> |
|
19 | + <h2 class="ee-admin-settings-hdr"><?php _e('Country Details', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2> |
|
20 | 20 | <div id="country-details-dv"><?php echo $country_details_settings; ?></div> |
21 | 21 | </div> |
22 | 22 | |
23 | 23 | <div id="country-states-settings-dv"> |
24 | - <h2 class="ee-admin-settings-hdr"><?php _e( 'States/Provinces', 'event_espresso' );?> <?php echo EEH_Template::get_help_tab_link('country_states_info');?></h2> |
|
24 | + <h2 class="ee-admin-settings-hdr"><?php _e('States/Provinces', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2> |
|
25 | 25 | <div id="country-states-dv"><?php echo $country_states_settings; ?></div> |
26 | 26 | </div> |
27 | 27 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | ?> |
7 | 7 | <div class="padding"> |
8 | 8 | |
9 | - <?php do_action( 'AHEE__admin_option_settings__template__before', $template_args ); ?> |
|
9 | + <?php do_action('AHEE__admin_option_settings__template__before', $template_args); ?> |
|
10 | 10 | |
11 | 11 | <?php /* @todo put back once we have a dashboard widget to use |
12 | 12 | <h2 class="ee-admin-settings-hdr"> |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | </table> |
72 | 72 | <?php endif; */ ?> |
73 | 73 | |
74 | - <?php if ( EE_Registry::instance()->CAP->current_user_can( 'manage_options', 'display_admin_settings_options_promote_and_affiliate' ) ) : ?> |
|
74 | + <?php if (EE_Registry::instance()->CAP->current_user_can('manage_options', 'display_admin_settings_options_promote_and_affiliate')) : ?> |
|
75 | 75 | <h2 class="ee-admin-settings-hdr"> |
76 | 76 | <?php _e('Promote Event Espresso', 'event_espresso'); ?> <span id="affiliate_info"><?php echo EEH_Template::get_help_tab_link('affiliate_info'); ?></span> |
77 | 77 | </h2> |
@@ -86,14 +86,14 @@ discard block |
||
86 | 86 | </label> |
87 | 87 | </th> |
88 | 88 | <td> |
89 | - <?php echo EEH_Form_Fields::select_input('show_reg_footer', $values, $show_reg_footer ); ?> |
|
89 | + <?php echo EEH_Form_Fields::select_input('show_reg_footer', $values, $show_reg_footer); ?> |
|
90 | 90 | </td> |
91 | 91 | </tr> |
92 | 92 | |
93 | 93 | <tr> |
94 | 94 | <th> |
95 | 95 | <label for="affiliate_id"> |
96 | - <?php printf( __('Event Espresso %sAffiliate%s ID', 'event_espresso'), '<a href="http://eventespresso.com/affiliates/" target="_blank">', '</a>' ); ?> |
|
96 | + <?php printf(__('Event Espresso %sAffiliate%s ID', 'event_espresso'), '<a href="http://eventespresso.com/affiliates/" target="_blank">', '</a>'); ?> |
|
97 | 97 | </label> |
98 | 98 | </th> |
99 | 99 | <td> |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | </label> |
124 | 124 | </th> |
125 | 125 | <td> |
126 | - <?php echo EEH_Form_Fields::select_input('help_tour_activation', $values, $help_tour_activation ); ?> |
|
126 | + <?php echo EEH_Form_Fields::select_input('help_tour_activation', $values, $help_tour_activation); ?> |
|
127 | 127 | </td> |
128 | 128 | </tr> |
129 | 129 | </tbody> |