@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <div class="changelog"> |
2 | 2 | <?php |
3 | 3 | //maintenance mode on? |
4 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
4 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
5 | 5 | ?> |
6 | 6 | <div class="ee-attention"> |
7 | - <h2 class="ee-maintenance-mode-callout"><?php esc_html_e('Event Espresso is in full maintenance mode.' , 'event_espresso'); ?></h2> |
|
7 | + <h2 class="ee-maintenance-mode-callout"><?php esc_html_e('Event Espresso is in full maintenance mode.', 'event_espresso'); ?></h2> |
|
8 | 8 | <p> |
9 | 9 | <?php |
10 | 10 | printf( |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | ?> |
21 | 21 | |
22 | 22 | <h2 class="about-headline-callout"><?php esc_html_e('Welcome to the Decaf (free) Version of Event Espresso 4!', 'event_espresso'); ?></h2> |
23 | - <p><?php echo sprintf( esc_html__('Manage your events from your WordPress dashboard. Reduce your admin, reduce your costs, make your life easier! This is the Decaf version of Event Espresso, but we also have a premium version called %sEvent Espreso 4 Regular%s and a hosted version called %sEvent Smart%s (SaaS).', 'event_espresso'),'<a href="?page=espresso_about&action=decafvpro">','</a>','<a href="https://eventsmart.com//?utm_source=ee4_decaf&utm_medium=link&utm_campaign=espresso_about_tab&utm_content=EE4+Decaf">','</a>'); ?></p> |
|
23 | + <p><?php echo sprintf(esc_html__('Manage your events from your WordPress dashboard. Reduce your admin, reduce your costs, make your life easier! This is the Decaf version of Event Espresso, but we also have a premium version called %sEvent Espreso 4 Regular%s and a hosted version called %sEvent Smart%s (SaaS).', 'event_espresso'), '<a href="?page=espresso_about&action=decafvpro">', '</a>', '<a href="https://eventsmart.com//?utm_source=ee4_decaf&utm_medium=link&utm_campaign=espresso_about_tab&utm_content=EE4+Decaf">', '</a>'); ?></p> |
|
24 | 24 | <h2><?php esc_html_e('Powering 40,000+ event websites; $100 million in ticket sales per year!', 'event_espresso'); ?></h2> |
25 | - <p><?php echo sprintf( esc_html__('Event Espresso is a %sWordPress event manager%s which makes it easy for you to register attendees for classes, workshops, events, trainings, conferences or concerts, all from your WordPress website. Event Espresso events are created from the WordPress admin area. You can create signup forms to collect information about your attendees, accept payments, and create reports. The Decaf (free) version of the plugin provides everything that you need to manage your event using WordPress.', 'event_espresso'),'<a href="http://eventespresso.com/?utm_source=wordpress_org&utm_medium=link&utm_campaign=plugin_description_tab&utm_content=EE4+Decaf">','</a>'); ?></p> |
|
25 | + <p><?php echo sprintf(esc_html__('Event Espresso is a %sWordPress event manager%s which makes it easy for you to register attendees for classes, workshops, events, trainings, conferences or concerts, all from your WordPress website. Event Espresso events are created from the WordPress admin area. You can create signup forms to collect information about your attendees, accept payments, and create reports. The Decaf (free) version of the plugin provides everything that you need to manage your event using WordPress.', 'event_espresso'), '<a href="http://eventespresso.com/?utm_source=wordpress_org&utm_medium=link&utm_campaign=plugin_description_tab&utm_content=EE4+Decaf">', '</a>'); ?></p> |
|
26 | 26 | <div class="feature-section col three-col about-updates"> |
27 | 27 | <div class="col-1"> |
28 | 28 | <img src="<?php echo EE_GLOBAL_ASSETS_URL; ?>images/screenshots/publish_meta_box.jpg"> |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | <h2 class="about-headline-callout"><?php esc_html_e('People Like You Manage Event Registration with WordPress', 'event_espresso'); ?></h2> |
81 | 81 | <div class="feature-section col two-col"> |
82 | 82 | <div class="grid_6"> |
83 | - <p><?php echo sprintf( esc_html__('Trusted by thousands, Event Espresso is the best WordPress event online registration and ticketing manager plugin–and the best supported with full-time support. Turn your existing blog or website into a %sfully-featured event management website%s and a new way to make money. With Event Espresso you get it all; everything from custom registration forms and emails, seating limits, multiple price options, and discount codes to printable tickets.', 'event_espresso'),'<strong>','</strong>'); ?></p> |
|
83 | + <p><?php echo sprintf(esc_html__('Trusted by thousands, Event Espresso is the best WordPress event online registration and ticketing manager plugin–and the best supported with full-time support. Turn your existing blog or website into a %sfully-featured event management website%s and a new way to make money. With Event Espresso you get it all; everything from custom registration forms and emails, seating limits, multiple price options, and discount codes to printable tickets.', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
84 | 84 | <p><?php esc_html_e('Event Espresso works perfectly for classes, workshops, fundraisers, sporting, trainings, conferences, networking, religion, social, non-profit, and nearly any other type of event.', 'event_espresso'); ?></p> |
85 | 85 | </div> |
86 | 86 | <div class="grid_6"> |
87 | - <p><?php echo sprintf( esc_html__('Our online event registration software can %smake your organization more profitable and efficient%s by helping you save money on registration and ticketing fees, reduce the countless hours of time you spend manually processing registrations, create a “green” and paperless event registration process and you will be open for business to accept registrations and payment 24/7.', 'event_espresso'),'<strong>','</strong>'); ?></p> |
|
87 | + <p><?php echo sprintf(esc_html__('Our online event registration software can %smake your organization more profitable and efficient%s by helping you save money on registration and ticketing fees, reduce the countless hours of time you spend manually processing registrations, create a “green” and paperless event registration process and you will be open for business to accept registrations and payment 24/7.', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
88 | 88 | <p><?php esc_html_e('If you\'re doing event registration and ticketing any other way, then you’re wasting time and money. We offer packages and prices to fit any budget, so get started with your online event registration and ticketing management system today.', 'event_espresso'); ?></p> |
89 | 89 | </div> |
90 | 90 | </div> |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | <h3><?php esc_html_e('Turn your blog into a complete event registration and management system', 'event_espresso'); ?></h3> |
95 | 95 | <p><?php esc_html_e('Create a beautiful event page with ticket selection, venue details, and an integrated single page checkout system. With WordPress, Event Espresso, and Espresso Arabica 2014 (based on the "Twenty Fourteen" theme by WordPress), your events will certainly sell out faster than ever!', 'event_espresso'); ?></p> |
96 | 96 | <p><?php esc_html_e('With a striking design that does not compromise the simplicity of WordPress and Event Espresso 4, Espresso Arabica 2014 will be the best event theme on the market.', 'event_espresso'); ?></p> |
97 | - <p><?php echo sprintf( esc_html__('%sLearn more >>%s', 'event_espresso'), '<a href="http://eventespresso.com/wiki/setup-event-espresso-arabica-theme/">', '</a>' ); ?></p> |
|
97 | + <p><?php echo sprintf(esc_html__('%sLearn more >>%s', 'event_espresso'), '<a href="http://eventespresso.com/wiki/setup-event-espresso-arabica-theme/">', '</a>'); ?></p> |
|
98 | 98 | </div> |
99 | 99 | <div><img src="<?php echo EE_GLOBAL_ASSETS_URL; ?>images/screenshots/single-event-page.jpg"></div> |
100 | 100 | </div> |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<p><?php echo sprintf( esc_html__('We offer a free version of Event Espresso 4 called Decaf which is a good fit for basic events. Need more features like custom registration forms and advanced email notifications? %sUpgrade to Event Espresso 4 (Regular)%s.', 'event_espresso'),'<a href="https://eventespresso.com/pricing/?ee_ver=ee4&utm_source=wordpress_org&utm_medium=link&utm_campaign=decaf_about_page&utm_content=Decaf+vs+Regular">','</a>');?><br> |
|
1 | +<p><?php echo sprintf(esc_html__('We offer a free version of Event Espresso 4 called Decaf which is a good fit for basic events. Need more features like custom registration forms and advanced email notifications? %sUpgrade to Event Espresso 4 (Regular)%s.', 'event_espresso'), '<a href="https://eventespresso.com/pricing/?ee_ver=ee4&utm_source=wordpress_org&utm_medium=link&utm_campaign=decaf_about_page&utm_content=Decaf+vs+Regular">', '</a>'); ?><br> |
|
2 | 2 | |
3 | 3 | <?php |
4 | 4 | |
@@ -8,43 +8,43 @@ discard block |
||
8 | 8 | |
9 | 9 | $features = array( |
10 | 10 | 'pricing-options' => array( |
11 | - 'label' => esc_html__( 'Handle multiple dates and pricing options', 'event_espresso' ), |
|
11 | + 'label' => esc_html__('Handle multiple dates and pricing options', 'event_espresso'), |
|
12 | 12 | 'decaf' => '<span class="dashicons dashicons-no-alt"></span>', |
13 | 13 | 'regular' => '<span class="dashicons dashicons-yes"></span></i>', |
14 | 14 | 'class' => 'alternate' |
15 | 15 | ), |
16 | 16 | 'custom-registration' => array( |
17 | - 'label' => esc_html__( 'Create custom registration forms', 'event_espresso' ), |
|
17 | + 'label' => esc_html__('Create custom registration forms', 'event_espresso'), |
|
18 | 18 | 'decaf' => '<span class="dashicons dashicons-no-alt"></span>', |
19 | 19 | 'regular' => '<span class="dashicons dashicons-yes"></span></i>', |
20 | 20 | 'class' => 'none' |
21 | 21 | ), |
22 | 22 | 'advanced-notifications' => array( |
23 | - 'label' => esc_html__( 'Customize advanced email notifications', 'event_espresso' ), |
|
23 | + 'label' => esc_html__('Customize advanced email notifications', 'event_espresso'), |
|
24 | 24 | 'decaf' => '<span class="dashicons dashicons-no-alt"></span>', |
25 | 25 | 'regular' => '<span class="dashicons dashicons-yes"></span></i>', |
26 | 26 | 'class' => 'alternate' |
27 | 27 | ), |
28 | 28 | 'manage-taxes' => array( |
29 | - 'label' => esc_html__( 'Manage taxes', 'event_espresso' ), |
|
29 | + 'label' => esc_html__('Manage taxes', 'event_espresso'), |
|
30 | 30 | 'decaf' => '<span class="dashicons dashicons-no-alt"></span>', |
31 | 31 | 'regular' => '<span class="dashicons dashicons-yes"></span></i>', |
32 | 32 | 'class' => 'none' |
33 | 33 | ), |
34 | 34 | 'typography' => array( |
35 | - 'label' => esc_html__( 'Additional payment methods available', 'event_espresso' ), |
|
35 | + 'label' => esc_html__('Additional payment methods available', 'event_espresso'), |
|
36 | 36 | 'decaf' => '<span class="dashicons dashicons-no-alt"></span>', |
37 | 37 | 'regular' => '<span class="dashicons dashicons-yes"></span></i>', |
38 | 38 | 'class' => 'alternate' |
39 | 39 | ), |
40 | 40 | 'add-on-compatibility' => array( |
41 | - 'label' => esc_html__( 'Compatibility with add-ons', 'event_espresso' ), |
|
41 | + 'label' => esc_html__('Compatibility with add-ons', 'event_espresso'), |
|
42 | 42 | 'decaf' => '<span class="dashicons dashicons-no-alt"></span>', |
43 | 43 | 'regular' => '<span class="dashicons dashicons-yes"></span></i>', |
44 | 44 | 'class' => 'none' |
45 | 45 | ), |
46 | 46 | 'best-support' => array( |
47 | - 'label' => esc_html__( 'Best in class support', 'event_espresso' ), |
|
47 | + 'label' => esc_html__('Best in class support', 'event_espresso'), |
|
48 | 48 | 'decaf' => '<span class="dashicons dashicons-no-alt"></span>', |
49 | 49 | 'regular' => '<span class="dashicons dashicons-yes"></span></i>', |
50 | 50 | 'class' => 'alternate' |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | <thead> |
57 | 57 | <tr> |
58 | 58 | <th></th> |
59 | - <th><?php esc_html_e( 'Decaf', 'event_espresso' ) ?></th> |
|
60 | - <th><?php esc_html_e( 'Regular', 'event_espresso' ) ?></th> |
|
59 | + <th><?php esc_html_e('Decaf', 'event_espresso') ?></th> |
|
60 | + <th><?php esc_html_e('Regular', 'event_espresso') ?></th> |
|
61 | 61 | </tr> |
62 | 62 | </thead> |
63 | 63 | <tbody> |
64 | - <?php foreach ( $features as $feature ): ?> |
|
64 | + <?php foreach ($features as $feature): ?> |
|
65 | 65 | <tr class="<?php echo $feature['class']; ?>"> |
66 | 66 | <td class="feature"> |
67 | 67 | <h3> |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | <?php endforeach; ?> |
79 | 79 | <tr> |
80 | 80 | <td></td> |
81 | - <td colspan="2" class="text-right"><a href="https://eventespresso.com/pricing/?utm_source=wordpress_org&utm_medium=link&utm_campaign=decaf_about_page&utm_content=Decaf+vs+Regular" target="_blank" class="button button-primary button-hero"><span class="dashicons dashicons-cart"></span><?php esc_html_e( 'Upgrade Now!', 'event_espresso' ) ?></a></td> |
|
81 | + <td colspan="2" class="text-right"><a href="https://eventespresso.com/pricing/?utm_source=wordpress_org&utm_medium=link&utm_campaign=decaf_about_page&utm_content=Decaf+vs+Regular" target="_blank" class="button button-primary button-hero"><span class="dashicons dashicons-cart"></span><?php esc_html_e('Upgrade Now!', 'event_espresso') ?></a></td> |
|
82 | 82 | </tr> |
83 | 83 | </tbody> |
84 | 84 | </table> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | //Copied from _whats_new() |
140 | 140 | $steps = EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ? $this->_get_started_steps() : FALSE; |
141 | 141 | $steps = $steps !== FALSE ? $steps : ''; |
142 | - $this->_admin_page_title = sprintf( esc_html__('Welcome to Event Espresso %s', 'event_espresso'), EVENT_ESPRESSO_VERSION ); |
|
142 | + $this->_admin_page_title = sprintf(esc_html__('Welcome to Event Espresso %s', 'event_espresso'), EVENT_ESPRESSO_VERSION); |
|
143 | 143 | $settings_message = $steps; |
144 | - $this->_template_args['admin_page_subtitle'] = esc_html__('Thank you for choosing Event Espresso, the most powerful, and free, Event Management plugin for WordPress.', 'event_espresso' ) . $settings_message; |
|
145 | - $template = EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php'; |
|
146 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( $template, $this->_template_args, TRUE ); |
|
144 | + $this->_template_args['admin_page_subtitle'] = esc_html__('Thank you for choosing Event Espresso, the most powerful, and free, Event Management plugin for WordPress.', 'event_espresso').$settings_message; |
|
145 | + $template = EE_ABOUT_TEMPLATE_PATH.'ee4-overview.template.php'; |
|
146 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template($template, $this->_template_args, TRUE); |
|
147 | 147 | $this->display_about_admin_page(); |
148 | 148 | } |
149 | 149 | |
@@ -151,36 +151,36 @@ discard block |
||
151 | 151 | |
152 | 152 | protected function _get_started_steps() { |
153 | 153 | $steps = '<h2>'.esc_html__('Getting Started').'</h2>'; |
154 | - $step_one = '<p>'.sprintf( esc_html__('%sStep 1%s: Visit your %sOrganization Settings%s and add/update your details.', 'event_espresso'), '<strong>', '</strong>', '<a href="admin.php?page=espresso_general_settings">', '</a>') .'</strong></p>'; |
|
155 | - $step_two = '<p>'.sprintf( esc_html__('%sStep 2%s: Setup your %sPayment Methods%s.', 'event_espresso'), '<strong>', '</strong>', '<a href="admin.php?page=espresso_payment_settings">', '</a>') .'</strong></p>'; |
|
156 | - $step_three = '<p>'.sprintf( esc_html__('%sStep 3%s: Create your %sFirst Event%s.', 'event_espresso'), '<strong>', '</strong>', '<a href="admin.php?page=espresso_events&action=create_new">', '</a>') .'</strong></p>'; |
|
154 | + $step_one = '<p>'.sprintf(esc_html__('%sStep 1%s: Visit your %sOrganization Settings%s and add/update your details.', 'event_espresso'), '<strong>', '</strong>', '<a href="admin.php?page=espresso_general_settings">', '</a>').'</strong></p>'; |
|
155 | + $step_two = '<p>'.sprintf(esc_html__('%sStep 2%s: Setup your %sPayment Methods%s.', 'event_espresso'), '<strong>', '</strong>', '<a href="admin.php?page=espresso_payment_settings">', '</a>').'</strong></p>'; |
|
156 | + $step_three = '<p>'.sprintf(esc_html__('%sStep 3%s: Create your %sFirst Event%s.', 'event_espresso'), '<strong>', '</strong>', '<a href="admin.php?page=espresso_events&action=create_new">', '</a>').'</strong></p>'; |
|
157 | 157 | |
158 | 158 | //done? |
159 | 159 | $done_step_one = EE_Registry::instance()->CFG->organization->address_1 == '123 Onna Road' ? FALSE : TRUE; |
160 | - $active_invoice_pm = EEM_Payment_Method::instance()->get_one_active( EEM_Payment_Method::scope_cart, array( array( 'PMD_type' => 'Invoice' ) ) ); |
|
161 | - $active_pms_count = EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ); |
|
160 | + $active_invoice_pm = EEM_Payment_Method::instance()->get_one_active(EEM_Payment_Method::scope_cart, array(array('PMD_type' => 'Invoice'))); |
|
161 | + $active_pms_count = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart); |
|
162 | 162 | //done step two if a non-invoice paymetn method is active; or there is more than one PM active, or |
163 | 163 | //if only the invoice is active but it's clearly been updated |
164 | - $done_step_two = $active_pms_count > 1 || |
|
165 | - ( $active_pms_count === 1 && ! $active_invoice_pm ) || |
|
166 | - ( $active_invoice_pm instanceof EE_Payment_Method && ( |
|
167 | - $active_invoice_pm->get_extra_meta( 'pdf_payee_name', TRUE, '' ) || |
|
168 | - $active_invoice_pm->get_extra_meta( 'pdf_payee_email', TRUE, '' ) || |
|
169 | - $active_invoice_pm->get_extra_meta( 'pdf_payee_tax_number', TRUE, '' ) || |
|
170 | - $active_invoice_pm->get_extra_meta( 'pdf_payee_address', TRUE, '' ) || |
|
171 | - $active_invoice_pm->get_extra_meta( 'page_extra_info', TRUE, '' ) |
|
164 | + $done_step_two = $active_pms_count > 1 || |
|
165 | + ($active_pms_count === 1 && ! $active_invoice_pm) || |
|
166 | + ($active_invoice_pm instanceof EE_Payment_Method && ( |
|
167 | + $active_invoice_pm->get_extra_meta('pdf_payee_name', TRUE, '') || |
|
168 | + $active_invoice_pm->get_extra_meta('pdf_payee_email', TRUE, '') || |
|
169 | + $active_invoice_pm->get_extra_meta('pdf_payee_tax_number', TRUE, '') || |
|
170 | + $active_invoice_pm->get_extra_meta('pdf_payee_address', TRUE, '') || |
|
171 | + $active_invoice_pm->get_extra_meta('page_extra_info', TRUE, '') |
|
172 | 172 | ) |
173 | 173 | ); |
174 | 174 | $done_step_three = EE_Registry::instance()->load_model('Event')->count() > 0 ? TRUE : FALSE; |
175 | 175 | |
176 | 176 | //if ALL steps are done, let's just return FALSE so we don't display anything |
177 | - if ( $done_step_one && $done_step_two && $done_step_three ) |
|
177 | + if ($done_step_one && $done_step_two && $done_step_three) |
|
178 | 178 | return FALSE; |
179 | 179 | |
180 | 180 | //now let's put it together |
181 | - $steps .= sprintf( '%s' . $step_one . '%s', $done_step_one ? '<strike>' : '', $done_step_one ? '</strike>': '' ); |
|
182 | - $steps .= sprintf( '%s' . $step_two . '%s', $done_step_two ? '<strike>' : '', $done_step_two ? '</strike>': '' ); |
|
183 | - $steps .= sprintf( '%s' . $step_three . '%s', $done_step_three ? '<strike>' : '', $done_step_three ? '</strike>': '' ); |
|
181 | + $steps .= sprintf('%s'.$step_one.'%s', $done_step_one ? '<strike>' : '', $done_step_one ? '</strike>' : ''); |
|
182 | + $steps .= sprintf('%s'.$step_two.'%s', $done_step_two ? '<strike>' : '', $done_step_two ? '</strike>' : ''); |
|
183 | + $steps .= sprintf('%s'.$step_three.'%s', $done_step_three ? '<strike>' : '', $done_step_three ? '</strike>' : ''); |
|
184 | 184 | |
185 | 185 | return $steps; |
186 | 186 | } |
@@ -188,27 +188,27 @@ discard block |
||
188 | 188 | |
189 | 189 | |
190 | 190 | protected function _credits() { |
191 | - $this->_template_args['admin_page_title'] = sprintf( __('Welcome to Event Espresso %s', 'event_espresso'), EVENT_ESPRESSO_VERSION ); |
|
191 | + $this->_template_args['admin_page_title'] = sprintf(__('Welcome to Event Espresso %s', 'event_espresso'), EVENT_ESPRESSO_VERSION); |
|
192 | 192 | $this->_template_args['admin_page_subtitle'] = __('Thank you for choosing Event Espresso Decaf, the most powerful, and free, Event Management plugin for WordPress.', 'event_espresso'); |
193 | - $template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php'; |
|
194 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( $template, $this->_template_args, TRUE ); |
|
193 | + $template = EE_ABOUT_TEMPLATE_PATH.'credits.template.php'; |
|
194 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template($template, $this->_template_args, TRUE); |
|
195 | 195 | $this->display_about_admin_page(); |
196 | 196 | } |
197 | 197 | |
198 | 198 | |
199 | 199 | protected function _decafvpro() { |
200 | - $this->_template_args['admin_page_title'] = sprintf( __('Welcome to Event Espresso %s', 'event_espresso'), EVENT_ESPRESSO_VERSION ); |
|
200 | + $this->_template_args['admin_page_title'] = sprintf(__('Welcome to Event Espresso %s', 'event_espresso'), EVENT_ESPRESSO_VERSION); |
|
201 | 201 | $this->_template_args['admin_page_subtitle'] = sprintf(__('Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s', 'event_espresso'), '<em>', '</em>', '<strong>', '</strong>'); |
202 | - $template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php'; |
|
203 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( $template, $this->_template_args, TRUE ); |
|
202 | + $template = EE_ABOUT_TEMPLATE_PATH.'decafvpro.template.php'; |
|
203 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template($template, $this->_template_args, TRUE); |
|
204 | 204 | $this->display_about_admin_page(); |
205 | 205 | } |
206 | 206 | |
207 | 207 | protected function _reviews() { |
208 | 208 | $this->_template_args['admin_page_title'] = __('Rave Reviews About Event Espresso 4', 'event_espresso'); |
209 | 209 | $this->_template_args['admin_page_subtitle'] = __('At Event Espresso, customer satisfaction is our ultimate goal.', 'event_espresso'); |
210 | - $template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php'; |
|
211 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( $template, $this->_template_args, TRUE ); |
|
210 | + $template = EE_ABOUT_TEMPLATE_PATH.'reviews.template.php'; |
|
211 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template($template, $this->_template_args, TRUE); |
|
212 | 212 | $this->display_about_admin_page(); |
213 | 213 | } |
214 | 214 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use EventEspresso\widgets\EspressoWidget; |
4 | 4 | |
5 | 5 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
6 | - exit('No direct script access allowed'); |
|
6 | + exit('No direct script access allowed'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | /** |
@@ -26,385 +26,385 @@ discard block |
||
26 | 26 | final class EE_Front_Controller |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * @var string $_template_path |
|
31 | - */ |
|
32 | - private $_template_path; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string $_template |
|
36 | - */ |
|
37 | - private $_template; |
|
38 | - |
|
39 | - /** |
|
40 | - * @type EE_Registry $Registry |
|
41 | - */ |
|
42 | - protected $Registry; |
|
43 | - |
|
44 | - /** |
|
45 | - * @type EE_Request_Handler $Request_Handler |
|
46 | - */ |
|
47 | - protected $Request_Handler; |
|
48 | - |
|
49 | - /** |
|
50 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
51 | - */ |
|
52 | - protected $Module_Request_Router; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * class constructor |
|
57 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
58 | - * |
|
59 | - * @access public |
|
60 | - * @param \EE_Registry $Registry |
|
61 | - * @param \EE_Request_Handler $Request_Handler |
|
62 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
63 | - */ |
|
64 | - public function __construct( |
|
65 | - EE_Registry $Registry, |
|
66 | - EE_Request_Handler $Request_Handler, |
|
67 | - EE_Module_Request_Router $Module_Request_Router |
|
68 | - ) { |
|
69 | - $this->Registry = $Registry; |
|
70 | - $this->Request_Handler = $Request_Handler; |
|
71 | - $this->Module_Request_Router = $Module_Request_Router; |
|
72 | - // determine how to integrate WP_Query with the EE models |
|
73 | - add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
74 | - // load other resources and begin to actually run shortcodes and modules |
|
75 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
76 | - // analyse the incoming WP request |
|
77 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
78 | - // process request with module factory |
|
79 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
80 | - // before headers sent |
|
81 | - add_action('wp', array($this, 'wp'), 5); |
|
82 | - // primarily used to process any content shortcodes |
|
83 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
84 | - // header |
|
85 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
86 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
87 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
88 | - // display errors |
|
89 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
90 | - // the content |
|
91 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
92 | - //exclude our private cpt comments |
|
93 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
94 | - //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
95 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
96 | - // action hook EE |
|
97 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
98 | - // for checking that browser cookies are enabled |
|
99 | - if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
100 | - setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
101 | - } |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return EE_Request_Handler |
|
107 | - */ |
|
108 | - public function Request_Handler() |
|
109 | - { |
|
110 | - return $this->Request_Handler; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @return EE_Module_Request_Router |
|
116 | - */ |
|
117 | - public function Module_Request_Router() |
|
118 | - { |
|
119 | - return $this->Module_Request_Router; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @return LegacyShortcodesManager |
|
126 | - */ |
|
127 | - public function getLegacyShortcodesManager() |
|
128 | - { |
|
129 | - return EE_Config::getLegacyShortcodesManager(); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - |
|
134 | - |
|
135 | - |
|
136 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * filter_wp_comments |
|
142 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
143 | - * widgets/queries done on frontend |
|
144 | - * |
|
145 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
146 | - * @return array array of comment clauses with modifications. |
|
147 | - */ |
|
148 | - public function filter_wp_comments($clauses) |
|
149 | - { |
|
150 | - global $wpdb; |
|
151 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
152 | - $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
153 | - foreach ($cpts as $cpt => $details) { |
|
154 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
155 | - } |
|
156 | - } |
|
157 | - return $clauses; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * employ_CPT_Strategy |
|
163 | - * |
|
164 | - * @access public |
|
165 | - * @return void |
|
166 | - */ |
|
167 | - public function employ_CPT_Strategy() |
|
168 | - { |
|
169 | - if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
170 | - $this->Registry->load_core('CPT_Strategy'); |
|
171 | - } |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
177 | - * |
|
178 | - * @param string $url incoming url |
|
179 | - * @return string final assembled url |
|
180 | - */ |
|
181 | - public function maybe_force_admin_ajax_ssl($url) |
|
182 | - { |
|
183 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
184 | - $url = str_replace('http://', 'https://', $url); |
|
185 | - } |
|
186 | - return $url; |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - |
|
191 | - |
|
192 | - |
|
193 | - |
|
194 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
199 | - * default priority init phases have run |
|
200 | - * |
|
201 | - * @access public |
|
202 | - * @return void |
|
203 | - */ |
|
204 | - public function wp_loaded() |
|
205 | - { |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - |
|
210 | - |
|
211 | - |
|
212 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
213 | - /** |
|
214 | - * _get_request |
|
215 | - * |
|
216 | - * @access public |
|
217 | - * @param WP $WP |
|
218 | - * @return void |
|
219 | - */ |
|
220 | - public function get_request(WP $WP) |
|
221 | - { |
|
222 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
223 | - $this->Request_Handler->parse_request($WP); |
|
224 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
231 | - * |
|
232 | - * @access public |
|
233 | - * @param WP_Query $WP_Query |
|
234 | - * @return void |
|
235 | - */ |
|
236 | - public function pre_get_posts($WP_Query) |
|
237 | - { |
|
238 | - // only load Module_Request_Router if this is the main query |
|
239 | - if ( |
|
240 | - $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
241 | - && $WP_Query->is_main_query() |
|
242 | - ) { |
|
243 | - // cycle thru module routes |
|
244 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
245 | - // determine module and method for route |
|
246 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
247 | - if ($module instanceof EED_Module) { |
|
248 | - // get registered view for route |
|
249 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
250 | - // grab module name |
|
251 | - $module_name = $module->module_name(); |
|
252 | - // map the module to the module objects |
|
253 | - $this->Registry->modules->{$module_name} = $module; |
|
254 | - } |
|
255 | - } |
|
256 | - } |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - |
|
261 | - |
|
262 | - |
|
263 | - /*********************************************** WP HOOK ***********************************************/ |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * wp - basically last chance to do stuff before headers sent |
|
268 | - * |
|
269 | - * @access public |
|
270 | - * @return void |
|
271 | - */ |
|
272 | - public function wp() |
|
273 | - { |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - |
|
278 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
279 | - |
|
280 | - |
|
281 | - |
|
282 | - /** |
|
283 | - * callback for the "template_redirect" hook point |
|
284 | - * checks sidebars for EE widgets |
|
285 | - * loads resources and assets accordingly |
|
286 | - * |
|
287 | - * @return void |
|
288 | - */ |
|
289 | - public function templateRedirect() |
|
290 | - { |
|
291 | - global $wp_query; |
|
292 | - if (empty($wp_query->posts)){ |
|
293 | - return; |
|
294 | - } |
|
295 | - // if we already know this is an espresso page, then load assets |
|
296 | - $load_assets = $this->Request_Handler->is_espresso_page(); |
|
297 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
298 | - $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
299 | - if ( $load_assets){ |
|
300 | - add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
301 | - add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
302 | - } |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * builds list of active widgets then scans active sidebars looking for them |
|
309 | - * returns true is an EE widget is found in an active sidebar |
|
310 | - * Please Note: this does NOT mean that the sidebar or widget |
|
311 | - * is actually in use in a given template, as that is unfortunately not known |
|
312 | - * until a sidebar and it's widgets are actually loaded |
|
313 | - * |
|
314 | - * @return boolean |
|
315 | - */ |
|
316 | - private function espresso_widgets_in_active_sidebars() |
|
317 | - { |
|
318 | - $espresso_widgets = array(); |
|
319 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
320 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
321 | - if (is_active_widget(false, false, $id_base)) { |
|
322 | - $espresso_widgets[] = $id_base; |
|
323 | - } |
|
324 | - } |
|
325 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
326 | - foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
327 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
328 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
329 | - foreach ($espresso_widgets as $espresso_widget) { |
|
330 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
331 | - return true; |
|
332 | - } |
|
333 | - } |
|
334 | - } |
|
335 | - } |
|
336 | - } |
|
337 | - return false; |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * header_meta_tag |
|
345 | - * |
|
346 | - * @access public |
|
347 | - * @return void |
|
348 | - */ |
|
349 | - public function header_meta_tag() |
|
350 | - { |
|
351 | - print( |
|
352 | - apply_filters( |
|
353 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
354 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
355 | - ); |
|
356 | - |
|
357 | - //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
358 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
359 | - //also exclude all critical pages from indexing |
|
360 | - if ( |
|
361 | - ( |
|
362 | - is_tax('espresso_event_type') |
|
363 | - && get_option( 'blog_public' ) !== '0' |
|
364 | - ) |
|
365 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
366 | - ) { |
|
367 | - print( |
|
368 | - apply_filters( |
|
369 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
370 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
371 | - ) |
|
372 | - ); |
|
373 | - } |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * wp_print_scripts |
|
380 | - * |
|
381 | - * @return void |
|
382 | - */ |
|
383 | - public function wp_print_scripts() |
|
384 | - { |
|
385 | - global $post; |
|
386 | - if ( |
|
387 | - isset($post->EE_Event) |
|
388 | - && $post->EE_Event instanceof EE_Event |
|
389 | - && get_post_type() === 'espresso_events' |
|
390 | - && is_singular() |
|
391 | - ) { |
|
392 | - \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
393 | - } |
|
394 | - } |
|
395 | - |
|
396 | - |
|
397 | - |
|
398 | - public function enqueueStyle() |
|
399 | - { |
|
400 | - wp_enqueue_style('espresso_default'); |
|
401 | - wp_enqueue_style('espresso_custom_css'); |
|
402 | - } |
|
403 | - |
|
404 | - |
|
405 | - |
|
406 | - |
|
407 | - /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
29 | + /** |
|
30 | + * @var string $_template_path |
|
31 | + */ |
|
32 | + private $_template_path; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string $_template |
|
36 | + */ |
|
37 | + private $_template; |
|
38 | + |
|
39 | + /** |
|
40 | + * @type EE_Registry $Registry |
|
41 | + */ |
|
42 | + protected $Registry; |
|
43 | + |
|
44 | + /** |
|
45 | + * @type EE_Request_Handler $Request_Handler |
|
46 | + */ |
|
47 | + protected $Request_Handler; |
|
48 | + |
|
49 | + /** |
|
50 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
51 | + */ |
|
52 | + protected $Module_Request_Router; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * class constructor |
|
57 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
58 | + * |
|
59 | + * @access public |
|
60 | + * @param \EE_Registry $Registry |
|
61 | + * @param \EE_Request_Handler $Request_Handler |
|
62 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
63 | + */ |
|
64 | + public function __construct( |
|
65 | + EE_Registry $Registry, |
|
66 | + EE_Request_Handler $Request_Handler, |
|
67 | + EE_Module_Request_Router $Module_Request_Router |
|
68 | + ) { |
|
69 | + $this->Registry = $Registry; |
|
70 | + $this->Request_Handler = $Request_Handler; |
|
71 | + $this->Module_Request_Router = $Module_Request_Router; |
|
72 | + // determine how to integrate WP_Query with the EE models |
|
73 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
74 | + // load other resources and begin to actually run shortcodes and modules |
|
75 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
76 | + // analyse the incoming WP request |
|
77 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
78 | + // process request with module factory |
|
79 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
80 | + // before headers sent |
|
81 | + add_action('wp', array($this, 'wp'), 5); |
|
82 | + // primarily used to process any content shortcodes |
|
83 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
84 | + // header |
|
85 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
86 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
87 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
88 | + // display errors |
|
89 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
90 | + // the content |
|
91 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
92 | + //exclude our private cpt comments |
|
93 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
94 | + //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
95 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
96 | + // action hook EE |
|
97 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
98 | + // for checking that browser cookies are enabled |
|
99 | + if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
100 | + setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
101 | + } |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return EE_Request_Handler |
|
107 | + */ |
|
108 | + public function Request_Handler() |
|
109 | + { |
|
110 | + return $this->Request_Handler; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @return EE_Module_Request_Router |
|
116 | + */ |
|
117 | + public function Module_Request_Router() |
|
118 | + { |
|
119 | + return $this->Module_Request_Router; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @return LegacyShortcodesManager |
|
126 | + */ |
|
127 | + public function getLegacyShortcodesManager() |
|
128 | + { |
|
129 | + return EE_Config::getLegacyShortcodesManager(); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + |
|
134 | + |
|
135 | + |
|
136 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * filter_wp_comments |
|
142 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
143 | + * widgets/queries done on frontend |
|
144 | + * |
|
145 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
146 | + * @return array array of comment clauses with modifications. |
|
147 | + */ |
|
148 | + public function filter_wp_comments($clauses) |
|
149 | + { |
|
150 | + global $wpdb; |
|
151 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
152 | + $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
153 | + foreach ($cpts as $cpt => $details) { |
|
154 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
155 | + } |
|
156 | + } |
|
157 | + return $clauses; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * employ_CPT_Strategy |
|
163 | + * |
|
164 | + * @access public |
|
165 | + * @return void |
|
166 | + */ |
|
167 | + public function employ_CPT_Strategy() |
|
168 | + { |
|
169 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
170 | + $this->Registry->load_core('CPT_Strategy'); |
|
171 | + } |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
177 | + * |
|
178 | + * @param string $url incoming url |
|
179 | + * @return string final assembled url |
|
180 | + */ |
|
181 | + public function maybe_force_admin_ajax_ssl($url) |
|
182 | + { |
|
183 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
184 | + $url = str_replace('http://', 'https://', $url); |
|
185 | + } |
|
186 | + return $url; |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + |
|
191 | + |
|
192 | + |
|
193 | + |
|
194 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
199 | + * default priority init phases have run |
|
200 | + * |
|
201 | + * @access public |
|
202 | + * @return void |
|
203 | + */ |
|
204 | + public function wp_loaded() |
|
205 | + { |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + |
|
210 | + |
|
211 | + |
|
212 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
213 | + /** |
|
214 | + * _get_request |
|
215 | + * |
|
216 | + * @access public |
|
217 | + * @param WP $WP |
|
218 | + * @return void |
|
219 | + */ |
|
220 | + public function get_request(WP $WP) |
|
221 | + { |
|
222 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
223 | + $this->Request_Handler->parse_request($WP); |
|
224 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
231 | + * |
|
232 | + * @access public |
|
233 | + * @param WP_Query $WP_Query |
|
234 | + * @return void |
|
235 | + */ |
|
236 | + public function pre_get_posts($WP_Query) |
|
237 | + { |
|
238 | + // only load Module_Request_Router if this is the main query |
|
239 | + if ( |
|
240 | + $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
241 | + && $WP_Query->is_main_query() |
|
242 | + ) { |
|
243 | + // cycle thru module routes |
|
244 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
245 | + // determine module and method for route |
|
246 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
247 | + if ($module instanceof EED_Module) { |
|
248 | + // get registered view for route |
|
249 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
250 | + // grab module name |
|
251 | + $module_name = $module->module_name(); |
|
252 | + // map the module to the module objects |
|
253 | + $this->Registry->modules->{$module_name} = $module; |
|
254 | + } |
|
255 | + } |
|
256 | + } |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + |
|
261 | + |
|
262 | + |
|
263 | + /*********************************************** WP HOOK ***********************************************/ |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * wp - basically last chance to do stuff before headers sent |
|
268 | + * |
|
269 | + * @access public |
|
270 | + * @return void |
|
271 | + */ |
|
272 | + public function wp() |
|
273 | + { |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + |
|
278 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
279 | + |
|
280 | + |
|
281 | + |
|
282 | + /** |
|
283 | + * callback for the "template_redirect" hook point |
|
284 | + * checks sidebars for EE widgets |
|
285 | + * loads resources and assets accordingly |
|
286 | + * |
|
287 | + * @return void |
|
288 | + */ |
|
289 | + public function templateRedirect() |
|
290 | + { |
|
291 | + global $wp_query; |
|
292 | + if (empty($wp_query->posts)){ |
|
293 | + return; |
|
294 | + } |
|
295 | + // if we already know this is an espresso page, then load assets |
|
296 | + $load_assets = $this->Request_Handler->is_espresso_page(); |
|
297 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
298 | + $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
299 | + if ( $load_assets){ |
|
300 | + add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
301 | + add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
302 | + } |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * builds list of active widgets then scans active sidebars looking for them |
|
309 | + * returns true is an EE widget is found in an active sidebar |
|
310 | + * Please Note: this does NOT mean that the sidebar or widget |
|
311 | + * is actually in use in a given template, as that is unfortunately not known |
|
312 | + * until a sidebar and it's widgets are actually loaded |
|
313 | + * |
|
314 | + * @return boolean |
|
315 | + */ |
|
316 | + private function espresso_widgets_in_active_sidebars() |
|
317 | + { |
|
318 | + $espresso_widgets = array(); |
|
319 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
320 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
321 | + if (is_active_widget(false, false, $id_base)) { |
|
322 | + $espresso_widgets[] = $id_base; |
|
323 | + } |
|
324 | + } |
|
325 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
326 | + foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
327 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
328 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
329 | + foreach ($espresso_widgets as $espresso_widget) { |
|
330 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
331 | + return true; |
|
332 | + } |
|
333 | + } |
|
334 | + } |
|
335 | + } |
|
336 | + } |
|
337 | + return false; |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * header_meta_tag |
|
345 | + * |
|
346 | + * @access public |
|
347 | + * @return void |
|
348 | + */ |
|
349 | + public function header_meta_tag() |
|
350 | + { |
|
351 | + print( |
|
352 | + apply_filters( |
|
353 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
354 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
355 | + ); |
|
356 | + |
|
357 | + //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
358 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
359 | + //also exclude all critical pages from indexing |
|
360 | + if ( |
|
361 | + ( |
|
362 | + is_tax('espresso_event_type') |
|
363 | + && get_option( 'blog_public' ) !== '0' |
|
364 | + ) |
|
365 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
366 | + ) { |
|
367 | + print( |
|
368 | + apply_filters( |
|
369 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
370 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
371 | + ) |
|
372 | + ); |
|
373 | + } |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * wp_print_scripts |
|
380 | + * |
|
381 | + * @return void |
|
382 | + */ |
|
383 | + public function wp_print_scripts() |
|
384 | + { |
|
385 | + global $post; |
|
386 | + if ( |
|
387 | + isset($post->EE_Event) |
|
388 | + && $post->EE_Event instanceof EE_Event |
|
389 | + && get_post_type() === 'espresso_events' |
|
390 | + && is_singular() |
|
391 | + ) { |
|
392 | + \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
393 | + } |
|
394 | + } |
|
395 | + |
|
396 | + |
|
397 | + |
|
398 | + public function enqueueStyle() |
|
399 | + { |
|
400 | + wp_enqueue_style('espresso_default'); |
|
401 | + wp_enqueue_style('espresso_custom_css'); |
|
402 | + } |
|
403 | + |
|
404 | + |
|
405 | + |
|
406 | + |
|
407 | + /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
408 | 408 | |
409 | 409 | |
410 | 410 | |
@@ -415,108 +415,108 @@ discard block |
||
415 | 415 | // * @param $the_content |
416 | 416 | // * @return string |
417 | 417 | // */ |
418 | - // public function the_content( $the_content ) { |
|
419 | - // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
420 | - // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
421 | - // } |
|
422 | - // return $the_content; |
|
423 | - // } |
|
424 | - |
|
425 | - |
|
426 | - |
|
427 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
428 | - |
|
429 | - |
|
430 | - |
|
431 | - public function enqueueScripts() |
|
432 | - { |
|
433 | - wp_enqueue_script('espresso_core'); |
|
434 | - } |
|
435 | - |
|
436 | - |
|
437 | - |
|
438 | - /** |
|
439 | - * display_errors |
|
440 | - * |
|
441 | - * @access public |
|
442 | - * @return void |
|
443 | - * @throws DomainException |
|
444 | - */ |
|
445 | - public function display_errors() |
|
446 | - { |
|
447 | - static $shown_already = false; |
|
448 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
449 | - if ( |
|
450 | - ! $shown_already |
|
451 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
452 | - && is_main_query() |
|
453 | - && ! is_feed() |
|
454 | - && in_the_loop() |
|
455 | - && $this->Request_Handler->is_espresso_page() |
|
456 | - ) { |
|
457 | - echo EE_Error::get_notices(); |
|
458 | - $shown_already = true; |
|
459 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
460 | - } |
|
461 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
462 | - } |
|
463 | - |
|
464 | - |
|
465 | - |
|
466 | - |
|
467 | - |
|
468 | - /*********************************************** UTILITIES ***********************************************/ |
|
469 | - /** |
|
470 | - * template_include |
|
471 | - * |
|
472 | - * @access public |
|
473 | - * @param string $template_include_path |
|
474 | - * @return string |
|
475 | - */ |
|
476 | - public function template_include($template_include_path = null) |
|
477 | - { |
|
478 | - if ($this->Request_Handler->is_espresso_page()) { |
|
479 | - $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
480 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
481 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
482 | - $this->_template = basename($this->_template_path); |
|
483 | - return $this->_template_path; |
|
484 | - } |
|
485 | - return $template_include_path; |
|
486 | - } |
|
487 | - |
|
488 | - |
|
489 | - /** |
|
490 | - * get_selected_template |
|
491 | - * |
|
492 | - * @access public |
|
493 | - * @param bool $with_path |
|
494 | - * @return string |
|
495 | - */ |
|
496 | - public function get_selected_template($with_path = false) |
|
497 | - { |
|
498 | - return $with_path ? $this->_template_path : $this->_template; |
|
499 | - } |
|
500 | - |
|
501 | - |
|
502 | - |
|
503 | - /** |
|
504 | - * @deprecated 4.9.26 |
|
505 | - * @param string $shortcode_class |
|
506 | - * @param \WP $wp |
|
507 | - */ |
|
508 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
509 | - { |
|
510 | - \EE_Error::doing_it_wrong( |
|
511 | - __METHOD__, |
|
512 | - __( |
|
513 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
514 | - 'event_espresso' |
|
515 | - ), |
|
516 | - '4.9.26' |
|
517 | - ); |
|
518 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
519 | - } |
|
418 | + // public function the_content( $the_content ) { |
|
419 | + // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
420 | + // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
421 | + // } |
|
422 | + // return $the_content; |
|
423 | + // } |
|
424 | + |
|
425 | + |
|
426 | + |
|
427 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
428 | + |
|
429 | + |
|
430 | + |
|
431 | + public function enqueueScripts() |
|
432 | + { |
|
433 | + wp_enqueue_script('espresso_core'); |
|
434 | + } |
|
435 | + |
|
436 | + |
|
437 | + |
|
438 | + /** |
|
439 | + * display_errors |
|
440 | + * |
|
441 | + * @access public |
|
442 | + * @return void |
|
443 | + * @throws DomainException |
|
444 | + */ |
|
445 | + public function display_errors() |
|
446 | + { |
|
447 | + static $shown_already = false; |
|
448 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
449 | + if ( |
|
450 | + ! $shown_already |
|
451 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
452 | + && is_main_query() |
|
453 | + && ! is_feed() |
|
454 | + && in_the_loop() |
|
455 | + && $this->Request_Handler->is_espresso_page() |
|
456 | + ) { |
|
457 | + echo EE_Error::get_notices(); |
|
458 | + $shown_already = true; |
|
459 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
460 | + } |
|
461 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
462 | + } |
|
463 | + |
|
464 | + |
|
465 | + |
|
466 | + |
|
467 | + |
|
468 | + /*********************************************** UTILITIES ***********************************************/ |
|
469 | + /** |
|
470 | + * template_include |
|
471 | + * |
|
472 | + * @access public |
|
473 | + * @param string $template_include_path |
|
474 | + * @return string |
|
475 | + */ |
|
476 | + public function template_include($template_include_path = null) |
|
477 | + { |
|
478 | + if ($this->Request_Handler->is_espresso_page()) { |
|
479 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
480 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
481 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
482 | + $this->_template = basename($this->_template_path); |
|
483 | + return $this->_template_path; |
|
484 | + } |
|
485 | + return $template_include_path; |
|
486 | + } |
|
487 | + |
|
488 | + |
|
489 | + /** |
|
490 | + * get_selected_template |
|
491 | + * |
|
492 | + * @access public |
|
493 | + * @param bool $with_path |
|
494 | + * @return string |
|
495 | + */ |
|
496 | + public function get_selected_template($with_path = false) |
|
497 | + { |
|
498 | + return $with_path ? $this->_template_path : $this->_template; |
|
499 | + } |
|
500 | + |
|
501 | + |
|
502 | + |
|
503 | + /** |
|
504 | + * @deprecated 4.9.26 |
|
505 | + * @param string $shortcode_class |
|
506 | + * @param \WP $wp |
|
507 | + */ |
|
508 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
509 | + { |
|
510 | + \EE_Error::doing_it_wrong( |
|
511 | + __METHOD__, |
|
512 | + __( |
|
513 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
514 | + 'event_espresso' |
|
515 | + ), |
|
516 | + '4.9.26' |
|
517 | + ); |
|
518 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
519 | + } |
|
520 | 520 | |
521 | 521 | } |
522 | 522 | // End of file EE_Front_Controller.core.php |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | do_action('AHEE__EE_Front_Controller__construct__done', $this); |
98 | 98 | // for checking that browser cookies are enabled |
99 | 99 | if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
100 | - setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
100 | + setcookie('ee_cookie_test', uniqid('ect', true), time() + DAY_IN_SECONDS, '/'); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -289,14 +289,14 @@ discard block |
||
289 | 289 | public function templateRedirect() |
290 | 290 | { |
291 | 291 | global $wp_query; |
292 | - if (empty($wp_query->posts)){ |
|
292 | + if (empty($wp_query->posts)) { |
|
293 | 293 | return; |
294 | 294 | } |
295 | 295 | // if we already know this is an espresso page, then load assets |
296 | 296 | $load_assets = $this->Request_Handler->is_espresso_page(); |
297 | 297 | // if we are already loading assets then just move along, otherwise check for widgets |
298 | 298 | $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
299 | - if ( $load_assets){ |
|
299 | + if ($load_assets) { |
|
300 | 300 | add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
301 | 301 | add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
302 | 302 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | print( |
352 | 352 | apply_filters( |
353 | 353 | 'FHEE__EE_Front_Controller__header_meta_tag', |
354 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
354 | + '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n") |
|
355 | 355 | ); |
356 | 356 | |
357 | 357 | //let's exclude all event type taxonomy term archive pages from search engine indexing |
@@ -360,14 +360,14 @@ discard block |
||
360 | 360 | if ( |
361 | 361 | ( |
362 | 362 | is_tax('espresso_event_type') |
363 | - && get_option( 'blog_public' ) !== '0' |
|
363 | + && get_option('blog_public') !== '0' |
|
364 | 364 | ) |
365 | 365 | || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
366 | 366 | ) { |
367 | 367 | print( |
368 | 368 | apply_filters( |
369 | 369 | 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
370 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
370 | + '<meta name="robots" content="noindex,follow" />'."\n" |
|
371 | 371 | ) |
372 | 372 | ); |
373 | 373 | } |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | ) { |
457 | 457 | echo EE_Error::get_notices(); |
458 | 458 | $shown_already = true; |
459 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
459 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
460 | 460 | } |
461 | 461 | do_action('AHEE__EE_Front_Controller__display_errors__end'); |
462 | 462 | } |
@@ -18,122 +18,122 @@ |
||
18 | 18 | class EE_Register_Payment_Method implements EEI_Plugin_API |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Holds values for registered payment methods |
|
23 | - * |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - protected static $_settings = array(); |
|
21 | + /** |
|
22 | + * Holds values for registered payment methods |
|
23 | + * |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + protected static $_settings = array(); |
|
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * Method for registering new EE_PMT_Base children |
|
32 | - * |
|
33 | - * @since 4.5.0 |
|
34 | - * @param string $payment_method_id a unique identifier for this set of modules Required. |
|
35 | - * @param array $setup_args an array of arguments provided for registering modules Required.{ |
|
36 | - * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class |
|
37 | - * (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains |
|
38 | - * the files EE_PMT_Payomatic.pm.php) |
|
39 | - * } |
|
40 | - * @throws EE_Error |
|
41 | - * @type array payment_method_paths an array of full server paths to folders containing any EE_PMT_Base |
|
42 | - * children, or to the EED_Module files themselves |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - public static function register($payment_method_id = null, $setup_args = array()) |
|
46 | - { |
|
47 | - //required fields MUST be present, so let's make sure they are. |
|
48 | - if (empty($payment_method_id) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) { |
|
49 | - throw new EE_Error( |
|
50 | - esc_html__( |
|
51 | - 'In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', |
|
52 | - 'event_espresso' |
|
53 | - ) |
|
54 | - ); |
|
55 | - } |
|
56 | - //make sure we don't register twice |
|
57 | - if (isset(self::$_settings[$payment_method_id])) { |
|
58 | - return; |
|
59 | - } |
|
60 | - //make sure this was called in the right place! |
|
61 | - if ( |
|
62 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
63 | - || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
64 | - ) { |
|
65 | - EE_Error::doing_it_wrong( |
|
66 | - __METHOD__, |
|
67 | - esc_html__( |
|
68 | - 'An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', |
|
69 | - 'event_espresso' |
|
70 | - ), |
|
71 | - '4.3.0' |
|
72 | - ); |
|
73 | - } |
|
74 | - //setup $_settings array from incoming values. |
|
75 | - self::$_settings[$payment_method_id] = array( |
|
76 | - // array of full server paths to any EE_PMT_Base children used |
|
77 | - 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
78 | - ? (array)$setup_args['payment_method_paths'] |
|
79 | - : array(), |
|
80 | - ); |
|
81 | - // add to list of modules to be registered |
|
82 | - add_filter( |
|
83 | - 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
84 | - array('EE_Register_Payment_Method', 'add_payment_methods') |
|
85 | - ); |
|
86 | - /** |
|
87 | - * If EE_Payment_Method_Manager::register_payment_methods has already been called, |
|
88 | - * we need it to be called again (because it's missing the payment method we JUST registered here). |
|
89 | - * We are assuming EE_Register_payment_method::register() will be called only once |
|
90 | - * per payment method from an addon, so going with that assumption we should always do this. |
|
91 | - * If that assumption is false, we should verify this newly-registered payment method |
|
92 | - * isn't on the EE_Payment_Method_Manager::_payment_method_types array before calling this |
|
93 | - * (this code should be changed to improve performance) |
|
94 | - */ |
|
95 | - if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) { |
|
96 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
97 | - EE_Payment_Method_Manager::instance()->maybe_register_payment_methods(true); |
|
98 | - } |
|
99 | - } |
|
30 | + /** |
|
31 | + * Method for registering new EE_PMT_Base children |
|
32 | + * |
|
33 | + * @since 4.5.0 |
|
34 | + * @param string $payment_method_id a unique identifier for this set of modules Required. |
|
35 | + * @param array $setup_args an array of arguments provided for registering modules Required.{ |
|
36 | + * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class |
|
37 | + * (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains |
|
38 | + * the files EE_PMT_Payomatic.pm.php) |
|
39 | + * } |
|
40 | + * @throws EE_Error |
|
41 | + * @type array payment_method_paths an array of full server paths to folders containing any EE_PMT_Base |
|
42 | + * children, or to the EED_Module files themselves |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + public static function register($payment_method_id = null, $setup_args = array()) |
|
46 | + { |
|
47 | + //required fields MUST be present, so let's make sure they are. |
|
48 | + if (empty($payment_method_id) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) { |
|
49 | + throw new EE_Error( |
|
50 | + esc_html__( |
|
51 | + 'In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', |
|
52 | + 'event_espresso' |
|
53 | + ) |
|
54 | + ); |
|
55 | + } |
|
56 | + //make sure we don't register twice |
|
57 | + if (isset(self::$_settings[$payment_method_id])) { |
|
58 | + return; |
|
59 | + } |
|
60 | + //make sure this was called in the right place! |
|
61 | + if ( |
|
62 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
63 | + || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
64 | + ) { |
|
65 | + EE_Error::doing_it_wrong( |
|
66 | + __METHOD__, |
|
67 | + esc_html__( |
|
68 | + 'An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', |
|
69 | + 'event_espresso' |
|
70 | + ), |
|
71 | + '4.3.0' |
|
72 | + ); |
|
73 | + } |
|
74 | + //setup $_settings array from incoming values. |
|
75 | + self::$_settings[$payment_method_id] = array( |
|
76 | + // array of full server paths to any EE_PMT_Base children used |
|
77 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
78 | + ? (array)$setup_args['payment_method_paths'] |
|
79 | + : array(), |
|
80 | + ); |
|
81 | + // add to list of modules to be registered |
|
82 | + add_filter( |
|
83 | + 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
84 | + array('EE_Register_Payment_Method', 'add_payment_methods') |
|
85 | + ); |
|
86 | + /** |
|
87 | + * If EE_Payment_Method_Manager::register_payment_methods has already been called, |
|
88 | + * we need it to be called again (because it's missing the payment method we JUST registered here). |
|
89 | + * We are assuming EE_Register_payment_method::register() will be called only once |
|
90 | + * per payment method from an addon, so going with that assumption we should always do this. |
|
91 | + * If that assumption is false, we should verify this newly-registered payment method |
|
92 | + * isn't on the EE_Payment_Method_Manager::_payment_method_types array before calling this |
|
93 | + * (this code should be changed to improve performance) |
|
94 | + */ |
|
95 | + if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) { |
|
96 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
97 | + EE_Payment_Method_Manager::instance()->maybe_register_payment_methods(true); |
|
98 | + } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * Filters the list of payment methods to add ours. |
|
105 | - * and they're just full filepaths to FOLDERS containing a payment method class file. Eg. |
|
106 | - * |
|
107 | - * @param array $payment_method_folders array of paths to all payment methods that require registering |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - public static function add_payment_methods($payment_method_folders) |
|
111 | - { |
|
112 | - foreach (self::$_settings as $settings) { |
|
113 | - $payment_method_folders = array_merge( |
|
114 | - $payment_method_folders, |
|
115 | - $settings['payment_method_paths'] |
|
116 | - ); |
|
117 | - } |
|
118 | - return $payment_method_folders; |
|
119 | - } |
|
103 | + /** |
|
104 | + * Filters the list of payment methods to add ours. |
|
105 | + * and they're just full filepaths to FOLDERS containing a payment method class file. Eg. |
|
106 | + * |
|
107 | + * @param array $payment_method_folders array of paths to all payment methods that require registering |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + public static function add_payment_methods($payment_method_folders) |
|
111 | + { |
|
112 | + foreach (self::$_settings as $settings) { |
|
113 | + $payment_method_folders = array_merge( |
|
114 | + $payment_method_folders, |
|
115 | + $settings['payment_method_paths'] |
|
116 | + ); |
|
117 | + } |
|
118 | + return $payment_method_folders; |
|
119 | + } |
|
120 | 120 | |
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * This deregisters a module that was previously registered with a specific $module_id. |
|
125 | - * |
|
126 | - * @since 4.3.0 |
|
127 | - * |
|
128 | - * @param string $module_id the name for the module that was previously registered |
|
129 | - * @return void |
|
130 | - */ |
|
131 | - public static function deregister($module_id = null) |
|
132 | - { |
|
133 | - if (isset(self::$_settings[$module_id])) { |
|
134 | - unset(self::$_settings[$module_id]); |
|
135 | - } |
|
136 | - } |
|
123 | + /** |
|
124 | + * This deregisters a module that was previously registered with a specific $module_id. |
|
125 | + * |
|
126 | + * @since 4.3.0 |
|
127 | + * |
|
128 | + * @param string $module_id the name for the module that was previously registered |
|
129 | + * @return void |
|
130 | + */ |
|
131 | + public static function deregister($module_id = null) |
|
132 | + { |
|
133 | + if (isset(self::$_settings[$module_id])) { |
|
134 | + unset(self::$_settings[$module_id]); |
|
135 | + } |
|
136 | + } |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | // End of file EE_Register_Payment_Method.lib.php |
@@ -75,7 +75,7 @@ |
||
75 | 75 | self::$_settings[$payment_method_id] = array( |
76 | 76 | // array of full server paths to any EE_PMT_Base children used |
77 | 77 | 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
78 | - ? (array)$setup_args['payment_method_paths'] |
|
78 | + ? (array) $setup_args['payment_method_paths'] |
|
79 | 79 | : array(), |
80 | 80 | ); |
81 | 81 | // add to list of modules to be registered |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public static function instance() |
37 | 37 | { |
38 | 38 | // check if class object is instantiated, and instantiated properly |
39 | - if (! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
39 | + if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
40 | 40 | self::$_instance = new self(); |
41 | 41 | } |
42 | 42 | EE_Registry::instance()->load_lib('PMT_Base'); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function maybe_register_payment_methods($force_recheck = false) |
69 | 69 | { |
70 | - if (! $this->_payment_method_types || $force_recheck) { |
|
70 | + if ( ! $this->_payment_method_types || $force_recheck) { |
|
71 | 71 | $this->_register_payment_methods(); |
72 | 72 | //if in admin lets ensure caps are set. |
73 | 73 | if (is_admin()) { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | protected function _register_payment_methods() |
88 | 88 | { |
89 | 89 | // grab list of installed modules |
90 | - $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR); |
|
90 | + $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR); |
|
91 | 91 | // filter list of modules to register |
92 | 92 | $pm_to_register = apply_filters( |
93 | 93 | 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
@@ -126,31 +126,31 @@ discard block |
||
126 | 126 | // create classname from module directory name |
127 | 127 | $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir); |
128 | 128 | // add class prefix |
129 | - $module_class = 'EE_PMT_' . $module; |
|
129 | + $module_class = 'EE_PMT_'.$module; |
|
130 | 130 | // does the module exist ? |
131 | - if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) { |
|
131 | + if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) { |
|
132 | 132 | $msg = sprintf( |
133 | 133 | esc_html__( |
134 | 134 | 'The requested %s payment method file could not be found or is not readable due to file permissions.', |
135 | 135 | 'event_espresso' |
136 | 136 | ), $module |
137 | 137 | ); |
138 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
138 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | // load the module class file |
142 | - require_once($payment_method_path . DS . $module_class . $module_ext); |
|
142 | + require_once($payment_method_path.DS.$module_class.$module_ext); |
|
143 | 143 | // verify that class exists |
144 | - if (! class_exists($module_class)) { |
|
144 | + if ( ! class_exists($module_class)) { |
|
145 | 145 | $msg = sprintf( |
146 | 146 | esc_html__('The requested %s module class does not exist.', 'event_espresso'), |
147 | 147 | $module_class |
148 | 148 | ); |
149 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
149 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | // add to array of registered modules |
153 | - $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext; |
|
153 | + $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext; |
|
154 | 154 | return true; |
155 | 155 | } |
156 | 156 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | public function payment_method_class_from_type($type) |
248 | 248 | { |
249 | 249 | $this->maybe_register_payment_methods(); |
250 | - return 'EE_PMT_' . $type; |
|
250 | + return 'EE_PMT_'.$type; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | public function activate_a_payment_method_of_type($payment_method_type) |
263 | 263 | { |
264 | 264 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
265 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
265 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
266 | 266 | $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
267 | 267 | if (class_exists($pm_type_class)) { |
268 | 268 | /** @var $pm_type_obj EE_PMT_Base */ |
269 | 269 | $pm_type_obj = new $pm_type_class; |
270 | 270 | $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
271 | - if (! $payment_method) { |
|
271 | + if ( ! $payment_method) { |
|
272 | 272 | $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
273 | 273 | } |
274 | 274 | $payment_method->set_type($payment_method_type); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | 'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.', |
300 | 300 | 'event_espresso' |
301 | 301 | ), |
302 | - '<a href="' . admin_url('admin.php?page=espresso_messages') . '">', |
|
302 | + '<a href="'.admin_url('admin.php?page=espresso_messages').'">', |
|
303 | 303 | '</a>' |
304 | 304 | ), |
305 | 305 | true |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | 'PMD_type' => $pm_type_obj->system_name(), |
327 | 327 | 'PMD_name' => $pm_type_obj->pretty_name(), |
328 | 328 | 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
329 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
329 | + 'PMD_slug' => $pm_type_obj->system_name(), //automatically converted to slug |
|
330 | 330 | 'PMD_wp_user' => $current_user->ID, |
331 | 331 | 'PMD_order' => EEM_Payment_Method::instance()->count( |
332 | 332 | array(array('PMD_type' => array('!=', 'Admin_Only'))) |
@@ -349,14 +349,14 @@ discard block |
||
349 | 349 | { |
350 | 350 | $pm_type_obj = $payment_method->type_obj(); |
351 | 351 | $payment_method->set_description($pm_type_obj->default_description()); |
352 | - if (! $payment_method->button_url()) { |
|
352 | + if ( ! $payment_method->button_url()) { |
|
353 | 353 | $payment_method->set_button_url($pm_type_obj->default_button_url()); |
354 | 354 | } |
355 | 355 | //now add setup its default extra meta properties |
356 | 356 | $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
357 | - if (! empty($extra_metas)) { |
|
357 | + if ( ! empty($extra_metas)) { |
|
358 | 358 | //verify the payment method has an ID before adding extra meta |
359 | - if (! $payment_method->ID()) { |
|
359 | + if ( ! $payment_method->ID()) { |
|
360 | 360 | $payment_method->save(); |
361 | 361 | } |
362 | 362 | foreach ($extra_metas as $meta_name => $input) { |
@@ -19,420 +19,420 @@ discard block |
||
19 | 19 | class EE_Payment_Method_Manager implements ResettableInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var EE_Payment_Method_Manager $_instance |
|
24 | - */ |
|
25 | - private static $_instance; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var array keys are class names without 'EE_PMT_', values are their filepaths |
|
29 | - */ |
|
30 | - protected $_payment_method_types = array(); |
|
31 | - |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @singleton method used to instantiate class object |
|
36 | - * @return EE_Payment_Method_Manager instance |
|
37 | - */ |
|
38 | - public static function instance() |
|
39 | - { |
|
40 | - // check if class object is instantiated, and instantiated properly |
|
41 | - if (! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
42 | - self::$_instance = new self(); |
|
43 | - } |
|
44 | - EE_Registry::instance()->load_lib('PMT_Base'); |
|
45 | - return self::$_instance; |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * Resets the instance and returns a new one |
|
52 | - * |
|
53 | - * @return EE_Payment_Method_Manager |
|
54 | - */ |
|
55 | - public static function reset() |
|
56 | - { |
|
57 | - self::$_instance = null; |
|
58 | - return self::instance(); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * If necessary, re-register payment methods |
|
65 | - * |
|
66 | - * @param boolean $force_recheck whether to recheck for payment method types, |
|
67 | - * or just re-use the PMTs we found last time we checked during this request (if |
|
68 | - * we have not yet checked during this request, then we need to check anyways) |
|
69 | - */ |
|
70 | - public function maybe_register_payment_methods($force_recheck = false) |
|
71 | - { |
|
72 | - if (! $this->_payment_method_types || $force_recheck) { |
|
73 | - $this->_register_payment_methods(); |
|
74 | - //if in admin lets ensure caps are set. |
|
75 | - if (is_admin()) { |
|
76 | - add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
77 | - EE_Registry::instance()->CAP->init_caps(); |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * register_payment_methods |
|
86 | - * |
|
87 | - * @return array |
|
88 | - */ |
|
89 | - protected function _register_payment_methods() |
|
90 | - { |
|
91 | - // grab list of installed modules |
|
92 | - $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR); |
|
93 | - // filter list of modules to register |
|
94 | - $pm_to_register = apply_filters( |
|
95 | - 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
96 | - $pm_to_register |
|
97 | - ); |
|
98 | - // loop through folders |
|
99 | - foreach ($pm_to_register as $pm_path) { |
|
100 | - $this->register_payment_method($pm_path); |
|
101 | - } |
|
102 | - do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
103 | - // filter list of installed modules |
|
104 | - //keep them organized alphabetically by the payment method type's name |
|
105 | - ksort($this->_payment_method_types); |
|
106 | - return apply_filters( |
|
107 | - 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', |
|
108 | - $this->_payment_method_types |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * register_payment_method- makes core aware of this payment method |
|
116 | - * |
|
117 | - * @param string $payment_method_path - full path up to and including payment method folder |
|
118 | - * @return boolean |
|
119 | - */ |
|
120 | - public function register_payment_method($payment_method_path = '') |
|
121 | - { |
|
122 | - do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
123 | - $module_ext = '.pm.php'; |
|
124 | - // make all separators match |
|
125 | - $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
126 | - // grab and sanitize module name |
|
127 | - $module_dir = basename($payment_method_path); |
|
128 | - // create classname from module directory name |
|
129 | - $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir); |
|
130 | - // add class prefix |
|
131 | - $module_class = 'EE_PMT_' . $module; |
|
132 | - // does the module exist ? |
|
133 | - if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) { |
|
134 | - $msg = sprintf( |
|
135 | - esc_html__( |
|
136 | - 'The requested %s payment method file could not be found or is not readable due to file permissions.', |
|
137 | - 'event_espresso' |
|
138 | - ), $module |
|
139 | - ); |
|
140 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
141 | - return false; |
|
142 | - } |
|
143 | - // load the module class file |
|
144 | - require_once($payment_method_path . DS . $module_class . $module_ext); |
|
145 | - // verify that class exists |
|
146 | - if (! class_exists($module_class)) { |
|
147 | - $msg = sprintf( |
|
148 | - esc_html__('The requested %s module class does not exist.', 'event_espresso'), |
|
149 | - $module_class |
|
150 | - ); |
|
151 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
152 | - return false; |
|
153 | - } |
|
154 | - // add to array of registered modules |
|
155 | - $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext; |
|
156 | - return true; |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Checks if a payment method has been registered, and if so includes it |
|
163 | - * |
|
164 | - * @param string $payment_method_name like 'PayPal_Pro', (ie classname without the prefix 'EEPM_') |
|
165 | - * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
166 | - * @return boolean |
|
167 | - */ |
|
168 | - public function payment_method_type_exists($payment_method_name, $force_recheck = false) |
|
169 | - { |
|
170 | - if ( |
|
171 | - $force_recheck |
|
172 | - || ! is_array($this->_payment_method_types) |
|
173 | - || ! isset($this->_payment_method_types[$payment_method_name]) |
|
174 | - ) { |
|
175 | - $this->maybe_register_payment_methods($force_recheck); |
|
176 | - } |
|
177 | - if (isset($this->_payment_method_types[$payment_method_name])) { |
|
178 | - require_once($this->_payment_method_types[$payment_method_name]); |
|
179 | - return true; |
|
180 | - } |
|
181 | - return false; |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * Returns all the class names of the various payment method types |
|
188 | - * |
|
189 | - * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names' |
|
190 | - * (what you'd find in wp_esp_payment_method.PMD_type) |
|
191 | - * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
192 | - * @return array |
|
193 | - */ |
|
194 | - public function payment_method_type_names($with_prefixes = false, $force_recheck = false) |
|
195 | - { |
|
196 | - $this->maybe_register_payment_methods($force_recheck); |
|
197 | - if ($with_prefixes) { |
|
198 | - $classnames = array_keys($this->_payment_method_types); |
|
199 | - $payment_methods = array(); |
|
200 | - foreach ($classnames as $classname) { |
|
201 | - $payment_methods[] = $this->payment_method_class_from_type($classname); |
|
202 | - } |
|
203 | - return $payment_methods; |
|
204 | - } |
|
205 | - return array_keys($this->_payment_method_types); |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * Gets an object of each payment method type, none of which are bound to a |
|
212 | - * payment method instance |
|
213 | - * |
|
214 | - * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
215 | - * @return EE_PMT_Base[] |
|
216 | - */ |
|
217 | - public function payment_method_types($force_recheck = false) |
|
218 | - { |
|
219 | - $this->maybe_register_payment_methods($force_recheck); |
|
220 | - $payment_method_objects = array(); |
|
221 | - foreach ($this->payment_method_type_names(true) as $classname) { |
|
222 | - $payment_method_objects[] = new $classname; |
|
223 | - } |
|
224 | - return $payment_method_objects; |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * Changes the payment method's classname into the payment method type's name |
|
231 | - * (as used on the payment method's table's PMD_type field) |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @return string |
|
235 | - */ |
|
236 | - public function payment_method_type_sans_class_prefix($classname) |
|
237 | - { |
|
238 | - return str_replace('EE_PMT_', '', $classname); |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * Does the opposite of payment-method_type_sans_prefix |
|
245 | - * |
|
246 | - * @param string $type |
|
247 | - * @return string |
|
248 | - */ |
|
249 | - public function payment_method_class_from_type($type) |
|
250 | - { |
|
251 | - $this->maybe_register_payment_methods(); |
|
252 | - return 'EE_PMT_' . $type; |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * Activates a payment method of the given type. |
|
259 | - * |
|
260 | - * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice' |
|
261 | - * @return EE_Payment_Method |
|
262 | - * @throws EE_Error |
|
263 | - */ |
|
264 | - public function activate_a_payment_method_of_type($payment_method_type) |
|
265 | - { |
|
266 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
|
267 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
268 | - $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
|
269 | - if (class_exists($pm_type_class)) { |
|
270 | - /** @var $pm_type_obj EE_PMT_Base */ |
|
271 | - $pm_type_obj = new $pm_type_class; |
|
272 | - $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
|
273 | - if (! $payment_method) { |
|
274 | - $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
275 | - } |
|
276 | - $payment_method->set_type($payment_method_type); |
|
277 | - $this->initialize_payment_method($payment_method); |
|
278 | - } else { |
|
279 | - throw new EE_Error( |
|
280 | - sprintf( |
|
281 | - esc_html__( |
|
282 | - 'There is no payment method of type %1$s, so it could not be activated', |
|
283 | - 'event_espresso' |
|
284 | - ), |
|
285 | - $pm_type_class |
|
286 | - ) |
|
287 | - ); |
|
288 | - } |
|
289 | - } |
|
290 | - $payment_method->set_active(); |
|
291 | - $payment_method->save(); |
|
292 | - if ($payment_method->type() === 'Invoice') { |
|
293 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
294 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
295 | - $message_resource_manager->ensure_message_type_is_active('invoice', 'html'); |
|
296 | - $message_resource_manager->ensure_messenger_is_active('pdf'); |
|
297 | - EE_Error::add_persistent_admin_notice( |
|
298 | - 'invoice_pm_requirements_notice', |
|
299 | - sprintf( |
|
300 | - esc_html__( |
|
301 | - 'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.', |
|
302 | - 'event_espresso' |
|
303 | - ), |
|
304 | - '<a href="' . admin_url('admin.php?page=espresso_messages') . '">', |
|
305 | - '</a>' |
|
306 | - ), |
|
307 | - true |
|
308 | - ); |
|
309 | - } |
|
310 | - return $payment_method; |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * Creates a payment method of the specified type. Does not save it. |
|
317 | - * |
|
318 | - * @global WP_User $current_user |
|
319 | - * @param EE_PMT_Base $pm_type_obj |
|
320 | - * @return EE_Payment_Method |
|
321 | - * @throws EE_Error |
|
322 | - */ |
|
323 | - public function create_payment_method_of_type($pm_type_obj) |
|
324 | - { |
|
325 | - global $current_user; |
|
326 | - $payment_method = EE_Payment_Method::new_instance( |
|
327 | - array( |
|
328 | - 'PMD_type' => $pm_type_obj->system_name(), |
|
329 | - 'PMD_name' => $pm_type_obj->pretty_name(), |
|
330 | - 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
|
331 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
332 | - 'PMD_wp_user' => $current_user->ID, |
|
333 | - 'PMD_order' => EEM_Payment_Method::instance()->count( |
|
334 | - array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
335 | - ) * 10, |
|
336 | - ) |
|
337 | - ); |
|
338 | - return $payment_method; |
|
339 | - } |
|
340 | - |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * Sets the initial payment method properties (including extra meta) |
|
345 | - * |
|
346 | - * @param EE_Payment_Method $payment_method |
|
347 | - * @return EE_Payment_Method |
|
348 | - * @throws EE_Error |
|
349 | - */ |
|
350 | - public function initialize_payment_method($payment_method) |
|
351 | - { |
|
352 | - $pm_type_obj = $payment_method->type_obj(); |
|
353 | - $payment_method->set_description($pm_type_obj->default_description()); |
|
354 | - if (! $payment_method->button_url()) { |
|
355 | - $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
356 | - } |
|
357 | - //now add setup its default extra meta properties |
|
358 | - $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
|
359 | - if (! empty($extra_metas)) { |
|
360 | - //verify the payment method has an ID before adding extra meta |
|
361 | - if (! $payment_method->ID()) { |
|
362 | - $payment_method->save(); |
|
363 | - } |
|
364 | - foreach ($extra_metas as $meta_name => $input) { |
|
365 | - $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
366 | - } |
|
367 | - } |
|
368 | - return $payment_method; |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - |
|
373 | - /** |
|
374 | - * Makes sure the payment method is related to the specified payment method |
|
375 | - * |
|
376 | - * @deprecated in 4.9.40 because the currency payment method table is being deprecated |
|
377 | - * @param EE_Payment_Method $payment_method |
|
378 | - * @return EE_Payment_Method |
|
379 | - * @throws EE_Error |
|
380 | - */ |
|
381 | - public function set_usable_currencies_on_payment_method($payment_method) |
|
382 | - { |
|
383 | - EE_Error::doing_it_wrong( |
|
384 | - 'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method', |
|
385 | - esc_html__( |
|
386 | - 'We no longer define what currencies are usable by payment methods. Its not used nor efficient.', |
|
387 | - 'event_espresso' |
|
388 | - ), |
|
389 | - '4.9.40' |
|
390 | - ); |
|
391 | - return $payment_method; |
|
392 | - } |
|
393 | - |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * Deactivates a payment method of the given payment method slug. |
|
398 | - * |
|
399 | - * @param string $payment_method_slug The slug for the payment method to deactivate. |
|
400 | - * @return int count of rows updated. |
|
401 | - * @throws EE_Error |
|
402 | - */ |
|
403 | - public function deactivate_payment_method($payment_method_slug) |
|
404 | - { |
|
405 | - EE_Log::instance()->log( |
|
406 | - __FILE__, |
|
407 | - __FUNCTION__, |
|
408 | - sprintf( |
|
409 | - esc_html__( |
|
410 | - 'Payment method with slug %1$s is being deactivated by site admin', |
|
411 | - 'event_espresso' |
|
412 | - ), |
|
413 | - $payment_method_slug |
|
414 | - ), |
|
415 | - 'payment_method_change' |
|
416 | - ); |
|
417 | - $count_updated = EEM_Payment_Method::instance()->update( |
|
418 | - array('PMD_scope' => array()), |
|
419 | - array(array('PMD_slug' => $payment_method_slug)) |
|
420 | - ); |
|
421 | - return $count_updated; |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * callback for FHEE__EE_Capabilities__init_caps_map__caps filter to add dynamic payment method |
|
428 | - * access caps. |
|
429 | - * |
|
430 | - * @param array $caps capabilities being filtered |
|
431 | - * @return array |
|
432 | - */ |
|
433 | - public function add_payment_method_caps($caps) |
|
434 | - { |
|
435 | - /* add dynamic caps from payment methods |
|
22 | + /** |
|
23 | + * @var EE_Payment_Method_Manager $_instance |
|
24 | + */ |
|
25 | + private static $_instance; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var array keys are class names without 'EE_PMT_', values are their filepaths |
|
29 | + */ |
|
30 | + protected $_payment_method_types = array(); |
|
31 | + |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @singleton method used to instantiate class object |
|
36 | + * @return EE_Payment_Method_Manager instance |
|
37 | + */ |
|
38 | + public static function instance() |
|
39 | + { |
|
40 | + // check if class object is instantiated, and instantiated properly |
|
41 | + if (! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
42 | + self::$_instance = new self(); |
|
43 | + } |
|
44 | + EE_Registry::instance()->load_lib('PMT_Base'); |
|
45 | + return self::$_instance; |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * Resets the instance and returns a new one |
|
52 | + * |
|
53 | + * @return EE_Payment_Method_Manager |
|
54 | + */ |
|
55 | + public static function reset() |
|
56 | + { |
|
57 | + self::$_instance = null; |
|
58 | + return self::instance(); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * If necessary, re-register payment methods |
|
65 | + * |
|
66 | + * @param boolean $force_recheck whether to recheck for payment method types, |
|
67 | + * or just re-use the PMTs we found last time we checked during this request (if |
|
68 | + * we have not yet checked during this request, then we need to check anyways) |
|
69 | + */ |
|
70 | + public function maybe_register_payment_methods($force_recheck = false) |
|
71 | + { |
|
72 | + if (! $this->_payment_method_types || $force_recheck) { |
|
73 | + $this->_register_payment_methods(); |
|
74 | + //if in admin lets ensure caps are set. |
|
75 | + if (is_admin()) { |
|
76 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
77 | + EE_Registry::instance()->CAP->init_caps(); |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * register_payment_methods |
|
86 | + * |
|
87 | + * @return array |
|
88 | + */ |
|
89 | + protected function _register_payment_methods() |
|
90 | + { |
|
91 | + // grab list of installed modules |
|
92 | + $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR); |
|
93 | + // filter list of modules to register |
|
94 | + $pm_to_register = apply_filters( |
|
95 | + 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
96 | + $pm_to_register |
|
97 | + ); |
|
98 | + // loop through folders |
|
99 | + foreach ($pm_to_register as $pm_path) { |
|
100 | + $this->register_payment_method($pm_path); |
|
101 | + } |
|
102 | + do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
103 | + // filter list of installed modules |
|
104 | + //keep them organized alphabetically by the payment method type's name |
|
105 | + ksort($this->_payment_method_types); |
|
106 | + return apply_filters( |
|
107 | + 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', |
|
108 | + $this->_payment_method_types |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * register_payment_method- makes core aware of this payment method |
|
116 | + * |
|
117 | + * @param string $payment_method_path - full path up to and including payment method folder |
|
118 | + * @return boolean |
|
119 | + */ |
|
120 | + public function register_payment_method($payment_method_path = '') |
|
121 | + { |
|
122 | + do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
123 | + $module_ext = '.pm.php'; |
|
124 | + // make all separators match |
|
125 | + $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
126 | + // grab and sanitize module name |
|
127 | + $module_dir = basename($payment_method_path); |
|
128 | + // create classname from module directory name |
|
129 | + $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir); |
|
130 | + // add class prefix |
|
131 | + $module_class = 'EE_PMT_' . $module; |
|
132 | + // does the module exist ? |
|
133 | + if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) { |
|
134 | + $msg = sprintf( |
|
135 | + esc_html__( |
|
136 | + 'The requested %s payment method file could not be found or is not readable due to file permissions.', |
|
137 | + 'event_espresso' |
|
138 | + ), $module |
|
139 | + ); |
|
140 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
141 | + return false; |
|
142 | + } |
|
143 | + // load the module class file |
|
144 | + require_once($payment_method_path . DS . $module_class . $module_ext); |
|
145 | + // verify that class exists |
|
146 | + if (! class_exists($module_class)) { |
|
147 | + $msg = sprintf( |
|
148 | + esc_html__('The requested %s module class does not exist.', 'event_espresso'), |
|
149 | + $module_class |
|
150 | + ); |
|
151 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
152 | + return false; |
|
153 | + } |
|
154 | + // add to array of registered modules |
|
155 | + $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext; |
|
156 | + return true; |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Checks if a payment method has been registered, and if so includes it |
|
163 | + * |
|
164 | + * @param string $payment_method_name like 'PayPal_Pro', (ie classname without the prefix 'EEPM_') |
|
165 | + * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
166 | + * @return boolean |
|
167 | + */ |
|
168 | + public function payment_method_type_exists($payment_method_name, $force_recheck = false) |
|
169 | + { |
|
170 | + if ( |
|
171 | + $force_recheck |
|
172 | + || ! is_array($this->_payment_method_types) |
|
173 | + || ! isset($this->_payment_method_types[$payment_method_name]) |
|
174 | + ) { |
|
175 | + $this->maybe_register_payment_methods($force_recheck); |
|
176 | + } |
|
177 | + if (isset($this->_payment_method_types[$payment_method_name])) { |
|
178 | + require_once($this->_payment_method_types[$payment_method_name]); |
|
179 | + return true; |
|
180 | + } |
|
181 | + return false; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * Returns all the class names of the various payment method types |
|
188 | + * |
|
189 | + * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names' |
|
190 | + * (what you'd find in wp_esp_payment_method.PMD_type) |
|
191 | + * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
192 | + * @return array |
|
193 | + */ |
|
194 | + public function payment_method_type_names($with_prefixes = false, $force_recheck = false) |
|
195 | + { |
|
196 | + $this->maybe_register_payment_methods($force_recheck); |
|
197 | + if ($with_prefixes) { |
|
198 | + $classnames = array_keys($this->_payment_method_types); |
|
199 | + $payment_methods = array(); |
|
200 | + foreach ($classnames as $classname) { |
|
201 | + $payment_methods[] = $this->payment_method_class_from_type($classname); |
|
202 | + } |
|
203 | + return $payment_methods; |
|
204 | + } |
|
205 | + return array_keys($this->_payment_method_types); |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * Gets an object of each payment method type, none of which are bound to a |
|
212 | + * payment method instance |
|
213 | + * |
|
214 | + * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
215 | + * @return EE_PMT_Base[] |
|
216 | + */ |
|
217 | + public function payment_method_types($force_recheck = false) |
|
218 | + { |
|
219 | + $this->maybe_register_payment_methods($force_recheck); |
|
220 | + $payment_method_objects = array(); |
|
221 | + foreach ($this->payment_method_type_names(true) as $classname) { |
|
222 | + $payment_method_objects[] = new $classname; |
|
223 | + } |
|
224 | + return $payment_method_objects; |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * Changes the payment method's classname into the payment method type's name |
|
231 | + * (as used on the payment method's table's PMD_type field) |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @return string |
|
235 | + */ |
|
236 | + public function payment_method_type_sans_class_prefix($classname) |
|
237 | + { |
|
238 | + return str_replace('EE_PMT_', '', $classname); |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * Does the opposite of payment-method_type_sans_prefix |
|
245 | + * |
|
246 | + * @param string $type |
|
247 | + * @return string |
|
248 | + */ |
|
249 | + public function payment_method_class_from_type($type) |
|
250 | + { |
|
251 | + $this->maybe_register_payment_methods(); |
|
252 | + return 'EE_PMT_' . $type; |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * Activates a payment method of the given type. |
|
259 | + * |
|
260 | + * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice' |
|
261 | + * @return EE_Payment_Method |
|
262 | + * @throws EE_Error |
|
263 | + */ |
|
264 | + public function activate_a_payment_method_of_type($payment_method_type) |
|
265 | + { |
|
266 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
|
267 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
268 | + $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
|
269 | + if (class_exists($pm_type_class)) { |
|
270 | + /** @var $pm_type_obj EE_PMT_Base */ |
|
271 | + $pm_type_obj = new $pm_type_class; |
|
272 | + $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
|
273 | + if (! $payment_method) { |
|
274 | + $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
275 | + } |
|
276 | + $payment_method->set_type($payment_method_type); |
|
277 | + $this->initialize_payment_method($payment_method); |
|
278 | + } else { |
|
279 | + throw new EE_Error( |
|
280 | + sprintf( |
|
281 | + esc_html__( |
|
282 | + 'There is no payment method of type %1$s, so it could not be activated', |
|
283 | + 'event_espresso' |
|
284 | + ), |
|
285 | + $pm_type_class |
|
286 | + ) |
|
287 | + ); |
|
288 | + } |
|
289 | + } |
|
290 | + $payment_method->set_active(); |
|
291 | + $payment_method->save(); |
|
292 | + if ($payment_method->type() === 'Invoice') { |
|
293 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
294 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
295 | + $message_resource_manager->ensure_message_type_is_active('invoice', 'html'); |
|
296 | + $message_resource_manager->ensure_messenger_is_active('pdf'); |
|
297 | + EE_Error::add_persistent_admin_notice( |
|
298 | + 'invoice_pm_requirements_notice', |
|
299 | + sprintf( |
|
300 | + esc_html__( |
|
301 | + 'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.', |
|
302 | + 'event_espresso' |
|
303 | + ), |
|
304 | + '<a href="' . admin_url('admin.php?page=espresso_messages') . '">', |
|
305 | + '</a>' |
|
306 | + ), |
|
307 | + true |
|
308 | + ); |
|
309 | + } |
|
310 | + return $payment_method; |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * Creates a payment method of the specified type. Does not save it. |
|
317 | + * |
|
318 | + * @global WP_User $current_user |
|
319 | + * @param EE_PMT_Base $pm_type_obj |
|
320 | + * @return EE_Payment_Method |
|
321 | + * @throws EE_Error |
|
322 | + */ |
|
323 | + public function create_payment_method_of_type($pm_type_obj) |
|
324 | + { |
|
325 | + global $current_user; |
|
326 | + $payment_method = EE_Payment_Method::new_instance( |
|
327 | + array( |
|
328 | + 'PMD_type' => $pm_type_obj->system_name(), |
|
329 | + 'PMD_name' => $pm_type_obj->pretty_name(), |
|
330 | + 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
|
331 | + 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
332 | + 'PMD_wp_user' => $current_user->ID, |
|
333 | + 'PMD_order' => EEM_Payment_Method::instance()->count( |
|
334 | + array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
335 | + ) * 10, |
|
336 | + ) |
|
337 | + ); |
|
338 | + return $payment_method; |
|
339 | + } |
|
340 | + |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * Sets the initial payment method properties (including extra meta) |
|
345 | + * |
|
346 | + * @param EE_Payment_Method $payment_method |
|
347 | + * @return EE_Payment_Method |
|
348 | + * @throws EE_Error |
|
349 | + */ |
|
350 | + public function initialize_payment_method($payment_method) |
|
351 | + { |
|
352 | + $pm_type_obj = $payment_method->type_obj(); |
|
353 | + $payment_method->set_description($pm_type_obj->default_description()); |
|
354 | + if (! $payment_method->button_url()) { |
|
355 | + $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
356 | + } |
|
357 | + //now add setup its default extra meta properties |
|
358 | + $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
|
359 | + if (! empty($extra_metas)) { |
|
360 | + //verify the payment method has an ID before adding extra meta |
|
361 | + if (! $payment_method->ID()) { |
|
362 | + $payment_method->save(); |
|
363 | + } |
|
364 | + foreach ($extra_metas as $meta_name => $input) { |
|
365 | + $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
366 | + } |
|
367 | + } |
|
368 | + return $payment_method; |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + |
|
373 | + /** |
|
374 | + * Makes sure the payment method is related to the specified payment method |
|
375 | + * |
|
376 | + * @deprecated in 4.9.40 because the currency payment method table is being deprecated |
|
377 | + * @param EE_Payment_Method $payment_method |
|
378 | + * @return EE_Payment_Method |
|
379 | + * @throws EE_Error |
|
380 | + */ |
|
381 | + public function set_usable_currencies_on_payment_method($payment_method) |
|
382 | + { |
|
383 | + EE_Error::doing_it_wrong( |
|
384 | + 'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method', |
|
385 | + esc_html__( |
|
386 | + 'We no longer define what currencies are usable by payment methods. Its not used nor efficient.', |
|
387 | + 'event_espresso' |
|
388 | + ), |
|
389 | + '4.9.40' |
|
390 | + ); |
|
391 | + return $payment_method; |
|
392 | + } |
|
393 | + |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * Deactivates a payment method of the given payment method slug. |
|
398 | + * |
|
399 | + * @param string $payment_method_slug The slug for the payment method to deactivate. |
|
400 | + * @return int count of rows updated. |
|
401 | + * @throws EE_Error |
|
402 | + */ |
|
403 | + public function deactivate_payment_method($payment_method_slug) |
|
404 | + { |
|
405 | + EE_Log::instance()->log( |
|
406 | + __FILE__, |
|
407 | + __FUNCTION__, |
|
408 | + sprintf( |
|
409 | + esc_html__( |
|
410 | + 'Payment method with slug %1$s is being deactivated by site admin', |
|
411 | + 'event_espresso' |
|
412 | + ), |
|
413 | + $payment_method_slug |
|
414 | + ), |
|
415 | + 'payment_method_change' |
|
416 | + ); |
|
417 | + $count_updated = EEM_Payment_Method::instance()->update( |
|
418 | + array('PMD_scope' => array()), |
|
419 | + array(array('PMD_slug' => $payment_method_slug)) |
|
420 | + ); |
|
421 | + return $count_updated; |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * callback for FHEE__EE_Capabilities__init_caps_map__caps filter to add dynamic payment method |
|
428 | + * access caps. |
|
429 | + * |
|
430 | + * @param array $caps capabilities being filtered |
|
431 | + * @return array |
|
432 | + */ |
|
433 | + public function add_payment_method_caps($caps) |
|
434 | + { |
|
435 | + /* add dynamic caps from payment methods |
|
436 | 436 | * at the time of writing, october 20 2014, these are the caps added: |
437 | 437 | * ee_payment_method_admin_only |
438 | 438 | * ee_payment_method_aim |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | * their related capability automatically added too, so long as they are |
447 | 447 | * registered properly using EE_Register_Payment_Method::register() |
448 | 448 | */ |
449 | - foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
450 | - $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
|
451 | - } |
|
452 | - return $caps; |
|
453 | - } |
|
449 | + foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
450 | + $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
|
451 | + } |
|
452 | + return $caps; |
|
453 | + } |
|
454 | 454 | |
455 | 455 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use EventEspresso\core\exceptions\InvalidFormSubmissionException; |
13 | 13 | |
14 | 14 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
15 | - exit('No direct script access allowed'); |
|
15 | + exit('No direct script access allowed'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | |
@@ -31,642 +31,642 @@ discard block |
||
31 | 31 | abstract class FormHandler implements FormHandlerInterface |
32 | 32 | { |
33 | 33 | |
34 | - /** |
|
35 | - * will add opening and closing HTML form tags as well as a submit button |
|
36 | - */ |
|
37 | - const ADD_FORM_TAGS_AND_SUBMIT = 'add_form_tags_and_submit'; |
|
38 | - |
|
39 | - /** |
|
40 | - * will add opening and closing HTML form tags but NOT a submit button |
|
41 | - */ |
|
42 | - const ADD_FORM_TAGS_ONLY = 'add_form_tags_only'; |
|
43 | - |
|
44 | - /** |
|
45 | - * will NOT add opening and closing HTML form tags but will add a submit button |
|
46 | - */ |
|
47 | - const ADD_FORM_SUBMIT_ONLY = 'add_form_submit_only'; |
|
48 | - |
|
49 | - /** |
|
50 | - * will NOT add opening and closing HTML form tags NOR a submit button |
|
51 | - */ |
|
52 | - const DO_NOT_SETUP_FORM = 'do_not_setup_form'; |
|
53 | - |
|
54 | - /** |
|
55 | - * if set to false, then this form has no displayable content, |
|
56 | - * and will only be used for processing data sent passed via GET or POST |
|
57 | - * defaults to true ( ie: form has displayable content ) |
|
58 | - * |
|
59 | - * @var boolean $displayable |
|
60 | - */ |
|
61 | - private $displayable = true; |
|
62 | - |
|
63 | - /** |
|
64 | - * @var string $form_name |
|
65 | - */ |
|
66 | - private $form_name; |
|
67 | - |
|
68 | - /** |
|
69 | - * @var string $admin_name |
|
70 | - */ |
|
71 | - private $admin_name; |
|
72 | - |
|
73 | - /** |
|
74 | - * @var string $slug |
|
75 | - */ |
|
76 | - private $slug; |
|
77 | - |
|
78 | - /** |
|
79 | - * @var string $submit_btn_text |
|
80 | - */ |
|
81 | - private $submit_btn_text; |
|
82 | - |
|
83 | - /** |
|
84 | - * @var string $form_action |
|
85 | - */ |
|
86 | - private $form_action; |
|
87 | - |
|
88 | - /** |
|
89 | - * form params in key value pairs |
|
90 | - * can be added to form action URL or as hidden inputs |
|
91 | - * |
|
92 | - * @var array $form_args |
|
93 | - */ |
|
94 | - private $form_args = array(); |
|
95 | - |
|
96 | - /** |
|
97 | - * value of one of the string constant above |
|
98 | - * |
|
99 | - * @var string $form_config |
|
100 | - */ |
|
101 | - private $form_config; |
|
102 | - |
|
103 | - /** |
|
104 | - * whether or not the form was determined to be invalid |
|
105 | - * |
|
106 | - * @var boolean $form_has_errors |
|
107 | - */ |
|
108 | - private $form_has_errors; |
|
109 | - |
|
110 | - /** |
|
111 | - * the absolute top level form section being used on the page |
|
112 | - * |
|
113 | - * @var \EE_Form_Section_Proper $form |
|
114 | - */ |
|
115 | - private $form; |
|
116 | - |
|
117 | - /** |
|
118 | - * @var \EE_Registry $registry |
|
119 | - */ |
|
120 | - protected $registry; |
|
121 | - |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * Form constructor. |
|
126 | - * |
|
127 | - * @param string $form_name |
|
128 | - * @param string $admin_name |
|
129 | - * @param string $slug |
|
130 | - * @param string $form_action |
|
131 | - * @param string $form_config |
|
132 | - * @param \EE_Registry $registry |
|
133 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
134 | - * @throws \DomainException |
|
135 | - * @throws \InvalidArgumentException |
|
136 | - */ |
|
137 | - public function __construct( |
|
138 | - $form_name, |
|
139 | - $admin_name, |
|
140 | - $slug, |
|
141 | - $form_action = '', |
|
142 | - $form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT, |
|
143 | - \EE_Registry $registry |
|
144 | - ) { |
|
145 | - $this->setFormName($form_name); |
|
146 | - $this->setAdminName($admin_name); |
|
147 | - $this->setSlug($slug); |
|
148 | - $this->setFormAction($form_action); |
|
149 | - $this->setFormConfig($form_config); |
|
150 | - $this->setSubmitBtnText(esc_html__('Submit', 'event_espresso')); |
|
151 | - $this->registry = $registry; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @return array |
|
158 | - */ |
|
159 | - public static function getFormConfigConstants() |
|
160 | - { |
|
161 | - return array( |
|
162 | - FormHandler::ADD_FORM_TAGS_AND_SUBMIT, |
|
163 | - FormHandler::ADD_FORM_TAGS_ONLY, |
|
164 | - FormHandler::ADD_FORM_SUBMIT_ONLY, |
|
165 | - FormHandler::DO_NOT_SETUP_FORM, |
|
166 | - ); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param bool $for_display |
|
173 | - * @return \EE_Form_Section_Proper |
|
174 | - * @throws \EE_Error |
|
175 | - * @throws \LogicException |
|
176 | - */ |
|
177 | - public function form($for_display = false) |
|
178 | - { |
|
179 | - if (! $this->formIsValid()) { |
|
180 | - return null; |
|
181 | - } |
|
182 | - if ($for_display) { |
|
183 | - $form_config = $this->formConfig(); |
|
184 | - if ( |
|
185 | - $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT |
|
186 | - || $form_config === FormHandler::ADD_FORM_SUBMIT_ONLY |
|
187 | - ) { |
|
188 | - $this->appendSubmitButton(); |
|
189 | - $this->clearFormButtonFloats(); |
|
190 | - } |
|
191 | - } |
|
192 | - return $this->form; |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * @return boolean |
|
199 | - * @throws LogicException |
|
200 | - */ |
|
201 | - public function formIsValid() |
|
202 | - { |
|
203 | - if (! $this->form instanceof \EE_Form_Section_Proper) { |
|
204 | - static $generated = false; |
|
205 | - if (! $generated) { |
|
206 | - $generated = true; |
|
207 | - $form = apply_filters( |
|
208 | - 'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__formIsValid__generated_form_object', |
|
209 | - $this->generate(), |
|
210 | - $this |
|
211 | - ); |
|
212 | - if ($form instanceof \EE_Form_Section_Proper) { |
|
213 | - $this->setForm($form); |
|
214 | - } |
|
215 | - } |
|
216 | - return $this->verifyForm(); |
|
217 | - } |
|
218 | - return true; |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * @return boolean |
|
225 | - * @throws LogicException |
|
226 | - */ |
|
227 | - public function verifyForm() |
|
228 | - { |
|
229 | - if ($this->form instanceof \EE_Form_Section_Proper) { |
|
230 | - return true; |
|
231 | - } |
|
232 | - throw new LogicException( |
|
233 | - sprintf( |
|
234 | - esc_html__('The "%1$s" form is invalid or missing', 'event_espresso'), |
|
235 | - $this->form_name |
|
236 | - ) |
|
237 | - ); |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * @param \EE_Form_Section_Proper $form |
|
244 | - */ |
|
245 | - public function setForm(\EE_Form_Section_Proper $form) |
|
246 | - { |
|
247 | - $this->form = $form; |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * @return boolean |
|
254 | - */ |
|
255 | - public function displayable() |
|
256 | - { |
|
257 | - return $this->displayable; |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * @param boolean $displayable |
|
264 | - */ |
|
265 | - public function setDisplayable($displayable = false) |
|
266 | - { |
|
267 | - $this->displayable = filter_var($displayable, FILTER_VALIDATE_BOOLEAN); |
|
268 | - } |
|
269 | - |
|
270 | - |
|
271 | - |
|
272 | - /** |
|
273 | - * a public name for the form that can be displayed on the frontend of a site |
|
274 | - * |
|
275 | - * @return string |
|
276 | - */ |
|
277 | - public function formName() |
|
278 | - { |
|
279 | - return $this->form_name; |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - |
|
284 | - /** |
|
285 | - * @param string $form_name |
|
286 | - * @throws InvalidDataTypeException |
|
287 | - */ |
|
288 | - public function setFormName($form_name) |
|
289 | - { |
|
290 | - if (! is_string($form_name)) { |
|
291 | - throw new InvalidDataTypeException('$form_name', $form_name, 'string'); |
|
292 | - } |
|
293 | - $this->form_name = $form_name; |
|
294 | - } |
|
295 | - |
|
296 | - |
|
297 | - |
|
298 | - /** |
|
299 | - * a public name for the form that can be displayed, but only in the admin |
|
300 | - * |
|
301 | - * @return string |
|
302 | - */ |
|
303 | - public function adminName() |
|
304 | - { |
|
305 | - return $this->admin_name; |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * @param string $admin_name |
|
312 | - * @throws InvalidDataTypeException |
|
313 | - */ |
|
314 | - public function setAdminName($admin_name) |
|
315 | - { |
|
316 | - if (! is_string($admin_name)) { |
|
317 | - throw new InvalidDataTypeException('$admin_name', $admin_name, 'string'); |
|
318 | - } |
|
319 | - $this->admin_name = $admin_name; |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * a URL friendly string that can be used for identifying the form |
|
326 | - * |
|
327 | - * @return string |
|
328 | - */ |
|
329 | - public function slug() |
|
330 | - { |
|
331 | - return $this->slug; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * @param string $slug |
|
338 | - * @throws InvalidDataTypeException |
|
339 | - */ |
|
340 | - public function setSlug($slug) |
|
341 | - { |
|
342 | - if (! is_string($slug)) { |
|
343 | - throw new InvalidDataTypeException('$slug', $slug, 'string'); |
|
344 | - } |
|
345 | - $this->slug = $slug; |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * @return string |
|
352 | - */ |
|
353 | - public function submitBtnText() |
|
354 | - { |
|
355 | - return $this->submit_btn_text; |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * @param string $submit_btn_text |
|
362 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
363 | - * @throws \InvalidArgumentException |
|
364 | - */ |
|
365 | - public function setSubmitBtnText($submit_btn_text) |
|
366 | - { |
|
367 | - if (! is_string($submit_btn_text)) { |
|
368 | - throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string'); |
|
369 | - } |
|
370 | - if (empty($submit_btn_text)) { |
|
371 | - throw new InvalidArgumentException( |
|
372 | - esc_html__('Can not set Submit button text because an empty string was provided.', 'event_espresso') |
|
373 | - ); |
|
374 | - } |
|
375 | - $this->submit_btn_text = $submit_btn_text; |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * @return string |
|
382 | - */ |
|
383 | - public function formAction() |
|
384 | - { |
|
385 | - return ! empty($this->form_args) |
|
386 | - ? add_query_arg($this->form_args, $this->form_action) |
|
387 | - : $this->form_action; |
|
388 | - } |
|
389 | - |
|
390 | - |
|
391 | - |
|
392 | - /** |
|
393 | - * @param string $form_action |
|
394 | - * @throws InvalidDataTypeException |
|
395 | - */ |
|
396 | - public function setFormAction($form_action) |
|
397 | - { |
|
398 | - if (! is_string($form_action)) { |
|
399 | - throw new InvalidDataTypeException('$form_action', $form_action, 'string'); |
|
400 | - } |
|
401 | - $this->form_action = $form_action; |
|
402 | - } |
|
403 | - |
|
404 | - |
|
405 | - |
|
406 | - /** |
|
407 | - * @param array $form_args |
|
408 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
409 | - * @throws \InvalidArgumentException |
|
410 | - */ |
|
411 | - public function addFormActionArgs($form_args = array()) |
|
412 | - { |
|
413 | - if (is_object($form_args)) { |
|
414 | - throw new InvalidDataTypeException( |
|
415 | - '$form_args', |
|
416 | - $form_args, |
|
417 | - 'anything other than an object was expected.' |
|
418 | - ); |
|
419 | - } |
|
420 | - if (empty($form_args)) { |
|
421 | - throw new InvalidArgumentException( |
|
422 | - esc_html__('The redirect arguments can not be an empty array.', 'event_espresso') |
|
423 | - ); |
|
424 | - } |
|
425 | - $this->form_args = array_merge($this->form_args, $form_args); |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * @return string |
|
432 | - */ |
|
433 | - public function formConfig() |
|
434 | - { |
|
435 | - return $this->form_config; |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * @param string $form_config |
|
442 | - * @throws DomainException |
|
443 | - */ |
|
444 | - public function setFormConfig($form_config) |
|
445 | - { |
|
446 | - if ( |
|
447 | - ! in_array( |
|
448 | - $form_config, |
|
449 | - array( |
|
450 | - FormHandler::ADD_FORM_TAGS_AND_SUBMIT, |
|
451 | - FormHandler::ADD_FORM_TAGS_ONLY, |
|
452 | - FormHandler::ADD_FORM_SUBMIT_ONLY, |
|
453 | - FormHandler::DO_NOT_SETUP_FORM, |
|
454 | - ), |
|
455 | - true |
|
456 | - ) |
|
457 | - ) { |
|
458 | - throw new DomainException( |
|
459 | - sprintf( |
|
460 | - esc_html__('"%1$s" is not a valid value for the form config. Please use one of the class constants on \EventEspresso\core\libraries\form_sections\form_handlers\Form', |
|
461 | - 'event_espresso'), |
|
462 | - $form_config |
|
463 | - ) |
|
464 | - ); |
|
465 | - } |
|
466 | - $this->form_config = $form_config; |
|
467 | - } |
|
468 | - |
|
469 | - |
|
470 | - |
|
471 | - /** |
|
472 | - * called after the form is instantiated |
|
473 | - * and used for performing any logic that needs to occur early |
|
474 | - * before any of the other methods are called. |
|
475 | - * returns true if everything is ok to proceed, |
|
476 | - * and false if no further form logic should be implemented |
|
477 | - * |
|
478 | - * @return boolean |
|
479 | - */ |
|
480 | - public function initialize() |
|
481 | - { |
|
482 | - $this->form_has_errors = \EE_Error::has_error(true); |
|
483 | - return true; |
|
484 | - } |
|
485 | - |
|
486 | - |
|
487 | - |
|
488 | - /** |
|
489 | - * used for setting up css and js |
|
490 | - * |
|
491 | - * @return void |
|
492 | - * @throws LogicException |
|
493 | - * @throws \EE_Error |
|
494 | - */ |
|
495 | - public function enqueueStylesAndScripts() |
|
496 | - { |
|
497 | - $this->form(false)->enqueue_js(); |
|
498 | - } |
|
499 | - |
|
500 | - |
|
501 | - |
|
502 | - /** |
|
503 | - * creates and returns the actual form |
|
504 | - * |
|
505 | - * @return EE_Form_Section_Proper |
|
506 | - */ |
|
507 | - abstract public function generate(); |
|
508 | - |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * creates and returns an EE_Submit_Input labeled "Submit" |
|
513 | - * |
|
514 | - * @param string $text |
|
515 | - * @return \EE_Submit_Input |
|
516 | - */ |
|
517 | - public function generateSubmitButton($text = '') |
|
518 | - { |
|
519 | - $text = ! empty($text) ? $text : $this->submitBtnText(); |
|
520 | - return new EE_Submit_Input( |
|
521 | - array( |
|
522 | - 'html_name' => 'ee-form-submit-' . $this->slug(), |
|
523 | - 'html_id' => 'ee-form-submit-' . $this->slug(), |
|
524 | - 'html_class' => 'ee-form-submit', |
|
525 | - 'html_label' => ' ', |
|
526 | - 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
527 | - 'default' => $text, |
|
528 | - ) |
|
529 | - ); |
|
530 | - } |
|
531 | - |
|
532 | - |
|
533 | - |
|
534 | - /** |
|
535 | - * calls generateSubmitButton() and appends it onto the form along with a float clearing div |
|
536 | - * |
|
537 | - * @param string $text |
|
538 | - * @return void |
|
539 | - * @throws \LogicException |
|
540 | - * @throws \EE_Error |
|
541 | - */ |
|
542 | - public function appendSubmitButton($text = '') |
|
543 | - { |
|
544 | - if ($this->form->subsection_exists($this->slug() . '-submit-btn')) { |
|
545 | - return; |
|
546 | - } |
|
547 | - $this->form->add_subsections( |
|
548 | - array($this->slug() . '-submit-btn' => $this->generateSubmitButton($text)), |
|
549 | - null, |
|
550 | - false |
|
551 | - ); |
|
552 | - } |
|
553 | - |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * creates and returns an EE_Submit_Input labeled "Cancel" |
|
558 | - * |
|
559 | - * @param string $text |
|
560 | - * @return \EE_Submit_Input |
|
561 | - */ |
|
562 | - public function generateCancelButton($text = '') |
|
563 | - { |
|
564 | - $cancel_button = new EE_Submit_Input( |
|
565 | - array( |
|
566 | - 'html_name' => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!! |
|
567 | - 'html_id' => 'ee-cancel-form-' . $this->slug(), |
|
568 | - 'html_class' => 'ee-cancel-form', |
|
569 | - 'html_label' => ' ', |
|
570 | - 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
571 | - 'default' => ! empty($text) ? $text : esc_html__('Cancel', 'event_espresso'), |
|
572 | - ) |
|
573 | - ); |
|
574 | - $cancel_button->set_button_css_attributes(false); |
|
575 | - return $cancel_button; |
|
576 | - } |
|
577 | - |
|
578 | - |
|
579 | - |
|
580 | - /** |
|
581 | - * appends a float clearing div onto end of form |
|
582 | - * |
|
583 | - * @return void |
|
584 | - * @throws \EE_Error |
|
585 | - */ |
|
586 | - public function clearFormButtonFloats() |
|
587 | - { |
|
588 | - $this->form->add_subsections( |
|
589 | - array( |
|
590 | - 'clear-submit-btn-float' => new \EE_Form_Section_HTML( |
|
591 | - EEH_HTML::div('', '', 'clear-float') . EEH_HTML::divx() |
|
592 | - ), |
|
593 | - ), |
|
594 | - null, |
|
595 | - false |
|
596 | - ); |
|
597 | - } |
|
598 | - |
|
599 | - |
|
600 | - |
|
601 | - /** |
|
602 | - * takes the generated form and displays it along with ony other non-form HTML that may be required |
|
603 | - * returns a string of HTML that can be directly echoed in a template |
|
604 | - * |
|
605 | - * @return string |
|
606 | - * @throws LogicException |
|
607 | - * @throws \EE_Error |
|
608 | - */ |
|
609 | - public function display() |
|
610 | - { |
|
611 | - $form_html = apply_filters( |
|
612 | - 'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__before_form', |
|
613 | - '' |
|
614 | - ); |
|
615 | - $form_config = $this->formConfig(); |
|
616 | - if ( |
|
617 | - $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT |
|
618 | - || $form_config === FormHandler::ADD_FORM_TAGS_ONLY |
|
619 | - ) { |
|
620 | - $form_html .= $this->form()->form_open($this->formAction()); |
|
621 | - } |
|
622 | - $form_html .= $this->form(true)->get_html($this->form_has_errors); |
|
623 | - if ( |
|
624 | - $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT |
|
625 | - || $form_config === FormHandler::ADD_FORM_TAGS_ONLY |
|
626 | - ) { |
|
627 | - $form_html .= $this->form()->form_close(); |
|
628 | - } |
|
629 | - $form_html .= apply_filters( |
|
630 | - 'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__after_form', |
|
631 | - '' |
|
632 | - ); |
|
633 | - return $form_html; |
|
634 | - } |
|
635 | - |
|
636 | - |
|
637 | - |
|
638 | - /** |
|
639 | - * handles processing the form submission |
|
640 | - * returns true or false depending on whether the form was processed successfully or not |
|
641 | - * |
|
642 | - * @param array $submitted_form_data |
|
643 | - * @return array |
|
644 | - * @throws \EE_Error |
|
645 | - * @throws \LogicException |
|
646 | - * @throws InvalidFormSubmissionException |
|
647 | - */ |
|
648 | - public function process($submitted_form_data = array()) |
|
649 | - { |
|
650 | - if (! $this->form()->was_submitted($submitted_form_data)) { |
|
651 | - throw new InvalidFormSubmissionException($this->form_name); |
|
652 | - } |
|
653 | - $this->form(true)->receive_form_submission($submitted_form_data); |
|
654 | - if (! $this->form()->is_valid()) { |
|
655 | - throw new InvalidFormSubmissionException( |
|
656 | - $this->form_name, |
|
657 | - sprintf( |
|
658 | - esc_html__( |
|
659 | - 'The "%1$s" form is invalid. Please correct the following errors and resubmit: %2$s %3$s', |
|
660 | - 'event_espresso' |
|
661 | - ), |
|
662 | - $this->form_name, |
|
663 | - '<br />', |
|
664 | - $this->form()->submission_error_message() |
|
665 | - ) |
|
666 | - ); |
|
667 | - } |
|
668 | - return $this->form()->valid_data(); |
|
669 | - } |
|
34 | + /** |
|
35 | + * will add opening and closing HTML form tags as well as a submit button |
|
36 | + */ |
|
37 | + const ADD_FORM_TAGS_AND_SUBMIT = 'add_form_tags_and_submit'; |
|
38 | + |
|
39 | + /** |
|
40 | + * will add opening and closing HTML form tags but NOT a submit button |
|
41 | + */ |
|
42 | + const ADD_FORM_TAGS_ONLY = 'add_form_tags_only'; |
|
43 | + |
|
44 | + /** |
|
45 | + * will NOT add opening and closing HTML form tags but will add a submit button |
|
46 | + */ |
|
47 | + const ADD_FORM_SUBMIT_ONLY = 'add_form_submit_only'; |
|
48 | + |
|
49 | + /** |
|
50 | + * will NOT add opening and closing HTML form tags NOR a submit button |
|
51 | + */ |
|
52 | + const DO_NOT_SETUP_FORM = 'do_not_setup_form'; |
|
53 | + |
|
54 | + /** |
|
55 | + * if set to false, then this form has no displayable content, |
|
56 | + * and will only be used for processing data sent passed via GET or POST |
|
57 | + * defaults to true ( ie: form has displayable content ) |
|
58 | + * |
|
59 | + * @var boolean $displayable |
|
60 | + */ |
|
61 | + private $displayable = true; |
|
62 | + |
|
63 | + /** |
|
64 | + * @var string $form_name |
|
65 | + */ |
|
66 | + private $form_name; |
|
67 | + |
|
68 | + /** |
|
69 | + * @var string $admin_name |
|
70 | + */ |
|
71 | + private $admin_name; |
|
72 | + |
|
73 | + /** |
|
74 | + * @var string $slug |
|
75 | + */ |
|
76 | + private $slug; |
|
77 | + |
|
78 | + /** |
|
79 | + * @var string $submit_btn_text |
|
80 | + */ |
|
81 | + private $submit_btn_text; |
|
82 | + |
|
83 | + /** |
|
84 | + * @var string $form_action |
|
85 | + */ |
|
86 | + private $form_action; |
|
87 | + |
|
88 | + /** |
|
89 | + * form params in key value pairs |
|
90 | + * can be added to form action URL or as hidden inputs |
|
91 | + * |
|
92 | + * @var array $form_args |
|
93 | + */ |
|
94 | + private $form_args = array(); |
|
95 | + |
|
96 | + /** |
|
97 | + * value of one of the string constant above |
|
98 | + * |
|
99 | + * @var string $form_config |
|
100 | + */ |
|
101 | + private $form_config; |
|
102 | + |
|
103 | + /** |
|
104 | + * whether or not the form was determined to be invalid |
|
105 | + * |
|
106 | + * @var boolean $form_has_errors |
|
107 | + */ |
|
108 | + private $form_has_errors; |
|
109 | + |
|
110 | + /** |
|
111 | + * the absolute top level form section being used on the page |
|
112 | + * |
|
113 | + * @var \EE_Form_Section_Proper $form |
|
114 | + */ |
|
115 | + private $form; |
|
116 | + |
|
117 | + /** |
|
118 | + * @var \EE_Registry $registry |
|
119 | + */ |
|
120 | + protected $registry; |
|
121 | + |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * Form constructor. |
|
126 | + * |
|
127 | + * @param string $form_name |
|
128 | + * @param string $admin_name |
|
129 | + * @param string $slug |
|
130 | + * @param string $form_action |
|
131 | + * @param string $form_config |
|
132 | + * @param \EE_Registry $registry |
|
133 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
134 | + * @throws \DomainException |
|
135 | + * @throws \InvalidArgumentException |
|
136 | + */ |
|
137 | + public function __construct( |
|
138 | + $form_name, |
|
139 | + $admin_name, |
|
140 | + $slug, |
|
141 | + $form_action = '', |
|
142 | + $form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT, |
|
143 | + \EE_Registry $registry |
|
144 | + ) { |
|
145 | + $this->setFormName($form_name); |
|
146 | + $this->setAdminName($admin_name); |
|
147 | + $this->setSlug($slug); |
|
148 | + $this->setFormAction($form_action); |
|
149 | + $this->setFormConfig($form_config); |
|
150 | + $this->setSubmitBtnText(esc_html__('Submit', 'event_espresso')); |
|
151 | + $this->registry = $registry; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @return array |
|
158 | + */ |
|
159 | + public static function getFormConfigConstants() |
|
160 | + { |
|
161 | + return array( |
|
162 | + FormHandler::ADD_FORM_TAGS_AND_SUBMIT, |
|
163 | + FormHandler::ADD_FORM_TAGS_ONLY, |
|
164 | + FormHandler::ADD_FORM_SUBMIT_ONLY, |
|
165 | + FormHandler::DO_NOT_SETUP_FORM, |
|
166 | + ); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param bool $for_display |
|
173 | + * @return \EE_Form_Section_Proper |
|
174 | + * @throws \EE_Error |
|
175 | + * @throws \LogicException |
|
176 | + */ |
|
177 | + public function form($for_display = false) |
|
178 | + { |
|
179 | + if (! $this->formIsValid()) { |
|
180 | + return null; |
|
181 | + } |
|
182 | + if ($for_display) { |
|
183 | + $form_config = $this->formConfig(); |
|
184 | + if ( |
|
185 | + $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT |
|
186 | + || $form_config === FormHandler::ADD_FORM_SUBMIT_ONLY |
|
187 | + ) { |
|
188 | + $this->appendSubmitButton(); |
|
189 | + $this->clearFormButtonFloats(); |
|
190 | + } |
|
191 | + } |
|
192 | + return $this->form; |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * @return boolean |
|
199 | + * @throws LogicException |
|
200 | + */ |
|
201 | + public function formIsValid() |
|
202 | + { |
|
203 | + if (! $this->form instanceof \EE_Form_Section_Proper) { |
|
204 | + static $generated = false; |
|
205 | + if (! $generated) { |
|
206 | + $generated = true; |
|
207 | + $form = apply_filters( |
|
208 | + 'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__formIsValid__generated_form_object', |
|
209 | + $this->generate(), |
|
210 | + $this |
|
211 | + ); |
|
212 | + if ($form instanceof \EE_Form_Section_Proper) { |
|
213 | + $this->setForm($form); |
|
214 | + } |
|
215 | + } |
|
216 | + return $this->verifyForm(); |
|
217 | + } |
|
218 | + return true; |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * @return boolean |
|
225 | + * @throws LogicException |
|
226 | + */ |
|
227 | + public function verifyForm() |
|
228 | + { |
|
229 | + if ($this->form instanceof \EE_Form_Section_Proper) { |
|
230 | + return true; |
|
231 | + } |
|
232 | + throw new LogicException( |
|
233 | + sprintf( |
|
234 | + esc_html__('The "%1$s" form is invalid or missing', 'event_espresso'), |
|
235 | + $this->form_name |
|
236 | + ) |
|
237 | + ); |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * @param \EE_Form_Section_Proper $form |
|
244 | + */ |
|
245 | + public function setForm(\EE_Form_Section_Proper $form) |
|
246 | + { |
|
247 | + $this->form = $form; |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * @return boolean |
|
254 | + */ |
|
255 | + public function displayable() |
|
256 | + { |
|
257 | + return $this->displayable; |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * @param boolean $displayable |
|
264 | + */ |
|
265 | + public function setDisplayable($displayable = false) |
|
266 | + { |
|
267 | + $this->displayable = filter_var($displayable, FILTER_VALIDATE_BOOLEAN); |
|
268 | + } |
|
269 | + |
|
270 | + |
|
271 | + |
|
272 | + /** |
|
273 | + * a public name for the form that can be displayed on the frontend of a site |
|
274 | + * |
|
275 | + * @return string |
|
276 | + */ |
|
277 | + public function formName() |
|
278 | + { |
|
279 | + return $this->form_name; |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + |
|
284 | + /** |
|
285 | + * @param string $form_name |
|
286 | + * @throws InvalidDataTypeException |
|
287 | + */ |
|
288 | + public function setFormName($form_name) |
|
289 | + { |
|
290 | + if (! is_string($form_name)) { |
|
291 | + throw new InvalidDataTypeException('$form_name', $form_name, 'string'); |
|
292 | + } |
|
293 | + $this->form_name = $form_name; |
|
294 | + } |
|
295 | + |
|
296 | + |
|
297 | + |
|
298 | + /** |
|
299 | + * a public name for the form that can be displayed, but only in the admin |
|
300 | + * |
|
301 | + * @return string |
|
302 | + */ |
|
303 | + public function adminName() |
|
304 | + { |
|
305 | + return $this->admin_name; |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * @param string $admin_name |
|
312 | + * @throws InvalidDataTypeException |
|
313 | + */ |
|
314 | + public function setAdminName($admin_name) |
|
315 | + { |
|
316 | + if (! is_string($admin_name)) { |
|
317 | + throw new InvalidDataTypeException('$admin_name', $admin_name, 'string'); |
|
318 | + } |
|
319 | + $this->admin_name = $admin_name; |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * a URL friendly string that can be used for identifying the form |
|
326 | + * |
|
327 | + * @return string |
|
328 | + */ |
|
329 | + public function slug() |
|
330 | + { |
|
331 | + return $this->slug; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * @param string $slug |
|
338 | + * @throws InvalidDataTypeException |
|
339 | + */ |
|
340 | + public function setSlug($slug) |
|
341 | + { |
|
342 | + if (! is_string($slug)) { |
|
343 | + throw new InvalidDataTypeException('$slug', $slug, 'string'); |
|
344 | + } |
|
345 | + $this->slug = $slug; |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * @return string |
|
352 | + */ |
|
353 | + public function submitBtnText() |
|
354 | + { |
|
355 | + return $this->submit_btn_text; |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * @param string $submit_btn_text |
|
362 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
363 | + * @throws \InvalidArgumentException |
|
364 | + */ |
|
365 | + public function setSubmitBtnText($submit_btn_text) |
|
366 | + { |
|
367 | + if (! is_string($submit_btn_text)) { |
|
368 | + throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string'); |
|
369 | + } |
|
370 | + if (empty($submit_btn_text)) { |
|
371 | + throw new InvalidArgumentException( |
|
372 | + esc_html__('Can not set Submit button text because an empty string was provided.', 'event_espresso') |
|
373 | + ); |
|
374 | + } |
|
375 | + $this->submit_btn_text = $submit_btn_text; |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * @return string |
|
382 | + */ |
|
383 | + public function formAction() |
|
384 | + { |
|
385 | + return ! empty($this->form_args) |
|
386 | + ? add_query_arg($this->form_args, $this->form_action) |
|
387 | + : $this->form_action; |
|
388 | + } |
|
389 | + |
|
390 | + |
|
391 | + |
|
392 | + /** |
|
393 | + * @param string $form_action |
|
394 | + * @throws InvalidDataTypeException |
|
395 | + */ |
|
396 | + public function setFormAction($form_action) |
|
397 | + { |
|
398 | + if (! is_string($form_action)) { |
|
399 | + throw new InvalidDataTypeException('$form_action', $form_action, 'string'); |
|
400 | + } |
|
401 | + $this->form_action = $form_action; |
|
402 | + } |
|
403 | + |
|
404 | + |
|
405 | + |
|
406 | + /** |
|
407 | + * @param array $form_args |
|
408 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
409 | + * @throws \InvalidArgumentException |
|
410 | + */ |
|
411 | + public function addFormActionArgs($form_args = array()) |
|
412 | + { |
|
413 | + if (is_object($form_args)) { |
|
414 | + throw new InvalidDataTypeException( |
|
415 | + '$form_args', |
|
416 | + $form_args, |
|
417 | + 'anything other than an object was expected.' |
|
418 | + ); |
|
419 | + } |
|
420 | + if (empty($form_args)) { |
|
421 | + throw new InvalidArgumentException( |
|
422 | + esc_html__('The redirect arguments can not be an empty array.', 'event_espresso') |
|
423 | + ); |
|
424 | + } |
|
425 | + $this->form_args = array_merge($this->form_args, $form_args); |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * @return string |
|
432 | + */ |
|
433 | + public function formConfig() |
|
434 | + { |
|
435 | + return $this->form_config; |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * @param string $form_config |
|
442 | + * @throws DomainException |
|
443 | + */ |
|
444 | + public function setFormConfig($form_config) |
|
445 | + { |
|
446 | + if ( |
|
447 | + ! in_array( |
|
448 | + $form_config, |
|
449 | + array( |
|
450 | + FormHandler::ADD_FORM_TAGS_AND_SUBMIT, |
|
451 | + FormHandler::ADD_FORM_TAGS_ONLY, |
|
452 | + FormHandler::ADD_FORM_SUBMIT_ONLY, |
|
453 | + FormHandler::DO_NOT_SETUP_FORM, |
|
454 | + ), |
|
455 | + true |
|
456 | + ) |
|
457 | + ) { |
|
458 | + throw new DomainException( |
|
459 | + sprintf( |
|
460 | + esc_html__('"%1$s" is not a valid value for the form config. Please use one of the class constants on \EventEspresso\core\libraries\form_sections\form_handlers\Form', |
|
461 | + 'event_espresso'), |
|
462 | + $form_config |
|
463 | + ) |
|
464 | + ); |
|
465 | + } |
|
466 | + $this->form_config = $form_config; |
|
467 | + } |
|
468 | + |
|
469 | + |
|
470 | + |
|
471 | + /** |
|
472 | + * called after the form is instantiated |
|
473 | + * and used for performing any logic that needs to occur early |
|
474 | + * before any of the other methods are called. |
|
475 | + * returns true if everything is ok to proceed, |
|
476 | + * and false if no further form logic should be implemented |
|
477 | + * |
|
478 | + * @return boolean |
|
479 | + */ |
|
480 | + public function initialize() |
|
481 | + { |
|
482 | + $this->form_has_errors = \EE_Error::has_error(true); |
|
483 | + return true; |
|
484 | + } |
|
485 | + |
|
486 | + |
|
487 | + |
|
488 | + /** |
|
489 | + * used for setting up css and js |
|
490 | + * |
|
491 | + * @return void |
|
492 | + * @throws LogicException |
|
493 | + * @throws \EE_Error |
|
494 | + */ |
|
495 | + public function enqueueStylesAndScripts() |
|
496 | + { |
|
497 | + $this->form(false)->enqueue_js(); |
|
498 | + } |
|
499 | + |
|
500 | + |
|
501 | + |
|
502 | + /** |
|
503 | + * creates and returns the actual form |
|
504 | + * |
|
505 | + * @return EE_Form_Section_Proper |
|
506 | + */ |
|
507 | + abstract public function generate(); |
|
508 | + |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * creates and returns an EE_Submit_Input labeled "Submit" |
|
513 | + * |
|
514 | + * @param string $text |
|
515 | + * @return \EE_Submit_Input |
|
516 | + */ |
|
517 | + public function generateSubmitButton($text = '') |
|
518 | + { |
|
519 | + $text = ! empty($text) ? $text : $this->submitBtnText(); |
|
520 | + return new EE_Submit_Input( |
|
521 | + array( |
|
522 | + 'html_name' => 'ee-form-submit-' . $this->slug(), |
|
523 | + 'html_id' => 'ee-form-submit-' . $this->slug(), |
|
524 | + 'html_class' => 'ee-form-submit', |
|
525 | + 'html_label' => ' ', |
|
526 | + 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
527 | + 'default' => $text, |
|
528 | + ) |
|
529 | + ); |
|
530 | + } |
|
531 | + |
|
532 | + |
|
533 | + |
|
534 | + /** |
|
535 | + * calls generateSubmitButton() and appends it onto the form along with a float clearing div |
|
536 | + * |
|
537 | + * @param string $text |
|
538 | + * @return void |
|
539 | + * @throws \LogicException |
|
540 | + * @throws \EE_Error |
|
541 | + */ |
|
542 | + public function appendSubmitButton($text = '') |
|
543 | + { |
|
544 | + if ($this->form->subsection_exists($this->slug() . '-submit-btn')) { |
|
545 | + return; |
|
546 | + } |
|
547 | + $this->form->add_subsections( |
|
548 | + array($this->slug() . '-submit-btn' => $this->generateSubmitButton($text)), |
|
549 | + null, |
|
550 | + false |
|
551 | + ); |
|
552 | + } |
|
553 | + |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * creates and returns an EE_Submit_Input labeled "Cancel" |
|
558 | + * |
|
559 | + * @param string $text |
|
560 | + * @return \EE_Submit_Input |
|
561 | + */ |
|
562 | + public function generateCancelButton($text = '') |
|
563 | + { |
|
564 | + $cancel_button = new EE_Submit_Input( |
|
565 | + array( |
|
566 | + 'html_name' => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!! |
|
567 | + 'html_id' => 'ee-cancel-form-' . $this->slug(), |
|
568 | + 'html_class' => 'ee-cancel-form', |
|
569 | + 'html_label' => ' ', |
|
570 | + 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
571 | + 'default' => ! empty($text) ? $text : esc_html__('Cancel', 'event_espresso'), |
|
572 | + ) |
|
573 | + ); |
|
574 | + $cancel_button->set_button_css_attributes(false); |
|
575 | + return $cancel_button; |
|
576 | + } |
|
577 | + |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * appends a float clearing div onto end of form |
|
582 | + * |
|
583 | + * @return void |
|
584 | + * @throws \EE_Error |
|
585 | + */ |
|
586 | + public function clearFormButtonFloats() |
|
587 | + { |
|
588 | + $this->form->add_subsections( |
|
589 | + array( |
|
590 | + 'clear-submit-btn-float' => new \EE_Form_Section_HTML( |
|
591 | + EEH_HTML::div('', '', 'clear-float') . EEH_HTML::divx() |
|
592 | + ), |
|
593 | + ), |
|
594 | + null, |
|
595 | + false |
|
596 | + ); |
|
597 | + } |
|
598 | + |
|
599 | + |
|
600 | + |
|
601 | + /** |
|
602 | + * takes the generated form and displays it along with ony other non-form HTML that may be required |
|
603 | + * returns a string of HTML that can be directly echoed in a template |
|
604 | + * |
|
605 | + * @return string |
|
606 | + * @throws LogicException |
|
607 | + * @throws \EE_Error |
|
608 | + */ |
|
609 | + public function display() |
|
610 | + { |
|
611 | + $form_html = apply_filters( |
|
612 | + 'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__before_form', |
|
613 | + '' |
|
614 | + ); |
|
615 | + $form_config = $this->formConfig(); |
|
616 | + if ( |
|
617 | + $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT |
|
618 | + || $form_config === FormHandler::ADD_FORM_TAGS_ONLY |
|
619 | + ) { |
|
620 | + $form_html .= $this->form()->form_open($this->formAction()); |
|
621 | + } |
|
622 | + $form_html .= $this->form(true)->get_html($this->form_has_errors); |
|
623 | + if ( |
|
624 | + $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT |
|
625 | + || $form_config === FormHandler::ADD_FORM_TAGS_ONLY |
|
626 | + ) { |
|
627 | + $form_html .= $this->form()->form_close(); |
|
628 | + } |
|
629 | + $form_html .= apply_filters( |
|
630 | + 'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__after_form', |
|
631 | + '' |
|
632 | + ); |
|
633 | + return $form_html; |
|
634 | + } |
|
635 | + |
|
636 | + |
|
637 | + |
|
638 | + /** |
|
639 | + * handles processing the form submission |
|
640 | + * returns true or false depending on whether the form was processed successfully or not |
|
641 | + * |
|
642 | + * @param array $submitted_form_data |
|
643 | + * @return array |
|
644 | + * @throws \EE_Error |
|
645 | + * @throws \LogicException |
|
646 | + * @throws InvalidFormSubmissionException |
|
647 | + */ |
|
648 | + public function process($submitted_form_data = array()) |
|
649 | + { |
|
650 | + if (! $this->form()->was_submitted($submitted_form_data)) { |
|
651 | + throw new InvalidFormSubmissionException($this->form_name); |
|
652 | + } |
|
653 | + $this->form(true)->receive_form_submission($submitted_form_data); |
|
654 | + if (! $this->form()->is_valid()) { |
|
655 | + throw new InvalidFormSubmissionException( |
|
656 | + $this->form_name, |
|
657 | + sprintf( |
|
658 | + esc_html__( |
|
659 | + 'The "%1$s" form is invalid. Please correct the following errors and resubmit: %2$s %3$s', |
|
660 | + 'event_espresso' |
|
661 | + ), |
|
662 | + $this->form_name, |
|
663 | + '<br />', |
|
664 | + $this->form()->submission_error_message() |
|
665 | + ) |
|
666 | + ); |
|
667 | + } |
|
668 | + return $this->form()->valid_data(); |
|
669 | + } |
|
670 | 670 | |
671 | 671 | |
672 | 672 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
12 | 12 | use EventEspresso\core\exceptions\InvalidFormSubmissionException; |
13 | 13 | |
14 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
14 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
15 | 15 | exit('No direct script access allowed'); |
16 | 16 | } |
17 | 17 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function form($for_display = false) |
178 | 178 | { |
179 | - if (! $this->formIsValid()) { |
|
179 | + if ( ! $this->formIsValid()) { |
|
180 | 180 | return null; |
181 | 181 | } |
182 | 182 | if ($for_display) { |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function formIsValid() |
202 | 202 | { |
203 | - if (! $this->form instanceof \EE_Form_Section_Proper) { |
|
203 | + if ( ! $this->form instanceof \EE_Form_Section_Proper) { |
|
204 | 204 | static $generated = false; |
205 | - if (! $generated) { |
|
205 | + if ( ! $generated) { |
|
206 | 206 | $generated = true; |
207 | 207 | $form = apply_filters( |
208 | 208 | 'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__formIsValid__generated_form_object', |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public function setFormName($form_name) |
289 | 289 | { |
290 | - if (! is_string($form_name)) { |
|
290 | + if ( ! is_string($form_name)) { |
|
291 | 291 | throw new InvalidDataTypeException('$form_name', $form_name, 'string'); |
292 | 292 | } |
293 | 293 | $this->form_name = $form_name; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function setAdminName($admin_name) |
315 | 315 | { |
316 | - if (! is_string($admin_name)) { |
|
316 | + if ( ! is_string($admin_name)) { |
|
317 | 317 | throw new InvalidDataTypeException('$admin_name', $admin_name, 'string'); |
318 | 318 | } |
319 | 319 | $this->admin_name = $admin_name; |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | public function setSlug($slug) |
341 | 341 | { |
342 | - if (! is_string($slug)) { |
|
342 | + if ( ! is_string($slug)) { |
|
343 | 343 | throw new InvalidDataTypeException('$slug', $slug, 'string'); |
344 | 344 | } |
345 | 345 | $this->slug = $slug; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | public function setSubmitBtnText($submit_btn_text) |
366 | 366 | { |
367 | - if (! is_string($submit_btn_text)) { |
|
367 | + if ( ! is_string($submit_btn_text)) { |
|
368 | 368 | throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string'); |
369 | 369 | } |
370 | 370 | if (empty($submit_btn_text)) { |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function setFormAction($form_action) |
397 | 397 | { |
398 | - if (! is_string($form_action)) { |
|
398 | + if ( ! is_string($form_action)) { |
|
399 | 399 | throw new InvalidDataTypeException('$form_action', $form_action, 'string'); |
400 | 400 | } |
401 | 401 | $this->form_action = $form_action; |
@@ -519,11 +519,11 @@ discard block |
||
519 | 519 | $text = ! empty($text) ? $text : $this->submitBtnText(); |
520 | 520 | return new EE_Submit_Input( |
521 | 521 | array( |
522 | - 'html_name' => 'ee-form-submit-' . $this->slug(), |
|
523 | - 'html_id' => 'ee-form-submit-' . $this->slug(), |
|
522 | + 'html_name' => 'ee-form-submit-'.$this->slug(), |
|
523 | + 'html_id' => 'ee-form-submit-'.$this->slug(), |
|
524 | 524 | 'html_class' => 'ee-form-submit', |
525 | 525 | 'html_label' => ' ', |
526 | - 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
526 | + 'other_html_attributes' => ' rel="'.$this->slug().'"', |
|
527 | 527 | 'default' => $text, |
528 | 528 | ) |
529 | 529 | ); |
@@ -541,11 +541,11 @@ discard block |
||
541 | 541 | */ |
542 | 542 | public function appendSubmitButton($text = '') |
543 | 543 | { |
544 | - if ($this->form->subsection_exists($this->slug() . '-submit-btn')) { |
|
544 | + if ($this->form->subsection_exists($this->slug().'-submit-btn')) { |
|
545 | 545 | return; |
546 | 546 | } |
547 | 547 | $this->form->add_subsections( |
548 | - array($this->slug() . '-submit-btn' => $this->generateSubmitButton($text)), |
|
548 | + array($this->slug().'-submit-btn' => $this->generateSubmitButton($text)), |
|
549 | 549 | null, |
550 | 550 | false |
551 | 551 | ); |
@@ -563,11 +563,11 @@ discard block |
||
563 | 563 | { |
564 | 564 | $cancel_button = new EE_Submit_Input( |
565 | 565 | array( |
566 | - 'html_name' => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!! |
|
567 | - 'html_id' => 'ee-cancel-form-' . $this->slug(), |
|
566 | + 'html_name' => 'ee-form-submit-'.$this->slug(), // YES! Same name as submit !!! |
|
567 | + 'html_id' => 'ee-cancel-form-'.$this->slug(), |
|
568 | 568 | 'html_class' => 'ee-cancel-form', |
569 | 569 | 'html_label' => ' ', |
570 | - 'other_html_attributes' => ' rel="' . $this->slug() . '"', |
|
570 | + 'other_html_attributes' => ' rel="'.$this->slug().'"', |
|
571 | 571 | 'default' => ! empty($text) ? $text : esc_html__('Cancel', 'event_espresso'), |
572 | 572 | ) |
573 | 573 | ); |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | $this->form->add_subsections( |
589 | 589 | array( |
590 | 590 | 'clear-submit-btn-float' => new \EE_Form_Section_HTML( |
591 | - EEH_HTML::div('', '', 'clear-float') . EEH_HTML::divx() |
|
591 | + EEH_HTML::div('', '', 'clear-float').EEH_HTML::divx() |
|
592 | 592 | ), |
593 | 593 | ), |
594 | 594 | null, |
@@ -647,11 +647,11 @@ discard block |
||
647 | 647 | */ |
648 | 648 | public function process($submitted_form_data = array()) |
649 | 649 | { |
650 | - if (! $this->form()->was_submitted($submitted_form_data)) { |
|
650 | + if ( ! $this->form()->was_submitted($submitted_form_data)) { |
|
651 | 651 | throw new InvalidFormSubmissionException($this->form_name); |
652 | 652 | } |
653 | 653 | $this->form(true)->receive_form_submission($submitted_form_data); |
654 | - if (! $this->form()->is_valid()) { |
|
654 | + if ( ! $this->form()->is_valid()) { |
|
655 | 655 | throw new InvalidFormSubmissionException( |
656 | 656 | $this->form_name, |
657 | 657 | sprintf( |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | if (! class_exists('WP_List_Table')) { |
6 | - require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); |
|
6 | + require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | |
@@ -22,782 +22,782 @@ discard block |
||
22 | 22 | abstract class EE_Admin_List_Table extends WP_List_Table |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * holds the data that will be processed for the table |
|
27 | - * |
|
28 | - * @var array $_data |
|
29 | - */ |
|
30 | - protected $_data; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * This holds the value of all the data available for the given view (for all pages). |
|
35 | - * |
|
36 | - * @var int $_all_data_count |
|
37 | - */ |
|
38 | - protected $_all_data_count; |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Will contain the count of trashed items for the view label. |
|
43 | - * |
|
44 | - * @var int $_trashed_count |
|
45 | - */ |
|
46 | - protected $_trashed_count; |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * This is what will be referenced as the slug for the current screen |
|
51 | - * |
|
52 | - * @var string $_screen |
|
53 | - */ |
|
54 | - protected $_screen; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * this is the EE_Admin_Page object |
|
59 | - * |
|
60 | - * @var EE_Admin_Page $_admin_page |
|
61 | - */ |
|
62 | - protected $_admin_page; |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * The current view |
|
67 | - * |
|
68 | - * @var string $_view |
|
69 | - */ |
|
70 | - protected $_view; |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * array of possible views for this table |
|
75 | - * |
|
76 | - * @var array $_views |
|
77 | - */ |
|
78 | - protected $_views; |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * An array of key => value pairs containing information about the current table |
|
83 | - * array( |
|
84 | - * 'plural' => 'plural label', |
|
85 | - * 'singular' => 'singular label', |
|
86 | - * 'ajax' => false, //whether to use ajax or not |
|
87 | - * 'screen' => null, //string used to reference what screen this is |
|
88 | - * (WP_List_table converts to screen object) |
|
89 | - * ) |
|
90 | - * |
|
91 | - * @var array $_wp_list_args |
|
92 | - */ |
|
93 | - protected $_wp_list_args; |
|
94 | - |
|
95 | - /** |
|
96 | - * an array of column names |
|
97 | - * array( |
|
98 | - * 'internal-name' => 'Title' |
|
99 | - * ) |
|
100 | - * |
|
101 | - * @var array $_columns |
|
102 | - */ |
|
103 | - protected $_columns; |
|
104 | - |
|
105 | - /** |
|
106 | - * An array of sortable columns |
|
107 | - * array( |
|
108 | - * 'internal-name' => 'orderby' //or |
|
109 | - * 'internal-name' => array( 'orderby', true ) |
|
110 | - * ) |
|
111 | - * |
|
112 | - * @var array $_sortable_columns |
|
113 | - */ |
|
114 | - protected $_sortable_columns; |
|
115 | - |
|
116 | - /** |
|
117 | - * callback method used to perform AJAX row reordering |
|
118 | - * |
|
119 | - * @var string $_ajax_sorting_callback |
|
120 | - */ |
|
121 | - protected $_ajax_sorting_callback; |
|
122 | - |
|
123 | - /** |
|
124 | - * An array of hidden columns (if needed) |
|
125 | - * array('internal-name', 'internal-name') |
|
126 | - * |
|
127 | - * @var array $_hidden_columns |
|
128 | - */ |
|
129 | - protected $_hidden_columns; |
|
130 | - |
|
131 | - /** |
|
132 | - * holds the per_page value |
|
133 | - * |
|
134 | - * @var int $_per_page |
|
135 | - */ |
|
136 | - protected $_per_page; |
|
137 | - |
|
138 | - /** |
|
139 | - * holds what page number is currently being viewed |
|
140 | - * |
|
141 | - * @var int $_current_page |
|
142 | - */ |
|
143 | - protected $_current_page; |
|
144 | - |
|
145 | - /** |
|
146 | - * the reference string for the nonce_action |
|
147 | - * |
|
148 | - * @var string $_nonce_action_ref |
|
149 | - */ |
|
150 | - protected $_nonce_action_ref; |
|
151 | - |
|
152 | - /** |
|
153 | - * property to hold incoming request data (as set by the admin_page_core) |
|
154 | - * |
|
155 | - * @var array $_req_data |
|
156 | - */ |
|
157 | - protected $_req_data; |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * yes / no array for admin form fields |
|
162 | - * |
|
163 | - * @var array $_yes_no |
|
164 | - */ |
|
165 | - protected $_yes_no = array(); |
|
166 | - |
|
167 | - /** |
|
168 | - * Array describing buttons that should appear at the bottom of the page |
|
169 | - * Keys are strings that represent the button's function (specifically a key in _labels['buttons']), |
|
170 | - * and the values are another array with the following keys |
|
171 | - * array( |
|
172 | - * 'route' => 'page_route', |
|
173 | - * 'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button. |
|
174 | - * ) |
|
175 | - * |
|
176 | - * @var array $_bottom_buttons |
|
177 | - */ |
|
178 | - protected $_bottom_buttons = array(); |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * Used to indicate what should be the primary column for the list table. |
|
183 | - * If not present then falls back to what WP calculates |
|
184 | - * as the primary column. |
|
185 | - * |
|
186 | - * @type string $_primary_column |
|
187 | - */ |
|
188 | - protected $_primary_column = ''; |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * Used to indicate whether the table has a checkbox column or not. |
|
193 | - * |
|
194 | - * @type bool $_has_checkbox_column |
|
195 | - */ |
|
196 | - protected $_has_checkbox_column = false; |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table |
|
201 | - */ |
|
202 | - public function __construct(EE_Admin_Page $admin_page) |
|
203 | - { |
|
204 | - $this->_admin_page = $admin_page; |
|
205 | - $this->_req_data = $this->_admin_page->get_request_data(); |
|
206 | - $this->_view = $this->_admin_page->get_view(); |
|
207 | - $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
208 | - $this->_current_page = $this->get_pagenum(); |
|
209 | - $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view(); |
|
210 | - $this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
211 | - |
|
212 | - $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10); |
|
213 | - |
|
214 | - $this->_setup_data(); |
|
215 | - $this->_add_view_counts(); |
|
216 | - |
|
217 | - $this->_nonce_action_ref = $this->_view; |
|
218 | - |
|
219 | - $this->_set_properties(); |
|
220 | - |
|
221 | - //set primary column |
|
222 | - add_filter('list_table_primary_column', array($this, 'set_primary_column')); |
|
223 | - |
|
224 | - //set parent defaults |
|
225 | - parent::__construct($this->_wp_list_args); |
|
226 | - |
|
227 | - $this->prepare_items(); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * _setup_data |
|
233 | - * this method is used to setup the $_data, $_all_data_count, and _per_page properties |
|
234 | - * |
|
235 | - * @uses $this->_admin_page |
|
236 | - * @return void |
|
237 | - */ |
|
238 | - abstract protected function _setup_data(); |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * set the properties that this class needs to be able to execute wp_list_table properly |
|
243 | - * properties set: |
|
244 | - * _wp_list_args = what the arguments required for the parent _wp_list_table. |
|
245 | - * _columns = set the columns in an array. |
|
246 | - * _sortable_columns = columns that are sortable (array). |
|
247 | - * _hidden_columns = columns that are hidden (array) |
|
248 | - * _default_orderby = the default orderby for sorting. |
|
249 | - * |
|
250 | - * @abstract |
|
251 | - * @access protected |
|
252 | - * @return void |
|
253 | - */ |
|
254 | - abstract protected function _set_properties(); |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * _get_table_filters |
|
259 | - * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
260 | - * get's shown in the table. |
|
261 | - * |
|
262 | - * @abstract |
|
263 | - * @access protected |
|
264 | - * @return string |
|
265 | - */ |
|
266 | - abstract protected function _get_table_filters(); |
|
267 | - |
|
268 | - |
|
269 | - /** |
|
270 | - * this is a method that child class will do to add counts to the views array so when views are displayed the |
|
271 | - * counts of the views is accurate. |
|
272 | - * |
|
273 | - * @abstract |
|
274 | - * @access protected |
|
275 | - * @return void |
|
276 | - */ |
|
277 | - abstract protected function _add_view_counts(); |
|
278 | - |
|
279 | - |
|
280 | - /** |
|
281 | - * _get_hidden_fields |
|
282 | - * returns a html string of hidden fields so if any table filters are used the current view will be respected. |
|
283 | - * |
|
284 | - * @return string |
|
285 | - */ |
|
286 | - protected function _get_hidden_fields() |
|
287 | - { |
|
288 | - $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : ''; |
|
289 | - $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action; |
|
290 | - //if action is STILL empty, then we set it to default |
|
291 | - $action = empty($action) ? 'default' : $action; |
|
292 | - $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n"; |
|
293 | - $field .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/ |
|
294 | - $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n"; |
|
295 | - |
|
296 | - $bulk_actions = $this->_get_bulk_actions(); |
|
297 | - foreach ($bulk_actions as $bulk_action => $label) { |
|
298 | - $field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n"; |
|
299 | - } |
|
300 | - |
|
301 | - return $field; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * _set_column_info |
|
307 | - * we're using this to set the column headers property. |
|
308 | - * |
|
309 | - * @access protected |
|
310 | - * @return void |
|
311 | - */ |
|
312 | - protected function _set_column_info() |
|
313 | - { |
|
314 | - $columns = $this->get_columns(); |
|
315 | - $hidden = $this->get_hidden_columns(); |
|
316 | - $_sortable = $this->get_sortable_columns(); |
|
317 | - |
|
318 | - /** |
|
319 | - * Dynamic hook allowing for adding sortable columns in this list table. |
|
320 | - * Note that $this->screen->id is in the format |
|
321 | - * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
322 | - * table it is: event-espresso_page_espresso_messages. |
|
323 | - * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
324 | - * hook prefix ("event-espresso") will be different. |
|
325 | - * |
|
326 | - * @var array |
|
327 | - */ |
|
328 | - $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen); |
|
329 | - |
|
330 | - $sortable = array(); |
|
331 | - foreach ($_sortable as $id => $data) { |
|
332 | - if (empty($data)) { |
|
333 | - continue; |
|
334 | - } |
|
335 | - //fix for offset errors with WP_List_Table default get_columninfo() |
|
336 | - if (is_array($data)) { |
|
337 | - $_data[0] = key($data); |
|
338 | - $_data[1] = isset($data[1]) ? $data[1] : false; |
|
339 | - } else { |
|
340 | - $_data[0] = $data; |
|
341 | - } |
|
342 | - |
|
343 | - $data = (array)$data; |
|
344 | - |
|
345 | - if (! isset($data[1])) { |
|
346 | - $_data[1] = false; |
|
347 | - } |
|
348 | - |
|
349 | - $sortable[$id] = $_data; |
|
350 | - } |
|
351 | - $primary = $this->get_primary_column_name(); |
|
352 | - $this->_column_headers = array($columns, $hidden, $sortable, $primary); |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814) |
|
358 | - * |
|
359 | - * @return string |
|
360 | - */ |
|
361 | - protected function get_primary_column_name() |
|
362 | - { |
|
363 | - foreach (class_parents($this) as $parent) { |
|
364 | - if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) { |
|
365 | - return parent::get_primary_column_name(); |
|
366 | - } |
|
367 | - } |
|
368 | - return $this->_primary_column; |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814) |
|
374 | - * |
|
375 | - * @param EE_Base_Class $item |
|
376 | - * @param string $column_name |
|
377 | - * @param string $primary |
|
378 | - * @return string |
|
379 | - */ |
|
380 | - protected function handle_row_actions($item, $column_name, $primary) |
|
381 | - { |
|
382 | - foreach (class_parents($this) as $parent) { |
|
383 | - if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) { |
|
384 | - return parent::handle_row_actions($item, $column_name, $primary); |
|
385 | - } |
|
386 | - } |
|
387 | - return ''; |
|
388 | - } |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * _get_bulk_actions |
|
393 | - * This is a wrapper called by WP_List_Table::get_bulk_actions() |
|
394 | - * |
|
395 | - * @access protected |
|
396 | - * @return array bulk_actions |
|
397 | - */ |
|
398 | - protected function _get_bulk_actions() |
|
399 | - { |
|
400 | - $actions = array(); |
|
401 | - //the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table(); |
|
402 | - foreach ($this->_views as $view => $args) { |
|
403 | - if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) { |
|
404 | - //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user. |
|
405 | - foreach ($args['bulk_action'] as $route => $label) { |
|
406 | - if ($this->_admin_page->check_user_access($route, true)) { |
|
407 | - $actions[$route] = $label; |
|
408 | - } |
|
409 | - } |
|
410 | - } |
|
411 | - } |
|
412 | - return $actions; |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - /** |
|
417 | - * _filters |
|
418 | - * This receives the filters array from children _get_table_filters() and assembles the string including the filter |
|
419 | - * button. |
|
420 | - * |
|
421 | - * @access private |
|
422 | - * @return string html showing filters |
|
423 | - */ |
|
424 | - private function _filters() |
|
425 | - { |
|
426 | - $classname = get_class($this); |
|
427 | - $filters = apply_filters("FHEE__{$classname}__filters", (array)$this->_get_table_filters(), $this, |
|
428 | - $this->_screen); |
|
429 | - |
|
430 | - if (empty($filters)) { |
|
431 | - return; |
|
432 | - } |
|
433 | - foreach ($filters as $filter) { |
|
434 | - echo $filter; |
|
435 | - } |
|
436 | - //add filter button at end |
|
437 | - echo '<input type="submit" class="button-secondary" value="' . __('Filter', |
|
438 | - 'event_espresso') . '" id="post-query-submit" />'; |
|
439 | - //add reset filters button at end |
|
440 | - echo '<a class="button button-secondary" href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters', |
|
441 | - 'event_espresso') . '</a>'; |
|
442 | - } |
|
443 | - |
|
444 | - |
|
445 | - /** |
|
446 | - * Callback for 'list_table_primary_column' WordPress filter |
|
447 | - * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary |
|
448 | - * column when class is instantiated. |
|
449 | - * |
|
450 | - * @see WP_List_Table::get_primary_column_name |
|
451 | - * @param string $column_name |
|
452 | - * @return string |
|
453 | - */ |
|
454 | - public function set_primary_column($column_name) |
|
455 | - { |
|
456 | - return ! empty($this->_primary_column) ? $this->_primary_column : $column_name; |
|
457 | - } |
|
458 | - |
|
459 | - |
|
460 | - /** |
|
461 | - * |
|
462 | - */ |
|
463 | - public function prepare_items() |
|
464 | - { |
|
465 | - |
|
466 | - $this->_set_column_info(); |
|
467 | - //$this->_column_headers = $this->get_column_info(); |
|
468 | - $total_items = $this->_all_data_count; |
|
469 | - $this->process_bulk_action(); |
|
470 | - |
|
471 | - $this->items = $this->_data; |
|
472 | - $this->set_pagination_args( |
|
473 | - array( |
|
474 | - 'total_items' => $total_items, |
|
475 | - 'per_page' => $this->_per_page, |
|
476 | - 'total_pages' => ceil($total_items / $this->_per_page), |
|
477 | - ) |
|
478 | - ); |
|
479 | - } |
|
480 | - |
|
481 | - |
|
482 | - /** |
|
483 | - * This column is the default for when there is no defined column method for a registered column. |
|
484 | - * This can be overridden by child classes, but allows for hooking in for custom columns. |
|
485 | - * |
|
486 | - * @param EE_Base_Class $item |
|
487 | - * @param string $column_name The column being called. |
|
488 | - * @return string html content for the column |
|
489 | - */ |
|
490 | - public function column_default($item, $column_name) |
|
491 | - { |
|
492 | - /** |
|
493 | - * Dynamic hook allowing for adding additional column content in this list table. |
|
494 | - * Note that $this->screen->id is in the format |
|
495 | - * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
496 | - * table it is: event-espresso_page_espresso_messages. |
|
497 | - * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
498 | - * hook prefix ("event-espresso") will be different. |
|
499 | - */ |
|
500 | - do_action('AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item, |
|
501 | - $this->_screen); |
|
502 | - } |
|
503 | - |
|
504 | - |
|
505 | - /** |
|
506 | - * Get a list of columns. The format is: |
|
507 | - * 'internal-name' => 'Title' |
|
508 | - * |
|
509 | - * @since 3.1.0 |
|
510 | - * @access public |
|
511 | - * @abstract |
|
512 | - * @return array |
|
513 | - */ |
|
514 | - public function get_columns() |
|
515 | - { |
|
516 | - /** |
|
517 | - * Dynamic hook allowing for adding additional columns in this list table. |
|
518 | - * Note that $this->screen->id is in the format |
|
519 | - * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
520 | - * table it is: event-espresso_page_espresso_messages. |
|
521 | - * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
522 | - * hook prefix ("event-espresso") will be different. |
|
523 | - * |
|
524 | - * @var array |
|
525 | - */ |
|
526 | - $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen); |
|
527 | - return $columns; |
|
528 | - } |
|
529 | - |
|
530 | - |
|
531 | - /** |
|
532 | - * Get an associative array ( id => link ) with the list |
|
533 | - * of views available on this table. |
|
534 | - * |
|
535 | - * @since 3.1.0 |
|
536 | - * @access protected |
|
537 | - * @return array |
|
538 | - */ |
|
539 | - public function get_views() |
|
540 | - { |
|
541 | - return $this->_views; |
|
542 | - } |
|
543 | - |
|
544 | - public function display_views() |
|
545 | - { |
|
546 | - $views = $this->get_views(); |
|
547 | - $assembled_views = array(); |
|
548 | - |
|
549 | - if (empty($views)) { |
|
550 | - return; |
|
551 | - } |
|
552 | - echo "<ul class='subsubsub'>\n"; |
|
553 | - foreach ($views as $view) { |
|
554 | - $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0; |
|
555 | - if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) { |
|
556 | - $assembled_views[$view['slug']] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>'; |
|
557 | - } |
|
558 | - } |
|
559 | - |
|
560 | - echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : ''; |
|
561 | - echo "</ul>"; |
|
562 | - } |
|
563 | - |
|
564 | - |
|
565 | - /** |
|
566 | - * Generates content for a single row of the table |
|
567 | - * |
|
568 | - * @since 4.1 |
|
569 | - * @access public |
|
570 | - * @param EE_Base_Class $item The current item |
|
571 | - */ |
|
572 | - public function single_row($item) |
|
573 | - { |
|
574 | - $row_class = $this->_get_row_class($item); |
|
575 | - echo '<tr class="' . esc_attr($row_class) . '">'; |
|
576 | - $this->single_row_columns($item); |
|
577 | - echo '</tr>'; |
|
578 | - } |
|
579 | - |
|
580 | - |
|
581 | - /** |
|
582 | - * This simply sets up the row class for the table rows. |
|
583 | - * Allows for easier overriding of child methods for setting up sorting. |
|
584 | - * |
|
585 | - * @param EE_Base_Class $item the current item |
|
586 | - * @return string |
|
587 | - */ |
|
588 | - protected function _get_row_class($item) |
|
589 | - { |
|
590 | - static $row_class = ''; |
|
591 | - $row_class = ($row_class === '' ? 'alternate' : ''); |
|
592 | - |
|
593 | - $new_row_class = $row_class; |
|
594 | - |
|
595 | - if (! empty($this->_ajax_sorting_callback)) { |
|
596 | - $new_row_class .= ' rowsortable'; |
|
597 | - } |
|
598 | - |
|
599 | - return $new_row_class; |
|
600 | - } |
|
601 | - |
|
602 | - |
|
603 | - /** |
|
604 | - * @return array |
|
605 | - */ |
|
606 | - public function get_sortable_columns() |
|
607 | - { |
|
608 | - return (array)$this->_sortable_columns; |
|
609 | - } |
|
610 | - |
|
611 | - |
|
612 | - /** |
|
613 | - * @return string |
|
614 | - */ |
|
615 | - public function get_ajax_sorting_callback() |
|
616 | - { |
|
617 | - return $this->_ajax_sorting_callback; |
|
618 | - } |
|
619 | - |
|
620 | - |
|
621 | - /** |
|
622 | - * @return array |
|
623 | - */ |
|
624 | - public function get_hidden_columns() |
|
625 | - { |
|
626 | - $user_id = get_current_user_id(); |
|
627 | - $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id); |
|
628 | - if (empty($has_default) && ! empty($this->_hidden_columns)) { |
|
629 | - update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true); |
|
630 | - update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true); |
|
631 | - } |
|
632 | - $ref = 'manage' . $this->screen->id . 'columnshidden'; |
|
633 | - return (array)get_user_option($ref, $user_id); |
|
634 | - } |
|
635 | - |
|
636 | - |
|
637 | - /** |
|
638 | - * Generates the columns for a single row of the table. |
|
639 | - * Overridden from wp_list_table so as to allow us to filter the column content for a given |
|
640 | - * column. |
|
641 | - * |
|
642 | - * @since 3.1.0 |
|
643 | - * @param EE_Base_Class $item The current item |
|
644 | - */ |
|
645 | - public function single_row_columns($item) |
|
646 | - { |
|
647 | - list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
648 | - |
|
649 | - global $wp_version; |
|
650 | - $use_hidden_class = version_compare($wp_version, '4.3-RC', '>='); |
|
651 | - |
|
652 | - foreach ($columns as $column_name => $column_display_name) { |
|
653 | - |
|
654 | - /** |
|
655 | - * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are |
|
656 | - * hidden or not instead of using "display:none;". This bit of code provides backward compat. |
|
657 | - */ |
|
658 | - $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : ''; |
|
659 | - $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : ''; |
|
660 | - |
|
661 | - $classes = $column_name . ' column-' . $column_name . $hidden_class; |
|
662 | - if ($primary === $column_name) { |
|
663 | - $classes .= ' has-row-actions column-primary'; |
|
664 | - } |
|
665 | - |
|
666 | - $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"'; |
|
667 | - |
|
668 | - $class = "class='$classes'"; |
|
669 | - |
|
670 | - $attributes = "$class$style$data"; |
|
671 | - |
|
672 | - if ($column_name === 'cb') { |
|
673 | - echo '<th scope="row" class="check-column">'; |
|
674 | - echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', |
|
675 | - $this->column_cb($item), $item, $this); |
|
676 | - echo '</th>'; |
|
677 | - } elseif (method_exists($this, 'column_' . $column_name)) { |
|
678 | - echo "<td $attributes>"; |
|
679 | - echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', |
|
680 | - call_user_func(array($this, 'column_' . $column_name), $item), $item, $this); |
|
681 | - echo $this->handle_row_actions($item, $column_name, $primary); |
|
682 | - echo "</td>"; |
|
683 | - } else { |
|
684 | - echo "<td $attributes>"; |
|
685 | - echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', |
|
686 | - $this->column_default($item, $column_name), $item, $column_name, $this); |
|
687 | - echo $this->handle_row_actions($item, $column_name, $primary); |
|
688 | - echo "</td>"; |
|
689 | - } |
|
690 | - } |
|
691 | - } |
|
692 | - |
|
693 | - |
|
694 | - /** |
|
695 | - * Extra controls to be displayed between bulk actions and pagination |
|
696 | - * |
|
697 | - * @access public |
|
698 | - * @param string $which |
|
699 | - * @throws \EE_Error |
|
700 | - */ |
|
701 | - public function extra_tablenav($which) |
|
702 | - { |
|
703 | - if ($which === 'top') { |
|
704 | - $this->_filters(); |
|
705 | - echo $this->_get_hidden_fields(); |
|
706 | - } else { |
|
707 | - echo '<div class="list-table-bottom-buttons alignleft actions">'; |
|
708 | - foreach ($this->_bottom_buttons as $type => $action) { |
|
709 | - $route = isset($action['route']) ? $action['route'] : ''; |
|
710 | - $extra_request = isset($action['extra_request']) ? $action['extra_request'] : ''; |
|
711 | - echo $this->_admin_page->get_action_link_or_button( |
|
712 | - $route, |
|
713 | - $type, |
|
714 | - $extra_request, |
|
715 | - 'button button-secondary', |
|
716 | - '', |
|
717 | - false |
|
718 | - ); |
|
719 | - } |
|
720 | - do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen); |
|
721 | - echo '</div>'; |
|
722 | - } |
|
723 | - //echo $this->_entries_per_page_dropdown; |
|
724 | - } |
|
725 | - |
|
726 | - |
|
727 | - /** |
|
728 | - * Get an associative array ( option_name => option_title ) with the list |
|
729 | - * of bulk actions available on this table. |
|
730 | - * |
|
731 | - * @since 3.1.0 |
|
732 | - * @access protected |
|
733 | - * @return array |
|
734 | - */ |
|
735 | - public function get_bulk_actions() |
|
736 | - { |
|
737 | - return (array)$this->_get_bulk_actions(); |
|
738 | - } |
|
739 | - |
|
740 | - public function process_bulk_action() |
|
741 | - { |
|
742 | - //this is not used it is handled by the child EE_Admin_Page class (routes). However, including here for reference in case there is a case where it gets used. |
|
743 | - } |
|
744 | - |
|
745 | - |
|
746 | - /** |
|
747 | - * returns the EE admin page this list table is associated with |
|
748 | - * |
|
749 | - * @return EE_Admin_Page |
|
750 | - */ |
|
751 | - public function get_admin_page() |
|
752 | - { |
|
753 | - return $this->_admin_page; |
|
754 | - } |
|
755 | - |
|
756 | - |
|
757 | - /** |
|
758 | - * A "helper" function for all children to provide an html string of |
|
759 | - * actions to output in their content. It is preferable for child classes |
|
760 | - * to use this method for generating their actions content so that it's |
|
761 | - * filterable by plugins |
|
762 | - * |
|
763 | - * @param string $action_container what are the html container |
|
764 | - * elements for this actions string? |
|
765 | - * @param string $action_class What class is for the container |
|
766 | - * element. |
|
767 | - * @param string $action_items The contents for the action items |
|
768 | - * container. This is filtered before |
|
769 | - * returned. |
|
770 | - * @param string $action_id What id (optional) is used for the |
|
771 | - * container element. |
|
772 | - * @param EE_Base_Class $item The object for the column displaying |
|
773 | - * the actions. |
|
774 | - * @return string The assembled action elements container. |
|
775 | - */ |
|
776 | - protected function _action_string( |
|
777 | - $action_items, |
|
778 | - $item, |
|
779 | - $action_container = 'ul', |
|
780 | - $action_class = '', |
|
781 | - $action_id = '' |
|
782 | - ) { |
|
783 | - $content = ''; |
|
784 | - $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : ''; |
|
785 | - $action_id = ! empty($action_id) ? ' id="' . $action_id . '"' : ''; |
|
786 | - $content .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : ''; |
|
787 | - try { |
|
788 | - $content .= apply_filters( |
|
789 | - 'FHEE__EE_Admin_List_Table___action_string__action_items', |
|
790 | - $action_items, |
|
791 | - $item, |
|
792 | - $this |
|
793 | - ); |
|
794 | - } catch (\Exception $e) { |
|
795 | - if (WP_DEBUG) { |
|
796 | - \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
797 | - } |
|
798 | - $content .= $action_items; |
|
799 | - } |
|
800 | - $content .= ! empty($action_container) ? '</' . $action_container . '>' : ''; |
|
801 | - return $content; |
|
802 | - } |
|
25 | + /** |
|
26 | + * holds the data that will be processed for the table |
|
27 | + * |
|
28 | + * @var array $_data |
|
29 | + */ |
|
30 | + protected $_data; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * This holds the value of all the data available for the given view (for all pages). |
|
35 | + * |
|
36 | + * @var int $_all_data_count |
|
37 | + */ |
|
38 | + protected $_all_data_count; |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Will contain the count of trashed items for the view label. |
|
43 | + * |
|
44 | + * @var int $_trashed_count |
|
45 | + */ |
|
46 | + protected $_trashed_count; |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * This is what will be referenced as the slug for the current screen |
|
51 | + * |
|
52 | + * @var string $_screen |
|
53 | + */ |
|
54 | + protected $_screen; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * this is the EE_Admin_Page object |
|
59 | + * |
|
60 | + * @var EE_Admin_Page $_admin_page |
|
61 | + */ |
|
62 | + protected $_admin_page; |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * The current view |
|
67 | + * |
|
68 | + * @var string $_view |
|
69 | + */ |
|
70 | + protected $_view; |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * array of possible views for this table |
|
75 | + * |
|
76 | + * @var array $_views |
|
77 | + */ |
|
78 | + protected $_views; |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * An array of key => value pairs containing information about the current table |
|
83 | + * array( |
|
84 | + * 'plural' => 'plural label', |
|
85 | + * 'singular' => 'singular label', |
|
86 | + * 'ajax' => false, //whether to use ajax or not |
|
87 | + * 'screen' => null, //string used to reference what screen this is |
|
88 | + * (WP_List_table converts to screen object) |
|
89 | + * ) |
|
90 | + * |
|
91 | + * @var array $_wp_list_args |
|
92 | + */ |
|
93 | + protected $_wp_list_args; |
|
94 | + |
|
95 | + /** |
|
96 | + * an array of column names |
|
97 | + * array( |
|
98 | + * 'internal-name' => 'Title' |
|
99 | + * ) |
|
100 | + * |
|
101 | + * @var array $_columns |
|
102 | + */ |
|
103 | + protected $_columns; |
|
104 | + |
|
105 | + /** |
|
106 | + * An array of sortable columns |
|
107 | + * array( |
|
108 | + * 'internal-name' => 'orderby' //or |
|
109 | + * 'internal-name' => array( 'orderby', true ) |
|
110 | + * ) |
|
111 | + * |
|
112 | + * @var array $_sortable_columns |
|
113 | + */ |
|
114 | + protected $_sortable_columns; |
|
115 | + |
|
116 | + /** |
|
117 | + * callback method used to perform AJAX row reordering |
|
118 | + * |
|
119 | + * @var string $_ajax_sorting_callback |
|
120 | + */ |
|
121 | + protected $_ajax_sorting_callback; |
|
122 | + |
|
123 | + /** |
|
124 | + * An array of hidden columns (if needed) |
|
125 | + * array('internal-name', 'internal-name') |
|
126 | + * |
|
127 | + * @var array $_hidden_columns |
|
128 | + */ |
|
129 | + protected $_hidden_columns; |
|
130 | + |
|
131 | + /** |
|
132 | + * holds the per_page value |
|
133 | + * |
|
134 | + * @var int $_per_page |
|
135 | + */ |
|
136 | + protected $_per_page; |
|
137 | + |
|
138 | + /** |
|
139 | + * holds what page number is currently being viewed |
|
140 | + * |
|
141 | + * @var int $_current_page |
|
142 | + */ |
|
143 | + protected $_current_page; |
|
144 | + |
|
145 | + /** |
|
146 | + * the reference string for the nonce_action |
|
147 | + * |
|
148 | + * @var string $_nonce_action_ref |
|
149 | + */ |
|
150 | + protected $_nonce_action_ref; |
|
151 | + |
|
152 | + /** |
|
153 | + * property to hold incoming request data (as set by the admin_page_core) |
|
154 | + * |
|
155 | + * @var array $_req_data |
|
156 | + */ |
|
157 | + protected $_req_data; |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * yes / no array for admin form fields |
|
162 | + * |
|
163 | + * @var array $_yes_no |
|
164 | + */ |
|
165 | + protected $_yes_no = array(); |
|
166 | + |
|
167 | + /** |
|
168 | + * Array describing buttons that should appear at the bottom of the page |
|
169 | + * Keys are strings that represent the button's function (specifically a key in _labels['buttons']), |
|
170 | + * and the values are another array with the following keys |
|
171 | + * array( |
|
172 | + * 'route' => 'page_route', |
|
173 | + * 'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button. |
|
174 | + * ) |
|
175 | + * |
|
176 | + * @var array $_bottom_buttons |
|
177 | + */ |
|
178 | + protected $_bottom_buttons = array(); |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * Used to indicate what should be the primary column for the list table. |
|
183 | + * If not present then falls back to what WP calculates |
|
184 | + * as the primary column. |
|
185 | + * |
|
186 | + * @type string $_primary_column |
|
187 | + */ |
|
188 | + protected $_primary_column = ''; |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * Used to indicate whether the table has a checkbox column or not. |
|
193 | + * |
|
194 | + * @type bool $_has_checkbox_column |
|
195 | + */ |
|
196 | + protected $_has_checkbox_column = false; |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table |
|
201 | + */ |
|
202 | + public function __construct(EE_Admin_Page $admin_page) |
|
203 | + { |
|
204 | + $this->_admin_page = $admin_page; |
|
205 | + $this->_req_data = $this->_admin_page->get_request_data(); |
|
206 | + $this->_view = $this->_admin_page->get_view(); |
|
207 | + $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
208 | + $this->_current_page = $this->get_pagenum(); |
|
209 | + $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view(); |
|
210 | + $this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
211 | + |
|
212 | + $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10); |
|
213 | + |
|
214 | + $this->_setup_data(); |
|
215 | + $this->_add_view_counts(); |
|
216 | + |
|
217 | + $this->_nonce_action_ref = $this->_view; |
|
218 | + |
|
219 | + $this->_set_properties(); |
|
220 | + |
|
221 | + //set primary column |
|
222 | + add_filter('list_table_primary_column', array($this, 'set_primary_column')); |
|
223 | + |
|
224 | + //set parent defaults |
|
225 | + parent::__construct($this->_wp_list_args); |
|
226 | + |
|
227 | + $this->prepare_items(); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * _setup_data |
|
233 | + * this method is used to setup the $_data, $_all_data_count, and _per_page properties |
|
234 | + * |
|
235 | + * @uses $this->_admin_page |
|
236 | + * @return void |
|
237 | + */ |
|
238 | + abstract protected function _setup_data(); |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * set the properties that this class needs to be able to execute wp_list_table properly |
|
243 | + * properties set: |
|
244 | + * _wp_list_args = what the arguments required for the parent _wp_list_table. |
|
245 | + * _columns = set the columns in an array. |
|
246 | + * _sortable_columns = columns that are sortable (array). |
|
247 | + * _hidden_columns = columns that are hidden (array) |
|
248 | + * _default_orderby = the default orderby for sorting. |
|
249 | + * |
|
250 | + * @abstract |
|
251 | + * @access protected |
|
252 | + * @return void |
|
253 | + */ |
|
254 | + abstract protected function _set_properties(); |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * _get_table_filters |
|
259 | + * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
260 | + * get's shown in the table. |
|
261 | + * |
|
262 | + * @abstract |
|
263 | + * @access protected |
|
264 | + * @return string |
|
265 | + */ |
|
266 | + abstract protected function _get_table_filters(); |
|
267 | + |
|
268 | + |
|
269 | + /** |
|
270 | + * this is a method that child class will do to add counts to the views array so when views are displayed the |
|
271 | + * counts of the views is accurate. |
|
272 | + * |
|
273 | + * @abstract |
|
274 | + * @access protected |
|
275 | + * @return void |
|
276 | + */ |
|
277 | + abstract protected function _add_view_counts(); |
|
278 | + |
|
279 | + |
|
280 | + /** |
|
281 | + * _get_hidden_fields |
|
282 | + * returns a html string of hidden fields so if any table filters are used the current view will be respected. |
|
283 | + * |
|
284 | + * @return string |
|
285 | + */ |
|
286 | + protected function _get_hidden_fields() |
|
287 | + { |
|
288 | + $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : ''; |
|
289 | + $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action; |
|
290 | + //if action is STILL empty, then we set it to default |
|
291 | + $action = empty($action) ? 'default' : $action; |
|
292 | + $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n"; |
|
293 | + $field .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/ |
|
294 | + $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n"; |
|
295 | + |
|
296 | + $bulk_actions = $this->_get_bulk_actions(); |
|
297 | + foreach ($bulk_actions as $bulk_action => $label) { |
|
298 | + $field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n"; |
|
299 | + } |
|
300 | + |
|
301 | + return $field; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * _set_column_info |
|
307 | + * we're using this to set the column headers property. |
|
308 | + * |
|
309 | + * @access protected |
|
310 | + * @return void |
|
311 | + */ |
|
312 | + protected function _set_column_info() |
|
313 | + { |
|
314 | + $columns = $this->get_columns(); |
|
315 | + $hidden = $this->get_hidden_columns(); |
|
316 | + $_sortable = $this->get_sortable_columns(); |
|
317 | + |
|
318 | + /** |
|
319 | + * Dynamic hook allowing for adding sortable columns in this list table. |
|
320 | + * Note that $this->screen->id is in the format |
|
321 | + * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
322 | + * table it is: event-espresso_page_espresso_messages. |
|
323 | + * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
324 | + * hook prefix ("event-espresso") will be different. |
|
325 | + * |
|
326 | + * @var array |
|
327 | + */ |
|
328 | + $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen); |
|
329 | + |
|
330 | + $sortable = array(); |
|
331 | + foreach ($_sortable as $id => $data) { |
|
332 | + if (empty($data)) { |
|
333 | + continue; |
|
334 | + } |
|
335 | + //fix for offset errors with WP_List_Table default get_columninfo() |
|
336 | + if (is_array($data)) { |
|
337 | + $_data[0] = key($data); |
|
338 | + $_data[1] = isset($data[1]) ? $data[1] : false; |
|
339 | + } else { |
|
340 | + $_data[0] = $data; |
|
341 | + } |
|
342 | + |
|
343 | + $data = (array)$data; |
|
344 | + |
|
345 | + if (! isset($data[1])) { |
|
346 | + $_data[1] = false; |
|
347 | + } |
|
348 | + |
|
349 | + $sortable[$id] = $_data; |
|
350 | + } |
|
351 | + $primary = $this->get_primary_column_name(); |
|
352 | + $this->_column_headers = array($columns, $hidden, $sortable, $primary); |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814) |
|
358 | + * |
|
359 | + * @return string |
|
360 | + */ |
|
361 | + protected function get_primary_column_name() |
|
362 | + { |
|
363 | + foreach (class_parents($this) as $parent) { |
|
364 | + if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) { |
|
365 | + return parent::get_primary_column_name(); |
|
366 | + } |
|
367 | + } |
|
368 | + return $this->_primary_column; |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + /** |
|
373 | + * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814) |
|
374 | + * |
|
375 | + * @param EE_Base_Class $item |
|
376 | + * @param string $column_name |
|
377 | + * @param string $primary |
|
378 | + * @return string |
|
379 | + */ |
|
380 | + protected function handle_row_actions($item, $column_name, $primary) |
|
381 | + { |
|
382 | + foreach (class_parents($this) as $parent) { |
|
383 | + if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) { |
|
384 | + return parent::handle_row_actions($item, $column_name, $primary); |
|
385 | + } |
|
386 | + } |
|
387 | + return ''; |
|
388 | + } |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * _get_bulk_actions |
|
393 | + * This is a wrapper called by WP_List_Table::get_bulk_actions() |
|
394 | + * |
|
395 | + * @access protected |
|
396 | + * @return array bulk_actions |
|
397 | + */ |
|
398 | + protected function _get_bulk_actions() |
|
399 | + { |
|
400 | + $actions = array(); |
|
401 | + //the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table(); |
|
402 | + foreach ($this->_views as $view => $args) { |
|
403 | + if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) { |
|
404 | + //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user. |
|
405 | + foreach ($args['bulk_action'] as $route => $label) { |
|
406 | + if ($this->_admin_page->check_user_access($route, true)) { |
|
407 | + $actions[$route] = $label; |
|
408 | + } |
|
409 | + } |
|
410 | + } |
|
411 | + } |
|
412 | + return $actions; |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + /** |
|
417 | + * _filters |
|
418 | + * This receives the filters array from children _get_table_filters() and assembles the string including the filter |
|
419 | + * button. |
|
420 | + * |
|
421 | + * @access private |
|
422 | + * @return string html showing filters |
|
423 | + */ |
|
424 | + private function _filters() |
|
425 | + { |
|
426 | + $classname = get_class($this); |
|
427 | + $filters = apply_filters("FHEE__{$classname}__filters", (array)$this->_get_table_filters(), $this, |
|
428 | + $this->_screen); |
|
429 | + |
|
430 | + if (empty($filters)) { |
|
431 | + return; |
|
432 | + } |
|
433 | + foreach ($filters as $filter) { |
|
434 | + echo $filter; |
|
435 | + } |
|
436 | + //add filter button at end |
|
437 | + echo '<input type="submit" class="button-secondary" value="' . __('Filter', |
|
438 | + 'event_espresso') . '" id="post-query-submit" />'; |
|
439 | + //add reset filters button at end |
|
440 | + echo '<a class="button button-secondary" href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters', |
|
441 | + 'event_espresso') . '</a>'; |
|
442 | + } |
|
443 | + |
|
444 | + |
|
445 | + /** |
|
446 | + * Callback for 'list_table_primary_column' WordPress filter |
|
447 | + * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary |
|
448 | + * column when class is instantiated. |
|
449 | + * |
|
450 | + * @see WP_List_Table::get_primary_column_name |
|
451 | + * @param string $column_name |
|
452 | + * @return string |
|
453 | + */ |
|
454 | + public function set_primary_column($column_name) |
|
455 | + { |
|
456 | + return ! empty($this->_primary_column) ? $this->_primary_column : $column_name; |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + /** |
|
461 | + * |
|
462 | + */ |
|
463 | + public function prepare_items() |
|
464 | + { |
|
465 | + |
|
466 | + $this->_set_column_info(); |
|
467 | + //$this->_column_headers = $this->get_column_info(); |
|
468 | + $total_items = $this->_all_data_count; |
|
469 | + $this->process_bulk_action(); |
|
470 | + |
|
471 | + $this->items = $this->_data; |
|
472 | + $this->set_pagination_args( |
|
473 | + array( |
|
474 | + 'total_items' => $total_items, |
|
475 | + 'per_page' => $this->_per_page, |
|
476 | + 'total_pages' => ceil($total_items / $this->_per_page), |
|
477 | + ) |
|
478 | + ); |
|
479 | + } |
|
480 | + |
|
481 | + |
|
482 | + /** |
|
483 | + * This column is the default for when there is no defined column method for a registered column. |
|
484 | + * This can be overridden by child classes, but allows for hooking in for custom columns. |
|
485 | + * |
|
486 | + * @param EE_Base_Class $item |
|
487 | + * @param string $column_name The column being called. |
|
488 | + * @return string html content for the column |
|
489 | + */ |
|
490 | + public function column_default($item, $column_name) |
|
491 | + { |
|
492 | + /** |
|
493 | + * Dynamic hook allowing for adding additional column content in this list table. |
|
494 | + * Note that $this->screen->id is in the format |
|
495 | + * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
496 | + * table it is: event-espresso_page_espresso_messages. |
|
497 | + * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
498 | + * hook prefix ("event-espresso") will be different. |
|
499 | + */ |
|
500 | + do_action('AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item, |
|
501 | + $this->_screen); |
|
502 | + } |
|
503 | + |
|
504 | + |
|
505 | + /** |
|
506 | + * Get a list of columns. The format is: |
|
507 | + * 'internal-name' => 'Title' |
|
508 | + * |
|
509 | + * @since 3.1.0 |
|
510 | + * @access public |
|
511 | + * @abstract |
|
512 | + * @return array |
|
513 | + */ |
|
514 | + public function get_columns() |
|
515 | + { |
|
516 | + /** |
|
517 | + * Dynamic hook allowing for adding additional columns in this list table. |
|
518 | + * Note that $this->screen->id is in the format |
|
519 | + * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}. So for the messages list |
|
520 | + * table it is: event-espresso_page_espresso_messages. |
|
521 | + * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
|
522 | + * hook prefix ("event-espresso") will be different. |
|
523 | + * |
|
524 | + * @var array |
|
525 | + */ |
|
526 | + $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen); |
|
527 | + return $columns; |
|
528 | + } |
|
529 | + |
|
530 | + |
|
531 | + /** |
|
532 | + * Get an associative array ( id => link ) with the list |
|
533 | + * of views available on this table. |
|
534 | + * |
|
535 | + * @since 3.1.0 |
|
536 | + * @access protected |
|
537 | + * @return array |
|
538 | + */ |
|
539 | + public function get_views() |
|
540 | + { |
|
541 | + return $this->_views; |
|
542 | + } |
|
543 | + |
|
544 | + public function display_views() |
|
545 | + { |
|
546 | + $views = $this->get_views(); |
|
547 | + $assembled_views = array(); |
|
548 | + |
|
549 | + if (empty($views)) { |
|
550 | + return; |
|
551 | + } |
|
552 | + echo "<ul class='subsubsub'>\n"; |
|
553 | + foreach ($views as $view) { |
|
554 | + $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0; |
|
555 | + if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) { |
|
556 | + $assembled_views[$view['slug']] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>'; |
|
557 | + } |
|
558 | + } |
|
559 | + |
|
560 | + echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : ''; |
|
561 | + echo "</ul>"; |
|
562 | + } |
|
563 | + |
|
564 | + |
|
565 | + /** |
|
566 | + * Generates content for a single row of the table |
|
567 | + * |
|
568 | + * @since 4.1 |
|
569 | + * @access public |
|
570 | + * @param EE_Base_Class $item The current item |
|
571 | + */ |
|
572 | + public function single_row($item) |
|
573 | + { |
|
574 | + $row_class = $this->_get_row_class($item); |
|
575 | + echo '<tr class="' . esc_attr($row_class) . '">'; |
|
576 | + $this->single_row_columns($item); |
|
577 | + echo '</tr>'; |
|
578 | + } |
|
579 | + |
|
580 | + |
|
581 | + /** |
|
582 | + * This simply sets up the row class for the table rows. |
|
583 | + * Allows for easier overriding of child methods for setting up sorting. |
|
584 | + * |
|
585 | + * @param EE_Base_Class $item the current item |
|
586 | + * @return string |
|
587 | + */ |
|
588 | + protected function _get_row_class($item) |
|
589 | + { |
|
590 | + static $row_class = ''; |
|
591 | + $row_class = ($row_class === '' ? 'alternate' : ''); |
|
592 | + |
|
593 | + $new_row_class = $row_class; |
|
594 | + |
|
595 | + if (! empty($this->_ajax_sorting_callback)) { |
|
596 | + $new_row_class .= ' rowsortable'; |
|
597 | + } |
|
598 | + |
|
599 | + return $new_row_class; |
|
600 | + } |
|
601 | + |
|
602 | + |
|
603 | + /** |
|
604 | + * @return array |
|
605 | + */ |
|
606 | + public function get_sortable_columns() |
|
607 | + { |
|
608 | + return (array)$this->_sortable_columns; |
|
609 | + } |
|
610 | + |
|
611 | + |
|
612 | + /** |
|
613 | + * @return string |
|
614 | + */ |
|
615 | + public function get_ajax_sorting_callback() |
|
616 | + { |
|
617 | + return $this->_ajax_sorting_callback; |
|
618 | + } |
|
619 | + |
|
620 | + |
|
621 | + /** |
|
622 | + * @return array |
|
623 | + */ |
|
624 | + public function get_hidden_columns() |
|
625 | + { |
|
626 | + $user_id = get_current_user_id(); |
|
627 | + $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id); |
|
628 | + if (empty($has_default) && ! empty($this->_hidden_columns)) { |
|
629 | + update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true); |
|
630 | + update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true); |
|
631 | + } |
|
632 | + $ref = 'manage' . $this->screen->id . 'columnshidden'; |
|
633 | + return (array)get_user_option($ref, $user_id); |
|
634 | + } |
|
635 | + |
|
636 | + |
|
637 | + /** |
|
638 | + * Generates the columns for a single row of the table. |
|
639 | + * Overridden from wp_list_table so as to allow us to filter the column content for a given |
|
640 | + * column. |
|
641 | + * |
|
642 | + * @since 3.1.0 |
|
643 | + * @param EE_Base_Class $item The current item |
|
644 | + */ |
|
645 | + public function single_row_columns($item) |
|
646 | + { |
|
647 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
648 | + |
|
649 | + global $wp_version; |
|
650 | + $use_hidden_class = version_compare($wp_version, '4.3-RC', '>='); |
|
651 | + |
|
652 | + foreach ($columns as $column_name => $column_display_name) { |
|
653 | + |
|
654 | + /** |
|
655 | + * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are |
|
656 | + * hidden or not instead of using "display:none;". This bit of code provides backward compat. |
|
657 | + */ |
|
658 | + $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : ''; |
|
659 | + $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : ''; |
|
660 | + |
|
661 | + $classes = $column_name . ' column-' . $column_name . $hidden_class; |
|
662 | + if ($primary === $column_name) { |
|
663 | + $classes .= ' has-row-actions column-primary'; |
|
664 | + } |
|
665 | + |
|
666 | + $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"'; |
|
667 | + |
|
668 | + $class = "class='$classes'"; |
|
669 | + |
|
670 | + $attributes = "$class$style$data"; |
|
671 | + |
|
672 | + if ($column_name === 'cb') { |
|
673 | + echo '<th scope="row" class="check-column">'; |
|
674 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', |
|
675 | + $this->column_cb($item), $item, $this); |
|
676 | + echo '</th>'; |
|
677 | + } elseif (method_exists($this, 'column_' . $column_name)) { |
|
678 | + echo "<td $attributes>"; |
|
679 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', |
|
680 | + call_user_func(array($this, 'column_' . $column_name), $item), $item, $this); |
|
681 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
682 | + echo "</td>"; |
|
683 | + } else { |
|
684 | + echo "<td $attributes>"; |
|
685 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', |
|
686 | + $this->column_default($item, $column_name), $item, $column_name, $this); |
|
687 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
688 | + echo "</td>"; |
|
689 | + } |
|
690 | + } |
|
691 | + } |
|
692 | + |
|
693 | + |
|
694 | + /** |
|
695 | + * Extra controls to be displayed between bulk actions and pagination |
|
696 | + * |
|
697 | + * @access public |
|
698 | + * @param string $which |
|
699 | + * @throws \EE_Error |
|
700 | + */ |
|
701 | + public function extra_tablenav($which) |
|
702 | + { |
|
703 | + if ($which === 'top') { |
|
704 | + $this->_filters(); |
|
705 | + echo $this->_get_hidden_fields(); |
|
706 | + } else { |
|
707 | + echo '<div class="list-table-bottom-buttons alignleft actions">'; |
|
708 | + foreach ($this->_bottom_buttons as $type => $action) { |
|
709 | + $route = isset($action['route']) ? $action['route'] : ''; |
|
710 | + $extra_request = isset($action['extra_request']) ? $action['extra_request'] : ''; |
|
711 | + echo $this->_admin_page->get_action_link_or_button( |
|
712 | + $route, |
|
713 | + $type, |
|
714 | + $extra_request, |
|
715 | + 'button button-secondary', |
|
716 | + '', |
|
717 | + false |
|
718 | + ); |
|
719 | + } |
|
720 | + do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen); |
|
721 | + echo '</div>'; |
|
722 | + } |
|
723 | + //echo $this->_entries_per_page_dropdown; |
|
724 | + } |
|
725 | + |
|
726 | + |
|
727 | + /** |
|
728 | + * Get an associative array ( option_name => option_title ) with the list |
|
729 | + * of bulk actions available on this table. |
|
730 | + * |
|
731 | + * @since 3.1.0 |
|
732 | + * @access protected |
|
733 | + * @return array |
|
734 | + */ |
|
735 | + public function get_bulk_actions() |
|
736 | + { |
|
737 | + return (array)$this->_get_bulk_actions(); |
|
738 | + } |
|
739 | + |
|
740 | + public function process_bulk_action() |
|
741 | + { |
|
742 | + //this is not used it is handled by the child EE_Admin_Page class (routes). However, including here for reference in case there is a case where it gets used. |
|
743 | + } |
|
744 | + |
|
745 | + |
|
746 | + /** |
|
747 | + * returns the EE admin page this list table is associated with |
|
748 | + * |
|
749 | + * @return EE_Admin_Page |
|
750 | + */ |
|
751 | + public function get_admin_page() |
|
752 | + { |
|
753 | + return $this->_admin_page; |
|
754 | + } |
|
755 | + |
|
756 | + |
|
757 | + /** |
|
758 | + * A "helper" function for all children to provide an html string of |
|
759 | + * actions to output in their content. It is preferable for child classes |
|
760 | + * to use this method for generating their actions content so that it's |
|
761 | + * filterable by plugins |
|
762 | + * |
|
763 | + * @param string $action_container what are the html container |
|
764 | + * elements for this actions string? |
|
765 | + * @param string $action_class What class is for the container |
|
766 | + * element. |
|
767 | + * @param string $action_items The contents for the action items |
|
768 | + * container. This is filtered before |
|
769 | + * returned. |
|
770 | + * @param string $action_id What id (optional) is used for the |
|
771 | + * container element. |
|
772 | + * @param EE_Base_Class $item The object for the column displaying |
|
773 | + * the actions. |
|
774 | + * @return string The assembled action elements container. |
|
775 | + */ |
|
776 | + protected function _action_string( |
|
777 | + $action_items, |
|
778 | + $item, |
|
779 | + $action_container = 'ul', |
|
780 | + $action_class = '', |
|
781 | + $action_id = '' |
|
782 | + ) { |
|
783 | + $content = ''; |
|
784 | + $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : ''; |
|
785 | + $action_id = ! empty($action_id) ? ' id="' . $action_id . '"' : ''; |
|
786 | + $content .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : ''; |
|
787 | + try { |
|
788 | + $content .= apply_filters( |
|
789 | + 'FHEE__EE_Admin_List_Table___action_string__action_items', |
|
790 | + $action_items, |
|
791 | + $item, |
|
792 | + $this |
|
793 | + ); |
|
794 | + } catch (\Exception $e) { |
|
795 | + if (WP_DEBUG) { |
|
796 | + \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
797 | + } |
|
798 | + $content .= $action_items; |
|
799 | + } |
|
800 | + $content .= ! empty($action_container) ? '</' . $action_container . '>' : ''; |
|
801 | + return $content; |
|
802 | + } |
|
803 | 803 | } |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | -if (! class_exists('WP_List_Table')) { |
|
6 | - require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); |
|
5 | +if ( ! class_exists('WP_List_Table')) { |
|
6 | + require_once(ABSPATH.'wp-admin/includes/class-wp-list-table.php'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | $this->_view = $this->_admin_page->get_view(); |
207 | 207 | $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
208 | 208 | $this->_current_page = $this->get_pagenum(); |
209 | - $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view(); |
|
209 | + $this->_screen = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view(); |
|
210 | 210 | $this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso')); |
211 | 211 | |
212 | - $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10); |
|
212 | + $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10); |
|
213 | 213 | |
214 | 214 | $this->_setup_data(); |
215 | 215 | $this->_add_view_counts(); |
@@ -289,13 +289,13 @@ discard block |
||
289 | 289 | $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action; |
290 | 290 | //if action is STILL empty, then we set it to default |
291 | 291 | $action = empty($action) ? 'default' : $action; |
292 | - $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n"; |
|
293 | - $field .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/ |
|
294 | - $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n"; |
|
292 | + $field = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n"; |
|
293 | + $field .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/ |
|
294 | + $field .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n"; |
|
295 | 295 | |
296 | 296 | $bulk_actions = $this->_get_bulk_actions(); |
297 | 297 | foreach ($bulk_actions as $bulk_action => $label) { |
298 | - $field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n"; |
|
298 | + $field .= '<input type="hidden" name="'.$bulk_action.'_nonce" value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n"; |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | return $field; |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | $_data[0] = $data; |
341 | 341 | } |
342 | 342 | |
343 | - $data = (array)$data; |
|
343 | + $data = (array) $data; |
|
344 | 344 | |
345 | - if (! isset($data[1])) { |
|
345 | + if ( ! isset($data[1])) { |
|
346 | 346 | $_data[1] = false; |
347 | 347 | } |
348 | 348 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | private function _filters() |
425 | 425 | { |
426 | 426 | $classname = get_class($this); |
427 | - $filters = apply_filters("FHEE__{$classname}__filters", (array)$this->_get_table_filters(), $this, |
|
427 | + $filters = apply_filters("FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, |
|
428 | 428 | $this->_screen); |
429 | 429 | |
430 | 430 | if (empty($filters)) { |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | echo $filter; |
435 | 435 | } |
436 | 436 | //add filter button at end |
437 | - echo '<input type="submit" class="button-secondary" value="' . __('Filter', |
|
438 | - 'event_espresso') . '" id="post-query-submit" />'; |
|
437 | + echo '<input type="submit" class="button-secondary" value="'.__('Filter', |
|
438 | + 'event_espresso').'" id="post-query-submit" />'; |
|
439 | 439 | //add reset filters button at end |
440 | - echo '<a class="button button-secondary" href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters', |
|
441 | - 'event_espresso') . '</a>'; |
|
440 | + echo '<a class="button button-secondary" href="'.$this->_admin_page->get_current_page_view_url().'" style="display:inline-block">'.__('Reset Filters', |
|
441 | + 'event_espresso').'</a>'; |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the |
498 | 498 | * hook prefix ("event-espresso") will be different. |
499 | 499 | */ |
500 | - do_action('AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item, |
|
500 | + do_action('AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id, $item, |
|
501 | 501 | $this->_screen); |
502 | 502 | } |
503 | 503 | |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | * |
524 | 524 | * @var array |
525 | 525 | */ |
526 | - $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen); |
|
526 | + $columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen); |
|
527 | 527 | return $columns; |
528 | 528 | } |
529 | 529 | |
@@ -553,11 +553,11 @@ discard block |
||
553 | 553 | foreach ($views as $view) { |
554 | 554 | $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0; |
555 | 555 | if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) { |
556 | - $assembled_views[$view['slug']] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>'; |
|
556 | + $assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>".'<a href="'.$view['url'].'">'.$view['label'].'</a> <span class="count">('.$count.')</span>'; |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
560 | - echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : ''; |
|
560 | + echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : ''; |
|
561 | 561 | echo "</ul>"; |
562 | 562 | } |
563 | 563 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | public function single_row($item) |
573 | 573 | { |
574 | 574 | $row_class = $this->_get_row_class($item); |
575 | - echo '<tr class="' . esc_attr($row_class) . '">'; |
|
575 | + echo '<tr class="'.esc_attr($row_class).'">'; |
|
576 | 576 | $this->single_row_columns($item); |
577 | 577 | echo '</tr>'; |
578 | 578 | } |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | |
593 | 593 | $new_row_class = $row_class; |
594 | 594 | |
595 | - if (! empty($this->_ajax_sorting_callback)) { |
|
595 | + if ( ! empty($this->_ajax_sorting_callback)) { |
|
596 | 596 | $new_row_class .= ' rowsortable'; |
597 | 597 | } |
598 | 598 | |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | */ |
606 | 606 | public function get_sortable_columns() |
607 | 607 | { |
608 | - return (array)$this->_sortable_columns; |
|
608 | + return (array) $this->_sortable_columns; |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | |
@@ -624,13 +624,13 @@ discard block |
||
624 | 624 | public function get_hidden_columns() |
625 | 625 | { |
626 | 626 | $user_id = get_current_user_id(); |
627 | - $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id); |
|
627 | + $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id); |
|
628 | 628 | if (empty($has_default) && ! empty($this->_hidden_columns)) { |
629 | - update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true); |
|
630 | - update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true); |
|
629 | + update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', true); |
|
630 | + update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, true); |
|
631 | 631 | } |
632 | - $ref = 'manage' . $this->screen->id . 'columnshidden'; |
|
633 | - return (array)get_user_option($ref, $user_id); |
|
632 | + $ref = 'manage'.$this->screen->id.'columnshidden'; |
|
633 | + return (array) get_user_option($ref, $user_id); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | |
@@ -658,12 +658,12 @@ discard block |
||
658 | 658 | $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : ''; |
659 | 659 | $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : ''; |
660 | 660 | |
661 | - $classes = $column_name . ' column-' . $column_name . $hidden_class; |
|
661 | + $classes = $column_name.' column-'.$column_name.$hidden_class; |
|
662 | 662 | if ($primary === $column_name) { |
663 | 663 | $classes .= ' has-row-actions column-primary'; |
664 | 664 | } |
665 | 665 | |
666 | - $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"'; |
|
666 | + $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"'; |
|
667 | 667 | |
668 | 668 | $class = "class='$classes'"; |
669 | 669 | |
@@ -674,10 +674,10 @@ discard block |
||
674 | 674 | echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', |
675 | 675 | $this->column_cb($item), $item, $this); |
676 | 676 | echo '</th>'; |
677 | - } elseif (method_exists($this, 'column_' . $column_name)) { |
|
677 | + } elseif (method_exists($this, 'column_'.$column_name)) { |
|
678 | 678 | echo "<td $attributes>"; |
679 | - echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', |
|
680 | - call_user_func(array($this, 'column_' . $column_name), $item), $item, $this); |
|
679 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content', |
|
680 | + call_user_func(array($this, 'column_'.$column_name), $item), $item, $this); |
|
681 | 681 | echo $this->handle_row_actions($item, $column_name, $primary); |
682 | 682 | echo "</td>"; |
683 | 683 | } else { |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | */ |
735 | 735 | public function get_bulk_actions() |
736 | 736 | { |
737 | - return (array)$this->_get_bulk_actions(); |
|
737 | + return (array) $this->_get_bulk_actions(); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | public function process_bulk_action() |
@@ -781,9 +781,9 @@ discard block |
||
781 | 781 | $action_id = '' |
782 | 782 | ) { |
783 | 783 | $content = ''; |
784 | - $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : ''; |
|
785 | - $action_id = ! empty($action_id) ? ' id="' . $action_id . '"' : ''; |
|
786 | - $content .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : ''; |
|
784 | + $action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : ''; |
|
785 | + $action_id = ! empty($action_id) ? ' id="'.$action_id.'"' : ''; |
|
786 | + $content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : ''; |
|
787 | 787 | try { |
788 | 788 | $content .= apply_filters( |
789 | 789 | 'FHEE__EE_Admin_List_Table___action_string__action_items', |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | } |
798 | 798 | $content .= $action_items; |
799 | 799 | } |
800 | - $content .= ! empty($action_container) ? '</' . $action_container . '>' : ''; |
|
800 | + $content .= ! empty($action_container) ? '</'.$action_container.'>' : ''; |
|
801 | 801 | return $content; |
802 | 802 | } |
803 | 803 | } |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\Codeception\helpers; |
3 | 3 | |
4 | -use Page\CoreAdmin; |
|
5 | 4 | use Page\CountrySettingsAdmin as CountrySettings; |
6 | 5 | |
7 | 6 | trait CountrySettingsAdmin |
@@ -6,59 +6,59 @@ |
||
6 | 6 | |
7 | 7 | trait CountrySettingsAdmin |
8 | 8 | { |
9 | - /** |
|
10 | - * Instructs the actor to browse to the country settings page. |
|
11 | - * Assumes the actor is already logged in. |
|
12 | - * @param string $additional_params |
|
13 | - */ |
|
14 | - public function amOnCountrySettingsAdminPage($additional_params = '') |
|
15 | - { |
|
16 | - $this->actor()->amOnAdminPage(CountrySettings::url($additional_params)); |
|
17 | - } |
|
9 | + /** |
|
10 | + * Instructs the actor to browse to the country settings page. |
|
11 | + * Assumes the actor is already logged in. |
|
12 | + * @param string $additional_params |
|
13 | + */ |
|
14 | + public function amOnCountrySettingsAdminPage($additional_params = '') |
|
15 | + { |
|
16 | + $this->actor()->amOnAdminPage(CountrySettings::url($additional_params)); |
|
17 | + } |
|
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * Instructs the actor to select the given decimal places radio option. |
|
22 | - * Assumes the actor is already on the country settings page. |
|
23 | - * @param string $decimal_places |
|
24 | - * @param string $country_code |
|
25 | - */ |
|
26 | - public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US') |
|
27 | - { |
|
28 | - $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code)); |
|
29 | - } |
|
20 | + /** |
|
21 | + * Instructs the actor to select the given decimal places radio option. |
|
22 | + * Assumes the actor is already on the country settings page. |
|
23 | + * @param string $decimal_places |
|
24 | + * @param string $country_code |
|
25 | + */ |
|
26 | + public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US') |
|
27 | + { |
|
28 | + $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code)); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Instructs the actor to select the given decimal mark radio option. |
|
34 | - * Assumes the actor is already on the country settings page. |
|
35 | - * @param string $decimal_mark |
|
36 | - */ |
|
37 | - public function setCurrencyDecimalMarkTo($decimal_mark = '.') |
|
38 | - { |
|
39 | - $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark)); |
|
40 | - } |
|
32 | + /** |
|
33 | + * Instructs the actor to select the given decimal mark radio option. |
|
34 | + * Assumes the actor is already on the country settings page. |
|
35 | + * @param string $decimal_mark |
|
36 | + */ |
|
37 | + public function setCurrencyDecimalMarkTo($decimal_mark = '.') |
|
38 | + { |
|
39 | + $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark)); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * Instructs the actor to select the given thousands separator radio option. |
|
45 | - * Assumes the actor is already on the country settings page. |
|
46 | - * @param string $thousands_seperator |
|
47 | - */ |
|
48 | - public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',') |
|
49 | - { |
|
50 | - $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator)); |
|
51 | - } |
|
43 | + /** |
|
44 | + * Instructs the actor to select the given thousands separator radio option. |
|
45 | + * Assumes the actor is already on the country settings page. |
|
46 | + * @param string $thousands_seperator |
|
47 | + */ |
|
48 | + public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',') |
|
49 | + { |
|
50 | + $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator)); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * Clicks the country settings submit button. |
|
56 | - * Assumes the actor is on the country settings admin page. |
|
57 | - */ |
|
58 | - public function saveCountrySettings() |
|
59 | - { |
|
60 | - $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON); |
|
61 | - //no indicator on the page when stuff has been updated so just give a bit of time for it to finish. |
|
62 | - $this->actor()->wait(5); |
|
63 | - } |
|
54 | + /** |
|
55 | + * Clicks the country settings submit button. |
|
56 | + * Assumes the actor is on the country settings admin page. |
|
57 | + */ |
|
58 | + public function saveCountrySettings() |
|
59 | + { |
|
60 | + $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON); |
|
61 | + //no indicator on the page when stuff has been updated so just give a bit of time for it to finish. |
|
62 | + $this->actor()->wait(5); |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | \ No newline at end of file |