@@ -13,45 +13,45 @@ |
||
13 | 13 | class EE_Detect_File_Editor_Request extends EE_Middleware |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Converts a Request to a Response |
|
18 | - * |
|
19 | - * @param EE_Request $request |
|
20 | - * @param EE_Response $response |
|
21 | - * @return EE_Response |
|
22 | - */ |
|
23 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
24 | - { |
|
25 | - $this->_request = $request; |
|
26 | - $this->_response = $response; |
|
27 | - $this->setFiltersForRequest(); |
|
28 | - $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
29 | - return $this->_response; |
|
30 | - } |
|
16 | + /** |
|
17 | + * Converts a Request to a Response |
|
18 | + * |
|
19 | + * @param EE_Request $request |
|
20 | + * @param EE_Response $response |
|
21 | + * @return EE_Response |
|
22 | + */ |
|
23 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
24 | + { |
|
25 | + $this->_request = $request; |
|
26 | + $this->_response = $response; |
|
27 | + $this->setFiltersForRequest(); |
|
28 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
29 | + return $this->_response; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * This sets any filters that need set on this request. |
|
35 | - */ |
|
36 | - protected function setFiltersForRequest() |
|
37 | - { |
|
38 | - if (! $this->isFileEditorRequest()) { |
|
39 | - return; |
|
40 | - } |
|
41 | - add_filter('FHEE_load_EE_Session', '__return_false', 999); |
|
42 | - } |
|
33 | + /** |
|
34 | + * This sets any filters that need set on this request. |
|
35 | + */ |
|
36 | + protected function setFiltersForRequest() |
|
37 | + { |
|
38 | + if (! $this->isFileEditorRequest()) { |
|
39 | + return; |
|
40 | + } |
|
41 | + add_filter('FHEE_load_EE_Session', '__return_false', 999); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * Conditions for a "file editor request" |
|
47 | - * @see wp-admin/includes/file.php |
|
48 | - * The file editor does a loopback request to the admin AND to the frontend when checking active theme or |
|
49 | - * active plugin edits. So these conditions consider that. |
|
50 | - * @return bool |
|
51 | - */ |
|
52 | - protected function isFileEditorRequest() |
|
53 | - { |
|
54 | - return $this->_request->get('wp_scrape_key') |
|
55 | - && $this->_request->get('wp_scrape_nonce'); |
|
56 | - } |
|
45 | + /** |
|
46 | + * Conditions for a "file editor request" |
|
47 | + * @see wp-admin/includes/file.php |
|
48 | + * The file editor does a loopback request to the admin AND to the frontend when checking active theme or |
|
49 | + * active plugin edits. So these conditions consider that. |
|
50 | + * @return bool |
|
51 | + */ |
|
52 | + protected function isFileEditorRequest() |
|
53 | + { |
|
54 | + return $this->_request->get('wp_scrape_key') |
|
55 | + && $this->_request->get('wp_scrape_nonce'); |
|
56 | + } |
|
57 | 57 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | protected function setFiltersForRequest() |
37 | 37 | { |
38 | - if (! $this->isFileEditorRequest()) { |
|
38 | + if ( ! $this->isFileEditorRequest()) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | add_filter('FHEE_load_EE_Session', '__return_false', 999); |
@@ -29,192 +29,192 @@ |
||
29 | 29 | class EE_Bootstrap |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @var EE_Request $request |
|
34 | - */ |
|
35 | - protected $request; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var EE_Response $response |
|
39 | - */ |
|
40 | - protected $response; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var EE_Request_Stack_Builder $request_stack_builder |
|
44 | - */ |
|
45 | - protected $request_stack_builder; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var EE_Request_Stack $_request_stack |
|
49 | - */ |
|
50 | - protected $request_stack; |
|
51 | - |
|
52 | - |
|
53 | - |
|
54 | - public function __construct(EE_Request $request, EE_Response $response) |
|
55 | - { |
|
56 | - $this->request = $request; |
|
57 | - $this->response = $response; |
|
58 | - // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
59 | - add_action('plugins_loaded', array($this, 'run_request_stack'), 0); |
|
60 | - // set framework for the rest of EE to hook into when loading |
|
61 | - add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
62 | - add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
63 | - add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
64 | - add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
65 | - add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * run_request_stack |
|
72 | - * construct request stack and run middleware apps |
|
73 | - * |
|
74 | - * @throws EE_Error |
|
75 | - * @throws InvalidArgumentException |
|
76 | - */ |
|
77 | - public function run_request_stack() |
|
78 | - { |
|
79 | - $this->load_autoloader(); |
|
80 | - $this->set_autoloaders_for_required_files(); |
|
81 | - $this->request_stack_builder = $this->build_request_stack(); |
|
82 | - $this->request_stack = $this->request_stack_builder->resolve( |
|
83 | - new EE_Load_Espresso_Core() |
|
84 | - ); |
|
85 | - $this->request_stack->handle_request($this->request, $this->response); |
|
86 | - $this->request_stack->handle_response(); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * load_autoloader |
|
93 | - */ |
|
94 | - protected function load_autoloader() |
|
95 | - { |
|
96 | - // load interfaces |
|
97 | - espresso_load_required( |
|
98 | - 'EEH_Autoloader', |
|
99 | - EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
100 | - ); |
|
101 | - EEH_Autoloader::instance(); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * load_required_files |
|
108 | - * |
|
109 | - * @throws EE_Error |
|
110 | - */ |
|
111 | - protected function set_autoloaders_for_required_files() |
|
112 | - { |
|
113 | - // load interfaces |
|
114 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
115 | - // load helpers |
|
116 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
117 | - // load request stack |
|
118 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
119 | - // load middleware |
|
120 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * build_request_stack |
|
127 | - * |
|
128 | - * @return EE_Request_Stack_Builder |
|
129 | - * @throws InvalidArgumentException |
|
130 | - */ |
|
131 | - public function build_request_stack() |
|
132 | - { |
|
133 | - $request_stack_builder = new EE_Request_Stack_Builder(); |
|
134 | - $stack_apps = apply_filters( |
|
135 | - 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
136 | - array( |
|
137 | - 'EE_Detect_File_Editor_Request', |
|
138 | - 'EE_Detect_Login', |
|
139 | - 'EE_Recommended_Versions', |
|
140 | - 'EE_Alpha_Banner_Warning', |
|
141 | - ) |
|
142 | - ); |
|
143 | - // load middleware onto stack : FILO (First In Last Out) |
|
144 | - foreach ((array)$stack_apps as $stack_app) { |
|
145 | - //$request_stack_builder->push( $stack_app ); |
|
146 | - $request_stack_builder->unshift($stack_app); |
|
147 | - } |
|
148 | - return apply_filters( |
|
149 | - 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
150 | - $request_stack_builder |
|
151 | - ); |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * load_espresso_addons |
|
158 | - * runs during the WP 'plugins_loaded' action at priority 1 |
|
159 | - * and is the initial loading phase for EE addons |
|
160 | - * no other logic should be performed at this point |
|
161 | - */ |
|
162 | - public static function load_espresso_addons() |
|
163 | - { |
|
164 | - do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * detect_activations_or_upgrades |
|
171 | - * runs during the WP 'plugins_loaded' action at priority 3 |
|
172 | - * Now that all of the addons have been loaded, |
|
173 | - * we can determine if anything needs activating or upgrading |
|
174 | - */ |
|
175 | - public static function detect_activations_or_upgrades() |
|
176 | - { |
|
177 | - do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * load_core_configuration |
|
184 | - * runs during the WP 'plugins_loaded' action at priority 5 |
|
185 | - * Now that the database is assumed to be at the correct version |
|
186 | - * we can load and set all of the system configurations |
|
187 | - */ |
|
188 | - public static function load_core_configuration() |
|
189 | - { |
|
190 | - do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * register_shortcodes_modules_and_widgets |
|
197 | - * runs during the WP 'plugins_loaded' action at priority 7 |
|
198 | - * and handles registering all o four shortcodes, modules and widgets |
|
199 | - * so that they are ready to be used throughout the system |
|
200 | - */ |
|
201 | - public static function register_shortcodes_modules_and_widgets() |
|
202 | - { |
|
203 | - do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * brew_espresso |
|
210 | - * runs during the WP 'plugins_loaded' action at priority 9 |
|
211 | - * bootstrapping is considered complete at this point, |
|
212 | - * so let the fun begin... |
|
213 | - */ |
|
214 | - public static function brew_espresso() |
|
215 | - { |
|
216 | - do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
217 | - } |
|
32 | + /** |
|
33 | + * @var EE_Request $request |
|
34 | + */ |
|
35 | + protected $request; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var EE_Response $response |
|
39 | + */ |
|
40 | + protected $response; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var EE_Request_Stack_Builder $request_stack_builder |
|
44 | + */ |
|
45 | + protected $request_stack_builder; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var EE_Request_Stack $_request_stack |
|
49 | + */ |
|
50 | + protected $request_stack; |
|
51 | + |
|
52 | + |
|
53 | + |
|
54 | + public function __construct(EE_Request $request, EE_Response $response) |
|
55 | + { |
|
56 | + $this->request = $request; |
|
57 | + $this->response = $response; |
|
58 | + // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
59 | + add_action('plugins_loaded', array($this, 'run_request_stack'), 0); |
|
60 | + // set framework for the rest of EE to hook into when loading |
|
61 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
62 | + add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
63 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
64 | + add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
65 | + add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * run_request_stack |
|
72 | + * construct request stack and run middleware apps |
|
73 | + * |
|
74 | + * @throws EE_Error |
|
75 | + * @throws InvalidArgumentException |
|
76 | + */ |
|
77 | + public function run_request_stack() |
|
78 | + { |
|
79 | + $this->load_autoloader(); |
|
80 | + $this->set_autoloaders_for_required_files(); |
|
81 | + $this->request_stack_builder = $this->build_request_stack(); |
|
82 | + $this->request_stack = $this->request_stack_builder->resolve( |
|
83 | + new EE_Load_Espresso_Core() |
|
84 | + ); |
|
85 | + $this->request_stack->handle_request($this->request, $this->response); |
|
86 | + $this->request_stack->handle_response(); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * load_autoloader |
|
93 | + */ |
|
94 | + protected function load_autoloader() |
|
95 | + { |
|
96 | + // load interfaces |
|
97 | + espresso_load_required( |
|
98 | + 'EEH_Autoloader', |
|
99 | + EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
100 | + ); |
|
101 | + EEH_Autoloader::instance(); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * load_required_files |
|
108 | + * |
|
109 | + * @throws EE_Error |
|
110 | + */ |
|
111 | + protected function set_autoloaders_for_required_files() |
|
112 | + { |
|
113 | + // load interfaces |
|
114 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
115 | + // load helpers |
|
116 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
117 | + // load request stack |
|
118 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
119 | + // load middleware |
|
120 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * build_request_stack |
|
127 | + * |
|
128 | + * @return EE_Request_Stack_Builder |
|
129 | + * @throws InvalidArgumentException |
|
130 | + */ |
|
131 | + public function build_request_stack() |
|
132 | + { |
|
133 | + $request_stack_builder = new EE_Request_Stack_Builder(); |
|
134 | + $stack_apps = apply_filters( |
|
135 | + 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
136 | + array( |
|
137 | + 'EE_Detect_File_Editor_Request', |
|
138 | + 'EE_Detect_Login', |
|
139 | + 'EE_Recommended_Versions', |
|
140 | + 'EE_Alpha_Banner_Warning', |
|
141 | + ) |
|
142 | + ); |
|
143 | + // load middleware onto stack : FILO (First In Last Out) |
|
144 | + foreach ((array)$stack_apps as $stack_app) { |
|
145 | + //$request_stack_builder->push( $stack_app ); |
|
146 | + $request_stack_builder->unshift($stack_app); |
|
147 | + } |
|
148 | + return apply_filters( |
|
149 | + 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
150 | + $request_stack_builder |
|
151 | + ); |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * load_espresso_addons |
|
158 | + * runs during the WP 'plugins_loaded' action at priority 1 |
|
159 | + * and is the initial loading phase for EE addons |
|
160 | + * no other logic should be performed at this point |
|
161 | + */ |
|
162 | + public static function load_espresso_addons() |
|
163 | + { |
|
164 | + do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * detect_activations_or_upgrades |
|
171 | + * runs during the WP 'plugins_loaded' action at priority 3 |
|
172 | + * Now that all of the addons have been loaded, |
|
173 | + * we can determine if anything needs activating or upgrading |
|
174 | + */ |
|
175 | + public static function detect_activations_or_upgrades() |
|
176 | + { |
|
177 | + do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * load_core_configuration |
|
184 | + * runs during the WP 'plugins_loaded' action at priority 5 |
|
185 | + * Now that the database is assumed to be at the correct version |
|
186 | + * we can load and set all of the system configurations |
|
187 | + */ |
|
188 | + public static function load_core_configuration() |
|
189 | + { |
|
190 | + do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * register_shortcodes_modules_and_widgets |
|
197 | + * runs during the WP 'plugins_loaded' action at priority 7 |
|
198 | + * and handles registering all o four shortcodes, modules and widgets |
|
199 | + * so that they are ready to be used throughout the system |
|
200 | + */ |
|
201 | + public static function register_shortcodes_modules_and_widgets() |
|
202 | + { |
|
203 | + do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * brew_espresso |
|
210 | + * runs during the WP 'plugins_loaded' action at priority 9 |
|
211 | + * bootstrapping is considered complete at this point, |
|
212 | + * so let the fun begin... |
|
213 | + */ |
|
214 | + public static function brew_espresso() |
|
215 | + { |
|
216 | + do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
217 | + } |
|
218 | 218 | |
219 | 219 | |
220 | 220 |
@@ -13,65 +13,65 @@ |
||
13 | 13 | class Checkout |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * The class selector for the next step button in the checkout. |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn'; |
|
21 | - |
|
22 | - |
|
23 | - const PAYMENT_METHOD_STEP_FORM = '#ee-spco-payment_options-reg-step-form'; |
|
24 | - |
|
25 | - |
|
26 | - const SELECTOR_PAYMENT_OPTIONS_CONTAINER = '#spco-available-methods-of-payment-dv'; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * @param int $attendee_number |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
34 | - { |
|
35 | - return self::fieldSelectorForAttendeeNumber('fname', $attendee_number); |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * @param int $attendee_number |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
44 | - { |
|
45 | - return self::fieldSelectorForAttendeeNumber('lname', $attendee_number); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * @param int $attendee_number |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
54 | - { |
|
55 | - return self::fieldSelectorForAttendeeNumber('email', $attendee_number); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @param $field_name |
|
60 | - * @param int $attendee_number |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1) |
|
64 | - { |
|
65 | - return "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]"; |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @param string $payment_method_slug Slug for the payment method. |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public static function fieldSelectorForPaymentOption($payment_method_slug) |
|
74 | - { |
|
75 | - return "#ee-available-payment-method-inputs-{$payment_method_slug}"; |
|
76 | - } |
|
16 | + /** |
|
17 | + * The class selector for the next step button in the checkout. |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn'; |
|
21 | + |
|
22 | + |
|
23 | + const PAYMENT_METHOD_STEP_FORM = '#ee-spco-payment_options-reg-step-form'; |
|
24 | + |
|
25 | + |
|
26 | + const SELECTOR_PAYMENT_OPTIONS_CONTAINER = '#spco-available-methods-of-payment-dv'; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * @param int $attendee_number |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
34 | + { |
|
35 | + return self::fieldSelectorForAttendeeNumber('fname', $attendee_number); |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * @param int $attendee_number |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
44 | + { |
|
45 | + return self::fieldSelectorForAttendeeNumber('lname', $attendee_number); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * @param int $attendee_number |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1) |
|
54 | + { |
|
55 | + return self::fieldSelectorForAttendeeNumber('email', $attendee_number); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @param $field_name |
|
60 | + * @param int $attendee_number |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1) |
|
64 | + { |
|
65 | + return "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]"; |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @param string $payment_method_slug Slug for the payment method. |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public static function fieldSelectorForPaymentOption($payment_method_slug) |
|
74 | + { |
|
75 | + return "#ee-available-payment-method-inputs-{$payment_method_slug}"; |
|
76 | + } |
|
77 | 77 | } |
@@ -13,72 +13,72 @@ |
||
13 | 13 | */ |
14 | 14 | trait Checkout |
15 | 15 | { |
16 | - /** |
|
17 | - * @param $value |
|
18 | - * @param int $attendee_number |
|
19 | - */ |
|
20 | - public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1) |
|
21 | - { |
|
22 | - $this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
23 | - } |
|
16 | + /** |
|
17 | + * @param $value |
|
18 | + * @param int $attendee_number |
|
19 | + */ |
|
20 | + public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1) |
|
21 | + { |
|
22 | + $this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param $value |
|
27 | - * @param int $attendee_number |
|
28 | - */ |
|
29 | - public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1) |
|
30 | - { |
|
31 | - $this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
32 | - } |
|
25 | + /** |
|
26 | + * @param $value |
|
27 | + * @param int $attendee_number |
|
28 | + */ |
|
29 | + public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1) |
|
30 | + { |
|
31 | + $this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param $value |
|
36 | - * @param int $attendee_number |
|
37 | - */ |
|
38 | - public function fillOutEmailFieldForAttendee($value, $attendee_number = 1) |
|
39 | - { |
|
40 | - $this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
41 | - } |
|
34 | + /** |
|
35 | + * @param $value |
|
36 | + * @param int $attendee_number |
|
37 | + */ |
|
38 | + public function fillOutEmailFieldForAttendee($value, $attendee_number = 1) |
|
39 | + { |
|
40 | + $this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number), $value); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Clicks the next registration step button. |
|
46 | - */ |
|
47 | - public function goToNextRegistrationStep() |
|
48 | - { |
|
49 | - $this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR); |
|
50 | - } |
|
44 | + /** |
|
45 | + * Clicks the next registration step button. |
|
46 | + */ |
|
47 | + public function goToNextRegistrationStep() |
|
48 | + { |
|
49 | + $this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * Selects the payment option for the given payment method slug. |
|
55 | - * |
|
56 | - * @param string $payment_method_slug |
|
57 | - * @param bool $verify_selected If true, this will wait for the "Important Information" info box after the |
|
58 | - * payment option select box is complete. Otherwise its up to calling code to |
|
59 | - * wait for whatever is needed after selecting the payment method. |
|
60 | - */ |
|
61 | - public function selectPaymentOptionFor($payment_method_slug = 'invoice', $verify_selected = true) |
|
62 | - { |
|
63 | - $this->waitForElementVisible(CheckoutPage::SELECTOR_PAYMENT_OPTIONS_CONTAINER); |
|
64 | - $this->wait(5); |
|
65 | - $this->actor()->selectOption( |
|
66 | - CheckoutPage::PAYMENT_METHOD_STEP_FORM, |
|
67 | - $payment_method_slug |
|
68 | - ); |
|
69 | - if ($verify_selected) { |
|
70 | - $this->actor()->waitForText('Important information regarding your payment'); |
|
71 | - } |
|
72 | - } |
|
53 | + /** |
|
54 | + * Selects the payment option for the given payment method slug. |
|
55 | + * |
|
56 | + * @param string $payment_method_slug |
|
57 | + * @param bool $verify_selected If true, this will wait for the "Important Information" info box after the |
|
58 | + * payment option select box is complete. Otherwise its up to calling code to |
|
59 | + * wait for whatever is needed after selecting the payment method. |
|
60 | + */ |
|
61 | + public function selectPaymentOptionFor($payment_method_slug = 'invoice', $verify_selected = true) |
|
62 | + { |
|
63 | + $this->waitForElementVisible(CheckoutPage::SELECTOR_PAYMENT_OPTIONS_CONTAINER); |
|
64 | + $this->wait(5); |
|
65 | + $this->actor()->selectOption( |
|
66 | + CheckoutPage::PAYMENT_METHOD_STEP_FORM, |
|
67 | + $payment_method_slug |
|
68 | + ); |
|
69 | + if ($verify_selected) { |
|
70 | + $this->actor()->waitForText('Important information regarding your payment'); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * Submits the payment options step form. |
|
77 | - * Assumes the actor is in the context of the payment options SPCO step. |
|
78 | - */ |
|
79 | - public function submitPaymentOptionsRegistrationStepForm() |
|
80 | - { |
|
81 | - $this->actor()->submitForm(CheckoutPage::PAYMENT_METHOD_STEP_FORM, array()); |
|
82 | - } |
|
75 | + /** |
|
76 | + * Submits the payment options step form. |
|
77 | + * Assumes the actor is in the context of the payment options SPCO step. |
|
78 | + */ |
|
79 | + public function submitPaymentOptionsRegistrationStepForm() |
|
80 | + { |
|
81 | + $this->actor()->submitForm(CheckoutPage::PAYMENT_METHOD_STEP_FORM, array()); |
|
82 | + } |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @param string $table_column |
34 | 34 | * @param string $nicename |
35 | 35 | * @param bool $nullable |
36 | - * @param null $default_value |
|
36 | + * @param integer $default_value |
|
37 | 37 | * @param MoneyFactory $factory |
38 | 38 | * @param MoneyFormatter $money_formatter |
39 | 39 | * @throws InvalidArgumentException |
@@ -19,257 +19,257 @@ |
||
19 | 19 | class EE_Money_Field extends EE_Float_Field |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var $money_factory MoneyFactory |
|
24 | - */ |
|
25 | - protected $money_factory; |
|
22 | + /** |
|
23 | + * @var $money_factory MoneyFactory |
|
24 | + */ |
|
25 | + protected $money_factory; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var $money_formatter MoneyFormatter |
|
29 | - */ |
|
30 | - protected $money_formatter; |
|
27 | + /** |
|
28 | + * @var $money_formatter MoneyFormatter |
|
29 | + */ |
|
30 | + protected $money_formatter; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @param string $table_column |
|
35 | - * @param string $nicename |
|
36 | - * @param bool $nullable |
|
37 | - * @param null $default_value |
|
38 | - * @param MoneyFactory $factory |
|
39 | - * @param MoneyFormatter $money_formatter |
|
40 | - * @throws InvalidArgumentException |
|
41 | - * @throws InvalidInterfaceException |
|
42 | - * @throws InvalidDataTypeException |
|
43 | - */ |
|
44 | - public function __construct( |
|
45 | - $table_column, |
|
46 | - $nicename, |
|
47 | - $nullable, |
|
48 | - $default_value = null, |
|
49 | - MoneyFactory $factory = null, |
|
50 | - MoneyFormatter $money_formatter = null |
|
51 | - ) { |
|
52 | - if (! $factory instanceof MoneyFactory) { |
|
53 | - $factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory'); |
|
54 | - } |
|
55 | - $this->money_factory = $factory; |
|
56 | - if (! $money_formatter instanceof MoneyFormatter) { |
|
57 | - $money_formatter = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\formatters\MoneyFormatter'); |
|
58 | - } |
|
59 | - $this->money_formatter = $money_formatter; |
|
60 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
61 | - $this->setSchemaType('object'); |
|
62 | - } |
|
33 | + /** |
|
34 | + * @param string $table_column |
|
35 | + * @param string $nicename |
|
36 | + * @param bool $nullable |
|
37 | + * @param null $default_value |
|
38 | + * @param MoneyFactory $factory |
|
39 | + * @param MoneyFormatter $money_formatter |
|
40 | + * @throws InvalidArgumentException |
|
41 | + * @throws InvalidInterfaceException |
|
42 | + * @throws InvalidDataTypeException |
|
43 | + */ |
|
44 | + public function __construct( |
|
45 | + $table_column, |
|
46 | + $nicename, |
|
47 | + $nullable, |
|
48 | + $default_value = null, |
|
49 | + MoneyFactory $factory = null, |
|
50 | + MoneyFormatter $money_formatter = null |
|
51 | + ) { |
|
52 | + if (! $factory instanceof MoneyFactory) { |
|
53 | + $factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory'); |
|
54 | + } |
|
55 | + $this->money_factory = $factory; |
|
56 | + if (! $money_formatter instanceof MoneyFormatter) { |
|
57 | + $money_formatter = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\formatters\MoneyFormatter'); |
|
58 | + } |
|
59 | + $this->money_formatter = $money_formatter; |
|
60 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
61 | + $this->setSchemaType('object'); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * Formats the value for pretty output, according to $schema. |
|
67 | - * If legacy filters are being used, uses EEH_Template::format_currency() to format it; |
|
68 | - * otherwise uses MoneyFormatter. |
|
69 | - * Schemas: |
|
70 | - * CurrencyAmountFormatterInterface::RAW: "3023.0000" |
|
71 | - * CurrencyAmountFormatterInterface::DECIMAL_ONLY: "3023.00" |
|
72 | - * CurrencyAmountFormatterInterface::ADD THOUSANDS/'localized_float': "3,023.00" |
|
73 | - * CurrencyAmountFormatterInterface::ADD_CURRENCY_SIGN/'no_currency_code': "$3,023.00" |
|
74 | - * CurrencyAmountFormatterInterface::ADD_CURRENCY_CODE/null: "$3,023.00<span>USD</span>" |
|
75 | - * |
|
76 | - * @param string|Money $value_on_field_to_be_outputted |
|
77 | - * @param string $schema |
|
78 | - * @return string |
|
79 | - * @throws InvalidIdentifierException |
|
80 | - * @throws InvalidArgumentException |
|
81 | - * @throws InvalidInterfaceException |
|
82 | - * @throws InvalidDataTypeException |
|
83 | - * @throws EE_Error |
|
84 | - * @throws ReflectionException |
|
85 | - */ |
|
86 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
87 | - { |
|
88 | - //has someone hooked into the old currency formatter helper's filters? |
|
89 | - //if so, we had better stick with it |
|
90 | - if ( |
|
91 | - apply_filters( |
|
92 | - 'FHEE__EE_Money_Field__prepare_for_pretty_echoing', |
|
93 | - has_filter('FHEE__EEH_Template__format_currency__raw_amount') |
|
94 | - || has_filter('FHEE__EEH_Template__format_currency__CNT_ISO') |
|
95 | - || has_filter('FHEE__EEH_Template__format_currency__amount') |
|
96 | - || has_filter('FHEE__EEH_Template__format_currency__display_code') |
|
97 | - || has_filter('FHEE__EEH_Template__format_currency__amount_formatted'), |
|
98 | - $this, |
|
99 | - $value_on_field_to_be_outputted, |
|
100 | - $schema |
|
101 | - ) |
|
102 | - ) { |
|
103 | - $value_on_field_to_be_outputted = $this->ensureNotMoney($value_on_field_to_be_outputted); |
|
104 | - $pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
65 | + /** |
|
66 | + * Formats the value for pretty output, according to $schema. |
|
67 | + * If legacy filters are being used, uses EEH_Template::format_currency() to format it; |
|
68 | + * otherwise uses MoneyFormatter. |
|
69 | + * Schemas: |
|
70 | + * CurrencyAmountFormatterInterface::RAW: "3023.0000" |
|
71 | + * CurrencyAmountFormatterInterface::DECIMAL_ONLY: "3023.00" |
|
72 | + * CurrencyAmountFormatterInterface::ADD THOUSANDS/'localized_float': "3,023.00" |
|
73 | + * CurrencyAmountFormatterInterface::ADD_CURRENCY_SIGN/'no_currency_code': "$3,023.00" |
|
74 | + * CurrencyAmountFormatterInterface::ADD_CURRENCY_CODE/null: "$3,023.00<span>USD</span>" |
|
75 | + * |
|
76 | + * @param string|Money $value_on_field_to_be_outputted |
|
77 | + * @param string $schema |
|
78 | + * @return string |
|
79 | + * @throws InvalidIdentifierException |
|
80 | + * @throws InvalidArgumentException |
|
81 | + * @throws InvalidInterfaceException |
|
82 | + * @throws InvalidDataTypeException |
|
83 | + * @throws EE_Error |
|
84 | + * @throws ReflectionException |
|
85 | + */ |
|
86 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
87 | + { |
|
88 | + //has someone hooked into the old currency formatter helper's filters? |
|
89 | + //if so, we had better stick with it |
|
90 | + if ( |
|
91 | + apply_filters( |
|
92 | + 'FHEE__EE_Money_Field__prepare_for_pretty_echoing', |
|
93 | + has_filter('FHEE__EEH_Template__format_currency__raw_amount') |
|
94 | + || has_filter('FHEE__EEH_Template__format_currency__CNT_ISO') |
|
95 | + || has_filter('FHEE__EEH_Template__format_currency__amount') |
|
96 | + || has_filter('FHEE__EEH_Template__format_currency__display_code') |
|
97 | + || has_filter('FHEE__EEH_Template__format_currency__amount_formatted'), |
|
98 | + $this, |
|
99 | + $value_on_field_to_be_outputted, |
|
100 | + $schema |
|
101 | + ) |
|
102 | + ) { |
|
103 | + $value_on_field_to_be_outputted = $this->ensureNotMoney($value_on_field_to_be_outputted); |
|
104 | + $pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
105 | 105 | |
106 | - if ($schema === 'localized_float') { |
|
107 | - return $pretty_float; |
|
108 | - } |
|
109 | - $display_code = true; |
|
110 | - if ($schema === 'no_currency_code') { |
|
111 | - // echo "schema no currency!"; |
|
112 | - $display_code = false; |
|
113 | - } |
|
106 | + if ($schema === 'localized_float') { |
|
107 | + return $pretty_float; |
|
108 | + } |
|
109 | + $display_code = true; |
|
110 | + if ($schema === 'no_currency_code') { |
|
111 | + // echo "schema no currency!"; |
|
112 | + $display_code = false; |
|
113 | + } |
|
114 | 114 | |
115 | - //we don't use the $pretty_float because format_currency will take care of it. |
|
116 | - return EEH_Money::format_currency($value_on_field_to_be_outputted, false, $display_code); |
|
117 | - } |
|
118 | - //ok let's just use the new formatting code then |
|
119 | - $schema = (string)$schema; |
|
120 | - switch ($schema) { |
|
121 | - case (string)CurrencyAmountFormatterInterface::ADD_CURRENCY_CODE: |
|
122 | - $formatting_level = CurrencyAmountFormatterInterface::ADD_CURRENCY_CODE; |
|
123 | - break; |
|
124 | - case 'no_currency_code': |
|
125 | - case (string)CurrencyAmountFormatterInterface::ADD_CURRENCY_SIGN: |
|
126 | - $formatting_level = CurrencyAmountFormatterInterface::ADD_CURRENCY_SIGN; |
|
127 | - break; |
|
128 | - case (string)CurrencyAmountFormatterInterface::ADD_THOUSANDS: |
|
129 | - case 'localized_float': |
|
130 | - $formatting_level = CurrencyAmountFormatterInterface::ADD_THOUSANDS; |
|
131 | - break; |
|
132 | - case (string)CurrencyAmountFormatterInterface::DECIMAL_ONLY: |
|
133 | - $formatting_level = CurrencyAmountFormatterInterface::DECIMAL_ONLY; |
|
134 | - break; |
|
135 | - default: |
|
136 | - $formatting_level = CurrencyAmountFormatterInterface::INTERNATIONAL; |
|
137 | - } |
|
138 | - $value_on_field_to_be_outputted = $this->ensureMoney($value_on_field_to_be_outputted); |
|
139 | - return $this->money_formatter->format( |
|
140 | - $value_on_field_to_be_outputted, |
|
141 | - $formatting_level |
|
142 | - ); |
|
143 | - } |
|
115 | + //we don't use the $pretty_float because format_currency will take care of it. |
|
116 | + return EEH_Money::format_currency($value_on_field_to_be_outputted, false, $display_code); |
|
117 | + } |
|
118 | + //ok let's just use the new formatting code then |
|
119 | + $schema = (string)$schema; |
|
120 | + switch ($schema) { |
|
121 | + case (string)CurrencyAmountFormatterInterface::ADD_CURRENCY_CODE: |
|
122 | + $formatting_level = CurrencyAmountFormatterInterface::ADD_CURRENCY_CODE; |
|
123 | + break; |
|
124 | + case 'no_currency_code': |
|
125 | + case (string)CurrencyAmountFormatterInterface::ADD_CURRENCY_SIGN: |
|
126 | + $formatting_level = CurrencyAmountFormatterInterface::ADD_CURRENCY_SIGN; |
|
127 | + break; |
|
128 | + case (string)CurrencyAmountFormatterInterface::ADD_THOUSANDS: |
|
129 | + case 'localized_float': |
|
130 | + $formatting_level = CurrencyAmountFormatterInterface::ADD_THOUSANDS; |
|
131 | + break; |
|
132 | + case (string)CurrencyAmountFormatterInterface::DECIMAL_ONLY: |
|
133 | + $formatting_level = CurrencyAmountFormatterInterface::DECIMAL_ONLY; |
|
134 | + break; |
|
135 | + default: |
|
136 | + $formatting_level = CurrencyAmountFormatterInterface::INTERNATIONAL; |
|
137 | + } |
|
138 | + $value_on_field_to_be_outputted = $this->ensureMoney($value_on_field_to_be_outputted); |
|
139 | + return $this->money_formatter->format( |
|
140 | + $value_on_field_to_be_outputted, |
|
141 | + $formatting_level |
|
142 | + ); |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | - /** |
|
147 | - * Make sure this value is a money object |
|
148 | - * |
|
149 | - * @param string|float|int|Money $value |
|
150 | - * @return Money |
|
151 | - * @throws InvalidIdentifierException |
|
152 | - * @throws InvalidArgumentException |
|
153 | - * @throws InvalidInterfaceException |
|
154 | - * @throws InvalidDataTypeException |
|
155 | - * @throws EE_Error |
|
156 | - */ |
|
157 | - private function ensureMoney($value) |
|
158 | - { |
|
159 | - if (! $value instanceof Money) { |
|
160 | - return $this->money_factory->createForSite($value); |
|
161 | - } |
|
162 | - return $value; |
|
163 | - } |
|
146 | + /** |
|
147 | + * Make sure this value is a money object |
|
148 | + * |
|
149 | + * @param string|float|int|Money $value |
|
150 | + * @return Money |
|
151 | + * @throws InvalidIdentifierException |
|
152 | + * @throws InvalidArgumentException |
|
153 | + * @throws InvalidInterfaceException |
|
154 | + * @throws InvalidDataTypeException |
|
155 | + * @throws EE_Error |
|
156 | + */ |
|
157 | + private function ensureMoney($value) |
|
158 | + { |
|
159 | + if (! $value instanceof Money) { |
|
160 | + return $this->money_factory->createForSite($value); |
|
161 | + } |
|
162 | + return $value; |
|
163 | + } |
|
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - /** |
|
168 | - * Ensures we're dealing with something that isn't Money |
|
169 | - * (for passing off to legacy systems or the parent field) |
|
170 | - * @param string|float|int|Money $value |
|
171 | - * @return string|float|int |
|
172 | - */ |
|
173 | - private function ensureNotMoney($value) |
|
174 | - { |
|
175 | - if( $value instanceof Money) { |
|
176 | - return $value->amount(); |
|
177 | - } |
|
178 | - return $value; |
|
179 | - } |
|
167 | + /** |
|
168 | + * Ensures we're dealing with something that isn't Money |
|
169 | + * (for passing off to legacy systems or the parent field) |
|
170 | + * @param string|float|int|Money $value |
|
171 | + * @return string|float|int |
|
172 | + */ |
|
173 | + private function ensureNotMoney($value) |
|
174 | + { |
|
175 | + if( $value instanceof Money) { |
|
176 | + return $value->amount(); |
|
177 | + } |
|
178 | + return $value; |
|
179 | + } |
|
180 | 180 | |
181 | 181 | |
182 | - /** |
|
183 | - * If provided with a string, strips out money-related formatting to turn it into a proper float. |
|
184 | - * Rounds the float to the correct number of decimal places for this country's currency. |
|
185 | - * Also, interprets periods and commas according to the country's currency settings. |
|
186 | - * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, |
|
187 | - * type cast it to a float first. |
|
188 | - * |
|
189 | - * @param string|float|int|Money $value_inputted_for_field_on_model_object |
|
190 | - * @return Money |
|
191 | - * @throws InvalidInterfaceException |
|
192 | - * @throws InvalidIdentifierException |
|
193 | - * @throws InvalidDataTypeException |
|
194 | - * @throws EE_Error |
|
195 | - * @throws InvalidArgumentException |
|
196 | - */ |
|
197 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
198 | - { |
|
199 | - if ($value_inputted_for_field_on_model_object instanceof Money) { |
|
200 | - return $value_inputted_for_field_on_model_object; |
|
201 | - } |
|
202 | - //now it's a float-style string or number |
|
203 | - return $this->ensureMoney( |
|
204 | - parent::prepare_for_set($value_inputted_for_field_on_model_object) |
|
205 | - ); |
|
206 | - } |
|
182 | + /** |
|
183 | + * If provided with a string, strips out money-related formatting to turn it into a proper float. |
|
184 | + * Rounds the float to the correct number of decimal places for this country's currency. |
|
185 | + * Also, interprets periods and commas according to the country's currency settings. |
|
186 | + * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, |
|
187 | + * type cast it to a float first. |
|
188 | + * |
|
189 | + * @param string|float|int|Money $value_inputted_for_field_on_model_object |
|
190 | + * @return Money |
|
191 | + * @throws InvalidInterfaceException |
|
192 | + * @throws InvalidIdentifierException |
|
193 | + * @throws InvalidDataTypeException |
|
194 | + * @throws EE_Error |
|
195 | + * @throws InvalidArgumentException |
|
196 | + */ |
|
197 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
198 | + { |
|
199 | + if ($value_inputted_for_field_on_model_object instanceof Money) { |
|
200 | + return $value_inputted_for_field_on_model_object; |
|
201 | + } |
|
202 | + //now it's a float-style string or number |
|
203 | + return $this->ensureMoney( |
|
204 | + parent::prepare_for_set($value_inputted_for_field_on_model_object) |
|
205 | + ); |
|
206 | + } |
|
207 | 207 | |
208 | 208 | |
209 | 209 | |
210 | - /** |
|
211 | - * @param string|float|int|Money $value_of_field_on_model_object |
|
212 | - * @return float |
|
213 | - * @throws InvalidArgumentException |
|
214 | - * @throws InvalidInterfaceException |
|
215 | - * @throws InvalidDataTypeException |
|
216 | - */ |
|
217 | - public function prepare_for_get($value_of_field_on_model_object) |
|
218 | - { |
|
219 | - $value_of_field_on_model_object = $this->ensureNotMoney($value_of_field_on_model_object); |
|
220 | - $c = EE_Registry::instance()->CFG->currency; |
|
221 | - return round(parent::prepare_for_get($value_of_field_on_model_object), $c->dec_plc); |
|
222 | - } |
|
210 | + /** |
|
211 | + * @param string|float|int|Money $value_of_field_on_model_object |
|
212 | + * @return float |
|
213 | + * @throws InvalidArgumentException |
|
214 | + * @throws InvalidInterfaceException |
|
215 | + * @throws InvalidDataTypeException |
|
216 | + */ |
|
217 | + public function prepare_for_get($value_of_field_on_model_object) |
|
218 | + { |
|
219 | + $value_of_field_on_model_object = $this->ensureNotMoney($value_of_field_on_model_object); |
|
220 | + $c = EE_Registry::instance()->CFG->currency; |
|
221 | + return round(parent::prepare_for_get($value_of_field_on_model_object), $c->dec_plc); |
|
222 | + } |
|
223 | 223 | |
224 | 224 | |
225 | - /** |
|
226 | - * Takes the incoming float and create a money entity for the model object |
|
227 | - * |
|
228 | - * @param string|float|int $value_found_in_db_for_model_object |
|
229 | - * @return Money |
|
230 | - * @throws InvalidIdentifierException |
|
231 | - * @throws InvalidArgumentException |
|
232 | - * @throws InvalidInterfaceException |
|
233 | - * @throws InvalidDataTypeException |
|
234 | - * @throws EE_Error |
|
235 | - */ |
|
236 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
237 | - { |
|
238 | - return $this->money_factory->createForSite($value_found_in_db_for_model_object); |
|
239 | - } |
|
225 | + /** |
|
226 | + * Takes the incoming float and create a money entity for the model object |
|
227 | + * |
|
228 | + * @param string|float|int $value_found_in_db_for_model_object |
|
229 | + * @return Money |
|
230 | + * @throws InvalidIdentifierException |
|
231 | + * @throws InvalidArgumentException |
|
232 | + * @throws InvalidInterfaceException |
|
233 | + * @throws InvalidDataTypeException |
|
234 | + * @throws EE_Error |
|
235 | + */ |
|
236 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
237 | + { |
|
238 | + return $this->money_factory->createForSite($value_found_in_db_for_model_object); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | |
242 | 242 | |
243 | - /** |
|
244 | - * Prepares a value for use in the DB |
|
245 | - * @param string|float|int|Money $value_of_field_on_model_object |
|
246 | - * @return float |
|
247 | - */ |
|
248 | - public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
249 | - { |
|
250 | - $value_of_field_on_model_object = $this->ensureNotMoney($value_of_field_on_model_object); |
|
251 | - return parent::prepare_for_use_in_db($value_of_field_on_model_object); |
|
252 | - } |
|
243 | + /** |
|
244 | + * Prepares a value for use in the DB |
|
245 | + * @param string|float|int|Money $value_of_field_on_model_object |
|
246 | + * @return float |
|
247 | + */ |
|
248 | + public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
249 | + { |
|
250 | + $value_of_field_on_model_object = $this->ensureNotMoney($value_of_field_on_model_object); |
|
251 | + return parent::prepare_for_use_in_db($value_of_field_on_model_object); |
|
252 | + } |
|
253 | 253 | |
254 | 254 | |
255 | 255 | |
256 | - public function getSchemaProperties() |
|
257 | - { |
|
258 | - return array( |
|
259 | - 'raw' => array( |
|
260 | - 'description' => sprintf( |
|
261 | - __('%s - the raw value as it exists in the database as a simple float.', 'event_espresso'), |
|
262 | - $this->get_nicename() |
|
263 | - ), |
|
264 | - 'type' => 'number' |
|
265 | - ), |
|
266 | - 'pretty' => array( |
|
267 | - 'description' => sprintf( |
|
268 | - __('%s - formatted for display in the set currency and decimal places.', 'event_espresso'), |
|
269 | - $this->get_nicename() |
|
270 | - ), |
|
271 | - 'type' => 'string' |
|
272 | - ) |
|
273 | - ); |
|
274 | - } |
|
256 | + public function getSchemaProperties() |
|
257 | + { |
|
258 | + return array( |
|
259 | + 'raw' => array( |
|
260 | + 'description' => sprintf( |
|
261 | + __('%s - the raw value as it exists in the database as a simple float.', 'event_espresso'), |
|
262 | + $this->get_nicename() |
|
263 | + ), |
|
264 | + 'type' => 'number' |
|
265 | + ), |
|
266 | + 'pretty' => array( |
|
267 | + 'description' => sprintf( |
|
268 | + __('%s - formatted for display in the set currency and decimal places.', 'event_espresso'), |
|
269 | + $this->get_nicename() |
|
270 | + ), |
|
271 | + 'type' => 'string' |
|
272 | + ) |
|
273 | + ); |
|
274 | + } |
|
275 | 275 | } |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | MoneyFactory $factory = null, |
50 | 50 | MoneyFormatter $money_formatter = null |
51 | 51 | ) { |
52 | - if (! $factory instanceof MoneyFactory) { |
|
52 | + if ( ! $factory instanceof MoneyFactory) { |
|
53 | 53 | $factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory'); |
54 | 54 | } |
55 | 55 | $this->money_factory = $factory; |
56 | - if (! $money_formatter instanceof MoneyFormatter) { |
|
56 | + if ( ! $money_formatter instanceof MoneyFormatter) { |
|
57 | 57 | $money_formatter = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\formatters\MoneyFormatter'); |
58 | 58 | } |
59 | 59 | $this->money_formatter = $money_formatter; |
@@ -116,20 +116,20 @@ discard block |
||
116 | 116 | return EEH_Money::format_currency($value_on_field_to_be_outputted, false, $display_code); |
117 | 117 | } |
118 | 118 | //ok let's just use the new formatting code then |
119 | - $schema = (string)$schema; |
|
119 | + $schema = (string) $schema; |
|
120 | 120 | switch ($schema) { |
121 | - case (string)CurrencyAmountFormatterInterface::ADD_CURRENCY_CODE: |
|
121 | + case (string) CurrencyAmountFormatterInterface::ADD_CURRENCY_CODE: |
|
122 | 122 | $formatting_level = CurrencyAmountFormatterInterface::ADD_CURRENCY_CODE; |
123 | 123 | break; |
124 | 124 | case 'no_currency_code': |
125 | - case (string)CurrencyAmountFormatterInterface::ADD_CURRENCY_SIGN: |
|
125 | + case (string) CurrencyAmountFormatterInterface::ADD_CURRENCY_SIGN: |
|
126 | 126 | $formatting_level = CurrencyAmountFormatterInterface::ADD_CURRENCY_SIGN; |
127 | 127 | break; |
128 | - case (string)CurrencyAmountFormatterInterface::ADD_THOUSANDS: |
|
128 | + case (string) CurrencyAmountFormatterInterface::ADD_THOUSANDS: |
|
129 | 129 | case 'localized_float': |
130 | 130 | $formatting_level = CurrencyAmountFormatterInterface::ADD_THOUSANDS; |
131 | 131 | break; |
132 | - case (string)CurrencyAmountFormatterInterface::DECIMAL_ONLY: |
|
132 | + case (string) CurrencyAmountFormatterInterface::DECIMAL_ONLY: |
|
133 | 133 | $formatting_level = CurrencyAmountFormatterInterface::DECIMAL_ONLY; |
134 | 134 | break; |
135 | 135 | default: |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function ensureMoney($value) |
158 | 158 | { |
159 | - if (! $value instanceof Money) { |
|
159 | + if ( ! $value instanceof Money) { |
|
160 | 160 | return $this->money_factory->createForSite($value); |
161 | 161 | } |
162 | 162 | return $value; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | private function ensureNotMoney($value) |
174 | 174 | { |
175 | - if( $value instanceof Money) { |
|
175 | + if ($value instanceof Money) { |
|
176 | 176 | return $value->amount(); |
177 | 177 | } |
178 | 178 | return $value; |
@@ -38,216 +38,216 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | |
64 | 64 | } else { |
65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | - /** |
|
68 | - * espresso_minimum_php_version_error |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | + /** |
|
68 | + * espresso_minimum_php_version_error |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.54.rc.052'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.54.rc.052'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | - /** |
|
119 | - * espresso_load_error_handling |
|
120 | - * this function loads EE's class for handling exceptions and errors |
|
121 | - */ |
|
122 | - function espresso_load_error_handling() |
|
123 | - { |
|
124 | - static $error_handling_loaded = false; |
|
125 | - if ($error_handling_loaded) { |
|
126 | - return; |
|
127 | - } |
|
128 | - // load debugging tools |
|
129 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
130 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
131 | - \EEH_Debug_Tools::instance(); |
|
132 | - } |
|
133 | - // load error handling |
|
134 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
135 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
136 | - } else { |
|
137 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
138 | - } |
|
139 | - $error_handling_loaded = true; |
|
140 | - } |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | + /** |
|
119 | + * espresso_load_error_handling |
|
120 | + * this function loads EE's class for handling exceptions and errors |
|
121 | + */ |
|
122 | + function espresso_load_error_handling() |
|
123 | + { |
|
124 | + static $error_handling_loaded = false; |
|
125 | + if ($error_handling_loaded) { |
|
126 | + return; |
|
127 | + } |
|
128 | + // load debugging tools |
|
129 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
130 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
131 | + \EEH_Debug_Tools::instance(); |
|
132 | + } |
|
133 | + // load error handling |
|
134 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
135 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
136 | + } else { |
|
137 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
138 | + } |
|
139 | + $error_handling_loaded = true; |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * espresso_load_required |
|
144 | - * given a class name and path, this function will load that file or throw an exception |
|
145 | - * |
|
146 | - * @param string $classname |
|
147 | - * @param string $full_path_to_file |
|
148 | - * @throws EE_Error |
|
149 | - */ |
|
150 | - function espresso_load_required($classname, $full_path_to_file) |
|
151 | - { |
|
152 | - if (is_readable($full_path_to_file)) { |
|
153 | - require_once $full_path_to_file; |
|
154 | - } else { |
|
155 | - throw new \EE_Error ( |
|
156 | - sprintf( |
|
157 | - esc_html__( |
|
158 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
159 | - 'event_espresso' |
|
160 | - ), |
|
161 | - $classname |
|
162 | - ) |
|
163 | - ); |
|
164 | - } |
|
165 | - } |
|
142 | + /** |
|
143 | + * espresso_load_required |
|
144 | + * given a class name and path, this function will load that file or throw an exception |
|
145 | + * |
|
146 | + * @param string $classname |
|
147 | + * @param string $full_path_to_file |
|
148 | + * @throws EE_Error |
|
149 | + */ |
|
150 | + function espresso_load_required($classname, $full_path_to_file) |
|
151 | + { |
|
152 | + if (is_readable($full_path_to_file)) { |
|
153 | + require_once $full_path_to_file; |
|
154 | + } else { |
|
155 | + throw new \EE_Error ( |
|
156 | + sprintf( |
|
157 | + esc_html__( |
|
158 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
159 | + 'event_espresso' |
|
160 | + ), |
|
161 | + $classname |
|
162 | + ) |
|
163 | + ); |
|
164 | + } |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @since 4.9.27 |
|
169 | - * @throws \EE_Error |
|
170 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
171 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
172 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
173 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
174 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
175 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
176 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
177 | - * @throws \OutOfBoundsException |
|
178 | - */ |
|
179 | - function bootstrap_espresso() |
|
180 | - { |
|
181 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
182 | - try { |
|
183 | - espresso_load_error_handling(); |
|
184 | - espresso_load_required( |
|
185 | - 'EEH_Base', |
|
186 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
187 | - ); |
|
188 | - espresso_load_required( |
|
189 | - 'EEH_File', |
|
190 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
191 | - ); |
|
192 | - espresso_load_required( |
|
193 | - 'EEH_File', |
|
194 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
195 | - ); |
|
196 | - espresso_load_required( |
|
197 | - 'EEH_Array', |
|
198 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
199 | - ); |
|
200 | - // instantiate and configure PSR4 autoloader |
|
201 | - espresso_load_required( |
|
202 | - 'Psr4Autoloader', |
|
203 | - EE_CORE . 'Psr4Autoloader.php' |
|
204 | - ); |
|
205 | - espresso_load_required( |
|
206 | - 'EE_Psr4AutoloaderInit', |
|
207 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
208 | - ); |
|
209 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
210 | - $AutoloaderInit->initializeAutoloader(); |
|
211 | - espresso_load_required( |
|
212 | - 'EE_Request', |
|
213 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
214 | - ); |
|
215 | - espresso_load_required( |
|
216 | - 'EE_Response', |
|
217 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
218 | - ); |
|
219 | - espresso_load_required( |
|
220 | - 'EE_Bootstrap', |
|
221 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
222 | - ); |
|
223 | - // bootstrap EE and the request stack |
|
224 | - new EE_Bootstrap( |
|
225 | - new EE_Request($_GET, $_POST, $_COOKIE), |
|
226 | - new EE_Response() |
|
227 | - ); |
|
228 | - } catch (Exception $e) { |
|
229 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
230 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
231 | - } |
|
232 | - } |
|
233 | - bootstrap_espresso(); |
|
234 | - } |
|
167 | + /** |
|
168 | + * @since 4.9.27 |
|
169 | + * @throws \EE_Error |
|
170 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
171 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
172 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
173 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
174 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
175 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
176 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
177 | + * @throws \OutOfBoundsException |
|
178 | + */ |
|
179 | + function bootstrap_espresso() |
|
180 | + { |
|
181 | + require_once __DIR__ . '/core/espresso_definitions.php'; |
|
182 | + try { |
|
183 | + espresso_load_error_handling(); |
|
184 | + espresso_load_required( |
|
185 | + 'EEH_Base', |
|
186 | + EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
187 | + ); |
|
188 | + espresso_load_required( |
|
189 | + 'EEH_File', |
|
190 | + EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
191 | + ); |
|
192 | + espresso_load_required( |
|
193 | + 'EEH_File', |
|
194 | + EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
195 | + ); |
|
196 | + espresso_load_required( |
|
197 | + 'EEH_Array', |
|
198 | + EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
199 | + ); |
|
200 | + // instantiate and configure PSR4 autoloader |
|
201 | + espresso_load_required( |
|
202 | + 'Psr4Autoloader', |
|
203 | + EE_CORE . 'Psr4Autoloader.php' |
|
204 | + ); |
|
205 | + espresso_load_required( |
|
206 | + 'EE_Psr4AutoloaderInit', |
|
207 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
208 | + ); |
|
209 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
210 | + $AutoloaderInit->initializeAutoloader(); |
|
211 | + espresso_load_required( |
|
212 | + 'EE_Request', |
|
213 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
214 | + ); |
|
215 | + espresso_load_required( |
|
216 | + 'EE_Response', |
|
217 | + EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
218 | + ); |
|
219 | + espresso_load_required( |
|
220 | + 'EE_Bootstrap', |
|
221 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
222 | + ); |
|
223 | + // bootstrap EE and the request stack |
|
224 | + new EE_Bootstrap( |
|
225 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
226 | + new EE_Response() |
|
227 | + ); |
|
228 | + } catch (Exception $e) { |
|
229 | + require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
230 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
231 | + } |
|
232 | + } |
|
233 | + bootstrap_espresso(); |
|
234 | + } |
|
235 | 235 | } |
236 | 236 | if (! function_exists('espresso_deactivate_plugin')) { |
237 | - /** |
|
238 | - * deactivate_plugin |
|
239 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
240 | - * |
|
241 | - * @access public |
|
242 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
243 | - * @return void |
|
244 | - */ |
|
245 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
246 | - { |
|
247 | - if (! function_exists('deactivate_plugins')) { |
|
248 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
249 | - } |
|
250 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
251 | - deactivate_plugins($plugin_basename); |
|
252 | - } |
|
237 | + /** |
|
238 | + * deactivate_plugin |
|
239 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
240 | + * |
|
241 | + * @access public |
|
242 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
243 | + * @return void |
|
244 | + */ |
|
245 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
246 | + { |
|
247 | + if (! function_exists('deactivate_plugins')) { |
|
248 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
249 | + } |
|
250 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
251 | + deactivate_plugins($plugin_basename); |
|
252 | + } |
|
253 | 253 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use EventEspresso\core\services\loaders\LoaderInterface; |
6 | 6 | |
7 | 7 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
8 | - exit('No direct script access allowed'); |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -22,820 +22,820 @@ discard block |
||
22 | 22 | class EE_Dependency_Map |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * This means that the requested class dependency is not present in the dependency map |
|
27 | - */ |
|
28 | - const not_registered = 0; |
|
29 | - |
|
30 | - /** |
|
31 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
32 | - */ |
|
33 | - const load_new_object = 1; |
|
34 | - |
|
35 | - /** |
|
36 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
37 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
38 | - */ |
|
39 | - const load_from_cache = 2; |
|
40 | - |
|
41 | - /** |
|
42 | - * When registering a dependency, |
|
43 | - * this indicates to keep any existing dependencies that already exist, |
|
44 | - * and simply discard any new dependencies declared in the incoming data |
|
45 | - */ |
|
46 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
47 | - |
|
48 | - /** |
|
49 | - * When registering a dependency, |
|
50 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
51 | - */ |
|
52 | - const OVERWRITE_DEPENDENCIES = 1; |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @type EE_Dependency_Map $_instance |
|
58 | - */ |
|
59 | - protected static $_instance; |
|
60 | - |
|
61 | - /** |
|
62 | - * @type EE_Request $request |
|
63 | - */ |
|
64 | - protected $_request; |
|
65 | - |
|
66 | - /** |
|
67 | - * @type EE_Response $response |
|
68 | - */ |
|
69 | - protected $_response; |
|
70 | - |
|
71 | - /** |
|
72 | - * @type LoaderInterface $loader |
|
73 | - */ |
|
74 | - protected $loader; |
|
75 | - |
|
76 | - /** |
|
77 | - * @type array $_dependency_map |
|
78 | - */ |
|
79 | - protected $_dependency_map = array(); |
|
80 | - |
|
81 | - /** |
|
82 | - * @type array $_class_loaders |
|
83 | - */ |
|
84 | - protected $_class_loaders = array(); |
|
85 | - |
|
86 | - /** |
|
87 | - * @type array $_aliases |
|
88 | - */ |
|
89 | - protected $_aliases = array(); |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * EE_Dependency_Map constructor. |
|
95 | - * |
|
96 | - * @param EE_Request $request |
|
97 | - * @param EE_Response $response |
|
98 | - */ |
|
99 | - protected function __construct(EE_Request $request, EE_Response $response) |
|
100 | - { |
|
101 | - $this->_request = $request; |
|
102 | - $this->_response = $response; |
|
103 | - add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
104 | - do_action('EE_Dependency_Map____construct'); |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @throws InvalidDataTypeException |
|
111 | - * @throws InvalidInterfaceException |
|
112 | - * @throws InvalidArgumentException |
|
113 | - */ |
|
114 | - public function initialize() |
|
115 | - { |
|
116 | - $this->_register_core_dependencies(); |
|
117 | - $this->_register_core_class_loaders(); |
|
118 | - $this->_register_core_aliases(); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * @singleton method used to instantiate class object |
|
125 | - * @access public |
|
126 | - * @param EE_Request $request |
|
127 | - * @param EE_Response $response |
|
128 | - * @return EE_Dependency_Map |
|
129 | - */ |
|
130 | - public static function instance(EE_Request $request = null, EE_Response $response = null) |
|
131 | - { |
|
132 | - // check if class object is instantiated, and instantiated properly |
|
133 | - if (! self::$_instance instanceof EE_Dependency_Map) { |
|
134 | - self::$_instance = new EE_Dependency_Map($request, $response); |
|
135 | - } |
|
136 | - return self::$_instance; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @param LoaderInterface $loader |
|
143 | - */ |
|
144 | - public function setLoader(LoaderInterface $loader) |
|
145 | - { |
|
146 | - $this->loader = $loader; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * @param string $class |
|
153 | - * @param array $dependencies |
|
154 | - * @param int $overwrite |
|
155 | - * @return bool |
|
156 | - */ |
|
157 | - public static function register_dependencies( |
|
158 | - $class, |
|
159 | - array $dependencies, |
|
160 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
161 | - ) { |
|
162 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
169 | - * to the class specified by the first parameter. |
|
170 | - * IMPORTANT !!! |
|
171 | - * The order of elements in the incoming $dependencies array MUST match |
|
172 | - * the order of the constructor parameters for the class in question. |
|
173 | - * This is especially important when overriding any existing dependencies that are registered. |
|
174 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
175 | - * |
|
176 | - * @param string $class |
|
177 | - * @param array $dependencies |
|
178 | - * @param int $overwrite |
|
179 | - * @return bool |
|
180 | - */ |
|
181 | - public function registerDependencies( |
|
182 | - $class, |
|
183 | - array $dependencies, |
|
184 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
185 | - ) { |
|
186 | - $class = trim($class, '\\'); |
|
187 | - $registered = false; |
|
188 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
189 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
190 | - } |
|
191 | - // we need to make sure that any aliases used when registering a dependency |
|
192 | - // get resolved to the correct class name |
|
193 | - foreach ((array)$dependencies as $dependency => $load_source) { |
|
194 | - $alias = self::$_instance->get_alias($dependency); |
|
195 | - if ( |
|
196 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
197 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
198 | - ) { |
|
199 | - unset($dependencies[$dependency]); |
|
200 | - $dependencies[$alias] = $load_source; |
|
201 | - $registered = true; |
|
202 | - } |
|
203 | - } |
|
204 | - // now add our two lists of dependencies together. |
|
205 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
206 | - // so $dependencies is NOT overwritten because it is listed first |
|
207 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
208 | - // Union is way faster than array_merge() but should be used with caution... |
|
209 | - // especially with numerically indexed arrays |
|
210 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
211 | - // now we need to ensure that the resulting dependencies |
|
212 | - // array only has the entries that are required for the class |
|
213 | - // so first count how many dependencies were originally registered for the class |
|
214 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
215 | - // if that count is non-zero (meaning dependencies were already registered) |
|
216 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
217 | - // then truncate the final array to match that count |
|
218 | - ? array_slice($dependencies, 0, $dependency_count) |
|
219 | - // otherwise just take the incoming array because nothing previously existed |
|
220 | - : $dependencies; |
|
221 | - return $registered; |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * @param string $class_name |
|
228 | - * @param string $loader |
|
229 | - * @return bool |
|
230 | - * @throws DomainException |
|
231 | - */ |
|
232 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
233 | - { |
|
234 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
235 | - throw new DomainException( |
|
236 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
237 | - ); |
|
238 | - } |
|
239 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
240 | - if ( |
|
241 | - ! is_callable($loader) |
|
242 | - && ( |
|
243 | - strpos($loader, 'load_') !== 0 |
|
244 | - || ! method_exists('EE_Registry', $loader) |
|
245 | - ) |
|
246 | - ) { |
|
247 | - throw new DomainException( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $loader |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - $class_name = self::$_instance->get_alias($class_name); |
|
258 | - if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
259 | - self::$_instance->_class_loaders[$class_name] = $loader; |
|
260 | - return true; |
|
261 | - } |
|
262 | - return false; |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * @return array |
|
269 | - */ |
|
270 | - public function dependency_map() |
|
271 | - { |
|
272 | - return $this->_dependency_map; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
279 | - * |
|
280 | - * @param string $class_name |
|
281 | - * @return boolean |
|
282 | - */ |
|
283 | - public function has($class_name = '') |
|
284 | - { |
|
285 | - // all legacy models have the same dependencies |
|
286 | - if (strpos($class_name, 'EEM_') === 0) { |
|
287 | - $class_name = 'LEGACY_MODELS'; |
|
288 | - } |
|
289 | - return isset($this->_dependency_map[$class_name]) ? true : false; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
296 | - * |
|
297 | - * @param string $class_name |
|
298 | - * @param string $dependency |
|
299 | - * @return bool |
|
300 | - */ |
|
301 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
302 | - { |
|
303 | - // all legacy models have the same dependencies |
|
304 | - if (strpos($class_name, 'EEM_') === 0) { |
|
305 | - $class_name = 'LEGACY_MODELS'; |
|
306 | - } |
|
307 | - $dependency = $this->get_alias($dependency); |
|
308 | - return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
309 | - ? true |
|
310 | - : false; |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
317 | - * |
|
318 | - * @param string $class_name |
|
319 | - * @param string $dependency |
|
320 | - * @return int |
|
321 | - */ |
|
322 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
323 | - { |
|
324 | - // all legacy models have the same dependencies |
|
325 | - if (strpos($class_name, 'EEM_') === 0) { |
|
326 | - $class_name = 'LEGACY_MODELS'; |
|
327 | - } |
|
328 | - $dependency = $this->get_alias($dependency); |
|
329 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
330 | - ? $this->_dependency_map[$class_name][$dependency] |
|
331 | - : EE_Dependency_Map::not_registered; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * @param string $class_name |
|
338 | - * @return string | Closure |
|
339 | - */ |
|
340 | - public function class_loader($class_name) |
|
341 | - { |
|
342 | - // all legacy models use load_model() |
|
343 | - if(strpos($class_name, 'EEM_') === 0){ |
|
344 | - return 'load_model'; |
|
345 | - } |
|
346 | - $class_name = $this->get_alias($class_name); |
|
347 | - return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * @return array |
|
354 | - */ |
|
355 | - public function class_loaders() |
|
356 | - { |
|
357 | - return $this->_class_loaders; |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * adds an alias for a classname |
|
364 | - * |
|
365 | - * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
366 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
367 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
368 | - */ |
|
369 | - public function add_alias($class_name, $alias, $for_class = '') |
|
370 | - { |
|
371 | - if ($for_class !== '') { |
|
372 | - if (! isset($this->_aliases[$for_class])) { |
|
373 | - $this->_aliases[$for_class] = array(); |
|
374 | - } |
|
375 | - $this->_aliases[$for_class][$class_name] = $alias; |
|
376 | - } |
|
377 | - $this->_aliases[$class_name] = $alias; |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - |
|
382 | - /** |
|
383 | - * returns TRUE if the provided class name has an alias |
|
384 | - * |
|
385 | - * @param string $class_name |
|
386 | - * @param string $for_class |
|
387 | - * @return bool |
|
388 | - */ |
|
389 | - public function has_alias($class_name = '', $for_class = '') |
|
390 | - { |
|
391 | - return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name]) |
|
392 | - || ( |
|
393 | - isset($this->_aliases[$class_name]) |
|
394 | - && ! is_array($this->_aliases[$class_name]) |
|
395 | - ); |
|
396 | - } |
|
397 | - |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * returns alias for class name if one exists, otherwise returns the original classname |
|
402 | - * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
403 | - * for example: |
|
404 | - * if the following two entries were added to the _aliases array: |
|
405 | - * array( |
|
406 | - * 'interface_alias' => 'some\namespace\interface' |
|
407 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
408 | - * ) |
|
409 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
410 | - * to load an instance of 'some\namespace\classname' |
|
411 | - * |
|
412 | - * @param string $class_name |
|
413 | - * @param string $for_class |
|
414 | - * @return string |
|
415 | - */ |
|
416 | - public function get_alias($class_name = '', $for_class = '') |
|
417 | - { |
|
418 | - if (! $this->has_alias($class_name, $for_class)) { |
|
419 | - return $class_name; |
|
420 | - } |
|
421 | - if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
422 | - return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
423 | - } |
|
424 | - return $this->get_alias($this->_aliases[$class_name]); |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
431 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
432 | - * This is done by using the following class constants: |
|
433 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
434 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
435 | - */ |
|
436 | - protected function _register_core_dependencies() |
|
437 | - { |
|
438 | - $this->_dependency_map = array( |
|
439 | - 'EE_Request_Handler' => array( |
|
440 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
441 | - ), |
|
442 | - 'EE_System' => array( |
|
443 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
444 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
445 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
446 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
447 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
448 | - ), |
|
449 | - 'EE_Session' => array( |
|
450 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
451 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
452 | - ), |
|
453 | - 'EE_Cart' => array( |
|
454 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
455 | - ), |
|
456 | - 'EE_Front_Controller' => array( |
|
457 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
458 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
459 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
460 | - ), |
|
461 | - 'EE_Messenger_Collection_Loader' => array( |
|
462 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
463 | - ), |
|
464 | - 'EE_Message_Type_Collection_Loader' => array( |
|
465 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
466 | - ), |
|
467 | - 'EE_Message_Resource_Manager' => array( |
|
468 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
469 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
470 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
471 | - ), |
|
472 | - 'EE_Message_Factory' => array( |
|
473 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
474 | - ), |
|
475 | - 'EE_messages' => array( |
|
476 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
477 | - ), |
|
478 | - 'EE_Messages_Generator' => array( |
|
479 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
480 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
481 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
482 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
483 | - ), |
|
484 | - 'EE_Messages_Processor' => array( |
|
485 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
486 | - ), |
|
487 | - 'EE_Messages_Queue' => array( |
|
488 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
489 | - ), |
|
490 | - 'EE_Messages_Template_Defaults' => array( |
|
491 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
492 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
493 | - ), |
|
494 | - 'EE_Message_To_Generate_From_Request' => array( |
|
495 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
496 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
497 | - ), |
|
498 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
499 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
500 | - ), |
|
501 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
502 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
503 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
504 | - ), |
|
505 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
506 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
507 | - ), |
|
508 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
509 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
510 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
511 | - ), |
|
512 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
513 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
514 | - ), |
|
515 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
516 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
517 | - ), |
|
518 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
519 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
520 | - ), |
|
521 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
522 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
523 | - ), |
|
524 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
525 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
526 | - ), |
|
527 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
528 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
529 | - ), |
|
530 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
531 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
532 | - ), |
|
533 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
534 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
535 | - ), |
|
536 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
537 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
538 | - ), |
|
539 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
540 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
541 | - ), |
|
542 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
543 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
544 | - ), |
|
545 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
546 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
547 | - ), |
|
548 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
549 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
550 | - ), |
|
551 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
552 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
553 | - ), |
|
554 | - 'EE_Data_Migration_Class_Base' => array( |
|
555 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
556 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
557 | - ), |
|
558 | - 'EE_DMS_Core_4_1_0' => array( |
|
559 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
560 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
561 | - ), |
|
562 | - 'EE_DMS_Core_4_2_0' => array( |
|
563 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
564 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
565 | - ), |
|
566 | - 'EE_DMS_Core_4_3_0' => array( |
|
567 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
568 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
569 | - ), |
|
570 | - 'EE_DMS_Core_4_4_0' => array( |
|
571 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
572 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
573 | - ), |
|
574 | - 'EE_DMS_Core_4_5_0' => array( |
|
575 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
576 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
577 | - ), |
|
578 | - 'EE_DMS_Core_4_6_0' => array( |
|
579 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
580 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
581 | - ), |
|
582 | - 'EE_DMS_Core_4_7_0' => array( |
|
583 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
584 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
585 | - ), |
|
586 | - 'EE_DMS_Core_4_8_0' => array( |
|
587 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
588 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
589 | - ), |
|
590 | - 'EE_DMS_Core_4_9_0' => array( |
|
591 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
592 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
593 | - ), |
|
594 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
595 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
596 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
597 | - ), |
|
598 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
599 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
600 | - ), |
|
601 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
602 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
603 | - ), |
|
604 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
605 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
606 | - ), |
|
607 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
608 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
609 | - ), |
|
610 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
611 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
612 | - ), |
|
613 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
614 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
615 | - ), |
|
616 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
617 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
618 | - ), |
|
619 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
620 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
621 | - ), |
|
622 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
623 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
624 | - ), |
|
625 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
626 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
627 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
628 | - ), |
|
629 | - 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
630 | - null, |
|
631 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
632 | - ), |
|
633 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
634 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
635 | - ), |
|
636 | - 'LEGACY_MODELS' => array( |
|
637 | - null, |
|
638 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
639 | - ), |
|
640 | - 'EE_Module_Request_Router' => array( |
|
641 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
642 | - ), |
|
643 | - 'EE_Registration_Processor' => array( |
|
644 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
645 | - ), |
|
646 | - 'EventEspresso\core\services\currency\CurrencyFactory' => array( |
|
647 | - 'EventEspresso\core\services\currency\CountryCurrencyDao' => EE_Dependency_Map::load_from_cache, |
|
648 | - 'EE_Organization_Config' => EE_Dependency_Map::load_from_cache, |
|
649 | - ), |
|
650 | - 'EventEspresso\core\services\currency\MoneyFactory' => array( |
|
651 | - 'EventEspresso\core\services\currency\CurrencyFactory' => EE_Dependency_Map::load_from_cache, |
|
652 | - 'EventEspresso\core\services\currency\Calculator' => EE_Dependency_Map::load_from_cache, |
|
653 | - ), |
|
654 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
655 | - null, |
|
656 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
657 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
658 | - ), |
|
659 | - 'EventEspresso\core\services\currency\MoneyFactory' => array( |
|
660 | - 'EventEspresso\core\services\currency\CurrencyFactory' => EE_Dependency_Map::load_from_cache |
|
661 | - ) |
|
662 | - ); |
|
663 | - } |
|
664 | - |
|
665 | - |
|
666 | - |
|
667 | - /** |
|
668 | - * Registers how core classes are loaded. |
|
669 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
670 | - * 'EE_Request_Handler' => 'load_core' |
|
671 | - * 'EE_Messages_Queue' => 'load_lib' |
|
672 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
673 | - * or, if greater control is required, by providing a custom closure. For example: |
|
674 | - * 'Some_Class' => function () { |
|
675 | - * return new Some_Class(); |
|
676 | - * }, |
|
677 | - * This is required for instantiating dependencies |
|
678 | - * where an interface has been type hinted in a class constructor. For example: |
|
679 | - * 'Required_Interface' => function () { |
|
680 | - * return new A_Class_That_Implements_Required_Interface(); |
|
681 | - * }, |
|
682 | - * |
|
683 | - * @throws InvalidInterfaceException |
|
684 | - * @throws InvalidDataTypeException |
|
685 | - * @throws InvalidArgumentException |
|
686 | - */ |
|
687 | - protected function _register_core_class_loaders() |
|
688 | - { |
|
689 | - //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
690 | - //be used in a closure. |
|
691 | - $request = &$this->_request; |
|
692 | - $response = &$this->_response; |
|
693 | - // $loader = &$this->loader; |
|
694 | - $this->_class_loaders = array( |
|
695 | - //load_core |
|
696 | - 'EE_Capabilities' => 'load_core', |
|
697 | - 'EE_Encryption' => 'load_core', |
|
698 | - 'EE_Front_Controller' => 'load_core', |
|
699 | - 'EE_Module_Request_Router' => 'load_core', |
|
700 | - 'EE_Registry' => 'load_core', |
|
701 | - 'EE_Request' => function () use (&$request) { |
|
702 | - return $request; |
|
703 | - }, |
|
704 | - 'EE_Response' => function () use (&$response) { |
|
705 | - return $response; |
|
706 | - }, |
|
707 | - 'EE_Request_Handler' => 'load_core', |
|
708 | - 'EE_Session' => 'load_core', |
|
709 | - 'EE_Cron_Tasks' => 'load_core', |
|
710 | - 'EE_System' => 'load_core', |
|
711 | - 'EE_Maintenance_Mode' => 'load_core', |
|
712 | - 'EE_Register_CPTs' => 'load_core', |
|
713 | - 'EE_Admin' => 'load_core', |
|
714 | - //load_lib |
|
715 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
716 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
717 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
718 | - 'EE_Messenger_Collection' => 'load_lib', |
|
719 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
720 | - 'EE_Messages_Processor' => 'load_lib', |
|
721 | - 'EE_Message_Repository' => 'load_lib', |
|
722 | - 'EE_Messages_Queue' => 'load_lib', |
|
723 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
724 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
725 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
726 | - 'EE_Messages_Generator' => function () { |
|
727 | - return EE_Registry::instance()->load_lib( |
|
728 | - 'Messages_Generator', |
|
729 | - array(), |
|
730 | - false, |
|
731 | - false |
|
732 | - ); |
|
733 | - }, |
|
734 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
735 | - return EE_Registry::instance()->load_lib( |
|
736 | - 'Messages_Template_Defaults', |
|
737 | - $arguments, |
|
738 | - false, |
|
739 | - false |
|
740 | - ); |
|
741 | - }, |
|
742 | - //load_model |
|
743 | - // 'EEM_Attendee' => 'load_model', |
|
744 | - // 'EEM_Message_Template_Group' => 'load_model', |
|
745 | - // 'EEM_Message_Template' => 'load_model', |
|
746 | - //load_helper |
|
747 | - 'EEH_Parse_Shortcodes' => function () { |
|
748 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
749 | - return new EEH_Parse_Shortcodes(); |
|
750 | - } |
|
751 | - return null; |
|
752 | - }, |
|
753 | - 'EE_Template_Config' => function () { |
|
754 | - return EE_Config::instance()->template_settings; |
|
755 | - }, |
|
756 | - 'EE_Currency_Config' => function () { |
|
757 | - return EE_Config::instance()->currency; |
|
758 | - }, |
|
759 | - 'EE_Registration_Config' => function () { |
|
760 | - return EE_Config::instance()->registration; |
|
761 | - }, |
|
762 | - 'EE_Organization_Config' => function () { |
|
763 | - return EE_Config::instance()->organization; |
|
764 | - }, |
|
765 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
766 | - return LoaderFactory::getLoader(); |
|
767 | - }, |
|
768 | - ); |
|
769 | - } |
|
770 | - |
|
771 | - |
|
772 | - |
|
773 | - /** |
|
774 | - * can be used for supplying alternate names for classes, |
|
775 | - * or for connecting interface names to instantiable classes |
|
776 | - */ |
|
777 | - protected function _register_core_aliases() |
|
778 | - { |
|
779 | - $this->_aliases = array( |
|
780 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
781 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
782 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
783 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
784 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
785 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
786 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
787 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
788 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
789 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
790 | - 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
791 | - 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
792 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
793 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
794 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
795 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
796 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
797 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
798 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
799 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
800 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
801 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
802 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
803 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
804 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
805 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
806 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
807 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
808 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
809 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
810 | - 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
811 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
812 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
813 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
814 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
815 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
816 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
817 | - 'EventEspresso\core\services\currency\Calculator' => 'EventEspresso\core\services\currency\DefaultCalculator', |
|
818 | - ); |
|
819 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
820 | - $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
821 | - } |
|
822 | - } |
|
823 | - |
|
824 | - |
|
825 | - |
|
826 | - /** |
|
827 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
828 | - * request Primarily used by unit tests. |
|
829 | - * |
|
830 | - * @throws InvalidDataTypeException |
|
831 | - * @throws InvalidInterfaceException |
|
832 | - * @throws InvalidArgumentException |
|
833 | - */ |
|
834 | - public function reset() |
|
835 | - { |
|
836 | - $this->_register_core_class_loaders(); |
|
837 | - $this->_register_core_dependencies(); |
|
838 | - } |
|
25 | + /** |
|
26 | + * This means that the requested class dependency is not present in the dependency map |
|
27 | + */ |
|
28 | + const not_registered = 0; |
|
29 | + |
|
30 | + /** |
|
31 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
32 | + */ |
|
33 | + const load_new_object = 1; |
|
34 | + |
|
35 | + /** |
|
36 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
37 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
38 | + */ |
|
39 | + const load_from_cache = 2; |
|
40 | + |
|
41 | + /** |
|
42 | + * When registering a dependency, |
|
43 | + * this indicates to keep any existing dependencies that already exist, |
|
44 | + * and simply discard any new dependencies declared in the incoming data |
|
45 | + */ |
|
46 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
47 | + |
|
48 | + /** |
|
49 | + * When registering a dependency, |
|
50 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
51 | + */ |
|
52 | + const OVERWRITE_DEPENDENCIES = 1; |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @type EE_Dependency_Map $_instance |
|
58 | + */ |
|
59 | + protected static $_instance; |
|
60 | + |
|
61 | + /** |
|
62 | + * @type EE_Request $request |
|
63 | + */ |
|
64 | + protected $_request; |
|
65 | + |
|
66 | + /** |
|
67 | + * @type EE_Response $response |
|
68 | + */ |
|
69 | + protected $_response; |
|
70 | + |
|
71 | + /** |
|
72 | + * @type LoaderInterface $loader |
|
73 | + */ |
|
74 | + protected $loader; |
|
75 | + |
|
76 | + /** |
|
77 | + * @type array $_dependency_map |
|
78 | + */ |
|
79 | + protected $_dependency_map = array(); |
|
80 | + |
|
81 | + /** |
|
82 | + * @type array $_class_loaders |
|
83 | + */ |
|
84 | + protected $_class_loaders = array(); |
|
85 | + |
|
86 | + /** |
|
87 | + * @type array $_aliases |
|
88 | + */ |
|
89 | + protected $_aliases = array(); |
|
90 | + |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * EE_Dependency_Map constructor. |
|
95 | + * |
|
96 | + * @param EE_Request $request |
|
97 | + * @param EE_Response $response |
|
98 | + */ |
|
99 | + protected function __construct(EE_Request $request, EE_Response $response) |
|
100 | + { |
|
101 | + $this->_request = $request; |
|
102 | + $this->_response = $response; |
|
103 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
104 | + do_action('EE_Dependency_Map____construct'); |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @throws InvalidDataTypeException |
|
111 | + * @throws InvalidInterfaceException |
|
112 | + * @throws InvalidArgumentException |
|
113 | + */ |
|
114 | + public function initialize() |
|
115 | + { |
|
116 | + $this->_register_core_dependencies(); |
|
117 | + $this->_register_core_class_loaders(); |
|
118 | + $this->_register_core_aliases(); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * @singleton method used to instantiate class object |
|
125 | + * @access public |
|
126 | + * @param EE_Request $request |
|
127 | + * @param EE_Response $response |
|
128 | + * @return EE_Dependency_Map |
|
129 | + */ |
|
130 | + public static function instance(EE_Request $request = null, EE_Response $response = null) |
|
131 | + { |
|
132 | + // check if class object is instantiated, and instantiated properly |
|
133 | + if (! self::$_instance instanceof EE_Dependency_Map) { |
|
134 | + self::$_instance = new EE_Dependency_Map($request, $response); |
|
135 | + } |
|
136 | + return self::$_instance; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @param LoaderInterface $loader |
|
143 | + */ |
|
144 | + public function setLoader(LoaderInterface $loader) |
|
145 | + { |
|
146 | + $this->loader = $loader; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * @param string $class |
|
153 | + * @param array $dependencies |
|
154 | + * @param int $overwrite |
|
155 | + * @return bool |
|
156 | + */ |
|
157 | + public static function register_dependencies( |
|
158 | + $class, |
|
159 | + array $dependencies, |
|
160 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
161 | + ) { |
|
162 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
169 | + * to the class specified by the first parameter. |
|
170 | + * IMPORTANT !!! |
|
171 | + * The order of elements in the incoming $dependencies array MUST match |
|
172 | + * the order of the constructor parameters for the class in question. |
|
173 | + * This is especially important when overriding any existing dependencies that are registered. |
|
174 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
175 | + * |
|
176 | + * @param string $class |
|
177 | + * @param array $dependencies |
|
178 | + * @param int $overwrite |
|
179 | + * @return bool |
|
180 | + */ |
|
181 | + public function registerDependencies( |
|
182 | + $class, |
|
183 | + array $dependencies, |
|
184 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
185 | + ) { |
|
186 | + $class = trim($class, '\\'); |
|
187 | + $registered = false; |
|
188 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
189 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
190 | + } |
|
191 | + // we need to make sure that any aliases used when registering a dependency |
|
192 | + // get resolved to the correct class name |
|
193 | + foreach ((array)$dependencies as $dependency => $load_source) { |
|
194 | + $alias = self::$_instance->get_alias($dependency); |
|
195 | + if ( |
|
196 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
197 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
198 | + ) { |
|
199 | + unset($dependencies[$dependency]); |
|
200 | + $dependencies[$alias] = $load_source; |
|
201 | + $registered = true; |
|
202 | + } |
|
203 | + } |
|
204 | + // now add our two lists of dependencies together. |
|
205 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
206 | + // so $dependencies is NOT overwritten because it is listed first |
|
207 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
208 | + // Union is way faster than array_merge() but should be used with caution... |
|
209 | + // especially with numerically indexed arrays |
|
210 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
211 | + // now we need to ensure that the resulting dependencies |
|
212 | + // array only has the entries that are required for the class |
|
213 | + // so first count how many dependencies were originally registered for the class |
|
214 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
215 | + // if that count is non-zero (meaning dependencies were already registered) |
|
216 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
217 | + // then truncate the final array to match that count |
|
218 | + ? array_slice($dependencies, 0, $dependency_count) |
|
219 | + // otherwise just take the incoming array because nothing previously existed |
|
220 | + : $dependencies; |
|
221 | + return $registered; |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * @param string $class_name |
|
228 | + * @param string $loader |
|
229 | + * @return bool |
|
230 | + * @throws DomainException |
|
231 | + */ |
|
232 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
233 | + { |
|
234 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
235 | + throw new DomainException( |
|
236 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
237 | + ); |
|
238 | + } |
|
239 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
240 | + if ( |
|
241 | + ! is_callable($loader) |
|
242 | + && ( |
|
243 | + strpos($loader, 'load_') !== 0 |
|
244 | + || ! method_exists('EE_Registry', $loader) |
|
245 | + ) |
|
246 | + ) { |
|
247 | + throw new DomainException( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $loader |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + $class_name = self::$_instance->get_alias($class_name); |
|
258 | + if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
259 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
260 | + return true; |
|
261 | + } |
|
262 | + return false; |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * @return array |
|
269 | + */ |
|
270 | + public function dependency_map() |
|
271 | + { |
|
272 | + return $this->_dependency_map; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
279 | + * |
|
280 | + * @param string $class_name |
|
281 | + * @return boolean |
|
282 | + */ |
|
283 | + public function has($class_name = '') |
|
284 | + { |
|
285 | + // all legacy models have the same dependencies |
|
286 | + if (strpos($class_name, 'EEM_') === 0) { |
|
287 | + $class_name = 'LEGACY_MODELS'; |
|
288 | + } |
|
289 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
296 | + * |
|
297 | + * @param string $class_name |
|
298 | + * @param string $dependency |
|
299 | + * @return bool |
|
300 | + */ |
|
301 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
302 | + { |
|
303 | + // all legacy models have the same dependencies |
|
304 | + if (strpos($class_name, 'EEM_') === 0) { |
|
305 | + $class_name = 'LEGACY_MODELS'; |
|
306 | + } |
|
307 | + $dependency = $this->get_alias($dependency); |
|
308 | + return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
309 | + ? true |
|
310 | + : false; |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
317 | + * |
|
318 | + * @param string $class_name |
|
319 | + * @param string $dependency |
|
320 | + * @return int |
|
321 | + */ |
|
322 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
323 | + { |
|
324 | + // all legacy models have the same dependencies |
|
325 | + if (strpos($class_name, 'EEM_') === 0) { |
|
326 | + $class_name = 'LEGACY_MODELS'; |
|
327 | + } |
|
328 | + $dependency = $this->get_alias($dependency); |
|
329 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
330 | + ? $this->_dependency_map[$class_name][$dependency] |
|
331 | + : EE_Dependency_Map::not_registered; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * @param string $class_name |
|
338 | + * @return string | Closure |
|
339 | + */ |
|
340 | + public function class_loader($class_name) |
|
341 | + { |
|
342 | + // all legacy models use load_model() |
|
343 | + if(strpos($class_name, 'EEM_') === 0){ |
|
344 | + return 'load_model'; |
|
345 | + } |
|
346 | + $class_name = $this->get_alias($class_name); |
|
347 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * @return array |
|
354 | + */ |
|
355 | + public function class_loaders() |
|
356 | + { |
|
357 | + return $this->_class_loaders; |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * adds an alias for a classname |
|
364 | + * |
|
365 | + * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
366 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
367 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
368 | + */ |
|
369 | + public function add_alias($class_name, $alias, $for_class = '') |
|
370 | + { |
|
371 | + if ($for_class !== '') { |
|
372 | + if (! isset($this->_aliases[$for_class])) { |
|
373 | + $this->_aliases[$for_class] = array(); |
|
374 | + } |
|
375 | + $this->_aliases[$for_class][$class_name] = $alias; |
|
376 | + } |
|
377 | + $this->_aliases[$class_name] = $alias; |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + |
|
382 | + /** |
|
383 | + * returns TRUE if the provided class name has an alias |
|
384 | + * |
|
385 | + * @param string $class_name |
|
386 | + * @param string $for_class |
|
387 | + * @return bool |
|
388 | + */ |
|
389 | + public function has_alias($class_name = '', $for_class = '') |
|
390 | + { |
|
391 | + return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name]) |
|
392 | + || ( |
|
393 | + isset($this->_aliases[$class_name]) |
|
394 | + && ! is_array($this->_aliases[$class_name]) |
|
395 | + ); |
|
396 | + } |
|
397 | + |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * returns alias for class name if one exists, otherwise returns the original classname |
|
402 | + * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
403 | + * for example: |
|
404 | + * if the following two entries were added to the _aliases array: |
|
405 | + * array( |
|
406 | + * 'interface_alias' => 'some\namespace\interface' |
|
407 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
408 | + * ) |
|
409 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
410 | + * to load an instance of 'some\namespace\classname' |
|
411 | + * |
|
412 | + * @param string $class_name |
|
413 | + * @param string $for_class |
|
414 | + * @return string |
|
415 | + */ |
|
416 | + public function get_alias($class_name = '', $for_class = '') |
|
417 | + { |
|
418 | + if (! $this->has_alias($class_name, $for_class)) { |
|
419 | + return $class_name; |
|
420 | + } |
|
421 | + if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
422 | + return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
423 | + } |
|
424 | + return $this->get_alias($this->_aliases[$class_name]); |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
431 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
432 | + * This is done by using the following class constants: |
|
433 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
434 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
435 | + */ |
|
436 | + protected function _register_core_dependencies() |
|
437 | + { |
|
438 | + $this->_dependency_map = array( |
|
439 | + 'EE_Request_Handler' => array( |
|
440 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
441 | + ), |
|
442 | + 'EE_System' => array( |
|
443 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
444 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
445 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
446 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
447 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
448 | + ), |
|
449 | + 'EE_Session' => array( |
|
450 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
451 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
452 | + ), |
|
453 | + 'EE_Cart' => array( |
|
454 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
455 | + ), |
|
456 | + 'EE_Front_Controller' => array( |
|
457 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
458 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
459 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
460 | + ), |
|
461 | + 'EE_Messenger_Collection_Loader' => array( |
|
462 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
463 | + ), |
|
464 | + 'EE_Message_Type_Collection_Loader' => array( |
|
465 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
466 | + ), |
|
467 | + 'EE_Message_Resource_Manager' => array( |
|
468 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
469 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
470 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
471 | + ), |
|
472 | + 'EE_Message_Factory' => array( |
|
473 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
474 | + ), |
|
475 | + 'EE_messages' => array( |
|
476 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
477 | + ), |
|
478 | + 'EE_Messages_Generator' => array( |
|
479 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
480 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
481 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
482 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
483 | + ), |
|
484 | + 'EE_Messages_Processor' => array( |
|
485 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
486 | + ), |
|
487 | + 'EE_Messages_Queue' => array( |
|
488 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
489 | + ), |
|
490 | + 'EE_Messages_Template_Defaults' => array( |
|
491 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
492 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
493 | + ), |
|
494 | + 'EE_Message_To_Generate_From_Request' => array( |
|
495 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
496 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
497 | + ), |
|
498 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
499 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
500 | + ), |
|
501 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
502 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
503 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
504 | + ), |
|
505 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
506 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
507 | + ), |
|
508 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
509 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
510 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
511 | + ), |
|
512 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
513 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
514 | + ), |
|
515 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
516 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
517 | + ), |
|
518 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
519 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
520 | + ), |
|
521 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
522 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
523 | + ), |
|
524 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
525 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
526 | + ), |
|
527 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
528 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
529 | + ), |
|
530 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
531 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
532 | + ), |
|
533 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
534 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
535 | + ), |
|
536 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
537 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
538 | + ), |
|
539 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
540 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
541 | + ), |
|
542 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
543 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
544 | + ), |
|
545 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
546 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
547 | + ), |
|
548 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
549 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
550 | + ), |
|
551 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
552 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
553 | + ), |
|
554 | + 'EE_Data_Migration_Class_Base' => array( |
|
555 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
556 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
557 | + ), |
|
558 | + 'EE_DMS_Core_4_1_0' => array( |
|
559 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
560 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
561 | + ), |
|
562 | + 'EE_DMS_Core_4_2_0' => array( |
|
563 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
564 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
565 | + ), |
|
566 | + 'EE_DMS_Core_4_3_0' => array( |
|
567 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
568 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
569 | + ), |
|
570 | + 'EE_DMS_Core_4_4_0' => array( |
|
571 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
572 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
573 | + ), |
|
574 | + 'EE_DMS_Core_4_5_0' => array( |
|
575 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
576 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
577 | + ), |
|
578 | + 'EE_DMS_Core_4_6_0' => array( |
|
579 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
580 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
581 | + ), |
|
582 | + 'EE_DMS_Core_4_7_0' => array( |
|
583 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
584 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
585 | + ), |
|
586 | + 'EE_DMS_Core_4_8_0' => array( |
|
587 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
588 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
589 | + ), |
|
590 | + 'EE_DMS_Core_4_9_0' => array( |
|
591 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
592 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
593 | + ), |
|
594 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
595 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
596 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
597 | + ), |
|
598 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
599 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
600 | + ), |
|
601 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
602 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
603 | + ), |
|
604 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
605 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
606 | + ), |
|
607 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
608 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
609 | + ), |
|
610 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
611 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
612 | + ), |
|
613 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
614 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
615 | + ), |
|
616 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
617 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
618 | + ), |
|
619 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
620 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
621 | + ), |
|
622 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
623 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
624 | + ), |
|
625 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
626 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
627 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
628 | + ), |
|
629 | + 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
630 | + null, |
|
631 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
632 | + ), |
|
633 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
634 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
635 | + ), |
|
636 | + 'LEGACY_MODELS' => array( |
|
637 | + null, |
|
638 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
639 | + ), |
|
640 | + 'EE_Module_Request_Router' => array( |
|
641 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
642 | + ), |
|
643 | + 'EE_Registration_Processor' => array( |
|
644 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
645 | + ), |
|
646 | + 'EventEspresso\core\services\currency\CurrencyFactory' => array( |
|
647 | + 'EventEspresso\core\services\currency\CountryCurrencyDao' => EE_Dependency_Map::load_from_cache, |
|
648 | + 'EE_Organization_Config' => EE_Dependency_Map::load_from_cache, |
|
649 | + ), |
|
650 | + 'EventEspresso\core\services\currency\MoneyFactory' => array( |
|
651 | + 'EventEspresso\core\services\currency\CurrencyFactory' => EE_Dependency_Map::load_from_cache, |
|
652 | + 'EventEspresso\core\services\currency\Calculator' => EE_Dependency_Map::load_from_cache, |
|
653 | + ), |
|
654 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
655 | + null, |
|
656 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
657 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
658 | + ), |
|
659 | + 'EventEspresso\core\services\currency\MoneyFactory' => array( |
|
660 | + 'EventEspresso\core\services\currency\CurrencyFactory' => EE_Dependency_Map::load_from_cache |
|
661 | + ) |
|
662 | + ); |
|
663 | + } |
|
664 | + |
|
665 | + |
|
666 | + |
|
667 | + /** |
|
668 | + * Registers how core classes are loaded. |
|
669 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
670 | + * 'EE_Request_Handler' => 'load_core' |
|
671 | + * 'EE_Messages_Queue' => 'load_lib' |
|
672 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
673 | + * or, if greater control is required, by providing a custom closure. For example: |
|
674 | + * 'Some_Class' => function () { |
|
675 | + * return new Some_Class(); |
|
676 | + * }, |
|
677 | + * This is required for instantiating dependencies |
|
678 | + * where an interface has been type hinted in a class constructor. For example: |
|
679 | + * 'Required_Interface' => function () { |
|
680 | + * return new A_Class_That_Implements_Required_Interface(); |
|
681 | + * }, |
|
682 | + * |
|
683 | + * @throws InvalidInterfaceException |
|
684 | + * @throws InvalidDataTypeException |
|
685 | + * @throws InvalidArgumentException |
|
686 | + */ |
|
687 | + protected function _register_core_class_loaders() |
|
688 | + { |
|
689 | + //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
690 | + //be used in a closure. |
|
691 | + $request = &$this->_request; |
|
692 | + $response = &$this->_response; |
|
693 | + // $loader = &$this->loader; |
|
694 | + $this->_class_loaders = array( |
|
695 | + //load_core |
|
696 | + 'EE_Capabilities' => 'load_core', |
|
697 | + 'EE_Encryption' => 'load_core', |
|
698 | + 'EE_Front_Controller' => 'load_core', |
|
699 | + 'EE_Module_Request_Router' => 'load_core', |
|
700 | + 'EE_Registry' => 'load_core', |
|
701 | + 'EE_Request' => function () use (&$request) { |
|
702 | + return $request; |
|
703 | + }, |
|
704 | + 'EE_Response' => function () use (&$response) { |
|
705 | + return $response; |
|
706 | + }, |
|
707 | + 'EE_Request_Handler' => 'load_core', |
|
708 | + 'EE_Session' => 'load_core', |
|
709 | + 'EE_Cron_Tasks' => 'load_core', |
|
710 | + 'EE_System' => 'load_core', |
|
711 | + 'EE_Maintenance_Mode' => 'load_core', |
|
712 | + 'EE_Register_CPTs' => 'load_core', |
|
713 | + 'EE_Admin' => 'load_core', |
|
714 | + //load_lib |
|
715 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
716 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
717 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
718 | + 'EE_Messenger_Collection' => 'load_lib', |
|
719 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
720 | + 'EE_Messages_Processor' => 'load_lib', |
|
721 | + 'EE_Message_Repository' => 'load_lib', |
|
722 | + 'EE_Messages_Queue' => 'load_lib', |
|
723 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
724 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
725 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
726 | + 'EE_Messages_Generator' => function () { |
|
727 | + return EE_Registry::instance()->load_lib( |
|
728 | + 'Messages_Generator', |
|
729 | + array(), |
|
730 | + false, |
|
731 | + false |
|
732 | + ); |
|
733 | + }, |
|
734 | + 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
735 | + return EE_Registry::instance()->load_lib( |
|
736 | + 'Messages_Template_Defaults', |
|
737 | + $arguments, |
|
738 | + false, |
|
739 | + false |
|
740 | + ); |
|
741 | + }, |
|
742 | + //load_model |
|
743 | + // 'EEM_Attendee' => 'load_model', |
|
744 | + // 'EEM_Message_Template_Group' => 'load_model', |
|
745 | + // 'EEM_Message_Template' => 'load_model', |
|
746 | + //load_helper |
|
747 | + 'EEH_Parse_Shortcodes' => function () { |
|
748 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
749 | + return new EEH_Parse_Shortcodes(); |
|
750 | + } |
|
751 | + return null; |
|
752 | + }, |
|
753 | + 'EE_Template_Config' => function () { |
|
754 | + return EE_Config::instance()->template_settings; |
|
755 | + }, |
|
756 | + 'EE_Currency_Config' => function () { |
|
757 | + return EE_Config::instance()->currency; |
|
758 | + }, |
|
759 | + 'EE_Registration_Config' => function () { |
|
760 | + return EE_Config::instance()->registration; |
|
761 | + }, |
|
762 | + 'EE_Organization_Config' => function () { |
|
763 | + return EE_Config::instance()->organization; |
|
764 | + }, |
|
765 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
766 | + return LoaderFactory::getLoader(); |
|
767 | + }, |
|
768 | + ); |
|
769 | + } |
|
770 | + |
|
771 | + |
|
772 | + |
|
773 | + /** |
|
774 | + * can be used for supplying alternate names for classes, |
|
775 | + * or for connecting interface names to instantiable classes |
|
776 | + */ |
|
777 | + protected function _register_core_aliases() |
|
778 | + { |
|
779 | + $this->_aliases = array( |
|
780 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
781 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
782 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
783 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
784 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
785 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
786 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
787 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
788 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
789 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
790 | + 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
791 | + 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
792 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
793 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
794 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
795 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
796 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
797 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
798 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
799 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
800 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
801 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
802 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
803 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
804 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
805 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
806 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
807 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
808 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
809 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
810 | + 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
811 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
812 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
813 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
814 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
815 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
816 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
817 | + 'EventEspresso\core\services\currency\Calculator' => 'EventEspresso\core\services\currency\DefaultCalculator', |
|
818 | + ); |
|
819 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
820 | + $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
821 | + } |
|
822 | + } |
|
823 | + |
|
824 | + |
|
825 | + |
|
826 | + /** |
|
827 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
828 | + * request Primarily used by unit tests. |
|
829 | + * |
|
830 | + * @throws InvalidDataTypeException |
|
831 | + * @throws InvalidInterfaceException |
|
832 | + * @throws InvalidArgumentException |
|
833 | + */ |
|
834 | + public function reset() |
|
835 | + { |
|
836 | + $this->_register_core_class_loaders(); |
|
837 | + $this->_register_core_dependencies(); |
|
838 | + } |
|
839 | 839 | |
840 | 840 | |
841 | 841 | } |
@@ -19,337 +19,337 @@ |
||
19 | 19 | class EEH_Money extends EEH_Base |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * This removes all localized money formatting from the incoming value |
|
24 | - * Note: uses this site's currency settings for deciding what is considered a |
|
25 | - * "thousands separator" (usually the character "," ) |
|
26 | - * and what is a "decimal mark" (usually the character ".") |
|
27 | - * |
|
28 | - * @param int|float|string $money_value |
|
29 | - * @param string $CNT_ISO |
|
30 | - * @return float |
|
31 | - * @throws EE_Error |
|
32 | - * @throws InvalidArgumentException |
|
33 | - * @throws ReflectionException |
|
34 | - * @throws InvalidDataTypeException |
|
35 | - * @throws InvalidInterfaceException |
|
36 | - */ |
|
37 | - public static function strip_localized_money_formatting($money_value, $CNT_ISO = '') |
|
38 | - { |
|
39 | - $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
40 | - $money_value = str_replace( |
|
41 | - array( |
|
42 | - $currency_config->thsnds, |
|
43 | - $currency_config->dec_mrk, |
|
44 | - ), |
|
45 | - array( |
|
46 | - '', // remove thousands separator |
|
47 | - '.', // convert decimal mark to what PHP expects |
|
48 | - ), |
|
49 | - $money_value |
|
50 | - ); |
|
51 | - $money_value = filter_var( |
|
52 | - $money_value, |
|
53 | - FILTER_SANITIZE_NUMBER_FLOAT, |
|
54 | - FILTER_FLAG_ALLOW_FRACTION |
|
55 | - ); |
|
56 | - return $money_value; |
|
57 | - } |
|
22 | + /** |
|
23 | + * This removes all localized money formatting from the incoming value |
|
24 | + * Note: uses this site's currency settings for deciding what is considered a |
|
25 | + * "thousands separator" (usually the character "," ) |
|
26 | + * and what is a "decimal mark" (usually the character ".") |
|
27 | + * |
|
28 | + * @param int|float|string $money_value |
|
29 | + * @param string $CNT_ISO |
|
30 | + * @return float |
|
31 | + * @throws EE_Error |
|
32 | + * @throws InvalidArgumentException |
|
33 | + * @throws ReflectionException |
|
34 | + * @throws InvalidDataTypeException |
|
35 | + * @throws InvalidInterfaceException |
|
36 | + */ |
|
37 | + public static function strip_localized_money_formatting($money_value, $CNT_ISO = '') |
|
38 | + { |
|
39 | + $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
40 | + $money_value = str_replace( |
|
41 | + array( |
|
42 | + $currency_config->thsnds, |
|
43 | + $currency_config->dec_mrk, |
|
44 | + ), |
|
45 | + array( |
|
46 | + '', // remove thousands separator |
|
47 | + '.', // convert decimal mark to what PHP expects |
|
48 | + ), |
|
49 | + $money_value |
|
50 | + ); |
|
51 | + $money_value = filter_var( |
|
52 | + $money_value, |
|
53 | + FILTER_SANITIZE_NUMBER_FLOAT, |
|
54 | + FILTER_FLAG_ALLOW_FRACTION |
|
55 | + ); |
|
56 | + return $money_value; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
62 | - * Only use this if you know the $money_value follows your currency configuration's |
|
63 | - * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
64 | - * "thousands separator" (usually the character "," ) |
|
65 | - * and what is a "decimal mark" (usually the character ".") |
|
66 | - * |
|
67 | - * @param int|string $money_value |
|
68 | - * @return float |
|
69 | - * @throws EE_Error |
|
70 | - * @throws InvalidArgumentException |
|
71 | - * @throws ReflectionException |
|
72 | - * @throws InvalidDataTypeException |
|
73 | - * @throws InvalidInterfaceException |
|
74 | - */ |
|
75 | - public static function convert_to_float_from_localized_money($money_value) |
|
76 | - { |
|
77 | - //float it! and round to three decimal places |
|
78 | - return round((float) EEH_Money::strip_localized_money_formatting($money_value), 3); |
|
79 | - } |
|
60 | + /** |
|
61 | + * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
62 | + * Only use this if you know the $money_value follows your currency configuration's |
|
63 | + * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
64 | + * "thousands separator" (usually the character "," ) |
|
65 | + * and what is a "decimal mark" (usually the character ".") |
|
66 | + * |
|
67 | + * @param int|string $money_value |
|
68 | + * @return float |
|
69 | + * @throws EE_Error |
|
70 | + * @throws InvalidArgumentException |
|
71 | + * @throws ReflectionException |
|
72 | + * @throws InvalidDataTypeException |
|
73 | + * @throws InvalidInterfaceException |
|
74 | + */ |
|
75 | + public static function convert_to_float_from_localized_money($money_value) |
|
76 | + { |
|
77 | + //float it! and round to three decimal places |
|
78 | + return round((float) EEH_Money::strip_localized_money_formatting($money_value), 3); |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
84 | - * This should be used to compare floats instead of normal '==' because floats |
|
85 | - * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
86 | - * but actually differ by 0.00000001. |
|
87 | - * |
|
88 | - * @see http://biostall.com/php-function-to-compare-floating-point-numbers |
|
89 | - * @param float $float1 |
|
90 | - * @param float $float2 |
|
91 | - * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
92 | - * @return bool whether the equation is true or false |
|
93 | - * @throws EE_Error |
|
94 | - */ |
|
95 | - public static function compare_floats($float1, $float2, $operator = '=') |
|
96 | - { |
|
97 | - // Check numbers to 5 digits of precision |
|
98 | - $epsilon = 0.00001; |
|
99 | - $float1 = (float) $float1; |
|
100 | - $float2 = (float) $float2; |
|
101 | - switch ($operator) { |
|
102 | - // equal |
|
103 | - case '=': |
|
104 | - case '==': |
|
105 | - case '===': |
|
106 | - case 'eq': |
|
107 | - if (abs($float1 - $float2) < $epsilon) { |
|
108 | - return true; |
|
109 | - } |
|
110 | - break; |
|
111 | - // less than |
|
112 | - case '<': |
|
113 | - case 'lt': |
|
114 | - if (abs($float1 - $float2) < $epsilon) { |
|
115 | - return false; |
|
116 | - } |
|
117 | - if ($float1 < $float2) { |
|
118 | - return true; |
|
119 | - } |
|
120 | - break; |
|
121 | - // less than or equal |
|
122 | - case '<=': |
|
123 | - case 'lte': |
|
124 | - if ( |
|
125 | - self::compare_floats($float1, $float2, '<') |
|
126 | - || self::compare_floats($float1, $float2) |
|
127 | - ) { |
|
128 | - return true; |
|
129 | - } |
|
130 | - break; |
|
131 | - // greater than |
|
132 | - case '>': |
|
133 | - case 'gt': |
|
134 | - if (abs($float1 - $float2) < $epsilon) { |
|
135 | - return false; |
|
136 | - } |
|
137 | - if ($float1 > $float2) { |
|
138 | - return true; |
|
139 | - } |
|
140 | - break; |
|
141 | - // greater than or equal |
|
142 | - case '>=': |
|
143 | - case 'gte': |
|
144 | - if ( |
|
145 | - self::compare_floats($float1, $float2, '>') |
|
146 | - || self::compare_floats($float1, $float2) |
|
147 | - ) { |
|
148 | - return true; |
|
149 | - } |
|
150 | - break; |
|
151 | - case '<>': |
|
152 | - case '!=': |
|
153 | - case 'ne': |
|
154 | - if (abs($float1 - $float2) > $epsilon) { |
|
155 | - return true; |
|
156 | - } |
|
157 | - break; |
|
158 | - default: |
|
159 | - throw new EE_Error( |
|
160 | - esc_html__( |
|
161 | - "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", |
|
162 | - 'event_espresso' |
|
163 | - ) |
|
164 | - ); |
|
165 | - } |
|
166 | - return false; |
|
167 | - } |
|
82 | + /** |
|
83 | + * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
84 | + * This should be used to compare floats instead of normal '==' because floats |
|
85 | + * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
86 | + * but actually differ by 0.00000001. |
|
87 | + * |
|
88 | + * @see http://biostall.com/php-function-to-compare-floating-point-numbers |
|
89 | + * @param float $float1 |
|
90 | + * @param float $float2 |
|
91 | + * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
92 | + * @return bool whether the equation is true or false |
|
93 | + * @throws EE_Error |
|
94 | + */ |
|
95 | + public static function compare_floats($float1, $float2, $operator = '=') |
|
96 | + { |
|
97 | + // Check numbers to 5 digits of precision |
|
98 | + $epsilon = 0.00001; |
|
99 | + $float1 = (float) $float1; |
|
100 | + $float2 = (float) $float2; |
|
101 | + switch ($operator) { |
|
102 | + // equal |
|
103 | + case '=': |
|
104 | + case '==': |
|
105 | + case '===': |
|
106 | + case 'eq': |
|
107 | + if (abs($float1 - $float2) < $epsilon) { |
|
108 | + return true; |
|
109 | + } |
|
110 | + break; |
|
111 | + // less than |
|
112 | + case '<': |
|
113 | + case 'lt': |
|
114 | + if (abs($float1 - $float2) < $epsilon) { |
|
115 | + return false; |
|
116 | + } |
|
117 | + if ($float1 < $float2) { |
|
118 | + return true; |
|
119 | + } |
|
120 | + break; |
|
121 | + // less than or equal |
|
122 | + case '<=': |
|
123 | + case 'lte': |
|
124 | + if ( |
|
125 | + self::compare_floats($float1, $float2, '<') |
|
126 | + || self::compare_floats($float1, $float2) |
|
127 | + ) { |
|
128 | + return true; |
|
129 | + } |
|
130 | + break; |
|
131 | + // greater than |
|
132 | + case '>': |
|
133 | + case 'gt': |
|
134 | + if (abs($float1 - $float2) < $epsilon) { |
|
135 | + return false; |
|
136 | + } |
|
137 | + if ($float1 > $float2) { |
|
138 | + return true; |
|
139 | + } |
|
140 | + break; |
|
141 | + // greater than or equal |
|
142 | + case '>=': |
|
143 | + case 'gte': |
|
144 | + if ( |
|
145 | + self::compare_floats($float1, $float2, '>') |
|
146 | + || self::compare_floats($float1, $float2) |
|
147 | + ) { |
|
148 | + return true; |
|
149 | + } |
|
150 | + break; |
|
151 | + case '<>': |
|
152 | + case '!=': |
|
153 | + case 'ne': |
|
154 | + if (abs($float1 - $float2) > $epsilon) { |
|
155 | + return true; |
|
156 | + } |
|
157 | + break; |
|
158 | + default: |
|
159 | + throw new EE_Error( |
|
160 | + esc_html__( |
|
161 | + "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", |
|
162 | + 'event_espresso' |
|
163 | + ) |
|
164 | + ); |
|
165 | + } |
|
166 | + return false; |
|
167 | + } |
|
168 | 168 | |
169 | 169 | |
170 | - /** |
|
171 | - * This returns a localized format string suitable for jqPlot. |
|
172 | - * |
|
173 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
174 | - * Otherwise will use currency settings for current active country on site. |
|
175 | - * @return string |
|
176 | - * @throws EE_Error |
|
177 | - * @throws InvalidArgumentException |
|
178 | - * @throws ReflectionException |
|
179 | - * @throws InvalidDataTypeException |
|
180 | - * @throws InvalidInterfaceException |
|
181 | - */ |
|
182 | - public static function get_format_for_jqplot($CNT_ISO = '') |
|
183 | - { |
|
184 | - //default format |
|
185 | - $format = 'f'; |
|
186 | - $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
187 | - //first get the decimal place and number of places |
|
188 | - $format = "%'." . $currency_config->dec_plc . $format; |
|
189 | - //currency symbol on right side. |
|
190 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
191 | - return $format; |
|
192 | - } |
|
170 | + /** |
|
171 | + * This returns a localized format string suitable for jqPlot. |
|
172 | + * |
|
173 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
174 | + * Otherwise will use currency settings for current active country on site. |
|
175 | + * @return string |
|
176 | + * @throws EE_Error |
|
177 | + * @throws InvalidArgumentException |
|
178 | + * @throws ReflectionException |
|
179 | + * @throws InvalidDataTypeException |
|
180 | + * @throws InvalidInterfaceException |
|
181 | + */ |
|
182 | + public static function get_format_for_jqplot($CNT_ISO = '') |
|
183 | + { |
|
184 | + //default format |
|
185 | + $format = 'f'; |
|
186 | + $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
187 | + //first get the decimal place and number of places |
|
188 | + $format = "%'." . $currency_config->dec_plc . $format; |
|
189 | + //currency symbol on right side. |
|
190 | + $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
191 | + return $format; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | |
195 | - /** |
|
196 | - * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
197 | - * |
|
198 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
199 | - * Otherwise will use currency settings for current active country on site. |
|
200 | - * Note: GoogleCharts uses ICU pattern set |
|
201 | - * (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
202 | - * @return array |
|
203 | - * @throws EE_Error |
|
204 | - * @throws InvalidArgumentException |
|
205 | - * @throws ReflectionException |
|
206 | - * @throws InvalidDataTypeException |
|
207 | - * @throws InvalidInterfaceException |
|
208 | - */ |
|
209 | - public static function get_format_for_google_charts($CNT_ISO = '') |
|
210 | - { |
|
211 | - $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
212 | - $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
|
213 | - //first get the decimal place and number of places |
|
214 | - $format = '#,##0.' . $decimal_places_placeholder; |
|
215 | - //currency symbol on right side. |
|
216 | - $format = $currency_config->sign_b4 |
|
217 | - ? $currency_config->sign . $format |
|
218 | - : $format |
|
219 | - . $currency_config->sign; |
|
220 | - $formatterObject = array( |
|
221 | - 'decimalSymbol' => $currency_config->dec_mrk, |
|
222 | - 'groupingSymbol' => $currency_config->thsnds, |
|
223 | - 'fractionDigits' => $currency_config->dec_plc, |
|
224 | - ); |
|
225 | - if ($currency_config->sign_b4) { |
|
226 | - $formatterObject['prefix'] = $currency_config->sign; |
|
227 | - } else { |
|
228 | - $formatterObject['suffix'] = $currency_config->sign; |
|
229 | - } |
|
230 | - return array( |
|
231 | - 'format' => $format, |
|
232 | - 'formatterObject' => $formatterObject, |
|
233 | - ); |
|
234 | - } |
|
195 | + /** |
|
196 | + * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
197 | + * |
|
198 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
199 | + * Otherwise will use currency settings for current active country on site. |
|
200 | + * Note: GoogleCharts uses ICU pattern set |
|
201 | + * (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
202 | + * @return array |
|
203 | + * @throws EE_Error |
|
204 | + * @throws InvalidArgumentException |
|
205 | + * @throws ReflectionException |
|
206 | + * @throws InvalidDataTypeException |
|
207 | + * @throws InvalidInterfaceException |
|
208 | + */ |
|
209 | + public static function get_format_for_google_charts($CNT_ISO = '') |
|
210 | + { |
|
211 | + $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
212 | + $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
|
213 | + //first get the decimal place and number of places |
|
214 | + $format = '#,##0.' . $decimal_places_placeholder; |
|
215 | + //currency symbol on right side. |
|
216 | + $format = $currency_config->sign_b4 |
|
217 | + ? $currency_config->sign . $format |
|
218 | + : $format |
|
219 | + . $currency_config->sign; |
|
220 | + $formatterObject = array( |
|
221 | + 'decimalSymbol' => $currency_config->dec_mrk, |
|
222 | + 'groupingSymbol' => $currency_config->thsnds, |
|
223 | + 'fractionDigits' => $currency_config->dec_plc, |
|
224 | + ); |
|
225 | + if ($currency_config->sign_b4) { |
|
226 | + $formatterObject['prefix'] = $currency_config->sign; |
|
227 | + } else { |
|
228 | + $formatterObject['suffix'] = $currency_config->sign; |
|
229 | + } |
|
230 | + return array( |
|
231 | + 'format' => $format, |
|
232 | + 'formatterObject' => $formatterObject, |
|
233 | + ); |
|
234 | + } |
|
235 | 235 | |
236 | 236 | |
237 | - /** |
|
238 | - * @param string $CNT_ISO |
|
239 | - * @param bool $from_db whether to fetch currency data from the admin editable DB, or the immutable JSON file |
|
240 | - * @return EE_Currency_Config |
|
241 | - * @throws EE_Error |
|
242 | - * @throws InvalidArgumentException |
|
243 | - * @throws ReflectionException |
|
244 | - * @throws InvalidDataTypeException |
|
245 | - * @throws InvalidInterfaceException |
|
246 | - */ |
|
247 | - public static function get_currency_config($CNT_ISO = '', $from_db = true) |
|
248 | - { |
|
249 | - //if CNT_ISO passed lets try to get currency settings for it. |
|
250 | - $currency_config = $CNT_ISO !== '' |
|
251 | - ? new EE_Currency_Config($CNT_ISO) |
|
252 | - : null; |
|
253 | - if ($from_db) { |
|
254 | - $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
255 | - if ($country instanceof EE_Country) { |
|
256 | - $currency_config->setFromCountry($country); |
|
257 | - } |
|
258 | - } |
|
259 | - //default currency settings for site if not set |
|
260 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
261 | - $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
262 | - ? EE_Registry::instance()->CFG->currency |
|
263 | - : new EE_Currency_Config(); |
|
264 | - } |
|
265 | - return $currency_config; |
|
266 | - } |
|
237 | + /** |
|
238 | + * @param string $CNT_ISO |
|
239 | + * @param bool $from_db whether to fetch currency data from the admin editable DB, or the immutable JSON file |
|
240 | + * @return EE_Currency_Config |
|
241 | + * @throws EE_Error |
|
242 | + * @throws InvalidArgumentException |
|
243 | + * @throws ReflectionException |
|
244 | + * @throws InvalidDataTypeException |
|
245 | + * @throws InvalidInterfaceException |
|
246 | + */ |
|
247 | + public static function get_currency_config($CNT_ISO = '', $from_db = true) |
|
248 | + { |
|
249 | + //if CNT_ISO passed lets try to get currency settings for it. |
|
250 | + $currency_config = $CNT_ISO !== '' |
|
251 | + ? new EE_Currency_Config($CNT_ISO) |
|
252 | + : null; |
|
253 | + if ($from_db) { |
|
254 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
255 | + if ($country instanceof EE_Country) { |
|
256 | + $currency_config->setFromCountry($country); |
|
257 | + } |
|
258 | + } |
|
259 | + //default currency settings for site if not set |
|
260 | + if (! $currency_config instanceof EE_Currency_Config) { |
|
261 | + $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
262 | + ? EE_Registry::instance()->CFG->currency |
|
263 | + : new EE_Currency_Config(); |
|
264 | + } |
|
265 | + return $currency_config; |
|
266 | + } |
|
267 | 267 | |
268 | 268 | |
269 | - /** |
|
270 | - * replacement for EEH_Template::format_currency |
|
271 | - * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
272 | - * the country currency settings from the supplied country ISO code |
|
273 | - * |
|
274 | - * @param float $amount raw money value |
|
275 | - * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
276 | - * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
277 | - * @param string $CNT_ISO 2 letter ISO code for a country |
|
278 | - * @param string $cur_code_span_class |
|
279 | - * @param boolean $from_db whether to fetch configuration data from the database (which a site admin can change) |
|
280 | - * or from our JSON file, which admins can't change. Setting to true is usually better |
|
281 | - * if the value will be displayed to a user; but if communicating with another server, |
|
282 | - * setting to false will return more reliable formatting. |
|
283 | - * @since $VID:$ |
|
284 | - * @return string the html output for the formatted money value |
|
285 | - * @throws EE_Error |
|
286 | - * @throws InvalidArgumentException |
|
287 | - * @throws ReflectionException |
|
288 | - * @throws InvalidDataTypeException |
|
289 | - * @throws InvalidInterfaceException |
|
290 | - */ |
|
291 | - public static function format_currency( |
|
292 | - $amount = null, |
|
293 | - $return_raw = false, |
|
294 | - $display_code = true, |
|
295 | - $CNT_ISO = '', |
|
296 | - $cur_code_span_class = 'currency-code', |
|
297 | - $from_db = true |
|
298 | - ) { |
|
299 | - // ensure amount was received |
|
300 | - if ($amount === null) { |
|
301 | - $msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
302 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
303 | - return ''; |
|
304 | - } |
|
305 | - //ensure amount is float |
|
306 | - $amount = (float)filter_var( |
|
307 | - apply_filters('FHEE__EEH_Template__format_currency__raw_amount', $amount), |
|
308 | - FILTER_SANITIZE_NUMBER_FLOAT, |
|
309 | - FILTER_FLAG_ALLOW_FRACTION |
|
310 | - ); |
|
311 | - $CNT_ISO = (string) apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
312 | - // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
313 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
314 | - // still a number or was amount converted to a string like "free" ? |
|
315 | - if (is_float($amount_formatted)) { |
|
316 | - // get currency config object for that country |
|
317 | - $mny = EEH_Money::get_currency_config($CNT_ISO, $from_db); |
|
318 | - // format float |
|
319 | - $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
320 | - // add formatting ? |
|
321 | - if (! $return_raw) { |
|
322 | - // add currency sign |
|
323 | - if ($mny->sign_b4) { |
|
324 | - if ($amount >= 0) { |
|
325 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
326 | - } else { |
|
327 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
328 | - } |
|
329 | - } else { |
|
330 | - $amount_formatted .= $mny->sign; |
|
331 | - } |
|
332 | - // filter to allow global setting of display_code |
|
333 | - $display_code = filter_var( |
|
334 | - apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code), |
|
335 | - FILTER_VALIDATE_BOOLEAN |
|
336 | - ); |
|
337 | - // add currency code ? |
|
338 | - $amount_formatted = $display_code |
|
339 | - ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' |
|
340 | - : $amount_formatted; |
|
341 | - } |
|
342 | - // filter results |
|
343 | - $amount_formatted = (string) apply_filters( |
|
344 | - 'FHEE__EEH_Template__format_currency__amount_formatted', |
|
345 | - $amount_formatted, |
|
346 | - $mny, |
|
347 | - $return_raw |
|
348 | - ); |
|
349 | - } |
|
350 | - // clean up vars |
|
351 | - unset($mny); |
|
352 | - // return formatted currency amount |
|
353 | - return $amount_formatted; |
|
354 | - } |
|
269 | + /** |
|
270 | + * replacement for EEH_Template::format_currency |
|
271 | + * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
272 | + * the country currency settings from the supplied country ISO code |
|
273 | + * |
|
274 | + * @param float $amount raw money value |
|
275 | + * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
276 | + * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
277 | + * @param string $CNT_ISO 2 letter ISO code for a country |
|
278 | + * @param string $cur_code_span_class |
|
279 | + * @param boolean $from_db whether to fetch configuration data from the database (which a site admin can change) |
|
280 | + * or from our JSON file, which admins can't change. Setting to true is usually better |
|
281 | + * if the value will be displayed to a user; but if communicating with another server, |
|
282 | + * setting to false will return more reliable formatting. |
|
283 | + * @since $VID:$ |
|
284 | + * @return string the html output for the formatted money value |
|
285 | + * @throws EE_Error |
|
286 | + * @throws InvalidArgumentException |
|
287 | + * @throws ReflectionException |
|
288 | + * @throws InvalidDataTypeException |
|
289 | + * @throws InvalidInterfaceException |
|
290 | + */ |
|
291 | + public static function format_currency( |
|
292 | + $amount = null, |
|
293 | + $return_raw = false, |
|
294 | + $display_code = true, |
|
295 | + $CNT_ISO = '', |
|
296 | + $cur_code_span_class = 'currency-code', |
|
297 | + $from_db = true |
|
298 | + ) { |
|
299 | + // ensure amount was received |
|
300 | + if ($amount === null) { |
|
301 | + $msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
302 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
303 | + return ''; |
|
304 | + } |
|
305 | + //ensure amount is float |
|
306 | + $amount = (float)filter_var( |
|
307 | + apply_filters('FHEE__EEH_Template__format_currency__raw_amount', $amount), |
|
308 | + FILTER_SANITIZE_NUMBER_FLOAT, |
|
309 | + FILTER_FLAG_ALLOW_FRACTION |
|
310 | + ); |
|
311 | + $CNT_ISO = (string) apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
312 | + // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
313 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
314 | + // still a number or was amount converted to a string like "free" ? |
|
315 | + if (is_float($amount_formatted)) { |
|
316 | + // get currency config object for that country |
|
317 | + $mny = EEH_Money::get_currency_config($CNT_ISO, $from_db); |
|
318 | + // format float |
|
319 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
320 | + // add formatting ? |
|
321 | + if (! $return_raw) { |
|
322 | + // add currency sign |
|
323 | + if ($mny->sign_b4) { |
|
324 | + if ($amount >= 0) { |
|
325 | + $amount_formatted = $mny->sign . $amount_formatted; |
|
326 | + } else { |
|
327 | + $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
328 | + } |
|
329 | + } else { |
|
330 | + $amount_formatted .= $mny->sign; |
|
331 | + } |
|
332 | + // filter to allow global setting of display_code |
|
333 | + $display_code = filter_var( |
|
334 | + apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code), |
|
335 | + FILTER_VALIDATE_BOOLEAN |
|
336 | + ); |
|
337 | + // add currency code ? |
|
338 | + $amount_formatted = $display_code |
|
339 | + ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' |
|
340 | + : $amount_formatted; |
|
341 | + } |
|
342 | + // filter results |
|
343 | + $amount_formatted = (string) apply_filters( |
|
344 | + 'FHEE__EEH_Template__format_currency__amount_formatted', |
|
345 | + $amount_formatted, |
|
346 | + $mny, |
|
347 | + $return_raw |
|
348 | + ); |
|
349 | + } |
|
350 | + // clean up vars |
|
351 | + unset($mny); |
|
352 | + // return formatted currency amount |
|
353 | + return $amount_formatted; |
|
354 | + } |
|
355 | 355 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | ), |
49 | 49 | $money_value |
50 | 50 | ); |
51 | - $money_value = filter_var( |
|
51 | + $money_value = filter_var( |
|
52 | 52 | $money_value, |
53 | 53 | FILTER_SANITIZE_NUMBER_FLOAT, |
54 | 54 | FILTER_FLAG_ALLOW_FRACTION |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | default: |
159 | 159 | throw new EE_Error( |
160 | 160 | esc_html__( |
161 | - "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", |
|
161 | + "Unknown operator '".$operator."' in EEH_Money::compare_floats()", |
|
162 | 162 | 'event_espresso' |
163 | 163 | ) |
164 | 164 | ); |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | $format = 'f'; |
186 | 186 | $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
187 | 187 | //first get the decimal place and number of places |
188 | - $format = "%'." . $currency_config->dec_plc . $format; |
|
188 | + $format = "%'.".$currency_config->dec_plc.$format; |
|
189 | 189 | //currency symbol on right side. |
190 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
190 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
191 | 191 | return $format; |
192 | 192 | } |
193 | 193 | |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
212 | 212 | $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
213 | 213 | //first get the decimal place and number of places |
214 | - $format = '#,##0.' . $decimal_places_placeholder; |
|
214 | + $format = '#,##0.'.$decimal_places_placeholder; |
|
215 | 215 | //currency symbol on right side. |
216 | - $format = $currency_config->sign_b4 |
|
217 | - ? $currency_config->sign . $format |
|
216 | + $format = $currency_config->sign_b4 |
|
217 | + ? $currency_config->sign.$format |
|
218 | 218 | : $format |
219 | 219 | . $currency_config->sign; |
220 | 220 | $formatterObject = array( |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | } |
258 | 258 | } |
259 | 259 | //default currency settings for site if not set |
260 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
260 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
261 | 261 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
262 | 262 | ? EE_Registry::instance()->CFG->currency |
263 | 263 | : new EE_Currency_Config(); |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | return ''; |
304 | 304 | } |
305 | 305 | //ensure amount is float |
306 | - $amount = (float)filter_var( |
|
306 | + $amount = (float) filter_var( |
|
307 | 307 | apply_filters('FHEE__EEH_Template__format_currency__raw_amount', $amount), |
308 | 308 | FILTER_SANITIZE_NUMBER_FLOAT, |
309 | 309 | FILTER_FLAG_ALLOW_FRACTION |
@@ -318,13 +318,13 @@ discard block |
||
318 | 318 | // format float |
319 | 319 | $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
320 | 320 | // add formatting ? |
321 | - if (! $return_raw) { |
|
321 | + if ( ! $return_raw) { |
|
322 | 322 | // add currency sign |
323 | 323 | if ($mny->sign_b4) { |
324 | 324 | if ($amount >= 0) { |
325 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
325 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
326 | 326 | } else { |
327 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
327 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
328 | 328 | } |
329 | 329 | } else { |
330 | 330 | $amount_formatted .= $mny->sign; |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | ); |
337 | 337 | // add currency code ? |
338 | 338 | $amount_formatted = $display_code |
339 | - ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' |
|
339 | + ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' |
|
340 | 340 | : $amount_formatted; |
341 | 341 | } |
342 | 342 | // filter results |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
5 | 5 | |
6 | 6 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('NO direct script access allowed'); |
|
7 | + exit('NO direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | /** |
10 | 10 | * Event Espresso |
@@ -20,35 +20,35 @@ discard block |
||
20 | 20 | |
21 | 21 | |
22 | 22 | if ( ! function_exists('espresso_get_template_part')) { |
23 | - /** |
|
24 | - * espresso_get_template_part |
|
25 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
26 | - * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
27 | - * |
|
28 | - * @param string $slug The slug name for the generic template. |
|
29 | - * @param string $name The name of the specialised template. |
|
30 | - * @return string the html output for the formatted money value |
|
31 | - */ |
|
32 | - function espresso_get_template_part($slug = null, $name = null) |
|
33 | - { |
|
34 | - EEH_Template::get_template_part($slug, $name); |
|
35 | - } |
|
23 | + /** |
|
24 | + * espresso_get_template_part |
|
25 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
26 | + * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
27 | + * |
|
28 | + * @param string $slug The slug name for the generic template. |
|
29 | + * @param string $name The name of the specialised template. |
|
30 | + * @return string the html output for the formatted money value |
|
31 | + */ |
|
32 | + function espresso_get_template_part($slug = null, $name = null) |
|
33 | + { |
|
34 | + EEH_Template::get_template_part($slug, $name); |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | if ( ! function_exists('espresso_get_object_css_class')) { |
40 | - /** |
|
41 | - * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
42 | - * |
|
43 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
44 | - * @param string $prefix added to the beginning of the generated class |
|
45 | - * @param string $suffix added to the end of the generated class |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
49 | - { |
|
50 | - return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
51 | - } |
|
40 | + /** |
|
41 | + * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
42 | + * |
|
43 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
44 | + * @param string $prefix added to the beginning of the generated class |
|
45 | + * @param string $suffix added to the end of the generated class |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
49 | + { |
|
50 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -63,610 +63,610 @@ discard block |
||
63 | 63 | class EEH_Template |
64 | 64 | { |
65 | 65 | |
66 | - private static $_espresso_themes = array(); |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
71 | - * |
|
72 | - * @return boolean |
|
73 | - */ |
|
74 | - public static function is_espresso_theme() |
|
75 | - { |
|
76 | - return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
81 | - * load it's functions.php file ( if not already loaded ) |
|
82 | - * |
|
83 | - * @return void |
|
84 | - */ |
|
85 | - public static function load_espresso_theme_functions() |
|
86 | - { |
|
87 | - if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
88 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
89 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
90 | - } |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
97 | - * |
|
98 | - * @return array |
|
99 | - */ |
|
100 | - public static function get_espresso_themes() |
|
101 | - { |
|
102 | - if (empty(EEH_Template::$_espresso_themes)) { |
|
103 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
104 | - if (empty($espresso_themes)) { |
|
105 | - return array(); |
|
106 | - } |
|
107 | - if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
108 | - unset($espresso_themes[$key]); |
|
109 | - } |
|
110 | - EEH_Template::$_espresso_themes = array(); |
|
111 | - foreach ($espresso_themes as $espresso_theme) { |
|
112 | - EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
113 | - } |
|
114 | - } |
|
115 | - return EEH_Template::$_espresso_themes; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * EEH_Template::get_template_part |
|
121 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
122 | - * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
123 | - * filtering based off of the entire template part name |
|
124 | - * |
|
125 | - * @param string $slug The slug name for the generic template. |
|
126 | - * @param string $name The name of the specialised template. |
|
127 | - * @param array $template_args |
|
128 | - * @param bool $return_string |
|
129 | - * @return string the html output for the formatted money value |
|
130 | - */ |
|
131 | - public static function get_template_part( |
|
132 | - $slug = null, |
|
133 | - $name = null, |
|
134 | - $template_args = array(), |
|
135 | - $return_string = false |
|
136 | - ) { |
|
137 | - do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
138 | - $templates = array(); |
|
139 | - $name = (string)$name; |
|
140 | - if ($name != '') { |
|
141 | - $templates[] = "{$slug}-{$name}.php"; |
|
142 | - } |
|
143 | - // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
144 | - if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
145 | - EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
146 | - } |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * locate_template |
|
152 | - * locate a template file by looking in the following places, in the following order: |
|
153 | - * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
154 | - * <assumed full absolute server path> |
|
155 | - * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
156 | - * <server path up to>/wp-content/uploads/espresso/templates/ |
|
157 | - * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
158 | - * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
159 | - * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
160 | - * as soon as the template is found in one of these locations, it will be returned or loaded |
|
161 | - * Example: |
|
162 | - * You are using the WordPress Twenty Sixteen theme, |
|
163 | - * and you want to customize the "some-event.template.php" template, |
|
164 | - * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
165 | - * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
166 | - * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
167 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
168 | - * /relative/path/to/some-event.template.php |
|
169 | - * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
170 | - * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
171 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
172 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
173 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
174 | - * Had you passed an absolute path to your template that was in some other location, |
|
175 | - * ie: "/absolute/path/to/some-event.template.php" |
|
176 | - * then the search would have been : |
|
177 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
178 | - * /absolute/path/to/some-event.template.php |
|
179 | - * and stopped there upon finding it in the second location |
|
180 | - * |
|
181 | - * @param array|string $templates array of template file names including extension (or just a single string) |
|
182 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
183 | - * @param boolean $load whether to pass the located template path on to the |
|
184 | - * EEH_Template::display_template() method or simply return it |
|
185 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
186 | - * string |
|
187 | - * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
188 | - * generate a custom template or not. Used in places where you don't actually |
|
189 | - * load the template, you just want to know if there's a custom version of it. |
|
190 | - * @return mixed |
|
191 | - */ |
|
192 | - public static function locate_template( |
|
193 | - $templates = array(), |
|
194 | - $template_args = array(), |
|
195 | - $load = true, |
|
196 | - $return_string = true, |
|
197 | - $check_if_custom = false |
|
198 | - ) { |
|
199 | - // first use WP locate_template to check for template in the current theme folder |
|
200 | - $template_path = locate_template($templates); |
|
201 | - |
|
202 | - if ($check_if_custom && ! empty($template_path)) { |
|
203 | - return true; |
|
204 | - } |
|
205 | - |
|
206 | - // not in the theme |
|
207 | - if (empty($template_path)) { |
|
208 | - // not even a template to look for ? |
|
209 | - if (empty($templates)) { |
|
210 | - // get post_type |
|
211 | - $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
212 | - // get array of EE Custom Post Types |
|
213 | - $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
|
214 | - // build template name based on request |
|
215 | - if (isset($EE_CPTs[$post_type])) { |
|
216 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
217 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
218 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
219 | - } |
|
220 | - } |
|
221 | - // currently active EE template theme |
|
222 | - $current_theme = EE_Config::get_current_theme(); |
|
223 | - |
|
224 | - // array of paths to folders that may contain templates |
|
225 | - $template_folder_paths = array( |
|
226 | - // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
227 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
228 | - // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
229 | - EVENT_ESPRESSO_TEMPLATE_DIR, |
|
230 | - ); |
|
231 | - |
|
232 | - //add core plugin folders for checking only if we're not $check_if_custom |
|
233 | - if ( ! $check_if_custom) { |
|
234 | - $core_paths = array( |
|
235 | - // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
236 | - EE_PUBLIC . $current_theme, |
|
237 | - // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
238 | - EE_TEMPLATES . $current_theme, |
|
239 | - // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
240 | - EE_PLUGIN_DIR_PATH, |
|
241 | - ); |
|
242 | - $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
243 | - } |
|
244 | - |
|
245 | - // now filter that array |
|
246 | - $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
247 | - $template_folder_paths); |
|
248 | - $templates = is_array($templates) ? $templates : array($templates); |
|
249 | - $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
250 | - // array to hold all possible template paths |
|
251 | - $full_template_paths = array(); |
|
252 | - |
|
253 | - // loop through $templates |
|
254 | - foreach ($templates as $template) { |
|
255 | - // normalize directory separators |
|
256 | - $template = EEH_File::standardise_directory_separators($template); |
|
257 | - $file_name = basename($template); |
|
258 | - $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
259 | - // while looping through all template folder paths |
|
260 | - foreach ($template_folder_paths as $template_folder_path) { |
|
261 | - // normalize directory separators |
|
262 | - $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
263 | - // determine if any common base path exists between the two paths |
|
264 | - $common_base_path = EEH_Template::_find_common_base_path( |
|
265 | - array($template_folder_path, $template_path_minus_file_name) |
|
266 | - ); |
|
267 | - if ($common_base_path !== '') { |
|
268 | - // both paths have a common base, so just tack the filename onto our search path |
|
269 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
270 | - } else { |
|
271 | - // no common base path, so let's just concatenate |
|
272 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
273 | - } |
|
274 | - // build up our template locations array by adding our resolved paths |
|
275 | - $full_template_paths[] = $resolved_path; |
|
276 | - } |
|
277 | - // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
278 | - array_unshift($full_template_paths, $template); |
|
279 | - // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
280 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
281 | - } |
|
282 | - // filter final array of full template paths |
|
283 | - $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
284 | - $full_template_paths, $file_name); |
|
285 | - // now loop through our final array of template location paths and check each location |
|
286 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
287 | - if (is_readable($full_template_path)) { |
|
288 | - $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
289 | - break; |
|
290 | - } |
|
291 | - } |
|
292 | - } |
|
293 | - |
|
294 | - // hook that can be used to display the full template path that will be used |
|
295 | - do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
296 | - |
|
297 | - // if we got it and you want to see it... |
|
298 | - if ($template_path && $load && ! $check_if_custom) { |
|
299 | - if ($return_string) { |
|
300 | - return EEH_Template::display_template($template_path, $template_args, true); |
|
301 | - } else { |
|
302 | - EEH_Template::display_template($template_path, $template_args, false); |
|
303 | - } |
|
304 | - } |
|
305 | - return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * _find_common_base_path |
|
311 | - * given two paths, this determines if there is a common base path between the two |
|
312 | - * |
|
313 | - * @param array $paths |
|
314 | - * @return string |
|
315 | - */ |
|
316 | - protected static function _find_common_base_path($paths) |
|
317 | - { |
|
318 | - $last_offset = 0; |
|
319 | - $common_base_path = ''; |
|
320 | - while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
321 | - $dir_length = $index - $last_offset + 1; |
|
322 | - $directory = substr($paths[0], $last_offset, $dir_length); |
|
323 | - foreach ($paths as $path) { |
|
324 | - if (substr($path, $last_offset, $dir_length) != $directory) { |
|
325 | - return $common_base_path; |
|
326 | - } |
|
327 | - } |
|
328 | - $common_base_path .= $directory; |
|
329 | - $last_offset = $index + 1; |
|
330 | - } |
|
331 | - return substr($common_base_path, 0, -1); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * load and display a template |
|
337 | - * |
|
338 | - * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
339 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
340 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
341 | - * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
|
342 | - * not found or is not readable |
|
343 | - * @return mixed string |
|
344 | - * @throws \DomainException |
|
345 | - */ |
|
66 | + private static $_espresso_themes = array(); |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
71 | + * |
|
72 | + * @return boolean |
|
73 | + */ |
|
74 | + public static function is_espresso_theme() |
|
75 | + { |
|
76 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
81 | + * load it's functions.php file ( if not already loaded ) |
|
82 | + * |
|
83 | + * @return void |
|
84 | + */ |
|
85 | + public static function load_espresso_theme_functions() |
|
86 | + { |
|
87 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
88 | + if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
89 | + require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
90 | + } |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
97 | + * |
|
98 | + * @return array |
|
99 | + */ |
|
100 | + public static function get_espresso_themes() |
|
101 | + { |
|
102 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
103 | + $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
104 | + if (empty($espresso_themes)) { |
|
105 | + return array(); |
|
106 | + } |
|
107 | + if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
108 | + unset($espresso_themes[$key]); |
|
109 | + } |
|
110 | + EEH_Template::$_espresso_themes = array(); |
|
111 | + foreach ($espresso_themes as $espresso_theme) { |
|
112 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
113 | + } |
|
114 | + } |
|
115 | + return EEH_Template::$_espresso_themes; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * EEH_Template::get_template_part |
|
121 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
122 | + * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
123 | + * filtering based off of the entire template part name |
|
124 | + * |
|
125 | + * @param string $slug The slug name for the generic template. |
|
126 | + * @param string $name The name of the specialised template. |
|
127 | + * @param array $template_args |
|
128 | + * @param bool $return_string |
|
129 | + * @return string the html output for the formatted money value |
|
130 | + */ |
|
131 | + public static function get_template_part( |
|
132 | + $slug = null, |
|
133 | + $name = null, |
|
134 | + $template_args = array(), |
|
135 | + $return_string = false |
|
136 | + ) { |
|
137 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
138 | + $templates = array(); |
|
139 | + $name = (string)$name; |
|
140 | + if ($name != '') { |
|
141 | + $templates[] = "{$slug}-{$name}.php"; |
|
142 | + } |
|
143 | + // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
144 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
145 | + EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
146 | + } |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * locate_template |
|
152 | + * locate a template file by looking in the following places, in the following order: |
|
153 | + * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
154 | + * <assumed full absolute server path> |
|
155 | + * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
156 | + * <server path up to>/wp-content/uploads/espresso/templates/ |
|
157 | + * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
158 | + * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
159 | + * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
160 | + * as soon as the template is found in one of these locations, it will be returned or loaded |
|
161 | + * Example: |
|
162 | + * You are using the WordPress Twenty Sixteen theme, |
|
163 | + * and you want to customize the "some-event.template.php" template, |
|
164 | + * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
165 | + * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
166 | + * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
167 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
168 | + * /relative/path/to/some-event.template.php |
|
169 | + * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
170 | + * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
171 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
172 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
173 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
174 | + * Had you passed an absolute path to your template that was in some other location, |
|
175 | + * ie: "/absolute/path/to/some-event.template.php" |
|
176 | + * then the search would have been : |
|
177 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
178 | + * /absolute/path/to/some-event.template.php |
|
179 | + * and stopped there upon finding it in the second location |
|
180 | + * |
|
181 | + * @param array|string $templates array of template file names including extension (or just a single string) |
|
182 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
183 | + * @param boolean $load whether to pass the located template path on to the |
|
184 | + * EEH_Template::display_template() method or simply return it |
|
185 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
186 | + * string |
|
187 | + * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
188 | + * generate a custom template or not. Used in places where you don't actually |
|
189 | + * load the template, you just want to know if there's a custom version of it. |
|
190 | + * @return mixed |
|
191 | + */ |
|
192 | + public static function locate_template( |
|
193 | + $templates = array(), |
|
194 | + $template_args = array(), |
|
195 | + $load = true, |
|
196 | + $return_string = true, |
|
197 | + $check_if_custom = false |
|
198 | + ) { |
|
199 | + // first use WP locate_template to check for template in the current theme folder |
|
200 | + $template_path = locate_template($templates); |
|
201 | + |
|
202 | + if ($check_if_custom && ! empty($template_path)) { |
|
203 | + return true; |
|
204 | + } |
|
205 | + |
|
206 | + // not in the theme |
|
207 | + if (empty($template_path)) { |
|
208 | + // not even a template to look for ? |
|
209 | + if (empty($templates)) { |
|
210 | + // get post_type |
|
211 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
212 | + // get array of EE Custom Post Types |
|
213 | + $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
|
214 | + // build template name based on request |
|
215 | + if (isset($EE_CPTs[$post_type])) { |
|
216 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
217 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
218 | + $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
219 | + } |
|
220 | + } |
|
221 | + // currently active EE template theme |
|
222 | + $current_theme = EE_Config::get_current_theme(); |
|
223 | + |
|
224 | + // array of paths to folders that may contain templates |
|
225 | + $template_folder_paths = array( |
|
226 | + // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
227 | + EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
228 | + // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
229 | + EVENT_ESPRESSO_TEMPLATE_DIR, |
|
230 | + ); |
|
231 | + |
|
232 | + //add core plugin folders for checking only if we're not $check_if_custom |
|
233 | + if ( ! $check_if_custom) { |
|
234 | + $core_paths = array( |
|
235 | + // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
236 | + EE_PUBLIC . $current_theme, |
|
237 | + // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
238 | + EE_TEMPLATES . $current_theme, |
|
239 | + // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
240 | + EE_PLUGIN_DIR_PATH, |
|
241 | + ); |
|
242 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
243 | + } |
|
244 | + |
|
245 | + // now filter that array |
|
246 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
247 | + $template_folder_paths); |
|
248 | + $templates = is_array($templates) ? $templates : array($templates); |
|
249 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
250 | + // array to hold all possible template paths |
|
251 | + $full_template_paths = array(); |
|
252 | + |
|
253 | + // loop through $templates |
|
254 | + foreach ($templates as $template) { |
|
255 | + // normalize directory separators |
|
256 | + $template = EEH_File::standardise_directory_separators($template); |
|
257 | + $file_name = basename($template); |
|
258 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
259 | + // while looping through all template folder paths |
|
260 | + foreach ($template_folder_paths as $template_folder_path) { |
|
261 | + // normalize directory separators |
|
262 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
263 | + // determine if any common base path exists between the two paths |
|
264 | + $common_base_path = EEH_Template::_find_common_base_path( |
|
265 | + array($template_folder_path, $template_path_minus_file_name) |
|
266 | + ); |
|
267 | + if ($common_base_path !== '') { |
|
268 | + // both paths have a common base, so just tack the filename onto our search path |
|
269 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
270 | + } else { |
|
271 | + // no common base path, so let's just concatenate |
|
272 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
273 | + } |
|
274 | + // build up our template locations array by adding our resolved paths |
|
275 | + $full_template_paths[] = $resolved_path; |
|
276 | + } |
|
277 | + // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
278 | + array_unshift($full_template_paths, $template); |
|
279 | + // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
280 | + array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
281 | + } |
|
282 | + // filter final array of full template paths |
|
283 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
284 | + $full_template_paths, $file_name); |
|
285 | + // now loop through our final array of template location paths and check each location |
|
286 | + foreach ((array)$full_template_paths as $full_template_path) { |
|
287 | + if (is_readable($full_template_path)) { |
|
288 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
289 | + break; |
|
290 | + } |
|
291 | + } |
|
292 | + } |
|
293 | + |
|
294 | + // hook that can be used to display the full template path that will be used |
|
295 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
296 | + |
|
297 | + // if we got it and you want to see it... |
|
298 | + if ($template_path && $load && ! $check_if_custom) { |
|
299 | + if ($return_string) { |
|
300 | + return EEH_Template::display_template($template_path, $template_args, true); |
|
301 | + } else { |
|
302 | + EEH_Template::display_template($template_path, $template_args, false); |
|
303 | + } |
|
304 | + } |
|
305 | + return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * _find_common_base_path |
|
311 | + * given two paths, this determines if there is a common base path between the two |
|
312 | + * |
|
313 | + * @param array $paths |
|
314 | + * @return string |
|
315 | + */ |
|
316 | + protected static function _find_common_base_path($paths) |
|
317 | + { |
|
318 | + $last_offset = 0; |
|
319 | + $common_base_path = ''; |
|
320 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
321 | + $dir_length = $index - $last_offset + 1; |
|
322 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
323 | + foreach ($paths as $path) { |
|
324 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
325 | + return $common_base_path; |
|
326 | + } |
|
327 | + } |
|
328 | + $common_base_path .= $directory; |
|
329 | + $last_offset = $index + 1; |
|
330 | + } |
|
331 | + return substr($common_base_path, 0, -1); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * load and display a template |
|
337 | + * |
|
338 | + * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
339 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
340 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
341 | + * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
|
342 | + * not found or is not readable |
|
343 | + * @return mixed string |
|
344 | + * @throws \DomainException |
|
345 | + */ |
|
346 | 346 | public static function display_template( |
347 | - $template_path = false, |
|
348 | - $template_args = array(), |
|
349 | - $return_string = false, |
|
350 | - $throw_exceptions = false |
|
351 | - ) { |
|
352 | - |
|
353 | - /** |
|
354 | - * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
355 | - * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
356 | - * the display_template method are templates we DON'T want modified (usually because of js |
|
357 | - * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
358 | - * using this. |
|
359 | - * |
|
360 | - * @since 4.6.0 |
|
361 | - */ |
|
362 | - $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
363 | - $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
364 | - |
|
365 | - // you gimme nuttin - YOU GET NUTTIN !! |
|
366 | - if ( ! $template_path || ! is_readable($template_path)) { |
|
367 | - return ''; |
|
368 | - } |
|
369 | - // if $template_args are not in an array, then make it so |
|
370 | - if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
371 | - $template_args = array($template_args); |
|
372 | - } |
|
373 | - extract( $template_args, EXTR_SKIP ); |
|
374 | - // ignore whether template is accessible ? |
|
375 | - if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
376 | - throw new \DomainException( |
|
377 | - esc_html__( |
|
378 | - 'Invalid, unreadable, or missing file.', |
|
379 | - 'event_espresso' |
|
380 | - ) |
|
381 | - ); |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - if ($return_string) { |
|
386 | - // because we want to return a string, we are going to capture the output |
|
387 | - ob_start(); |
|
388 | - include($template_path); |
|
389 | - return ob_get_clean(); |
|
390 | - } else { |
|
391 | - include($template_path); |
|
392 | - } |
|
393 | - return ''; |
|
394 | - } |
|
395 | - |
|
396 | - |
|
397 | - /** |
|
398 | - * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
399 | - * |
|
400 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
401 | - * @param string $prefix added to the beginning of the generated class |
|
402 | - * @param string $suffix added to the end of the generated class |
|
403 | - * @return string |
|
404 | - */ |
|
405 | - public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
406 | - { |
|
407 | - // in the beginning... |
|
408 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
409 | - // da muddle |
|
410 | - $class = ''; |
|
411 | - // the end |
|
412 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
413 | - // is the passed object an EE object ? |
|
414 | - if ($object instanceof EE_Base_Class) { |
|
415 | - // grab the exact type of object |
|
416 | - $obj_class = get_class($object); |
|
417 | - // depending on the type of object... |
|
418 | - switch ($obj_class) { |
|
419 | - // no specifics just yet... |
|
420 | - default : |
|
421 | - $class = strtolower(str_replace('_', '-', $obj_class)); |
|
422 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
423 | - |
|
424 | - } |
|
425 | - } |
|
426 | - return $prefix . $class . $suffix; |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - |
|
431 | - /** |
|
432 | - * EEH_Template::format_currency |
|
433 | - * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
434 | - * the country currency settings from the supplied country ISO code |
|
435 | - * |
|
436 | - * @deprecated $VID:$ |
|
437 | - * @param float $amount raw money value |
|
438 | - * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
439 | - * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
440 | - * @param string $CNT_ISO 2 letter ISO code for a country |
|
441 | - * @param string $cur_code_span_class |
|
442 | - * @return string the html output for the formatted money value |
|
443 | - * @throws EE_Error |
|
444 | - * @throws InvalidArgumentException |
|
445 | - * @throws ReflectionException |
|
446 | - * @throws InvalidDataTypeException |
|
447 | - * @throws InvalidInterfaceException |
|
448 | - */ |
|
449 | - public static function format_currency( |
|
450 | - $amount = null, |
|
451 | - $return_raw = false, |
|
452 | - $display_code = true, |
|
453 | - $CNT_ISO = '', |
|
454 | - $cur_code_span_class = 'currency-code' |
|
455 | - ) { |
|
456 | - return EEH_Money::format_currency( |
|
457 | - $amount, |
|
458 | - $return_raw, |
|
459 | - $display_code, |
|
460 | - $CNT_ISO, |
|
461 | - $cur_code_span_class |
|
462 | - ); |
|
463 | - } |
|
464 | - |
|
465 | - |
|
466 | - /** |
|
467 | - * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
468 | - * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
469 | - * related status model or model object (i.e. in documentation etc.) |
|
470 | - * |
|
471 | - * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
472 | - * match, then 'Unknown' will be returned. |
|
473 | - * @param boolean $plural Whether to return plural or not |
|
474 | - * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
475 | - * @return string The localized label for the status id. |
|
476 | - */ |
|
477 | - public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
478 | - { |
|
479 | - /** @type EEM_Status $EEM_Status */ |
|
480 | - $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
481 | - $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
482 | - $schema); |
|
483 | - return $status[$status_id]; |
|
484 | - } |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
488 | - * This helper just returns a button or link for the given parameters |
|
489 | - * |
|
490 | - * @param string $url the url for the link, note that `esc_url` will be called on it |
|
491 | - * @param string $label What is the label you want displayed for the button |
|
492 | - * @param string $class what class is used for the button (defaults to 'button-primary') |
|
493 | - * @param string $icon |
|
494 | - * @param string $title |
|
495 | - * @return string the html output for the button |
|
496 | - */ |
|
497 | - public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
498 | - { |
|
499 | - $icon_html = ''; |
|
500 | - if ( ! empty($icon)) { |
|
501 | - $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
502 | - $dashicons = array_filter($dashicons); |
|
503 | - $count = count($dashicons); |
|
504 | - $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
505 | - foreach ($dashicons as $dashicon) { |
|
506 | - $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
507 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
508 | - } |
|
509 | - $icon_html .= $count > 1 ? '</span>' : ''; |
|
510 | - } |
|
511 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
512 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
513 | - return $button; |
|
514 | - } |
|
515 | - |
|
516 | - |
|
517 | - /** |
|
518 | - * This returns a generated link that will load the related help tab on admin pages. |
|
519 | - * |
|
520 | - * @param string $help_tab_id the id for the connected help tab |
|
521 | - * @param bool|string $page The page identifier for the page the help tab is on |
|
522 | - * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
523 | - * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
524 | - * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
525 | - * @return string generated link |
|
526 | - */ |
|
527 | - public static function get_help_tab_link( |
|
528 | - $help_tab_id, |
|
529 | - $page = false, |
|
530 | - $action = false, |
|
531 | - $icon_style = false, |
|
532 | - $help_text = false |
|
533 | - ) { |
|
534 | - |
|
535 | - if ( ! $page) { |
|
536 | - $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
537 | - } |
|
538 | - |
|
539 | - if ( ! $action) { |
|
540 | - $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
541 | - } |
|
542 | - |
|
543 | - $action = empty($action) ? 'default' : $action; |
|
544 | - |
|
545 | - |
|
546 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
547 | - $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
548 | - $help_text = ! $help_text ? '' : $help_text; |
|
549 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
550 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
551 | - } |
|
552 | - |
|
553 | - |
|
554 | - /** |
|
555 | - * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
556 | - * |
|
557 | - * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
558 | - * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
559 | - * @param EE_Help_Tour |
|
560 | - * @return string html |
|
561 | - */ |
|
562 | - public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
563 | - { |
|
564 | - $id = $tour->get_slug(); |
|
565 | - $stops = $tour->get_stops(); |
|
566 | - |
|
567 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
568 | - |
|
569 | - foreach ($stops as $stop) { |
|
570 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
571 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
572 | - |
|
573 | - //if container is set to modal then let's make sure we set the options accordingly |
|
574 | - if (empty($data_id) && empty($data_class)) { |
|
575 | - $stop['options']['modal'] = true; |
|
576 | - $stop['options']['expose'] = true; |
|
577 | - } |
|
578 | - |
|
579 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
580 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
581 | - $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
582 | - |
|
583 | - //options |
|
584 | - if (isset($stop['options']) && is_array($stop['options'])) { |
|
585 | - $options = ' data-options="'; |
|
586 | - foreach ($stop['options'] as $option => $value) { |
|
587 | - $options .= $option . ':' . $value . ';'; |
|
588 | - } |
|
589 | - $options .= '"'; |
|
590 | - } else { |
|
591 | - $options = ''; |
|
592 | - } |
|
593 | - |
|
594 | - //let's put all together |
|
595 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
596 | - } |
|
597 | - |
|
598 | - $content .= '</ol>'; |
|
599 | - return $content; |
|
600 | - } |
|
601 | - |
|
602 | - |
|
603 | - /** |
|
604 | - * This is a helper method to generate a status legend for a given status array. |
|
605 | - * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
606 | - * status_array. |
|
607 | - * |
|
608 | - * @param array $status_array array of statuses that will make up the legend. In format: |
|
609 | - * array( |
|
610 | - * 'status_item' => 'status_name' |
|
611 | - * ) |
|
612 | - * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
613 | - * the legend. |
|
614 | - * @throws EE_Error |
|
615 | - * @return string html structure for status. |
|
616 | - */ |
|
617 | - public static function status_legend($status_array, $active_status = '') |
|
618 | - { |
|
619 | - if ( ! is_array($status_array)) { |
|
620 | - throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
621 | - 'event_espresso')); |
|
622 | - } |
|
623 | - |
|
624 | - $setup_array = array(); |
|
625 | - foreach ($status_array as $item => $status) { |
|
626 | - $setup_array[$item] = array( |
|
627 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
628 | - 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
629 | - 'status' => $status, |
|
630 | - ); |
|
631 | - } |
|
632 | - |
|
633 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
634 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
635 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
636 | - foreach ($setup_array as $item => $details) { |
|
637 | - $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
638 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
639 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
640 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
641 | - $content .= '</dt>' . "\n"; |
|
642 | - } |
|
643 | - $content .= '</dl>' . "\n"; |
|
644 | - $content .= '</div>' . "\n"; |
|
645 | - return $content; |
|
646 | - } |
|
647 | - |
|
648 | - |
|
649 | - /** |
|
650 | - * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
651 | - * that's nice for presenting in the wp admin |
|
652 | - * |
|
653 | - * @param mixed $data |
|
654 | - * @return string |
|
655 | - */ |
|
656 | - public static function layout_array_as_table($data) |
|
657 | - { |
|
658 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
659 | - $data = (array)$data; |
|
660 | - } |
|
661 | - ob_start(); |
|
662 | - if (is_array($data)) { |
|
663 | - if (EEH_Array::is_associative_array($data)) { |
|
664 | - ?> |
|
347 | + $template_path = false, |
|
348 | + $template_args = array(), |
|
349 | + $return_string = false, |
|
350 | + $throw_exceptions = false |
|
351 | + ) { |
|
352 | + |
|
353 | + /** |
|
354 | + * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
355 | + * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
356 | + * the display_template method are templates we DON'T want modified (usually because of js |
|
357 | + * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
358 | + * using this. |
|
359 | + * |
|
360 | + * @since 4.6.0 |
|
361 | + */ |
|
362 | + $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
363 | + $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
364 | + |
|
365 | + // you gimme nuttin - YOU GET NUTTIN !! |
|
366 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
367 | + return ''; |
|
368 | + } |
|
369 | + // if $template_args are not in an array, then make it so |
|
370 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
371 | + $template_args = array($template_args); |
|
372 | + } |
|
373 | + extract( $template_args, EXTR_SKIP ); |
|
374 | + // ignore whether template is accessible ? |
|
375 | + if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
376 | + throw new \DomainException( |
|
377 | + esc_html__( |
|
378 | + 'Invalid, unreadable, or missing file.', |
|
379 | + 'event_espresso' |
|
380 | + ) |
|
381 | + ); |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + if ($return_string) { |
|
386 | + // because we want to return a string, we are going to capture the output |
|
387 | + ob_start(); |
|
388 | + include($template_path); |
|
389 | + return ob_get_clean(); |
|
390 | + } else { |
|
391 | + include($template_path); |
|
392 | + } |
|
393 | + return ''; |
|
394 | + } |
|
395 | + |
|
396 | + |
|
397 | + /** |
|
398 | + * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
399 | + * |
|
400 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
401 | + * @param string $prefix added to the beginning of the generated class |
|
402 | + * @param string $suffix added to the end of the generated class |
|
403 | + * @return string |
|
404 | + */ |
|
405 | + public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
406 | + { |
|
407 | + // in the beginning... |
|
408 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
409 | + // da muddle |
|
410 | + $class = ''; |
|
411 | + // the end |
|
412 | + $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
413 | + // is the passed object an EE object ? |
|
414 | + if ($object instanceof EE_Base_Class) { |
|
415 | + // grab the exact type of object |
|
416 | + $obj_class = get_class($object); |
|
417 | + // depending on the type of object... |
|
418 | + switch ($obj_class) { |
|
419 | + // no specifics just yet... |
|
420 | + default : |
|
421 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
422 | + $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
423 | + |
|
424 | + } |
|
425 | + } |
|
426 | + return $prefix . $class . $suffix; |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + |
|
431 | + /** |
|
432 | + * EEH_Template::format_currency |
|
433 | + * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
434 | + * the country currency settings from the supplied country ISO code |
|
435 | + * |
|
436 | + * @deprecated $VID:$ |
|
437 | + * @param float $amount raw money value |
|
438 | + * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
439 | + * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
440 | + * @param string $CNT_ISO 2 letter ISO code for a country |
|
441 | + * @param string $cur_code_span_class |
|
442 | + * @return string the html output for the formatted money value |
|
443 | + * @throws EE_Error |
|
444 | + * @throws InvalidArgumentException |
|
445 | + * @throws ReflectionException |
|
446 | + * @throws InvalidDataTypeException |
|
447 | + * @throws InvalidInterfaceException |
|
448 | + */ |
|
449 | + public static function format_currency( |
|
450 | + $amount = null, |
|
451 | + $return_raw = false, |
|
452 | + $display_code = true, |
|
453 | + $CNT_ISO = '', |
|
454 | + $cur_code_span_class = 'currency-code' |
|
455 | + ) { |
|
456 | + return EEH_Money::format_currency( |
|
457 | + $amount, |
|
458 | + $return_raw, |
|
459 | + $display_code, |
|
460 | + $CNT_ISO, |
|
461 | + $cur_code_span_class |
|
462 | + ); |
|
463 | + } |
|
464 | + |
|
465 | + |
|
466 | + /** |
|
467 | + * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
468 | + * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
469 | + * related status model or model object (i.e. in documentation etc.) |
|
470 | + * |
|
471 | + * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
472 | + * match, then 'Unknown' will be returned. |
|
473 | + * @param boolean $plural Whether to return plural or not |
|
474 | + * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
475 | + * @return string The localized label for the status id. |
|
476 | + */ |
|
477 | + public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
478 | + { |
|
479 | + /** @type EEM_Status $EEM_Status */ |
|
480 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
481 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
482 | + $schema); |
|
483 | + return $status[$status_id]; |
|
484 | + } |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | + * This helper just returns a button or link for the given parameters |
|
489 | + * |
|
490 | + * @param string $url the url for the link, note that `esc_url` will be called on it |
|
491 | + * @param string $label What is the label you want displayed for the button |
|
492 | + * @param string $class what class is used for the button (defaults to 'button-primary') |
|
493 | + * @param string $icon |
|
494 | + * @param string $title |
|
495 | + * @return string the html output for the button |
|
496 | + */ |
|
497 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
498 | + { |
|
499 | + $icon_html = ''; |
|
500 | + if ( ! empty($icon)) { |
|
501 | + $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
502 | + $dashicons = array_filter($dashicons); |
|
503 | + $count = count($dashicons); |
|
504 | + $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
505 | + foreach ($dashicons as $dashicon) { |
|
506 | + $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
507 | + $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
508 | + } |
|
509 | + $icon_html .= $count > 1 ? '</span>' : ''; |
|
510 | + } |
|
511 | + $label = ! empty($icon) ? $icon_html . $label : $label; |
|
512 | + $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
513 | + return $button; |
|
514 | + } |
|
515 | + |
|
516 | + |
|
517 | + /** |
|
518 | + * This returns a generated link that will load the related help tab on admin pages. |
|
519 | + * |
|
520 | + * @param string $help_tab_id the id for the connected help tab |
|
521 | + * @param bool|string $page The page identifier for the page the help tab is on |
|
522 | + * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
523 | + * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
524 | + * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
525 | + * @return string generated link |
|
526 | + */ |
|
527 | + public static function get_help_tab_link( |
|
528 | + $help_tab_id, |
|
529 | + $page = false, |
|
530 | + $action = false, |
|
531 | + $icon_style = false, |
|
532 | + $help_text = false |
|
533 | + ) { |
|
534 | + |
|
535 | + if ( ! $page) { |
|
536 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
537 | + } |
|
538 | + |
|
539 | + if ( ! $action) { |
|
540 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
541 | + } |
|
542 | + |
|
543 | + $action = empty($action) ? 'default' : $action; |
|
544 | + |
|
545 | + |
|
546 | + $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
547 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
548 | + $help_text = ! $help_text ? '' : $help_text; |
|
549 | + return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
550 | + 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
551 | + } |
|
552 | + |
|
553 | + |
|
554 | + /** |
|
555 | + * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
556 | + * |
|
557 | + * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
558 | + * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
559 | + * @param EE_Help_Tour |
|
560 | + * @return string html |
|
561 | + */ |
|
562 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
563 | + { |
|
564 | + $id = $tour->get_slug(); |
|
565 | + $stops = $tour->get_stops(); |
|
566 | + |
|
567 | + $content = '<ol style="display:none" id="' . $id . '">'; |
|
568 | + |
|
569 | + foreach ($stops as $stop) { |
|
570 | + $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
571 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
572 | + |
|
573 | + //if container is set to modal then let's make sure we set the options accordingly |
|
574 | + if (empty($data_id) && empty($data_class)) { |
|
575 | + $stop['options']['modal'] = true; |
|
576 | + $stop['options']['expose'] = true; |
|
577 | + } |
|
578 | + |
|
579 | + $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
580 | + $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
581 | + $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
582 | + |
|
583 | + //options |
|
584 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
585 | + $options = ' data-options="'; |
|
586 | + foreach ($stop['options'] as $option => $value) { |
|
587 | + $options .= $option . ':' . $value . ';'; |
|
588 | + } |
|
589 | + $options .= '"'; |
|
590 | + } else { |
|
591 | + $options = ''; |
|
592 | + } |
|
593 | + |
|
594 | + //let's put all together |
|
595 | + $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
596 | + } |
|
597 | + |
|
598 | + $content .= '</ol>'; |
|
599 | + return $content; |
|
600 | + } |
|
601 | + |
|
602 | + |
|
603 | + /** |
|
604 | + * This is a helper method to generate a status legend for a given status array. |
|
605 | + * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
606 | + * status_array. |
|
607 | + * |
|
608 | + * @param array $status_array array of statuses that will make up the legend. In format: |
|
609 | + * array( |
|
610 | + * 'status_item' => 'status_name' |
|
611 | + * ) |
|
612 | + * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
613 | + * the legend. |
|
614 | + * @throws EE_Error |
|
615 | + * @return string html structure for status. |
|
616 | + */ |
|
617 | + public static function status_legend($status_array, $active_status = '') |
|
618 | + { |
|
619 | + if ( ! is_array($status_array)) { |
|
620 | + throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
621 | + 'event_espresso')); |
|
622 | + } |
|
623 | + |
|
624 | + $setup_array = array(); |
|
625 | + foreach ($status_array as $item => $status) { |
|
626 | + $setup_array[$item] = array( |
|
627 | + 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
628 | + 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
629 | + 'status' => $status, |
|
630 | + ); |
|
631 | + } |
|
632 | + |
|
633 | + $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
634 | + $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
635 | + $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
636 | + foreach ($setup_array as $item => $details) { |
|
637 | + $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
638 | + $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
639 | + $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
640 | + $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
641 | + $content .= '</dt>' . "\n"; |
|
642 | + } |
|
643 | + $content .= '</dl>' . "\n"; |
|
644 | + $content .= '</div>' . "\n"; |
|
645 | + return $content; |
|
646 | + } |
|
647 | + |
|
648 | + |
|
649 | + /** |
|
650 | + * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
651 | + * that's nice for presenting in the wp admin |
|
652 | + * |
|
653 | + * @param mixed $data |
|
654 | + * @return string |
|
655 | + */ |
|
656 | + public static function layout_array_as_table($data) |
|
657 | + { |
|
658 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
659 | + $data = (array)$data; |
|
660 | + } |
|
661 | + ob_start(); |
|
662 | + if (is_array($data)) { |
|
663 | + if (EEH_Array::is_associative_array($data)) { |
|
664 | + ?> |
|
665 | 665 | <table class="widefat"> |
666 | 666 | <tbody> |
667 | 667 | <?php |
668 | - foreach ($data as $data_key => $data_values) { |
|
669 | - ?> |
|
668 | + foreach ($data as $data_key => $data_values) { |
|
669 | + ?> |
|
670 | 670 | <tr> |
671 | 671 | <td> |
672 | 672 | <?php echo $data_key; ?> |
@@ -676,248 +676,248 @@ discard block |
||
676 | 676 | </td> |
677 | 677 | </tr> |
678 | 678 | <?php |
679 | - } ?> |
|
679 | + } ?> |
|
680 | 680 | </tbody> |
681 | 681 | </table> |
682 | 682 | <?php |
683 | - } else { |
|
684 | - ?> |
|
683 | + } else { |
|
684 | + ?> |
|
685 | 685 | <ul> |
686 | 686 | <?php |
687 | - foreach ($data as $datum) { |
|
688 | - echo "<li>"; |
|
689 | - echo self::layout_array_as_table($datum); |
|
690 | - echo "</li>"; |
|
691 | - } ?> |
|
687 | + foreach ($data as $datum) { |
|
688 | + echo "<li>"; |
|
689 | + echo self::layout_array_as_table($datum); |
|
690 | + echo "</li>"; |
|
691 | + } ?> |
|
692 | 692 | </ul> |
693 | 693 | <?php |
694 | - } |
|
695 | - } else { |
|
696 | - //simple value |
|
697 | - echo esc_html($data); |
|
698 | - } |
|
699 | - return ob_get_clean(); |
|
700 | - } |
|
701 | - |
|
702 | - |
|
703 | - /** |
|
704 | - * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
705 | - * |
|
706 | - * @since 4.4.0 |
|
707 | - * @see self:get_paging_html() for argument docs. |
|
708 | - * @param $total_items |
|
709 | - * @param $current |
|
710 | - * @param $per_page |
|
711 | - * @param $url |
|
712 | - * @param bool $show_num_field |
|
713 | - * @param string $paged_arg_name |
|
714 | - * @param array $items_label |
|
715 | - * @return string |
|
716 | - */ |
|
717 | - public static function paging_html( |
|
718 | - $total_items, |
|
719 | - $current, |
|
720 | - $per_page, |
|
721 | - $url, |
|
722 | - $show_num_field = true, |
|
723 | - $paged_arg_name = 'paged', |
|
724 | - $items_label = array() |
|
725 | - ) { |
|
726 | - echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
727 | - $items_label); |
|
728 | - } |
|
729 | - |
|
730 | - |
|
731 | - /** |
|
732 | - * A method for generating paging similar to WP_List_Table |
|
733 | - * |
|
734 | - * @since 4.4.0 |
|
735 | - * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
736 | - * @param integer $total_items How many total items there are to page. |
|
737 | - * @param integer $current What the current page is. |
|
738 | - * @param integer $per_page How many items per page. |
|
739 | - * @param string $url What the base url for page links is. |
|
740 | - * @param boolean $show_num_field Whether to show the input for changing page number. |
|
741 | - * @param string $paged_arg_name The name of the key for the paged query argument. |
|
742 | - * @param array $items_label An array of singular/plural values for the items label: |
|
743 | - * array( |
|
744 | - * 'single' => 'item', |
|
745 | - * 'plural' => 'items' |
|
746 | - * ) |
|
747 | - * @return string |
|
748 | - */ |
|
749 | - public static function get_paging_html( |
|
750 | - $total_items, |
|
751 | - $current, |
|
752 | - $per_page, |
|
753 | - $url, |
|
754 | - $show_num_field = true, |
|
755 | - $paged_arg_name = 'paged', |
|
756 | - $items_label = array() |
|
757 | - ) { |
|
758 | - $page_links = array(); |
|
759 | - $disable_first = $disable_last = ''; |
|
760 | - $total_items = (int)$total_items; |
|
761 | - $per_page = (int)$per_page; |
|
762 | - $current = (int)$current; |
|
763 | - $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
764 | - |
|
765 | - //filter items_label |
|
766 | - $items_label = apply_filters( |
|
767 | - 'FHEE__EEH_Template__get_paging_html__items_label', |
|
768 | - $items_label |
|
769 | - ); |
|
770 | - |
|
771 | - if (empty($items_label) |
|
772 | - || ! is_array($items_label) |
|
773 | - || ! isset($items_label['single']) |
|
774 | - || ! isset($items_label['plural']) |
|
775 | - ) { |
|
776 | - $items_label = array( |
|
777 | - 'single' => __('1 item', 'event_espresso'), |
|
778 | - 'plural' => __('%s items', 'event_espresso'), |
|
779 | - ); |
|
780 | - } else { |
|
781 | - $items_label = array( |
|
782 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
783 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
784 | - ); |
|
785 | - } |
|
786 | - |
|
787 | - $total_pages = ceil($total_items / $per_page); |
|
788 | - |
|
789 | - if ($total_pages <= 1) { |
|
790 | - return ''; |
|
791 | - } |
|
792 | - |
|
793 | - $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
794 | - |
|
795 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
796 | - |
|
797 | - if ($current === 1) { |
|
798 | - $disable_first = ' disabled'; |
|
799 | - } |
|
800 | - if ($current == $total_pages) { |
|
801 | - $disable_last = ' disabled'; |
|
802 | - } |
|
803 | - |
|
804 | - $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
805 | - 'first-page' . $disable_first, |
|
806 | - esc_attr__('Go to the first page'), |
|
807 | - esc_url(remove_query_arg($paged_arg_name, $url)), |
|
808 | - '«' |
|
809 | - ); |
|
810 | - |
|
811 | - $page_links[] = sprintf( |
|
812 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
813 | - 'prev-page' . $disable_first, |
|
814 | - esc_attr__('Go to the previous page'), |
|
815 | - esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
816 | - '‹' |
|
817 | - ); |
|
818 | - |
|
819 | - if ( ! $show_num_field) { |
|
820 | - $html_current_page = $current; |
|
821 | - } else { |
|
822 | - $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
823 | - esc_attr__('Current page'), |
|
824 | - $current, |
|
825 | - strlen($total_pages) |
|
826 | - ); |
|
827 | - } |
|
828 | - |
|
829 | - $html_total_pages = sprintf( |
|
830 | - '<span class="total-pages">%s</span>', |
|
831 | - number_format_i18n($total_pages) |
|
832 | - ); |
|
833 | - $page_links[] = sprintf( |
|
834 | - _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
835 | - $html_current_page, |
|
836 | - $html_total_pages, |
|
837 | - '<span class="paging-input">', |
|
838 | - '</span>' |
|
839 | - ); |
|
840 | - |
|
841 | - $page_links[] = sprintf( |
|
842 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
843 | - 'next-page' . $disable_last, |
|
844 | - esc_attr__('Go to the next page'), |
|
845 | - esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
846 | - '›' |
|
847 | - ); |
|
848 | - |
|
849 | - $page_links[] = sprintf( |
|
850 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
851 | - 'last-page' . $disable_last, |
|
852 | - esc_attr__('Go to the last page'), |
|
853 | - esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
854 | - '»' |
|
855 | - ); |
|
856 | - |
|
857 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
858 | - // set page class |
|
859 | - if ($total_pages) { |
|
860 | - $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
861 | - } else { |
|
862 | - $page_class = ' no-pages'; |
|
863 | - } |
|
864 | - |
|
865 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
866 | - } |
|
867 | - |
|
868 | - |
|
869 | - /** |
|
870 | - * @param string $wrap_class |
|
871 | - * @param string $wrap_id |
|
872 | - * @return string |
|
873 | - */ |
|
874 | - public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
875 | - { |
|
876 | - $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
877 | - if ( |
|
878 | - ! $admin && |
|
879 | - ! apply_filters( |
|
880 | - 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
881 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
882 | - ) |
|
883 | - ) { |
|
884 | - return ''; |
|
885 | - } |
|
886 | - $tag = $admin ? 'span' : 'div'; |
|
887 | - $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
888 | - $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
889 | - $attributes .= ! empty($wrap_class) |
|
890 | - ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
891 | - : ' class="powered-by-event-espresso-credit"'; |
|
892 | - $query_args = array_merge( |
|
893 | - array( |
|
894 | - 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
895 | - 'utm_source' => 'powered_by_event_espresso', |
|
896 | - 'utm_medium' => 'link', |
|
897 | - 'utm_campaign' => 'powered_by', |
|
898 | - ), |
|
899 | - $query_args |
|
900 | - ); |
|
901 | - $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
902 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
903 | - $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
904 | - $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
905 | - return (string)apply_filters( |
|
906 | - 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
907 | - sprintf( |
|
908 | - esc_html_x( |
|
909 | - '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s', |
|
910 | - 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
911 | - 'event_espresso' |
|
912 | - ), |
|
913 | - "<{$tag}{$attributes}>", |
|
914 | - "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>", |
|
915 | - $admin ? '' : '<br />' |
|
916 | - ), |
|
917 | - $wrap_class, |
|
918 | - $wrap_id |
|
919 | - ); |
|
920 | - } |
|
694 | + } |
|
695 | + } else { |
|
696 | + //simple value |
|
697 | + echo esc_html($data); |
|
698 | + } |
|
699 | + return ob_get_clean(); |
|
700 | + } |
|
701 | + |
|
702 | + |
|
703 | + /** |
|
704 | + * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
705 | + * |
|
706 | + * @since 4.4.0 |
|
707 | + * @see self:get_paging_html() for argument docs. |
|
708 | + * @param $total_items |
|
709 | + * @param $current |
|
710 | + * @param $per_page |
|
711 | + * @param $url |
|
712 | + * @param bool $show_num_field |
|
713 | + * @param string $paged_arg_name |
|
714 | + * @param array $items_label |
|
715 | + * @return string |
|
716 | + */ |
|
717 | + public static function paging_html( |
|
718 | + $total_items, |
|
719 | + $current, |
|
720 | + $per_page, |
|
721 | + $url, |
|
722 | + $show_num_field = true, |
|
723 | + $paged_arg_name = 'paged', |
|
724 | + $items_label = array() |
|
725 | + ) { |
|
726 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
727 | + $items_label); |
|
728 | + } |
|
729 | + |
|
730 | + |
|
731 | + /** |
|
732 | + * A method for generating paging similar to WP_List_Table |
|
733 | + * |
|
734 | + * @since 4.4.0 |
|
735 | + * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
736 | + * @param integer $total_items How many total items there are to page. |
|
737 | + * @param integer $current What the current page is. |
|
738 | + * @param integer $per_page How many items per page. |
|
739 | + * @param string $url What the base url for page links is. |
|
740 | + * @param boolean $show_num_field Whether to show the input for changing page number. |
|
741 | + * @param string $paged_arg_name The name of the key for the paged query argument. |
|
742 | + * @param array $items_label An array of singular/plural values for the items label: |
|
743 | + * array( |
|
744 | + * 'single' => 'item', |
|
745 | + * 'plural' => 'items' |
|
746 | + * ) |
|
747 | + * @return string |
|
748 | + */ |
|
749 | + public static function get_paging_html( |
|
750 | + $total_items, |
|
751 | + $current, |
|
752 | + $per_page, |
|
753 | + $url, |
|
754 | + $show_num_field = true, |
|
755 | + $paged_arg_name = 'paged', |
|
756 | + $items_label = array() |
|
757 | + ) { |
|
758 | + $page_links = array(); |
|
759 | + $disable_first = $disable_last = ''; |
|
760 | + $total_items = (int)$total_items; |
|
761 | + $per_page = (int)$per_page; |
|
762 | + $current = (int)$current; |
|
763 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
764 | + |
|
765 | + //filter items_label |
|
766 | + $items_label = apply_filters( |
|
767 | + 'FHEE__EEH_Template__get_paging_html__items_label', |
|
768 | + $items_label |
|
769 | + ); |
|
770 | + |
|
771 | + if (empty($items_label) |
|
772 | + || ! is_array($items_label) |
|
773 | + || ! isset($items_label['single']) |
|
774 | + || ! isset($items_label['plural']) |
|
775 | + ) { |
|
776 | + $items_label = array( |
|
777 | + 'single' => __('1 item', 'event_espresso'), |
|
778 | + 'plural' => __('%s items', 'event_espresso'), |
|
779 | + ); |
|
780 | + } else { |
|
781 | + $items_label = array( |
|
782 | + 'single' => '1 ' . esc_html($items_label['single']), |
|
783 | + 'plural' => '%s ' . esc_html($items_label['plural']), |
|
784 | + ); |
|
785 | + } |
|
786 | + |
|
787 | + $total_pages = ceil($total_items / $per_page); |
|
788 | + |
|
789 | + if ($total_pages <= 1) { |
|
790 | + return ''; |
|
791 | + } |
|
792 | + |
|
793 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
794 | + |
|
795 | + $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
796 | + |
|
797 | + if ($current === 1) { |
|
798 | + $disable_first = ' disabled'; |
|
799 | + } |
|
800 | + if ($current == $total_pages) { |
|
801 | + $disable_last = ' disabled'; |
|
802 | + } |
|
803 | + |
|
804 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
805 | + 'first-page' . $disable_first, |
|
806 | + esc_attr__('Go to the first page'), |
|
807 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
808 | + '«' |
|
809 | + ); |
|
810 | + |
|
811 | + $page_links[] = sprintf( |
|
812 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
813 | + 'prev-page' . $disable_first, |
|
814 | + esc_attr__('Go to the previous page'), |
|
815 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
816 | + '‹' |
|
817 | + ); |
|
818 | + |
|
819 | + if ( ! $show_num_field) { |
|
820 | + $html_current_page = $current; |
|
821 | + } else { |
|
822 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
823 | + esc_attr__('Current page'), |
|
824 | + $current, |
|
825 | + strlen($total_pages) |
|
826 | + ); |
|
827 | + } |
|
828 | + |
|
829 | + $html_total_pages = sprintf( |
|
830 | + '<span class="total-pages">%s</span>', |
|
831 | + number_format_i18n($total_pages) |
|
832 | + ); |
|
833 | + $page_links[] = sprintf( |
|
834 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
835 | + $html_current_page, |
|
836 | + $html_total_pages, |
|
837 | + '<span class="paging-input">', |
|
838 | + '</span>' |
|
839 | + ); |
|
840 | + |
|
841 | + $page_links[] = sprintf( |
|
842 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
843 | + 'next-page' . $disable_last, |
|
844 | + esc_attr__('Go to the next page'), |
|
845 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
846 | + '›' |
|
847 | + ); |
|
848 | + |
|
849 | + $page_links[] = sprintf( |
|
850 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
851 | + 'last-page' . $disable_last, |
|
852 | + esc_attr__('Go to the last page'), |
|
853 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
854 | + '»' |
|
855 | + ); |
|
856 | + |
|
857 | + $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
858 | + // set page class |
|
859 | + if ($total_pages) { |
|
860 | + $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
861 | + } else { |
|
862 | + $page_class = ' no-pages'; |
|
863 | + } |
|
864 | + |
|
865 | + return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
866 | + } |
|
867 | + |
|
868 | + |
|
869 | + /** |
|
870 | + * @param string $wrap_class |
|
871 | + * @param string $wrap_id |
|
872 | + * @return string |
|
873 | + */ |
|
874 | + public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
875 | + { |
|
876 | + $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
877 | + if ( |
|
878 | + ! $admin && |
|
879 | + ! apply_filters( |
|
880 | + 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
881 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
882 | + ) |
|
883 | + ) { |
|
884 | + return ''; |
|
885 | + } |
|
886 | + $tag = $admin ? 'span' : 'div'; |
|
887 | + $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
888 | + $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
889 | + $attributes .= ! empty($wrap_class) |
|
890 | + ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
891 | + : ' class="powered-by-event-espresso-credit"'; |
|
892 | + $query_args = array_merge( |
|
893 | + array( |
|
894 | + 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
895 | + 'utm_source' => 'powered_by_event_espresso', |
|
896 | + 'utm_medium' => 'link', |
|
897 | + 'utm_campaign' => 'powered_by', |
|
898 | + ), |
|
899 | + $query_args |
|
900 | + ); |
|
901 | + $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
902 | + $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
903 | + $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
904 | + $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
905 | + return (string)apply_filters( |
|
906 | + 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
907 | + sprintf( |
|
908 | + esc_html_x( |
|
909 | + '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s', |
|
910 | + 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
911 | + 'event_espresso' |
|
912 | + ), |
|
913 | + "<{$tag}{$attributes}>", |
|
914 | + "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>", |
|
915 | + $admin ? '' : '<br />' |
|
916 | + ), |
|
917 | + $wrap_class, |
|
918 | + $wrap_id |
|
919 | + ); |
|
920 | + } |
|
921 | 921 | |
922 | 922 | |
923 | 923 | } //end EEH_Template class |
@@ -926,33 +926,33 @@ discard block |
||
926 | 926 | |
927 | 927 | |
928 | 928 | if ( ! function_exists('espresso_pagination')) { |
929 | - /** |
|
930 | - * espresso_pagination |
|
931 | - * |
|
932 | - * @access public |
|
933 | - * @return void |
|
934 | - */ |
|
935 | - function espresso_pagination() |
|
936 | - { |
|
937 | - global $wp_query; |
|
938 | - $big = 999999999; // need an unlikely integer |
|
939 | - $pagination = paginate_links( |
|
940 | - array( |
|
941 | - 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
942 | - 'format' => '?paged=%#%', |
|
943 | - 'current' => max(1, get_query_var('paged')), |
|
944 | - 'total' => $wp_query->max_num_pages, |
|
945 | - 'show_all' => true, |
|
946 | - 'end_size' => 10, |
|
947 | - 'mid_size' => 6, |
|
948 | - 'prev_next' => true, |
|
949 | - 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
950 | - 'next_text' => __('NEXT ›', 'event_espresso'), |
|
951 | - 'type' => 'plain', |
|
952 | - 'add_args' => false, |
|
953 | - 'add_fragment' => '', |
|
954 | - ) |
|
955 | - ); |
|
956 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : ''; |
|
957 | - } |
|
929 | + /** |
|
930 | + * espresso_pagination |
|
931 | + * |
|
932 | + * @access public |
|
933 | + * @return void |
|
934 | + */ |
|
935 | + function espresso_pagination() |
|
936 | + { |
|
937 | + global $wp_query; |
|
938 | + $big = 999999999; // need an unlikely integer |
|
939 | + $pagination = paginate_links( |
|
940 | + array( |
|
941 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
942 | + 'format' => '?paged=%#%', |
|
943 | + 'current' => max(1, get_query_var('paged')), |
|
944 | + 'total' => $wp_query->max_num_pages, |
|
945 | + 'show_all' => true, |
|
946 | + 'end_size' => 10, |
|
947 | + 'mid_size' => 6, |
|
948 | + 'prev_next' => true, |
|
949 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
950 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
951 | + 'type' => 'plain', |
|
952 | + 'add_args' => false, |
|
953 | + 'add_fragment' => '', |
|
954 | + ) |
|
955 | + ); |
|
956 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : ''; |
|
957 | + } |
|
958 | 958 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
4 | 4 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
5 | 5 | |
6 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | 7 | exit('NO direct script access allowed'); |
8 | 8 | } |
9 | 9 | /** |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | public static function load_espresso_theme_functions() |
86 | 86 | { |
87 | 87 | if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
88 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
89 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
88 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
89 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public static function get_espresso_themes() |
101 | 101 | { |
102 | 102 | if (empty(EEH_Template::$_espresso_themes)) { |
103 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
103 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
104 | 104 | if (empty($espresso_themes)) { |
105 | 105 | return array(); |
106 | 106 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | ) { |
137 | 137 | do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
138 | 138 | $templates = array(); |
139 | - $name = (string)$name; |
|
139 | + $name = (string) $name; |
|
140 | 140 | if ($name != '') { |
141 | 141 | $templates[] = "{$slug}-{$name}.php"; |
142 | 142 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | if (isset($EE_CPTs[$post_type])) { |
216 | 216 | $archive_or_single = is_archive() ? 'archive' : ''; |
217 | 217 | $archive_or_single = is_single() ? 'single' : $archive_or_single; |
218 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
218 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | // currently active EE template theme |
@@ -224,18 +224,18 @@ discard block |
||
224 | 224 | // array of paths to folders that may contain templates |
225 | 225 | $template_folder_paths = array( |
226 | 226 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
227 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
227 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
228 | 228 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
229 | 229 | EVENT_ESPRESSO_TEMPLATE_DIR, |
230 | 230 | ); |
231 | 231 | |
232 | 232 | //add core plugin folders for checking only if we're not $check_if_custom |
233 | 233 | if ( ! $check_if_custom) { |
234 | - $core_paths = array( |
|
234 | + $core_paths = array( |
|
235 | 235 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
236 | - EE_PUBLIC . $current_theme, |
|
236 | + EE_PUBLIC.$current_theme, |
|
237 | 237 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
238 | - EE_TEMPLATES . $current_theme, |
|
238 | + EE_TEMPLATES.$current_theme, |
|
239 | 239 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
240 | 240 | EE_PLUGIN_DIR_PATH, |
241 | 241 | ); |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | ); |
267 | 267 | if ($common_base_path !== '') { |
268 | 268 | // both paths have a common base, so just tack the filename onto our search path |
269 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
269 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
270 | 270 | } else { |
271 | 271 | // no common base path, so let's just concatenate |
272 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
272 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
273 | 273 | } |
274 | 274 | // build up our template locations array by adding our resolved paths |
275 | 275 | $full_template_paths[] = $resolved_path; |
@@ -277,13 +277,13 @@ discard block |
||
277 | 277 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
278 | 278 | array_unshift($full_template_paths, $template); |
279 | 279 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
280 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
280 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
281 | 281 | } |
282 | 282 | // filter final array of full template paths |
283 | 283 | $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
284 | 284 | $full_template_paths, $file_name); |
285 | 285 | // now loop through our final array of template location paths and check each location |
286 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
286 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
287 | 287 | if (is_readable($full_template_path)) { |
288 | 288 | $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
289 | 289 | break; |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | if ( ! is_array($template_args) && ! is_object($template_args)) { |
371 | 371 | $template_args = array($template_args); |
372 | 372 | } |
373 | - extract( $template_args, EXTR_SKIP ); |
|
373 | + extract($template_args, EXTR_SKIP); |
|
374 | 374 | // ignore whether template is accessible ? |
375 | - if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
375 | + if ($throw_exceptions && ! is_readable($template_path)) { |
|
376 | 376 | throw new \DomainException( |
377 | 377 | esc_html__( |
378 | 378 | 'Invalid, unreadable, or missing file.', |
@@ -405,11 +405,11 @@ discard block |
||
405 | 405 | public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
406 | 406 | { |
407 | 407 | // in the beginning... |
408 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
408 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
409 | 409 | // da muddle |
410 | 410 | $class = ''; |
411 | 411 | // the end |
412 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
412 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
413 | 413 | // is the passed object an EE object ? |
414 | 414 | if ($object instanceof EE_Base_Class) { |
415 | 415 | // grab the exact type of object |
@@ -419,11 +419,11 @@ discard block |
||
419 | 419 | // no specifics just yet... |
420 | 420 | default : |
421 | 421 | $class = strtolower(str_replace('_', '-', $obj_class)); |
422 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
422 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
423 | 423 | |
424 | 424 | } |
425 | 425 | } |
426 | - return $prefix . $class . $suffix; |
|
426 | + return $prefix.$class.$suffix; |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | |
@@ -504,12 +504,12 @@ discard block |
||
504 | 504 | $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
505 | 505 | foreach ($dashicons as $dashicon) { |
506 | 506 | $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
507 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
507 | + $icon_html .= '<span class="'.$type.$dashicon.'"></span>'; |
|
508 | 508 | } |
509 | 509 | $icon_html .= $count > 1 ? '</span>' : ''; |
510 | 510 | } |
511 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
512 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
511 | + $label = ! empty($icon) ? $icon_html.$label : $label; |
|
512 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.esc_url($url).'" class="'.$class.'" title="'.$title.'">'.$label.'</a>'; |
|
513 | 513 | return $button; |
514 | 514 | } |
515 | 515 | |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | $action = empty($action) ? 'default' : $action; |
544 | 544 | |
545 | 545 | |
546 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
546 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
547 | 547 | $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
548 | 548 | $help_text = ! $help_text ? '' : $help_text; |
549 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
550 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
549 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
550 | + 'event_espresso').'" > '.$help_text.' </a>'; |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | |
@@ -564,11 +564,11 @@ discard block |
||
564 | 564 | $id = $tour->get_slug(); |
565 | 565 | $stops = $tour->get_stops(); |
566 | 566 | |
567 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
567 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
568 | 568 | |
569 | 569 | foreach ($stops as $stop) { |
570 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
571 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
570 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
571 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
572 | 572 | |
573 | 573 | //if container is set to modal then let's make sure we set the options accordingly |
574 | 574 | if (empty($data_id) && empty($data_class)) { |
@@ -576,15 +576,15 @@ discard block |
||
576 | 576 | $stop['options']['expose'] = true; |
577 | 577 | } |
578 | 578 | |
579 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
580 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
579 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
580 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
581 | 581 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
582 | 582 | |
583 | 583 | //options |
584 | 584 | if (isset($stop['options']) && is_array($stop['options'])) { |
585 | 585 | $options = ' data-options="'; |
586 | 586 | foreach ($stop['options'] as $option => $value) { |
587 | - $options .= $option . ':' . $value . ';'; |
|
587 | + $options .= $option.':'.$value.';'; |
|
588 | 588 | } |
589 | 589 | $options .= '"'; |
590 | 590 | } else { |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | } |
593 | 593 | |
594 | 594 | //let's put all together |
595 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
595 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | $content .= '</ol>'; |
@@ -624,24 +624,24 @@ discard block |
||
624 | 624 | $setup_array = array(); |
625 | 625 | foreach ($status_array as $item => $status) { |
626 | 626 | $setup_array[$item] = array( |
627 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
627 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
628 | 628 | 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
629 | 629 | 'status' => $status, |
630 | 630 | ); |
631 | 631 | } |
632 | 632 | |
633 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
634 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
635 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
633 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
634 | + $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
635 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
636 | 636 | foreach ($setup_array as $item => $details) { |
637 | 637 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
638 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
639 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
640 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
641 | - $content .= '</dt>' . "\n"; |
|
638 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
639 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
640 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
641 | + $content .= '</dt>'."\n"; |
|
642 | 642 | } |
643 | - $content .= '</dl>' . "\n"; |
|
644 | - $content .= '</div>' . "\n"; |
|
643 | + $content .= '</dl>'."\n"; |
|
644 | + $content .= '</div>'."\n"; |
|
645 | 645 | return $content; |
646 | 646 | } |
647 | 647 | |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | public static function layout_array_as_table($data) |
657 | 657 | { |
658 | 658 | if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
659 | - $data = (array)$data; |
|
659 | + $data = (array) $data; |
|
660 | 660 | } |
661 | 661 | ob_start(); |
662 | 662 | if (is_array($data)) { |
@@ -757,9 +757,9 @@ discard block |
||
757 | 757 | ) { |
758 | 758 | $page_links = array(); |
759 | 759 | $disable_first = $disable_last = ''; |
760 | - $total_items = (int)$total_items; |
|
761 | - $per_page = (int)$per_page; |
|
762 | - $current = (int)$current; |
|
760 | + $total_items = (int) $total_items; |
|
761 | + $per_page = (int) $per_page; |
|
762 | + $current = (int) $current; |
|
763 | 763 | $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
764 | 764 | |
765 | 765 | //filter items_label |
@@ -779,8 +779,8 @@ discard block |
||
779 | 779 | ); |
780 | 780 | } else { |
781 | 781 | $items_label = array( |
782 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
783 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
782 | + 'single' => '1 '.esc_html($items_label['single']), |
|
783 | + 'plural' => '%s '.esc_html($items_label['plural']), |
|
784 | 784 | ); |
785 | 785 | } |
786 | 786 | |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | |
793 | 793 | $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
794 | 794 | |
795 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
795 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
796 | 796 | |
797 | 797 | if ($current === 1) { |
798 | 798 | $disable_first = ' disabled'; |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | } |
803 | 803 | |
804 | 804 | $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
805 | - 'first-page' . $disable_first, |
|
805 | + 'first-page'.$disable_first, |
|
806 | 806 | esc_attr__('Go to the first page'), |
807 | 807 | esc_url(remove_query_arg($paged_arg_name, $url)), |
808 | 808 | '«' |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | |
811 | 811 | $page_links[] = sprintf( |
812 | 812 | '<a class="%s" title="%s" href="%s">%s</a>', |
813 | - 'prev-page' . $disable_first, |
|
813 | + 'prev-page'.$disable_first, |
|
814 | 814 | esc_attr__('Go to the previous page'), |
815 | 815 | esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
816 | 816 | '‹' |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | '<span class="total-pages">%s</span>', |
831 | 831 | number_format_i18n($total_pages) |
832 | 832 | ); |
833 | - $page_links[] = sprintf( |
|
833 | + $page_links[] = sprintf( |
|
834 | 834 | _x('%3$s%1$s of %2$s%4$s', 'paging'), |
835 | 835 | $html_current_page, |
836 | 836 | $html_total_pages, |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | |
841 | 841 | $page_links[] = sprintf( |
842 | 842 | '<a class="%s" title="%s" href="%s">%s</a>', |
843 | - 'next-page' . $disable_last, |
|
843 | + 'next-page'.$disable_last, |
|
844 | 844 | esc_attr__('Go to the next page'), |
845 | 845 | esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
846 | 846 | '›' |
@@ -848,13 +848,13 @@ discard block |
||
848 | 848 | |
849 | 849 | $page_links[] = sprintf( |
850 | 850 | '<a class="%s" title="%s" href="%s">%s</a>', |
851 | - 'last-page' . $disable_last, |
|
851 | + 'last-page'.$disable_last, |
|
852 | 852 | esc_attr__('Go to the last page'), |
853 | 853 | esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
854 | 854 | '»' |
855 | 855 | ); |
856 | 856 | |
857 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
857 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
858 | 858 | // set page class |
859 | 859 | if ($total_pages) { |
860 | 860 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | $page_class = ' no-pages'; |
863 | 863 | } |
864 | 864 | |
865 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
865 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
@@ -899,10 +899,10 @@ discard block |
||
899 | 899 | $query_args |
900 | 900 | ); |
901 | 901 | $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
902 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
902 | + $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
903 | 903 | $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
904 | 904 | $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
905 | - return (string)apply_filters( |
|
905 | + return (string) apply_filters( |
|
906 | 906 | 'FHEE__EEH_Template__powered_by_event_espresso__html', |
907 | 907 | sprintf( |
908 | 908 | esc_html_x( |
@@ -953,6 +953,6 @@ discard block |
||
953 | 953 | 'add_fragment' => '', |
954 | 954 | ) |
955 | 955 | ); |
956 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : ''; |
|
956 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : ''; |
|
957 | 957 | } |
958 | 958 | } |