@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public static function set_trap() |
55 | 55 | { |
56 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
56 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS); |
|
57 | 57 | add_action( |
58 | 58 | 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
59 | 59 | array('EED_Bot_Trap', 'generate_bot_trap'), |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
120 | 120 | $time = microtime(true); |
121 | 121 | $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
122 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
122 | + $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>'; |
|
123 | 123 | $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
124 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
124 | + $html .= $time.'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
125 | 125 | $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
126 | 126 | echo $html; |
127 | 127 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | return; |
148 | 148 | } |
149 | 149 | // check the given callback is valid first before executing |
150 | - if (! is_callable($triggered_trap_callback)) { |
|
150 | + if ( ! is_callable($triggered_trap_callback)) { |
|
151 | 151 | // invalid callback so lets just sub in our default. |
152 | 152 | $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
153 | 153 | } |
@@ -16,304 +16,304 @@ |
||
16 | 16 | class EED_Bot_Trap extends EED_Module |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @return EED_Bot_Trap|EED_Module |
|
21 | - */ |
|
22 | - public static function instance() |
|
23 | - { |
|
24 | - return parent::get_instance(__CLASS__); |
|
25 | - } |
|
19 | + /** |
|
20 | + * @return EED_Bot_Trap|EED_Module |
|
21 | + */ |
|
22 | + public static function instance() |
|
23 | + { |
|
24 | + return parent::get_instance(__CLASS__); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public static function set_hooks() |
|
34 | - { |
|
35 | - if (apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
36 | - EE_Registry::instance()->CFG->registration->use_bot_trap |
|
37 | - ) { |
|
38 | - EED_Bot_Trap::set_trap(); |
|
39 | - // redirect bots to bogus success page |
|
40 | - EE_Config::register_route( |
|
41 | - 'ticket_selection_received', |
|
42 | - 'EED_Bot_Trap', |
|
43 | - 'display_bot_trap_success' |
|
44 | - ); |
|
45 | - } |
|
46 | - } |
|
28 | + /** |
|
29 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public static function set_hooks() |
|
34 | + { |
|
35 | + if (apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
36 | + EE_Registry::instance()->CFG->registration->use_bot_trap |
|
37 | + ) { |
|
38 | + EED_Bot_Trap::set_trap(); |
|
39 | + // redirect bots to bogus success page |
|
40 | + EE_Config::register_route( |
|
41 | + 'ticket_selection_received', |
|
42 | + 'EED_Bot_Trap', |
|
43 | + 'display_bot_trap_success' |
|
44 | + ); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
51 | - * |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public static function set_trap() |
|
55 | - { |
|
56 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
57 | - add_action( |
|
58 | - 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
59 | - array('EED_Bot_Trap', 'generate_bot_trap'), |
|
60 | - 10, |
|
61 | - 2 |
|
62 | - ); |
|
63 | - add_action( |
|
64 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
65 | - array('EED_Bot_Trap', 'process_bot_trap'), |
|
66 | - 1, |
|
67 | - 2 |
|
68 | - ); |
|
69 | - } |
|
49 | + /** |
|
50 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
51 | + * |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public static function set_trap() |
|
55 | + { |
|
56 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
57 | + add_action( |
|
58 | + 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
59 | + array('EED_Bot_Trap', 'generate_bot_trap'), |
|
60 | + 10, |
|
61 | + 2 |
|
62 | + ); |
|
63 | + add_action( |
|
64 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
65 | + array('EED_Bot_Trap', 'process_bot_trap'), |
|
66 | + 1, |
|
67 | + 2 |
|
68 | + ); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
74 | - * |
|
75 | - * @return void |
|
76 | - */ |
|
77 | - public static function set_hooks_admin() |
|
78 | - { |
|
79 | - if (defined('DOING_AJAX') |
|
80 | - && DOING_AJAX |
|
81 | - && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
82 | - && EE_Registry::instance()->CFG->registration->use_bot_trap |
|
83 | - ) { |
|
84 | - EED_Bot_Trap::set_trap(); |
|
85 | - } |
|
86 | - add_action( |
|
87 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
88 | - array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
89 | - 5 |
|
90 | - ); |
|
91 | - add_filter( |
|
92 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
93 | - array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
94 | - 10, |
|
95 | - 1 |
|
96 | - ); |
|
97 | - } |
|
72 | + /** |
|
73 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
74 | + * |
|
75 | + * @return void |
|
76 | + */ |
|
77 | + public static function set_hooks_admin() |
|
78 | + { |
|
79 | + if (defined('DOING_AJAX') |
|
80 | + && DOING_AJAX |
|
81 | + && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
82 | + && EE_Registry::instance()->CFG->registration->use_bot_trap |
|
83 | + ) { |
|
84 | + EED_Bot_Trap::set_trap(); |
|
85 | + } |
|
86 | + add_action( |
|
87 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
88 | + array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
89 | + 5 |
|
90 | + ); |
|
91 | + add_filter( |
|
92 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
93 | + array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
94 | + 10, |
|
95 | + 1 |
|
96 | + ); |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | - /** |
|
101 | - * run - initial module setup |
|
102 | - * |
|
103 | - * @param WP $WP |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public function run($WP) |
|
107 | - { |
|
108 | - } |
|
100 | + /** |
|
101 | + * run - initial module setup |
|
102 | + * |
|
103 | + * @param WP $WP |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public function run($WP) |
|
107 | + { |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * generate_bot_trap |
|
113 | - * |
|
114 | - * @return void |
|
115 | - * @throws RuntimeException |
|
116 | - */ |
|
117 | - public static function generate_bot_trap() |
|
118 | - { |
|
119 | - $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
120 | - $time = microtime(true); |
|
121 | - $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
122 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
123 | - $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
124 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
125 | - $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
126 | - echo $html; |
|
127 | - } |
|
111 | + /** |
|
112 | + * generate_bot_trap |
|
113 | + * |
|
114 | + * @return void |
|
115 | + * @throws RuntimeException |
|
116 | + */ |
|
117 | + public static function generate_bot_trap() |
|
118 | + { |
|
119 | + $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
120 | + $time = microtime(true); |
|
121 | + $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
122 | + $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
123 | + $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
124 | + $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
125 | + $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
126 | + echo $html; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * process_bot_trap |
|
132 | - * |
|
133 | - * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
134 | - * response if the bot trap is triggered. |
|
135 | - * It should receive one argument: a boolean indicating |
|
136 | - * whether the trap was triggered by suspicious timing or not. |
|
137 | - * @throws RuntimeException |
|
138 | - */ |
|
139 | - public static function process_bot_trap($triggered_trap_callback = array()) |
|
140 | - { |
|
141 | - // what's your email address Mr. Bot ? |
|
142 | - $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
143 | - && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
144 | - // are we human ? |
|
145 | - if ($empty_trap) { |
|
146 | - do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
147 | - return; |
|
148 | - } |
|
149 | - // check the given callback is valid first before executing |
|
150 | - if (! is_callable($triggered_trap_callback)) { |
|
151 | - // invalid callback so lets just sub in our default. |
|
152 | - $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
153 | - } |
|
154 | - call_user_func($triggered_trap_callback); |
|
155 | - } |
|
130 | + /** |
|
131 | + * process_bot_trap |
|
132 | + * |
|
133 | + * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
134 | + * response if the bot trap is triggered. |
|
135 | + * It should receive one argument: a boolean indicating |
|
136 | + * whether the trap was triggered by suspicious timing or not. |
|
137 | + * @throws RuntimeException |
|
138 | + */ |
|
139 | + public static function process_bot_trap($triggered_trap_callback = array()) |
|
140 | + { |
|
141 | + // what's your email address Mr. Bot ? |
|
142 | + $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
143 | + && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
144 | + // are we human ? |
|
145 | + if ($empty_trap) { |
|
146 | + do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
147 | + return; |
|
148 | + } |
|
149 | + // check the given callback is valid first before executing |
|
150 | + if (! is_callable($triggered_trap_callback)) { |
|
151 | + // invalid callback so lets just sub in our default. |
|
152 | + $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
153 | + } |
|
154 | + call_user_func($triggered_trap_callback); |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | - /** |
|
159 | - * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
160 | - * |
|
161 | - * @throws InvalidArgumentException |
|
162 | - * @throws InvalidDataTypeException |
|
163 | - * @throws InvalidInterfaceException |
|
164 | - */ |
|
165 | - public static function triggered_trap_response() |
|
166 | - { |
|
167 | - // UH OH... |
|
168 | - $redirect_url = apply_filters( |
|
169 | - 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', |
|
170 | - add_query_arg( |
|
171 | - array('ee' => 'ticket_selection_received'), |
|
172 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
173 | - ) |
|
174 | - ); |
|
175 | - // if AJAX, return the redirect URL |
|
176 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
177 | - echo wp_json_encode( |
|
178 | - array_merge( |
|
179 | - EE_Error::get_notices(false), |
|
180 | - array( |
|
181 | - 'redirect_url' => $redirect_url, |
|
182 | - ) |
|
183 | - ) |
|
184 | - ); |
|
185 | - exit(); |
|
186 | - } |
|
187 | - wp_safe_redirect($redirect_url); |
|
188 | - exit(); |
|
189 | - } |
|
158 | + /** |
|
159 | + * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
160 | + * |
|
161 | + * @throws InvalidArgumentException |
|
162 | + * @throws InvalidDataTypeException |
|
163 | + * @throws InvalidInterfaceException |
|
164 | + */ |
|
165 | + public static function triggered_trap_response() |
|
166 | + { |
|
167 | + // UH OH... |
|
168 | + $redirect_url = apply_filters( |
|
169 | + 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', |
|
170 | + add_query_arg( |
|
171 | + array('ee' => 'ticket_selection_received'), |
|
172 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
173 | + ) |
|
174 | + ); |
|
175 | + // if AJAX, return the redirect URL |
|
176 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
177 | + echo wp_json_encode( |
|
178 | + array_merge( |
|
179 | + EE_Error::get_notices(false), |
|
180 | + array( |
|
181 | + 'redirect_url' => $redirect_url, |
|
182 | + ) |
|
183 | + ) |
|
184 | + ); |
|
185 | + exit(); |
|
186 | + } |
|
187 | + wp_safe_redirect($redirect_url); |
|
188 | + exit(); |
|
189 | + } |
|
190 | 190 | |
191 | 191 | |
192 | - /** |
|
193 | - * display_bot_trap_success |
|
194 | - * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
195 | - * think the form was submitted successfully |
|
196 | - * |
|
197 | - * @return void |
|
198 | - */ |
|
199 | - public static function display_bot_trap_success() |
|
200 | - { |
|
201 | - add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
202 | - $bot_notice = esc_html__( |
|
203 | - 'Thank you so much. Your ticket selections have been received for consideration.', |
|
204 | - 'event_espresso' |
|
205 | - ); |
|
206 | - $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
207 | - ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
208 | - : $bot_notice; |
|
209 | - EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
210 | - } |
|
192 | + /** |
|
193 | + * display_bot_trap_success |
|
194 | + * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
195 | + * think the form was submitted successfully |
|
196 | + * |
|
197 | + * @return void |
|
198 | + */ |
|
199 | + public static function display_bot_trap_success() |
|
200 | + { |
|
201 | + add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
202 | + $bot_notice = esc_html__( |
|
203 | + 'Thank you so much. Your ticket selections have been received for consideration.', |
|
204 | + 'event_espresso' |
|
205 | + ); |
|
206 | + $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
207 | + ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
208 | + : $bot_notice; |
|
209 | + EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
210 | + } |
|
211 | 211 | |
212 | 212 | |
213 | 213 | |
214 | - /*********************************** ADMIN **********************************/ |
|
214 | + /*********************************** ADMIN **********************************/ |
|
215 | 215 | |
216 | 216 | |
217 | - /** |
|
218 | - * bot_trap_settings_form |
|
219 | - * |
|
220 | - * @return void |
|
221 | - * @throws EE_Error |
|
222 | - * @throws InvalidArgumentException |
|
223 | - * @throws InvalidDataTypeException |
|
224 | - * @throws InvalidInterfaceException |
|
225 | - */ |
|
226 | - public static function bot_trap_settings_form() |
|
227 | - { |
|
228 | - EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
229 | - echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
230 | - } |
|
217 | + /** |
|
218 | + * bot_trap_settings_form |
|
219 | + * |
|
220 | + * @return void |
|
221 | + * @throws EE_Error |
|
222 | + * @throws InvalidArgumentException |
|
223 | + * @throws InvalidDataTypeException |
|
224 | + * @throws InvalidInterfaceException |
|
225 | + */ |
|
226 | + public static function bot_trap_settings_form() |
|
227 | + { |
|
228 | + EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
229 | + echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
230 | + } |
|
231 | 231 | |
232 | 232 | |
233 | - /** |
|
234 | - * _bot_trap_settings_form |
|
235 | - * |
|
236 | - * @return EE_Form_Section_Proper |
|
237 | - * @throws EE_Error |
|
238 | - */ |
|
239 | - protected static function _bot_trap_settings_form() |
|
240 | - { |
|
241 | - return new EE_Form_Section_Proper( |
|
242 | - array( |
|
243 | - 'name' => 'bot_trap_settings', |
|
244 | - 'html_id' => 'bot_trap_settings', |
|
245 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
246 | - 'subsections' => array( |
|
247 | - 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
248 | - EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
249 | - ), |
|
250 | - 'use_bot_trap' => new EE_Yes_No_Input( |
|
251 | - array( |
|
252 | - 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
253 | - 'html_help_text' => esc_html__( |
|
254 | - 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', |
|
255 | - 'event_espresso' |
|
256 | - ), |
|
257 | - 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
258 | - ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
259 | - : true, |
|
260 | - 'required' => false, |
|
261 | - ) |
|
262 | - ), |
|
263 | - ), |
|
264 | - ) |
|
265 | - ); |
|
266 | - } |
|
233 | + /** |
|
234 | + * _bot_trap_settings_form |
|
235 | + * |
|
236 | + * @return EE_Form_Section_Proper |
|
237 | + * @throws EE_Error |
|
238 | + */ |
|
239 | + protected static function _bot_trap_settings_form() |
|
240 | + { |
|
241 | + return new EE_Form_Section_Proper( |
|
242 | + array( |
|
243 | + 'name' => 'bot_trap_settings', |
|
244 | + 'html_id' => 'bot_trap_settings', |
|
245 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
246 | + 'subsections' => array( |
|
247 | + 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
248 | + EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
249 | + ), |
|
250 | + 'use_bot_trap' => new EE_Yes_No_Input( |
|
251 | + array( |
|
252 | + 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
253 | + 'html_help_text' => esc_html__( |
|
254 | + 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', |
|
255 | + 'event_espresso' |
|
256 | + ), |
|
257 | + 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
258 | + ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
259 | + : true, |
|
260 | + 'required' => false, |
|
261 | + ) |
|
262 | + ), |
|
263 | + ), |
|
264 | + ) |
|
265 | + ); |
|
266 | + } |
|
267 | 267 | |
268 | 268 | |
269 | - /** |
|
270 | - * update_bot_trap_settings_form |
|
271 | - * |
|
272 | - * @param EE_Registration_Config $EE_Registration_Config |
|
273 | - * @return EE_Registration_Config |
|
274 | - * @throws EE_Error |
|
275 | - * @throws InvalidArgumentException |
|
276 | - * @throws ReflectionException |
|
277 | - * @throws InvalidDataTypeException |
|
278 | - * @throws InvalidInterfaceException |
|
279 | - */ |
|
280 | - public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
281 | - { |
|
282 | - try { |
|
283 | - $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
284 | - // if not displaying a form, then check for form submission |
|
285 | - if ($bot_trap_settings_form->was_submitted()) { |
|
286 | - // capture form data |
|
287 | - $bot_trap_settings_form->receive_form_submission(); |
|
288 | - // validate form data |
|
289 | - if ($bot_trap_settings_form->is_valid()) { |
|
290 | - // grab validated data from form |
|
291 | - $valid_data = $bot_trap_settings_form->valid_data(); |
|
292 | - if (isset($valid_data['use_bot_trap'])) { |
|
293 | - $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
294 | - } else { |
|
295 | - EE_Error::add_error( |
|
296 | - esc_html__( |
|
297 | - 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
298 | - 'event_espresso' |
|
299 | - ), |
|
300 | - __FILE__, |
|
301 | - __FUNCTION__, |
|
302 | - __LINE__ |
|
303 | - ); |
|
304 | - } |
|
305 | - } elseif ($bot_trap_settings_form->submission_error_message() !== '') { |
|
306 | - EE_Error::add_error( |
|
307 | - $bot_trap_settings_form->submission_error_message(), |
|
308 | - __FILE__, |
|
309 | - __FUNCTION__, |
|
310 | - __LINE__ |
|
311 | - ); |
|
312 | - } |
|
313 | - } |
|
314 | - } catch (EE_Error $e) { |
|
315 | - $e->get_error(); |
|
316 | - } |
|
317 | - return $EE_Registration_Config; |
|
318 | - } |
|
269 | + /** |
|
270 | + * update_bot_trap_settings_form |
|
271 | + * |
|
272 | + * @param EE_Registration_Config $EE_Registration_Config |
|
273 | + * @return EE_Registration_Config |
|
274 | + * @throws EE_Error |
|
275 | + * @throws InvalidArgumentException |
|
276 | + * @throws ReflectionException |
|
277 | + * @throws InvalidDataTypeException |
|
278 | + * @throws InvalidInterfaceException |
|
279 | + */ |
|
280 | + public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
281 | + { |
|
282 | + try { |
|
283 | + $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
284 | + // if not displaying a form, then check for form submission |
|
285 | + if ($bot_trap_settings_form->was_submitted()) { |
|
286 | + // capture form data |
|
287 | + $bot_trap_settings_form->receive_form_submission(); |
|
288 | + // validate form data |
|
289 | + if ($bot_trap_settings_form->is_valid()) { |
|
290 | + // grab validated data from form |
|
291 | + $valid_data = $bot_trap_settings_form->valid_data(); |
|
292 | + if (isset($valid_data['use_bot_trap'])) { |
|
293 | + $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
294 | + } else { |
|
295 | + EE_Error::add_error( |
|
296 | + esc_html__( |
|
297 | + 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
298 | + 'event_espresso' |
|
299 | + ), |
|
300 | + __FILE__, |
|
301 | + __FUNCTION__, |
|
302 | + __LINE__ |
|
303 | + ); |
|
304 | + } |
|
305 | + } elseif ($bot_trap_settings_form->submission_error_message() !== '') { |
|
306 | + EE_Error::add_error( |
|
307 | + $bot_trap_settings_form->submission_error_message(), |
|
308 | + __FILE__, |
|
309 | + __FUNCTION__, |
|
310 | + __LINE__ |
|
311 | + ); |
|
312 | + } |
|
313 | + } |
|
314 | + } catch (EE_Error $e) { |
|
315 | + $e->get_error(); |
|
316 | + } |
|
317 | + return $EE_Registration_Config; |
|
318 | + } |
|
319 | 319 | } |
@@ -31,554 +31,554 @@ |
||
31 | 31 | class CoreAssetManager extends AssetManager |
32 | 32 | { |
33 | 33 | |
34 | - // WordPress core / Third party JS asset handles |
|
35 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
34 | + // WordPress core / Third party JS asset handles |
|
35 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
36 | 36 | |
37 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
37 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
38 | 38 | |
39 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
39 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
40 | 40 | |
41 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
41 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
42 | 42 | |
43 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
43 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @since 4.9.71.p |
|
47 | - */ |
|
48 | - const JS_HANDLE_REACT = 'react'; |
|
45 | + /** |
|
46 | + * @since 4.9.71.p |
|
47 | + */ |
|
48 | + const JS_HANDLE_REACT = 'react'; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @since 4.9.71.p |
|
52 | - */ |
|
53 | - const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
50 | + /** |
|
51 | + * @since 4.9.71.p |
|
52 | + */ |
|
53 | + const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @since 4.9.71.p |
|
57 | - */ |
|
58 | - const JS_HANDLE_LODASH = 'lodash'; |
|
55 | + /** |
|
56 | + * @since 4.9.71.p |
|
57 | + */ |
|
58 | + const JS_HANDLE_LODASH = 'lodash'; |
|
59 | 59 | |
60 | - // EE JS assets handles |
|
61 | - const JS_HANDLE_MANIFEST = 'ee-manifest'; |
|
60 | + // EE JS assets handles |
|
61 | + const JS_HANDLE_MANIFEST = 'ee-manifest'; |
|
62 | 62 | |
63 | - const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
63 | + const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
64 | 64 | |
65 | - const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
65 | + const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
66 | 66 | |
67 | - const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
67 | + const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
68 | 68 | |
69 | - const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
69 | + const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
70 | 70 | |
71 | - const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
71 | + const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
72 | 72 | |
73 | - const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
73 | + const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
74 | 74 | |
75 | - const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
75 | + const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
76 | 76 | |
77 | - const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
78 | - |
|
79 | - const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
77 | + const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
78 | + |
|
79 | + const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
80 | 80 | |
81 | - const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
81 | + const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
82 | 82 | |
83 | - const JS_HANDLE_CORE = 'espresso_core'; |
|
83 | + const JS_HANDLE_CORE = 'espresso_core'; |
|
84 | 84 | |
85 | - const JS_HANDLE_I18N = 'eei18n'; |
|
86 | - |
|
87 | - const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
88 | - |
|
89 | - const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
90 | - |
|
91 | - // EE CSS assets handles |
|
92 | - const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
93 | - |
|
94 | - const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
95 | - |
|
96 | - const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
97 | - |
|
98 | - /** |
|
99 | - * @var EE_Currency_Config $currency_config |
|
100 | - */ |
|
101 | - protected $currency_config; |
|
102 | - |
|
103 | - /** |
|
104 | - * @var EE_Template_Config $template_config |
|
105 | - */ |
|
106 | - protected $template_config; |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * CoreAssetRegister constructor. |
|
111 | - * |
|
112 | - * @param AssetCollection $assets |
|
113 | - * @param EE_Currency_Config $currency_config |
|
114 | - * @param EE_Template_Config $template_config |
|
115 | - * @param DomainInterface $domain |
|
116 | - * @param Registry $registry |
|
117 | - */ |
|
118 | - public function __construct( |
|
119 | - AssetCollection $assets, |
|
120 | - EE_Currency_Config $currency_config, |
|
121 | - EE_Template_Config $template_config, |
|
122 | - DomainInterface $domain, |
|
123 | - Registry $registry |
|
124 | - ) { |
|
125 | - $this->currency_config = $currency_config; |
|
126 | - $this->template_config = $template_config; |
|
127 | - parent::__construct($domain, $assets, $registry); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @since 4.9.62.p |
|
133 | - * @throws DomainException |
|
134 | - * @throws DuplicateCollectionIdentifierException |
|
135 | - * @throws InvalidArgumentException |
|
136 | - * @throws InvalidDataTypeException |
|
137 | - * @throws InvalidEntityException |
|
138 | - * @throws InvalidInterfaceException |
|
139 | - */ |
|
140 | - public function addAssets() |
|
141 | - { |
|
142 | - $this->addJavascriptFiles(); |
|
143 | - $this->addStylesheetFiles(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @since 4.9.62.p |
|
149 | - * @throws DomainException |
|
150 | - * @throws DuplicateCollectionIdentifierException |
|
151 | - * @throws InvalidArgumentException |
|
152 | - * @throws InvalidDataTypeException |
|
153 | - * @throws InvalidEntityException |
|
154 | - * @throws InvalidInterfaceException |
|
155 | - */ |
|
156 | - public function addJavascriptFiles() |
|
157 | - { |
|
158 | - $this->loadCoreJs(); |
|
159 | - $this->loadJqueryValidate(); |
|
160 | - $this->loadAccountingJs(); |
|
161 | - add_action( |
|
162 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
163 | - array($this, 'loadQtipJs') |
|
164 | - ); |
|
165 | - $this->registerAdminAssets(); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @since 4.9.62.p |
|
171 | - * @throws DuplicateCollectionIdentifierException |
|
172 | - * @throws InvalidDataTypeException |
|
173 | - * @throws InvalidEntityException |
|
174 | - */ |
|
175 | - public function addStylesheetFiles() |
|
176 | - { |
|
177 | - $this->loadCoreCss(); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * core default javascript |
|
183 | - * |
|
184 | - * @since 4.9.62.p |
|
185 | - * @throws DomainException |
|
186 | - * @throws DuplicateCollectionIdentifierException |
|
187 | - * @throws InvalidArgumentException |
|
188 | - * @throws InvalidDataTypeException |
|
189 | - * @throws InvalidEntityException |
|
190 | - * @throws InvalidInterfaceException |
|
191 | - */ |
|
192 | - private function loadCoreJs() |
|
193 | - { |
|
194 | - // conditionally load third-party libraries that WP core MIGHT have. |
|
195 | - $this->registerWpAssets(); |
|
196 | - |
|
197 | - $this->addJavascript( |
|
198 | - CoreAssetManager::JS_HANDLE_MANIFEST, |
|
199 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
200 | - ); |
|
201 | - |
|
202 | - $this->addJavascript( |
|
203 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
204 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
205 | - array(CoreAssetManager::JS_HANDLE_MANIFEST) |
|
206 | - ) |
|
207 | - ->setHasInlineData(); |
|
208 | - |
|
209 | - $this->addJavascript( |
|
210 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
211 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
212 | - array( |
|
213 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
214 | - CoreAssetManager::JS_HANDLE_REACT, |
|
215 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
216 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
217 | - ) |
|
218 | - ); |
|
219 | - |
|
220 | - $this->addJavascript( |
|
221 | - CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
222 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators') |
|
223 | - )->setRequiresTranslation(); |
|
224 | - |
|
225 | - $this->addJavascript( |
|
226 | - CoreAssetManager::JS_HANDLE_HELPERS, |
|
227 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'), |
|
228 | - array( |
|
229 | - CoreAssetManager::JS_HANDLE_VALIDATORS |
|
230 | - ) |
|
231 | - )->setRequiresTranslation(); |
|
232 | - |
|
233 | - $this->addJavascript( |
|
234 | - CoreAssetManager::JS_HANDLE_MODEL, |
|
235 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'), |
|
236 | - array( |
|
237 | - CoreAssetManager::JS_HANDLE_HELPERS |
|
238 | - ) |
|
239 | - )->setRequiresTranslation(); |
|
240 | - |
|
241 | - $this->addJavascript( |
|
242 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
243 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'), |
|
244 | - array( |
|
245 | - CoreAssetManager::JS_HANDLE_MODEL |
|
246 | - ) |
|
247 | - )->setRequiresTranslation(); |
|
248 | - |
|
249 | - $this->addJavascript( |
|
250 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
251 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
252 | - array( |
|
253 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
254 | - 'wp-data', |
|
255 | - 'wp-api-fetch', |
|
256 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS |
|
257 | - ) |
|
258 | - ) |
|
259 | - ->setRequiresTranslation() |
|
260 | - ->setInlineDataCallback( |
|
261 | - function() { |
|
262 | - wp_add_inline_script( |
|
263 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
264 | - is_admin() |
|
265 | - ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )' |
|
266 | - : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )' |
|
267 | - ); |
|
268 | - } |
|
269 | - ); |
|
270 | - |
|
271 | - $this->addJavascript( |
|
272 | - CoreAssetManager::JS_HANDLE_HOCS, |
|
273 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'), |
|
274 | - array( |
|
275 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
276 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
277 | - 'wp-components', |
|
278 | - ) |
|
279 | - )->setRequiresTranslation(); |
|
280 | - |
|
281 | - $this->addJavascript( |
|
282 | - CoreAssetManager::JS_HANDLE_COMPONENTS, |
|
283 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
284 | - array( |
|
285 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
286 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
287 | - 'wp-components', |
|
288 | - ) |
|
289 | - ) |
|
290 | - ->setRequiresTranslation(); |
|
291 | - |
|
292 | - $this->addJavascript( |
|
293 | - CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
|
294 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'), |
|
295 | - array( |
|
296 | - CoreAssetManager::JS_HANDLE_COMPONENTS |
|
297 | - ) |
|
298 | - )->setRequiresTranslation(); |
|
299 | - |
|
300 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
301 | - $this->registry->addData( |
|
302 | - 'paths', |
|
303 | - array( |
|
304 | - 'base_rest_route' => rest_url(), |
|
305 | - 'rest_route' => rest_url('ee/v4.8.36/'), |
|
306 | - 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
307 | - 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
308 | - 'site_url' => site_url('/'), |
|
309 | - 'admin_url' => admin_url('/'), |
|
310 | - ) |
|
311 | - ); |
|
312 | - /** site formatting values **/ |
|
313 | - $this->registry->addData( |
|
314 | - 'site_formats', |
|
315 | - array( |
|
316 | - 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
317 | - ) |
|
318 | - ); |
|
319 | - /** currency data **/ |
|
320 | - $this->registry->addData( |
|
321 | - 'currency_config', |
|
322 | - $this->getCurrencySettings() |
|
323 | - ); |
|
324 | - /** site timezone */ |
|
325 | - $this->registry->addData( |
|
326 | - 'default_timezone', |
|
327 | - array( |
|
328 | - 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
329 | - 'string' => get_option('timezone_string'), |
|
330 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
331 | - ) |
|
332 | - ); |
|
333 | - /** site locale (user locale if user logged in) */ |
|
334 | - $this->registry->addData( |
|
335 | - 'locale', |
|
336 | - array( |
|
337 | - 'user' => get_user_locale(), |
|
338 | - 'site' => get_locale() |
|
339 | - ) |
|
340 | - ); |
|
341 | - |
|
342 | - $this->addJavascript( |
|
343 | - CoreAssetManager::JS_HANDLE_CORE, |
|
344 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
345 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
346 | - ) |
|
347 | - ->setInlineDataCallback( |
|
348 | - function () { |
|
349 | - wp_localize_script( |
|
350 | - CoreAssetManager::JS_HANDLE_CORE, |
|
351 | - CoreAssetManager::JS_HANDLE_I18N, |
|
352 | - EE_Registry::$i18n_js_strings |
|
353 | - ); |
|
354 | - } |
|
355 | - ); |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
361 | - * WordPress in the running environment. |
|
362 | - * |
|
363 | - * @throws DuplicateCollectionIdentifierException |
|
364 | - * @throws InvalidDataTypeException |
|
365 | - * @throws InvalidEntityException |
|
366 | - * @throws DomainException |
|
367 | - * @since 4.9.71.p |
|
368 | - */ |
|
369 | - private function registerWpAssets() |
|
370 | - { |
|
371 | - global $wp_version; |
|
372 | - if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
373 | - return; |
|
374 | - } |
|
375 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
376 | - ->setVersion('16.6.0'); |
|
377 | - $this->addVendorJavascript( |
|
378 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
379 | - array(CoreAssetManager::JS_HANDLE_REACT) |
|
380 | - )->setVersion('16.6.0'); |
|
381 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
382 | - ->setInlineDataCallback( |
|
383 | - function() { |
|
384 | - wp_add_inline_script( |
|
385 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
386 | - 'window.lodash = _.noConflict();' |
|
387 | - ); |
|
388 | - } |
|
389 | - ) |
|
390 | - ->setVersion('4.17.11'); |
|
391 | - } |
|
392 | - |
|
393 | - |
|
394 | - /** |
|
395 | - * Returns configuration data for the accounting-js library. |
|
396 | - * @since 4.9.71.p |
|
397 | - * @return array |
|
398 | - */ |
|
399 | - private function getAccountingSettings() { |
|
400 | - return array( |
|
401 | - 'currency' => array( |
|
402 | - 'symbol' => $this->currency_config->sign, |
|
403 | - 'format' => array( |
|
404 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
405 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
406 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
407 | - ), |
|
408 | - 'decimal' => $this->currency_config->dec_mrk, |
|
409 | - 'thousand' => $this->currency_config->thsnds, |
|
410 | - 'precision' => $this->currency_config->dec_plc, |
|
411 | - ), |
|
412 | - 'number' => array( |
|
413 | - 'precision' => $this->currency_config->dec_plc, |
|
414 | - 'thousand' => $this->currency_config->thsnds, |
|
415 | - 'decimal' => $this->currency_config->dec_mrk, |
|
416 | - ), |
|
417 | - ); |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * Returns configuration data for the js Currency VO. |
|
423 | - * @since 4.9.71.p |
|
424 | - * @return array |
|
425 | - */ |
|
426 | - private function getCurrencySettings() |
|
427 | - { |
|
428 | - return array( |
|
429 | - 'code' => $this->currency_config->code, |
|
430 | - 'singularLabel' => $this->currency_config->name, |
|
431 | - 'pluralLabel' => $this->currency_config->plural, |
|
432 | - 'sign' => $this->currency_config->sign, |
|
433 | - 'signB4' => $this->currency_config->sign_b4, |
|
434 | - 'decimalPlaces' => $this->currency_config->dec_plc, |
|
435 | - 'decimalMark' => $this->currency_config->dec_mrk, |
|
436 | - 'thousandsSeparator' => $this->currency_config->thsnds, |
|
437 | - ); |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * @since 4.9.62.p |
|
443 | - * @throws DuplicateCollectionIdentifierException |
|
444 | - * @throws InvalidDataTypeException |
|
445 | - * @throws InvalidEntityException |
|
446 | - */ |
|
447 | - private function loadCoreCss() |
|
448 | - { |
|
449 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
450 | - $this->addStylesheet( |
|
451 | - CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
452 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
453 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
454 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
455 | - array('dashicons') |
|
456 | - ); |
|
457 | - //Load custom style sheet if available |
|
458 | - if ($this->template_config->custom_style_sheet !== null) { |
|
459 | - $this->addStylesheet( |
|
460 | - CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
461 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
462 | - array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
463 | - ); |
|
464 | - } |
|
465 | - } |
|
466 | - $this->addStylesheet( |
|
467 | - CoreAssetManager::CSS_HANDLE_COMPONENTS, |
|
468 | - $this->registry->getCssUrl( |
|
469 | - $this->domain->assetNamespace(), |
|
470 | - 'components' |
|
471 | - ) |
|
472 | - ); |
|
473 | - } |
|
474 | - |
|
475 | - |
|
476 | - /** |
|
477 | - * jQuery Validate for form validation |
|
478 | - * |
|
479 | - * @since 4.9.62.p |
|
480 | - * @throws DomainException |
|
481 | - * @throws DuplicateCollectionIdentifierException |
|
482 | - * @throws InvalidDataTypeException |
|
483 | - * @throws InvalidEntityException |
|
484 | - */ |
|
485 | - private function loadJqueryValidate() |
|
486 | - { |
|
487 | - $this->addJavascript( |
|
488 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
489 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
490 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
491 | - ) |
|
492 | - ->setVersion('1.15.0'); |
|
493 | - |
|
494 | - $this->addJavascript( |
|
495 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
496 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
497 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
498 | - ) |
|
499 | - ->setVersion('1.15.0'); |
|
500 | - } |
|
501 | - |
|
502 | - |
|
503 | - /** |
|
504 | - * accounting.js for performing client-side calculations |
|
505 | - * |
|
506 | - * @since 4.9.62.p |
|
507 | - * @throws DomainException |
|
508 | - * @throws DuplicateCollectionIdentifierException |
|
509 | - * @throws InvalidDataTypeException |
|
510 | - * @throws InvalidEntityException |
|
511 | - */ |
|
512 | - private function loadAccountingJs() |
|
513 | - { |
|
514 | - //accounting.js library |
|
515 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
516 | - $this->addJavascript( |
|
517 | - CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
518 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
519 | - array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
520 | - ) |
|
521 | - ->setVersion('0.3.2'); |
|
522 | - |
|
523 | - $this->addJavascript( |
|
524 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
525 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
526 | - array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
527 | - ) |
|
528 | - ->setInlineDataCallback( |
|
529 | - function () { |
|
530 | - wp_localize_script( |
|
531 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
532 | - 'EE_ACCOUNTING_CFG', |
|
533 | - $this->getAccountingSettings() |
|
534 | - ); |
|
535 | - } |
|
536 | - ) |
|
537 | - ->setVersion(); |
|
538 | - } |
|
539 | - |
|
540 | - |
|
541 | - /** |
|
542 | - * registers assets for cleaning your ears |
|
543 | - * |
|
544 | - * @param JavascriptAsset $script |
|
545 | - */ |
|
546 | - public function loadQtipJs(JavascriptAsset $script) |
|
547 | - { |
|
548 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
549 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
550 | - if ( |
|
551 | - $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
552 | - && apply_filters('FHEE_load_qtip', false) |
|
553 | - ) { |
|
554 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
555 | - } |
|
556 | - } |
|
557 | - |
|
558 | - |
|
559 | - /** |
|
560 | - * assets that are used in the WordPress admin |
|
561 | - * |
|
562 | - * @since 4.9.62.p |
|
563 | - * @throws DuplicateCollectionIdentifierException |
|
564 | - * @throws InvalidDataTypeException |
|
565 | - * @throws InvalidEntityException |
|
566 | - */ |
|
567 | - private function registerAdminAssets() |
|
568 | - { |
|
569 | - $this->addJavascript( |
|
570 | - CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
571 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
572 | - array( |
|
573 | - CoreAssetManager::JS_HANDLE_JQUERY, |
|
574 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
575 | - ) |
|
576 | - ) |
|
577 | - ->setRequiresTranslation(); |
|
578 | - |
|
579 | - $this->addStylesheet( |
|
580 | - CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
581 | - $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
582 | - ); |
|
583 | - } |
|
85 | + const JS_HANDLE_I18N = 'eei18n'; |
|
86 | + |
|
87 | + const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
88 | + |
|
89 | + const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
90 | + |
|
91 | + // EE CSS assets handles |
|
92 | + const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
93 | + |
|
94 | + const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
95 | + |
|
96 | + const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
97 | + |
|
98 | + /** |
|
99 | + * @var EE_Currency_Config $currency_config |
|
100 | + */ |
|
101 | + protected $currency_config; |
|
102 | + |
|
103 | + /** |
|
104 | + * @var EE_Template_Config $template_config |
|
105 | + */ |
|
106 | + protected $template_config; |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * CoreAssetRegister constructor. |
|
111 | + * |
|
112 | + * @param AssetCollection $assets |
|
113 | + * @param EE_Currency_Config $currency_config |
|
114 | + * @param EE_Template_Config $template_config |
|
115 | + * @param DomainInterface $domain |
|
116 | + * @param Registry $registry |
|
117 | + */ |
|
118 | + public function __construct( |
|
119 | + AssetCollection $assets, |
|
120 | + EE_Currency_Config $currency_config, |
|
121 | + EE_Template_Config $template_config, |
|
122 | + DomainInterface $domain, |
|
123 | + Registry $registry |
|
124 | + ) { |
|
125 | + $this->currency_config = $currency_config; |
|
126 | + $this->template_config = $template_config; |
|
127 | + parent::__construct($domain, $assets, $registry); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @since 4.9.62.p |
|
133 | + * @throws DomainException |
|
134 | + * @throws DuplicateCollectionIdentifierException |
|
135 | + * @throws InvalidArgumentException |
|
136 | + * @throws InvalidDataTypeException |
|
137 | + * @throws InvalidEntityException |
|
138 | + * @throws InvalidInterfaceException |
|
139 | + */ |
|
140 | + public function addAssets() |
|
141 | + { |
|
142 | + $this->addJavascriptFiles(); |
|
143 | + $this->addStylesheetFiles(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @since 4.9.62.p |
|
149 | + * @throws DomainException |
|
150 | + * @throws DuplicateCollectionIdentifierException |
|
151 | + * @throws InvalidArgumentException |
|
152 | + * @throws InvalidDataTypeException |
|
153 | + * @throws InvalidEntityException |
|
154 | + * @throws InvalidInterfaceException |
|
155 | + */ |
|
156 | + public function addJavascriptFiles() |
|
157 | + { |
|
158 | + $this->loadCoreJs(); |
|
159 | + $this->loadJqueryValidate(); |
|
160 | + $this->loadAccountingJs(); |
|
161 | + add_action( |
|
162 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
163 | + array($this, 'loadQtipJs') |
|
164 | + ); |
|
165 | + $this->registerAdminAssets(); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @since 4.9.62.p |
|
171 | + * @throws DuplicateCollectionIdentifierException |
|
172 | + * @throws InvalidDataTypeException |
|
173 | + * @throws InvalidEntityException |
|
174 | + */ |
|
175 | + public function addStylesheetFiles() |
|
176 | + { |
|
177 | + $this->loadCoreCss(); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * core default javascript |
|
183 | + * |
|
184 | + * @since 4.9.62.p |
|
185 | + * @throws DomainException |
|
186 | + * @throws DuplicateCollectionIdentifierException |
|
187 | + * @throws InvalidArgumentException |
|
188 | + * @throws InvalidDataTypeException |
|
189 | + * @throws InvalidEntityException |
|
190 | + * @throws InvalidInterfaceException |
|
191 | + */ |
|
192 | + private function loadCoreJs() |
|
193 | + { |
|
194 | + // conditionally load third-party libraries that WP core MIGHT have. |
|
195 | + $this->registerWpAssets(); |
|
196 | + |
|
197 | + $this->addJavascript( |
|
198 | + CoreAssetManager::JS_HANDLE_MANIFEST, |
|
199 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
200 | + ); |
|
201 | + |
|
202 | + $this->addJavascript( |
|
203 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
204 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
205 | + array(CoreAssetManager::JS_HANDLE_MANIFEST) |
|
206 | + ) |
|
207 | + ->setHasInlineData(); |
|
208 | + |
|
209 | + $this->addJavascript( |
|
210 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
211 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
212 | + array( |
|
213 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
214 | + CoreAssetManager::JS_HANDLE_REACT, |
|
215 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
216 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
217 | + ) |
|
218 | + ); |
|
219 | + |
|
220 | + $this->addJavascript( |
|
221 | + CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
222 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators') |
|
223 | + )->setRequiresTranslation(); |
|
224 | + |
|
225 | + $this->addJavascript( |
|
226 | + CoreAssetManager::JS_HANDLE_HELPERS, |
|
227 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'), |
|
228 | + array( |
|
229 | + CoreAssetManager::JS_HANDLE_VALIDATORS |
|
230 | + ) |
|
231 | + )->setRequiresTranslation(); |
|
232 | + |
|
233 | + $this->addJavascript( |
|
234 | + CoreAssetManager::JS_HANDLE_MODEL, |
|
235 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'), |
|
236 | + array( |
|
237 | + CoreAssetManager::JS_HANDLE_HELPERS |
|
238 | + ) |
|
239 | + )->setRequiresTranslation(); |
|
240 | + |
|
241 | + $this->addJavascript( |
|
242 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
243 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'), |
|
244 | + array( |
|
245 | + CoreAssetManager::JS_HANDLE_MODEL |
|
246 | + ) |
|
247 | + )->setRequiresTranslation(); |
|
248 | + |
|
249 | + $this->addJavascript( |
|
250 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
251 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
252 | + array( |
|
253 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
254 | + 'wp-data', |
|
255 | + 'wp-api-fetch', |
|
256 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS |
|
257 | + ) |
|
258 | + ) |
|
259 | + ->setRequiresTranslation() |
|
260 | + ->setInlineDataCallback( |
|
261 | + function() { |
|
262 | + wp_add_inline_script( |
|
263 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
264 | + is_admin() |
|
265 | + ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )' |
|
266 | + : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )' |
|
267 | + ); |
|
268 | + } |
|
269 | + ); |
|
270 | + |
|
271 | + $this->addJavascript( |
|
272 | + CoreAssetManager::JS_HANDLE_HOCS, |
|
273 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'), |
|
274 | + array( |
|
275 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
276 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
277 | + 'wp-components', |
|
278 | + ) |
|
279 | + )->setRequiresTranslation(); |
|
280 | + |
|
281 | + $this->addJavascript( |
|
282 | + CoreAssetManager::JS_HANDLE_COMPONENTS, |
|
283 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
284 | + array( |
|
285 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
286 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
287 | + 'wp-components', |
|
288 | + ) |
|
289 | + ) |
|
290 | + ->setRequiresTranslation(); |
|
291 | + |
|
292 | + $this->addJavascript( |
|
293 | + CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
|
294 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'), |
|
295 | + array( |
|
296 | + CoreAssetManager::JS_HANDLE_COMPONENTS |
|
297 | + ) |
|
298 | + )->setRequiresTranslation(); |
|
299 | + |
|
300 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
301 | + $this->registry->addData( |
|
302 | + 'paths', |
|
303 | + array( |
|
304 | + 'base_rest_route' => rest_url(), |
|
305 | + 'rest_route' => rest_url('ee/v4.8.36/'), |
|
306 | + 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
307 | + 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
308 | + 'site_url' => site_url('/'), |
|
309 | + 'admin_url' => admin_url('/'), |
|
310 | + ) |
|
311 | + ); |
|
312 | + /** site formatting values **/ |
|
313 | + $this->registry->addData( |
|
314 | + 'site_formats', |
|
315 | + array( |
|
316 | + 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
317 | + ) |
|
318 | + ); |
|
319 | + /** currency data **/ |
|
320 | + $this->registry->addData( |
|
321 | + 'currency_config', |
|
322 | + $this->getCurrencySettings() |
|
323 | + ); |
|
324 | + /** site timezone */ |
|
325 | + $this->registry->addData( |
|
326 | + 'default_timezone', |
|
327 | + array( |
|
328 | + 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
329 | + 'string' => get_option('timezone_string'), |
|
330 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
331 | + ) |
|
332 | + ); |
|
333 | + /** site locale (user locale if user logged in) */ |
|
334 | + $this->registry->addData( |
|
335 | + 'locale', |
|
336 | + array( |
|
337 | + 'user' => get_user_locale(), |
|
338 | + 'site' => get_locale() |
|
339 | + ) |
|
340 | + ); |
|
341 | + |
|
342 | + $this->addJavascript( |
|
343 | + CoreAssetManager::JS_HANDLE_CORE, |
|
344 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
345 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
346 | + ) |
|
347 | + ->setInlineDataCallback( |
|
348 | + function () { |
|
349 | + wp_localize_script( |
|
350 | + CoreAssetManager::JS_HANDLE_CORE, |
|
351 | + CoreAssetManager::JS_HANDLE_I18N, |
|
352 | + EE_Registry::$i18n_js_strings |
|
353 | + ); |
|
354 | + } |
|
355 | + ); |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
361 | + * WordPress in the running environment. |
|
362 | + * |
|
363 | + * @throws DuplicateCollectionIdentifierException |
|
364 | + * @throws InvalidDataTypeException |
|
365 | + * @throws InvalidEntityException |
|
366 | + * @throws DomainException |
|
367 | + * @since 4.9.71.p |
|
368 | + */ |
|
369 | + private function registerWpAssets() |
|
370 | + { |
|
371 | + global $wp_version; |
|
372 | + if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
373 | + return; |
|
374 | + } |
|
375 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
376 | + ->setVersion('16.6.0'); |
|
377 | + $this->addVendorJavascript( |
|
378 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
379 | + array(CoreAssetManager::JS_HANDLE_REACT) |
|
380 | + )->setVersion('16.6.0'); |
|
381 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
382 | + ->setInlineDataCallback( |
|
383 | + function() { |
|
384 | + wp_add_inline_script( |
|
385 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
386 | + 'window.lodash = _.noConflict();' |
|
387 | + ); |
|
388 | + } |
|
389 | + ) |
|
390 | + ->setVersion('4.17.11'); |
|
391 | + } |
|
392 | + |
|
393 | + |
|
394 | + /** |
|
395 | + * Returns configuration data for the accounting-js library. |
|
396 | + * @since 4.9.71.p |
|
397 | + * @return array |
|
398 | + */ |
|
399 | + private function getAccountingSettings() { |
|
400 | + return array( |
|
401 | + 'currency' => array( |
|
402 | + 'symbol' => $this->currency_config->sign, |
|
403 | + 'format' => array( |
|
404 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
405 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
406 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
407 | + ), |
|
408 | + 'decimal' => $this->currency_config->dec_mrk, |
|
409 | + 'thousand' => $this->currency_config->thsnds, |
|
410 | + 'precision' => $this->currency_config->dec_plc, |
|
411 | + ), |
|
412 | + 'number' => array( |
|
413 | + 'precision' => $this->currency_config->dec_plc, |
|
414 | + 'thousand' => $this->currency_config->thsnds, |
|
415 | + 'decimal' => $this->currency_config->dec_mrk, |
|
416 | + ), |
|
417 | + ); |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * Returns configuration data for the js Currency VO. |
|
423 | + * @since 4.9.71.p |
|
424 | + * @return array |
|
425 | + */ |
|
426 | + private function getCurrencySettings() |
|
427 | + { |
|
428 | + return array( |
|
429 | + 'code' => $this->currency_config->code, |
|
430 | + 'singularLabel' => $this->currency_config->name, |
|
431 | + 'pluralLabel' => $this->currency_config->plural, |
|
432 | + 'sign' => $this->currency_config->sign, |
|
433 | + 'signB4' => $this->currency_config->sign_b4, |
|
434 | + 'decimalPlaces' => $this->currency_config->dec_plc, |
|
435 | + 'decimalMark' => $this->currency_config->dec_mrk, |
|
436 | + 'thousandsSeparator' => $this->currency_config->thsnds, |
|
437 | + ); |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * @since 4.9.62.p |
|
443 | + * @throws DuplicateCollectionIdentifierException |
|
444 | + * @throws InvalidDataTypeException |
|
445 | + * @throws InvalidEntityException |
|
446 | + */ |
|
447 | + private function loadCoreCss() |
|
448 | + { |
|
449 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
450 | + $this->addStylesheet( |
|
451 | + CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
452 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
453 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
454 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
455 | + array('dashicons') |
|
456 | + ); |
|
457 | + //Load custom style sheet if available |
|
458 | + if ($this->template_config->custom_style_sheet !== null) { |
|
459 | + $this->addStylesheet( |
|
460 | + CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
461 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
462 | + array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
463 | + ); |
|
464 | + } |
|
465 | + } |
|
466 | + $this->addStylesheet( |
|
467 | + CoreAssetManager::CSS_HANDLE_COMPONENTS, |
|
468 | + $this->registry->getCssUrl( |
|
469 | + $this->domain->assetNamespace(), |
|
470 | + 'components' |
|
471 | + ) |
|
472 | + ); |
|
473 | + } |
|
474 | + |
|
475 | + |
|
476 | + /** |
|
477 | + * jQuery Validate for form validation |
|
478 | + * |
|
479 | + * @since 4.9.62.p |
|
480 | + * @throws DomainException |
|
481 | + * @throws DuplicateCollectionIdentifierException |
|
482 | + * @throws InvalidDataTypeException |
|
483 | + * @throws InvalidEntityException |
|
484 | + */ |
|
485 | + private function loadJqueryValidate() |
|
486 | + { |
|
487 | + $this->addJavascript( |
|
488 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
489 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
490 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
491 | + ) |
|
492 | + ->setVersion('1.15.0'); |
|
493 | + |
|
494 | + $this->addJavascript( |
|
495 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
496 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
497 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
498 | + ) |
|
499 | + ->setVersion('1.15.0'); |
|
500 | + } |
|
501 | + |
|
502 | + |
|
503 | + /** |
|
504 | + * accounting.js for performing client-side calculations |
|
505 | + * |
|
506 | + * @since 4.9.62.p |
|
507 | + * @throws DomainException |
|
508 | + * @throws DuplicateCollectionIdentifierException |
|
509 | + * @throws InvalidDataTypeException |
|
510 | + * @throws InvalidEntityException |
|
511 | + */ |
|
512 | + private function loadAccountingJs() |
|
513 | + { |
|
514 | + //accounting.js library |
|
515 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
516 | + $this->addJavascript( |
|
517 | + CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
518 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
519 | + array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
520 | + ) |
|
521 | + ->setVersion('0.3.2'); |
|
522 | + |
|
523 | + $this->addJavascript( |
|
524 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
525 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
526 | + array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
527 | + ) |
|
528 | + ->setInlineDataCallback( |
|
529 | + function () { |
|
530 | + wp_localize_script( |
|
531 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
532 | + 'EE_ACCOUNTING_CFG', |
|
533 | + $this->getAccountingSettings() |
|
534 | + ); |
|
535 | + } |
|
536 | + ) |
|
537 | + ->setVersion(); |
|
538 | + } |
|
539 | + |
|
540 | + |
|
541 | + /** |
|
542 | + * registers assets for cleaning your ears |
|
543 | + * |
|
544 | + * @param JavascriptAsset $script |
|
545 | + */ |
|
546 | + public function loadQtipJs(JavascriptAsset $script) |
|
547 | + { |
|
548 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
549 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
550 | + if ( |
|
551 | + $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
552 | + && apply_filters('FHEE_load_qtip', false) |
|
553 | + ) { |
|
554 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
555 | + } |
|
556 | + } |
|
557 | + |
|
558 | + |
|
559 | + /** |
|
560 | + * assets that are used in the WordPress admin |
|
561 | + * |
|
562 | + * @since 4.9.62.p |
|
563 | + * @throws DuplicateCollectionIdentifierException |
|
564 | + * @throws InvalidDataTypeException |
|
565 | + * @throws InvalidEntityException |
|
566 | + */ |
|
567 | + private function registerAdminAssets() |
|
568 | + { |
|
569 | + $this->addJavascript( |
|
570 | + CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
571 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
572 | + array( |
|
573 | + CoreAssetManager::JS_HANDLE_JQUERY, |
|
574 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
575 | + ) |
|
576 | + ) |
|
577 | + ->setRequiresTranslation(); |
|
578 | + |
|
579 | + $this->addStylesheet( |
|
580 | + CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
581 | + $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
582 | + ); |
|
583 | + } |
|
584 | 584 | } |
@@ -38,103 +38,103 @@ |
||
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 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
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.76.rc.015'); |
|
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.76.rc.015'); |
|
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'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |