@@ -11,244 +11,244 @@ |
||
11 | 11 | */ |
12 | 12 | class Support_Admin_Page extends EE_Admin_Page |
13 | 13 | { |
14 | - protected function _init_page_props() |
|
15 | - { |
|
16 | - $this->page_slug = EE_SUPPORT_PG_SLUG; |
|
17 | - $this->page_label = esc_html__('Help & Support', 'event_espresso'); |
|
18 | - $this->_admin_base_url = EE_SUPPORT_ADMIN_URL; |
|
19 | - $this->_admin_base_path = EE_SUPPORT_ADMIN; |
|
20 | - } |
|
21 | - |
|
22 | - |
|
23 | - protected function _ajax_hooks() |
|
24 | - { |
|
25 | - } |
|
26 | - |
|
27 | - |
|
28 | - protected function _define_page_props() |
|
29 | - { |
|
30 | - $this->_labels = array(); |
|
31 | - $this->_admin_page_title = $this->page_label; |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - protected function _set_page_routes() |
|
36 | - { |
|
37 | - $this->_page_routes = array( |
|
38 | - 'default' => array( |
|
39 | - 'func' => '_contact_support', |
|
40 | - 'capability' => 'ee_read_ee', |
|
41 | - ), |
|
42 | - 'developers' => array( |
|
43 | - 'func' => '_developers', |
|
44 | - 'capability' => 'ee_read_ee', |
|
45 | - ), |
|
46 | - 'shortcodes' => array( |
|
47 | - 'func' => '_shortcodes', |
|
48 | - 'capability' => 'ee_read_ee', |
|
49 | - ), |
|
50 | - ); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - protected function _set_page_config() |
|
55 | - { |
|
56 | - $this->_page_config = array( |
|
57 | - 'default' => array( |
|
58 | - 'nav' => array( |
|
59 | - 'label' => esc_html__('Support', 'event_espresso'), |
|
60 | - 'icon' => 'dashicons-sos', |
|
61 | - 'order' => 30, |
|
62 | - ), |
|
63 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')), |
|
64 | - 'require_nonce' => false, |
|
65 | - ), |
|
66 | - 'developers' => array( |
|
67 | - 'nav' => array( |
|
68 | - 'label' => esc_html__('Developers', 'event_espresso'), |
|
69 | - 'icon' => 'dashicons-coffee', |
|
70 | - 'order' => 50, |
|
71 | - ), |
|
72 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
73 | - 'require_nonce' => false, |
|
74 | - ), |
|
75 | - 'shortcodes' => array( |
|
76 | - 'nav' => array( |
|
77 | - 'label' => esc_html__('Shortcodes', 'event_espresso'), |
|
78 | - 'icon' => 'dashicons-shortcode', |
|
79 | - 'order' => 60, |
|
80 | - ), |
|
81 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')), |
|
82 | - 'require_nonce' => false, |
|
83 | - ), |
|
84 | - ); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - // none of the below group are currently used for Support pages |
|
89 | - protected function _add_screen_options() |
|
90 | - { |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - protected function _add_feature_pointers() |
|
95 | - { |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - public function admin_init() |
|
100 | - { |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - public function admin_notices() |
|
105 | - { |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - public function admin_footer_scripts() |
|
110 | - { |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - public function load_scripts_styles() |
|
115 | - { |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - protected function _installation() |
|
120 | - { |
|
121 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php'; |
|
122 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
123 | - $template_path, |
|
124 | - '', |
|
125 | - true |
|
126 | - ); |
|
127 | - $this->display_admin_page_with_sidebar(); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - protected function _resources() |
|
132 | - { |
|
133 | - $this->display_admin_page_with_sidebar(); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - protected function _add_settings_metabox($box, $label, array $args) |
|
138 | - { |
|
139 | - $this->addMetaBox( |
|
140 | - "espresso_{$box}_settings", |
|
141 | - $label, |
|
142 | - function ($post, $metabox) { |
|
143 | - EEH_Template::display_template( |
|
144 | - $metabox['args']['template_path'], |
|
145 | - $metabox['args']['template_args'] |
|
146 | - ); |
|
147 | - }, |
|
148 | - $this->_current_screen->id, |
|
149 | - 'normal', |
|
150 | - 'high', |
|
151 | - apply_filters( |
|
152 | - "FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array", |
|
153 | - $args |
|
154 | - ) |
|
155 | - ); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - protected function _resources_boxes() |
|
160 | - { |
|
161 | - $boxes = apply_filters( |
|
162 | - 'FHEE__Support_Admin_Page___resources_boxes__boxes_array', |
|
163 | - array( |
|
164 | - 'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'), |
|
165 | - 'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'), |
|
166 | - 'hire_developer' => esc_html__('Hire a Developer', 'event_espresso'), |
|
167 | - 'partners' => esc_html__('Partners', 'event_espresso'), |
|
168 | - 'recommended_plugins' => esc_html__('Recommended Plugins', 'event_espresso'), |
|
169 | - 'other_resources' => esc_html__('Other Resources', 'event_espresso'), |
|
170 | - ) |
|
171 | - ); |
|
172 | - foreach ($boxes as $box => $label) { |
|
173 | - $this->_add_settings_metabox( |
|
174 | - $box, |
|
175 | - $label, |
|
176 | - array( |
|
177 | - 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
178 | - 'template_args' => $this->_template_args, |
|
179 | - ) |
|
180 | - ); |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - protected function _shortcodes() |
|
186 | - { |
|
187 | - $this->display_admin_page_with_sidebar(); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - protected function _shortcodes_boxes() |
|
192 | - { |
|
193 | - $boxes = apply_filters( |
|
194 | - 'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array', |
|
195 | - array( |
|
196 | - 'shortcodes_event_listings' => esc_html__('Event Listings', 'event_espresso'), |
|
197 | - 'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'), |
|
198 | - 'shortcodes_category' => esc_html__('Event Categories', 'event_espresso'), |
|
199 | - 'shortcodes_attendee' => esc_html__('Event Attendees', 'event_espresso') |
|
200 | - /*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/ |
|
201 | - /*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/ |
|
202 | - ) |
|
203 | - ); |
|
204 | - foreach ($boxes as $box => $label) { |
|
205 | - $this->_add_settings_metabox( |
|
206 | - $box, |
|
207 | - $label, |
|
208 | - array( |
|
209 | - 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
210 | - 'template_args' => $this->_template_args, |
|
211 | - ) |
|
212 | - ); |
|
213 | - } |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - protected function _contact_support() |
|
218 | - { |
|
219 | - $this->display_admin_page_with_sidebar(); |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - protected function _support_boxes() |
|
224 | - { |
|
225 | - $boxes = apply_filters( |
|
226 | - 'FHEE__Support_Admin_Page___support_boxes__boxes_array', |
|
227 | - array( |
|
228 | - 'contact_support' => esc_html__('Contact Support', 'event_espresso'), |
|
229 | - 'important_information' => esc_html__('Important Information', 'event_espresso'), |
|
230 | - ) |
|
231 | - ); |
|
232 | - foreach ($boxes as $box => $label) { |
|
233 | - $this->_add_settings_metabox( |
|
234 | - $box, |
|
235 | - $label, |
|
236 | - array( |
|
237 | - 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
238 | - 'template_args' => $this->_template_args, |
|
239 | - ) |
|
240 | - ); |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - protected function _developers() |
|
246 | - { |
|
247 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
248 | - EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php', |
|
249 | - array(), |
|
250 | - true |
|
251 | - ); |
|
252 | - $this->display_admin_page_with_sidebar(); |
|
253 | - } |
|
14 | + protected function _init_page_props() |
|
15 | + { |
|
16 | + $this->page_slug = EE_SUPPORT_PG_SLUG; |
|
17 | + $this->page_label = esc_html__('Help & Support', 'event_espresso'); |
|
18 | + $this->_admin_base_url = EE_SUPPORT_ADMIN_URL; |
|
19 | + $this->_admin_base_path = EE_SUPPORT_ADMIN; |
|
20 | + } |
|
21 | + |
|
22 | + |
|
23 | + protected function _ajax_hooks() |
|
24 | + { |
|
25 | + } |
|
26 | + |
|
27 | + |
|
28 | + protected function _define_page_props() |
|
29 | + { |
|
30 | + $this->_labels = array(); |
|
31 | + $this->_admin_page_title = $this->page_label; |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + protected function _set_page_routes() |
|
36 | + { |
|
37 | + $this->_page_routes = array( |
|
38 | + 'default' => array( |
|
39 | + 'func' => '_contact_support', |
|
40 | + 'capability' => 'ee_read_ee', |
|
41 | + ), |
|
42 | + 'developers' => array( |
|
43 | + 'func' => '_developers', |
|
44 | + 'capability' => 'ee_read_ee', |
|
45 | + ), |
|
46 | + 'shortcodes' => array( |
|
47 | + 'func' => '_shortcodes', |
|
48 | + 'capability' => 'ee_read_ee', |
|
49 | + ), |
|
50 | + ); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + protected function _set_page_config() |
|
55 | + { |
|
56 | + $this->_page_config = array( |
|
57 | + 'default' => array( |
|
58 | + 'nav' => array( |
|
59 | + 'label' => esc_html__('Support', 'event_espresso'), |
|
60 | + 'icon' => 'dashicons-sos', |
|
61 | + 'order' => 30, |
|
62 | + ), |
|
63 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')), |
|
64 | + 'require_nonce' => false, |
|
65 | + ), |
|
66 | + 'developers' => array( |
|
67 | + 'nav' => array( |
|
68 | + 'label' => esc_html__('Developers', 'event_espresso'), |
|
69 | + 'icon' => 'dashicons-coffee', |
|
70 | + 'order' => 50, |
|
71 | + ), |
|
72 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
73 | + 'require_nonce' => false, |
|
74 | + ), |
|
75 | + 'shortcodes' => array( |
|
76 | + 'nav' => array( |
|
77 | + 'label' => esc_html__('Shortcodes', 'event_espresso'), |
|
78 | + 'icon' => 'dashicons-shortcode', |
|
79 | + 'order' => 60, |
|
80 | + ), |
|
81 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')), |
|
82 | + 'require_nonce' => false, |
|
83 | + ), |
|
84 | + ); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + // none of the below group are currently used for Support pages |
|
89 | + protected function _add_screen_options() |
|
90 | + { |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + protected function _add_feature_pointers() |
|
95 | + { |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + public function admin_init() |
|
100 | + { |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + public function admin_notices() |
|
105 | + { |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + public function admin_footer_scripts() |
|
110 | + { |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + public function load_scripts_styles() |
|
115 | + { |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + protected function _installation() |
|
120 | + { |
|
121 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php'; |
|
122 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
123 | + $template_path, |
|
124 | + '', |
|
125 | + true |
|
126 | + ); |
|
127 | + $this->display_admin_page_with_sidebar(); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + protected function _resources() |
|
132 | + { |
|
133 | + $this->display_admin_page_with_sidebar(); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + protected function _add_settings_metabox($box, $label, array $args) |
|
138 | + { |
|
139 | + $this->addMetaBox( |
|
140 | + "espresso_{$box}_settings", |
|
141 | + $label, |
|
142 | + function ($post, $metabox) { |
|
143 | + EEH_Template::display_template( |
|
144 | + $metabox['args']['template_path'], |
|
145 | + $metabox['args']['template_args'] |
|
146 | + ); |
|
147 | + }, |
|
148 | + $this->_current_screen->id, |
|
149 | + 'normal', |
|
150 | + 'high', |
|
151 | + apply_filters( |
|
152 | + "FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array", |
|
153 | + $args |
|
154 | + ) |
|
155 | + ); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + protected function _resources_boxes() |
|
160 | + { |
|
161 | + $boxes = apply_filters( |
|
162 | + 'FHEE__Support_Admin_Page___resources_boxes__boxes_array', |
|
163 | + array( |
|
164 | + 'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'), |
|
165 | + 'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'), |
|
166 | + 'hire_developer' => esc_html__('Hire a Developer', 'event_espresso'), |
|
167 | + 'partners' => esc_html__('Partners', 'event_espresso'), |
|
168 | + 'recommended_plugins' => esc_html__('Recommended Plugins', 'event_espresso'), |
|
169 | + 'other_resources' => esc_html__('Other Resources', 'event_espresso'), |
|
170 | + ) |
|
171 | + ); |
|
172 | + foreach ($boxes as $box => $label) { |
|
173 | + $this->_add_settings_metabox( |
|
174 | + $box, |
|
175 | + $label, |
|
176 | + array( |
|
177 | + 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
178 | + 'template_args' => $this->_template_args, |
|
179 | + ) |
|
180 | + ); |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + protected function _shortcodes() |
|
186 | + { |
|
187 | + $this->display_admin_page_with_sidebar(); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + protected function _shortcodes_boxes() |
|
192 | + { |
|
193 | + $boxes = apply_filters( |
|
194 | + 'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array', |
|
195 | + array( |
|
196 | + 'shortcodes_event_listings' => esc_html__('Event Listings', 'event_espresso'), |
|
197 | + 'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'), |
|
198 | + 'shortcodes_category' => esc_html__('Event Categories', 'event_espresso'), |
|
199 | + 'shortcodes_attendee' => esc_html__('Event Attendees', 'event_espresso') |
|
200 | + /*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/ |
|
201 | + /*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/ |
|
202 | + ) |
|
203 | + ); |
|
204 | + foreach ($boxes as $box => $label) { |
|
205 | + $this->_add_settings_metabox( |
|
206 | + $box, |
|
207 | + $label, |
|
208 | + array( |
|
209 | + 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
210 | + 'template_args' => $this->_template_args, |
|
211 | + ) |
|
212 | + ); |
|
213 | + } |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + protected function _contact_support() |
|
218 | + { |
|
219 | + $this->display_admin_page_with_sidebar(); |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + protected function _support_boxes() |
|
224 | + { |
|
225 | + $boxes = apply_filters( |
|
226 | + 'FHEE__Support_Admin_Page___support_boxes__boxes_array', |
|
227 | + array( |
|
228 | + 'contact_support' => esc_html__('Contact Support', 'event_espresso'), |
|
229 | + 'important_information' => esc_html__('Important Information', 'event_espresso'), |
|
230 | + ) |
|
231 | + ); |
|
232 | + foreach ($boxes as $box => $label) { |
|
233 | + $this->_add_settings_metabox( |
|
234 | + $box, |
|
235 | + $label, |
|
236 | + array( |
|
237 | + 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
238 | + 'template_args' => $this->_template_args, |
|
239 | + ) |
|
240 | + ); |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + protected function _developers() |
|
246 | + { |
|
247 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
248 | + EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php', |
|
249 | + array(), |
|
250 | + true |
|
251 | + ); |
|
252 | + $this->display_admin_page_with_sidebar(); |
|
253 | + } |
|
254 | 254 | } |
@@ -14,247 +14,247 @@ |
||
14 | 14 | */ |
15 | 15 | class Extend_Transactions_Admin_Page extends Transactions_Admin_Page |
16 | 16 | { |
17 | - /** |
|
18 | - * This is used to hold the reports template data which is setup early in the request. |
|
19 | - * |
|
20 | - * @type array |
|
21 | - */ |
|
22 | - protected $_reports_template_data = array(); |
|
23 | - |
|
24 | - /** |
|
25 | - * @Constructor |
|
26 | - * @access public |
|
27 | - * |
|
28 | - * @param bool $routing |
|
29 | - * |
|
30 | - * @return \Extend_Transactions_Admin_Page |
|
31 | - */ |
|
32 | - public function __construct($routing = true) |
|
33 | - { |
|
34 | - parent::__construct($routing); |
|
35 | - define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
36 | - define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
37 | - define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * _extend_page_config |
|
43 | - * |
|
44 | - * @access protected |
|
45 | - * @return void |
|
46 | - */ |
|
47 | - protected function _extend_page_config() |
|
48 | - { |
|
49 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
50 | - |
|
51 | - $new_page_routes = array( |
|
52 | - 'reports' => array( |
|
53 | - 'func' => '_transaction_reports', |
|
54 | - 'capability' => 'ee_read_transactions', |
|
55 | - ), |
|
56 | - ); |
|
57 | - |
|
58 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
59 | - |
|
60 | - $new_page_config = array( |
|
61 | - 'reports' => array( |
|
62 | - 'nav' => array( |
|
63 | - 'label' => esc_html__('Reports', 'event_espresso'), |
|
64 | - 'icon' => 'dashicons-chart-bar', |
|
65 | - 'order' => 20, |
|
66 | - ), |
|
67 | - 'help_tabs' => array( |
|
68 | - 'transactions_reports_help_tab' => array( |
|
69 | - 'title' => esc_html__('Transaction Reports', 'event_espresso'), |
|
70 | - 'filename' => 'transactions_reports', |
|
71 | - ), |
|
72 | - ), |
|
73 | - 'require_nonce' => false, |
|
74 | - ), |
|
75 | - ); |
|
76 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * load_scripts_styles_reports |
|
82 | - * |
|
83 | - * @access public |
|
84 | - * @return void |
|
85 | - */ |
|
86 | - public function load_scripts_styles_reports() |
|
87 | - { |
|
88 | - wp_register_script( |
|
89 | - 'ee-txn-reports-js', |
|
90 | - TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', |
|
91 | - array('google-charts'), |
|
92 | - EVENT_ESPRESSO_VERSION, |
|
93 | - true |
|
94 | - ); |
|
95 | - wp_enqueue_script('ee-txn-reports-js'); |
|
96 | - $this->_transaction_reports_js_setup(); |
|
97 | - EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts(); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
103 | - * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method. |
|
104 | - */ |
|
105 | - protected function _transaction_reports_js_setup() |
|
106 | - { |
|
107 | - $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report(); |
|
108 | - $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report(); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * _transaction_reports |
|
114 | - * generates Business Reports regarding Transactions |
|
115 | - * |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - protected function _transaction_reports() |
|
119 | - { |
|
120 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
121 | - $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
|
122 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
123 | - $template_path, |
|
124 | - $this->_reports_template_data, |
|
125 | - true |
|
126 | - ); |
|
127 | - |
|
128 | - // the final template wrapper |
|
129 | - $this->display_admin_page_with_no_sidebar(); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * _revenue_per_day_report |
|
135 | - * generates Business Report showing Total Revenue per Day. |
|
136 | - * |
|
137 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
138 | - * |
|
139 | - * @return string |
|
140 | - */ |
|
141 | - private function _revenue_per_day_report($period = '-1 month') |
|
142 | - { |
|
143 | - |
|
144 | - $report_ID = 'txn-admin-revenue-per-day-report-dv'; |
|
145 | - |
|
146 | - $TXN = EEM_Transaction::instance(); |
|
147 | - |
|
148 | - $results = $TXN->get_revenue_per_day_report($period); |
|
149 | - $results = (array) $results; |
|
150 | - $revenue = array(); |
|
151 | - $subtitle = ''; |
|
152 | - |
|
153 | - if ($results) { |
|
154 | - $revenue[] = array( |
|
155 | - esc_html__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'), |
|
156 | - esc_html__('Total Revenue', 'event_espresso'), |
|
157 | - ); |
|
158 | - foreach ($results as $result) { |
|
159 | - $revenue[] = array($result->txnDate, (float) $result->revenue); |
|
160 | - } |
|
161 | - |
|
162 | - // setup the date range. |
|
163 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
164 | - $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
165 | - $subtitle = sprintf( |
|
166 | - wp_strip_all_tags( |
|
167 | - _x('For the period: %s to %s', 'Used to give date range', 'event_espresso') |
|
168 | - ), |
|
169 | - $beginning_date->format('Y-m-d'), |
|
170 | - $ending_date->format('Y-m-d') |
|
171 | - ); |
|
172 | - } |
|
173 | - |
|
174 | - $report_title = wp_strip_all_tags(__('Total Revenue per Day', 'event_espresso')); |
|
175 | - |
|
176 | - $report_params = array( |
|
177 | - 'title' => $report_title, |
|
178 | - 'subtitle' => $subtitle, |
|
179 | - 'id' => $report_ID, |
|
180 | - 'revenue' => $revenue, |
|
181 | - 'noResults' => empty($revenue) || count($revenue) === 1, |
|
182 | - 'noTxnMsg' => sprintf( |
|
183 | - wp_strip_all_tags( |
|
184 | - __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso') |
|
185 | - ), |
|
186 | - '<h2>' . $report_title . '</h2><p>', |
|
187 | - '</p>' |
|
188 | - ), |
|
189 | - ); |
|
190 | - wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
|
191 | - |
|
192 | - return $report_ID; |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * _revenue_per_event_report |
|
198 | - * generates Business Report showing total revenue per event. |
|
199 | - * |
|
200 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
201 | - * |
|
202 | - * @return int |
|
203 | - */ |
|
204 | - private function _revenue_per_event_report($period = '-1 month') |
|
205 | - { |
|
206 | - |
|
207 | - $report_ID = 'txn-admin-revenue-per-event-report-dv'; |
|
208 | - |
|
209 | - $TXN = EEM_Transaction::instance(); |
|
210 | - $results = $TXN->get_revenue_per_event_report($period); |
|
211 | - $results = (array) $results; |
|
212 | - $revenue = array(); |
|
213 | - $subtitle = ''; |
|
214 | - |
|
215 | - if ($results) { |
|
216 | - $revenue[] = array( |
|
217 | - esc_html__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'), |
|
218 | - esc_html__('Total Revenue', 'event_espresso'), |
|
219 | - ); |
|
220 | - foreach ($results as $result) { |
|
221 | - if ($result->revenue > 1) { |
|
222 | - $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
|
223 | - $event_name = wp_trim_words($event_name, 5, '...'); |
|
224 | - $revenue[] = array($event_name, (float) $result->revenue); |
|
225 | - } |
|
226 | - } |
|
227 | - |
|
228 | - // setup the date range. |
|
229 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
230 | - $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
231 | - $subtitle = sprintf( |
|
232 | - wp_strip_all_tags( |
|
233 | - _x('For the period: %s to %s', 'Used to give date range', 'event_espresso') |
|
234 | - ), |
|
235 | - $beginning_date->format('Y-m-d'), |
|
236 | - $ending_date->format('Y-m-d') |
|
237 | - ); |
|
238 | - } |
|
239 | - |
|
240 | - $report_title = wp_strip_all_tags(__('Total Revenue per Event', 'event_espresso')); |
|
241 | - |
|
242 | - $report_params = array( |
|
243 | - 'title' => $report_title, |
|
244 | - 'subtitle' => $subtitle, |
|
245 | - 'id' => $report_ID, |
|
246 | - 'revenue' => $revenue, |
|
247 | - 'noResults' => empty($revenue), |
|
248 | - 'noTxnMsg' => sprintf( |
|
249 | - wp_strip_all_tags( |
|
250 | - __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso') |
|
251 | - ), |
|
252 | - '<h2>' . $report_title . '</h2><p>', |
|
253 | - '</p>' |
|
254 | - ), |
|
255 | - ); |
|
256 | - wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
|
257 | - |
|
258 | - return $report_ID; |
|
259 | - } |
|
17 | + /** |
|
18 | + * This is used to hold the reports template data which is setup early in the request. |
|
19 | + * |
|
20 | + * @type array |
|
21 | + */ |
|
22 | + protected $_reports_template_data = array(); |
|
23 | + |
|
24 | + /** |
|
25 | + * @Constructor |
|
26 | + * @access public |
|
27 | + * |
|
28 | + * @param bool $routing |
|
29 | + * |
|
30 | + * @return \Extend_Transactions_Admin_Page |
|
31 | + */ |
|
32 | + public function __construct($routing = true) |
|
33 | + { |
|
34 | + parent::__construct($routing); |
|
35 | + define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
36 | + define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
37 | + define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * _extend_page_config |
|
43 | + * |
|
44 | + * @access protected |
|
45 | + * @return void |
|
46 | + */ |
|
47 | + protected function _extend_page_config() |
|
48 | + { |
|
49 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
50 | + |
|
51 | + $new_page_routes = array( |
|
52 | + 'reports' => array( |
|
53 | + 'func' => '_transaction_reports', |
|
54 | + 'capability' => 'ee_read_transactions', |
|
55 | + ), |
|
56 | + ); |
|
57 | + |
|
58 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
59 | + |
|
60 | + $new_page_config = array( |
|
61 | + 'reports' => array( |
|
62 | + 'nav' => array( |
|
63 | + 'label' => esc_html__('Reports', 'event_espresso'), |
|
64 | + 'icon' => 'dashicons-chart-bar', |
|
65 | + 'order' => 20, |
|
66 | + ), |
|
67 | + 'help_tabs' => array( |
|
68 | + 'transactions_reports_help_tab' => array( |
|
69 | + 'title' => esc_html__('Transaction Reports', 'event_espresso'), |
|
70 | + 'filename' => 'transactions_reports', |
|
71 | + ), |
|
72 | + ), |
|
73 | + 'require_nonce' => false, |
|
74 | + ), |
|
75 | + ); |
|
76 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * load_scripts_styles_reports |
|
82 | + * |
|
83 | + * @access public |
|
84 | + * @return void |
|
85 | + */ |
|
86 | + public function load_scripts_styles_reports() |
|
87 | + { |
|
88 | + wp_register_script( |
|
89 | + 'ee-txn-reports-js', |
|
90 | + TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', |
|
91 | + array('google-charts'), |
|
92 | + EVENT_ESPRESSO_VERSION, |
|
93 | + true |
|
94 | + ); |
|
95 | + wp_enqueue_script('ee-txn-reports-js'); |
|
96 | + $this->_transaction_reports_js_setup(); |
|
97 | + EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts(); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
103 | + * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method. |
|
104 | + */ |
|
105 | + protected function _transaction_reports_js_setup() |
|
106 | + { |
|
107 | + $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report(); |
|
108 | + $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report(); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * _transaction_reports |
|
114 | + * generates Business Reports regarding Transactions |
|
115 | + * |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + protected function _transaction_reports() |
|
119 | + { |
|
120 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
121 | + $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
|
122 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
123 | + $template_path, |
|
124 | + $this->_reports_template_data, |
|
125 | + true |
|
126 | + ); |
|
127 | + |
|
128 | + // the final template wrapper |
|
129 | + $this->display_admin_page_with_no_sidebar(); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * _revenue_per_day_report |
|
135 | + * generates Business Report showing Total Revenue per Day. |
|
136 | + * |
|
137 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
138 | + * |
|
139 | + * @return string |
|
140 | + */ |
|
141 | + private function _revenue_per_day_report($period = '-1 month') |
|
142 | + { |
|
143 | + |
|
144 | + $report_ID = 'txn-admin-revenue-per-day-report-dv'; |
|
145 | + |
|
146 | + $TXN = EEM_Transaction::instance(); |
|
147 | + |
|
148 | + $results = $TXN->get_revenue_per_day_report($period); |
|
149 | + $results = (array) $results; |
|
150 | + $revenue = array(); |
|
151 | + $subtitle = ''; |
|
152 | + |
|
153 | + if ($results) { |
|
154 | + $revenue[] = array( |
|
155 | + esc_html__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'), |
|
156 | + esc_html__('Total Revenue', 'event_espresso'), |
|
157 | + ); |
|
158 | + foreach ($results as $result) { |
|
159 | + $revenue[] = array($result->txnDate, (float) $result->revenue); |
|
160 | + } |
|
161 | + |
|
162 | + // setup the date range. |
|
163 | + $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
164 | + $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
165 | + $subtitle = sprintf( |
|
166 | + wp_strip_all_tags( |
|
167 | + _x('For the period: %s to %s', 'Used to give date range', 'event_espresso') |
|
168 | + ), |
|
169 | + $beginning_date->format('Y-m-d'), |
|
170 | + $ending_date->format('Y-m-d') |
|
171 | + ); |
|
172 | + } |
|
173 | + |
|
174 | + $report_title = wp_strip_all_tags(__('Total Revenue per Day', 'event_espresso')); |
|
175 | + |
|
176 | + $report_params = array( |
|
177 | + 'title' => $report_title, |
|
178 | + 'subtitle' => $subtitle, |
|
179 | + 'id' => $report_ID, |
|
180 | + 'revenue' => $revenue, |
|
181 | + 'noResults' => empty($revenue) || count($revenue) === 1, |
|
182 | + 'noTxnMsg' => sprintf( |
|
183 | + wp_strip_all_tags( |
|
184 | + __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso') |
|
185 | + ), |
|
186 | + '<h2>' . $report_title . '</h2><p>', |
|
187 | + '</p>' |
|
188 | + ), |
|
189 | + ); |
|
190 | + wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
|
191 | + |
|
192 | + return $report_ID; |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * _revenue_per_event_report |
|
198 | + * generates Business Report showing total revenue per event. |
|
199 | + * |
|
200 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
201 | + * |
|
202 | + * @return int |
|
203 | + */ |
|
204 | + private function _revenue_per_event_report($period = '-1 month') |
|
205 | + { |
|
206 | + |
|
207 | + $report_ID = 'txn-admin-revenue-per-event-report-dv'; |
|
208 | + |
|
209 | + $TXN = EEM_Transaction::instance(); |
|
210 | + $results = $TXN->get_revenue_per_event_report($period); |
|
211 | + $results = (array) $results; |
|
212 | + $revenue = array(); |
|
213 | + $subtitle = ''; |
|
214 | + |
|
215 | + if ($results) { |
|
216 | + $revenue[] = array( |
|
217 | + esc_html__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'), |
|
218 | + esc_html__('Total Revenue', 'event_espresso'), |
|
219 | + ); |
|
220 | + foreach ($results as $result) { |
|
221 | + if ($result->revenue > 1) { |
|
222 | + $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
|
223 | + $event_name = wp_trim_words($event_name, 5, '...'); |
|
224 | + $revenue[] = array($event_name, (float) $result->revenue); |
|
225 | + } |
|
226 | + } |
|
227 | + |
|
228 | + // setup the date range. |
|
229 | + $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
230 | + $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
231 | + $subtitle = sprintf( |
|
232 | + wp_strip_all_tags( |
|
233 | + _x('For the period: %s to %s', 'Used to give date range', 'event_espresso') |
|
234 | + ), |
|
235 | + $beginning_date->format('Y-m-d'), |
|
236 | + $ending_date->format('Y-m-d') |
|
237 | + ); |
|
238 | + } |
|
239 | + |
|
240 | + $report_title = wp_strip_all_tags(__('Total Revenue per Event', 'event_espresso')); |
|
241 | + |
|
242 | + $report_params = array( |
|
243 | + 'title' => $report_title, |
|
244 | + 'subtitle' => $subtitle, |
|
245 | + 'id' => $report_ID, |
|
246 | + 'revenue' => $revenue, |
|
247 | + 'noResults' => empty($revenue), |
|
248 | + 'noTxnMsg' => sprintf( |
|
249 | + wp_strip_all_tags( |
|
250 | + __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso') |
|
251 | + ), |
|
252 | + '<h2>' . $report_title . '</h2><p>', |
|
253 | + '</p>' |
|
254 | + ), |
|
255 | + ); |
|
256 | + wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
|
257 | + |
|
258 | + return $report_ID; |
|
259 | + } |
|
260 | 260 | } |
@@ -16,191 +16,191 @@ |
||
16 | 16 | */ |
17 | 17 | class Extend_Messages_Admin_Page extends Messages_Admin_Page |
18 | 18 | { |
19 | - public function __construct($routing = true) |
|
20 | - { |
|
21 | - parent::__construct($routing); |
|
22 | - if (! defined('EE_MSG_CAF_ASSETS_PATH')) { |
|
23 | - define('EE_MSG_CAF_ASSETS_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/assets/'); |
|
24 | - define('EE_MSG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/'); |
|
25 | - define('EE_MSG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/'); |
|
26 | - define('EE_MSG_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/templates/'); |
|
27 | - } |
|
28 | - } |
|
29 | - |
|
30 | - protected function _extend_page_config() |
|
31 | - { |
|
32 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'messages'; |
|
33 | - $this->_page_routes['custom_mtps'] = array( |
|
34 | - 'func' => '_ee_custom_messages_overview_list_table', |
|
35 | - 'capability' => 'ee_read_messages', |
|
36 | - ); |
|
37 | - $this->_page_config['custom_mtps'] = array( |
|
38 | - 'nav' => array( |
|
39 | - 'label' => esc_html__('Custom Message Templates', 'event_espresso'), |
|
40 | - 'icon' => 'dashicons-art', |
|
41 | - 'order' => 30, |
|
42 | - ), |
|
43 | - 'list_table' => 'Custom_Messages_Template_List_Table', |
|
44 | - 'help_tabs' => array( |
|
45 | - 'message_overview_message_types_help_tab' => array( |
|
46 | - 'title' => esc_html__('Message Types', 'event_espresso'), |
|
47 | - 'filename' => 'messages_overview_types', |
|
48 | - ), |
|
49 | - 'messages_overview_messengers_help_tab' => array( |
|
50 | - 'title' => esc_html__('Messengers', 'event_espresso'), |
|
51 | - 'filename' => 'messages_overview_messengers', |
|
52 | - ), |
|
53 | - 'messages_overview_other_help_tab' => array( |
|
54 | - 'title' => esc_html__('Messages Other', 'event_espresso'), |
|
55 | - 'filename' => 'messages_overview_other', |
|
56 | - ), |
|
57 | - ), |
|
58 | - 'require_nonce' => false, |
|
59 | - ); |
|
60 | - |
|
61 | - add_action('current_screen', array($this, 'dynamic_screen_hooks'), 10); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * Callback for current_screen action |
|
67 | - * This is used for any filters and/or actions that require the dynamic screen hook_prefix to be correct. |
|
68 | - * |
|
69 | - * @since 4.5.0 |
|
70 | - * |
|
71 | - * @return void |
|
72 | - */ |
|
73 | - public function dynamic_screen_hooks() |
|
74 | - { |
|
75 | - global $admin_page_hooks; |
|
76 | - |
|
77 | - if (! empty($admin_page_hooks['espresso_events'])) { |
|
78 | - // we're on a EE specific page... good stuff! |
|
79 | - $hook_prefix = $admin_page_hooks['espresso_events']; |
|
80 | - $filter_ref = $hook_prefix . '_page_' . $this->page_slug; |
|
81 | - add_filter('FHEE_manage_' . $filter_ref . '_columns', array($this, 'add_custom_mtps_columns'), 10, 2); |
|
82 | - add_action( |
|
83 | - 'AHEE__EE_Admin_List_Table__column_actions__' . $filter_ref, |
|
84 | - array($this, 'custom_mtp_create_button_column'), |
|
85 | - 10, |
|
86 | - 2 |
|
87 | - ); |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * This is the callback for the FHEE__manage_event-espresso_page_espresso_messages_columns to register the |
|
94 | - * caffeinated columns for the global message templates list table. |
|
95 | - * |
|
96 | - * @since 4.3.2 |
|
97 | - * |
|
98 | - * @param array $columns Original defined list of columns |
|
99 | - * @param string $screen_id The unique screen id for the page. |
|
100 | - */ |
|
101 | - public function add_custom_mtps_columns($columns, $screen_id) |
|
102 | - { |
|
103 | - if ($screen_id !== 'espresso_messages_global_mtps') { |
|
104 | - return $columns; |
|
105 | - } |
|
106 | - |
|
107 | - $columns['actions'] = ''; |
|
108 | - return $columns; |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * Callback for FHEE__EE_Admin_List_Table__column_actions__event-espresso_page_espresso_messages action that allows |
|
114 | - * for adding the content for the registered "action" column. |
|
115 | - * |
|
116 | - * @since 4.3.2 |
|
117 | - * |
|
118 | - * @param EE_Base_Class |
|
119 | - * @param string $screen_id Unique screen id for the page |
|
120 | - * |
|
121 | - * @return string html content for the page. |
|
122 | - */ |
|
123 | - public function custom_mtp_create_button_column($item, $screen_id) |
|
124 | - { |
|
125 | - if ( |
|
126 | - $screen_id !== 'espresso_messages_global_mtps' || ! EE_Registry::instance()->CAP->current_user_can( |
|
127 | - 'ee_edit_messages', |
|
128 | - 'espresso_messages_add_new_message_template' |
|
129 | - ) |
|
130 | - ) { |
|
131 | - return ''; |
|
132 | - } |
|
133 | - |
|
134 | - // first we consider whether this template has override set. If it does then that means no custom templates can be created from this template as a base. So let's just skip the button creation. |
|
135 | - if ($item->get('MTP_is_override')) { |
|
136 | - return ''; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - $create_args = array( |
|
141 | - 'GRP_ID' => $item->ID(), |
|
142 | - 'messenger' => $item->messenger(), |
|
143 | - 'message_type' => $item->message_type(), |
|
144 | - 'action' => 'add_new_message_template', |
|
145 | - ); |
|
146 | - $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
147 | - echo sprintf( |
|
148 | - '<a href="%s" class="button button--secondary button--small">%s</a>', |
|
149 | - $create_link, |
|
150 | - esc_html__('Create Custom', 'event_espresso') |
|
151 | - ); |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - protected function _add_screen_options_custom_mtps() |
|
156 | - { |
|
157 | - $page_title = $this->_admin_page_title; |
|
158 | - $this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso'); |
|
159 | - $this->_per_page_screen_option(); |
|
160 | - $this->_admin_page_title = $page_title; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * set views array for Custom Templates list table |
|
166 | - * |
|
167 | - * @access public |
|
168 | - * @return void |
|
169 | - */ |
|
170 | - public function _set_list_table_views_custom_mtps() |
|
171 | - { |
|
172 | - $this->_views = array( |
|
173 | - 'in_use' => array( |
|
174 | - 'slug' => 'in_use', |
|
175 | - 'label' => esc_html__('In Use', 'event_espresso'), |
|
176 | - 'count' => 0, |
|
177 | - 'bulk_action' => array( |
|
178 | - 'trash_message_template' => esc_html__('Move to Trash', 'event_espresso'), |
|
179 | - ), |
|
180 | - ), |
|
181 | - ); |
|
182 | - if ( |
|
183 | - EE_Registry::instance()->CAP->current_user_can( |
|
184 | - 'ee_delete_messages', |
|
185 | - 'espresso_messages_trash_message_template' |
|
186 | - ) |
|
187 | - ) { |
|
188 | - $this->_views['trashed'] = array( |
|
189 | - 'slug' => 'trashed', |
|
190 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
191 | - 'count' => 0, |
|
192 | - 'bulk_action' => array( |
|
193 | - 'restore_message_template' => esc_html__('Restore From Trash', 'event_espresso'), |
|
194 | - 'delete_message_template' => esc_html__('Delete Permanently', 'event_espresso'), |
|
195 | - ), |
|
196 | - ); |
|
197 | - } |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - protected function _ee_custom_messages_overview_list_table() |
|
202 | - { |
|
203 | - $this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso'); |
|
204 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
205 | - } |
|
19 | + public function __construct($routing = true) |
|
20 | + { |
|
21 | + parent::__construct($routing); |
|
22 | + if (! defined('EE_MSG_CAF_ASSETS_PATH')) { |
|
23 | + define('EE_MSG_CAF_ASSETS_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/assets/'); |
|
24 | + define('EE_MSG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/'); |
|
25 | + define('EE_MSG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/'); |
|
26 | + define('EE_MSG_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/templates/'); |
|
27 | + } |
|
28 | + } |
|
29 | + |
|
30 | + protected function _extend_page_config() |
|
31 | + { |
|
32 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'messages'; |
|
33 | + $this->_page_routes['custom_mtps'] = array( |
|
34 | + 'func' => '_ee_custom_messages_overview_list_table', |
|
35 | + 'capability' => 'ee_read_messages', |
|
36 | + ); |
|
37 | + $this->_page_config['custom_mtps'] = array( |
|
38 | + 'nav' => array( |
|
39 | + 'label' => esc_html__('Custom Message Templates', 'event_espresso'), |
|
40 | + 'icon' => 'dashicons-art', |
|
41 | + 'order' => 30, |
|
42 | + ), |
|
43 | + 'list_table' => 'Custom_Messages_Template_List_Table', |
|
44 | + 'help_tabs' => array( |
|
45 | + 'message_overview_message_types_help_tab' => array( |
|
46 | + 'title' => esc_html__('Message Types', 'event_espresso'), |
|
47 | + 'filename' => 'messages_overview_types', |
|
48 | + ), |
|
49 | + 'messages_overview_messengers_help_tab' => array( |
|
50 | + 'title' => esc_html__('Messengers', 'event_espresso'), |
|
51 | + 'filename' => 'messages_overview_messengers', |
|
52 | + ), |
|
53 | + 'messages_overview_other_help_tab' => array( |
|
54 | + 'title' => esc_html__('Messages Other', 'event_espresso'), |
|
55 | + 'filename' => 'messages_overview_other', |
|
56 | + ), |
|
57 | + ), |
|
58 | + 'require_nonce' => false, |
|
59 | + ); |
|
60 | + |
|
61 | + add_action('current_screen', array($this, 'dynamic_screen_hooks'), 10); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * Callback for current_screen action |
|
67 | + * This is used for any filters and/or actions that require the dynamic screen hook_prefix to be correct. |
|
68 | + * |
|
69 | + * @since 4.5.0 |
|
70 | + * |
|
71 | + * @return void |
|
72 | + */ |
|
73 | + public function dynamic_screen_hooks() |
|
74 | + { |
|
75 | + global $admin_page_hooks; |
|
76 | + |
|
77 | + if (! empty($admin_page_hooks['espresso_events'])) { |
|
78 | + // we're on a EE specific page... good stuff! |
|
79 | + $hook_prefix = $admin_page_hooks['espresso_events']; |
|
80 | + $filter_ref = $hook_prefix . '_page_' . $this->page_slug; |
|
81 | + add_filter('FHEE_manage_' . $filter_ref . '_columns', array($this, 'add_custom_mtps_columns'), 10, 2); |
|
82 | + add_action( |
|
83 | + 'AHEE__EE_Admin_List_Table__column_actions__' . $filter_ref, |
|
84 | + array($this, 'custom_mtp_create_button_column'), |
|
85 | + 10, |
|
86 | + 2 |
|
87 | + ); |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * This is the callback for the FHEE__manage_event-espresso_page_espresso_messages_columns to register the |
|
94 | + * caffeinated columns for the global message templates list table. |
|
95 | + * |
|
96 | + * @since 4.3.2 |
|
97 | + * |
|
98 | + * @param array $columns Original defined list of columns |
|
99 | + * @param string $screen_id The unique screen id for the page. |
|
100 | + */ |
|
101 | + public function add_custom_mtps_columns($columns, $screen_id) |
|
102 | + { |
|
103 | + if ($screen_id !== 'espresso_messages_global_mtps') { |
|
104 | + return $columns; |
|
105 | + } |
|
106 | + |
|
107 | + $columns['actions'] = ''; |
|
108 | + return $columns; |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * Callback for FHEE__EE_Admin_List_Table__column_actions__event-espresso_page_espresso_messages action that allows |
|
114 | + * for adding the content for the registered "action" column. |
|
115 | + * |
|
116 | + * @since 4.3.2 |
|
117 | + * |
|
118 | + * @param EE_Base_Class |
|
119 | + * @param string $screen_id Unique screen id for the page |
|
120 | + * |
|
121 | + * @return string html content for the page. |
|
122 | + */ |
|
123 | + public function custom_mtp_create_button_column($item, $screen_id) |
|
124 | + { |
|
125 | + if ( |
|
126 | + $screen_id !== 'espresso_messages_global_mtps' || ! EE_Registry::instance()->CAP->current_user_can( |
|
127 | + 'ee_edit_messages', |
|
128 | + 'espresso_messages_add_new_message_template' |
|
129 | + ) |
|
130 | + ) { |
|
131 | + return ''; |
|
132 | + } |
|
133 | + |
|
134 | + // first we consider whether this template has override set. If it does then that means no custom templates can be created from this template as a base. So let's just skip the button creation. |
|
135 | + if ($item->get('MTP_is_override')) { |
|
136 | + return ''; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + $create_args = array( |
|
141 | + 'GRP_ID' => $item->ID(), |
|
142 | + 'messenger' => $item->messenger(), |
|
143 | + 'message_type' => $item->message_type(), |
|
144 | + 'action' => 'add_new_message_template', |
|
145 | + ); |
|
146 | + $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
147 | + echo sprintf( |
|
148 | + '<a href="%s" class="button button--secondary button--small">%s</a>', |
|
149 | + $create_link, |
|
150 | + esc_html__('Create Custom', 'event_espresso') |
|
151 | + ); |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + protected function _add_screen_options_custom_mtps() |
|
156 | + { |
|
157 | + $page_title = $this->_admin_page_title; |
|
158 | + $this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso'); |
|
159 | + $this->_per_page_screen_option(); |
|
160 | + $this->_admin_page_title = $page_title; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * set views array for Custom Templates list table |
|
166 | + * |
|
167 | + * @access public |
|
168 | + * @return void |
|
169 | + */ |
|
170 | + public function _set_list_table_views_custom_mtps() |
|
171 | + { |
|
172 | + $this->_views = array( |
|
173 | + 'in_use' => array( |
|
174 | + 'slug' => 'in_use', |
|
175 | + 'label' => esc_html__('In Use', 'event_espresso'), |
|
176 | + 'count' => 0, |
|
177 | + 'bulk_action' => array( |
|
178 | + 'trash_message_template' => esc_html__('Move to Trash', 'event_espresso'), |
|
179 | + ), |
|
180 | + ), |
|
181 | + ); |
|
182 | + if ( |
|
183 | + EE_Registry::instance()->CAP->current_user_can( |
|
184 | + 'ee_delete_messages', |
|
185 | + 'espresso_messages_trash_message_template' |
|
186 | + ) |
|
187 | + ) { |
|
188 | + $this->_views['trashed'] = array( |
|
189 | + 'slug' => 'trashed', |
|
190 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
191 | + 'count' => 0, |
|
192 | + 'bulk_action' => array( |
|
193 | + 'restore_message_template' => esc_html__('Restore From Trash', 'event_espresso'), |
|
194 | + 'delete_message_template' => esc_html__('Delete Permanently', 'event_espresso'), |
|
195 | + ), |
|
196 | + ); |
|
197 | + } |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + protected function _ee_custom_messages_overview_list_table() |
|
202 | + { |
|
203 | + $this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso'); |
|
204 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
205 | + } |
|
206 | 206 | } |
@@ -14,1289 +14,1289 @@ |
||
14 | 14 | */ |
15 | 15 | class Extend_Registrations_Admin_Page extends Registrations_Admin_Page |
16 | 16 | { |
17 | - /** |
|
18 | - * This is used to hold the reports template data which is setup early in the request. |
|
19 | - * |
|
20 | - * @type array |
|
21 | - */ |
|
22 | - protected $_reports_template_data = array(); |
|
17 | + /** |
|
18 | + * This is used to hold the reports template data which is setup early in the request. |
|
19 | + * |
|
20 | + * @type array |
|
21 | + */ |
|
22 | + protected $_reports_template_data = array(); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Extend_Registrations_Admin_Page constructor. |
|
27 | - * |
|
28 | - * @param bool $routing |
|
29 | - */ |
|
30 | - public function __construct($routing = true) |
|
31 | - { |
|
32 | - parent::__construct($routing); |
|
33 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
34 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
35 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
36 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
37 | - } |
|
38 | - } |
|
25 | + /** |
|
26 | + * Extend_Registrations_Admin_Page constructor. |
|
27 | + * |
|
28 | + * @param bool $routing |
|
29 | + */ |
|
30 | + public function __construct($routing = true) |
|
31 | + { |
|
32 | + parent::__construct($routing); |
|
33 | + if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
34 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
35 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
36 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
37 | + } |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Extending page configuration. |
|
43 | - */ |
|
44 | - protected function _extend_page_config() |
|
45 | - { |
|
46 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
47 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
48 | - ? $this->_req_data['_REG_ID'] |
|
49 | - : 0; |
|
50 | - $new_page_routes = array( |
|
51 | - 'reports' => array( |
|
52 | - 'func' => '_registration_reports', |
|
53 | - 'capability' => 'ee_read_registrations', |
|
54 | - ), |
|
55 | - 'registration_checkins' => array( |
|
56 | - 'func' => '_registration_checkin_list_table', |
|
57 | - 'capability' => 'ee_read_checkins', |
|
58 | - ), |
|
59 | - 'newsletter_selected_send' => array( |
|
60 | - 'func' => '_newsletter_selected_send', |
|
61 | - 'noheader' => true, |
|
62 | - 'capability' => 'ee_send_message', |
|
63 | - ), |
|
64 | - 'delete_checkin_rows' => array( |
|
65 | - 'func' => '_delete_checkin_rows', |
|
66 | - 'noheader' => true, |
|
67 | - 'capability' => 'ee_delete_checkins', |
|
68 | - ), |
|
69 | - 'delete_checkin_row' => array( |
|
70 | - 'func' => '_delete_checkin_row', |
|
71 | - 'noheader' => true, |
|
72 | - 'capability' => 'ee_delete_checkin', |
|
73 | - 'obj_id' => $reg_id, |
|
74 | - ), |
|
75 | - 'toggle_checkin_status' => array( |
|
76 | - 'func' => '_toggle_checkin_status', |
|
77 | - 'noheader' => true, |
|
78 | - 'capability' => 'ee_edit_checkin', |
|
79 | - 'obj_id' => $reg_id, |
|
80 | - ), |
|
81 | - 'toggle_checkin_status_bulk' => array( |
|
82 | - 'func' => '_toggle_checkin_status', |
|
83 | - 'noheader' => true, |
|
84 | - 'capability' => 'ee_edit_checkins', |
|
85 | - ), |
|
86 | - 'event_registrations' => array( |
|
87 | - 'func' => '_event_registrations_list_table', |
|
88 | - 'capability' => 'ee_read_checkins', |
|
89 | - ), |
|
90 | - 'registrations_checkin_report' => array( |
|
91 | - 'func' => '_registrations_checkin_report', |
|
92 | - 'noheader' => true, |
|
93 | - 'capability' => 'ee_read_registrations', |
|
94 | - ), |
|
95 | - ); |
|
96 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
97 | - $new_page_config = array( |
|
98 | - 'reports' => array( |
|
99 | - 'nav' => array( |
|
100 | - 'label' => esc_html__('Reports', 'event_espresso'), |
|
101 | - 'icon' => 'dashicons-chart-bar', |
|
102 | - 'order' => 30, |
|
103 | - ), |
|
104 | - 'help_tabs' => array( |
|
105 | - 'registrations_reports_help_tab' => array( |
|
106 | - 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
107 | - 'filename' => 'registrations_reports', |
|
108 | - ), |
|
109 | - ), |
|
110 | - 'require_nonce' => false, |
|
111 | - ), |
|
112 | - 'event_registrations' => array( |
|
113 | - 'nav' => array( |
|
114 | - 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
115 | - 'icon' => 'dashicons-yes-alt', |
|
116 | - 'order' => 10, |
|
117 | - 'persistent' => true, |
|
118 | - ), |
|
119 | - 'help_tabs' => array( |
|
120 | - 'registrations_event_checkin_help_tab' => array( |
|
121 | - 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
122 | - 'filename' => 'registrations_event_checkin', |
|
123 | - ), |
|
124 | - 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
125 | - 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
126 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
127 | - ), |
|
128 | - 'registrations_event_checkin_filters_help_tab' => array( |
|
129 | - 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
130 | - 'filename' => 'registrations_event_checkin_filters', |
|
131 | - ), |
|
132 | - 'registrations_event_checkin_views_help_tab' => array( |
|
133 | - 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
134 | - 'filename' => 'registrations_event_checkin_views', |
|
135 | - ), |
|
136 | - 'registrations_event_checkin_other_help_tab' => array( |
|
137 | - 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
138 | - 'filename' => 'registrations_event_checkin_other', |
|
139 | - ), |
|
140 | - ), |
|
141 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
142 | - 'metaboxes' => array(), |
|
143 | - 'require_nonce' => false, |
|
144 | - ), |
|
145 | - 'registration_checkins' => array( |
|
146 | - 'nav' => array( |
|
147 | - 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
148 | - 'icon' => 'dashicons-list-view', |
|
149 | - 'order' => 15, |
|
150 | - 'persistent' => false, |
|
151 | - 'url' => '', |
|
152 | - ), |
|
153 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
154 | - 'metaboxes' => array(), |
|
155 | - 'require_nonce' => false, |
|
156 | - ), |
|
157 | - ); |
|
158 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
159 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
160 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
161 | - } |
|
41 | + /** |
|
42 | + * Extending page configuration. |
|
43 | + */ |
|
44 | + protected function _extend_page_config() |
|
45 | + { |
|
46 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
47 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
48 | + ? $this->_req_data['_REG_ID'] |
|
49 | + : 0; |
|
50 | + $new_page_routes = array( |
|
51 | + 'reports' => array( |
|
52 | + 'func' => '_registration_reports', |
|
53 | + 'capability' => 'ee_read_registrations', |
|
54 | + ), |
|
55 | + 'registration_checkins' => array( |
|
56 | + 'func' => '_registration_checkin_list_table', |
|
57 | + 'capability' => 'ee_read_checkins', |
|
58 | + ), |
|
59 | + 'newsletter_selected_send' => array( |
|
60 | + 'func' => '_newsletter_selected_send', |
|
61 | + 'noheader' => true, |
|
62 | + 'capability' => 'ee_send_message', |
|
63 | + ), |
|
64 | + 'delete_checkin_rows' => array( |
|
65 | + 'func' => '_delete_checkin_rows', |
|
66 | + 'noheader' => true, |
|
67 | + 'capability' => 'ee_delete_checkins', |
|
68 | + ), |
|
69 | + 'delete_checkin_row' => array( |
|
70 | + 'func' => '_delete_checkin_row', |
|
71 | + 'noheader' => true, |
|
72 | + 'capability' => 'ee_delete_checkin', |
|
73 | + 'obj_id' => $reg_id, |
|
74 | + ), |
|
75 | + 'toggle_checkin_status' => array( |
|
76 | + 'func' => '_toggle_checkin_status', |
|
77 | + 'noheader' => true, |
|
78 | + 'capability' => 'ee_edit_checkin', |
|
79 | + 'obj_id' => $reg_id, |
|
80 | + ), |
|
81 | + 'toggle_checkin_status_bulk' => array( |
|
82 | + 'func' => '_toggle_checkin_status', |
|
83 | + 'noheader' => true, |
|
84 | + 'capability' => 'ee_edit_checkins', |
|
85 | + ), |
|
86 | + 'event_registrations' => array( |
|
87 | + 'func' => '_event_registrations_list_table', |
|
88 | + 'capability' => 'ee_read_checkins', |
|
89 | + ), |
|
90 | + 'registrations_checkin_report' => array( |
|
91 | + 'func' => '_registrations_checkin_report', |
|
92 | + 'noheader' => true, |
|
93 | + 'capability' => 'ee_read_registrations', |
|
94 | + ), |
|
95 | + ); |
|
96 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
97 | + $new_page_config = array( |
|
98 | + 'reports' => array( |
|
99 | + 'nav' => array( |
|
100 | + 'label' => esc_html__('Reports', 'event_espresso'), |
|
101 | + 'icon' => 'dashicons-chart-bar', |
|
102 | + 'order' => 30, |
|
103 | + ), |
|
104 | + 'help_tabs' => array( |
|
105 | + 'registrations_reports_help_tab' => array( |
|
106 | + 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
107 | + 'filename' => 'registrations_reports', |
|
108 | + ), |
|
109 | + ), |
|
110 | + 'require_nonce' => false, |
|
111 | + ), |
|
112 | + 'event_registrations' => array( |
|
113 | + 'nav' => array( |
|
114 | + 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
115 | + 'icon' => 'dashicons-yes-alt', |
|
116 | + 'order' => 10, |
|
117 | + 'persistent' => true, |
|
118 | + ), |
|
119 | + 'help_tabs' => array( |
|
120 | + 'registrations_event_checkin_help_tab' => array( |
|
121 | + 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
122 | + 'filename' => 'registrations_event_checkin', |
|
123 | + ), |
|
124 | + 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
125 | + 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
126 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
127 | + ), |
|
128 | + 'registrations_event_checkin_filters_help_tab' => array( |
|
129 | + 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
130 | + 'filename' => 'registrations_event_checkin_filters', |
|
131 | + ), |
|
132 | + 'registrations_event_checkin_views_help_tab' => array( |
|
133 | + 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
134 | + 'filename' => 'registrations_event_checkin_views', |
|
135 | + ), |
|
136 | + 'registrations_event_checkin_other_help_tab' => array( |
|
137 | + 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
138 | + 'filename' => 'registrations_event_checkin_other', |
|
139 | + ), |
|
140 | + ), |
|
141 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
142 | + 'metaboxes' => array(), |
|
143 | + 'require_nonce' => false, |
|
144 | + ), |
|
145 | + 'registration_checkins' => array( |
|
146 | + 'nav' => array( |
|
147 | + 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
148 | + 'icon' => 'dashicons-list-view', |
|
149 | + 'order' => 15, |
|
150 | + 'persistent' => false, |
|
151 | + 'url' => '', |
|
152 | + ), |
|
153 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
154 | + 'metaboxes' => array(), |
|
155 | + 'require_nonce' => false, |
|
156 | + ), |
|
157 | + ); |
|
158 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
159 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
160 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
161 | + } |
|
162 | 162 | |
163 | 163 | |
164 | - /** |
|
165 | - * Ajax hooks for all routes in this page. |
|
166 | - */ |
|
167 | - protected function _ajax_hooks() |
|
168 | - { |
|
169 | - parent::_ajax_hooks(); |
|
170 | - add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
171 | - } |
|
164 | + /** |
|
165 | + * Ajax hooks for all routes in this page. |
|
166 | + */ |
|
167 | + protected function _ajax_hooks() |
|
168 | + { |
|
169 | + parent::_ajax_hooks(); |
|
170 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
171 | + } |
|
172 | 172 | |
173 | 173 | |
174 | - /** |
|
175 | - * Global scripts for all routes in this page. |
|
176 | - */ |
|
177 | - public function load_scripts_styles() |
|
178 | - { |
|
179 | - parent::load_scripts_styles(); |
|
180 | - // if newsletter message type is active then let's add filter and load js for it. |
|
181 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
182 | - // enqueue newsletter js |
|
183 | - wp_enqueue_script( |
|
184 | - 'ee-newsletter-trigger', |
|
185 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
186 | - array('ee-dialog'), |
|
187 | - EVENT_ESPRESSO_VERSION, |
|
188 | - true |
|
189 | - ); |
|
190 | - wp_enqueue_style( |
|
191 | - 'ee-newsletter-trigger-css', |
|
192 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
193 | - array(), |
|
194 | - EVENT_ESPRESSO_VERSION |
|
195 | - ); |
|
196 | - // hook in buttons for newsletter message type trigger. |
|
197 | - add_action( |
|
198 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
199 | - array($this, 'add_newsletter_action_buttons'), |
|
200 | - 10 |
|
201 | - ); |
|
202 | - } |
|
203 | - } |
|
174 | + /** |
|
175 | + * Global scripts for all routes in this page. |
|
176 | + */ |
|
177 | + public function load_scripts_styles() |
|
178 | + { |
|
179 | + parent::load_scripts_styles(); |
|
180 | + // if newsletter message type is active then let's add filter and load js for it. |
|
181 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
182 | + // enqueue newsletter js |
|
183 | + wp_enqueue_script( |
|
184 | + 'ee-newsletter-trigger', |
|
185 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
186 | + array('ee-dialog'), |
|
187 | + EVENT_ESPRESSO_VERSION, |
|
188 | + true |
|
189 | + ); |
|
190 | + wp_enqueue_style( |
|
191 | + 'ee-newsletter-trigger-css', |
|
192 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
193 | + array(), |
|
194 | + EVENT_ESPRESSO_VERSION |
|
195 | + ); |
|
196 | + // hook in buttons for newsletter message type trigger. |
|
197 | + add_action( |
|
198 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
199 | + array($this, 'add_newsletter_action_buttons'), |
|
200 | + 10 |
|
201 | + ); |
|
202 | + } |
|
203 | + } |
|
204 | 204 | |
205 | 205 | |
206 | - /** |
|
207 | - * Scripts and styles for just the reports route. |
|
208 | - */ |
|
209 | - public function load_scripts_styles_reports() |
|
210 | - { |
|
211 | - wp_register_script( |
|
212 | - 'ee-reg-reports-js', |
|
213 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
214 | - array('google-charts'), |
|
215 | - EVENT_ESPRESSO_VERSION, |
|
216 | - true |
|
217 | - ); |
|
218 | - wp_enqueue_script('ee-reg-reports-js'); |
|
219 | - $this->_registration_reports_js_setup(); |
|
220 | - } |
|
206 | + /** |
|
207 | + * Scripts and styles for just the reports route. |
|
208 | + */ |
|
209 | + public function load_scripts_styles_reports() |
|
210 | + { |
|
211 | + wp_register_script( |
|
212 | + 'ee-reg-reports-js', |
|
213 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
214 | + array('google-charts'), |
|
215 | + EVENT_ESPRESSO_VERSION, |
|
216 | + true |
|
217 | + ); |
|
218 | + wp_enqueue_script('ee-reg-reports-js'); |
|
219 | + $this->_registration_reports_js_setup(); |
|
220 | + } |
|
221 | 221 | |
222 | 222 | |
223 | - /** |
|
224 | - * Register screen options for event_registrations route. |
|
225 | - */ |
|
226 | - protected function _add_screen_options_event_registrations() |
|
227 | - { |
|
228 | - $this->_per_page_screen_option(); |
|
229 | - } |
|
223 | + /** |
|
224 | + * Register screen options for event_registrations route. |
|
225 | + */ |
|
226 | + protected function _add_screen_options_event_registrations() |
|
227 | + { |
|
228 | + $this->_per_page_screen_option(); |
|
229 | + } |
|
230 | 230 | |
231 | 231 | |
232 | - /** |
|
233 | - * Register screen options for registration_checkins route |
|
234 | - */ |
|
235 | - protected function _add_screen_options_registration_checkins() |
|
236 | - { |
|
237 | - $page_title = $this->_admin_page_title; |
|
238 | - $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
239 | - $this->_per_page_screen_option(); |
|
240 | - $this->_admin_page_title = $page_title; |
|
241 | - } |
|
232 | + /** |
|
233 | + * Register screen options for registration_checkins route |
|
234 | + */ |
|
235 | + protected function _add_screen_options_registration_checkins() |
|
236 | + { |
|
237 | + $page_title = $this->_admin_page_title; |
|
238 | + $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
239 | + $this->_per_page_screen_option(); |
|
240 | + $this->_admin_page_title = $page_title; |
|
241 | + } |
|
242 | 242 | |
243 | 243 | |
244 | - /** |
|
245 | - * Set views property for event_registrations route. |
|
246 | - */ |
|
247 | - protected function _set_list_table_views_event_registrations() |
|
248 | - { |
|
249 | - $this->_views = array( |
|
250 | - 'all' => array( |
|
251 | - 'slug' => 'all', |
|
252 | - 'label' => esc_html__('All', 'event_espresso'), |
|
253 | - 'count' => 0, |
|
254 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
255 | - ? array() |
|
256 | - : array( |
|
257 | - 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
258 | - ), |
|
259 | - ), |
|
260 | - ); |
|
261 | - } |
|
244 | + /** |
|
245 | + * Set views property for event_registrations route. |
|
246 | + */ |
|
247 | + protected function _set_list_table_views_event_registrations() |
|
248 | + { |
|
249 | + $this->_views = array( |
|
250 | + 'all' => array( |
|
251 | + 'slug' => 'all', |
|
252 | + 'label' => esc_html__('All', 'event_espresso'), |
|
253 | + 'count' => 0, |
|
254 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
255 | + ? array() |
|
256 | + : array( |
|
257 | + 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
258 | + ), |
|
259 | + ), |
|
260 | + ); |
|
261 | + } |
|
262 | 262 | |
263 | 263 | |
264 | - /** |
|
265 | - * Set views property for registration_checkins route. |
|
266 | - */ |
|
267 | - protected function _set_list_table_views_registration_checkins() |
|
268 | - { |
|
269 | - $this->_views = array( |
|
270 | - 'all' => array( |
|
271 | - 'slug' => 'all', |
|
272 | - 'label' => esc_html__('All', 'event_espresso'), |
|
273 | - 'count' => 0, |
|
274 | - 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
275 | - ), |
|
276 | - ); |
|
277 | - } |
|
264 | + /** |
|
265 | + * Set views property for registration_checkins route. |
|
266 | + */ |
|
267 | + protected function _set_list_table_views_registration_checkins() |
|
268 | + { |
|
269 | + $this->_views = array( |
|
270 | + 'all' => array( |
|
271 | + 'slug' => 'all', |
|
272 | + 'label' => esc_html__('All', 'event_espresso'), |
|
273 | + 'count' => 0, |
|
274 | + 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
275 | + ), |
|
276 | + ); |
|
277 | + } |
|
278 | 278 | |
279 | 279 | |
280 | - /** |
|
281 | - * callback for ajax action. |
|
282 | - * |
|
283 | - * @since 4.3.0 |
|
284 | - * @return void (JSON) |
|
285 | - * @throws EE_Error |
|
286 | - * @throws InvalidArgumentException |
|
287 | - * @throws InvalidDataTypeException |
|
288 | - * @throws InvalidInterfaceException |
|
289 | - */ |
|
290 | - public function get_newsletter_form_content() |
|
291 | - { |
|
292 | - // do a nonce check cause we're not coming in from an normal route here. |
|
293 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
294 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
295 | - ) : ''; |
|
296 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
297 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
298 | - // let's get the mtp for the incoming MTP_ ID |
|
299 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
300 | - EE_Error::add_error( |
|
301 | - esc_html__( |
|
302 | - 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
303 | - 'event_espresso' |
|
304 | - ), |
|
305 | - __FILE__, |
|
306 | - __FUNCTION__, |
|
307 | - __LINE__ |
|
308 | - ); |
|
309 | - $this->_template_args['success'] = false; |
|
310 | - $this->_template_args['error'] = true; |
|
311 | - $this->_return_json(); |
|
312 | - } |
|
313 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
314 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
315 | - EE_Error::add_error( |
|
316 | - sprintf( |
|
317 | - esc_html__( |
|
318 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
319 | - 'event_espresso' |
|
320 | - ), |
|
321 | - $this->_req_data['GRP_ID'] |
|
322 | - ), |
|
323 | - __FILE__, |
|
324 | - __FUNCTION__, |
|
325 | - __LINE__ |
|
326 | - ); |
|
327 | - $this->_template_args['success'] = false; |
|
328 | - $this->_template_args['error'] = true; |
|
329 | - $this->_return_json(); |
|
330 | - } |
|
331 | - $MTPs = $MTPG->context_templates(); |
|
332 | - $MTPs = $MTPs['attendee']; |
|
333 | - $template_fields = array(); |
|
334 | - /** @var EE_Message_Template $MTP */ |
|
335 | - foreach ($MTPs as $MTP) { |
|
336 | - $field = $MTP->get('MTP_template_field'); |
|
337 | - if ($field === 'content') { |
|
338 | - $content = $MTP->get('MTP_content'); |
|
339 | - if (! empty($content['newsletter_content'])) { |
|
340 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
341 | - } |
|
342 | - continue; |
|
343 | - } |
|
344 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
345 | - } |
|
346 | - $this->_template_args['success'] = true; |
|
347 | - $this->_template_args['error'] = false; |
|
348 | - $this->_template_args['data'] = array( |
|
349 | - 'batch_message_from' => isset($template_fields['from']) |
|
350 | - ? $template_fields['from'] |
|
351 | - : '', |
|
352 | - 'batch_message_subject' => isset($template_fields['subject']) |
|
353 | - ? $template_fields['subject'] |
|
354 | - : '', |
|
355 | - 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
356 | - ? $template_fields['newsletter_content'] |
|
357 | - : '', |
|
358 | - ); |
|
359 | - $this->_return_json(); |
|
360 | - } |
|
280 | + /** |
|
281 | + * callback for ajax action. |
|
282 | + * |
|
283 | + * @since 4.3.0 |
|
284 | + * @return void (JSON) |
|
285 | + * @throws EE_Error |
|
286 | + * @throws InvalidArgumentException |
|
287 | + * @throws InvalidDataTypeException |
|
288 | + * @throws InvalidInterfaceException |
|
289 | + */ |
|
290 | + public function get_newsletter_form_content() |
|
291 | + { |
|
292 | + // do a nonce check cause we're not coming in from an normal route here. |
|
293 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
294 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
295 | + ) : ''; |
|
296 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
297 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
298 | + // let's get the mtp for the incoming MTP_ ID |
|
299 | + if (! isset($this->_req_data['GRP_ID'])) { |
|
300 | + EE_Error::add_error( |
|
301 | + esc_html__( |
|
302 | + 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
303 | + 'event_espresso' |
|
304 | + ), |
|
305 | + __FILE__, |
|
306 | + __FUNCTION__, |
|
307 | + __LINE__ |
|
308 | + ); |
|
309 | + $this->_template_args['success'] = false; |
|
310 | + $this->_template_args['error'] = true; |
|
311 | + $this->_return_json(); |
|
312 | + } |
|
313 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
314 | + if (! $MTPG instanceof EE_Message_Template_Group) { |
|
315 | + EE_Error::add_error( |
|
316 | + sprintf( |
|
317 | + esc_html__( |
|
318 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
319 | + 'event_espresso' |
|
320 | + ), |
|
321 | + $this->_req_data['GRP_ID'] |
|
322 | + ), |
|
323 | + __FILE__, |
|
324 | + __FUNCTION__, |
|
325 | + __LINE__ |
|
326 | + ); |
|
327 | + $this->_template_args['success'] = false; |
|
328 | + $this->_template_args['error'] = true; |
|
329 | + $this->_return_json(); |
|
330 | + } |
|
331 | + $MTPs = $MTPG->context_templates(); |
|
332 | + $MTPs = $MTPs['attendee']; |
|
333 | + $template_fields = array(); |
|
334 | + /** @var EE_Message_Template $MTP */ |
|
335 | + foreach ($MTPs as $MTP) { |
|
336 | + $field = $MTP->get('MTP_template_field'); |
|
337 | + if ($field === 'content') { |
|
338 | + $content = $MTP->get('MTP_content'); |
|
339 | + if (! empty($content['newsletter_content'])) { |
|
340 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
341 | + } |
|
342 | + continue; |
|
343 | + } |
|
344 | + $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
345 | + } |
|
346 | + $this->_template_args['success'] = true; |
|
347 | + $this->_template_args['error'] = false; |
|
348 | + $this->_template_args['data'] = array( |
|
349 | + 'batch_message_from' => isset($template_fields['from']) |
|
350 | + ? $template_fields['from'] |
|
351 | + : '', |
|
352 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
353 | + ? $template_fields['subject'] |
|
354 | + : '', |
|
355 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
356 | + ? $template_fields['newsletter_content'] |
|
357 | + : '', |
|
358 | + ); |
|
359 | + $this->_return_json(); |
|
360 | + } |
|
361 | 361 | |
362 | 362 | |
363 | - /** |
|
364 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
365 | - * |
|
366 | - * @since 4.3.0 |
|
367 | - * @param EE_Admin_List_Table $list_table |
|
368 | - * @return void |
|
369 | - * @throws InvalidArgumentException |
|
370 | - * @throws InvalidDataTypeException |
|
371 | - * @throws InvalidInterfaceException |
|
372 | - */ |
|
373 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
374 | - { |
|
375 | - if ( |
|
376 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
377 | - 'ee_send_message', |
|
378 | - 'espresso_registrations_newsletter_selected_send' |
|
379 | - ) |
|
380 | - ) { |
|
381 | - return; |
|
382 | - } |
|
383 | - $routes_to_add_to = array( |
|
384 | - 'contact_list', |
|
385 | - 'event_registrations', |
|
386 | - 'default', |
|
387 | - ); |
|
388 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
389 | - if ( |
|
390 | - ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
391 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
392 | - ) { |
|
393 | - echo ''; |
|
394 | - } else { |
|
395 | - $button_text = sprintf( |
|
396 | - esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
397 | - '<span class="send-selected-newsletter-count">0</span>' |
|
398 | - ); |
|
399 | - echo '<button id="selected-batch-send-trigger" class="button button--secondary">' |
|
400 | - . '<span class="dashicons dashicons-email "></span>' |
|
401 | - . $button_text |
|
402 | - . '</button>'; |
|
403 | - add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
404 | - } |
|
405 | - } |
|
406 | - } |
|
363 | + /** |
|
364 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
365 | + * |
|
366 | + * @since 4.3.0 |
|
367 | + * @param EE_Admin_List_Table $list_table |
|
368 | + * @return void |
|
369 | + * @throws InvalidArgumentException |
|
370 | + * @throws InvalidDataTypeException |
|
371 | + * @throws InvalidInterfaceException |
|
372 | + */ |
|
373 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
374 | + { |
|
375 | + if ( |
|
376 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
377 | + 'ee_send_message', |
|
378 | + 'espresso_registrations_newsletter_selected_send' |
|
379 | + ) |
|
380 | + ) { |
|
381 | + return; |
|
382 | + } |
|
383 | + $routes_to_add_to = array( |
|
384 | + 'contact_list', |
|
385 | + 'event_registrations', |
|
386 | + 'default', |
|
387 | + ); |
|
388 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
389 | + if ( |
|
390 | + ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
391 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
392 | + ) { |
|
393 | + echo ''; |
|
394 | + } else { |
|
395 | + $button_text = sprintf( |
|
396 | + esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
397 | + '<span class="send-selected-newsletter-count">0</span>' |
|
398 | + ); |
|
399 | + echo '<button id="selected-batch-send-trigger" class="button button--secondary">' |
|
400 | + . '<span class="dashicons dashicons-email "></span>' |
|
401 | + . $button_text |
|
402 | + . '</button>'; |
|
403 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
404 | + } |
|
405 | + } |
|
406 | + } |
|
407 | 407 | |
408 | 408 | |
409 | - /** |
|
410 | - * @throws DomainException |
|
411 | - * @throws EE_Error |
|
412 | - * @throws InvalidArgumentException |
|
413 | - * @throws InvalidDataTypeException |
|
414 | - * @throws InvalidInterfaceException |
|
415 | - */ |
|
416 | - public function newsletter_send_form_skeleton() |
|
417 | - { |
|
418 | - $list_table = $this->_list_table_object; |
|
419 | - $codes = array(); |
|
420 | - // need to templates for the newsletter message type for the template selector. |
|
421 | - $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
422 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
423 | - array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
424 | - ); |
|
425 | - foreach ($mtps as $mtp) { |
|
426 | - $name = $mtp->name(); |
|
427 | - $values[] = array( |
|
428 | - 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
429 | - 'id' => $mtp->ID(), |
|
430 | - ); |
|
431 | - } |
|
432 | - // need to get a list of shortcodes that are available for the newsletter message type. |
|
433 | - $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
434 | - 'newsletter', |
|
435 | - 'email', |
|
436 | - array(), |
|
437 | - 'attendee', |
|
438 | - false |
|
439 | - ); |
|
440 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
441 | - $available_shortcodes = array(); |
|
442 | - foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
443 | - $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
444 | - ? 'content' |
|
445 | - : $field; |
|
446 | - $field_id = 'batch-message-' . strtolower($field_id); |
|
447 | - $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
448 | - . $shortcode |
|
449 | - . '" data-linked-input-id="' . $field_id . '">' |
|
450 | - . $shortcode |
|
451 | - . '</span>'; |
|
452 | - } |
|
453 | - $codes[ $field ] = implode(', ', $available_shortcodes); |
|
454 | - } |
|
455 | - $shortcodes = $codes; |
|
456 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
457 | - $form_template_args = array( |
|
458 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
459 | - 'form_route' => 'newsletter_selected_send', |
|
460 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
461 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
462 | - 'redirect_back_to' => $this->_req_action, |
|
463 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
464 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
465 | - 'shortcodes' => $shortcodes, |
|
466 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
467 | - ); |
|
468 | - EEH_Template::display_template($form_template, $form_template_args); |
|
469 | - } |
|
409 | + /** |
|
410 | + * @throws DomainException |
|
411 | + * @throws EE_Error |
|
412 | + * @throws InvalidArgumentException |
|
413 | + * @throws InvalidDataTypeException |
|
414 | + * @throws InvalidInterfaceException |
|
415 | + */ |
|
416 | + public function newsletter_send_form_skeleton() |
|
417 | + { |
|
418 | + $list_table = $this->_list_table_object; |
|
419 | + $codes = array(); |
|
420 | + // need to templates for the newsletter message type for the template selector. |
|
421 | + $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
422 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
423 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
424 | + ); |
|
425 | + foreach ($mtps as $mtp) { |
|
426 | + $name = $mtp->name(); |
|
427 | + $values[] = array( |
|
428 | + 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
429 | + 'id' => $mtp->ID(), |
|
430 | + ); |
|
431 | + } |
|
432 | + // need to get a list of shortcodes that are available for the newsletter message type. |
|
433 | + $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
434 | + 'newsletter', |
|
435 | + 'email', |
|
436 | + array(), |
|
437 | + 'attendee', |
|
438 | + false |
|
439 | + ); |
|
440 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
441 | + $available_shortcodes = array(); |
|
442 | + foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
443 | + $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
444 | + ? 'content' |
|
445 | + : $field; |
|
446 | + $field_id = 'batch-message-' . strtolower($field_id); |
|
447 | + $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
448 | + . $shortcode |
|
449 | + . '" data-linked-input-id="' . $field_id . '">' |
|
450 | + . $shortcode |
|
451 | + . '</span>'; |
|
452 | + } |
|
453 | + $codes[ $field ] = implode(', ', $available_shortcodes); |
|
454 | + } |
|
455 | + $shortcodes = $codes; |
|
456 | + $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
457 | + $form_template_args = array( |
|
458 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
459 | + 'form_route' => 'newsletter_selected_send', |
|
460 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
461 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
462 | + 'redirect_back_to' => $this->_req_action, |
|
463 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
464 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
465 | + 'shortcodes' => $shortcodes, |
|
466 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
467 | + ); |
|
468 | + EEH_Template::display_template($form_template, $form_template_args); |
|
469 | + } |
|
470 | 470 | |
471 | 471 | |
472 | - /** |
|
473 | - * Handles sending selected registrations/contacts a newsletter. |
|
474 | - * |
|
475 | - * @since 4.3.0 |
|
476 | - * @return void |
|
477 | - * @throws EE_Error |
|
478 | - * @throws InvalidArgumentException |
|
479 | - * @throws InvalidDataTypeException |
|
480 | - * @throws InvalidInterfaceException |
|
481 | - */ |
|
482 | - protected function _newsletter_selected_send() |
|
483 | - { |
|
484 | - $success = true; |
|
485 | - // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
486 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
487 | - EE_Error::add_error( |
|
488 | - esc_html__( |
|
489 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
490 | - 'event_espresso' |
|
491 | - ), |
|
492 | - __FILE__, |
|
493 | - __FUNCTION__, |
|
494 | - __LINE__ |
|
495 | - ); |
|
496 | - $success = false; |
|
497 | - } |
|
498 | - if ($success) { |
|
499 | - // update Message template in case there are any changes |
|
500 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
501 | - $this->_req_data['newsletter_mtp_selected'] |
|
502 | - ); |
|
503 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
504 | - ? $Message_Template_Group->context_templates() |
|
505 | - : array(); |
|
506 | - if (empty($Message_Templates)) { |
|
507 | - EE_Error::add_error( |
|
508 | - esc_html__( |
|
509 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
510 | - 'event_espresso' |
|
511 | - ), |
|
512 | - __FILE__, |
|
513 | - __FUNCTION__, |
|
514 | - __LINE__ |
|
515 | - ); |
|
516 | - } |
|
517 | - // let's just update the specific fields |
|
518 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
519 | - if ($Message_Template instanceof EE_Message_Template) { |
|
520 | - $field = $Message_Template->get('MTP_template_field'); |
|
521 | - $content = $Message_Template->get('MTP_content'); |
|
522 | - $new_content = $content; |
|
523 | - switch ($field) { |
|
524 | - case 'from': |
|
525 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
526 | - ? $this->_req_data['batch_message']['from'] |
|
527 | - : $content; |
|
528 | - break; |
|
529 | - case 'subject': |
|
530 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
531 | - ? $this->_req_data['batch_message']['subject'] |
|
532 | - : $content; |
|
533 | - break; |
|
534 | - case 'content': |
|
535 | - $new_content = $content; |
|
536 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
537 | - ? $this->_req_data['batch_message']['content'] |
|
538 | - : $content['newsletter_content']; |
|
539 | - break; |
|
540 | - default: |
|
541 | - // continue the foreach loop, we don't want to set $new_content nor save. |
|
542 | - continue 2; |
|
543 | - } |
|
544 | - $Message_Template->set('MTP_content', $new_content); |
|
545 | - $Message_Template->save(); |
|
546 | - } |
|
547 | - } |
|
548 | - // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
549 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
550 | - ? $this->_req_data['batch_message']['id_type'] |
|
551 | - : 'registration'; |
|
552 | - // id_type will affect how we assemble the ids. |
|
553 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
554 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
555 | - : array(); |
|
556 | - $registrations_used_for_contact_data = array(); |
|
557 | - // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
558 | - switch ($id_type) { |
|
559 | - case 'registration': |
|
560 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
561 | - array( |
|
562 | - array( |
|
563 | - 'REG_ID' => array('IN', $ids), |
|
564 | - ), |
|
565 | - ) |
|
566 | - ); |
|
567 | - break; |
|
568 | - case 'contact': |
|
569 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
570 | - ->get_latest_registration_for_each_of_given_contacts( |
|
571 | - $ids |
|
572 | - ); |
|
573 | - break; |
|
574 | - } |
|
575 | - do_action_ref_array( |
|
576 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
577 | - array( |
|
578 | - $registrations_used_for_contact_data, |
|
579 | - $Message_Template_Group->ID(), |
|
580 | - ) |
|
581 | - ); |
|
582 | - // kept for backward compat, internally we no longer use this action. |
|
583 | - // @deprecated 4.8.36.rc.002 |
|
584 | - $contacts = $id_type === 'registration' |
|
585 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
586 | - : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
587 | - do_action_ref_array( |
|
588 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
589 | - array( |
|
590 | - $contacts, |
|
591 | - $Message_Template_Group->ID(), |
|
592 | - ) |
|
593 | - ); |
|
594 | - } |
|
595 | - $query_args = array( |
|
596 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
597 | - ? $this->_req_data['redirect_back_to'] |
|
598 | - : 'default', |
|
599 | - ); |
|
600 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
601 | - } |
|
472 | + /** |
|
473 | + * Handles sending selected registrations/contacts a newsletter. |
|
474 | + * |
|
475 | + * @since 4.3.0 |
|
476 | + * @return void |
|
477 | + * @throws EE_Error |
|
478 | + * @throws InvalidArgumentException |
|
479 | + * @throws InvalidDataTypeException |
|
480 | + * @throws InvalidInterfaceException |
|
481 | + */ |
|
482 | + protected function _newsletter_selected_send() |
|
483 | + { |
|
484 | + $success = true; |
|
485 | + // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
486 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
487 | + EE_Error::add_error( |
|
488 | + esc_html__( |
|
489 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
490 | + 'event_espresso' |
|
491 | + ), |
|
492 | + __FILE__, |
|
493 | + __FUNCTION__, |
|
494 | + __LINE__ |
|
495 | + ); |
|
496 | + $success = false; |
|
497 | + } |
|
498 | + if ($success) { |
|
499 | + // update Message template in case there are any changes |
|
500 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
501 | + $this->_req_data['newsletter_mtp_selected'] |
|
502 | + ); |
|
503 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
504 | + ? $Message_Template_Group->context_templates() |
|
505 | + : array(); |
|
506 | + if (empty($Message_Templates)) { |
|
507 | + EE_Error::add_error( |
|
508 | + esc_html__( |
|
509 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
510 | + 'event_espresso' |
|
511 | + ), |
|
512 | + __FILE__, |
|
513 | + __FUNCTION__, |
|
514 | + __LINE__ |
|
515 | + ); |
|
516 | + } |
|
517 | + // let's just update the specific fields |
|
518 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
519 | + if ($Message_Template instanceof EE_Message_Template) { |
|
520 | + $field = $Message_Template->get('MTP_template_field'); |
|
521 | + $content = $Message_Template->get('MTP_content'); |
|
522 | + $new_content = $content; |
|
523 | + switch ($field) { |
|
524 | + case 'from': |
|
525 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
526 | + ? $this->_req_data['batch_message']['from'] |
|
527 | + : $content; |
|
528 | + break; |
|
529 | + case 'subject': |
|
530 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
531 | + ? $this->_req_data['batch_message']['subject'] |
|
532 | + : $content; |
|
533 | + break; |
|
534 | + case 'content': |
|
535 | + $new_content = $content; |
|
536 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
537 | + ? $this->_req_data['batch_message']['content'] |
|
538 | + : $content['newsletter_content']; |
|
539 | + break; |
|
540 | + default: |
|
541 | + // continue the foreach loop, we don't want to set $new_content nor save. |
|
542 | + continue 2; |
|
543 | + } |
|
544 | + $Message_Template->set('MTP_content', $new_content); |
|
545 | + $Message_Template->save(); |
|
546 | + } |
|
547 | + } |
|
548 | + // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
549 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
550 | + ? $this->_req_data['batch_message']['id_type'] |
|
551 | + : 'registration'; |
|
552 | + // id_type will affect how we assemble the ids. |
|
553 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
554 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
555 | + : array(); |
|
556 | + $registrations_used_for_contact_data = array(); |
|
557 | + // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
558 | + switch ($id_type) { |
|
559 | + case 'registration': |
|
560 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
561 | + array( |
|
562 | + array( |
|
563 | + 'REG_ID' => array('IN', $ids), |
|
564 | + ), |
|
565 | + ) |
|
566 | + ); |
|
567 | + break; |
|
568 | + case 'contact': |
|
569 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
570 | + ->get_latest_registration_for_each_of_given_contacts( |
|
571 | + $ids |
|
572 | + ); |
|
573 | + break; |
|
574 | + } |
|
575 | + do_action_ref_array( |
|
576 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
577 | + array( |
|
578 | + $registrations_used_for_contact_data, |
|
579 | + $Message_Template_Group->ID(), |
|
580 | + ) |
|
581 | + ); |
|
582 | + // kept for backward compat, internally we no longer use this action. |
|
583 | + // @deprecated 4.8.36.rc.002 |
|
584 | + $contacts = $id_type === 'registration' |
|
585 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
586 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
587 | + do_action_ref_array( |
|
588 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
589 | + array( |
|
590 | + $contacts, |
|
591 | + $Message_Template_Group->ID(), |
|
592 | + ) |
|
593 | + ); |
|
594 | + } |
|
595 | + $query_args = array( |
|
596 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
597 | + ? $this->_req_data['redirect_back_to'] |
|
598 | + : 'default', |
|
599 | + ); |
|
600 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
601 | + } |
|
602 | 602 | |
603 | 603 | |
604 | - /** |
|
605 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
606 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
607 | - */ |
|
608 | - protected function _registration_reports_js_setup() |
|
609 | - { |
|
610 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
611 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
612 | - } |
|
604 | + /** |
|
605 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
606 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
607 | + */ |
|
608 | + protected function _registration_reports_js_setup() |
|
609 | + { |
|
610 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
611 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
612 | + } |
|
613 | 613 | |
614 | 614 | |
615 | - /** |
|
616 | - * generates Business Reports regarding Registrations |
|
617 | - * |
|
618 | - * @access protected |
|
619 | - * @return void |
|
620 | - * @throws DomainException |
|
621 | - */ |
|
622 | - protected function _registration_reports() |
|
623 | - { |
|
624 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
625 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
626 | - $template_path, |
|
627 | - $this->_reports_template_data, |
|
628 | - true |
|
629 | - ); |
|
630 | - // the final template wrapper |
|
631 | - $this->display_admin_page_with_no_sidebar(); |
|
632 | - } |
|
615 | + /** |
|
616 | + * generates Business Reports regarding Registrations |
|
617 | + * |
|
618 | + * @access protected |
|
619 | + * @return void |
|
620 | + * @throws DomainException |
|
621 | + */ |
|
622 | + protected function _registration_reports() |
|
623 | + { |
|
624 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
625 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
626 | + $template_path, |
|
627 | + $this->_reports_template_data, |
|
628 | + true |
|
629 | + ); |
|
630 | + // the final template wrapper |
|
631 | + $this->display_admin_page_with_no_sidebar(); |
|
632 | + } |
|
633 | 633 | |
634 | 634 | |
635 | - /** |
|
636 | - * Generates Business Report showing total registrations per day. |
|
637 | - * |
|
638 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
639 | - * @return string |
|
640 | - * @throws EE_Error |
|
641 | - * @throws InvalidArgumentException |
|
642 | - * @throws InvalidDataTypeException |
|
643 | - * @throws InvalidInterfaceException |
|
644 | - */ |
|
645 | - private function _registrations_per_day_report($period = '-1 month') |
|
646 | - { |
|
647 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
648 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
649 | - $results = (array) $results; |
|
650 | - $regs = array(); |
|
651 | - $subtitle = ''; |
|
652 | - if ($results) { |
|
653 | - $column_titles = array(); |
|
654 | - $tracker = 0; |
|
655 | - foreach ($results as $result) { |
|
656 | - $report_column_values = array(); |
|
657 | - foreach ($result as $property_name => $property_value) { |
|
658 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
659 | - : (int) $property_value; |
|
660 | - $report_column_values[] = $property_value; |
|
661 | - if ($tracker === 0) { |
|
662 | - if ($property_name === 'Registration_REG_date') { |
|
663 | - $column_titles[] = esc_html__( |
|
664 | - 'Date (only days with registrations are shown)', |
|
665 | - 'event_espresso' |
|
666 | - ); |
|
667 | - } else { |
|
668 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
669 | - } |
|
670 | - } |
|
671 | - } |
|
672 | - $tracker++; |
|
673 | - $regs[] = $report_column_values; |
|
674 | - } |
|
675 | - // make sure the column_titles is pushed to the beginning of the array |
|
676 | - array_unshift($regs, $column_titles); |
|
677 | - // setup the date range. |
|
678 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
679 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
680 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
681 | - $subtitle = sprintf( |
|
682 | - wp_strip_all_tags( |
|
683 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
684 | - ), |
|
685 | - $beginning_date->format('Y-m-d'), |
|
686 | - $ending_date->format('Y-m-d') |
|
687 | - ); |
|
688 | - } |
|
689 | - $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
690 | - $report_params = array( |
|
691 | - 'title' => $report_title, |
|
692 | - 'subtitle' => $subtitle, |
|
693 | - 'id' => $report_ID, |
|
694 | - 'regs' => $regs, |
|
695 | - 'noResults' => empty($regs), |
|
696 | - 'noRegsMsg' => sprintf( |
|
697 | - wp_strip_all_tags( |
|
698 | - __( |
|
699 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
700 | - 'event_espresso' |
|
701 | - ) |
|
702 | - ), |
|
703 | - '<h2>' . $report_title . '</h2><p>', |
|
704 | - '</p>' |
|
705 | - ), |
|
706 | - ); |
|
707 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
708 | - return $report_ID; |
|
709 | - } |
|
635 | + /** |
|
636 | + * Generates Business Report showing total registrations per day. |
|
637 | + * |
|
638 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
639 | + * @return string |
|
640 | + * @throws EE_Error |
|
641 | + * @throws InvalidArgumentException |
|
642 | + * @throws InvalidDataTypeException |
|
643 | + * @throws InvalidInterfaceException |
|
644 | + */ |
|
645 | + private function _registrations_per_day_report($period = '-1 month') |
|
646 | + { |
|
647 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
648 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
649 | + $results = (array) $results; |
|
650 | + $regs = array(); |
|
651 | + $subtitle = ''; |
|
652 | + if ($results) { |
|
653 | + $column_titles = array(); |
|
654 | + $tracker = 0; |
|
655 | + foreach ($results as $result) { |
|
656 | + $report_column_values = array(); |
|
657 | + foreach ($result as $property_name => $property_value) { |
|
658 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
659 | + : (int) $property_value; |
|
660 | + $report_column_values[] = $property_value; |
|
661 | + if ($tracker === 0) { |
|
662 | + if ($property_name === 'Registration_REG_date') { |
|
663 | + $column_titles[] = esc_html__( |
|
664 | + 'Date (only days with registrations are shown)', |
|
665 | + 'event_espresso' |
|
666 | + ); |
|
667 | + } else { |
|
668 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
669 | + } |
|
670 | + } |
|
671 | + } |
|
672 | + $tracker++; |
|
673 | + $regs[] = $report_column_values; |
|
674 | + } |
|
675 | + // make sure the column_titles is pushed to the beginning of the array |
|
676 | + array_unshift($regs, $column_titles); |
|
677 | + // setup the date range. |
|
678 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
679 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
680 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
681 | + $subtitle = sprintf( |
|
682 | + wp_strip_all_tags( |
|
683 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
684 | + ), |
|
685 | + $beginning_date->format('Y-m-d'), |
|
686 | + $ending_date->format('Y-m-d') |
|
687 | + ); |
|
688 | + } |
|
689 | + $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
690 | + $report_params = array( |
|
691 | + 'title' => $report_title, |
|
692 | + 'subtitle' => $subtitle, |
|
693 | + 'id' => $report_ID, |
|
694 | + 'regs' => $regs, |
|
695 | + 'noResults' => empty($regs), |
|
696 | + 'noRegsMsg' => sprintf( |
|
697 | + wp_strip_all_tags( |
|
698 | + __( |
|
699 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
700 | + 'event_espresso' |
|
701 | + ) |
|
702 | + ), |
|
703 | + '<h2>' . $report_title . '</h2><p>', |
|
704 | + '</p>' |
|
705 | + ), |
|
706 | + ); |
|
707 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
708 | + return $report_ID; |
|
709 | + } |
|
710 | 710 | |
711 | 711 | |
712 | - /** |
|
713 | - * Generates Business Report showing total registrations per event. |
|
714 | - * |
|
715 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
716 | - * @return string |
|
717 | - * @throws EE_Error |
|
718 | - * @throws InvalidArgumentException |
|
719 | - * @throws InvalidDataTypeException |
|
720 | - * @throws InvalidInterfaceException |
|
721 | - */ |
|
722 | - private function _registrations_per_event_report($period = '-1 month') |
|
723 | - { |
|
724 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
725 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
726 | - $results = (array) $results; |
|
727 | - $regs = array(); |
|
728 | - $subtitle = ''; |
|
729 | - if ($results) { |
|
730 | - $column_titles = array(); |
|
731 | - $tracker = 0; |
|
732 | - foreach ($results as $result) { |
|
733 | - $report_column_values = array(); |
|
734 | - foreach ($result as $property_name => $property_value) { |
|
735 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
736 | - $property_value, |
|
737 | - 4, |
|
738 | - '...' |
|
739 | - ) : (int) $property_value; |
|
740 | - $report_column_values[] = $property_value; |
|
741 | - if ($tracker === 0) { |
|
742 | - if ($property_name === 'Registration_Event') { |
|
743 | - $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
744 | - } else { |
|
745 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
746 | - } |
|
747 | - } |
|
748 | - } |
|
749 | - $tracker++; |
|
750 | - $regs[] = $report_column_values; |
|
751 | - } |
|
752 | - // make sure the column_titles is pushed to the beginning of the array |
|
753 | - array_unshift($regs, $column_titles); |
|
754 | - // setup the date range. |
|
755 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
756 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
757 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
758 | - $subtitle = sprintf( |
|
759 | - wp_strip_all_tags( |
|
760 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
761 | - ), |
|
762 | - $beginning_date->format('Y-m-d'), |
|
763 | - $ending_date->format('Y-m-d') |
|
764 | - ); |
|
765 | - } |
|
766 | - $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
767 | - $report_params = array( |
|
768 | - 'title' => $report_title, |
|
769 | - 'subtitle' => $subtitle, |
|
770 | - 'id' => $report_ID, |
|
771 | - 'regs' => $regs, |
|
772 | - 'noResults' => empty($regs), |
|
773 | - 'noRegsMsg' => sprintf( |
|
774 | - wp_strip_all_tags( |
|
775 | - __( |
|
776 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
777 | - 'event_espresso' |
|
778 | - ) |
|
779 | - ), |
|
780 | - '<h2>' . $report_title . '</h2><p>', |
|
781 | - '</p>' |
|
782 | - ), |
|
783 | - ); |
|
784 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
785 | - return $report_ID; |
|
786 | - } |
|
712 | + /** |
|
713 | + * Generates Business Report showing total registrations per event. |
|
714 | + * |
|
715 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
716 | + * @return string |
|
717 | + * @throws EE_Error |
|
718 | + * @throws InvalidArgumentException |
|
719 | + * @throws InvalidDataTypeException |
|
720 | + * @throws InvalidInterfaceException |
|
721 | + */ |
|
722 | + private function _registrations_per_event_report($period = '-1 month') |
|
723 | + { |
|
724 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
725 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
726 | + $results = (array) $results; |
|
727 | + $regs = array(); |
|
728 | + $subtitle = ''; |
|
729 | + if ($results) { |
|
730 | + $column_titles = array(); |
|
731 | + $tracker = 0; |
|
732 | + foreach ($results as $result) { |
|
733 | + $report_column_values = array(); |
|
734 | + foreach ($result as $property_name => $property_value) { |
|
735 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
736 | + $property_value, |
|
737 | + 4, |
|
738 | + '...' |
|
739 | + ) : (int) $property_value; |
|
740 | + $report_column_values[] = $property_value; |
|
741 | + if ($tracker === 0) { |
|
742 | + if ($property_name === 'Registration_Event') { |
|
743 | + $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
744 | + } else { |
|
745 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
746 | + } |
|
747 | + } |
|
748 | + } |
|
749 | + $tracker++; |
|
750 | + $regs[] = $report_column_values; |
|
751 | + } |
|
752 | + // make sure the column_titles is pushed to the beginning of the array |
|
753 | + array_unshift($regs, $column_titles); |
|
754 | + // setup the date range. |
|
755 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
756 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
757 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
758 | + $subtitle = sprintf( |
|
759 | + wp_strip_all_tags( |
|
760 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
761 | + ), |
|
762 | + $beginning_date->format('Y-m-d'), |
|
763 | + $ending_date->format('Y-m-d') |
|
764 | + ); |
|
765 | + } |
|
766 | + $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
767 | + $report_params = array( |
|
768 | + 'title' => $report_title, |
|
769 | + 'subtitle' => $subtitle, |
|
770 | + 'id' => $report_ID, |
|
771 | + 'regs' => $regs, |
|
772 | + 'noResults' => empty($regs), |
|
773 | + 'noRegsMsg' => sprintf( |
|
774 | + wp_strip_all_tags( |
|
775 | + __( |
|
776 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
777 | + 'event_espresso' |
|
778 | + ) |
|
779 | + ), |
|
780 | + '<h2>' . $report_title . '</h2><p>', |
|
781 | + '</p>' |
|
782 | + ), |
|
783 | + ); |
|
784 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
785 | + return $report_ID; |
|
786 | + } |
|
787 | 787 | |
788 | 788 | |
789 | - /** |
|
790 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
791 | - * |
|
792 | - * @access protected |
|
793 | - * @return void |
|
794 | - * @throws EE_Error |
|
795 | - * @throws InvalidArgumentException |
|
796 | - * @throws InvalidDataTypeException |
|
797 | - * @throws InvalidInterfaceException |
|
798 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
799 | - */ |
|
800 | - protected function _registration_checkin_list_table() |
|
801 | - { |
|
802 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
803 | - $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
|
804 | - /** @var EE_Registration $registration */ |
|
805 | - $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
806 | - if (! $registration instanceof EE_Registration) { |
|
807 | - throw new EE_Error( |
|
808 | - sprintf( |
|
809 | - esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
810 | - $reg_id |
|
811 | - ) |
|
812 | - ); |
|
813 | - } |
|
814 | - $attendee = $registration->attendee(); |
|
815 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
816 | - 'new_registration', |
|
817 | - 'add-registrant', |
|
818 | - array('event_id' => $registration->event_ID()), |
|
819 | - 'add-new-h2' |
|
820 | - ); |
|
821 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
822 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
823 | - $legend_items = array( |
|
824 | - 'checkin' => array( |
|
825 | - 'class' => $checked_in->cssClasses(), |
|
826 | - 'desc' => $checked_in->legendLabel(), |
|
827 | - ), |
|
828 | - 'checkout' => array( |
|
829 | - 'class' => $checked_out->cssClasses(), |
|
830 | - 'desc' => $checked_out->legendLabel(), |
|
831 | - ), |
|
832 | - ); |
|
833 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
834 | - $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
835 | - /** @var EE_Datetime $datetime */ |
|
836 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
837 | - $datetime_label = ''; |
|
838 | - if ($datetime instanceof EE_Datetime) { |
|
839 | - $datetime_label = $datetime->get_dtt_display_name(true); |
|
840 | - $datetime_label .= ! empty($datetime_label) |
|
841 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
842 | - : $datetime->get_dtt_display_name(); |
|
843 | - } |
|
844 | - $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
845 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
846 | - array( |
|
847 | - 'action' => 'event_registrations', |
|
848 | - 'event_id' => $registration->event_ID(), |
|
849 | - 'DTT_ID' => $dtt_id, |
|
850 | - ), |
|
851 | - $this->_admin_base_url |
|
852 | - ) |
|
853 | - : ''; |
|
854 | - $datetime_link = ! empty($datetime_link) |
|
855 | - ? '<a href="' . $datetime_link . '">' |
|
856 | - . '<span id="checkin-dtt">' |
|
857 | - . $datetime_label |
|
858 | - . '</span></a>' |
|
859 | - : $datetime_label; |
|
860 | - $attendee_name = $attendee instanceof EE_Attendee |
|
861 | - ? $attendee->full_name() |
|
862 | - : ''; |
|
863 | - $attendee_link = $attendee instanceof EE_Attendee |
|
864 | - ? $attendee->get_admin_details_link() |
|
865 | - : ''; |
|
866 | - $attendee_link = ! empty($attendee_link) |
|
867 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
868 | - . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
869 | - . '<span id="checkin-attendee-name">' |
|
870 | - . $attendee_name |
|
871 | - . '</span></a>' |
|
872 | - : ''; |
|
873 | - $event_link = $registration->event() instanceof EE_Event |
|
874 | - ? $registration->event()->get_admin_details_link() |
|
875 | - : ''; |
|
876 | - $event_link = ! empty($event_link) |
|
877 | - ? '<a href="' . $event_link . '"' |
|
878 | - . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
879 | - . '<span id="checkin-event-name">' |
|
880 | - . $registration->event_name() |
|
881 | - . '</span>' |
|
882 | - . '</a>' |
|
883 | - : ''; |
|
884 | - $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
885 | - ? '<h2>' . sprintf( |
|
886 | - esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
887 | - $attendee_link, |
|
888 | - $datetime_link, |
|
889 | - $event_link |
|
890 | - ) . '</h2>' |
|
891 | - : ''; |
|
892 | - $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
893 | - ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
894 | - $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
895 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
896 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
897 | - } |
|
789 | + /** |
|
790 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
791 | + * |
|
792 | + * @access protected |
|
793 | + * @return void |
|
794 | + * @throws EE_Error |
|
795 | + * @throws InvalidArgumentException |
|
796 | + * @throws InvalidDataTypeException |
|
797 | + * @throws InvalidInterfaceException |
|
798 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
799 | + */ |
|
800 | + protected function _registration_checkin_list_table() |
|
801 | + { |
|
802 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
803 | + $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
|
804 | + /** @var EE_Registration $registration */ |
|
805 | + $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
806 | + if (! $registration instanceof EE_Registration) { |
|
807 | + throw new EE_Error( |
|
808 | + sprintf( |
|
809 | + esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
810 | + $reg_id |
|
811 | + ) |
|
812 | + ); |
|
813 | + } |
|
814 | + $attendee = $registration->attendee(); |
|
815 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
816 | + 'new_registration', |
|
817 | + 'add-registrant', |
|
818 | + array('event_id' => $registration->event_ID()), |
|
819 | + 'add-new-h2' |
|
820 | + ); |
|
821 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
822 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
823 | + $legend_items = array( |
|
824 | + 'checkin' => array( |
|
825 | + 'class' => $checked_in->cssClasses(), |
|
826 | + 'desc' => $checked_in->legendLabel(), |
|
827 | + ), |
|
828 | + 'checkout' => array( |
|
829 | + 'class' => $checked_out->cssClasses(), |
|
830 | + 'desc' => $checked_out->legendLabel(), |
|
831 | + ), |
|
832 | + ); |
|
833 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
834 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
835 | + /** @var EE_Datetime $datetime */ |
|
836 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
837 | + $datetime_label = ''; |
|
838 | + if ($datetime instanceof EE_Datetime) { |
|
839 | + $datetime_label = $datetime->get_dtt_display_name(true); |
|
840 | + $datetime_label .= ! empty($datetime_label) |
|
841 | + ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
842 | + : $datetime->get_dtt_display_name(); |
|
843 | + } |
|
844 | + $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
845 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
846 | + array( |
|
847 | + 'action' => 'event_registrations', |
|
848 | + 'event_id' => $registration->event_ID(), |
|
849 | + 'DTT_ID' => $dtt_id, |
|
850 | + ), |
|
851 | + $this->_admin_base_url |
|
852 | + ) |
|
853 | + : ''; |
|
854 | + $datetime_link = ! empty($datetime_link) |
|
855 | + ? '<a href="' . $datetime_link . '">' |
|
856 | + . '<span id="checkin-dtt">' |
|
857 | + . $datetime_label |
|
858 | + . '</span></a>' |
|
859 | + : $datetime_label; |
|
860 | + $attendee_name = $attendee instanceof EE_Attendee |
|
861 | + ? $attendee->full_name() |
|
862 | + : ''; |
|
863 | + $attendee_link = $attendee instanceof EE_Attendee |
|
864 | + ? $attendee->get_admin_details_link() |
|
865 | + : ''; |
|
866 | + $attendee_link = ! empty($attendee_link) |
|
867 | + ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
868 | + . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
869 | + . '<span id="checkin-attendee-name">' |
|
870 | + . $attendee_name |
|
871 | + . '</span></a>' |
|
872 | + : ''; |
|
873 | + $event_link = $registration->event() instanceof EE_Event |
|
874 | + ? $registration->event()->get_admin_details_link() |
|
875 | + : ''; |
|
876 | + $event_link = ! empty($event_link) |
|
877 | + ? '<a href="' . $event_link . '"' |
|
878 | + . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
879 | + . '<span id="checkin-event-name">' |
|
880 | + . $registration->event_name() |
|
881 | + . '</span>' |
|
882 | + . '</a>' |
|
883 | + : ''; |
|
884 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
885 | + ? '<h2>' . sprintf( |
|
886 | + esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
887 | + $attendee_link, |
|
888 | + $datetime_link, |
|
889 | + $event_link |
|
890 | + ) . '</h2>' |
|
891 | + : ''; |
|
892 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
893 | + ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
894 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
895 | + ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
896 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
897 | + } |
|
898 | 898 | |
899 | 899 | |
900 | - /** |
|
901 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
902 | - * |
|
903 | - * @return void (JSON) |
|
904 | - * @throws EE_Error |
|
905 | - * @throws InvalidArgumentException |
|
906 | - * @throws InvalidDataTypeException |
|
907 | - * @throws InvalidInterfaceException |
|
908 | - */ |
|
909 | - public function toggle_checkin_status() |
|
910 | - { |
|
911 | - // first make sure we have the necessary data |
|
912 | - if (! isset($this->_req_data['_regid'])) { |
|
913 | - EE_Error::add_error( |
|
914 | - esc_html__( |
|
915 | - 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
916 | - 'event_espresso' |
|
917 | - ), |
|
918 | - __FILE__, |
|
919 | - __FUNCTION__, |
|
920 | - __LINE__ |
|
921 | - ); |
|
922 | - $this->_template_args['success'] = false; |
|
923 | - $this->_template_args['error'] = true; |
|
924 | - $this->_return_json(); |
|
925 | - }; |
|
926 | - // do a nonce check cause we're not coming in from an normal route here. |
|
927 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
928 | - : ''; |
|
929 | - $nonce_ref = 'checkin_nonce'; |
|
930 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
931 | - // beautiful! Made it this far so let's get the status. |
|
932 | - $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
933 | - // setup new class to return via ajax |
|
934 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
935 | - $this->_template_args['success'] = true; |
|
936 | - $this->_return_json(); |
|
937 | - } |
|
900 | + /** |
|
901 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
902 | + * |
|
903 | + * @return void (JSON) |
|
904 | + * @throws EE_Error |
|
905 | + * @throws InvalidArgumentException |
|
906 | + * @throws InvalidDataTypeException |
|
907 | + * @throws InvalidInterfaceException |
|
908 | + */ |
|
909 | + public function toggle_checkin_status() |
|
910 | + { |
|
911 | + // first make sure we have the necessary data |
|
912 | + if (! isset($this->_req_data['_regid'])) { |
|
913 | + EE_Error::add_error( |
|
914 | + esc_html__( |
|
915 | + 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
916 | + 'event_espresso' |
|
917 | + ), |
|
918 | + __FILE__, |
|
919 | + __FUNCTION__, |
|
920 | + __LINE__ |
|
921 | + ); |
|
922 | + $this->_template_args['success'] = false; |
|
923 | + $this->_template_args['error'] = true; |
|
924 | + $this->_return_json(); |
|
925 | + }; |
|
926 | + // do a nonce check cause we're not coming in from an normal route here. |
|
927 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
928 | + : ''; |
|
929 | + $nonce_ref = 'checkin_nonce'; |
|
930 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
931 | + // beautiful! Made it this far so let's get the status. |
|
932 | + $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
933 | + // setup new class to return via ajax |
|
934 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
935 | + $this->_template_args['success'] = true; |
|
936 | + $this->_return_json(); |
|
937 | + } |
|
938 | 938 | |
939 | 939 | |
940 | - /** |
|
941 | - * handles toggling the checkin status for the registration, |
|
942 | - * |
|
943 | - * @access protected |
|
944 | - * @return int|void |
|
945 | - * @throws EE_Error |
|
946 | - * @throws InvalidArgumentException |
|
947 | - * @throws InvalidDataTypeException |
|
948 | - * @throws InvalidInterfaceException |
|
949 | - */ |
|
950 | - protected function _toggle_checkin_status() |
|
951 | - { |
|
952 | - // first let's get the query args out of the way for the redirect |
|
953 | - $query_args = array( |
|
954 | - 'action' => 'event_registrations', |
|
955 | - 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
956 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
957 | - ); |
|
958 | - $new_status = false; |
|
959 | - // bulk action check in toggle |
|
960 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
961 | - // cycle thru checkboxes |
|
962 | - while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
963 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
964 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
965 | - } |
|
966 | - } elseif (isset($this->_req_data['_regid'])) { |
|
967 | - // coming from ajax request |
|
968 | - $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
969 | - $query_args['DTT_ID'] = $DTT_ID; |
|
970 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
971 | - } else { |
|
972 | - EE_Error::add_error( |
|
973 | - esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
974 | - __FILE__, |
|
975 | - __FUNCTION__, |
|
976 | - __LINE__ |
|
977 | - ); |
|
978 | - } |
|
979 | - if (defined('DOING_AJAX')) { |
|
980 | - return $new_status; |
|
981 | - } |
|
982 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
983 | - } |
|
940 | + /** |
|
941 | + * handles toggling the checkin status for the registration, |
|
942 | + * |
|
943 | + * @access protected |
|
944 | + * @return int|void |
|
945 | + * @throws EE_Error |
|
946 | + * @throws InvalidArgumentException |
|
947 | + * @throws InvalidDataTypeException |
|
948 | + * @throws InvalidInterfaceException |
|
949 | + */ |
|
950 | + protected function _toggle_checkin_status() |
|
951 | + { |
|
952 | + // first let's get the query args out of the way for the redirect |
|
953 | + $query_args = array( |
|
954 | + 'action' => 'event_registrations', |
|
955 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
956 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
957 | + ); |
|
958 | + $new_status = false; |
|
959 | + // bulk action check in toggle |
|
960 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
961 | + // cycle thru checkboxes |
|
962 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
963 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
964 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
965 | + } |
|
966 | + } elseif (isset($this->_req_data['_regid'])) { |
|
967 | + // coming from ajax request |
|
968 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
969 | + $query_args['DTT_ID'] = $DTT_ID; |
|
970 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
971 | + } else { |
|
972 | + EE_Error::add_error( |
|
973 | + esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
974 | + __FILE__, |
|
975 | + __FUNCTION__, |
|
976 | + __LINE__ |
|
977 | + ); |
|
978 | + } |
|
979 | + if (defined('DOING_AJAX')) { |
|
980 | + return $new_status; |
|
981 | + } |
|
982 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
983 | + } |
|
984 | 984 | |
985 | 985 | |
986 | - /** |
|
987 | - * This is toggles a single Check-in for the given registration and datetime. |
|
988 | - * |
|
989 | - * @param int $REG_ID The registration we're toggling |
|
990 | - * @param int $DTT_ID The datetime we're toggling |
|
991 | - * @return int The new status toggled to. |
|
992 | - * @throws EE_Error |
|
993 | - * @throws InvalidArgumentException |
|
994 | - * @throws InvalidDataTypeException |
|
995 | - * @throws InvalidInterfaceException |
|
996 | - */ |
|
997 | - private function _toggle_checkin($REG_ID, $DTT_ID) |
|
998 | - { |
|
999 | - /** @var EE_Registration $REG */ |
|
1000 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
1001 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
1002 | - if ($new_status !== false) { |
|
1003 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
1004 | - } else { |
|
1005 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
1006 | - $new_status = false; |
|
1007 | - } |
|
1008 | - return $new_status; |
|
1009 | - } |
|
986 | + /** |
|
987 | + * This is toggles a single Check-in for the given registration and datetime. |
|
988 | + * |
|
989 | + * @param int $REG_ID The registration we're toggling |
|
990 | + * @param int $DTT_ID The datetime we're toggling |
|
991 | + * @return int The new status toggled to. |
|
992 | + * @throws EE_Error |
|
993 | + * @throws InvalidArgumentException |
|
994 | + * @throws InvalidDataTypeException |
|
995 | + * @throws InvalidInterfaceException |
|
996 | + */ |
|
997 | + private function _toggle_checkin($REG_ID, $DTT_ID) |
|
998 | + { |
|
999 | + /** @var EE_Registration $REG */ |
|
1000 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
1001 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
1002 | + if ($new_status !== false) { |
|
1003 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
1004 | + } else { |
|
1005 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
1006 | + $new_status = false; |
|
1007 | + } |
|
1008 | + return $new_status; |
|
1009 | + } |
|
1010 | 1010 | |
1011 | 1011 | |
1012 | - /** |
|
1013 | - * Takes care of deleting multiple EE_Checkin table rows |
|
1014 | - * |
|
1015 | - * @access protected |
|
1016 | - * @return void |
|
1017 | - * @throws EE_Error |
|
1018 | - * @throws InvalidArgumentException |
|
1019 | - * @throws InvalidDataTypeException |
|
1020 | - * @throws InvalidInterfaceException |
|
1021 | - */ |
|
1022 | - protected function _delete_checkin_rows() |
|
1023 | - { |
|
1024 | - $query_args = array( |
|
1025 | - 'action' => 'registration_checkins', |
|
1026 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1027 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1028 | - ); |
|
1029 | - $errors = 0; |
|
1030 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1031 | - while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1032 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1033 | - $errors++; |
|
1034 | - } |
|
1035 | - } |
|
1036 | - } else { |
|
1037 | - EE_Error::add_error( |
|
1038 | - esc_html__( |
|
1039 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
1040 | - 'event_espresso' |
|
1041 | - ), |
|
1042 | - __FILE__, |
|
1043 | - __FUNCTION__, |
|
1044 | - __LINE__ |
|
1045 | - ); |
|
1046 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1047 | - } |
|
1048 | - if ($errors > 0) { |
|
1049 | - EE_Error::add_error( |
|
1050 | - sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
1051 | - __FILE__, |
|
1052 | - __FUNCTION__, |
|
1053 | - __LINE__ |
|
1054 | - ); |
|
1055 | - } else { |
|
1056 | - EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
1057 | - } |
|
1058 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1059 | - } |
|
1012 | + /** |
|
1013 | + * Takes care of deleting multiple EE_Checkin table rows |
|
1014 | + * |
|
1015 | + * @access protected |
|
1016 | + * @return void |
|
1017 | + * @throws EE_Error |
|
1018 | + * @throws InvalidArgumentException |
|
1019 | + * @throws InvalidDataTypeException |
|
1020 | + * @throws InvalidInterfaceException |
|
1021 | + */ |
|
1022 | + protected function _delete_checkin_rows() |
|
1023 | + { |
|
1024 | + $query_args = array( |
|
1025 | + 'action' => 'registration_checkins', |
|
1026 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1027 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1028 | + ); |
|
1029 | + $errors = 0; |
|
1030 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1031 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1032 | + if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1033 | + $errors++; |
|
1034 | + } |
|
1035 | + } |
|
1036 | + } else { |
|
1037 | + EE_Error::add_error( |
|
1038 | + esc_html__( |
|
1039 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
1040 | + 'event_espresso' |
|
1041 | + ), |
|
1042 | + __FILE__, |
|
1043 | + __FUNCTION__, |
|
1044 | + __LINE__ |
|
1045 | + ); |
|
1046 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1047 | + } |
|
1048 | + if ($errors > 0) { |
|
1049 | + EE_Error::add_error( |
|
1050 | + sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
1051 | + __FILE__, |
|
1052 | + __FUNCTION__, |
|
1053 | + __LINE__ |
|
1054 | + ); |
|
1055 | + } else { |
|
1056 | + EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
1057 | + } |
|
1058 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1059 | + } |
|
1060 | 1060 | |
1061 | 1061 | |
1062 | - /** |
|
1063 | - * Deletes a single EE_Checkin row |
|
1064 | - * |
|
1065 | - * @return void |
|
1066 | - * @throws EE_Error |
|
1067 | - * @throws InvalidArgumentException |
|
1068 | - * @throws InvalidDataTypeException |
|
1069 | - * @throws InvalidInterfaceException |
|
1070 | - */ |
|
1071 | - protected function _delete_checkin_row() |
|
1072 | - { |
|
1073 | - $query_args = array( |
|
1074 | - 'action' => 'registration_checkins', |
|
1075 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1076 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1077 | - ); |
|
1078 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
1079 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1080 | - EE_Error::add_error( |
|
1081 | - esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1082 | - __FILE__, |
|
1083 | - __FUNCTION__, |
|
1084 | - __LINE__ |
|
1085 | - ); |
|
1086 | - } else { |
|
1087 | - EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
1088 | - } |
|
1089 | - } else { |
|
1090 | - EE_Error::add_error( |
|
1091 | - esc_html__( |
|
1092 | - 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1093 | - 'event_espresso' |
|
1094 | - ), |
|
1095 | - __FILE__, |
|
1096 | - __FUNCTION__, |
|
1097 | - __LINE__ |
|
1098 | - ); |
|
1099 | - } |
|
1100 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1101 | - } |
|
1062 | + /** |
|
1063 | + * Deletes a single EE_Checkin row |
|
1064 | + * |
|
1065 | + * @return void |
|
1066 | + * @throws EE_Error |
|
1067 | + * @throws InvalidArgumentException |
|
1068 | + * @throws InvalidDataTypeException |
|
1069 | + * @throws InvalidInterfaceException |
|
1070 | + */ |
|
1071 | + protected function _delete_checkin_row() |
|
1072 | + { |
|
1073 | + $query_args = array( |
|
1074 | + 'action' => 'registration_checkins', |
|
1075 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1076 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1077 | + ); |
|
1078 | + if (! empty($this->_req_data['CHK_ID'])) { |
|
1079 | + if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1080 | + EE_Error::add_error( |
|
1081 | + esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1082 | + __FILE__, |
|
1083 | + __FUNCTION__, |
|
1084 | + __LINE__ |
|
1085 | + ); |
|
1086 | + } else { |
|
1087 | + EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
1088 | + } |
|
1089 | + } else { |
|
1090 | + EE_Error::add_error( |
|
1091 | + esc_html__( |
|
1092 | + 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1093 | + 'event_espresso' |
|
1094 | + ), |
|
1095 | + __FILE__, |
|
1096 | + __FUNCTION__, |
|
1097 | + __LINE__ |
|
1098 | + ); |
|
1099 | + } |
|
1100 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1101 | + } |
|
1102 | 1102 | |
1103 | 1103 | |
1104 | - /** |
|
1105 | - * generates HTML for the Event Registrations List Table |
|
1106 | - * |
|
1107 | - * @access protected |
|
1108 | - * @return void |
|
1109 | - * @throws EE_Error |
|
1110 | - * @throws InvalidArgumentException |
|
1111 | - * @throws InvalidDataTypeException |
|
1112 | - * @throws InvalidInterfaceException |
|
1113 | - */ |
|
1114 | - protected function _event_registrations_list_table() |
|
1115 | - { |
|
1116 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1117 | - $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
1118 | - ? $this->get_action_link_or_button( |
|
1119 | - 'new_registration', |
|
1120 | - 'add-registrant', |
|
1121 | - array('event_id' => $this->_req_data['event_id']), |
|
1122 | - 'add-new-h2', |
|
1123 | - '', |
|
1124 | - false |
|
1125 | - ) |
|
1126 | - : ''; |
|
1127 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1128 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1129 | - $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1130 | - $checkin_invalid = new CheckinStatusDashicon(EE_Checkin::status_invalid); |
|
1131 | - $legend_items = array( |
|
1132 | - 'star-icon' => array( |
|
1133 | - 'class' => 'dashicons dashicons-star-filled gold-icon', |
|
1134 | - 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1135 | - ), |
|
1136 | - 'checkin' => array( |
|
1137 | - 'class' => $checked_in->cssClasses(), |
|
1138 | - 'desc' => $checked_in->legendLabel(), |
|
1139 | - ), |
|
1140 | - 'checkout' => array( |
|
1141 | - 'class' => $checked_out->cssClasses(), |
|
1142 | - 'desc' => $checked_out->legendLabel(), |
|
1143 | - ), |
|
1144 | - 'nocheckinrecord' => array( |
|
1145 | - 'class' => $checked_never->cssClasses(), |
|
1146 | - 'desc' => $checked_never->legendLabel(), |
|
1147 | - ), |
|
1148 | - 'canNotCheckin' => array( |
|
1149 | - 'class' => $checkin_invalid->cssClasses(), |
|
1150 | - 'desc' => $checkin_invalid->legendLabel(), |
|
1151 | - ), |
|
1152 | - 'approved_status' => array( |
|
1153 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved, |
|
1154 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1155 | - ), |
|
1156 | - 'cancelled_status' => array( |
|
1157 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled, |
|
1158 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1159 | - ), |
|
1160 | - 'declined_status' => array( |
|
1161 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined, |
|
1162 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1163 | - ), |
|
1164 | - 'not_approved' => array( |
|
1165 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved, |
|
1166 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1167 | - ), |
|
1168 | - 'pending_status' => array( |
|
1169 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment, |
|
1170 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1171 | - ), |
|
1172 | - 'wait_list' => array( |
|
1173 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list, |
|
1174 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1175 | - ), |
|
1176 | - ); |
|
1177 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1178 | - $event_id = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
1179 | - /** @var EE_Event $event */ |
|
1180 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1181 | - $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
1182 | - ? '<h2> |
|
1104 | + /** |
|
1105 | + * generates HTML for the Event Registrations List Table |
|
1106 | + * |
|
1107 | + * @access protected |
|
1108 | + * @return void |
|
1109 | + * @throws EE_Error |
|
1110 | + * @throws InvalidArgumentException |
|
1111 | + * @throws InvalidDataTypeException |
|
1112 | + * @throws InvalidInterfaceException |
|
1113 | + */ |
|
1114 | + protected function _event_registrations_list_table() |
|
1115 | + { |
|
1116 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1117 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
1118 | + ? $this->get_action_link_or_button( |
|
1119 | + 'new_registration', |
|
1120 | + 'add-registrant', |
|
1121 | + array('event_id' => $this->_req_data['event_id']), |
|
1122 | + 'add-new-h2', |
|
1123 | + '', |
|
1124 | + false |
|
1125 | + ) |
|
1126 | + : ''; |
|
1127 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1128 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1129 | + $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1130 | + $checkin_invalid = new CheckinStatusDashicon(EE_Checkin::status_invalid); |
|
1131 | + $legend_items = array( |
|
1132 | + 'star-icon' => array( |
|
1133 | + 'class' => 'dashicons dashicons-star-filled gold-icon', |
|
1134 | + 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1135 | + ), |
|
1136 | + 'checkin' => array( |
|
1137 | + 'class' => $checked_in->cssClasses(), |
|
1138 | + 'desc' => $checked_in->legendLabel(), |
|
1139 | + ), |
|
1140 | + 'checkout' => array( |
|
1141 | + 'class' => $checked_out->cssClasses(), |
|
1142 | + 'desc' => $checked_out->legendLabel(), |
|
1143 | + ), |
|
1144 | + 'nocheckinrecord' => array( |
|
1145 | + 'class' => $checked_never->cssClasses(), |
|
1146 | + 'desc' => $checked_never->legendLabel(), |
|
1147 | + ), |
|
1148 | + 'canNotCheckin' => array( |
|
1149 | + 'class' => $checkin_invalid->cssClasses(), |
|
1150 | + 'desc' => $checkin_invalid->legendLabel(), |
|
1151 | + ), |
|
1152 | + 'approved_status' => array( |
|
1153 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved, |
|
1154 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1155 | + ), |
|
1156 | + 'cancelled_status' => array( |
|
1157 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled, |
|
1158 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1159 | + ), |
|
1160 | + 'declined_status' => array( |
|
1161 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined, |
|
1162 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1163 | + ), |
|
1164 | + 'not_approved' => array( |
|
1165 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved, |
|
1166 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1167 | + ), |
|
1168 | + 'pending_status' => array( |
|
1169 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment, |
|
1170 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1171 | + ), |
|
1172 | + 'wait_list' => array( |
|
1173 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list, |
|
1174 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1175 | + ), |
|
1176 | + ); |
|
1177 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1178 | + $event_id = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
1179 | + /** @var EE_Event $event */ |
|
1180 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1181 | + $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
1182 | + ? '<h2> |
|
1183 | 1183 | ' . sprintf( |
1184 | - esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1185 | - "<span class='ee-event-name'>{$event->name()}</span>" |
|
1186 | - ) |
|
1187 | - : ''; |
|
1188 | - // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
1189 | - // the event. |
|
1190 | - $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1191 | - $datetime = null; |
|
1192 | - if ($event instanceof EE_Event) { |
|
1193 | - $datetimes_on_event = $event->datetimes(); |
|
1194 | - if (count($datetimes_on_event) === 1) { |
|
1195 | - $datetime = reset($datetimes_on_event); |
|
1196 | - } |
|
1197 | - } |
|
1198 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1199 | - if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1200 | - $active_status = $datetime->get_active_status(); |
|
1201 | - $datetime_status = |
|
1202 | - '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' . |
|
1203 | - esc_attr($active_status) . '">' |
|
1204 | - . EEH_Template::pretty_status($active_status, false, 'sentence') |
|
1205 | - . '</span>'; |
|
1206 | - $this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">'; |
|
1207 | - $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>'; |
|
1208 | - $this->_template_args['before_list_table'] .= $datetime->name(); |
|
1209 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1210 | - $this->_template_args['before_list_table'] .= $datetime_status; |
|
1211 | - $this->_template_args['before_list_table'] .= '</span>'; |
|
1212 | - } |
|
1213 | - $this->_template_args['before_list_table'] .= '</h2>'; |
|
1214 | - // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
1215 | - // column represents |
|
1216 | - if (! $datetime instanceof EE_Datetime) { |
|
1217 | - $this->_template_args['before_list_table'] .= '<h3 class="description">' |
|
1218 | - . esc_html__( |
|
1219 | - 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1220 | - 'event_espresso' |
|
1221 | - ) |
|
1222 | - . '</h3>'; |
|
1223 | - } |
|
1224 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1225 | - } |
|
1184 | + esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1185 | + "<span class='ee-event-name'>{$event->name()}</span>" |
|
1186 | + ) |
|
1187 | + : ''; |
|
1188 | + // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
1189 | + // the event. |
|
1190 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1191 | + $datetime = null; |
|
1192 | + if ($event instanceof EE_Event) { |
|
1193 | + $datetimes_on_event = $event->datetimes(); |
|
1194 | + if (count($datetimes_on_event) === 1) { |
|
1195 | + $datetime = reset($datetimes_on_event); |
|
1196 | + } |
|
1197 | + } |
|
1198 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1199 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1200 | + $active_status = $datetime->get_active_status(); |
|
1201 | + $datetime_status = |
|
1202 | + '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' . |
|
1203 | + esc_attr($active_status) . '">' |
|
1204 | + . EEH_Template::pretty_status($active_status, false, 'sentence') |
|
1205 | + . '</span>'; |
|
1206 | + $this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">'; |
|
1207 | + $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>'; |
|
1208 | + $this->_template_args['before_list_table'] .= $datetime->name(); |
|
1209 | + $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1210 | + $this->_template_args['before_list_table'] .= $datetime_status; |
|
1211 | + $this->_template_args['before_list_table'] .= '</span>'; |
|
1212 | + } |
|
1213 | + $this->_template_args['before_list_table'] .= '</h2>'; |
|
1214 | + // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
1215 | + // column represents |
|
1216 | + if (! $datetime instanceof EE_Datetime) { |
|
1217 | + $this->_template_args['before_list_table'] .= '<h3 class="description">' |
|
1218 | + . esc_html__( |
|
1219 | + 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1220 | + 'event_espresso' |
|
1221 | + ) |
|
1222 | + . '</h3>'; |
|
1223 | + } |
|
1224 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1225 | + } |
|
1226 | 1226 | |
1227 | - /** |
|
1228 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1229 | - * conditions) |
|
1230 | - * |
|
1231 | - * @return void ends the request by a redirect or download |
|
1232 | - */ |
|
1233 | - public function _registrations_checkin_report() |
|
1234 | - { |
|
1235 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1236 | - } |
|
1227 | + /** |
|
1228 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1229 | + * conditions) |
|
1230 | + * |
|
1231 | + * @return void ends the request by a redirect or download |
|
1232 | + */ |
|
1233 | + public function _registrations_checkin_report() |
|
1234 | + { |
|
1235 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1236 | + } |
|
1237 | 1237 | |
1238 | - /** |
|
1239 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1240 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1241 | - * |
|
1242 | - * @param array $request |
|
1243 | - * @param int $per_page |
|
1244 | - * @param bool $count |
|
1245 | - * @return array |
|
1246 | - * @throws EE_Error |
|
1247 | - */ |
|
1248 | - protected function _get_checkin_query_params_from_request( |
|
1249 | - $request, |
|
1250 | - $per_page = 10, |
|
1251 | - $count = false |
|
1252 | - ) { |
|
1253 | - $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
1254 | - // unlike the regular registrations list table, |
|
1255 | - $status_ids_array = apply_filters( |
|
1256 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1257 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1258 | - ); |
|
1259 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1260 | - return $query_params; |
|
1261 | - } |
|
1238 | + /** |
|
1239 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1240 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1241 | + * |
|
1242 | + * @param array $request |
|
1243 | + * @param int $per_page |
|
1244 | + * @param bool $count |
|
1245 | + * @return array |
|
1246 | + * @throws EE_Error |
|
1247 | + */ |
|
1248 | + protected function _get_checkin_query_params_from_request( |
|
1249 | + $request, |
|
1250 | + $per_page = 10, |
|
1251 | + $count = false |
|
1252 | + ) { |
|
1253 | + $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
1254 | + // unlike the regular registrations list table, |
|
1255 | + $status_ids_array = apply_filters( |
|
1256 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1257 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1258 | + ); |
|
1259 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1260 | + return $query_params; |
|
1261 | + } |
|
1262 | 1262 | |
1263 | 1263 | |
1264 | - /** |
|
1265 | - * Gets registrations for an event |
|
1266 | - * |
|
1267 | - * @param int $per_page |
|
1268 | - * @param bool $count whether to return count or data. |
|
1269 | - * @param bool $trash |
|
1270 | - * @param string $orderby |
|
1271 | - * @return EE_Registration[]|int |
|
1272 | - * @throws EE_Error |
|
1273 | - * @throws InvalidArgumentException |
|
1274 | - * @throws InvalidDataTypeException |
|
1275 | - * @throws InvalidInterfaceException |
|
1276 | - */ |
|
1277 | - public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
1278 | - { |
|
1279 | - // normalize some request params that get setup by the parent `get_registrations` method. |
|
1280 | - $request = $this->_req_data; |
|
1281 | - $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
1282 | - $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
1283 | - if ($trash) { |
|
1284 | - $request['status'] = 'trash'; |
|
1285 | - } |
|
1286 | - $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count); |
|
1287 | - /** |
|
1288 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1289 | - * |
|
1290 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1291 | - * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1292 | - * or if you have the development copy of EE you can view this at the path: |
|
1293 | - * /docs/G--Model-System/model-query-params.md |
|
1294 | - */ |
|
1295 | - $query_params['group_by'] = ''; |
|
1264 | + /** |
|
1265 | + * Gets registrations for an event |
|
1266 | + * |
|
1267 | + * @param int $per_page |
|
1268 | + * @param bool $count whether to return count or data. |
|
1269 | + * @param bool $trash |
|
1270 | + * @param string $orderby |
|
1271 | + * @return EE_Registration[]|int |
|
1272 | + * @throws EE_Error |
|
1273 | + * @throws InvalidArgumentException |
|
1274 | + * @throws InvalidDataTypeException |
|
1275 | + * @throws InvalidInterfaceException |
|
1276 | + */ |
|
1277 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
1278 | + { |
|
1279 | + // normalize some request params that get setup by the parent `get_registrations` method. |
|
1280 | + $request = $this->_req_data; |
|
1281 | + $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
1282 | + $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
1283 | + if ($trash) { |
|
1284 | + $request['status'] = 'trash'; |
|
1285 | + } |
|
1286 | + $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count); |
|
1287 | + /** |
|
1288 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1289 | + * |
|
1290 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1291 | + * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1292 | + * or if you have the development copy of EE you can view this at the path: |
|
1293 | + * /docs/G--Model-System/model-query-params.md |
|
1294 | + */ |
|
1295 | + $query_params['group_by'] = ''; |
|
1296 | 1296 | |
1297 | - return $count |
|
1298 | - ? EEM_Registration::instance()->count($query_params) |
|
1299 | - /** @type EE_Registration[] */ |
|
1300 | - : EEM_Registration::instance()->get_all($query_params); |
|
1301 | - } |
|
1297 | + return $count |
|
1298 | + ? EEM_Registration::instance()->count($query_params) |
|
1299 | + /** @type EE_Registration[] */ |
|
1300 | + : EEM_Registration::instance()->get_all($query_params); |
|
1301 | + } |
|
1302 | 1302 | } |
@@ -16,193 +16,193 @@ |
||
16 | 16 | */ |
17 | 17 | class Extend_About_Admin_Page extends About_Admin_Page |
18 | 18 | { |
19 | - public function __construct($routing = true) |
|
20 | - { |
|
21 | - parent::__construct($routing); |
|
22 | - define('EE_ABOUT_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'about/templates/'); |
|
23 | - } |
|
24 | - |
|
25 | - |
|
26 | - protected function _extend_page_config() |
|
27 | - { |
|
28 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'about'; |
|
29 | - } |
|
30 | - |
|
31 | - protected function _set_page_routes() |
|
32 | - { |
|
33 | - $this->_page_routes = array( |
|
34 | - 'default' => array( |
|
35 | - 'func' => '_whats_new', |
|
36 | - 'capability' => 'manage_options', |
|
37 | - ), |
|
38 | - 'overview' => array( |
|
39 | - 'func' => '_overview', |
|
40 | - 'capability' => 'manage_options', |
|
41 | - ), |
|
42 | - 'credits' => array( |
|
43 | - 'func' => '_credits', |
|
44 | - 'capability' => 'manage_options', |
|
45 | - ), |
|
46 | - /*'decafvpro' => array( |
|
19 | + public function __construct($routing = true) |
|
20 | + { |
|
21 | + parent::__construct($routing); |
|
22 | + define('EE_ABOUT_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'about/templates/'); |
|
23 | + } |
|
24 | + |
|
25 | + |
|
26 | + protected function _extend_page_config() |
|
27 | + { |
|
28 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'about'; |
|
29 | + } |
|
30 | + |
|
31 | + protected function _set_page_routes() |
|
32 | + { |
|
33 | + $this->_page_routes = array( |
|
34 | + 'default' => array( |
|
35 | + 'func' => '_whats_new', |
|
36 | + 'capability' => 'manage_options', |
|
37 | + ), |
|
38 | + 'overview' => array( |
|
39 | + 'func' => '_overview', |
|
40 | + 'capability' => 'manage_options', |
|
41 | + ), |
|
42 | + 'credits' => array( |
|
43 | + 'func' => '_credits', |
|
44 | + 'capability' => 'manage_options', |
|
45 | + ), |
|
46 | + /*'decafvpro' => array( |
|
47 | 47 | 'func' => '_decafvpro', |
48 | 48 | 'capability' => 'manage_options' |
49 | 49 | ),*/ |
50 | - 'reviews' => array( |
|
51 | - 'func' => '_reviews', |
|
52 | - 'capability' => 'manage_options', |
|
53 | - ), |
|
54 | - |
|
55 | - |
|
56 | - ); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - protected function _set_page_config() |
|
61 | - { |
|
62 | - $this->_page_config = array( |
|
63 | - 'default' => array( |
|
64 | - 'nav' => array( |
|
65 | - 'label' => esc_html__('What\'s New', 'event_espresso'), |
|
66 | - 'icon' => 'dashicons-bell', |
|
67 | - 'order' => 10, |
|
68 | - ), |
|
69 | - 'require_nonce' => false, |
|
70 | - ), |
|
71 | - 'overview' => array( |
|
72 | - 'nav' => array( |
|
73 | - 'label' => esc_html__('About', 'event_espresso'), |
|
74 | - 'icon' => 'dashicons-info', |
|
75 | - 'order' => 20, |
|
76 | - ), |
|
77 | - 'require_nonce' => false, |
|
78 | - ), |
|
79 | - 'credits' => array( |
|
80 | - 'nav' => array( |
|
81 | - 'label' => esc_html__('Credits', 'event_espresso'), |
|
82 | - 'icon' => 'dashicons-thumbs-up', |
|
83 | - 'order' => 30, |
|
84 | - ), |
|
85 | - 'require_nonce' => false, |
|
86 | - ), |
|
87 | - /*'decafvpro' => array( |
|
50 | + 'reviews' => array( |
|
51 | + 'func' => '_reviews', |
|
52 | + 'capability' => 'manage_options', |
|
53 | + ), |
|
54 | + |
|
55 | + |
|
56 | + ); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + protected function _set_page_config() |
|
61 | + { |
|
62 | + $this->_page_config = array( |
|
63 | + 'default' => array( |
|
64 | + 'nav' => array( |
|
65 | + 'label' => esc_html__('What\'s New', 'event_espresso'), |
|
66 | + 'icon' => 'dashicons-bell', |
|
67 | + 'order' => 10, |
|
68 | + ), |
|
69 | + 'require_nonce' => false, |
|
70 | + ), |
|
71 | + 'overview' => array( |
|
72 | + 'nav' => array( |
|
73 | + 'label' => esc_html__('About', 'event_espresso'), |
|
74 | + 'icon' => 'dashicons-info', |
|
75 | + 'order' => 20, |
|
76 | + ), |
|
77 | + 'require_nonce' => false, |
|
78 | + ), |
|
79 | + 'credits' => array( |
|
80 | + 'nav' => array( |
|
81 | + 'label' => esc_html__('Credits', 'event_espresso'), |
|
82 | + 'icon' => 'dashicons-thumbs-up', |
|
83 | + 'order' => 30, |
|
84 | + ), |
|
85 | + 'require_nonce' => false, |
|
86 | + ), |
|
87 | + /*'decafvpro' => array( |
|
88 | 88 | 'nav' => array( |
89 | 89 | 'label' => esc_html__('Decaf vs Regular', 'event_espresso'), |
90 | 90 | 'order' => 40), |
91 | 91 | 'require_nonce' => FALSE |
92 | 92 | ),*/ |
93 | - 'reviews' => array( |
|
94 | - 'nav' => array( |
|
95 | - 'label' => esc_html__('Reviews', 'event_espresso'), |
|
96 | - 'icon' => 'dashicons-star-filled', |
|
97 | - 'order' => 50, |
|
98 | - ), |
|
99 | - 'require_nonce' => false, |
|
100 | - ), |
|
101 | - |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - protected function _whats_new() |
|
107 | - { |
|
108 | - $steps = EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance |
|
109 | - ? $this->_get_started_steps() : false; |
|
110 | - $steps = $steps !== false ? $steps : ''; |
|
111 | - $this->_admin_page_title = sprintf( |
|
112 | - esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
113 | - EVENT_ESPRESSO_VERSION |
|
114 | - ); |
|
115 | - $settings_message = $steps; |
|
116 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
117 | - 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
118 | - 'event_espresso' |
|
119 | - ) . $settings_message; |
|
120 | - $template = is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php') |
|
121 | - ? EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php' : EE_ABOUT_TEMPLATE_PATH . 'whats_new.template.php'; |
|
122 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
123 | - $template, |
|
124 | - $this->_template_args, |
|
125 | - true |
|
126 | - ); |
|
127 | - $this->display_about_admin_page(); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - protected function _overview() |
|
132 | - { |
|
133 | - $this->_admin_page_title = esc_html__('About Event Espresso', 'event_espresso'); |
|
134 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
135 | - 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
136 | - 'event_espresso' |
|
137 | - ); |
|
138 | - $template = is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php') |
|
139 | - ? EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php' |
|
140 | - : EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php'; |
|
141 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
142 | - $template, |
|
143 | - $this->_template_args, |
|
144 | - true |
|
145 | - ); |
|
146 | - $this->display_about_admin_page(); |
|
147 | - } |
|
148 | - |
|
149 | - protected function _credits() |
|
150 | - { |
|
151 | - // $this->_template_args['admin_page_title'] = sprintf( |
|
152 | - // esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
153 | - // EVENT_ESPRESSO_VERSION |
|
154 | - // ); |
|
155 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
156 | - 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
157 | - 'event_espresso' |
|
158 | - ); |
|
159 | - $template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php'; |
|
160 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
161 | - $template, |
|
162 | - $this->_template_args, |
|
163 | - true |
|
164 | - ); |
|
165 | - $this->display_about_admin_page(); |
|
166 | - } |
|
167 | - |
|
168 | - protected function _decafvpro() |
|
169 | - { |
|
170 | - $this->_template_args['admin_page_title'] = sprintf( |
|
171 | - esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
172 | - EVENT_ESPRESSO_VERSION |
|
173 | - ); |
|
174 | - $this->_template_args['admin_page_subtitle'] = sprintf( |
|
175 | - esc_html__( |
|
176 | - 'Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s', |
|
177 | - 'event_espresso' |
|
178 | - ), |
|
179 | - '<em>', |
|
180 | - '</em>', |
|
181 | - '<strong>', |
|
182 | - '</strong>' |
|
183 | - ); |
|
184 | - $template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php'; |
|
185 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
186 | - $template, |
|
187 | - $this->_template_args, |
|
188 | - true |
|
189 | - ); |
|
190 | - $this->display_about_admin_page(); |
|
191 | - } |
|
192 | - |
|
193 | - protected function _reviews() |
|
194 | - { |
|
195 | - $this->_template_args['admin_page_title'] = esc_html__('Rave Reviews About Event Espresso 4', 'event_espresso'); |
|
196 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
197 | - 'At Event Espresso, customer satisfaction is our ultimate goal.', |
|
198 | - 'event_espresso' |
|
199 | - ); |
|
200 | - $template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php'; |
|
201 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
202 | - $template, |
|
203 | - $this->_template_args, |
|
204 | - true |
|
205 | - ); |
|
206 | - $this->display_about_admin_page(); |
|
207 | - } |
|
93 | + 'reviews' => array( |
|
94 | + 'nav' => array( |
|
95 | + 'label' => esc_html__('Reviews', 'event_espresso'), |
|
96 | + 'icon' => 'dashicons-star-filled', |
|
97 | + 'order' => 50, |
|
98 | + ), |
|
99 | + 'require_nonce' => false, |
|
100 | + ), |
|
101 | + |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + protected function _whats_new() |
|
107 | + { |
|
108 | + $steps = EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance |
|
109 | + ? $this->_get_started_steps() : false; |
|
110 | + $steps = $steps !== false ? $steps : ''; |
|
111 | + $this->_admin_page_title = sprintf( |
|
112 | + esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
113 | + EVENT_ESPRESSO_VERSION |
|
114 | + ); |
|
115 | + $settings_message = $steps; |
|
116 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
117 | + 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
118 | + 'event_espresso' |
|
119 | + ) . $settings_message; |
|
120 | + $template = is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php') |
|
121 | + ? EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php' : EE_ABOUT_TEMPLATE_PATH . 'whats_new.template.php'; |
|
122 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
123 | + $template, |
|
124 | + $this->_template_args, |
|
125 | + true |
|
126 | + ); |
|
127 | + $this->display_about_admin_page(); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + protected function _overview() |
|
132 | + { |
|
133 | + $this->_admin_page_title = esc_html__('About Event Espresso', 'event_espresso'); |
|
134 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
135 | + 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
136 | + 'event_espresso' |
|
137 | + ); |
|
138 | + $template = is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php') |
|
139 | + ? EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php' |
|
140 | + : EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php'; |
|
141 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
142 | + $template, |
|
143 | + $this->_template_args, |
|
144 | + true |
|
145 | + ); |
|
146 | + $this->display_about_admin_page(); |
|
147 | + } |
|
148 | + |
|
149 | + protected function _credits() |
|
150 | + { |
|
151 | + // $this->_template_args['admin_page_title'] = sprintf( |
|
152 | + // esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
153 | + // EVENT_ESPRESSO_VERSION |
|
154 | + // ); |
|
155 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
156 | + 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
157 | + 'event_espresso' |
|
158 | + ); |
|
159 | + $template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php'; |
|
160 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
161 | + $template, |
|
162 | + $this->_template_args, |
|
163 | + true |
|
164 | + ); |
|
165 | + $this->display_about_admin_page(); |
|
166 | + } |
|
167 | + |
|
168 | + protected function _decafvpro() |
|
169 | + { |
|
170 | + $this->_template_args['admin_page_title'] = sprintf( |
|
171 | + esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
172 | + EVENT_ESPRESSO_VERSION |
|
173 | + ); |
|
174 | + $this->_template_args['admin_page_subtitle'] = sprintf( |
|
175 | + esc_html__( |
|
176 | + 'Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s', |
|
177 | + 'event_espresso' |
|
178 | + ), |
|
179 | + '<em>', |
|
180 | + '</em>', |
|
181 | + '<strong>', |
|
182 | + '</strong>' |
|
183 | + ); |
|
184 | + $template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php'; |
|
185 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
186 | + $template, |
|
187 | + $this->_template_args, |
|
188 | + true |
|
189 | + ); |
|
190 | + $this->display_about_admin_page(); |
|
191 | + } |
|
192 | + |
|
193 | + protected function _reviews() |
|
194 | + { |
|
195 | + $this->_template_args['admin_page_title'] = esc_html__('Rave Reviews About Event Espresso 4', 'event_espresso'); |
|
196 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
197 | + 'At Event Espresso, customer satisfaction is our ultimate goal.', |
|
198 | + 'event_espresso' |
|
199 | + ); |
|
200 | + $template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php'; |
|
201 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
202 | + $template, |
|
203 | + $this->_template_args, |
|
204 | + true |
|
205 | + ); |
|
206 | + $this->display_about_admin_page(); |
|
207 | + } |
|
208 | 208 | } |
@@ -2,75 +2,75 @@ discard block |
||
2 | 2 | <div class='padding'> |
3 | 3 | <div class="headline-feature"> |
4 | 4 | <h2 class="about-headline-callout"><?php |
5 | - esc_html_e('Welcome to Event Espresso 4!', 'event_espresso'); ?></h2> |
|
5 | + esc_html_e('Welcome to Event Espresso 4!', 'event_espresso'); ?></h2> |
|
6 | 6 | <p> |
7 | 7 | <?php |
8 | - printf( |
|
9 | - esc_html__( |
|
10 | - 'Manage your events from your WordPress dashboard. Reduce your admin, reduce your costs, make your life easier! This is the Caffeinated/Regular version of Event Espresso, but we also have a hosted version called %sEvent Smart%s for customers that want to cut back on their hosting and security expenses.', |
|
11 | - 'event_espresso' |
|
12 | - ), |
|
13 | - '<a href="https://eventsmart.com//?utm_source=ee4_decaf&utm_medium=link&utm_campaign=espresso_about_tab&utm_content=EE4+Caffeinated">', |
|
14 | - '</a>' |
|
15 | - ); ?> |
|
8 | + printf( |
|
9 | + esc_html__( |
|
10 | + 'Manage your events from your WordPress dashboard. Reduce your admin, reduce your costs, make your life easier! This is the Caffeinated/Regular version of Event Espresso, but we also have a hosted version called %sEvent Smart%s for customers that want to cut back on their hosting and security expenses.', |
|
11 | + 'event_espresso' |
|
12 | + ), |
|
13 | + '<a href="https://eventsmart.com//?utm_source=ee4_decaf&utm_medium=link&utm_campaign=espresso_about_tab&utm_content=EE4+Caffeinated">', |
|
14 | + '</a>' |
|
15 | + ); ?> |
|
16 | 16 | </p> |
17 | 17 | <h2> |
18 | 18 | <?php |
19 | - esc_html_e( |
|
20 | - 'Powering 40,000+ event websites; $100 million in ticket sales per year!', |
|
21 | - 'event_espresso' |
|
22 | - ); ?> |
|
19 | + esc_html_e( |
|
20 | + 'Powering 40,000+ event websites; $100 million in ticket sales per year!', |
|
21 | + 'event_espresso' |
|
22 | + ); ?> |
|
23 | 23 | </h2> |
24 | 24 | <p> |
25 | 25 | <?php |
26 | - printf( |
|
27 | - esc_html__( |
|
28 | - '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 lite version of the plugin provides everything that you need to manage your event using WordPress.', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - '<a href="https://eventespresso.com/?utm_source=wordpress_org&utm_medium=link&utm_campaign=espresso_about_tab&utm_content=EE4+Decaf" rel="nofollow">', |
|
32 | - '</a>' |
|
33 | - ); ?> |
|
26 | + printf( |
|
27 | + esc_html__( |
|
28 | + '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 lite version of the plugin provides everything that you need to manage your event using WordPress.', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + '<a href="https://eventespresso.com/?utm_source=wordpress_org&utm_medium=link&utm_campaign=espresso_about_tab&utm_content=EE4+Decaf" rel="nofollow">', |
|
32 | + '</a>' |
|
33 | + ); ?> |
|
34 | 34 | </p> |
35 | 35 | </div> |
36 | 36 | <div class="feature-section has-3-columns is-fullwidth three-col"> |
37 | 37 | <div class="column col"> |
38 | 38 | <img src="<?php |
39 | - echo EEH_Template::getScreenshotUrl('publish_meta_box'); ?>"> |
|
39 | + echo EEH_Template::getScreenshotUrl('publish_meta_box'); ?>"> |
|
40 | 40 | <h3><?php |
41 | - esc_html_e('Optimized aesthetic', 'event_espresso'); ?></h3> |
|
41 | + esc_html_e('Optimized aesthetic', 'event_espresso'); ?></h3> |
|
42 | 42 | <p> |
43 | 43 | <?php |
44 | - esc_html_e( |
|
45 | - 'The Event Espresso 4 dashboard has a fresh, uncluttered design that embraces clarity and simplicity.', |
|
46 | - 'event_espresso' |
|
47 | - ); ?> |
|
44 | + esc_html_e( |
|
45 | + 'The Event Espresso 4 dashboard has a fresh, uncluttered design that embraces clarity and simplicity.', |
|
46 | + 'event_espresso' |
|
47 | + ); ?> |
|
48 | 48 | </p> |
49 | 49 | </div> |
50 | 50 | <div class="column col"> |
51 | 51 | <img src="<?php |
52 | - echo EEH_Template::getScreenshotUrl('registrations-overview'); ?>"> |
|
52 | + echo EEH_Template::getScreenshotUrl('registrations-overview'); ?>"> |
|
53 | 53 | <h3><?php |
54 | - esc_html_e('Integrated management', 'event_espresso'); ?></h3> |
|
54 | + esc_html_e('Integrated management', 'event_espresso'); ?></h3> |
|
55 | 55 | <p> |
56 | 56 | <?php |
57 | - esc_html_e( |
|
58 | - 'We’ve made it easier to know who your customers are and how they’ve done business with you over time.', |
|
59 | - 'event_espresso' |
|
60 | - ); ?> |
|
57 | + esc_html_e( |
|
58 | + 'We’ve made it easier to know who your customers are and how they’ve done business with you over time.', |
|
59 | + 'event_espresso' |
|
60 | + ); ?> |
|
61 | 61 | </p> |
62 | 62 | </div> |
63 | 63 | <div class="column col last-feature"> |
64 | 64 | <img src="<?php |
65 | - echo EEH_Template::getScreenshotUrl('refined-bookkeeping'); ?>"> |
|
65 | + echo EEH_Template::getScreenshotUrl('refined-bookkeeping'); ?>"> |
|
66 | 66 | <h3><?php |
67 | - esc_html_e('Easy bookkeeping', 'event_espresso'); ?></h3> |
|
67 | + esc_html_e('Easy bookkeeping', 'event_espresso'); ?></h3> |
|
68 | 68 | <p> |
69 | 69 | <?php |
70 | - esc_html_e( |
|
71 | - 'Registrations, payment, and transactions have been substantially improved in Event Espresso 4.', |
|
72 | - 'event_espresso' |
|
73 | - ); ?> |
|
70 | + esc_html_e( |
|
71 | + 'Registrations, payment, and transactions have been substantially improved in Event Espresso 4.', |
|
72 | + 'event_espresso' |
|
73 | + ); ?> |
|
74 | 74 | </p> |
75 | 75 | </div> |
76 | 76 | </div> |
@@ -80,61 +80,61 @@ discard block |
||
80 | 80 | <div class="feature-section has-2-columns is-fullwidth two-col"> |
81 | 81 | <div class="column col"> |
82 | 82 | <h3><?php |
83 | - esc_html_e('Higher customer retention', 'event_espresso'); ?></h3> |
|
83 | + esc_html_e('Higher customer retention', 'event_espresso'); ?></h3> |
|
84 | 84 | <p> |
85 | 85 | <?php |
86 | - esc_html_e( |
|
87 | - 'The Event Espresso 4 registration process is faster than ever. With quick ticket selections, single page check-out, and customizable notifications! Registration that can scale to your business needs.', |
|
88 | - 'event_espresso' |
|
89 | - ); ?> |
|
86 | + esc_html_e( |
|
87 | + 'The Event Espresso 4 registration process is faster than ever. With quick ticket selections, single page check-out, and customizable notifications! Registration that can scale to your business needs.', |
|
88 | + 'event_espresso' |
|
89 | + ); ?> |
|
90 | 90 | </p> |
91 | 91 | <h4><?php |
92 | - esc_html_e('Ticket selection boxes on any post page or post', 'event_espresso'); ?></h4> |
|
92 | + esc_html_e('Ticket selection boxes on any post page or post', 'event_espresso'); ?></h4> |
|
93 | 93 | <p> |
94 | 94 | <?php |
95 | - esc_html_e( |
|
96 | - 'Customers can easily register for classes, events, or conferences, in just a few simple steps. No matter how you use it, Event Espresso 4 will adapt to a multitude of different ticketing and pricing scenarios.', |
|
97 | - 'event_espresso' |
|
98 | - ); ?> |
|
95 | + esc_html_e( |
|
96 | + 'Customers can easily register for classes, events, or conferences, in just a few simple steps. No matter how you use it, Event Espresso 4 will adapt to a multitude of different ticketing and pricing scenarios.', |
|
97 | + 'event_espresso' |
|
98 | + ); ?> |
|
99 | 99 | </p> |
100 | 100 | </div> |
101 | 101 | <div class="column col last-feature about-colors-img"> |
102 | 102 | <img src="<?php |
103 | - echo EEH_Template::getScreenshotUrl('registration-page-large'); ?>"> |
|
103 | + echo EEH_Template::getScreenshotUrl('registration-page-large'); ?>"> |
|
104 | 104 | </div> |
105 | 105 | </div> |
106 | 106 | |
107 | 107 | <div class="feature-section has-2-columns is-fullwidth two-col"> |
108 | 108 | <div class="column col"> |
109 | 109 | <h3><?php |
110 | - esc_html_e('Refined event management', 'event_espresso'); ?></h3> |
|
110 | + esc_html_e('Refined event management', 'event_espresso'); ?></h3> |
|
111 | 111 | <p> |
112 | 112 | <?php |
113 | - esc_html_e( |
|
114 | - 'The new event management screen lets you survey your events at a glance. Want more information? Click to view more. Quickly add/edit prices, dates, or information in any event.', |
|
115 | - 'event_espresso' |
|
116 | - ); ?> |
|
113 | + esc_html_e( |
|
114 | + 'The new event management screen lets you survey your events at a glance. Want more information? Click to view more. Quickly add/edit prices, dates, or information in any event.', |
|
115 | + 'event_espresso' |
|
116 | + ); ?> |
|
117 | 117 | </p> |
118 | 118 | <h4><?php |
119 | - esc_html_e('Smoother price types, taxes, and price modifiers', 'event_espresso'); ?></h4> |
|
119 | + esc_html_e('Smoother price types, taxes, and price modifiers', 'event_espresso'); ?></h4> |
|
120 | 120 | <p> |
121 | 121 | <?php |
122 | - esc_html_e( |
|
123 | - 'Price Types allow you to create new prices that adjust the default ticket (base) price for your system-default ticket', |
|
124 | - 'event_espresso' |
|
125 | - ); ?>. |
|
122 | + esc_html_e( |
|
123 | + 'Price Types allow you to create new prices that adjust the default ticket (base) price for your system-default ticket', |
|
124 | + 'event_espresso' |
|
125 | + ); ?>. |
|
126 | 126 | </p> |
127 | 127 | <p> |
128 | 128 | <?php |
129 | - esc_html_e( |
|
130 | - 'Easily categorize a price modifier and indicate how that price gets applied to the running total when a transaction occurs.', |
|
131 | - 'event_espresso' |
|
132 | - ); ?> |
|
129 | + esc_html_e( |
|
130 | + 'Easily categorize a price modifier and indicate how that price gets applied to the running total when a transaction occurs.', |
|
131 | + 'event_espresso' |
|
132 | + ); ?> |
|
133 | 133 | </p> |
134 | 134 | </div> |
135 | 135 | <div class="column col last-feature about-themes-img"> |
136 | 136 | <img src="<?php |
137 | - echo EEH_Template::getScreenshotUrl('event-management'); ?>"> |
|
137 | + echo EEH_Template::getScreenshotUrl('event-management'); ?>"> |
|
138 | 138 | </div> |
139 | 139 | </div> |
140 | 140 | |
@@ -142,50 +142,50 @@ discard block |
||
142 | 142 | |
143 | 143 | <h2 class="about-headline-callout"> |
144 | 144 | <?php |
145 | - esc_html_e( |
|
146 | - 'People Like You Manage Event Registration with WordPress', |
|
147 | - 'event_espresso' |
|
148 | - ); ?> |
|
145 | + esc_html_e( |
|
146 | + 'People Like You Manage Event Registration with WordPress', |
|
147 | + 'event_espresso' |
|
148 | + ); ?> |
|
149 | 149 | </h2> |
150 | 150 | <div class="feature-section has-2-columns is-fullwidth two-col"> |
151 | 151 | <div class="column col"> |
152 | 152 | <p> |
153 | 153 | <?php |
154 | - printf( |
|
155 | - esc_html__( |
|
156 | - '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.', |
|
157 | - 'event_espresso' |
|
158 | - ), |
|
159 | - '<strong>', |
|
160 | - '</strong>' |
|
161 | - ); ?> |
|
154 | + printf( |
|
155 | + esc_html__( |
|
156 | + '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.', |
|
157 | + 'event_espresso' |
|
158 | + ), |
|
159 | + '<strong>', |
|
160 | + '</strong>' |
|
161 | + ); ?> |
|
162 | 162 | </p> |
163 | 163 | <p> |
164 | 164 | <?php |
165 | - esc_html_e( |
|
166 | - 'Event Espresso works perfectly for classes, workshops, fundraisers, sporting, trainings, conferences, networking, religion, social, non-profit, and nearly any other type of event.', |
|
167 | - 'event_espresso' |
|
168 | - ); ?> |
|
165 | + esc_html_e( |
|
166 | + 'Event Espresso works perfectly for classes, workshops, fundraisers, sporting, trainings, conferences, networking, religion, social, non-profit, and nearly any other type of event.', |
|
167 | + 'event_espresso' |
|
168 | + ); ?> |
|
169 | 169 | </p> |
170 | 170 | </div> |
171 | 171 | <div class="column col"> |
172 | 172 | <p> |
173 | 173 | <?php |
174 | - printf( |
|
175 | - esc_html__( |
|
176 | - '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.', |
|
177 | - 'event_espresso' |
|
178 | - ), |
|
179 | - '<strong>', |
|
180 | - '</strong>' |
|
181 | - ); ?> |
|
174 | + printf( |
|
175 | + esc_html__( |
|
176 | + '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.', |
|
177 | + 'event_espresso' |
|
178 | + ), |
|
179 | + '<strong>', |
|
180 | + '</strong>' |
|
181 | + ); ?> |
|
182 | 182 | </p> |
183 | 183 | <p> |
184 | 184 | <?php |
185 | - esc_html_e( |
|
186 | - '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.', |
|
187 | - 'event_espresso' |
|
188 | - ); ?> |
|
185 | + esc_html_e( |
|
186 | + '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.', |
|
187 | + 'event_espresso' |
|
188 | + ); ?> |
|
189 | 189 | </p> |
190 | 190 | </div> |
191 | 191 | </div> |
@@ -194,37 +194,37 @@ discard block |
||
194 | 194 | <div class="column col"> |
195 | 195 | <h3> |
196 | 196 | <?php |
197 | - esc_html_e( |
|
198 | - 'Turn your blog into a complete event registration and management system', |
|
199 | - 'event_espresso' |
|
200 | - ); ?> |
|
197 | + esc_html_e( |
|
198 | + 'Turn your blog into a complete event registration and management system', |
|
199 | + 'event_espresso' |
|
200 | + ); ?> |
|
201 | 201 | </h3> |
202 | 202 | <p> |
203 | 203 | <?php |
204 | - esc_html_e( |
|
205 | - '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!', |
|
206 | - 'event_espresso' |
|
207 | - ); ?> |
|
204 | + esc_html_e( |
|
205 | + '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!', |
|
206 | + 'event_espresso' |
|
207 | + ); ?> |
|
208 | 208 | </p> |
209 | 209 | <p> |
210 | 210 | <?php |
211 | - esc_html_e( |
|
212 | - '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.', |
|
213 | - 'event_espresso' |
|
214 | - ); ?> |
|
211 | + esc_html_e( |
|
212 | + '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.', |
|
213 | + 'event_espresso' |
|
214 | + ); ?> |
|
215 | 215 | </p> |
216 | 216 | <p> |
217 | 217 | <?php |
218 | - echo sprintf( |
|
219 | - esc_html__('%sLearn more >>%s', 'event_espresso'), |
|
220 | - '<a href="https://eventespresso.com/wiki/setup-event-espresso-arabica-theme/">', |
|
221 | - '</a>' |
|
222 | - ); ?> |
|
218 | + echo sprintf( |
|
219 | + esc_html__('%sLearn more >>%s', 'event_espresso'), |
|
220 | + '<a href="https://eventespresso.com/wiki/setup-event-espresso-arabica-theme/">', |
|
221 | + '</a>' |
|
222 | + ); ?> |
|
223 | 223 | </p> |
224 | 224 | </div> |
225 | 225 | <div class="column col"> |
226 | 226 | <img src="<?php |
227 | - echo EEH_Template::getScreenshotUrl('single-event-page'); ?>"> |
|
227 | + echo EEH_Template::getScreenshotUrl('single-event-page'); ?>"> |
|
228 | 228 | </div> |
229 | 229 | </div> |
230 | 230 | |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | |
233 | 233 | <h2 class="about-headline-callout"> |
234 | 234 | <?php |
235 | - esc_html_e('Pick a theme, any theme', 'event_espresso'); ?> |
|
235 | + esc_html_e('Pick a theme, any theme', 'event_espresso'); ?> |
|
236 | 236 | </h2> |
237 | 237 | <div class="feature-section has-1-column is-fullwidth is-wide one-col"> |
238 | 238 | <div class="column col"> |
239 | 239 | <p><?php |
240 | - esc_html_e( |
|
241 | - 'We’ve made it super easy to integrate Event Espresso with almost any properly coded WordPress theme, including many of the thousands of themes available on WordPress.org. The image below shows the same Event Espresso ticketing page across three diffrent WordPress themes.', |
|
242 | - 'event_espresso' |
|
243 | - ); ?></p> |
|
240 | + esc_html_e( |
|
241 | + 'We’ve made it super easy to integrate Event Espresso with almost any properly coded WordPress theme, including many of the thousands of themes available on WordPress.org. The image below shows the same Event Espresso ticketing page across three diffrent WordPress themes.', |
|
242 | + 'event_espresso' |
|
243 | + ); ?></p> |
|
244 | 244 | <p> |
245 | 245 | <img class="about-overview-img" |
246 | 246 | src="<?php |
247 | - echo EEH_Template::getScreenshotUrl('multiple-themes'); ?>" |
|
247 | + echo EEH_Template::getScreenshotUrl('multiple-themes'); ?>" |
|
248 | 248 | /> |
249 | 249 | </p> |
250 | 250 | </div> |
@@ -11,72 +11,72 @@ |
||
11 | 11 | */ |
12 | 12 | class Extend_Support_Admin_Page extends Support_Admin_Page |
13 | 13 | { |
14 | - public function __construct($routing = true) |
|
15 | - { |
|
16 | - parent::__construct($routing); |
|
17 | - define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'support/templates/'); |
|
18 | - } |
|
14 | + public function __construct($routing = true) |
|
15 | + { |
|
16 | + parent::__construct($routing); |
|
17 | + define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'support/templates/'); |
|
18 | + } |
|
19 | 19 | |
20 | 20 | |
21 | - protected function _extend_page_config() |
|
22 | - { |
|
23 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'support'; |
|
24 | - // new routes and new configs (or overrides ) |
|
25 | - $new_page_routes = array( |
|
26 | - 'faq' => array( |
|
27 | - 'func' => '_faq', |
|
28 | - 'capability' => 'ee_read_ee', |
|
29 | - ), |
|
30 | - ); |
|
31 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
32 | - $new_page_config = array( |
|
33 | - 'faq' => array( |
|
34 | - 'nav' => array( |
|
35 | - 'label' => esc_html__('FAQ', 'event_espresso'), |
|
36 | - 'icon' => 'dashicons-editor-help', |
|
37 | - 'order' => 40, |
|
38 | - ), |
|
39 | - 'metaboxes' => array('_espresso_news_post_box', '_espresso_links_post_box'), |
|
40 | - 'require_nonce' => false, |
|
41 | - ), |
|
42 | - ); |
|
43 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
44 | - $this->_page_config['default']['metaboxes'][] = '_installation_boxes'; |
|
45 | - } |
|
21 | + protected function _extend_page_config() |
|
22 | + { |
|
23 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'support'; |
|
24 | + // new routes and new configs (or overrides ) |
|
25 | + $new_page_routes = array( |
|
26 | + 'faq' => array( |
|
27 | + 'func' => '_faq', |
|
28 | + 'capability' => 'ee_read_ee', |
|
29 | + ), |
|
30 | + ); |
|
31 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
32 | + $new_page_config = array( |
|
33 | + 'faq' => array( |
|
34 | + 'nav' => array( |
|
35 | + 'label' => esc_html__('FAQ', 'event_espresso'), |
|
36 | + 'icon' => 'dashicons-editor-help', |
|
37 | + 'order' => 40, |
|
38 | + ), |
|
39 | + 'metaboxes' => array('_espresso_news_post_box', '_espresso_links_post_box'), |
|
40 | + 'require_nonce' => false, |
|
41 | + ), |
|
42 | + ); |
|
43 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
44 | + $this->_page_config['default']['metaboxes'][] = '_installation_boxes'; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - protected function _faq() |
|
49 | - { |
|
50 | - $template_path = EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH . 'support_admin_details_faq.template.php'; |
|
51 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
52 | - $template_path, |
|
53 | - '', |
|
54 | - true |
|
55 | - ); |
|
56 | - $this->display_admin_page_with_sidebar(); |
|
57 | - } |
|
48 | + protected function _faq() |
|
49 | + { |
|
50 | + $template_path = EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH . 'support_admin_details_faq.template.php'; |
|
51 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
52 | + $template_path, |
|
53 | + '', |
|
54 | + true |
|
55 | + ); |
|
56 | + $this->display_admin_page_with_sidebar(); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - protected function _installation_boxes() |
|
61 | - { |
|
62 | - $callback_args = array( |
|
63 | - 'template_path' => EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH |
|
64 | - . 'support_admin_details_additional_information.template.php', |
|
65 | - ); |
|
66 | - $this->addMetaBox( |
|
67 | - 'espresso_additional_information_support', |
|
68 | - esc_html__('Additional Information', 'event_espresso'), |
|
69 | - function ($post, $metabox) { |
|
70 | - echo EEH_Template::display_template( |
|
71 | - $metabox['args']['template_path'], |
|
72 | - '', |
|
73 | - true |
|
74 | - ); |
|
75 | - }, |
|
76 | - $this->_current_screen->id, |
|
77 | - 'normal', |
|
78 | - 'high', |
|
79 | - $callback_args |
|
80 | - ); |
|
81 | - } |
|
60 | + protected function _installation_boxes() |
|
61 | + { |
|
62 | + $callback_args = array( |
|
63 | + 'template_path' => EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH |
|
64 | + . 'support_admin_details_additional_information.template.php', |
|
65 | + ); |
|
66 | + $this->addMetaBox( |
|
67 | + 'espresso_additional_information_support', |
|
68 | + esc_html__('Additional Information', 'event_espresso'), |
|
69 | + function ($post, $metabox) { |
|
70 | + echo EEH_Template::display_template( |
|
71 | + $metabox['args']['template_path'], |
|
72 | + '', |
|
73 | + true |
|
74 | + ); |
|
75 | + }, |
|
76 | + $this->_current_screen->id, |
|
77 | + 'normal', |
|
78 | + 'high', |
|
79 | + $callback_args |
|
80 | + ); |
|
81 | + } |
|
82 | 82 | } |
@@ -11,1289 +11,1289 @@ |
||
11 | 11 | */ |
12 | 12 | class Pricing_Admin_Page extends EE_Admin_Page |
13 | 13 | { |
14 | - protected function _init_page_props() |
|
15 | - { |
|
16 | - $this->page_slug = PRICING_PG_SLUG; |
|
17 | - $this->page_label = PRICING_LABEL; |
|
18 | - $this->_admin_base_url = PRICING_ADMIN_URL; |
|
19 | - $this->_admin_base_path = PRICING_ADMIN; |
|
20 | - } |
|
21 | - |
|
22 | - |
|
23 | - protected function _ajax_hooks() |
|
24 | - { |
|
25 | - add_action('wp_ajax_espresso_update_prices_order', [$this, 'update_price_order']); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - protected function _define_page_props() |
|
30 | - { |
|
31 | - $this->_admin_page_title = PRICING_LABEL; |
|
32 | - $this->_labels = [ |
|
33 | - 'buttons' => [ |
|
34 | - 'add' => esc_html__('Add New Default Price', 'event_espresso'), |
|
35 | - 'edit' => esc_html__('Edit Default Price', 'event_espresso'), |
|
36 | - 'delete' => esc_html__('Delete Default Price', 'event_espresso'), |
|
37 | - 'add_type' => esc_html__('Add New Default Price Type', 'event_espresso'), |
|
38 | - 'edit_type' => esc_html__('Edit Price Type', 'event_espresso'), |
|
39 | - 'delete_type' => esc_html__('Delete Price Type', 'event_espresso'), |
|
40 | - ], |
|
41 | - ]; |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * an array for storing request actions and their corresponding methods |
|
47 | - * |
|
48 | - * @return void |
|
49 | - */ |
|
50 | - protected function _set_page_routes() |
|
51 | - { |
|
52 | - $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER); |
|
53 | - $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
54 | - $this->_page_routes = [ |
|
55 | - 'default' => [ |
|
56 | - 'func' => '_price_overview_list_table', |
|
57 | - 'capability' => 'ee_read_default_prices', |
|
58 | - ], |
|
59 | - 'add_new_price' => [ |
|
60 | - 'func' => '_edit_price_details', |
|
61 | - // 'args' => ['new_price' => true], |
|
62 | - 'capability' => 'ee_edit_default_prices', |
|
63 | - ], |
|
64 | - 'edit_price' => [ |
|
65 | - 'func' => '_edit_price_details', |
|
66 | - // 'args' => ['new_price' => false], |
|
67 | - 'capability' => 'ee_edit_default_price', |
|
68 | - 'obj_id' => $PRC_ID, |
|
69 | - ], |
|
70 | - 'insert_price' => [ |
|
71 | - 'func' => '_insert_or_update_price', |
|
72 | - 'args' => ['insert' => true], |
|
73 | - 'noheader' => true, |
|
74 | - 'capability' => 'ee_edit_default_prices', |
|
75 | - ], |
|
76 | - 'update_price' => [ |
|
77 | - 'func' => '_insert_or_update_price', |
|
78 | - 'args' => ['insert' => false], |
|
79 | - 'noheader' => true, |
|
80 | - 'capability' => 'ee_edit_default_price', |
|
81 | - 'obj_id' => $PRC_ID, |
|
82 | - ], |
|
83 | - 'trash_price' => [ |
|
84 | - 'func' => '_trash_or_restore_price', |
|
85 | - 'args' => ['trash' => true], |
|
86 | - 'noheader' => true, |
|
87 | - 'capability' => 'ee_delete_default_price', |
|
88 | - 'obj_id' => $PRC_ID, |
|
89 | - ], |
|
90 | - 'restore_price' => [ |
|
91 | - 'func' => '_trash_or_restore_price', |
|
92 | - 'args' => ['trash' => false], |
|
93 | - 'noheader' => true, |
|
94 | - 'capability' => 'ee_delete_default_price', |
|
95 | - 'obj_id' => $PRC_ID, |
|
96 | - ], |
|
97 | - 'delete_price' => [ |
|
98 | - 'func' => '_delete_price', |
|
99 | - 'noheader' => true, |
|
100 | - 'capability' => 'ee_delete_default_price', |
|
101 | - 'obj_id' => $PRC_ID, |
|
102 | - ], |
|
103 | - 'espresso_update_price_order' => [ |
|
104 | - 'func' => 'update_price_order', |
|
105 | - 'noheader' => true, |
|
106 | - 'capability' => 'ee_edit_default_prices', |
|
107 | - ], |
|
108 | - // price types |
|
109 | - 'price_types' => [ |
|
110 | - 'func' => '_price_types_overview_list_table', |
|
111 | - 'capability' => 'ee_read_default_price_types', |
|
112 | - ], |
|
113 | - 'add_new_price_type' => [ |
|
114 | - 'func' => '_edit_price_type_details', |
|
115 | - 'capability' => 'ee_edit_default_price_types', |
|
116 | - ], |
|
117 | - 'edit_price_type' => [ |
|
118 | - 'func' => '_edit_price_type_details', |
|
119 | - 'capability' => 'ee_edit_default_price_type', |
|
120 | - 'obj_id' => $PRT_ID, |
|
121 | - ], |
|
122 | - 'insert_price_type' => [ |
|
123 | - 'func' => '_insert_or_update_price_type', |
|
124 | - 'args' => ['new_price_type' => true], |
|
125 | - 'noheader' => true, |
|
126 | - 'capability' => 'ee_edit_default_price_types', |
|
127 | - ], |
|
128 | - 'update_price_type' => [ |
|
129 | - 'func' => '_insert_or_update_price_type', |
|
130 | - 'args' => ['new_price_type' => false], |
|
131 | - 'noheader' => true, |
|
132 | - 'capability' => 'ee_edit_default_price_type', |
|
133 | - 'obj_id' => $PRT_ID, |
|
134 | - ], |
|
135 | - 'trash_price_type' => [ |
|
136 | - 'func' => '_trash_or_restore_price_type', |
|
137 | - 'args' => ['trash' => true], |
|
138 | - 'noheader' => true, |
|
139 | - 'capability' => 'ee_delete_default_price_type', |
|
140 | - 'obj_id' => $PRT_ID, |
|
141 | - ], |
|
142 | - 'restore_price_type' => [ |
|
143 | - 'func' => '_trash_or_restore_price_type', |
|
144 | - 'args' => ['trash' => false], |
|
145 | - 'noheader' => true, |
|
146 | - 'capability' => 'ee_delete_default_price_type', |
|
147 | - 'obj_id' => $PRT_ID, |
|
148 | - ], |
|
149 | - 'delete_price_type' => [ |
|
150 | - 'func' => '_delete_price_type', |
|
151 | - 'noheader' => true, |
|
152 | - 'capability' => 'ee_delete_default_price_type', |
|
153 | - 'obj_id' => $PRT_ID, |
|
154 | - ], |
|
155 | - 'tax_settings' => [ |
|
156 | - 'func' => '_tax_settings', |
|
157 | - 'capability' => 'manage_options', |
|
158 | - ], |
|
159 | - 'update_tax_settings' => [ |
|
160 | - 'func' => '_update_tax_settings', |
|
161 | - 'capability' => 'manage_options', |
|
162 | - 'noheader' => true, |
|
163 | - ], |
|
164 | - ]; |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - protected function _set_page_config() |
|
169 | - { |
|
170 | - $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
171 | - $this->_page_config = [ |
|
172 | - 'default' => [ |
|
173 | - 'nav' => [ |
|
174 | - 'label' => esc_html__('Default Pricing', 'event_espresso'), |
|
175 | - 'icon' => 'dashicons-money-alt', |
|
176 | - 'order' => 10, |
|
177 | - ], |
|
178 | - 'list_table' => 'Prices_List_Table', |
|
179 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
180 | - 'help_tabs' => [ |
|
181 | - 'pricing_default_pricing_help_tab' => [ |
|
182 | - 'title' => esc_html__('Default Pricing', 'event_espresso'), |
|
183 | - 'filename' => 'pricing_default_pricing', |
|
184 | - ], |
|
185 | - 'pricing_default_pricing_table_column_headings_help_tab' => [ |
|
186 | - 'title' => esc_html__('Default Pricing Table Column Headings', 'event_espresso'), |
|
187 | - 'filename' => 'pricing_default_pricing_table_column_headings', |
|
188 | - ], |
|
189 | - 'pricing_default_pricing_views_bulk_actions_search_help_tab' => [ |
|
190 | - 'title' => esc_html__('Default Pricing Views & Bulk Actions & Search', 'event_espresso'), |
|
191 | - 'filename' => 'pricing_default_pricing_views_bulk_actions_search', |
|
192 | - ], |
|
193 | - ], |
|
194 | - 'require_nonce' => false, |
|
195 | - ], |
|
196 | - 'add_new_price' => [ |
|
197 | - 'nav' => [ |
|
198 | - 'label' => esc_html__('Add New Default Price', 'event_espresso'), |
|
199 | - 'icon' => 'dashicons-plus-alt', |
|
200 | - 'order' => 20, |
|
201 | - 'persistent' => false, |
|
202 | - ], |
|
203 | - 'help_tabs' => [ |
|
204 | - 'add_new_default_price_help_tab' => [ |
|
205 | - 'title' => esc_html__('Add New Default Price', 'event_espresso'), |
|
206 | - 'filename' => 'pricing_add_new_default_price', |
|
207 | - ], |
|
208 | - ], |
|
209 | - 'metaboxes' => array_merge( |
|
210 | - ['_publish_post_box'], |
|
211 | - $this->_default_espresso_metaboxes |
|
212 | - ), |
|
213 | - 'require_nonce' => false, |
|
214 | - ], |
|
215 | - 'edit_price' => [ |
|
216 | - 'nav' => [ |
|
217 | - 'label' => esc_html__('Edit Default Price', 'event_espresso'), |
|
218 | - 'icon' => 'dashicons-edit-large', |
|
219 | - 'order' => 20, |
|
220 | - 'url' => $PRC_ID |
|
221 | - ? add_query_arg(['id' => $PRC_ID], $this->_current_page_view_url) |
|
222 | - : $this->_admin_base_url, |
|
223 | - 'persistent' => false, |
|
224 | - ], |
|
225 | - 'metaboxes' => array_merge( |
|
226 | - ['_publish_post_box'], |
|
227 | - $this->_default_espresso_metaboxes |
|
228 | - ), |
|
229 | - 'help_tabs' => [ |
|
230 | - 'edit_default_price_help_tab' => [ |
|
231 | - 'title' => esc_html__('Edit Default Price', 'event_espresso'), |
|
232 | - 'filename' => 'pricing_edit_default_price', |
|
233 | - ], |
|
234 | - ], |
|
235 | - 'require_nonce' => false, |
|
236 | - ], |
|
237 | - 'price_types' => [ |
|
238 | - 'nav' => [ |
|
239 | - 'label' => esc_html__('Price Types', 'event_espresso'), |
|
240 | - 'icon' => 'dashicons-networking', |
|
241 | - 'order' => 30, |
|
242 | - ], |
|
243 | - 'list_table' => 'Price_Types_List_Table', |
|
244 | - 'help_tabs' => [ |
|
245 | - 'pricing_price_types_help_tab' => [ |
|
246 | - 'title' => esc_html__('Price Types', 'event_espresso'), |
|
247 | - 'filename' => 'pricing_price_types', |
|
248 | - ], |
|
249 | - 'pricing_price_types_table_column_headings_help_tab' => [ |
|
250 | - 'title' => esc_html__('Price Types Table Column Headings', 'event_espresso'), |
|
251 | - 'filename' => 'pricing_price_types_table_column_headings', |
|
252 | - ], |
|
253 | - 'pricing_price_types_views_bulk_actions_search_help_tab' => [ |
|
254 | - 'title' => esc_html__('Price Types Views & Bulk Actions & Search', 'event_espresso'), |
|
255 | - 'filename' => 'pricing_price_types_views_bulk_actions_search', |
|
256 | - ], |
|
257 | - ], |
|
258 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
259 | - 'require_nonce' => false, |
|
260 | - ], |
|
261 | - 'add_new_price_type' => [ |
|
262 | - 'nav' => [ |
|
263 | - 'label' => esc_html__('Add New Price Type', 'event_espresso'), |
|
264 | - 'icon' => 'dashicons-plus-alt', |
|
265 | - 'order' => 40, |
|
266 | - 'persistent' => false, |
|
267 | - ], |
|
268 | - 'help_tabs' => [ |
|
269 | - 'add_new_price_type_help_tab' => [ |
|
270 | - 'title' => esc_html__('Add New Price Type', 'event_espresso'), |
|
271 | - 'filename' => 'pricing_add_new_price_type', |
|
272 | - ], |
|
273 | - ], |
|
274 | - 'metaboxes' => array_merge( |
|
275 | - ['_publish_post_box'], |
|
276 | - $this->_default_espresso_metaboxes |
|
277 | - ), |
|
278 | - 'require_nonce' => false, |
|
279 | - ], |
|
280 | - 'edit_price_type' => [ |
|
281 | - 'nav' => [ |
|
282 | - 'label' => esc_html__('Edit Price Type', 'event_espresso'), |
|
283 | - 'icon' => 'dashicons-edit-large', |
|
284 | - 'order' => 40, |
|
285 | - 'persistent' => false, |
|
286 | - ], |
|
287 | - 'help_tabs' => [ |
|
288 | - 'edit_price_type_help_tab' => [ |
|
289 | - 'title' => esc_html__('Edit Price Type', 'event_espresso'), |
|
290 | - 'filename' => 'pricing_edit_price_type', |
|
291 | - ], |
|
292 | - ], |
|
293 | - 'metaboxes' => array_merge( |
|
294 | - ['_publish_post_box'], |
|
295 | - $this->_default_espresso_metaboxes |
|
296 | - ), |
|
297 | - 'require_nonce' => false, |
|
298 | - ], |
|
299 | - 'tax_settings' => [ |
|
300 | - 'nav' => [ |
|
301 | - 'label' => esc_html__('Tax Settings', 'event_espresso'), |
|
302 | - 'icon' => 'dashicons-sticky', |
|
303 | - 'order' => 50, |
|
304 | - ], |
|
305 | - 'labels' => [ |
|
306 | - 'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'), |
|
307 | - ], |
|
308 | - 'metaboxes' => array_merge( |
|
309 | - ['_publish_post_box'], |
|
310 | - $this->_default_espresso_metaboxes |
|
311 | - ), |
|
312 | - 'require_nonce' => true, |
|
313 | - ], |
|
314 | - ]; |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - protected function _add_screen_options() |
|
319 | - { |
|
320 | - // todo |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - protected function _add_screen_options_default() |
|
325 | - { |
|
326 | - $this->_per_page_screen_option(); |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - protected function _add_screen_options_price_types() |
|
331 | - { |
|
332 | - $page_title = $this->_admin_page_title; |
|
333 | - $this->_admin_page_title = esc_html__('Price Types', 'event_espresso'); |
|
334 | - $this->_per_page_screen_option(); |
|
335 | - $this->_admin_page_title = $page_title; |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - protected function _add_feature_pointers() |
|
340 | - { |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - public function load_scripts_styles() |
|
345 | - { |
|
346 | - // styles |
|
347 | - wp_enqueue_style('espresso-ui-theme'); |
|
348 | - wp_register_style( |
|
349 | - 'espresso_PRICING', |
|
350 | - PRICING_ASSETS_URL . 'espresso_pricing_admin.css', |
|
351 | - [], |
|
352 | - EVENT_ESPRESSO_VERSION |
|
353 | - ); |
|
354 | - wp_enqueue_style('espresso_PRICING'); |
|
355 | - |
|
356 | - // scripts |
|
357 | - wp_enqueue_script('ee_admin_js'); |
|
358 | - wp_enqueue_script('jquery-ui-position'); |
|
359 | - wp_enqueue_script('jquery-ui-widget'); |
|
360 | - wp_register_script( |
|
361 | - 'espresso_PRICING', |
|
362 | - PRICING_ASSETS_URL . 'espresso_pricing_admin.js', |
|
363 | - ['jquery'], |
|
364 | - EVENT_ESPRESSO_VERSION, |
|
365 | - true |
|
366 | - ); |
|
367 | - wp_enqueue_script('espresso_PRICING'); |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - public function load_scripts_styles_default() |
|
372 | - { |
|
373 | - wp_enqueue_script('espresso_ajax_table_sorting'); |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - public function admin_footer_scripts() |
|
378 | - { |
|
379 | - } |
|
380 | - |
|
381 | - |
|
382 | - public function admin_init() |
|
383 | - { |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - public function admin_notices() |
|
388 | - { |
|
389 | - } |
|
390 | - |
|
391 | - |
|
392 | - protected function _set_list_table_views_default() |
|
393 | - { |
|
394 | - $this->_views = [ |
|
395 | - 'all' => [ |
|
396 | - 'slug' => 'all', |
|
397 | - 'label' => esc_html__('View All Default Pricing', 'event_espresso'), |
|
398 | - 'count' => 0, |
|
399 | - 'bulk_action' => [ |
|
400 | - 'trash_price' => esc_html__('Move to Trash', 'event_espresso'), |
|
401 | - ], |
|
402 | - ], |
|
403 | - ]; |
|
404 | - |
|
405 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) { |
|
406 | - $this->_views['trashed'] = [ |
|
407 | - 'slug' => 'trashed', |
|
408 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
409 | - 'count' => 0, |
|
410 | - 'bulk_action' => [ |
|
411 | - 'restore_price' => esc_html__('Restore from Trash', 'event_espresso'), |
|
412 | - 'delete_price' => esc_html__('Delete Permanently', 'event_espresso'), |
|
413 | - ], |
|
414 | - ]; |
|
415 | - } |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - protected function _set_list_table_views_price_types() |
|
420 | - { |
|
421 | - $this->_views = [ |
|
422 | - 'all' => [ |
|
423 | - 'slug' => 'all', |
|
424 | - 'label' => esc_html__('All', 'event_espresso'), |
|
425 | - 'count' => 0, |
|
426 | - 'bulk_action' => [ |
|
427 | - 'trash_price_type' => esc_html__('Move to Trash', 'event_espresso'), |
|
428 | - ], |
|
429 | - ], |
|
430 | - ]; |
|
431 | - |
|
432 | - if ( |
|
433 | - EE_Registry::instance()->CAP->current_user_can( |
|
434 | - 'ee_delete_default_price_types', |
|
435 | - 'pricing_trash_price_type' |
|
436 | - ) |
|
437 | - ) { |
|
438 | - $this->_views['trashed'] = [ |
|
439 | - 'slug' => 'trashed', |
|
440 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
441 | - 'count' => 0, |
|
442 | - 'bulk_action' => [ |
|
443 | - 'restore_price_type' => esc_html__('Restore from Trash', 'event_espresso'), |
|
444 | - 'delete_price_type' => esc_html__('Delete Permanently', 'event_espresso'), |
|
445 | - ], |
|
446 | - ]; |
|
447 | - } |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - /** |
|
452 | - * generates HTML for main Prices Admin page |
|
453 | - * |
|
454 | - * @return void |
|
455 | - * @throws EE_Error |
|
456 | - */ |
|
457 | - protected function _price_overview_list_table() |
|
458 | - { |
|
459 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
460 | - 'add_new_price', |
|
461 | - 'add', |
|
462 | - [], |
|
463 | - 'add-new-h2' |
|
464 | - ); |
|
465 | - $this->_admin_page_title .= $this->_learn_more_about_pricing_link(); |
|
466 | - $this->_search_btn_label = esc_html__('Default Prices', 'event_espresso'); |
|
467 | - $this->display_admin_list_table_page_with_sidebar(); |
|
468 | - } |
|
469 | - |
|
470 | - |
|
471 | - /** |
|
472 | - * retrieve data for Prices List table |
|
473 | - * |
|
474 | - * @param int $per_page how many prices displayed per page |
|
475 | - * @param bool $count return the count or objects |
|
476 | - * @param bool $trashed whether the current view is of the trash can - eww yuck! |
|
477 | - * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects |
|
478 | - * @throws EE_Error |
|
479 | - * @throws ReflectionException |
|
480 | - */ |
|
481 | - public function get_prices_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
482 | - { |
|
483 | - // start with an empty array |
|
484 | - $event_pricing = []; |
|
485 | - |
|
486 | - require_once(PRICING_ADMIN . 'Prices_List_Table.class.php'); |
|
487 | - |
|
488 | - $orderby = $this->request->getRequestParam('orderby', ''); |
|
489 | - $order = $this->request->getRequestParam('order', 'ASC'); |
|
490 | - |
|
491 | - switch ($orderby) { |
|
492 | - case 'name': |
|
493 | - $orderby = ['PRC_name' => $order]; |
|
494 | - break; |
|
495 | - case 'type': |
|
496 | - $orderby = ['Price_Type.PRT_name' => $order]; |
|
497 | - break; |
|
498 | - case 'amount': |
|
499 | - $orderby = ['PRC_amount' => $order]; |
|
500 | - break; |
|
501 | - default: |
|
502 | - $orderby = ['PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order]; |
|
503 | - } |
|
504 | - |
|
505 | - $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER); |
|
506 | - $per_page = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER); |
|
507 | - |
|
508 | - $where = [ |
|
509 | - 'PRC_is_default' => 1, |
|
510 | - 'PRC_deleted' => $trashed, |
|
511 | - ]; |
|
512 | - |
|
513 | - $offset = ($current_page - 1) * $per_page; |
|
514 | - $limit = [$offset, $per_page]; |
|
515 | - |
|
516 | - $search_term = $this->request->getRequestParam('s'); |
|
517 | - if ($search_term) { |
|
518 | - $search_term = "%{$search_term}%"; |
|
519 | - $where['OR'] = [ |
|
520 | - 'PRC_name' => ['LIKE', $search_term], |
|
521 | - 'PRC_desc' => ['LIKE', $search_term], |
|
522 | - 'PRC_amount' => ['LIKE', $search_term], |
|
523 | - 'Price_Type.PRT_name' => ['LIKE', $search_term], |
|
524 | - ]; |
|
525 | - } |
|
526 | - |
|
527 | - $query_params = [ |
|
528 | - $where, |
|
529 | - 'order_by' => $orderby, |
|
530 | - 'limit' => $limit, |
|
531 | - 'group_by' => 'PRC_ID', |
|
532 | - ]; |
|
533 | - |
|
534 | - if ($count) { |
|
535 | - return $trashed |
|
536 | - ? EEM_Price::instance()->count([$where]) |
|
537 | - : EEM_Price::instance()->count_deleted_and_undeleted([$where]); |
|
538 | - } |
|
539 | - return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params); |
|
540 | - } |
|
541 | - |
|
542 | - |
|
543 | - /** |
|
544 | - * @return void |
|
545 | - * @throws EE_Error |
|
546 | - * @throws ReflectionException |
|
547 | - */ |
|
548 | - protected function _edit_price_details() |
|
549 | - { |
|
550 | - // grab price ID |
|
551 | - $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
552 | - // change page title based on request action |
|
553 | - switch ($this->_req_action) { |
|
554 | - case 'add_new_price': |
|
555 | - $this->_admin_page_title = esc_html__('Add New Price', 'event_espresso'); |
|
556 | - break; |
|
557 | - case 'edit_price': |
|
558 | - $this->_admin_page_title = esc_html__('Edit Price', 'event_espresso'); |
|
559 | - break; |
|
560 | - default: |
|
561 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
562 | - } |
|
563 | - // add PRC_ID to title if editing |
|
564 | - $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title; |
|
565 | - |
|
566 | - if ($PRC_ID) { |
|
567 | - $price = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
|
568 | - $additional_hidden_fields = [ |
|
569 | - 'PRC_ID' => ['type' => 'hidden', 'value' => $PRC_ID], |
|
570 | - ]; |
|
571 | - $this->_set_add_edit_form_tags('update_price', $additional_hidden_fields); |
|
572 | - } else { |
|
573 | - $price = EEM_Price::instance()->get_new_price(); |
|
574 | - $this->_set_add_edit_form_tags('insert_price'); |
|
575 | - } |
|
576 | - |
|
577 | - if (! $price instanceof EE_Price) { |
|
578 | - throw new RuntimeException( |
|
579 | - sprintf( |
|
580 | - esc_html__( |
|
581 | - 'A valid Price could not be retrieved from the database with ID: %1$s', |
|
582 | - 'event_espresso' |
|
583 | - ), |
|
584 | - $PRC_ID |
|
585 | - ) |
|
586 | - ); |
|
587 | - } |
|
588 | - |
|
589 | - $this->_template_args['PRC_ID'] = $PRC_ID; |
|
590 | - $this->_template_args['price'] = $price; |
|
591 | - |
|
592 | - $default_base_price = $price->type_obj() && $price->type_obj()->base_type() === 1; |
|
593 | - |
|
594 | - $this->_template_args['default_base_price'] = $default_base_price; |
|
595 | - |
|
596 | - // get price types |
|
597 | - $price_types = EEM_Price_Type::instance()->get_all([['PBT_ID' => ['!=', 1]]]); |
|
598 | - if (empty($price_types)) { |
|
599 | - $msg = esc_html__( |
|
600 | - 'You have no price types defined. Please add a price type before adding a price.', |
|
601 | - 'event_espresso' |
|
602 | - ); |
|
603 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
604 | - $this->display_admin_page_with_sidebar(); |
|
605 | - } |
|
606 | - $attributes = []; |
|
607 | - $price_type_names = []; |
|
608 | - $attributes[] = 'id="PRT_ID"'; |
|
609 | - if ($default_base_price) { |
|
610 | - $attributes[] = 'disabled="disabled"'; |
|
611 | - $price_type_names[] = ['id' => 1, 'text' => esc_html__('Base Price', 'event_espresso')]; |
|
612 | - } |
|
613 | - foreach ($price_types as $type) { |
|
614 | - $price_type_names[] = ['id' => $type->ID(), 'text' => $type->name()]; |
|
615 | - } |
|
616 | - $this->_template_args['attributes'] = implode(' ', $attributes); |
|
617 | - $this->_template_args['price_types'] = $price_type_names; |
|
618 | - |
|
619 | - $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link(); |
|
620 | - $this->_template_args['admin_page_content'] = $this->_edit_price_details_meta_box(); |
|
621 | - |
|
622 | - $this->_set_publish_post_box_vars('id', $PRC_ID); |
|
623 | - // the details template wrapper |
|
624 | - $this->display_admin_page_with_sidebar(); |
|
625 | - } |
|
626 | - |
|
627 | - |
|
628 | - /** |
|
629 | - * |
|
630 | - * @return string |
|
631 | - */ |
|
632 | - public function _edit_price_details_meta_box(): string |
|
633 | - { |
|
634 | - return EEH_Template::display_template( |
|
635 | - PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php', |
|
636 | - $this->_template_args, |
|
637 | - true |
|
638 | - ); |
|
639 | - } |
|
640 | - |
|
641 | - |
|
642 | - /** |
|
643 | - * @return array |
|
644 | - * @throws EE_Error |
|
645 | - * @throws ReflectionException |
|
646 | - */ |
|
647 | - protected function set_price_column_values(): array |
|
648 | - { |
|
649 | - $PRC_order = 0; |
|
650 | - $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
651 | - if ($PRT_ID) { |
|
652 | - /** @var EE_Price_Type $price_type */ |
|
653 | - $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID); |
|
654 | - if ($price_type instanceof EE_Price_Type) { |
|
655 | - $PRC_order = $price_type->order(); |
|
656 | - } |
|
657 | - } |
|
658 | - return [ |
|
659 | - 'PRT_ID' => $PRT_ID, |
|
660 | - 'PRC_amount' => $this->request->getRequestParam('PRC_amount', 0, DataType::FLOAT), |
|
661 | - 'PRC_name' => $this->request->getRequestParam('PRC_name'), |
|
662 | - 'PRC_desc' => $this->request->getRequestParam('PRC_desc'), |
|
663 | - 'PRC_is_default' => 1, |
|
664 | - 'PRC_overrides' => null, |
|
665 | - 'PRC_order' => $PRC_order, |
|
666 | - 'PRC_deleted' => 0, |
|
667 | - 'PRC_parent' => 0, |
|
668 | - ]; |
|
669 | - } |
|
670 | - |
|
671 | - |
|
672 | - /** |
|
673 | - * @param bool $insert - whether to insert or update |
|
674 | - * @return void |
|
675 | - * @throws EE_Error |
|
676 | - * @throws ReflectionException |
|
677 | - */ |
|
678 | - protected function _insert_or_update_price(bool $insert = false) |
|
679 | - { |
|
680 | - // why be so pessimistic ??? : ( |
|
681 | - $updated = 0; |
|
682 | - |
|
683 | - $set_column_values = $this->set_price_column_values(); |
|
684 | - // is this a new Price ? |
|
685 | - if ($insert) { |
|
686 | - // run the insert |
|
687 | - $PRC_ID = EEM_Price::instance()->insert($set_column_values); |
|
688 | - if ($PRC_ID) { |
|
689 | - // make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type |
|
690 | - $price = EEM_price::instance()->get_one_by_ID($PRC_ID); |
|
691 | - if ( |
|
692 | - $price instanceof EE_Price |
|
693 | - && $price->type_obj() instanceof EE_Price_type |
|
694 | - && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax |
|
695 | - ) { |
|
696 | - $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
|
697 | - $ticket->_add_relation_to($price, 'Price'); |
|
698 | - $ticket->save(); |
|
699 | - } |
|
700 | - $updated = 1; |
|
701 | - } |
|
702 | - $action_desc = 'created'; |
|
703 | - } else { |
|
704 | - $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER); |
|
705 | - // run the update |
|
706 | - $where_cols_n_values = ['PRC_ID' => $PRC_ID]; |
|
707 | - $updated = EEM_Price::instance()->update($set_column_values, [$where_cols_n_values]); |
|
708 | - |
|
709 | - $price = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
|
710 | - if ($price instanceof EE_Price && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) { |
|
711 | - // if this is $PRC_ID == 1, |
|
712 | - // then we need to update the default ticket attached to this price so the TKT_price value is updated. |
|
713 | - if ($PRC_ID === 1) { |
|
714 | - $ticket = $price->get_first_related('Ticket'); |
|
715 | - if ($ticket) { |
|
716 | - $ticket->set('TKT_price', $price->get('PRC_amount')); |
|
717 | - $ticket->set('TKT_name', $price->get('PRC_name')); |
|
718 | - $ticket->set('TKT_description', $price->get('PRC_desc')); |
|
719 | - $ticket->save(); |
|
720 | - } |
|
721 | - } else { |
|
722 | - // we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type. |
|
723 | - $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
|
724 | - $ticket->_add_relation_to($PRC_ID, 'Price'); |
|
725 | - $ticket->save(); |
|
726 | - } |
|
727 | - } |
|
728 | - |
|
729 | - $action_desc = 'updated'; |
|
730 | - } |
|
731 | - |
|
732 | - $query_args = ['action' => 'edit_price', 'id' => $PRC_ID]; |
|
733 | - |
|
734 | - $this->_redirect_after_action($updated, 'Prices', $action_desc, $query_args); |
|
735 | - } |
|
736 | - |
|
737 | - |
|
738 | - /** |
|
739 | - * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
740 | - * @return void |
|
741 | - * @throws EE_Error |
|
742 | - * @throws ReflectionException |
|
743 | - */ |
|
744 | - protected function _trash_or_restore_price(bool $trash = true) |
|
745 | - { |
|
746 | - $entity_model = EEM_Price::instance(); |
|
747 | - $action = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE; |
|
748 | - $result = $this->trashRestoreDeleteEntities( |
|
749 | - $entity_model, |
|
750 | - 'id', |
|
751 | - $action, |
|
752 | - 'PRC_deleted', |
|
753 | - [$this, 'adjustTicketRelations'] |
|
754 | - ); |
|
755 | - |
|
756 | - if ($result) { |
|
757 | - $msg = $trash |
|
758 | - ? esc_html( |
|
759 | - _n( |
|
760 | - 'The Price has been trashed', |
|
761 | - 'The Prices have been trashed', |
|
762 | - $result, |
|
763 | - 'event_espresso' |
|
764 | - ) |
|
765 | - ) |
|
766 | - : esc_html( |
|
767 | - _n( |
|
768 | - 'The Price has been restored', |
|
769 | - 'The Prices have been restored', |
|
770 | - $result, |
|
771 | - 'event_espresso' |
|
772 | - ) |
|
773 | - ); |
|
774 | - EE_Error::add_success($msg); |
|
775 | - } |
|
776 | - |
|
777 | - $this->_redirect_after_action( |
|
778 | - $result, |
|
779 | - _n('Price', 'Prices', $result, 'event_espresso'), |
|
780 | - $trash ? 'trashed' : 'restored', |
|
781 | - ['action' => 'default'], |
|
782 | - true |
|
783 | - ); |
|
784 | - } |
|
785 | - |
|
786 | - |
|
787 | - /** |
|
788 | - * @param EEM_Base $entity_model |
|
789 | - * @param int|string $entity_ID |
|
790 | - * @param string $action |
|
791 | - * @param int $result |
|
792 | - * @throws EE_Error |
|
793 | - * @throws ReflectionException |
|
794 | - * @since 4.10.30.p |
|
795 | - */ |
|
796 | - public function adjustTicketRelations( |
|
797 | - EEM_Base $entity_model, |
|
798 | - $entity_ID, |
|
799 | - string $action, |
|
800 | - int $result |
|
801 | - ) { |
|
802 | - if (! $entity_ID || (float) $result < 1) { |
|
803 | - return; |
|
804 | - } |
|
805 | - |
|
806 | - $entity = $entity_model->get_one_by_ID($entity_ID); |
|
807 | - if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) { |
|
808 | - return; |
|
809 | - } |
|
810 | - |
|
811 | - // get default tickets for updating |
|
812 | - $default_tickets = EEM_Ticket::instance()->get_all_default_tickets(); |
|
813 | - foreach ($default_tickets as $default_ticket) { |
|
814 | - if (! $default_ticket instanceof EE_Ticket) { |
|
815 | - continue; |
|
816 | - } |
|
817 | - switch ($action) { |
|
818 | - case EE_Admin_List_Table::ACTION_DELETE: |
|
819 | - case EE_Admin_List_Table::ACTION_TRASH: |
|
820 | - // if trashing then remove relations to base default ticket. |
|
821 | - $default_ticket->_remove_relation_to($entity_ID, 'Price'); |
|
822 | - break; |
|
823 | - case EE_Admin_List_Table::ACTION_RESTORE: |
|
824 | - // if restoring then add back to base default ticket |
|
825 | - $default_ticket->_add_relation_to($entity_ID, 'Price'); |
|
826 | - break; |
|
827 | - } |
|
828 | - $default_ticket->save(); |
|
829 | - } |
|
830 | - } |
|
831 | - |
|
832 | - |
|
833 | - /** |
|
834 | - * @return void |
|
835 | - * @throws EE_Error |
|
836 | - * @throws ReflectionException |
|
837 | - */ |
|
838 | - protected function _delete_price() |
|
839 | - { |
|
840 | - $entity_model = EEM_Price::instance(); |
|
841 | - $deleted = $this->trashRestoreDeleteEntities($entity_model, 'id'); |
|
842 | - $entity = $entity_model->item_name($deleted); |
|
843 | - $this->_redirect_after_action( |
|
844 | - $deleted, |
|
845 | - $entity, |
|
846 | - 'deleted', |
|
847 | - ['action' => 'default'] |
|
848 | - ); |
|
849 | - } |
|
850 | - |
|
851 | - |
|
852 | - /** |
|
853 | - * @throws EE_Error |
|
854 | - * @throws ReflectionException |
|
855 | - */ |
|
856 | - public function update_price_order() |
|
857 | - { |
|
858 | - // grab our row IDs |
|
859 | - $row_ids = $this->request->getRequestParam('row_ids', ''); |
|
860 | - $row_ids = explode(',', rtrim($row_ids, ',')); |
|
861 | - |
|
862 | - $all_updated = true; |
|
863 | - foreach ($row_ids as $i => $row_id) { |
|
864 | - // Update the prices when re-ordering |
|
865 | - $fields_n_values = ['PRC_order' => $i + 1]; |
|
866 | - $query_params = [['PRC_ID' => absint($row_id)]]; |
|
867 | - // any failure will toggle $all_updated to false |
|
868 | - $all_updated = $row_id && EEM_Price::instance()->update($fields_n_values, $query_params) !== false |
|
869 | - ? $all_updated |
|
870 | - : false; |
|
871 | - } |
|
872 | - $success = $all_updated |
|
873 | - ? esc_html__('Price order was updated successfully.', 'event_espresso') |
|
874 | - : false; |
|
875 | - $errors = ! $all_updated |
|
876 | - ? esc_html__('An error occurred. The price order was not updated.', 'event_espresso') |
|
877 | - : false; |
|
878 | - |
|
879 | - echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]); |
|
880 | - die(); |
|
881 | - } |
|
882 | - |
|
883 | - |
|
884 | - /****************************************************************************************************************** |
|
14 | + protected function _init_page_props() |
|
15 | + { |
|
16 | + $this->page_slug = PRICING_PG_SLUG; |
|
17 | + $this->page_label = PRICING_LABEL; |
|
18 | + $this->_admin_base_url = PRICING_ADMIN_URL; |
|
19 | + $this->_admin_base_path = PRICING_ADMIN; |
|
20 | + } |
|
21 | + |
|
22 | + |
|
23 | + protected function _ajax_hooks() |
|
24 | + { |
|
25 | + add_action('wp_ajax_espresso_update_prices_order', [$this, 'update_price_order']); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + protected function _define_page_props() |
|
30 | + { |
|
31 | + $this->_admin_page_title = PRICING_LABEL; |
|
32 | + $this->_labels = [ |
|
33 | + 'buttons' => [ |
|
34 | + 'add' => esc_html__('Add New Default Price', 'event_espresso'), |
|
35 | + 'edit' => esc_html__('Edit Default Price', 'event_espresso'), |
|
36 | + 'delete' => esc_html__('Delete Default Price', 'event_espresso'), |
|
37 | + 'add_type' => esc_html__('Add New Default Price Type', 'event_espresso'), |
|
38 | + 'edit_type' => esc_html__('Edit Price Type', 'event_espresso'), |
|
39 | + 'delete_type' => esc_html__('Delete Price Type', 'event_espresso'), |
|
40 | + ], |
|
41 | + ]; |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * an array for storing request actions and their corresponding methods |
|
47 | + * |
|
48 | + * @return void |
|
49 | + */ |
|
50 | + protected function _set_page_routes() |
|
51 | + { |
|
52 | + $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER); |
|
53 | + $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
54 | + $this->_page_routes = [ |
|
55 | + 'default' => [ |
|
56 | + 'func' => '_price_overview_list_table', |
|
57 | + 'capability' => 'ee_read_default_prices', |
|
58 | + ], |
|
59 | + 'add_new_price' => [ |
|
60 | + 'func' => '_edit_price_details', |
|
61 | + // 'args' => ['new_price' => true], |
|
62 | + 'capability' => 'ee_edit_default_prices', |
|
63 | + ], |
|
64 | + 'edit_price' => [ |
|
65 | + 'func' => '_edit_price_details', |
|
66 | + // 'args' => ['new_price' => false], |
|
67 | + 'capability' => 'ee_edit_default_price', |
|
68 | + 'obj_id' => $PRC_ID, |
|
69 | + ], |
|
70 | + 'insert_price' => [ |
|
71 | + 'func' => '_insert_or_update_price', |
|
72 | + 'args' => ['insert' => true], |
|
73 | + 'noheader' => true, |
|
74 | + 'capability' => 'ee_edit_default_prices', |
|
75 | + ], |
|
76 | + 'update_price' => [ |
|
77 | + 'func' => '_insert_or_update_price', |
|
78 | + 'args' => ['insert' => false], |
|
79 | + 'noheader' => true, |
|
80 | + 'capability' => 'ee_edit_default_price', |
|
81 | + 'obj_id' => $PRC_ID, |
|
82 | + ], |
|
83 | + 'trash_price' => [ |
|
84 | + 'func' => '_trash_or_restore_price', |
|
85 | + 'args' => ['trash' => true], |
|
86 | + 'noheader' => true, |
|
87 | + 'capability' => 'ee_delete_default_price', |
|
88 | + 'obj_id' => $PRC_ID, |
|
89 | + ], |
|
90 | + 'restore_price' => [ |
|
91 | + 'func' => '_trash_or_restore_price', |
|
92 | + 'args' => ['trash' => false], |
|
93 | + 'noheader' => true, |
|
94 | + 'capability' => 'ee_delete_default_price', |
|
95 | + 'obj_id' => $PRC_ID, |
|
96 | + ], |
|
97 | + 'delete_price' => [ |
|
98 | + 'func' => '_delete_price', |
|
99 | + 'noheader' => true, |
|
100 | + 'capability' => 'ee_delete_default_price', |
|
101 | + 'obj_id' => $PRC_ID, |
|
102 | + ], |
|
103 | + 'espresso_update_price_order' => [ |
|
104 | + 'func' => 'update_price_order', |
|
105 | + 'noheader' => true, |
|
106 | + 'capability' => 'ee_edit_default_prices', |
|
107 | + ], |
|
108 | + // price types |
|
109 | + 'price_types' => [ |
|
110 | + 'func' => '_price_types_overview_list_table', |
|
111 | + 'capability' => 'ee_read_default_price_types', |
|
112 | + ], |
|
113 | + 'add_new_price_type' => [ |
|
114 | + 'func' => '_edit_price_type_details', |
|
115 | + 'capability' => 'ee_edit_default_price_types', |
|
116 | + ], |
|
117 | + 'edit_price_type' => [ |
|
118 | + 'func' => '_edit_price_type_details', |
|
119 | + 'capability' => 'ee_edit_default_price_type', |
|
120 | + 'obj_id' => $PRT_ID, |
|
121 | + ], |
|
122 | + 'insert_price_type' => [ |
|
123 | + 'func' => '_insert_or_update_price_type', |
|
124 | + 'args' => ['new_price_type' => true], |
|
125 | + 'noheader' => true, |
|
126 | + 'capability' => 'ee_edit_default_price_types', |
|
127 | + ], |
|
128 | + 'update_price_type' => [ |
|
129 | + 'func' => '_insert_or_update_price_type', |
|
130 | + 'args' => ['new_price_type' => false], |
|
131 | + 'noheader' => true, |
|
132 | + 'capability' => 'ee_edit_default_price_type', |
|
133 | + 'obj_id' => $PRT_ID, |
|
134 | + ], |
|
135 | + 'trash_price_type' => [ |
|
136 | + 'func' => '_trash_or_restore_price_type', |
|
137 | + 'args' => ['trash' => true], |
|
138 | + 'noheader' => true, |
|
139 | + 'capability' => 'ee_delete_default_price_type', |
|
140 | + 'obj_id' => $PRT_ID, |
|
141 | + ], |
|
142 | + 'restore_price_type' => [ |
|
143 | + 'func' => '_trash_or_restore_price_type', |
|
144 | + 'args' => ['trash' => false], |
|
145 | + 'noheader' => true, |
|
146 | + 'capability' => 'ee_delete_default_price_type', |
|
147 | + 'obj_id' => $PRT_ID, |
|
148 | + ], |
|
149 | + 'delete_price_type' => [ |
|
150 | + 'func' => '_delete_price_type', |
|
151 | + 'noheader' => true, |
|
152 | + 'capability' => 'ee_delete_default_price_type', |
|
153 | + 'obj_id' => $PRT_ID, |
|
154 | + ], |
|
155 | + 'tax_settings' => [ |
|
156 | + 'func' => '_tax_settings', |
|
157 | + 'capability' => 'manage_options', |
|
158 | + ], |
|
159 | + 'update_tax_settings' => [ |
|
160 | + 'func' => '_update_tax_settings', |
|
161 | + 'capability' => 'manage_options', |
|
162 | + 'noheader' => true, |
|
163 | + ], |
|
164 | + ]; |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + protected function _set_page_config() |
|
169 | + { |
|
170 | + $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
171 | + $this->_page_config = [ |
|
172 | + 'default' => [ |
|
173 | + 'nav' => [ |
|
174 | + 'label' => esc_html__('Default Pricing', 'event_espresso'), |
|
175 | + 'icon' => 'dashicons-money-alt', |
|
176 | + 'order' => 10, |
|
177 | + ], |
|
178 | + 'list_table' => 'Prices_List_Table', |
|
179 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
180 | + 'help_tabs' => [ |
|
181 | + 'pricing_default_pricing_help_tab' => [ |
|
182 | + 'title' => esc_html__('Default Pricing', 'event_espresso'), |
|
183 | + 'filename' => 'pricing_default_pricing', |
|
184 | + ], |
|
185 | + 'pricing_default_pricing_table_column_headings_help_tab' => [ |
|
186 | + 'title' => esc_html__('Default Pricing Table Column Headings', 'event_espresso'), |
|
187 | + 'filename' => 'pricing_default_pricing_table_column_headings', |
|
188 | + ], |
|
189 | + 'pricing_default_pricing_views_bulk_actions_search_help_tab' => [ |
|
190 | + 'title' => esc_html__('Default Pricing Views & Bulk Actions & Search', 'event_espresso'), |
|
191 | + 'filename' => 'pricing_default_pricing_views_bulk_actions_search', |
|
192 | + ], |
|
193 | + ], |
|
194 | + 'require_nonce' => false, |
|
195 | + ], |
|
196 | + 'add_new_price' => [ |
|
197 | + 'nav' => [ |
|
198 | + 'label' => esc_html__('Add New Default Price', 'event_espresso'), |
|
199 | + 'icon' => 'dashicons-plus-alt', |
|
200 | + 'order' => 20, |
|
201 | + 'persistent' => false, |
|
202 | + ], |
|
203 | + 'help_tabs' => [ |
|
204 | + 'add_new_default_price_help_tab' => [ |
|
205 | + 'title' => esc_html__('Add New Default Price', 'event_espresso'), |
|
206 | + 'filename' => 'pricing_add_new_default_price', |
|
207 | + ], |
|
208 | + ], |
|
209 | + 'metaboxes' => array_merge( |
|
210 | + ['_publish_post_box'], |
|
211 | + $this->_default_espresso_metaboxes |
|
212 | + ), |
|
213 | + 'require_nonce' => false, |
|
214 | + ], |
|
215 | + 'edit_price' => [ |
|
216 | + 'nav' => [ |
|
217 | + 'label' => esc_html__('Edit Default Price', 'event_espresso'), |
|
218 | + 'icon' => 'dashicons-edit-large', |
|
219 | + 'order' => 20, |
|
220 | + 'url' => $PRC_ID |
|
221 | + ? add_query_arg(['id' => $PRC_ID], $this->_current_page_view_url) |
|
222 | + : $this->_admin_base_url, |
|
223 | + 'persistent' => false, |
|
224 | + ], |
|
225 | + 'metaboxes' => array_merge( |
|
226 | + ['_publish_post_box'], |
|
227 | + $this->_default_espresso_metaboxes |
|
228 | + ), |
|
229 | + 'help_tabs' => [ |
|
230 | + 'edit_default_price_help_tab' => [ |
|
231 | + 'title' => esc_html__('Edit Default Price', 'event_espresso'), |
|
232 | + 'filename' => 'pricing_edit_default_price', |
|
233 | + ], |
|
234 | + ], |
|
235 | + 'require_nonce' => false, |
|
236 | + ], |
|
237 | + 'price_types' => [ |
|
238 | + 'nav' => [ |
|
239 | + 'label' => esc_html__('Price Types', 'event_espresso'), |
|
240 | + 'icon' => 'dashicons-networking', |
|
241 | + 'order' => 30, |
|
242 | + ], |
|
243 | + 'list_table' => 'Price_Types_List_Table', |
|
244 | + 'help_tabs' => [ |
|
245 | + 'pricing_price_types_help_tab' => [ |
|
246 | + 'title' => esc_html__('Price Types', 'event_espresso'), |
|
247 | + 'filename' => 'pricing_price_types', |
|
248 | + ], |
|
249 | + 'pricing_price_types_table_column_headings_help_tab' => [ |
|
250 | + 'title' => esc_html__('Price Types Table Column Headings', 'event_espresso'), |
|
251 | + 'filename' => 'pricing_price_types_table_column_headings', |
|
252 | + ], |
|
253 | + 'pricing_price_types_views_bulk_actions_search_help_tab' => [ |
|
254 | + 'title' => esc_html__('Price Types Views & Bulk Actions & Search', 'event_espresso'), |
|
255 | + 'filename' => 'pricing_price_types_views_bulk_actions_search', |
|
256 | + ], |
|
257 | + ], |
|
258 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
259 | + 'require_nonce' => false, |
|
260 | + ], |
|
261 | + 'add_new_price_type' => [ |
|
262 | + 'nav' => [ |
|
263 | + 'label' => esc_html__('Add New Price Type', 'event_espresso'), |
|
264 | + 'icon' => 'dashicons-plus-alt', |
|
265 | + 'order' => 40, |
|
266 | + 'persistent' => false, |
|
267 | + ], |
|
268 | + 'help_tabs' => [ |
|
269 | + 'add_new_price_type_help_tab' => [ |
|
270 | + 'title' => esc_html__('Add New Price Type', 'event_espresso'), |
|
271 | + 'filename' => 'pricing_add_new_price_type', |
|
272 | + ], |
|
273 | + ], |
|
274 | + 'metaboxes' => array_merge( |
|
275 | + ['_publish_post_box'], |
|
276 | + $this->_default_espresso_metaboxes |
|
277 | + ), |
|
278 | + 'require_nonce' => false, |
|
279 | + ], |
|
280 | + 'edit_price_type' => [ |
|
281 | + 'nav' => [ |
|
282 | + 'label' => esc_html__('Edit Price Type', 'event_espresso'), |
|
283 | + 'icon' => 'dashicons-edit-large', |
|
284 | + 'order' => 40, |
|
285 | + 'persistent' => false, |
|
286 | + ], |
|
287 | + 'help_tabs' => [ |
|
288 | + 'edit_price_type_help_tab' => [ |
|
289 | + 'title' => esc_html__('Edit Price Type', 'event_espresso'), |
|
290 | + 'filename' => 'pricing_edit_price_type', |
|
291 | + ], |
|
292 | + ], |
|
293 | + 'metaboxes' => array_merge( |
|
294 | + ['_publish_post_box'], |
|
295 | + $this->_default_espresso_metaboxes |
|
296 | + ), |
|
297 | + 'require_nonce' => false, |
|
298 | + ], |
|
299 | + 'tax_settings' => [ |
|
300 | + 'nav' => [ |
|
301 | + 'label' => esc_html__('Tax Settings', 'event_espresso'), |
|
302 | + 'icon' => 'dashicons-sticky', |
|
303 | + 'order' => 50, |
|
304 | + ], |
|
305 | + 'labels' => [ |
|
306 | + 'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'), |
|
307 | + ], |
|
308 | + 'metaboxes' => array_merge( |
|
309 | + ['_publish_post_box'], |
|
310 | + $this->_default_espresso_metaboxes |
|
311 | + ), |
|
312 | + 'require_nonce' => true, |
|
313 | + ], |
|
314 | + ]; |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + protected function _add_screen_options() |
|
319 | + { |
|
320 | + // todo |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + protected function _add_screen_options_default() |
|
325 | + { |
|
326 | + $this->_per_page_screen_option(); |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + protected function _add_screen_options_price_types() |
|
331 | + { |
|
332 | + $page_title = $this->_admin_page_title; |
|
333 | + $this->_admin_page_title = esc_html__('Price Types', 'event_espresso'); |
|
334 | + $this->_per_page_screen_option(); |
|
335 | + $this->_admin_page_title = $page_title; |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + protected function _add_feature_pointers() |
|
340 | + { |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + public function load_scripts_styles() |
|
345 | + { |
|
346 | + // styles |
|
347 | + wp_enqueue_style('espresso-ui-theme'); |
|
348 | + wp_register_style( |
|
349 | + 'espresso_PRICING', |
|
350 | + PRICING_ASSETS_URL . 'espresso_pricing_admin.css', |
|
351 | + [], |
|
352 | + EVENT_ESPRESSO_VERSION |
|
353 | + ); |
|
354 | + wp_enqueue_style('espresso_PRICING'); |
|
355 | + |
|
356 | + // scripts |
|
357 | + wp_enqueue_script('ee_admin_js'); |
|
358 | + wp_enqueue_script('jquery-ui-position'); |
|
359 | + wp_enqueue_script('jquery-ui-widget'); |
|
360 | + wp_register_script( |
|
361 | + 'espresso_PRICING', |
|
362 | + PRICING_ASSETS_URL . 'espresso_pricing_admin.js', |
|
363 | + ['jquery'], |
|
364 | + EVENT_ESPRESSO_VERSION, |
|
365 | + true |
|
366 | + ); |
|
367 | + wp_enqueue_script('espresso_PRICING'); |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + public function load_scripts_styles_default() |
|
372 | + { |
|
373 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + public function admin_footer_scripts() |
|
378 | + { |
|
379 | + } |
|
380 | + |
|
381 | + |
|
382 | + public function admin_init() |
|
383 | + { |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + public function admin_notices() |
|
388 | + { |
|
389 | + } |
|
390 | + |
|
391 | + |
|
392 | + protected function _set_list_table_views_default() |
|
393 | + { |
|
394 | + $this->_views = [ |
|
395 | + 'all' => [ |
|
396 | + 'slug' => 'all', |
|
397 | + 'label' => esc_html__('View All Default Pricing', 'event_espresso'), |
|
398 | + 'count' => 0, |
|
399 | + 'bulk_action' => [ |
|
400 | + 'trash_price' => esc_html__('Move to Trash', 'event_espresso'), |
|
401 | + ], |
|
402 | + ], |
|
403 | + ]; |
|
404 | + |
|
405 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) { |
|
406 | + $this->_views['trashed'] = [ |
|
407 | + 'slug' => 'trashed', |
|
408 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
409 | + 'count' => 0, |
|
410 | + 'bulk_action' => [ |
|
411 | + 'restore_price' => esc_html__('Restore from Trash', 'event_espresso'), |
|
412 | + 'delete_price' => esc_html__('Delete Permanently', 'event_espresso'), |
|
413 | + ], |
|
414 | + ]; |
|
415 | + } |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + protected function _set_list_table_views_price_types() |
|
420 | + { |
|
421 | + $this->_views = [ |
|
422 | + 'all' => [ |
|
423 | + 'slug' => 'all', |
|
424 | + 'label' => esc_html__('All', 'event_espresso'), |
|
425 | + 'count' => 0, |
|
426 | + 'bulk_action' => [ |
|
427 | + 'trash_price_type' => esc_html__('Move to Trash', 'event_espresso'), |
|
428 | + ], |
|
429 | + ], |
|
430 | + ]; |
|
431 | + |
|
432 | + if ( |
|
433 | + EE_Registry::instance()->CAP->current_user_can( |
|
434 | + 'ee_delete_default_price_types', |
|
435 | + 'pricing_trash_price_type' |
|
436 | + ) |
|
437 | + ) { |
|
438 | + $this->_views['trashed'] = [ |
|
439 | + 'slug' => 'trashed', |
|
440 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
441 | + 'count' => 0, |
|
442 | + 'bulk_action' => [ |
|
443 | + 'restore_price_type' => esc_html__('Restore from Trash', 'event_espresso'), |
|
444 | + 'delete_price_type' => esc_html__('Delete Permanently', 'event_espresso'), |
|
445 | + ], |
|
446 | + ]; |
|
447 | + } |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + /** |
|
452 | + * generates HTML for main Prices Admin page |
|
453 | + * |
|
454 | + * @return void |
|
455 | + * @throws EE_Error |
|
456 | + */ |
|
457 | + protected function _price_overview_list_table() |
|
458 | + { |
|
459 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
460 | + 'add_new_price', |
|
461 | + 'add', |
|
462 | + [], |
|
463 | + 'add-new-h2' |
|
464 | + ); |
|
465 | + $this->_admin_page_title .= $this->_learn_more_about_pricing_link(); |
|
466 | + $this->_search_btn_label = esc_html__('Default Prices', 'event_espresso'); |
|
467 | + $this->display_admin_list_table_page_with_sidebar(); |
|
468 | + } |
|
469 | + |
|
470 | + |
|
471 | + /** |
|
472 | + * retrieve data for Prices List table |
|
473 | + * |
|
474 | + * @param int $per_page how many prices displayed per page |
|
475 | + * @param bool $count return the count or objects |
|
476 | + * @param bool $trashed whether the current view is of the trash can - eww yuck! |
|
477 | + * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects |
|
478 | + * @throws EE_Error |
|
479 | + * @throws ReflectionException |
|
480 | + */ |
|
481 | + public function get_prices_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
482 | + { |
|
483 | + // start with an empty array |
|
484 | + $event_pricing = []; |
|
485 | + |
|
486 | + require_once(PRICING_ADMIN . 'Prices_List_Table.class.php'); |
|
487 | + |
|
488 | + $orderby = $this->request->getRequestParam('orderby', ''); |
|
489 | + $order = $this->request->getRequestParam('order', 'ASC'); |
|
490 | + |
|
491 | + switch ($orderby) { |
|
492 | + case 'name': |
|
493 | + $orderby = ['PRC_name' => $order]; |
|
494 | + break; |
|
495 | + case 'type': |
|
496 | + $orderby = ['Price_Type.PRT_name' => $order]; |
|
497 | + break; |
|
498 | + case 'amount': |
|
499 | + $orderby = ['PRC_amount' => $order]; |
|
500 | + break; |
|
501 | + default: |
|
502 | + $orderby = ['PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order]; |
|
503 | + } |
|
504 | + |
|
505 | + $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER); |
|
506 | + $per_page = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER); |
|
507 | + |
|
508 | + $where = [ |
|
509 | + 'PRC_is_default' => 1, |
|
510 | + 'PRC_deleted' => $trashed, |
|
511 | + ]; |
|
512 | + |
|
513 | + $offset = ($current_page - 1) * $per_page; |
|
514 | + $limit = [$offset, $per_page]; |
|
515 | + |
|
516 | + $search_term = $this->request->getRequestParam('s'); |
|
517 | + if ($search_term) { |
|
518 | + $search_term = "%{$search_term}%"; |
|
519 | + $where['OR'] = [ |
|
520 | + 'PRC_name' => ['LIKE', $search_term], |
|
521 | + 'PRC_desc' => ['LIKE', $search_term], |
|
522 | + 'PRC_amount' => ['LIKE', $search_term], |
|
523 | + 'Price_Type.PRT_name' => ['LIKE', $search_term], |
|
524 | + ]; |
|
525 | + } |
|
526 | + |
|
527 | + $query_params = [ |
|
528 | + $where, |
|
529 | + 'order_by' => $orderby, |
|
530 | + 'limit' => $limit, |
|
531 | + 'group_by' => 'PRC_ID', |
|
532 | + ]; |
|
533 | + |
|
534 | + if ($count) { |
|
535 | + return $trashed |
|
536 | + ? EEM_Price::instance()->count([$where]) |
|
537 | + : EEM_Price::instance()->count_deleted_and_undeleted([$where]); |
|
538 | + } |
|
539 | + return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params); |
|
540 | + } |
|
541 | + |
|
542 | + |
|
543 | + /** |
|
544 | + * @return void |
|
545 | + * @throws EE_Error |
|
546 | + * @throws ReflectionException |
|
547 | + */ |
|
548 | + protected function _edit_price_details() |
|
549 | + { |
|
550 | + // grab price ID |
|
551 | + $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
552 | + // change page title based on request action |
|
553 | + switch ($this->_req_action) { |
|
554 | + case 'add_new_price': |
|
555 | + $this->_admin_page_title = esc_html__('Add New Price', 'event_espresso'); |
|
556 | + break; |
|
557 | + case 'edit_price': |
|
558 | + $this->_admin_page_title = esc_html__('Edit Price', 'event_espresso'); |
|
559 | + break; |
|
560 | + default: |
|
561 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
562 | + } |
|
563 | + // add PRC_ID to title if editing |
|
564 | + $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title; |
|
565 | + |
|
566 | + if ($PRC_ID) { |
|
567 | + $price = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
|
568 | + $additional_hidden_fields = [ |
|
569 | + 'PRC_ID' => ['type' => 'hidden', 'value' => $PRC_ID], |
|
570 | + ]; |
|
571 | + $this->_set_add_edit_form_tags('update_price', $additional_hidden_fields); |
|
572 | + } else { |
|
573 | + $price = EEM_Price::instance()->get_new_price(); |
|
574 | + $this->_set_add_edit_form_tags('insert_price'); |
|
575 | + } |
|
576 | + |
|
577 | + if (! $price instanceof EE_Price) { |
|
578 | + throw new RuntimeException( |
|
579 | + sprintf( |
|
580 | + esc_html__( |
|
581 | + 'A valid Price could not be retrieved from the database with ID: %1$s', |
|
582 | + 'event_espresso' |
|
583 | + ), |
|
584 | + $PRC_ID |
|
585 | + ) |
|
586 | + ); |
|
587 | + } |
|
588 | + |
|
589 | + $this->_template_args['PRC_ID'] = $PRC_ID; |
|
590 | + $this->_template_args['price'] = $price; |
|
591 | + |
|
592 | + $default_base_price = $price->type_obj() && $price->type_obj()->base_type() === 1; |
|
593 | + |
|
594 | + $this->_template_args['default_base_price'] = $default_base_price; |
|
595 | + |
|
596 | + // get price types |
|
597 | + $price_types = EEM_Price_Type::instance()->get_all([['PBT_ID' => ['!=', 1]]]); |
|
598 | + if (empty($price_types)) { |
|
599 | + $msg = esc_html__( |
|
600 | + 'You have no price types defined. Please add a price type before adding a price.', |
|
601 | + 'event_espresso' |
|
602 | + ); |
|
603 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
604 | + $this->display_admin_page_with_sidebar(); |
|
605 | + } |
|
606 | + $attributes = []; |
|
607 | + $price_type_names = []; |
|
608 | + $attributes[] = 'id="PRT_ID"'; |
|
609 | + if ($default_base_price) { |
|
610 | + $attributes[] = 'disabled="disabled"'; |
|
611 | + $price_type_names[] = ['id' => 1, 'text' => esc_html__('Base Price', 'event_espresso')]; |
|
612 | + } |
|
613 | + foreach ($price_types as $type) { |
|
614 | + $price_type_names[] = ['id' => $type->ID(), 'text' => $type->name()]; |
|
615 | + } |
|
616 | + $this->_template_args['attributes'] = implode(' ', $attributes); |
|
617 | + $this->_template_args['price_types'] = $price_type_names; |
|
618 | + |
|
619 | + $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link(); |
|
620 | + $this->_template_args['admin_page_content'] = $this->_edit_price_details_meta_box(); |
|
621 | + |
|
622 | + $this->_set_publish_post_box_vars('id', $PRC_ID); |
|
623 | + // the details template wrapper |
|
624 | + $this->display_admin_page_with_sidebar(); |
|
625 | + } |
|
626 | + |
|
627 | + |
|
628 | + /** |
|
629 | + * |
|
630 | + * @return string |
|
631 | + */ |
|
632 | + public function _edit_price_details_meta_box(): string |
|
633 | + { |
|
634 | + return EEH_Template::display_template( |
|
635 | + PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php', |
|
636 | + $this->_template_args, |
|
637 | + true |
|
638 | + ); |
|
639 | + } |
|
640 | + |
|
641 | + |
|
642 | + /** |
|
643 | + * @return array |
|
644 | + * @throws EE_Error |
|
645 | + * @throws ReflectionException |
|
646 | + */ |
|
647 | + protected function set_price_column_values(): array |
|
648 | + { |
|
649 | + $PRC_order = 0; |
|
650 | + $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
651 | + if ($PRT_ID) { |
|
652 | + /** @var EE_Price_Type $price_type */ |
|
653 | + $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID); |
|
654 | + if ($price_type instanceof EE_Price_Type) { |
|
655 | + $PRC_order = $price_type->order(); |
|
656 | + } |
|
657 | + } |
|
658 | + return [ |
|
659 | + 'PRT_ID' => $PRT_ID, |
|
660 | + 'PRC_amount' => $this->request->getRequestParam('PRC_amount', 0, DataType::FLOAT), |
|
661 | + 'PRC_name' => $this->request->getRequestParam('PRC_name'), |
|
662 | + 'PRC_desc' => $this->request->getRequestParam('PRC_desc'), |
|
663 | + 'PRC_is_default' => 1, |
|
664 | + 'PRC_overrides' => null, |
|
665 | + 'PRC_order' => $PRC_order, |
|
666 | + 'PRC_deleted' => 0, |
|
667 | + 'PRC_parent' => 0, |
|
668 | + ]; |
|
669 | + } |
|
670 | + |
|
671 | + |
|
672 | + /** |
|
673 | + * @param bool $insert - whether to insert or update |
|
674 | + * @return void |
|
675 | + * @throws EE_Error |
|
676 | + * @throws ReflectionException |
|
677 | + */ |
|
678 | + protected function _insert_or_update_price(bool $insert = false) |
|
679 | + { |
|
680 | + // why be so pessimistic ??? : ( |
|
681 | + $updated = 0; |
|
682 | + |
|
683 | + $set_column_values = $this->set_price_column_values(); |
|
684 | + // is this a new Price ? |
|
685 | + if ($insert) { |
|
686 | + // run the insert |
|
687 | + $PRC_ID = EEM_Price::instance()->insert($set_column_values); |
|
688 | + if ($PRC_ID) { |
|
689 | + // make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type |
|
690 | + $price = EEM_price::instance()->get_one_by_ID($PRC_ID); |
|
691 | + if ( |
|
692 | + $price instanceof EE_Price |
|
693 | + && $price->type_obj() instanceof EE_Price_type |
|
694 | + && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax |
|
695 | + ) { |
|
696 | + $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
|
697 | + $ticket->_add_relation_to($price, 'Price'); |
|
698 | + $ticket->save(); |
|
699 | + } |
|
700 | + $updated = 1; |
|
701 | + } |
|
702 | + $action_desc = 'created'; |
|
703 | + } else { |
|
704 | + $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER); |
|
705 | + // run the update |
|
706 | + $where_cols_n_values = ['PRC_ID' => $PRC_ID]; |
|
707 | + $updated = EEM_Price::instance()->update($set_column_values, [$where_cols_n_values]); |
|
708 | + |
|
709 | + $price = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
|
710 | + if ($price instanceof EE_Price && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) { |
|
711 | + // if this is $PRC_ID == 1, |
|
712 | + // then we need to update the default ticket attached to this price so the TKT_price value is updated. |
|
713 | + if ($PRC_ID === 1) { |
|
714 | + $ticket = $price->get_first_related('Ticket'); |
|
715 | + if ($ticket) { |
|
716 | + $ticket->set('TKT_price', $price->get('PRC_amount')); |
|
717 | + $ticket->set('TKT_name', $price->get('PRC_name')); |
|
718 | + $ticket->set('TKT_description', $price->get('PRC_desc')); |
|
719 | + $ticket->save(); |
|
720 | + } |
|
721 | + } else { |
|
722 | + // we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type. |
|
723 | + $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
|
724 | + $ticket->_add_relation_to($PRC_ID, 'Price'); |
|
725 | + $ticket->save(); |
|
726 | + } |
|
727 | + } |
|
728 | + |
|
729 | + $action_desc = 'updated'; |
|
730 | + } |
|
731 | + |
|
732 | + $query_args = ['action' => 'edit_price', 'id' => $PRC_ID]; |
|
733 | + |
|
734 | + $this->_redirect_after_action($updated, 'Prices', $action_desc, $query_args); |
|
735 | + } |
|
736 | + |
|
737 | + |
|
738 | + /** |
|
739 | + * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
740 | + * @return void |
|
741 | + * @throws EE_Error |
|
742 | + * @throws ReflectionException |
|
743 | + */ |
|
744 | + protected function _trash_or_restore_price(bool $trash = true) |
|
745 | + { |
|
746 | + $entity_model = EEM_Price::instance(); |
|
747 | + $action = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE; |
|
748 | + $result = $this->trashRestoreDeleteEntities( |
|
749 | + $entity_model, |
|
750 | + 'id', |
|
751 | + $action, |
|
752 | + 'PRC_deleted', |
|
753 | + [$this, 'adjustTicketRelations'] |
|
754 | + ); |
|
755 | + |
|
756 | + if ($result) { |
|
757 | + $msg = $trash |
|
758 | + ? esc_html( |
|
759 | + _n( |
|
760 | + 'The Price has been trashed', |
|
761 | + 'The Prices have been trashed', |
|
762 | + $result, |
|
763 | + 'event_espresso' |
|
764 | + ) |
|
765 | + ) |
|
766 | + : esc_html( |
|
767 | + _n( |
|
768 | + 'The Price has been restored', |
|
769 | + 'The Prices have been restored', |
|
770 | + $result, |
|
771 | + 'event_espresso' |
|
772 | + ) |
|
773 | + ); |
|
774 | + EE_Error::add_success($msg); |
|
775 | + } |
|
776 | + |
|
777 | + $this->_redirect_after_action( |
|
778 | + $result, |
|
779 | + _n('Price', 'Prices', $result, 'event_espresso'), |
|
780 | + $trash ? 'trashed' : 'restored', |
|
781 | + ['action' => 'default'], |
|
782 | + true |
|
783 | + ); |
|
784 | + } |
|
785 | + |
|
786 | + |
|
787 | + /** |
|
788 | + * @param EEM_Base $entity_model |
|
789 | + * @param int|string $entity_ID |
|
790 | + * @param string $action |
|
791 | + * @param int $result |
|
792 | + * @throws EE_Error |
|
793 | + * @throws ReflectionException |
|
794 | + * @since 4.10.30.p |
|
795 | + */ |
|
796 | + public function adjustTicketRelations( |
|
797 | + EEM_Base $entity_model, |
|
798 | + $entity_ID, |
|
799 | + string $action, |
|
800 | + int $result |
|
801 | + ) { |
|
802 | + if (! $entity_ID || (float) $result < 1) { |
|
803 | + return; |
|
804 | + } |
|
805 | + |
|
806 | + $entity = $entity_model->get_one_by_ID($entity_ID); |
|
807 | + if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) { |
|
808 | + return; |
|
809 | + } |
|
810 | + |
|
811 | + // get default tickets for updating |
|
812 | + $default_tickets = EEM_Ticket::instance()->get_all_default_tickets(); |
|
813 | + foreach ($default_tickets as $default_ticket) { |
|
814 | + if (! $default_ticket instanceof EE_Ticket) { |
|
815 | + continue; |
|
816 | + } |
|
817 | + switch ($action) { |
|
818 | + case EE_Admin_List_Table::ACTION_DELETE: |
|
819 | + case EE_Admin_List_Table::ACTION_TRASH: |
|
820 | + // if trashing then remove relations to base default ticket. |
|
821 | + $default_ticket->_remove_relation_to($entity_ID, 'Price'); |
|
822 | + break; |
|
823 | + case EE_Admin_List_Table::ACTION_RESTORE: |
|
824 | + // if restoring then add back to base default ticket |
|
825 | + $default_ticket->_add_relation_to($entity_ID, 'Price'); |
|
826 | + break; |
|
827 | + } |
|
828 | + $default_ticket->save(); |
|
829 | + } |
|
830 | + } |
|
831 | + |
|
832 | + |
|
833 | + /** |
|
834 | + * @return void |
|
835 | + * @throws EE_Error |
|
836 | + * @throws ReflectionException |
|
837 | + */ |
|
838 | + protected function _delete_price() |
|
839 | + { |
|
840 | + $entity_model = EEM_Price::instance(); |
|
841 | + $deleted = $this->trashRestoreDeleteEntities($entity_model, 'id'); |
|
842 | + $entity = $entity_model->item_name($deleted); |
|
843 | + $this->_redirect_after_action( |
|
844 | + $deleted, |
|
845 | + $entity, |
|
846 | + 'deleted', |
|
847 | + ['action' => 'default'] |
|
848 | + ); |
|
849 | + } |
|
850 | + |
|
851 | + |
|
852 | + /** |
|
853 | + * @throws EE_Error |
|
854 | + * @throws ReflectionException |
|
855 | + */ |
|
856 | + public function update_price_order() |
|
857 | + { |
|
858 | + // grab our row IDs |
|
859 | + $row_ids = $this->request->getRequestParam('row_ids', ''); |
|
860 | + $row_ids = explode(',', rtrim($row_ids, ',')); |
|
861 | + |
|
862 | + $all_updated = true; |
|
863 | + foreach ($row_ids as $i => $row_id) { |
|
864 | + // Update the prices when re-ordering |
|
865 | + $fields_n_values = ['PRC_order' => $i + 1]; |
|
866 | + $query_params = [['PRC_ID' => absint($row_id)]]; |
|
867 | + // any failure will toggle $all_updated to false |
|
868 | + $all_updated = $row_id && EEM_Price::instance()->update($fields_n_values, $query_params) !== false |
|
869 | + ? $all_updated |
|
870 | + : false; |
|
871 | + } |
|
872 | + $success = $all_updated |
|
873 | + ? esc_html__('Price order was updated successfully.', 'event_espresso') |
|
874 | + : false; |
|
875 | + $errors = ! $all_updated |
|
876 | + ? esc_html__('An error occurred. The price order was not updated.', 'event_espresso') |
|
877 | + : false; |
|
878 | + |
|
879 | + echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]); |
|
880 | + die(); |
|
881 | + } |
|
882 | + |
|
883 | + |
|
884 | + /****************************************************************************************************************** |
|
885 | 885 | *********************************************** TICKET PRICE TYPES ********************************************* |
886 | 886 | ******************************************************************************************************************/ |
887 | 887 | |
888 | 888 | |
889 | - /** |
|
890 | - * generates HTML for main Prices Admin page |
|
891 | - * |
|
892 | - * @return void |
|
893 | - * @throws EE_Error |
|
894 | - */ |
|
895 | - protected function _price_types_overview_list_table() |
|
896 | - { |
|
897 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
898 | - 'add_new_price_type', |
|
899 | - 'add_type', |
|
900 | - [], |
|
901 | - 'add-new-h2' |
|
902 | - ); |
|
903 | - $this->_admin_page_title .= $this->_learn_more_about_pricing_link(); |
|
904 | - $this->_search_btn_label = esc_html__('Price Types', 'event_espresso'); |
|
905 | - $this->display_admin_list_table_page_with_sidebar(); |
|
906 | - } |
|
907 | - |
|
908 | - |
|
909 | - /** |
|
910 | - * retrieve data for Price Types List table |
|
911 | - * |
|
912 | - * @param int $per_page how many prices displayed per page |
|
913 | - * @param bool $count return the count or objects |
|
914 | - * @param bool $trashed whether the current view is of the trash can - eww yuck! |
|
915 | - * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects |
|
916 | - * @throws EE_Error |
|
917 | - * @throws ReflectionException |
|
918 | - */ |
|
919 | - public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
920 | - { |
|
921 | - // start with an empty array |
|
922 | - require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php'); |
|
923 | - |
|
924 | - $orderby = $this->request->getRequestParam('orderby', ''); |
|
925 | - $order = $this->request->getRequestParam('order', 'ASC'); |
|
926 | - |
|
927 | - switch ($orderby) { |
|
928 | - case 'name': |
|
929 | - $orderby = ['PRT_name' => $order]; |
|
930 | - break; |
|
931 | - default: |
|
932 | - $orderby = ['PRT_order' => $order]; |
|
933 | - } |
|
934 | - |
|
935 | - $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER); |
|
936 | - $per_page = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER); |
|
937 | - |
|
938 | - $offset = ($current_page - 1) * $per_page; |
|
939 | - $limit = [$offset, $per_page]; |
|
940 | - |
|
941 | - $where = ['PRT_deleted' => $trashed, 'PBT_ID' => ['!=', 1]]; |
|
942 | - |
|
943 | - $search_term = $this->request->getRequestParam('s'); |
|
944 | - if ($search_term) { |
|
945 | - $where['OR'] = [ |
|
946 | - 'PRT_name' => ['LIKE', "%{$search_term}%"], |
|
947 | - ]; |
|
948 | - } |
|
949 | - $query_params = [ |
|
950 | - $where, |
|
951 | - 'order_by' => $orderby, |
|
952 | - 'limit' => $limit, |
|
953 | - ]; |
|
954 | - return $count |
|
955 | - ? EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params) |
|
956 | - : EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params); |
|
957 | - } |
|
958 | - |
|
959 | - |
|
960 | - /** |
|
961 | - * _edit_price_type_details |
|
962 | - * |
|
963 | - * @return void |
|
964 | - * @throws EE_Error |
|
965 | - * @throws ReflectionException |
|
966 | - */ |
|
967 | - protected function _edit_price_type_details() |
|
968 | - { |
|
969 | - // grab price type ID |
|
970 | - $PRT_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
971 | - // change page title based on request action |
|
972 | - switch ($this->_req_action) { |
|
973 | - case 'add_new_price_type': |
|
974 | - $this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso'); |
|
975 | - break; |
|
976 | - case 'edit_price_type': |
|
977 | - $this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso'); |
|
978 | - break; |
|
979 | - default: |
|
980 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
981 | - } |
|
982 | - // add PRT_ID to title if editing |
|
983 | - $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title; |
|
984 | - |
|
985 | - if ($PRT_ID) { |
|
986 | - $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID); |
|
987 | - $additional_hidden_fields = ['PRT_ID' => ['type' => 'hidden', 'value' => $PRT_ID]]; |
|
988 | - $this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields); |
|
989 | - } else { |
|
990 | - $price_type = EEM_Price_Type::instance()->get_new_price_type(); |
|
991 | - $this->_set_add_edit_form_tags('insert_price_type'); |
|
992 | - } |
|
993 | - |
|
994 | - if (! $price_type instanceof EE_Price_Type) { |
|
995 | - throw new RuntimeException( |
|
996 | - sprintf( |
|
997 | - esc_html__( |
|
998 | - 'A valid Price Type could not be retrieved from the database with ID: %1$s', |
|
999 | - 'event_espresso' |
|
1000 | - ), |
|
1001 | - $PRT_ID |
|
1002 | - ) |
|
1003 | - ); |
|
1004 | - } |
|
1005 | - |
|
1006 | - $this->_template_args['PRT_ID'] = $PRT_ID; |
|
1007 | - $this->_template_args['price_type'] = $price_type; |
|
1008 | - |
|
1009 | - $base_types = EEM_Price_Type::instance()->get_base_types(); |
|
1010 | - $select_values = []; |
|
1011 | - foreach ($base_types as $ref => $text) { |
|
1012 | - if ($ref == EEM_Price_Type::base_type_base_price) { |
|
1013 | - // do not allow creation of base_type_base_prices because that's a system only base type. |
|
1014 | - continue; |
|
1015 | - } |
|
1016 | - $select_values[] = ['id' => $ref, 'text' => $text]; |
|
1017 | - } |
|
1018 | - |
|
1019 | - $this->_template_args['base_type_select'] = EEH_Form_Fields::select_input( |
|
1020 | - 'base_type', |
|
1021 | - $select_values, |
|
1022 | - $price_type->base_type(), |
|
1023 | - 'id="price-type-base-type-slct"' |
|
1024 | - ); |
|
1025 | - |
|
1026 | - $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link(); |
|
1027 | - $this->_template_args['admin_page_content'] = $this->_edit_price_type_details_meta_box(); |
|
1028 | - |
|
1029 | - $redirect_URL = add_query_arg(['action' => 'price_types'], $this->_admin_base_url); |
|
1030 | - $this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL); |
|
1031 | - // the details template wrapper |
|
1032 | - $this->display_admin_page_with_sidebar(); |
|
1033 | - } |
|
1034 | - |
|
1035 | - |
|
1036 | - /** |
|
1037 | - * _edit_price_type_details_meta_box |
|
1038 | - * |
|
1039 | - * @return string |
|
1040 | - */ |
|
1041 | - public function _edit_price_type_details_meta_box(): string |
|
1042 | - { |
|
1043 | - return EEH_Template::display_template( |
|
1044 | - PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php', |
|
1045 | - $this->_template_args, |
|
1046 | - true |
|
1047 | - ); |
|
1048 | - } |
|
1049 | - |
|
1050 | - |
|
1051 | - /** |
|
1052 | - * @return array |
|
1053 | - */ |
|
1054 | - protected function set_price_type_column_values(): array |
|
1055 | - { |
|
1056 | - $base_type = $this->request->getRequestParam( |
|
1057 | - 'base_type', |
|
1058 | - EEM_Price_Type::base_type_base_price, |
|
1059 | - DataType::INTEGER |
|
1060 | - ); |
|
1061 | - $is_percent = $this->request->getRequestParam('PRT_is_percent', 0, DataType::INTEGER); |
|
1062 | - $order = $this->request->getRequestParam('PRT_order', 0, DataType::INTEGER); |
|
1063 | - switch ($base_type) { |
|
1064 | - case EEM_Price_Type::base_type_base_price: |
|
1065 | - $is_percent = 0; |
|
1066 | - $order = 0; |
|
1067 | - break; |
|
1068 | - |
|
1069 | - case EEM_Price_Type::base_type_discount: |
|
1070 | - case EEM_Price_Type::base_type_surcharge: |
|
1071 | - break; |
|
1072 | - |
|
1073 | - case EEM_Price_Type::base_type_tax: |
|
1074 | - $is_percent = 1; |
|
1075 | - break; |
|
1076 | - } |
|
1077 | - |
|
1078 | - return [ |
|
1079 | - 'PBT_ID' => $base_type, |
|
1080 | - 'PRT_name' => $this->request->getRequestParam('PRT_name', ''), |
|
1081 | - 'PRT_is_percent' => $is_percent, |
|
1082 | - 'PRT_order' => $order, |
|
1083 | - 'PRT_deleted' => 0, |
|
1084 | - ]; |
|
1085 | - } |
|
1086 | - |
|
1087 | - |
|
1088 | - /** |
|
1089 | - * @param bool $new_price_type - whether to insert or update |
|
1090 | - * @return void |
|
1091 | - * @throws EE_Error |
|
1092 | - * @throws ReflectionException |
|
1093 | - */ |
|
1094 | - protected function _insert_or_update_price_type(bool $new_price_type = false) |
|
1095 | - { |
|
1096 | - // why be so pessimistic ??? : ( |
|
1097 | - $success = 0; |
|
1098 | - |
|
1099 | - $set_column_values = $this->set_price_type_column_values(); |
|
1100 | - // is this a new Price ? |
|
1101 | - if ($new_price_type) { |
|
1102 | - // run the insert |
|
1103 | - if ($PRT_ID = EEM_Price_Type::instance()->insert($set_column_values)) { |
|
1104 | - $success = 1; |
|
1105 | - } |
|
1106 | - $action_desc = 'created'; |
|
1107 | - } else { |
|
1108 | - $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
1109 | - // run the update |
|
1110 | - $where_cols_n_values = ['PRT_ID' => $PRT_ID]; |
|
1111 | - if (EEM_Price_Type::instance()->update($set_column_values, [$where_cols_n_values])) { |
|
1112 | - $success = 1; |
|
1113 | - } |
|
1114 | - $action_desc = 'updated'; |
|
1115 | - } |
|
1116 | - |
|
1117 | - $query_args = ['action' => 'edit_price_type', 'id' => $PRT_ID]; |
|
1118 | - $this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args); |
|
1119 | - } |
|
1120 | - |
|
1121 | - |
|
1122 | - /** |
|
1123 | - * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
1124 | - * @return void |
|
1125 | - * @throws EE_Error |
|
1126 | - * @throws ReflectionException |
|
1127 | - */ |
|
1128 | - protected function _trash_or_restore_price_type(bool $trash = true) |
|
1129 | - { |
|
1130 | - $entity_model = EEM_Price_Type::instance(); |
|
1131 | - $action = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE; |
|
1132 | - $success = $this->trashRestoreDeleteEntities($entity_model, 'id', $action, 'PRT_deleted'); |
|
1133 | - if ($success) { |
|
1134 | - $msg = $trash |
|
1135 | - ? esc_html( |
|
1136 | - _n( |
|
1137 | - 'The Price Type has been trashed', |
|
1138 | - 'The Price Types have been trashed', |
|
1139 | - $success, |
|
1140 | - 'event_espresso' |
|
1141 | - ) |
|
1142 | - ) |
|
1143 | - : esc_html( |
|
1144 | - _n( |
|
1145 | - 'The Price Type has been restored', |
|
1146 | - 'The Price Types have been restored', |
|
1147 | - $success, |
|
1148 | - 'event_espresso' |
|
1149 | - ) |
|
1150 | - ); |
|
1151 | - EE_Error::add_success($msg); |
|
1152 | - } |
|
1153 | - $this->_redirect_after_action('', '', '', ['action' => 'price_types'], true); |
|
1154 | - } |
|
1155 | - |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * @return void |
|
1159 | - * @throws EE_Error |
|
1160 | - * @throws ReflectionException |
|
1161 | - */ |
|
1162 | - protected function _delete_price_type() |
|
1163 | - { |
|
1164 | - $entity_model = EEM_Price_Type::instance(); |
|
1165 | - $deleted = $this->trashRestoreDeleteEntities($entity_model, 'id'); |
|
1166 | - $this->_redirect_after_action( |
|
1167 | - $deleted, |
|
1168 | - $entity_model->item_name($deleted), |
|
1169 | - 'deleted', |
|
1170 | - ['action' => 'price_types'] |
|
1171 | - ); |
|
1172 | - } |
|
1173 | - |
|
1174 | - |
|
1175 | - /** |
|
1176 | - * @return string |
|
1177 | - */ |
|
1178 | - protected function _learn_more_about_pricing_link(): string |
|
1179 | - { |
|
1180 | - return ' |
|
889 | + /** |
|
890 | + * generates HTML for main Prices Admin page |
|
891 | + * |
|
892 | + * @return void |
|
893 | + * @throws EE_Error |
|
894 | + */ |
|
895 | + protected function _price_types_overview_list_table() |
|
896 | + { |
|
897 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
898 | + 'add_new_price_type', |
|
899 | + 'add_type', |
|
900 | + [], |
|
901 | + 'add-new-h2' |
|
902 | + ); |
|
903 | + $this->_admin_page_title .= $this->_learn_more_about_pricing_link(); |
|
904 | + $this->_search_btn_label = esc_html__('Price Types', 'event_espresso'); |
|
905 | + $this->display_admin_list_table_page_with_sidebar(); |
|
906 | + } |
|
907 | + |
|
908 | + |
|
909 | + /** |
|
910 | + * retrieve data for Price Types List table |
|
911 | + * |
|
912 | + * @param int $per_page how many prices displayed per page |
|
913 | + * @param bool $count return the count or objects |
|
914 | + * @param bool $trashed whether the current view is of the trash can - eww yuck! |
|
915 | + * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects |
|
916 | + * @throws EE_Error |
|
917 | + * @throws ReflectionException |
|
918 | + */ |
|
919 | + public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
920 | + { |
|
921 | + // start with an empty array |
|
922 | + require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php'); |
|
923 | + |
|
924 | + $orderby = $this->request->getRequestParam('orderby', ''); |
|
925 | + $order = $this->request->getRequestParam('order', 'ASC'); |
|
926 | + |
|
927 | + switch ($orderby) { |
|
928 | + case 'name': |
|
929 | + $orderby = ['PRT_name' => $order]; |
|
930 | + break; |
|
931 | + default: |
|
932 | + $orderby = ['PRT_order' => $order]; |
|
933 | + } |
|
934 | + |
|
935 | + $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER); |
|
936 | + $per_page = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER); |
|
937 | + |
|
938 | + $offset = ($current_page - 1) * $per_page; |
|
939 | + $limit = [$offset, $per_page]; |
|
940 | + |
|
941 | + $where = ['PRT_deleted' => $trashed, 'PBT_ID' => ['!=', 1]]; |
|
942 | + |
|
943 | + $search_term = $this->request->getRequestParam('s'); |
|
944 | + if ($search_term) { |
|
945 | + $where['OR'] = [ |
|
946 | + 'PRT_name' => ['LIKE', "%{$search_term}%"], |
|
947 | + ]; |
|
948 | + } |
|
949 | + $query_params = [ |
|
950 | + $where, |
|
951 | + 'order_by' => $orderby, |
|
952 | + 'limit' => $limit, |
|
953 | + ]; |
|
954 | + return $count |
|
955 | + ? EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params) |
|
956 | + : EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params); |
|
957 | + } |
|
958 | + |
|
959 | + |
|
960 | + /** |
|
961 | + * _edit_price_type_details |
|
962 | + * |
|
963 | + * @return void |
|
964 | + * @throws EE_Error |
|
965 | + * @throws ReflectionException |
|
966 | + */ |
|
967 | + protected function _edit_price_type_details() |
|
968 | + { |
|
969 | + // grab price type ID |
|
970 | + $PRT_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER); |
|
971 | + // change page title based on request action |
|
972 | + switch ($this->_req_action) { |
|
973 | + case 'add_new_price_type': |
|
974 | + $this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso'); |
|
975 | + break; |
|
976 | + case 'edit_price_type': |
|
977 | + $this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso'); |
|
978 | + break; |
|
979 | + default: |
|
980 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
981 | + } |
|
982 | + // add PRT_ID to title if editing |
|
983 | + $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title; |
|
984 | + |
|
985 | + if ($PRT_ID) { |
|
986 | + $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID); |
|
987 | + $additional_hidden_fields = ['PRT_ID' => ['type' => 'hidden', 'value' => $PRT_ID]]; |
|
988 | + $this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields); |
|
989 | + } else { |
|
990 | + $price_type = EEM_Price_Type::instance()->get_new_price_type(); |
|
991 | + $this->_set_add_edit_form_tags('insert_price_type'); |
|
992 | + } |
|
993 | + |
|
994 | + if (! $price_type instanceof EE_Price_Type) { |
|
995 | + throw new RuntimeException( |
|
996 | + sprintf( |
|
997 | + esc_html__( |
|
998 | + 'A valid Price Type could not be retrieved from the database with ID: %1$s', |
|
999 | + 'event_espresso' |
|
1000 | + ), |
|
1001 | + $PRT_ID |
|
1002 | + ) |
|
1003 | + ); |
|
1004 | + } |
|
1005 | + |
|
1006 | + $this->_template_args['PRT_ID'] = $PRT_ID; |
|
1007 | + $this->_template_args['price_type'] = $price_type; |
|
1008 | + |
|
1009 | + $base_types = EEM_Price_Type::instance()->get_base_types(); |
|
1010 | + $select_values = []; |
|
1011 | + foreach ($base_types as $ref => $text) { |
|
1012 | + if ($ref == EEM_Price_Type::base_type_base_price) { |
|
1013 | + // do not allow creation of base_type_base_prices because that's a system only base type. |
|
1014 | + continue; |
|
1015 | + } |
|
1016 | + $select_values[] = ['id' => $ref, 'text' => $text]; |
|
1017 | + } |
|
1018 | + |
|
1019 | + $this->_template_args['base_type_select'] = EEH_Form_Fields::select_input( |
|
1020 | + 'base_type', |
|
1021 | + $select_values, |
|
1022 | + $price_type->base_type(), |
|
1023 | + 'id="price-type-base-type-slct"' |
|
1024 | + ); |
|
1025 | + |
|
1026 | + $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link(); |
|
1027 | + $this->_template_args['admin_page_content'] = $this->_edit_price_type_details_meta_box(); |
|
1028 | + |
|
1029 | + $redirect_URL = add_query_arg(['action' => 'price_types'], $this->_admin_base_url); |
|
1030 | + $this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL); |
|
1031 | + // the details template wrapper |
|
1032 | + $this->display_admin_page_with_sidebar(); |
|
1033 | + } |
|
1034 | + |
|
1035 | + |
|
1036 | + /** |
|
1037 | + * _edit_price_type_details_meta_box |
|
1038 | + * |
|
1039 | + * @return string |
|
1040 | + */ |
|
1041 | + public function _edit_price_type_details_meta_box(): string |
|
1042 | + { |
|
1043 | + return EEH_Template::display_template( |
|
1044 | + PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php', |
|
1045 | + $this->_template_args, |
|
1046 | + true |
|
1047 | + ); |
|
1048 | + } |
|
1049 | + |
|
1050 | + |
|
1051 | + /** |
|
1052 | + * @return array |
|
1053 | + */ |
|
1054 | + protected function set_price_type_column_values(): array |
|
1055 | + { |
|
1056 | + $base_type = $this->request->getRequestParam( |
|
1057 | + 'base_type', |
|
1058 | + EEM_Price_Type::base_type_base_price, |
|
1059 | + DataType::INTEGER |
|
1060 | + ); |
|
1061 | + $is_percent = $this->request->getRequestParam('PRT_is_percent', 0, DataType::INTEGER); |
|
1062 | + $order = $this->request->getRequestParam('PRT_order', 0, DataType::INTEGER); |
|
1063 | + switch ($base_type) { |
|
1064 | + case EEM_Price_Type::base_type_base_price: |
|
1065 | + $is_percent = 0; |
|
1066 | + $order = 0; |
|
1067 | + break; |
|
1068 | + |
|
1069 | + case EEM_Price_Type::base_type_discount: |
|
1070 | + case EEM_Price_Type::base_type_surcharge: |
|
1071 | + break; |
|
1072 | + |
|
1073 | + case EEM_Price_Type::base_type_tax: |
|
1074 | + $is_percent = 1; |
|
1075 | + break; |
|
1076 | + } |
|
1077 | + |
|
1078 | + return [ |
|
1079 | + 'PBT_ID' => $base_type, |
|
1080 | + 'PRT_name' => $this->request->getRequestParam('PRT_name', ''), |
|
1081 | + 'PRT_is_percent' => $is_percent, |
|
1082 | + 'PRT_order' => $order, |
|
1083 | + 'PRT_deleted' => 0, |
|
1084 | + ]; |
|
1085 | + } |
|
1086 | + |
|
1087 | + |
|
1088 | + /** |
|
1089 | + * @param bool $new_price_type - whether to insert or update |
|
1090 | + * @return void |
|
1091 | + * @throws EE_Error |
|
1092 | + * @throws ReflectionException |
|
1093 | + */ |
|
1094 | + protected function _insert_or_update_price_type(bool $new_price_type = false) |
|
1095 | + { |
|
1096 | + // why be so pessimistic ??? : ( |
|
1097 | + $success = 0; |
|
1098 | + |
|
1099 | + $set_column_values = $this->set_price_type_column_values(); |
|
1100 | + // is this a new Price ? |
|
1101 | + if ($new_price_type) { |
|
1102 | + // run the insert |
|
1103 | + if ($PRT_ID = EEM_Price_Type::instance()->insert($set_column_values)) { |
|
1104 | + $success = 1; |
|
1105 | + } |
|
1106 | + $action_desc = 'created'; |
|
1107 | + } else { |
|
1108 | + $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER); |
|
1109 | + // run the update |
|
1110 | + $where_cols_n_values = ['PRT_ID' => $PRT_ID]; |
|
1111 | + if (EEM_Price_Type::instance()->update($set_column_values, [$where_cols_n_values])) { |
|
1112 | + $success = 1; |
|
1113 | + } |
|
1114 | + $action_desc = 'updated'; |
|
1115 | + } |
|
1116 | + |
|
1117 | + $query_args = ['action' => 'edit_price_type', 'id' => $PRT_ID]; |
|
1118 | + $this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args); |
|
1119 | + } |
|
1120 | + |
|
1121 | + |
|
1122 | + /** |
|
1123 | + * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
1124 | + * @return void |
|
1125 | + * @throws EE_Error |
|
1126 | + * @throws ReflectionException |
|
1127 | + */ |
|
1128 | + protected function _trash_or_restore_price_type(bool $trash = true) |
|
1129 | + { |
|
1130 | + $entity_model = EEM_Price_Type::instance(); |
|
1131 | + $action = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE; |
|
1132 | + $success = $this->trashRestoreDeleteEntities($entity_model, 'id', $action, 'PRT_deleted'); |
|
1133 | + if ($success) { |
|
1134 | + $msg = $trash |
|
1135 | + ? esc_html( |
|
1136 | + _n( |
|
1137 | + 'The Price Type has been trashed', |
|
1138 | + 'The Price Types have been trashed', |
|
1139 | + $success, |
|
1140 | + 'event_espresso' |
|
1141 | + ) |
|
1142 | + ) |
|
1143 | + : esc_html( |
|
1144 | + _n( |
|
1145 | + 'The Price Type has been restored', |
|
1146 | + 'The Price Types have been restored', |
|
1147 | + $success, |
|
1148 | + 'event_espresso' |
|
1149 | + ) |
|
1150 | + ); |
|
1151 | + EE_Error::add_success($msg); |
|
1152 | + } |
|
1153 | + $this->_redirect_after_action('', '', '', ['action' => 'price_types'], true); |
|
1154 | + } |
|
1155 | + |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * @return void |
|
1159 | + * @throws EE_Error |
|
1160 | + * @throws ReflectionException |
|
1161 | + */ |
|
1162 | + protected function _delete_price_type() |
|
1163 | + { |
|
1164 | + $entity_model = EEM_Price_Type::instance(); |
|
1165 | + $deleted = $this->trashRestoreDeleteEntities($entity_model, 'id'); |
|
1166 | + $this->_redirect_after_action( |
|
1167 | + $deleted, |
|
1168 | + $entity_model->item_name($deleted), |
|
1169 | + 'deleted', |
|
1170 | + ['action' => 'price_types'] |
|
1171 | + ); |
|
1172 | + } |
|
1173 | + |
|
1174 | + |
|
1175 | + /** |
|
1176 | + * @return string |
|
1177 | + */ |
|
1178 | + protected function _learn_more_about_pricing_link(): string |
|
1179 | + { |
|
1180 | + return ' |
|
1181 | 1181 | <a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" > |
1182 | 1182 | ' . esc_html__('learn more about how pricing works', 'event_espresso') . ' |
1183 | 1183 | </a>'; |
1184 | - } |
|
1185 | - |
|
1186 | - |
|
1187 | - /** |
|
1188 | - * @throws EE_Error |
|
1189 | - */ |
|
1190 | - protected function _tax_settings() |
|
1191 | - { |
|
1192 | - $this->_set_add_edit_form_tags('update_tax_settings'); |
|
1193 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1194 | - $this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html(); |
|
1195 | - $this->display_admin_page_with_sidebar(); |
|
1196 | - } |
|
1197 | - |
|
1198 | - |
|
1199 | - /** |
|
1200 | - * @return EE_Form_Section_Proper |
|
1201 | - * @throws EE_Error |
|
1202 | - */ |
|
1203 | - protected function tax_settings_form(): EE_Form_Section_Proper |
|
1204 | - { |
|
1205 | - $tax_settings = EE_Config::instance()->tax_settings; |
|
1206 | - return new EE_Form_Section_Proper( |
|
1207 | - [ |
|
1208 | - 'name' => 'tax_settings_form', |
|
1209 | - 'html_id' => 'tax_settings_form', |
|
1210 | - 'html_class' => 'padding', |
|
1211 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
1212 | - 'subsections' => apply_filters( |
|
1213 | - 'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections', |
|
1214 | - [ |
|
1215 | - 'tax_settings' => new EE_Form_Section_Proper( |
|
1216 | - [ |
|
1217 | - 'name' => 'tax_settings_tbl', |
|
1218 | - 'html_id' => 'tax_settings_tbl', |
|
1219 | - 'html_class' => 'form-table', |
|
1220 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1221 | - 'subsections' => [ |
|
1222 | - 'prices_displayed_including_taxes' => new EE_Yes_No_Input( |
|
1223 | - [ |
|
1224 | - 'html_label_text' => esc_html__( |
|
1225 | - 'Show Prices With Taxes Included?', |
|
1226 | - 'event_espresso' |
|
1227 | - ), |
|
1228 | - 'html_help_text' => esc_html__( |
|
1229 | - 'Indicates whether or not to display prices with the taxes included', |
|
1230 | - 'event_espresso' |
|
1231 | - ), |
|
1232 | - 'default' => $tax_settings->prices_displayed_including_taxes |
|
1233 | - ?? true, |
|
1234 | - 'display_html_label_text' => false, |
|
1235 | - ] |
|
1236 | - ), |
|
1237 | - ], |
|
1238 | - ] |
|
1239 | - ), |
|
1240 | - ] |
|
1241 | - ), |
|
1242 | - ] |
|
1243 | - ); |
|
1244 | - } |
|
1245 | - |
|
1246 | - |
|
1247 | - /** |
|
1248 | - * _update_tax_settings |
|
1249 | - * |
|
1250 | - * @return void |
|
1251 | - * @throws EE_Error |
|
1252 | - * @throws ReflectionException |
|
1253 | - * @since 4.9.13 |
|
1254 | - */ |
|
1255 | - public function _update_tax_settings() |
|
1256 | - { |
|
1257 | - $tax_settings = EE_Config::instance()->tax_settings; |
|
1258 | - if (! $tax_settings instanceof EE_Tax_Config) { |
|
1259 | - $tax_settings = new EE_Tax_Config(); |
|
1260 | - } |
|
1261 | - try { |
|
1262 | - $tax_form = $this->tax_settings_form(); |
|
1263 | - // check for form submission |
|
1264 | - if ($tax_form->was_submitted()) { |
|
1265 | - // capture form data |
|
1266 | - $tax_form->receive_form_submission(); |
|
1267 | - // validate form data |
|
1268 | - if ($tax_form->is_valid()) { |
|
1269 | - // grab validated data from form |
|
1270 | - $valid_data = $tax_form->valid_data(); |
|
1271 | - // set data on config |
|
1272 | - $tax_settings->prices_displayed_including_taxes = |
|
1273 | - $valid_data['tax_settings']['prices_displayed_including_taxes']; |
|
1274 | - } else { |
|
1275 | - if ($tax_form->submission_error_message() !== '') { |
|
1276 | - EE_Error::add_error( |
|
1277 | - $tax_form->submission_error_message(), |
|
1278 | - __FILE__, |
|
1279 | - __FUNCTION__, |
|
1280 | - __LINE__ |
|
1281 | - ); |
|
1282 | - } |
|
1283 | - } |
|
1284 | - } |
|
1285 | - } catch (EE_Error $e) { |
|
1286 | - EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__); |
|
1287 | - } |
|
1288 | - |
|
1289 | - $what = 'Tax Settings'; |
|
1290 | - $success = $this->_update_espresso_configuration( |
|
1291 | - $what, |
|
1292 | - $tax_settings, |
|
1293 | - __FILE__, |
|
1294 | - __FUNCTION__, |
|
1295 | - __LINE__ |
|
1296 | - ); |
|
1297 | - $this->_redirect_after_action($success, $what, 'updated', ['action' => 'tax_settings']); |
|
1298 | - } |
|
1184 | + } |
|
1185 | + |
|
1186 | + |
|
1187 | + /** |
|
1188 | + * @throws EE_Error |
|
1189 | + */ |
|
1190 | + protected function _tax_settings() |
|
1191 | + { |
|
1192 | + $this->_set_add_edit_form_tags('update_tax_settings'); |
|
1193 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1194 | + $this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html(); |
|
1195 | + $this->display_admin_page_with_sidebar(); |
|
1196 | + } |
|
1197 | + |
|
1198 | + |
|
1199 | + /** |
|
1200 | + * @return EE_Form_Section_Proper |
|
1201 | + * @throws EE_Error |
|
1202 | + */ |
|
1203 | + protected function tax_settings_form(): EE_Form_Section_Proper |
|
1204 | + { |
|
1205 | + $tax_settings = EE_Config::instance()->tax_settings; |
|
1206 | + return new EE_Form_Section_Proper( |
|
1207 | + [ |
|
1208 | + 'name' => 'tax_settings_form', |
|
1209 | + 'html_id' => 'tax_settings_form', |
|
1210 | + 'html_class' => 'padding', |
|
1211 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
1212 | + 'subsections' => apply_filters( |
|
1213 | + 'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections', |
|
1214 | + [ |
|
1215 | + 'tax_settings' => new EE_Form_Section_Proper( |
|
1216 | + [ |
|
1217 | + 'name' => 'tax_settings_tbl', |
|
1218 | + 'html_id' => 'tax_settings_tbl', |
|
1219 | + 'html_class' => 'form-table', |
|
1220 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1221 | + 'subsections' => [ |
|
1222 | + 'prices_displayed_including_taxes' => new EE_Yes_No_Input( |
|
1223 | + [ |
|
1224 | + 'html_label_text' => esc_html__( |
|
1225 | + 'Show Prices With Taxes Included?', |
|
1226 | + 'event_espresso' |
|
1227 | + ), |
|
1228 | + 'html_help_text' => esc_html__( |
|
1229 | + 'Indicates whether or not to display prices with the taxes included', |
|
1230 | + 'event_espresso' |
|
1231 | + ), |
|
1232 | + 'default' => $tax_settings->prices_displayed_including_taxes |
|
1233 | + ?? true, |
|
1234 | + 'display_html_label_text' => false, |
|
1235 | + ] |
|
1236 | + ), |
|
1237 | + ], |
|
1238 | + ] |
|
1239 | + ), |
|
1240 | + ] |
|
1241 | + ), |
|
1242 | + ] |
|
1243 | + ); |
|
1244 | + } |
|
1245 | + |
|
1246 | + |
|
1247 | + /** |
|
1248 | + * _update_tax_settings |
|
1249 | + * |
|
1250 | + * @return void |
|
1251 | + * @throws EE_Error |
|
1252 | + * @throws ReflectionException |
|
1253 | + * @since 4.9.13 |
|
1254 | + */ |
|
1255 | + public function _update_tax_settings() |
|
1256 | + { |
|
1257 | + $tax_settings = EE_Config::instance()->tax_settings; |
|
1258 | + if (! $tax_settings instanceof EE_Tax_Config) { |
|
1259 | + $tax_settings = new EE_Tax_Config(); |
|
1260 | + } |
|
1261 | + try { |
|
1262 | + $tax_form = $this->tax_settings_form(); |
|
1263 | + // check for form submission |
|
1264 | + if ($tax_form->was_submitted()) { |
|
1265 | + // capture form data |
|
1266 | + $tax_form->receive_form_submission(); |
|
1267 | + // validate form data |
|
1268 | + if ($tax_form->is_valid()) { |
|
1269 | + // grab validated data from form |
|
1270 | + $valid_data = $tax_form->valid_data(); |
|
1271 | + // set data on config |
|
1272 | + $tax_settings->prices_displayed_including_taxes = |
|
1273 | + $valid_data['tax_settings']['prices_displayed_including_taxes']; |
|
1274 | + } else { |
|
1275 | + if ($tax_form->submission_error_message() !== '') { |
|
1276 | + EE_Error::add_error( |
|
1277 | + $tax_form->submission_error_message(), |
|
1278 | + __FILE__, |
|
1279 | + __FUNCTION__, |
|
1280 | + __LINE__ |
|
1281 | + ); |
|
1282 | + } |
|
1283 | + } |
|
1284 | + } |
|
1285 | + } catch (EE_Error $e) { |
|
1286 | + EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__); |
|
1287 | + } |
|
1288 | + |
|
1289 | + $what = 'Tax Settings'; |
|
1290 | + $success = $this->_update_espresso_configuration( |
|
1291 | + $what, |
|
1292 | + $tax_settings, |
|
1293 | + __FILE__, |
|
1294 | + __FUNCTION__, |
|
1295 | + __LINE__ |
|
1296 | + ); |
|
1297 | + $this->_redirect_after_action($success, $what, 'updated', ['action' => 'tax_settings']); |
|
1298 | + } |
|
1299 | 1299 | } |
@@ -14,26 +14,26 @@ |
||
14 | 14 | */ |
15 | 15 | abstract class CommandHandler implements CommandHandlerInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * Verifies the Command class matches the Handler class |
|
19 | - * by simply removing "Handler" from the Command class and then comparing. |
|
20 | - * IF the Command Handler has been changed via CommandHandlerManager::addCommandHandler, |
|
21 | - * or via the filter in CommandHandlerManager::getCommandHandler(), |
|
22 | - * then this method MUST be overridden in the new Command Handler class. |
|
23 | - * PLZ NOTE: that it also needs to return itself ($this) |
|
24 | - * because the CommandBus utilizes method chaining. |
|
25 | - * |
|
26 | - * @param CommandInterface $command |
|
27 | - * @return CommandHandlerInterface |
|
28 | - * @throws InvalidEntityException |
|
29 | - * @since 4.9.80.p |
|
30 | - */ |
|
31 | - public function verify(CommandInterface $command): CommandHandlerInterface |
|
32 | - { |
|
33 | - $expected = str_replace('CommandHandler', 'Command', get_class($this)); |
|
34 | - if (! $command instanceof $expected) { |
|
35 | - throw new InvalidEntityException($command, $expected); |
|
36 | - } |
|
37 | - return $this; |
|
38 | - } |
|
17 | + /** |
|
18 | + * Verifies the Command class matches the Handler class |
|
19 | + * by simply removing "Handler" from the Command class and then comparing. |
|
20 | + * IF the Command Handler has been changed via CommandHandlerManager::addCommandHandler, |
|
21 | + * or via the filter in CommandHandlerManager::getCommandHandler(), |
|
22 | + * then this method MUST be overridden in the new Command Handler class. |
|
23 | + * PLZ NOTE: that it also needs to return itself ($this) |
|
24 | + * because the CommandBus utilizes method chaining. |
|
25 | + * |
|
26 | + * @param CommandInterface $command |
|
27 | + * @return CommandHandlerInterface |
|
28 | + * @throws InvalidEntityException |
|
29 | + * @since 4.9.80.p |
|
30 | + */ |
|
31 | + public function verify(CommandInterface $command): CommandHandlerInterface |
|
32 | + { |
|
33 | + $expected = str_replace('CommandHandler', 'Command', get_class($this)); |
|
34 | + if (! $command instanceof $expected) { |
|
35 | + throw new InvalidEntityException($command, $expected); |
|
36 | + } |
|
37 | + return $this; |
|
38 | + } |
|
39 | 39 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | public function verify(CommandInterface $command): CommandHandlerInterface |
32 | 32 | { |
33 | 33 | $expected = str_replace('CommandHandler', 'Command', get_class($this)); |
34 | - if (! $command instanceof $expected) { |
|
34 | + if ( ! $command instanceof $expected) { |
|
35 | 35 | throw new InvalidEntityException($command, $expected); |
36 | 36 | } |
37 | 37 | return $this; |