@@ -11,246 +11,246 @@ |
||
11 | 11 | */ |
12 | 12 | class EED_Event_Single_Caff extends EED_Event_Single |
13 | 13 | { |
14 | - /** |
|
15 | - * @return EED_Event_Single_Caff |
|
16 | - * @throws EE_Error |
|
17 | - * @throws ReflectionException |
|
18 | - */ |
|
19 | - public static function instance() |
|
20 | - { |
|
21 | - return parent::get_instance(__CLASS__); |
|
22 | - } |
|
14 | + /** |
|
15 | + * @return EED_Event_Single_Caff |
|
16 | + * @throws EE_Error |
|
17 | + * @throws ReflectionException |
|
18 | + */ |
|
19 | + public static function instance() |
|
20 | + { |
|
21 | + return parent::get_instance(__CLASS__); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
27 | - * |
|
28 | - * @access public |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public static function set_hooks() |
|
32 | - { |
|
33 | - } |
|
25 | + /** |
|
26 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
27 | + * |
|
28 | + * @access public |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public static function set_hooks() |
|
32 | + { |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public static function set_hooks_admin() |
|
43 | - { |
|
44 | - self::setDefinitions(); |
|
45 | - add_action( |
|
46 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings', |
|
47 | - ['EED_Event_Single_Caff', 'load_scripts_styles'], |
|
48 | - 10 |
|
49 | - ); |
|
50 | - add_action( |
|
51 | - 'AHEE__template_settings__template__before_settings_form', |
|
52 | - ['EED_Event_Single_Caff', 'template_settings_form'], |
|
53 | - 10 |
|
54 | - ); |
|
55 | - add_filter( |
|
56 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
57 | - ['EED_Event_Single_Caff', 'update_template_settings'], |
|
58 | - 10, |
|
59 | - 2 |
|
60 | - ); |
|
61 | - // AJAX |
|
62 | - add_action( |
|
63 | - 'wp_ajax_espresso_update_event_single_order', |
|
64 | - ['EED_Event_Single_Caff', 'update_event_single_order'] |
|
65 | - ); |
|
66 | - } |
|
36 | + /** |
|
37 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public static function set_hooks_admin() |
|
43 | + { |
|
44 | + self::setDefinitions(); |
|
45 | + add_action( |
|
46 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings', |
|
47 | + ['EED_Event_Single_Caff', 'load_scripts_styles'], |
|
48 | + 10 |
|
49 | + ); |
|
50 | + add_action( |
|
51 | + 'AHEE__template_settings__template__before_settings_form', |
|
52 | + ['EED_Event_Single_Caff', 'template_settings_form'], |
|
53 | + 10 |
|
54 | + ); |
|
55 | + add_filter( |
|
56 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
57 | + ['EED_Event_Single_Caff', 'update_template_settings'], |
|
58 | + 10, |
|
59 | + 2 |
|
60 | + ); |
|
61 | + // AJAX |
|
62 | + add_action( |
|
63 | + 'wp_ajax_espresso_update_event_single_order', |
|
64 | + ['EED_Event_Single_Caff', 'update_event_single_order'] |
|
65 | + ); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - public static function load_scripts_styles() |
|
70 | - { |
|
71 | - add_action('admin_enqueue_scripts', ['EED_Event_Single_Caff', 'enqueue_scripts_styles'], 10); |
|
72 | - } |
|
69 | + public static function load_scripts_styles() |
|
70 | + { |
|
71 | + add_action('admin_enqueue_scripts', ['EED_Event_Single_Caff', 'enqueue_scripts_styles'], 10); |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - public static function enqueue_scripts_styles() |
|
76 | - { |
|
77 | - wp_register_style( |
|
78 | - 'eed-event-single-sortable', |
|
79 | - EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', |
|
80 | - [], |
|
81 | - EVENT_ESPRESSO_VERSION |
|
82 | - ); |
|
83 | - wp_enqueue_style('eed-event-single-sortable'); |
|
84 | - wp_register_script( |
|
85 | - 'eed-event-single-sortable', |
|
86 | - EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', |
|
87 | - ['espresso_core', 'jquery-ui-sortable'], |
|
88 | - EVENT_ESPRESSO_VERSION, |
|
89 | - true |
|
90 | - ); |
|
91 | - wp_enqueue_script('eed-event-single-sortable'); |
|
92 | - } |
|
75 | + public static function enqueue_scripts_styles() |
|
76 | + { |
|
77 | + wp_register_style( |
|
78 | + 'eed-event-single-sortable', |
|
79 | + EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', |
|
80 | + [], |
|
81 | + EVENT_ESPRESSO_VERSION |
|
82 | + ); |
|
83 | + wp_enqueue_style('eed-event-single-sortable'); |
|
84 | + wp_register_script( |
|
85 | + 'eed-event-single-sortable', |
|
86 | + EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', |
|
87 | + ['espresso_core', 'jquery-ui-sortable'], |
|
88 | + EVENT_ESPRESSO_VERSION, |
|
89 | + true |
|
90 | + ); |
|
91 | + wp_enqueue_script('eed-event-single-sortable'); |
|
92 | + } |
|
93 | 93 | |
94 | 94 | |
95 | - /** |
|
96 | - * Set constants only if they haven't been set yet. |
|
97 | - */ |
|
98 | - public static function setDefinitions() |
|
99 | - { |
|
100 | - if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) { |
|
101 | - define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
102 | - define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
103 | - } |
|
104 | - } |
|
95 | + /** |
|
96 | + * Set constants only if they haven't been set yet. |
|
97 | + */ |
|
98 | + public static function setDefinitions() |
|
99 | + { |
|
100 | + if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) { |
|
101 | + define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
102 | + define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - /** |
|
108 | - * template_settings_form |
|
109 | - * |
|
110 | - * @access public |
|
111 | - * @static |
|
112 | - * @return void |
|
113 | - * @throws EE_Error |
|
114 | - */ |
|
115 | - public static function template_settings_form() |
|
116 | - { |
|
117 | - $config = EE_Registry::instance()->CFG->template_settings; |
|
118 | - $config = |
|
119 | - isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config |
|
120 | - ? $config->EED_Event_Single : new EE_Event_Single_Config(); |
|
121 | - $config->use_sortable_display_order = $config->use_sortable_display_order ?? false; |
|
122 | - $config = |
|
123 | - apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config); |
|
107 | + /** |
|
108 | + * template_settings_form |
|
109 | + * |
|
110 | + * @access public |
|
111 | + * @static |
|
112 | + * @return void |
|
113 | + * @throws EE_Error |
|
114 | + */ |
|
115 | + public static function template_settings_form() |
|
116 | + { |
|
117 | + $config = EE_Registry::instance()->CFG->template_settings; |
|
118 | + $config = |
|
119 | + isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config |
|
120 | + ? $config->EED_Event_Single : new EE_Event_Single_Config(); |
|
121 | + $config->use_sortable_display_order = $config->use_sortable_display_order ?? false; |
|
122 | + $config = |
|
123 | + apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config); |
|
124 | 124 | |
125 | - $event_single_order_array = []; |
|
126 | - $event_single_order_array[ $config->display_order_tickets ] = 'tickets'; |
|
127 | - $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes'; |
|
128 | - $event_single_order_array[ $config->display_order_event ] = 'event'; |
|
129 | - $event_single_order_array[ $config->display_order_venue ] = 'venue'; |
|
130 | - // get template parts |
|
131 | - $template_parts = EED_Event_Single::instance()->initialize_template_parts($config); |
|
132 | - // convert to array so that we can add more properties |
|
133 | - $config = get_object_vars($config); |
|
134 | - $config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts( |
|
135 | - 'event-single-sortable-js', |
|
136 | - '', |
|
137 | - 'single-sortable-li single-sortable-js' |
|
138 | - ); |
|
139 | - EEH_Template::display_template( |
|
140 | - EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', |
|
141 | - $config |
|
142 | - ); |
|
143 | - } |
|
125 | + $event_single_order_array = []; |
|
126 | + $event_single_order_array[ $config->display_order_tickets ] = 'tickets'; |
|
127 | + $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes'; |
|
128 | + $event_single_order_array[ $config->display_order_event ] = 'event'; |
|
129 | + $event_single_order_array[ $config->display_order_venue ] = 'venue'; |
|
130 | + // get template parts |
|
131 | + $template_parts = EED_Event_Single::instance()->initialize_template_parts($config); |
|
132 | + // convert to array so that we can add more properties |
|
133 | + $config = get_object_vars($config); |
|
134 | + $config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts( |
|
135 | + 'event-single-sortable-js', |
|
136 | + '', |
|
137 | + 'single-sortable-li single-sortable-js' |
|
138 | + ); |
|
139 | + EEH_Template::display_template( |
|
140 | + EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', |
|
141 | + $config |
|
142 | + ); |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | - /** |
|
147 | - * update_template_settings |
|
148 | - * |
|
149 | - * @param EE_Template_Config $CFG |
|
150 | - * @param array $REQ |
|
151 | - * @return EE_Template_Config |
|
152 | - */ |
|
153 | - public static function update_template_settings(EE_Template_Config $CFG, $REQ): EE_Template_Config |
|
154 | - { |
|
155 | - /** @var EE_Capabilities $capabilities */ |
|
156 | - $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
|
157 | - if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
158 | - wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
159 | - } |
|
160 | - if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) { |
|
161 | - $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
|
162 | - } |
|
163 | - $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
|
164 | - ? $CFG->EED_Event_Single->display_order_event |
|
165 | - : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
166 | - $display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null |
|
167 | - ? $CFG->EED_Event_Single->display_order_datetimes |
|
168 | - : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
169 | - $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null |
|
170 | - ? $CFG->EED_Event_Single->display_order_tickets |
|
171 | - : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
172 | - $display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null |
|
173 | - ? $CFG->EED_Event_Single->display_order_venue |
|
174 | - : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
175 | - $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
|
176 | - $CFG->EED_Event_Single->display_status_banner_single = $REQ['display_status_banner_single'] ?? false; |
|
177 | - $CFG->EED_Event_Single->display_venue = $REQ['display_venue'] ?? false; |
|
178 | - $CFG->EED_Event_Single->use_sortable_display_order = |
|
179 | - ! empty($REQ['EED_Events_Single_use_sortable_display_order']) |
|
180 | - ? absint($REQ['EED_Events_Single_use_sortable_display_order']) |
|
181 | - : 0; |
|
182 | - $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order |
|
183 | - ? $display_order_event |
|
184 | - : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
185 | - $CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order |
|
186 | - ? $display_order_datetimes |
|
187 | - : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
188 | - $CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order |
|
189 | - ? $display_order_tickets |
|
190 | - : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
191 | - $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order |
|
192 | - ? $display_order_venue |
|
193 | - : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
194 | - do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ); |
|
195 | - return $CFG; |
|
196 | - } |
|
146 | + /** |
|
147 | + * update_template_settings |
|
148 | + * |
|
149 | + * @param EE_Template_Config $CFG |
|
150 | + * @param array $REQ |
|
151 | + * @return EE_Template_Config |
|
152 | + */ |
|
153 | + public static function update_template_settings(EE_Template_Config $CFG, $REQ): EE_Template_Config |
|
154 | + { |
|
155 | + /** @var EE_Capabilities $capabilities */ |
|
156 | + $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
|
157 | + if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
158 | + wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
159 | + } |
|
160 | + if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) { |
|
161 | + $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
|
162 | + } |
|
163 | + $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
|
164 | + ? $CFG->EED_Event_Single->display_order_event |
|
165 | + : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
166 | + $display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null |
|
167 | + ? $CFG->EED_Event_Single->display_order_datetimes |
|
168 | + : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
169 | + $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null |
|
170 | + ? $CFG->EED_Event_Single->display_order_tickets |
|
171 | + : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
172 | + $display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null |
|
173 | + ? $CFG->EED_Event_Single->display_order_venue |
|
174 | + : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
175 | + $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
|
176 | + $CFG->EED_Event_Single->display_status_banner_single = $REQ['display_status_banner_single'] ?? false; |
|
177 | + $CFG->EED_Event_Single->display_venue = $REQ['display_venue'] ?? false; |
|
178 | + $CFG->EED_Event_Single->use_sortable_display_order = |
|
179 | + ! empty($REQ['EED_Events_Single_use_sortable_display_order']) |
|
180 | + ? absint($REQ['EED_Events_Single_use_sortable_display_order']) |
|
181 | + : 0; |
|
182 | + $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order |
|
183 | + ? $display_order_event |
|
184 | + : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
185 | + $CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order |
|
186 | + ? $display_order_datetimes |
|
187 | + : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
188 | + $CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order |
|
189 | + ? $display_order_tickets |
|
190 | + : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
191 | + $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order |
|
192 | + ? $display_order_venue |
|
193 | + : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
194 | + do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ); |
|
195 | + return $CFG; |
|
196 | + } |
|
197 | 197 | |
198 | 198 | |
199 | - /** |
|
200 | - * @return void |
|
201 | - * @throws EE_Error |
|
202 | - * @throws ReflectionException |
|
203 | - */ |
|
204 | - public static function update_event_single_order() |
|
205 | - { |
|
206 | - /** @var EE_Capabilities $capabilities */ |
|
207 | - $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
|
208 | - if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
209 | - wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
210 | - } |
|
211 | - if ( |
|
212 | - ! isset(EE_Registry::instance()->CFG->template_settings->EED_Event_Single) |
|
213 | - || ! EE_Registry::instance()->CFG->template_settings->EED_Event_Single instanceof EE_Event_Single_Config |
|
214 | - ) { |
|
215 | - EE_Registry::instance()->CFG->template_settings->EED_Event_Single = new EE_Event_Single_Config(); |
|
216 | - } |
|
217 | - $config_saved = false; |
|
218 | - $template_parts = EED_Event_Single_Caff::getRequest()->getRequestParam('elements'); |
|
219 | - if (! empty($template_parts)) { |
|
220 | - $template_parts = explode(',', trim($template_parts, ',')); |
|
221 | - foreach ($template_parts as $key => $template_part) { |
|
222 | - $template_part = |
|
223 | - "display_order_$template_part"; |
|
224 | - $priority = |
|
225 | - ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
226 | - EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority; |
|
227 | - do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority); |
|
228 | - } |
|
229 | - $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false); |
|
230 | - } |
|
231 | - if ($config_saved) { |
|
232 | - EE_Error::add_success(esc_html__('Display Order has been successfully updated.', 'event_espresso')); |
|
233 | - } else { |
|
234 | - EE_Error::add_error( |
|
235 | - esc_html__('Display Order was not updated.', 'event_espresso'), |
|
236 | - __FILE__, |
|
237 | - __FUNCTION__, |
|
238 | - __LINE__ |
|
239 | - ); |
|
240 | - } |
|
241 | - echo wp_json_encode(EE_Error::get_notices(false)); |
|
242 | - exit(); |
|
243 | - } |
|
199 | + /** |
|
200 | + * @return void |
|
201 | + * @throws EE_Error |
|
202 | + * @throws ReflectionException |
|
203 | + */ |
|
204 | + public static function update_event_single_order() |
|
205 | + { |
|
206 | + /** @var EE_Capabilities $capabilities */ |
|
207 | + $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
|
208 | + if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
209 | + wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
210 | + } |
|
211 | + if ( |
|
212 | + ! isset(EE_Registry::instance()->CFG->template_settings->EED_Event_Single) |
|
213 | + || ! EE_Registry::instance()->CFG->template_settings->EED_Event_Single instanceof EE_Event_Single_Config |
|
214 | + ) { |
|
215 | + EE_Registry::instance()->CFG->template_settings->EED_Event_Single = new EE_Event_Single_Config(); |
|
216 | + } |
|
217 | + $config_saved = false; |
|
218 | + $template_parts = EED_Event_Single_Caff::getRequest()->getRequestParam('elements'); |
|
219 | + if (! empty($template_parts)) { |
|
220 | + $template_parts = explode(',', trim($template_parts, ',')); |
|
221 | + foreach ($template_parts as $key => $template_part) { |
|
222 | + $template_part = |
|
223 | + "display_order_$template_part"; |
|
224 | + $priority = |
|
225 | + ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
226 | + EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority; |
|
227 | + do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority); |
|
228 | + } |
|
229 | + $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false); |
|
230 | + } |
|
231 | + if ($config_saved) { |
|
232 | + EE_Error::add_success(esc_html__('Display Order has been successfully updated.', 'event_espresso')); |
|
233 | + } else { |
|
234 | + EE_Error::add_error( |
|
235 | + esc_html__('Display Order was not updated.', 'event_espresso'), |
|
236 | + __FILE__, |
|
237 | + __FUNCTION__, |
|
238 | + __LINE__ |
|
239 | + ); |
|
240 | + } |
|
241 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
242 | + exit(); |
|
243 | + } |
|
244 | 244 | |
245 | 245 | |
246 | - /** |
|
247 | - * run - initial module setup |
|
248 | - * |
|
249 | - * @access public |
|
250 | - * @param WP $WP |
|
251 | - * @return void |
|
252 | - */ |
|
253 | - public function run($WP) |
|
254 | - { |
|
255 | - } |
|
246 | + /** |
|
247 | + * run - initial module setup |
|
248 | + * |
|
249 | + * @access public |
|
250 | + * @param WP $WP |
|
251 | + * @return void |
|
252 | + */ |
|
253 | + public function run($WP) |
|
254 | + { |
|
255 | + } |
|
256 | 256 | } |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | { |
77 | 77 | wp_register_style( |
78 | 78 | 'eed-event-single-sortable', |
79 | - EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', |
|
79 | + EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.css', |
|
80 | 80 | [], |
81 | 81 | EVENT_ESPRESSO_VERSION |
82 | 82 | ); |
83 | 83 | wp_enqueue_style('eed-event-single-sortable'); |
84 | 84 | wp_register_script( |
85 | 85 | 'eed-event-single-sortable', |
86 | - EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', |
|
86 | + EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.js', |
|
87 | 87 | ['espresso_core', 'jquery-ui-sortable'], |
88 | 88 | EVENT_ESPRESSO_VERSION, |
89 | 89 | true |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public static function setDefinitions() |
99 | 99 | { |
100 | - if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) { |
|
101 | - define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
102 | - define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
100 | + if ( ! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) { |
|
101 | + define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates/'); |
|
102 | + define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config); |
124 | 124 | |
125 | 125 | $event_single_order_array = []; |
126 | - $event_single_order_array[ $config->display_order_tickets ] = 'tickets'; |
|
127 | - $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes'; |
|
128 | - $event_single_order_array[ $config->display_order_event ] = 'event'; |
|
129 | - $event_single_order_array[ $config->display_order_venue ] = 'venue'; |
|
126 | + $event_single_order_array[$config->display_order_tickets] = 'tickets'; |
|
127 | + $event_single_order_array[$config->display_order_datetimes] = 'datetimes'; |
|
128 | + $event_single_order_array[$config->display_order_event] = 'event'; |
|
129 | + $event_single_order_array[$config->display_order_venue] = 'venue'; |
|
130 | 130 | // get template parts |
131 | 131 | $template_parts = EED_Event_Single::instance()->initialize_template_parts($config); |
132 | 132 | // convert to array so that we can add more properties |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'single-sortable-li single-sortable-js' |
138 | 138 | ); |
139 | 139 | EEH_Template::display_template( |
140 | - EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', |
|
140 | + EVENT_SINGLE_CAFF_TEMPLATES_PATH.'admin-event-single-settings.template.php', |
|
141 | 141 | $config |
142 | 142 | ); |
143 | 143 | } |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | { |
155 | 155 | /** @var EE_Capabilities $capabilities */ |
156 | 156 | $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
157 | - if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
157 | + if ( ! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
158 | 158 | wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
159 | 159 | } |
160 | - if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) { |
|
160 | + if ( ! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) { |
|
161 | 161 | $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
162 | 162 | } |
163 | 163 | $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | { |
206 | 206 | /** @var EE_Capabilities $capabilities */ |
207 | 207 | $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
208 | - if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
208 | + if ( ! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
209 | 209 | wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
210 | 210 | } |
211 | 211 | if ( |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | $config_saved = false; |
218 | 218 | $template_parts = EED_Event_Single_Caff::getRequest()->getRequestParam('elements'); |
219 | - if (! empty($template_parts)) { |
|
219 | + if ( ! empty($template_parts)) { |
|
220 | 220 | $template_parts = explode(',', trim($template_parts, ',')); |
221 | 221 | foreach ($template_parts as $key => $template_part) { |
222 | 222 | $template_part = |
@@ -14,275 +14,275 @@ |
||
14 | 14 | */ |
15 | 15 | class EED_Events_Archive_Caff extends EED_Events_Archive |
16 | 16 | { |
17 | - /** |
|
18 | - * @return EED_Events_Archive_Caff|EED_Module |
|
19 | - * @throws EE_Error |
|
20 | - * @throws ReflectionException |
|
21 | - */ |
|
22 | - public static function instance() |
|
23 | - { |
|
24 | - return parent::get_instance(__CLASS__); |
|
25 | - } |
|
17 | + /** |
|
18 | + * @return EED_Events_Archive_Caff|EED_Module |
|
19 | + * @throws EE_Error |
|
20 | + * @throws ReflectionException |
|
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 | - } |
|
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 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
40 | - * |
|
41 | - * @access public |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public static function set_hooks_admin() |
|
45 | - { |
|
46 | - self::setDefinitions(); |
|
47 | - add_action( |
|
48 | - 'AHEE__template_settings__template__before_settings_form', |
|
49 | - ['EED_Events_Archive_Caff', 'template_settings_form'] |
|
50 | - ); |
|
51 | - add_filter( |
|
52 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
53 | - ['EED_Events_Archive_Caff', 'update_template_settings'], |
|
54 | - 10, |
|
55 | - 2 |
|
56 | - ); |
|
57 | - // AJAX |
|
58 | - add_action( |
|
59 | - 'wp_ajax_espresso_update_event_archive_order', |
|
60 | - ['EED_Events_Archive_Caff', 'update_event_archive_order'] |
|
61 | - ); |
|
62 | - add_action( |
|
63 | - 'wp_ajax_nopriv_espresso_update_event_archive_order', |
|
64 | - ['EED_Events_Archive_Caff', 'update_event_archive_order'] |
|
65 | - ); |
|
66 | - } |
|
38 | + /** |
|
39 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
40 | + * |
|
41 | + * @access public |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public static function set_hooks_admin() |
|
45 | + { |
|
46 | + self::setDefinitions(); |
|
47 | + add_action( |
|
48 | + 'AHEE__template_settings__template__before_settings_form', |
|
49 | + ['EED_Events_Archive_Caff', 'template_settings_form'] |
|
50 | + ); |
|
51 | + add_filter( |
|
52 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
53 | + ['EED_Events_Archive_Caff', 'update_template_settings'], |
|
54 | + 10, |
|
55 | + 2 |
|
56 | + ); |
|
57 | + // AJAX |
|
58 | + add_action( |
|
59 | + 'wp_ajax_espresso_update_event_archive_order', |
|
60 | + ['EED_Events_Archive_Caff', 'update_event_archive_order'] |
|
61 | + ); |
|
62 | + add_action( |
|
63 | + 'wp_ajax_nopriv_espresso_update_event_archive_order', |
|
64 | + ['EED_Events_Archive_Caff', 'update_event_archive_order'] |
|
65 | + ); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * run - initial module setup |
|
71 | - * |
|
72 | - * @param WP $WP |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - public function run($WP) |
|
76 | - { |
|
77 | - } |
|
69 | + /** |
|
70 | + * run - initial module setup |
|
71 | + * |
|
72 | + * @param WP $WP |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + public function run($WP) |
|
76 | + { |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * Conditionally set constants if they haven't been defined yet. |
|
82 | - */ |
|
83 | - public static function setDefinitions() |
|
84 | - { |
|
85 | - if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) { |
|
86 | - define('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
87 | - define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
88 | - } |
|
89 | - } |
|
80 | + /** |
|
81 | + * Conditionally set constants if they haven't been defined yet. |
|
82 | + */ |
|
83 | + public static function setDefinitions() |
|
84 | + { |
|
85 | + if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) { |
|
86 | + define('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
87 | + define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * @return void |
|
94 | - * @throws EE_Error |
|
95 | - * @throws ReflectionException |
|
96 | - */ |
|
97 | - public static function template_settings_form() |
|
98 | - { |
|
99 | - /** @var EE_Admin_Page_Loader $admin_page_loader */ |
|
100 | - $admin_page_loader = LoaderFactory::getLoader()->getShared('EE_Admin_Page_Loader'); |
|
101 | - // grab general settings admin page and remove the existing hook callback |
|
102 | - $gen_set_admin = $admin_page_loader->get_admin_page_object('general_settings'); |
|
103 | - if ($gen_set_admin instanceof General_Settings_Admin_Page) { |
|
104 | - remove_action( |
|
105 | - 'AHEE__template_settings__template__before_settings_form', |
|
106 | - [$gen_set_admin, 'template_settings_caff_features'], |
|
107 | - 100 |
|
108 | - ); |
|
109 | - } |
|
92 | + /** |
|
93 | + * @return void |
|
94 | + * @throws EE_Error |
|
95 | + * @throws ReflectionException |
|
96 | + */ |
|
97 | + public static function template_settings_form() |
|
98 | + { |
|
99 | + /** @var EE_Admin_Page_Loader $admin_page_loader */ |
|
100 | + $admin_page_loader = LoaderFactory::getLoader()->getShared('EE_Admin_Page_Loader'); |
|
101 | + // grab general settings admin page and remove the existing hook callback |
|
102 | + $gen_set_admin = $admin_page_loader->get_admin_page_object('general_settings'); |
|
103 | + if ($gen_set_admin instanceof General_Settings_Admin_Page) { |
|
104 | + remove_action( |
|
105 | + 'AHEE__template_settings__template__before_settings_form', |
|
106 | + [$gen_set_admin, 'template_settings_caff_features'], |
|
107 | + 100 |
|
108 | + ); |
|
109 | + } |
|
110 | 110 | |
111 | - // first just grab the template settings |
|
112 | - $config = EE_Registry::instance()->CFG->template_settings; |
|
113 | - // then if the Event Archive config is valid, use that, else create a new one |
|
114 | - $config = $config instanceof EE_Template_Config |
|
115 | - && $config->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
116 | - ? $config->EED_Events_Archive |
|
117 | - : new EE_Events_Archive_Config(); |
|
118 | - /** @var EE_Events_Archive_Config $config */ |
|
119 | - $config = apply_filters( |
|
120 | - 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
|
121 | - $config |
|
122 | - ); |
|
111 | + // first just grab the template settings |
|
112 | + $config = EE_Registry::instance()->CFG->template_settings; |
|
113 | + // then if the Event Archive config is valid, use that, else create a new one |
|
114 | + $config = $config instanceof EE_Template_Config |
|
115 | + && $config->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
116 | + ? $config->EED_Events_Archive |
|
117 | + : new EE_Events_Archive_Config(); |
|
118 | + /** @var EE_Events_Archive_Config $config */ |
|
119 | + $config = apply_filters( |
|
120 | + 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
|
121 | + $config |
|
122 | + ); |
|
123 | 123 | |
124 | - $config->display_status_banner = $config->display_status_banner ?? false; |
|
125 | - $config->display_description = $config->display_description ?? true; |
|
126 | - $config->display_ticket_selector = $config->display_ticket_selector ?? false; |
|
127 | - $config->display_datetimes = $config->display_datetimes ?? true; |
|
128 | - $config->display_venue = $config->display_venue ?? false; |
|
129 | - $config->display_expired_events = $config->display_expired_events ?? false; |
|
130 | - $config->display_events_with_expired_tickets = $config->display_events_with_expired_tickets ?? false; |
|
131 | - // display order options |
|
132 | - $config->use_sortable_display_order = $config->use_sortable_display_order ?? false; |
|
133 | - $config->display_order_event = $config->display_order_event ?? 100; |
|
134 | - $config->display_order_datetimes = $config->display_order_datetimes ?? 110; |
|
135 | - $config->display_order_tickets = $config->display_order_tickets ?? 120; |
|
136 | - $config->display_order_venue = $config->display_order_venue ?? 130; |
|
124 | + $config->display_status_banner = $config->display_status_banner ?? false; |
|
125 | + $config->display_description = $config->display_description ?? true; |
|
126 | + $config->display_ticket_selector = $config->display_ticket_selector ?? false; |
|
127 | + $config->display_datetimes = $config->display_datetimes ?? true; |
|
128 | + $config->display_venue = $config->display_venue ?? false; |
|
129 | + $config->display_expired_events = $config->display_expired_events ?? false; |
|
130 | + $config->display_events_with_expired_tickets = $config->display_events_with_expired_tickets ?? false; |
|
131 | + // display order options |
|
132 | + $config->use_sortable_display_order = $config->use_sortable_display_order ?? false; |
|
133 | + $config->display_order_event = $config->display_order_event ?? 100; |
|
134 | + $config->display_order_datetimes = $config->display_order_datetimes ?? 110; |
|
135 | + $config->display_order_tickets = $config->display_order_tickets ?? 120; |
|
136 | + $config->display_order_venue = $config->display_order_venue ?? 130; |
|
137 | 137 | |
138 | - // get template parts |
|
139 | - $template_parts = EED_Events_Archive::instance()->initialize_template_parts($config); |
|
140 | - // convert to array so that we can add more properties |
|
141 | - $config = get_object_vars($config); |
|
142 | - $config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts( |
|
143 | - 'event-archive-sortable-js', |
|
144 | - '', |
|
145 | - 'archive-sortable-li archive-sortable-js' |
|
146 | - ); |
|
147 | - EEH_Template::display_template( |
|
148 | - EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
149 | - $config |
|
150 | - ); |
|
151 | - } |
|
138 | + // get template parts |
|
139 | + $template_parts = EED_Events_Archive::instance()->initialize_template_parts($config); |
|
140 | + // convert to array so that we can add more properties |
|
141 | + $config = get_object_vars($config); |
|
142 | + $config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts( |
|
143 | + 'event-archive-sortable-js', |
|
144 | + '', |
|
145 | + 'archive-sortable-li archive-sortable-js' |
|
146 | + ); |
|
147 | + EEH_Template::display_template( |
|
148 | + EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
149 | + $config |
|
150 | + ); |
|
151 | + } |
|
152 | 152 | |
153 | 153 | |
154 | - /** |
|
155 | - * @param EE_Template_Config $CFG |
|
156 | - * @param array $REQ |
|
157 | - * @return EE_Template_Config |
|
158 | - */ |
|
159 | - public static function update_template_settings(EE_Template_Config $CFG, array $REQ): EE_Template_Config |
|
160 | - { |
|
161 | - /** @var EE_Capabilities $capabilities */ |
|
162 | - $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
|
163 | - if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
164 | - wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
165 | - } |
|
166 | - $request = EED_Module::getRequest(); |
|
167 | - $reset_event_list_settings = $request->getRequestParam( |
|
168 | - 'EED_Events_Archive_reset_event_list_settings', |
|
169 | - false, |
|
170 | - DataType::BOOL |
|
171 | - ); |
|
172 | - if ($reset_event_list_settings) { |
|
173 | - $config = new EE_Events_Archive_Config(); |
|
174 | - return EED_Events_Archive_Caff::afterUpdateTemplateSettings($CFG, $config, $REQ); |
|
175 | - } |
|
176 | - /** @var EE_Events_Archive_Config $config */ |
|
177 | - $config = $CFG->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
178 | - ? $CFG->EED_Events_Archive |
|
179 | - : new EE_Events_Archive_Config(); |
|
154 | + /** |
|
155 | + * @param EE_Template_Config $CFG |
|
156 | + * @param array $REQ |
|
157 | + * @return EE_Template_Config |
|
158 | + */ |
|
159 | + public static function update_template_settings(EE_Template_Config $CFG, array $REQ): EE_Template_Config |
|
160 | + { |
|
161 | + /** @var EE_Capabilities $capabilities */ |
|
162 | + $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
|
163 | + if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
164 | + wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
165 | + } |
|
166 | + $request = EED_Module::getRequest(); |
|
167 | + $reset_event_list_settings = $request->getRequestParam( |
|
168 | + 'EED_Events_Archive_reset_event_list_settings', |
|
169 | + false, |
|
170 | + DataType::BOOL |
|
171 | + ); |
|
172 | + if ($reset_event_list_settings) { |
|
173 | + $config = new EE_Events_Archive_Config(); |
|
174 | + return EED_Events_Archive_Caff::afterUpdateTemplateSettings($CFG, $config, $REQ); |
|
175 | + } |
|
176 | + /** @var EE_Events_Archive_Config $config */ |
|
177 | + $config = $CFG->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
178 | + ? $CFG->EED_Events_Archive |
|
179 | + : new EE_Events_Archive_Config(); |
|
180 | 180 | |
181 | - $config->display_status_banner = $request->getRequestParam( |
|
182 | - 'EED_Events_Archive_display_status_banner', |
|
183 | - false, |
|
184 | - DataType::BOOL |
|
185 | - ); |
|
186 | - $config->display_description = $request->getRequestParam( |
|
187 | - 'EED_Events_Archive_display_description', |
|
188 | - 1, |
|
189 | - DataType::INT |
|
190 | - ); |
|
191 | - $config->display_ticket_selector = $request->getRequestParam( |
|
192 | - 'EED_Events_Archive_display_ticket_selector', |
|
193 | - false, |
|
194 | - DataType::BOOL |
|
195 | - ); |
|
196 | - $config->display_datetimes = $request->getRequestParam( |
|
197 | - 'EED_Events_Archive_display_datetimes', |
|
198 | - true, |
|
199 | - DataType::BOOL |
|
200 | - ); |
|
201 | - $config->display_venue = $request->getRequestParam( |
|
202 | - 'EED_Events_Archive_display_venue', |
|
203 | - false, |
|
204 | - DataType::BOOL |
|
205 | - ); |
|
206 | - $config->display_expired_events = $request->getRequestParam( |
|
207 | - 'EED_Events_Archive_display_expired_events', |
|
208 | - false, |
|
209 | - DataType::BOOL |
|
210 | - ); |
|
211 | - $config->display_events_with_expired_tickets = $request->getRequestParam( |
|
212 | - 'EED_Events_Archive_display_events_with_expired_tickets', |
|
213 | - false, |
|
214 | - DataType::BOOL |
|
215 | - ); |
|
216 | - $config->use_sortable_display_order = $request->getRequestParam( |
|
217 | - 'EED_Events_Archive_use_sortable_display_order', |
|
218 | - false, |
|
219 | - DataType::BOOL |
|
220 | - ); |
|
221 | - if (! $config->use_sortable_display_order) { |
|
222 | - $config->display_order_event = EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
223 | - $config->display_order_datetimes = EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
|
224 | - $config->display_order_tickets = EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
|
225 | - $config->display_order_venue = EED_Events_Archive::EVENT_VENUES_PRIORITY; |
|
226 | - } |
|
181 | + $config->display_status_banner = $request->getRequestParam( |
|
182 | + 'EED_Events_Archive_display_status_banner', |
|
183 | + false, |
|
184 | + DataType::BOOL |
|
185 | + ); |
|
186 | + $config->display_description = $request->getRequestParam( |
|
187 | + 'EED_Events_Archive_display_description', |
|
188 | + 1, |
|
189 | + DataType::INT |
|
190 | + ); |
|
191 | + $config->display_ticket_selector = $request->getRequestParam( |
|
192 | + 'EED_Events_Archive_display_ticket_selector', |
|
193 | + false, |
|
194 | + DataType::BOOL |
|
195 | + ); |
|
196 | + $config->display_datetimes = $request->getRequestParam( |
|
197 | + 'EED_Events_Archive_display_datetimes', |
|
198 | + true, |
|
199 | + DataType::BOOL |
|
200 | + ); |
|
201 | + $config->display_venue = $request->getRequestParam( |
|
202 | + 'EED_Events_Archive_display_venue', |
|
203 | + false, |
|
204 | + DataType::BOOL |
|
205 | + ); |
|
206 | + $config->display_expired_events = $request->getRequestParam( |
|
207 | + 'EED_Events_Archive_display_expired_events', |
|
208 | + false, |
|
209 | + DataType::BOOL |
|
210 | + ); |
|
211 | + $config->display_events_with_expired_tickets = $request->getRequestParam( |
|
212 | + 'EED_Events_Archive_display_events_with_expired_tickets', |
|
213 | + false, |
|
214 | + DataType::BOOL |
|
215 | + ); |
|
216 | + $config->use_sortable_display_order = $request->getRequestParam( |
|
217 | + 'EED_Events_Archive_use_sortable_display_order', |
|
218 | + false, |
|
219 | + DataType::BOOL |
|
220 | + ); |
|
221 | + if (! $config->use_sortable_display_order) { |
|
222 | + $config->display_order_event = EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
223 | + $config->display_order_datetimes = EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
|
224 | + $config->display_order_tickets = EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
|
225 | + $config->display_order_venue = EED_Events_Archive::EVENT_VENUES_PRIORITY; |
|
226 | + } |
|
227 | 227 | |
228 | - return EED_Events_Archive_Caff::afterUpdateTemplateSettings($CFG, $config, $REQ); |
|
229 | - } |
|
228 | + return EED_Events_Archive_Caff::afterUpdateTemplateSettings($CFG, $config, $REQ); |
|
229 | + } |
|
230 | 230 | |
231 | 231 | |
232 | - private static function afterUpdateTemplateSettings( |
|
233 | - EE_Template_Config $CFG, |
|
234 | - EE_Events_Archive_Config $config, |
|
235 | - array $REQ |
|
236 | - ): EE_Template_Config { |
|
237 | - $CFG->EED_Events_Archive = $config; |
|
238 | - do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ); |
|
239 | - return $CFG; |
|
240 | - } |
|
232 | + private static function afterUpdateTemplateSettings( |
|
233 | + EE_Template_Config $CFG, |
|
234 | + EE_Events_Archive_Config $config, |
|
235 | + array $REQ |
|
236 | + ): EE_Template_Config { |
|
237 | + $CFG->EED_Events_Archive = $config; |
|
238 | + do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ); |
|
239 | + return $CFG; |
|
240 | + } |
|
241 | 241 | |
242 | 242 | |
243 | - /** |
|
244 | - * @return void |
|
245 | - * @throws EE_Error |
|
246 | - * @throws ReflectionException |
|
247 | - */ |
|
248 | - public static function update_event_archive_order() |
|
249 | - { |
|
250 | - /** @var EE_Capabilities $capabilities */ |
|
251 | - $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
|
252 | - if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
253 | - wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
254 | - } |
|
255 | - $config = EE_Registry::instance()->CFG; |
|
256 | - $config_saved = false; |
|
257 | - $template_parts = EED_Events_Archive_Caff::getRequest()->getRequestParam('elements'); |
|
258 | - if (! empty($template_parts)) { |
|
259 | - $template_parts = explode(',', trim($template_parts, ',')); |
|
260 | - foreach ($template_parts as $key => $template_part) { |
|
261 | - $template_part = "display_order_$template_part"; |
|
262 | - $priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
263 | - if ( |
|
264 | - $config->template_settings->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
265 | - && property_exists( |
|
266 | - $config->template_settings->EED_Events_Archive, |
|
267 | - $template_part |
|
268 | - ) |
|
269 | - ) { |
|
270 | - $config->template_settings->EED_Events_Archive->{$template_part} = $priority; |
|
271 | - } |
|
272 | - do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority); |
|
273 | - } |
|
274 | - $config_saved = $config->update_espresso_config(false, false); |
|
275 | - } |
|
276 | - if ($config_saved) { |
|
277 | - EE_Error::add_success(esc_html__('Display Order has been successfully updated.', 'event_espresso')); |
|
278 | - } else { |
|
279 | - EE_Error::add_error( |
|
280 | - esc_html__('Display Order was not updated.', 'event_espresso'), |
|
281 | - __FILE__, |
|
282 | - __FUNCTION__, |
|
283 | - __LINE__ |
|
284 | - ); |
|
285 | - } |
|
286 | - wp_send_json(EE_Error::get_notices(false)); |
|
287 | - } |
|
243 | + /** |
|
244 | + * @return void |
|
245 | + * @throws EE_Error |
|
246 | + * @throws ReflectionException |
|
247 | + */ |
|
248 | + public static function update_event_archive_order() |
|
249 | + { |
|
250 | + /** @var EE_Capabilities $capabilities */ |
|
251 | + $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
|
252 | + if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
253 | + wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
254 | + } |
|
255 | + $config = EE_Registry::instance()->CFG; |
|
256 | + $config_saved = false; |
|
257 | + $template_parts = EED_Events_Archive_Caff::getRequest()->getRequestParam('elements'); |
|
258 | + if (! empty($template_parts)) { |
|
259 | + $template_parts = explode(',', trim($template_parts, ',')); |
|
260 | + foreach ($template_parts as $key => $template_part) { |
|
261 | + $template_part = "display_order_$template_part"; |
|
262 | + $priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
263 | + if ( |
|
264 | + $config->template_settings->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
265 | + && property_exists( |
|
266 | + $config->template_settings->EED_Events_Archive, |
|
267 | + $template_part |
|
268 | + ) |
|
269 | + ) { |
|
270 | + $config->template_settings->EED_Events_Archive->{$template_part} = $priority; |
|
271 | + } |
|
272 | + do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority); |
|
273 | + } |
|
274 | + $config_saved = $config->update_espresso_config(false, false); |
|
275 | + } |
|
276 | + if ($config_saved) { |
|
277 | + EE_Error::add_success(esc_html__('Display Order has been successfully updated.', 'event_espresso')); |
|
278 | + } else { |
|
279 | + EE_Error::add_error( |
|
280 | + esc_html__('Display Order was not updated.', 'event_espresso'), |
|
281 | + __FILE__, |
|
282 | + __FUNCTION__, |
|
283 | + __LINE__ |
|
284 | + ); |
|
285 | + } |
|
286 | + wp_send_json(EE_Error::get_notices(false)); |
|
287 | + } |
|
288 | 288 | } |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public static function setDefinitions() |
84 | 84 | { |
85 | - if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) { |
|
86 | - define('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
87 | - define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
85 | + if ( ! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) { |
|
86 | + define('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates/'); |
|
87 | + define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'archive-sortable-li archive-sortable-js' |
146 | 146 | ); |
147 | 147 | EEH_Template::display_template( |
148 | - EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
148 | + EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH.'admin-event-list-settings.template.php', |
|
149 | 149 | $config |
150 | 150 | ); |
151 | 151 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | { |
161 | 161 | /** @var EE_Capabilities $capabilities */ |
162 | 162 | $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
163 | - if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
163 | + if ( ! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
164 | 164 | wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
165 | 165 | } |
166 | 166 | $request = EED_Module::getRequest(); |
@@ -178,32 +178,32 @@ discard block |
||
178 | 178 | ? $CFG->EED_Events_Archive |
179 | 179 | : new EE_Events_Archive_Config(); |
180 | 180 | |
181 | - $config->display_status_banner = $request->getRequestParam( |
|
181 | + $config->display_status_banner = $request->getRequestParam( |
|
182 | 182 | 'EED_Events_Archive_display_status_banner', |
183 | 183 | false, |
184 | 184 | DataType::BOOL |
185 | 185 | ); |
186 | - $config->display_description = $request->getRequestParam( |
|
186 | + $config->display_description = $request->getRequestParam( |
|
187 | 187 | 'EED_Events_Archive_display_description', |
188 | 188 | 1, |
189 | 189 | DataType::INT |
190 | 190 | ); |
191 | - $config->display_ticket_selector = $request->getRequestParam( |
|
191 | + $config->display_ticket_selector = $request->getRequestParam( |
|
192 | 192 | 'EED_Events_Archive_display_ticket_selector', |
193 | 193 | false, |
194 | 194 | DataType::BOOL |
195 | 195 | ); |
196 | - $config->display_datetimes = $request->getRequestParam( |
|
196 | + $config->display_datetimes = $request->getRequestParam( |
|
197 | 197 | 'EED_Events_Archive_display_datetimes', |
198 | 198 | true, |
199 | 199 | DataType::BOOL |
200 | 200 | ); |
201 | - $config->display_venue = $request->getRequestParam( |
|
201 | + $config->display_venue = $request->getRequestParam( |
|
202 | 202 | 'EED_Events_Archive_display_venue', |
203 | 203 | false, |
204 | 204 | DataType::BOOL |
205 | 205 | ); |
206 | - $config->display_expired_events = $request->getRequestParam( |
|
206 | + $config->display_expired_events = $request->getRequestParam( |
|
207 | 207 | 'EED_Events_Archive_display_expired_events', |
208 | 208 | false, |
209 | 209 | DataType::BOOL |
@@ -213,12 +213,12 @@ discard block |
||
213 | 213 | false, |
214 | 214 | DataType::BOOL |
215 | 215 | ); |
216 | - $config->use_sortable_display_order = $request->getRequestParam( |
|
216 | + $config->use_sortable_display_order = $request->getRequestParam( |
|
217 | 217 | 'EED_Events_Archive_use_sortable_display_order', |
218 | 218 | false, |
219 | 219 | DataType::BOOL |
220 | 220 | ); |
221 | - if (! $config->use_sortable_display_order) { |
|
221 | + if ( ! $config->use_sortable_display_order) { |
|
222 | 222 | $config->display_order_event = EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
223 | 223 | $config->display_order_datetimes = EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
224 | 224 | $config->display_order_tickets = EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
@@ -249,13 +249,13 @@ discard block |
||
249 | 249 | { |
250 | 250 | /** @var EE_Capabilities $capabilities */ |
251 | 251 | $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
252 | - if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
252 | + if ( ! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
253 | 253 | wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
254 | 254 | } |
255 | 255 | $config = EE_Registry::instance()->CFG; |
256 | 256 | $config_saved = false; |
257 | 257 | $template_parts = EED_Events_Archive_Caff::getRequest()->getRequestParam('elements'); |
258 | - if (! empty($template_parts)) { |
|
258 | + if ( ! empty($template_parts)) { |
|
259 | 259 | $template_parts = explode(',', trim($template_parts, ',')); |
260 | 260 | foreach ($template_parts as $key => $template_part) { |
261 | 261 | $template_part = "display_order_$template_part"; |
@@ -16,321 +16,321 @@ |
||
16 | 16 | */ |
17 | 17 | class EED_Ticket_Selector_Caff extends EED_Ticket_Selector |
18 | 18 | { |
19 | - /** |
|
20 | - * @return EED_Module|EED_Ticket_Selector_Caff |
|
21 | - * @throws EE_Error |
|
22 | - * @throws ReflectionException |
|
23 | - */ |
|
24 | - public static function instance() |
|
25 | - { |
|
26 | - return EED_Module::get_instance(__CLASS__); |
|
27 | - } |
|
19 | + /** |
|
20 | + * @return EED_Module|EED_Ticket_Selector_Caff |
|
21 | + * @throws EE_Error |
|
22 | + * @throws ReflectionException |
|
23 | + */ |
|
24 | + public static function instance() |
|
25 | + { |
|
26 | + return EED_Module::get_instance(__CLASS__); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
32 | - * |
|
33 | - * @access public |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public static function set_hooks() |
|
37 | - { |
|
38 | - add_action( |
|
39 | - 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
40 | - array('EED_Ticket_Selector_Caff', 'ticket_price_details'), |
|
41 | - 10, |
|
42 | - 3 |
|
43 | - ); |
|
44 | - } |
|
30 | + /** |
|
31 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
32 | + * |
|
33 | + * @access public |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public static function set_hooks() |
|
37 | + { |
|
38 | + add_action( |
|
39 | + 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
40 | + array('EED_Ticket_Selector_Caff', 'ticket_price_details'), |
|
41 | + 10, |
|
42 | + 3 |
|
43 | + ); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
48 | - * |
|
49 | - * @access public |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public static function set_hooks_admin() |
|
53 | - { |
|
54 | - define( |
|
55 | - 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', |
|
56 | - str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/' |
|
57 | - ); |
|
58 | - add_action( |
|
59 | - 'AHEE__template_settings__template__before_settings_form', |
|
60 | - array('EED_Ticket_Selector_Caff', 'template_settings_form') |
|
61 | - ); |
|
62 | - add_filter( |
|
63 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
64 | - array('EED_Ticket_Selector_Caff', 'update_template_settings'), |
|
65 | - 10, |
|
66 | - 2 |
|
67 | - ); |
|
68 | - } |
|
46 | + /** |
|
47 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
48 | + * |
|
49 | + * @access public |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public static function set_hooks_admin() |
|
53 | + { |
|
54 | + define( |
|
55 | + 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', |
|
56 | + str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/' |
|
57 | + ); |
|
58 | + add_action( |
|
59 | + 'AHEE__template_settings__template__before_settings_form', |
|
60 | + array('EED_Ticket_Selector_Caff', 'template_settings_form') |
|
61 | + ); |
|
62 | + add_filter( |
|
63 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
64 | + array('EED_Ticket_Selector_Caff', 'update_template_settings'), |
|
65 | + 10, |
|
66 | + 2 |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @param WP $WP |
|
73 | - */ |
|
74 | - public function run($WP) |
|
75 | - { |
|
76 | - $this->set_config(); |
|
77 | - } |
|
71 | + /** |
|
72 | + * @param WP $WP |
|
73 | + */ |
|
74 | + public function run($WP) |
|
75 | + { |
|
76 | + $this->set_config(); |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * @static |
|
82 | - * @return void |
|
83 | - * @throws EE_Error |
|
84 | - * @throws ReflectionException |
|
85 | - */ |
|
86 | - public static function template_settings_form() |
|
87 | - { |
|
88 | - echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html(); |
|
89 | - } |
|
80 | + /** |
|
81 | + * @static |
|
82 | + * @return void |
|
83 | + * @throws EE_Error |
|
84 | + * @throws ReflectionException |
|
85 | + */ |
|
86 | + public static function template_settings_form() |
|
87 | + { |
|
88 | + echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html(); |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * @return EE_Form_Section_Proper |
|
94 | - * @throws EE_Error |
|
95 | - * @throws ReflectionException |
|
96 | - */ |
|
97 | - public static function _ticket_selector_settings_form(): EE_Form_Section_Proper |
|
98 | - { |
|
99 | - return new EE_Form_Section_Proper( |
|
100 | - array( |
|
101 | - 'name' => 'ticket_selector_settings_form', |
|
102 | - 'html_id' => 'ticket_selector_settings_form', |
|
103 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
104 | - 'subsections' => apply_filters( |
|
105 | - 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
|
106 | - array( |
|
107 | - 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
|
108 | - EEH_HTML::br(2) . |
|
109 | - EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
|
110 | - ), |
|
111 | - 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(), |
|
112 | - ) |
|
113 | - ), |
|
114 | - ) |
|
115 | - ); |
|
116 | - } |
|
92 | + /** |
|
93 | + * @return EE_Form_Section_Proper |
|
94 | + * @throws EE_Error |
|
95 | + * @throws ReflectionException |
|
96 | + */ |
|
97 | + public static function _ticket_selector_settings_form(): EE_Form_Section_Proper |
|
98 | + { |
|
99 | + return new EE_Form_Section_Proper( |
|
100 | + array( |
|
101 | + 'name' => 'ticket_selector_settings_form', |
|
102 | + 'html_id' => 'ticket_selector_settings_form', |
|
103 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
104 | + 'subsections' => apply_filters( |
|
105 | + 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
|
106 | + array( |
|
107 | + 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
|
108 | + EEH_HTML::br(2) . |
|
109 | + EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
|
110 | + ), |
|
111 | + 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(), |
|
112 | + ) |
|
113 | + ), |
|
114 | + ) |
|
115 | + ); |
|
116 | + } |
|
117 | 117 | |
118 | 118 | |
119 | - /** |
|
120 | - * @return EE_Form_Section_Proper |
|
121 | - * @throws EE_Error |
|
122 | - * @throws ReflectionException |
|
123 | - */ |
|
124 | - public static function _ticket_selector_appearance_settings(): EE_Form_Section_Proper |
|
125 | - { |
|
126 | - if ( |
|
127 | - ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
128 | - ) { |
|
129 | - EED_Ticket_Selector::instance()->set_config(); |
|
130 | - EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance() |
|
131 | - ->config(); |
|
132 | - } |
|
133 | - $EE_Ticket_Selector_Config = EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector; |
|
134 | - // get option for whether to show datetime selector in TS |
|
135 | - $show_datetime_selector = $EE_Ticket_Selector_Config->getShowDatetimeSelector(); |
|
136 | - // and option for how may datetimes must exist if display is conditional |
|
137 | - $datetime_selector_threshold = $EE_Ticket_Selector_Config->getDatetimeSelectorThreshold(); |
|
119 | + /** |
|
120 | + * @return EE_Form_Section_Proper |
|
121 | + * @throws EE_Error |
|
122 | + * @throws ReflectionException |
|
123 | + */ |
|
124 | + public static function _ticket_selector_appearance_settings(): EE_Form_Section_Proper |
|
125 | + { |
|
126 | + if ( |
|
127 | + ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
128 | + ) { |
|
129 | + EED_Ticket_Selector::instance()->set_config(); |
|
130 | + EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance() |
|
131 | + ->config(); |
|
132 | + } |
|
133 | + $EE_Ticket_Selector_Config = EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector; |
|
134 | + // get option for whether to show datetime selector in TS |
|
135 | + $show_datetime_selector = $EE_Ticket_Selector_Config->getShowDatetimeSelector(); |
|
136 | + // and option for how may datetimes must exist if display is conditional |
|
137 | + $datetime_selector_threshold = $EE_Ticket_Selector_Config->getDatetimeSelectorThreshold(); |
|
138 | 138 | |
139 | - return new EE_Form_Section_Proper( |
|
140 | - array( |
|
141 | - 'name' => 'ticket_selector_settings_tbl', |
|
142 | - 'html_id' => 'ticket_selector_settings_tbl', |
|
143 | - 'html_class' => 'form-table', |
|
144 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
145 | - 'subsections' => apply_filters( |
|
146 | - 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections', |
|
147 | - array( |
|
148 | - 'show_ticket_details' => new EE_Yes_No_Input( |
|
149 | - array( |
|
150 | - 'html_label_text' => esc_html__( |
|
151 | - 'Show Ticket Details?', |
|
152 | - 'event_espresso' |
|
153 | - ), |
|
154 | - 'html_help_text' => esc_html__( |
|
155 | - 'This lets you choose whether the extra ticket details section is displayed with the ticket selector.', |
|
156 | - 'event_espresso' |
|
157 | - ), |
|
158 | - 'default' => $EE_Ticket_Selector_Config->show_ticket_details ?? true, |
|
159 | - 'display_html_label_text' => false, |
|
160 | - ) |
|
161 | - ), |
|
162 | - 'show_ticket_sale_columns' => new EE_Yes_No_Input( |
|
163 | - array( |
|
164 | - 'html_label_text' => esc_html__( |
|
165 | - 'Show Ticket Sale Info?', |
|
166 | - 'event_espresso' |
|
167 | - ), |
|
168 | - 'html_help_text' => esc_html__( |
|
169 | - 'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', |
|
170 | - 'event_espresso' |
|
171 | - ), |
|
172 | - 'default' => $EE_Ticket_Selector_Config->show_ticket_sale_columns ?? true, |
|
173 | - 'display_html_label_text' => false, |
|
174 | - ) |
|
175 | - ), |
|
176 | - 'show_expired_tickets' => new EE_Yes_No_Input( |
|
177 | - array( |
|
178 | - 'html_label_text' => esc_html__( |
|
179 | - 'Show Expired Tickets?', |
|
180 | - 'event_espresso' |
|
181 | - ), |
|
182 | - 'html_help_text' => esc_html__( |
|
183 | - 'Indicate whether to show expired tickets in the ticket selector', |
|
184 | - 'event_espresso' |
|
185 | - ), |
|
186 | - 'default' => $EE_Ticket_Selector_Config->show_expired_tickets ?? true, |
|
187 | - 'display_html_label_text' => false, |
|
188 | - ) |
|
189 | - ), |
|
190 | - 'show_datetime_selector' => new EE_Select_Input( |
|
191 | - $EE_Ticket_Selector_Config->getShowDatetimeSelectorOptions(false), |
|
192 | - array( |
|
193 | - 'html_label_text' => esc_html__( |
|
194 | - 'Show Date & Time Filter?', |
|
195 | - 'event_espresso' |
|
196 | - ), |
|
197 | - 'html_help_text' => sprintf( |
|
198 | - esc_html__( |
|
199 | - 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s • %2$sdo not show date & time filter%3$s%1$s this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".', |
|
200 | - 'event_espresso' |
|
201 | - ), |
|
202 | - '<br>', |
|
203 | - '<strong>', |
|
204 | - '</strong>' |
|
205 | - ), |
|
206 | - 'default' => ! empty($show_datetime_selector) |
|
207 | - ? $show_datetime_selector |
|
208 | - : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
209 | - 'display_html_label_text' => false, |
|
210 | - 'html_class' => 'ee-input-width--reg', |
|
211 | - ) |
|
212 | - ), |
|
213 | - 'datetime_selector_threshold' => new EE_Select_Input( |
|
214 | - array_combine($r = range(1, 10), $r), |
|
215 | - array( |
|
216 | - 'html_label_text' => esc_html__( |
|
217 | - 'Date & Time Filter Threshold', |
|
218 | - 'event_espresso' |
|
219 | - ), |
|
220 | - 'html_help_text' => esc_html__( |
|
221 | - 'The number of unique dates an event has to have before conditionally displaying a date & time filter', |
|
222 | - 'event_espresso' |
|
223 | - ), |
|
224 | - 'default' => ! empty($datetime_selector_threshold) |
|
225 | - ? $datetime_selector_threshold |
|
226 | - : 3, |
|
227 | - 'display_html_label_text' => false, |
|
228 | - 'html_class' => 'ee-input-width--tiny', |
|
229 | - ) |
|
230 | - ), |
|
231 | - 'datetime_selector_max_checked' => new EE_Integer_Input( |
|
232 | - array( |
|
233 | - 'html_label_text' => esc_html__( |
|
234 | - 'Date & Time Filter Max Checked', |
|
235 | - 'event_espresso' |
|
236 | - ), |
|
237 | - 'html_help_text' => sprintf( |
|
238 | - esc_html__( |
|
239 | - 'Determines the maximum number of dates that will be checked upon initial loading for a Date and Time Filter.%1$sIf set to zero or left blank, then ALL dates will be checked upon initial loading.', |
|
240 | - 'event_espresso' |
|
241 | - ), |
|
242 | - '<br>' |
|
243 | - ), |
|
244 | - 'default' => $EE_Ticket_Selector_Config->getDatetimeSelectorMaxChecked(), |
|
245 | - 'display_html_label_text' => false, |
|
246 | - 'min_value' => 0, |
|
247 | - 'html_class' => 'ee-input-width--tiny', |
|
248 | - ) |
|
249 | - ), |
|
250 | - ) |
|
251 | - ), |
|
252 | - ) |
|
253 | - ); |
|
254 | - } |
|
139 | + return new EE_Form_Section_Proper( |
|
140 | + array( |
|
141 | + 'name' => 'ticket_selector_settings_tbl', |
|
142 | + 'html_id' => 'ticket_selector_settings_tbl', |
|
143 | + 'html_class' => 'form-table', |
|
144 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
145 | + 'subsections' => apply_filters( |
|
146 | + 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections', |
|
147 | + array( |
|
148 | + 'show_ticket_details' => new EE_Yes_No_Input( |
|
149 | + array( |
|
150 | + 'html_label_text' => esc_html__( |
|
151 | + 'Show Ticket Details?', |
|
152 | + 'event_espresso' |
|
153 | + ), |
|
154 | + 'html_help_text' => esc_html__( |
|
155 | + 'This lets you choose whether the extra ticket details section is displayed with the ticket selector.', |
|
156 | + 'event_espresso' |
|
157 | + ), |
|
158 | + 'default' => $EE_Ticket_Selector_Config->show_ticket_details ?? true, |
|
159 | + 'display_html_label_text' => false, |
|
160 | + ) |
|
161 | + ), |
|
162 | + 'show_ticket_sale_columns' => new EE_Yes_No_Input( |
|
163 | + array( |
|
164 | + 'html_label_text' => esc_html__( |
|
165 | + 'Show Ticket Sale Info?', |
|
166 | + 'event_espresso' |
|
167 | + ), |
|
168 | + 'html_help_text' => esc_html__( |
|
169 | + 'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', |
|
170 | + 'event_espresso' |
|
171 | + ), |
|
172 | + 'default' => $EE_Ticket_Selector_Config->show_ticket_sale_columns ?? true, |
|
173 | + 'display_html_label_text' => false, |
|
174 | + ) |
|
175 | + ), |
|
176 | + 'show_expired_tickets' => new EE_Yes_No_Input( |
|
177 | + array( |
|
178 | + 'html_label_text' => esc_html__( |
|
179 | + 'Show Expired Tickets?', |
|
180 | + 'event_espresso' |
|
181 | + ), |
|
182 | + 'html_help_text' => esc_html__( |
|
183 | + 'Indicate whether to show expired tickets in the ticket selector', |
|
184 | + 'event_espresso' |
|
185 | + ), |
|
186 | + 'default' => $EE_Ticket_Selector_Config->show_expired_tickets ?? true, |
|
187 | + 'display_html_label_text' => false, |
|
188 | + ) |
|
189 | + ), |
|
190 | + 'show_datetime_selector' => new EE_Select_Input( |
|
191 | + $EE_Ticket_Selector_Config->getShowDatetimeSelectorOptions(false), |
|
192 | + array( |
|
193 | + 'html_label_text' => esc_html__( |
|
194 | + 'Show Date & Time Filter?', |
|
195 | + 'event_espresso' |
|
196 | + ), |
|
197 | + 'html_help_text' => sprintf( |
|
198 | + esc_html__( |
|
199 | + 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s • %2$sdo not show date & time filter%3$s%1$s this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".', |
|
200 | + 'event_espresso' |
|
201 | + ), |
|
202 | + '<br>', |
|
203 | + '<strong>', |
|
204 | + '</strong>' |
|
205 | + ), |
|
206 | + 'default' => ! empty($show_datetime_selector) |
|
207 | + ? $show_datetime_selector |
|
208 | + : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
209 | + 'display_html_label_text' => false, |
|
210 | + 'html_class' => 'ee-input-width--reg', |
|
211 | + ) |
|
212 | + ), |
|
213 | + 'datetime_selector_threshold' => new EE_Select_Input( |
|
214 | + array_combine($r = range(1, 10), $r), |
|
215 | + array( |
|
216 | + 'html_label_text' => esc_html__( |
|
217 | + 'Date & Time Filter Threshold', |
|
218 | + 'event_espresso' |
|
219 | + ), |
|
220 | + 'html_help_text' => esc_html__( |
|
221 | + 'The number of unique dates an event has to have before conditionally displaying a date & time filter', |
|
222 | + 'event_espresso' |
|
223 | + ), |
|
224 | + 'default' => ! empty($datetime_selector_threshold) |
|
225 | + ? $datetime_selector_threshold |
|
226 | + : 3, |
|
227 | + 'display_html_label_text' => false, |
|
228 | + 'html_class' => 'ee-input-width--tiny', |
|
229 | + ) |
|
230 | + ), |
|
231 | + 'datetime_selector_max_checked' => new EE_Integer_Input( |
|
232 | + array( |
|
233 | + 'html_label_text' => esc_html__( |
|
234 | + 'Date & Time Filter Max Checked', |
|
235 | + 'event_espresso' |
|
236 | + ), |
|
237 | + 'html_help_text' => sprintf( |
|
238 | + esc_html__( |
|
239 | + 'Determines the maximum number of dates that will be checked upon initial loading for a Date and Time Filter.%1$sIf set to zero or left blank, then ALL dates will be checked upon initial loading.', |
|
240 | + 'event_espresso' |
|
241 | + ), |
|
242 | + '<br>' |
|
243 | + ), |
|
244 | + 'default' => $EE_Ticket_Selector_Config->getDatetimeSelectorMaxChecked(), |
|
245 | + 'display_html_label_text' => false, |
|
246 | + 'min_value' => 0, |
|
247 | + 'html_class' => 'ee-input-width--tiny', |
|
248 | + ) |
|
249 | + ), |
|
250 | + ) |
|
251 | + ), |
|
252 | + ) |
|
253 | + ); |
|
254 | + } |
|
255 | 255 | |
256 | 256 | |
257 | - /** |
|
258 | - * callback for updating template settings |
|
259 | - * |
|
260 | - * @param EE_Template_Config $CFG |
|
261 | - * @param array $REQ incoming request |
|
262 | - * @return EE_Template_Config |
|
263 | - * @throws EE_Error |
|
264 | - * @throws InvalidArgumentException |
|
265 | - * @throws ReflectionException |
|
266 | - * @throws InvalidDataTypeException |
|
267 | - * @throws InvalidInterfaceException |
|
268 | - *@since 4.6.18.rc.006 |
|
269 | - */ |
|
270 | - public static function update_template_settings(EE_Template_Config $CFG, array $REQ): EE_Template_Config |
|
271 | - { |
|
272 | - /** @var EE_Capabilities $capabilities */ |
|
273 | - $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
|
274 | - if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
275 | - wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
276 | - } |
|
277 | - if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
278 | - EED_Ticket_Selector::instance()->set_config(); |
|
279 | - $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config(); |
|
280 | - } |
|
281 | - try { |
|
282 | - $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
|
257 | + /** |
|
258 | + * callback for updating template settings |
|
259 | + * |
|
260 | + * @param EE_Template_Config $CFG |
|
261 | + * @param array $REQ incoming request |
|
262 | + * @return EE_Template_Config |
|
263 | + * @throws EE_Error |
|
264 | + * @throws InvalidArgumentException |
|
265 | + * @throws ReflectionException |
|
266 | + * @throws InvalidDataTypeException |
|
267 | + * @throws InvalidInterfaceException |
|
268 | + *@since 4.6.18.rc.006 |
|
269 | + */ |
|
270 | + public static function update_template_settings(EE_Template_Config $CFG, array $REQ): EE_Template_Config |
|
271 | + { |
|
272 | + /** @var EE_Capabilities $capabilities */ |
|
273 | + $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
|
274 | + if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
275 | + wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
|
276 | + } |
|
277 | + if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
278 | + EED_Ticket_Selector::instance()->set_config(); |
|
279 | + $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config(); |
|
280 | + } |
|
281 | + try { |
|
282 | + $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
|
283 | 283 | |
284 | - // check for form submission |
|
285 | - if ($ticket_selector_form->was_submitted()) { |
|
286 | - // capture form data |
|
287 | - $ticket_selector_form->receive_form_submission(); |
|
284 | + // check for form submission |
|
285 | + if ($ticket_selector_form->was_submitted()) { |
|
286 | + // capture form data |
|
287 | + $ticket_selector_form->receive_form_submission(); |
|
288 | 288 | |
289 | - // validate form data |
|
290 | - if ($ticket_selector_form->is_valid()) { |
|
291 | - // grab validated data from form |
|
292 | - $valid_data = $ticket_selector_form->valid_data(); |
|
289 | + // validate form data |
|
290 | + if ($ticket_selector_form->is_valid()) { |
|
291 | + // grab validated data from form |
|
292 | + $valid_data = $ticket_selector_form->valid_data(); |
|
293 | 293 | |
294 | - // set data on config |
|
295 | - $CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns']; |
|
296 | - $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details']; |
|
297 | - $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets']; |
|
298 | - $CFG->EED_Ticket_Selector->setShowDatetimeSelector( |
|
299 | - $valid_data['appearance_settings']['show_datetime_selector'] |
|
300 | - ); |
|
301 | - $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold( |
|
302 | - $valid_data['appearance_settings']['datetime_selector_threshold'] |
|
303 | - ); |
|
304 | - $CFG->EED_Ticket_Selector->setDatetimeSelectorMaxChecked( |
|
305 | - $valid_data['appearance_settings']['datetime_selector_max_checked'] |
|
306 | - ); |
|
307 | - } else { |
|
308 | - if ($ticket_selector_form->submission_error_message() !== '') { |
|
309 | - EE_Error::add_error( |
|
310 | - $ticket_selector_form->submission_error_message(), |
|
311 | - __FILE__, |
|
312 | - __FUNCTION__, |
|
313 | - __LINE__ |
|
314 | - ); |
|
315 | - } |
|
316 | - } |
|
317 | - } |
|
318 | - } catch (EE_Error $e) { |
|
319 | - $e->get_error(); |
|
320 | - } |
|
294 | + // set data on config |
|
295 | + $CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns']; |
|
296 | + $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details']; |
|
297 | + $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets']; |
|
298 | + $CFG->EED_Ticket_Selector->setShowDatetimeSelector( |
|
299 | + $valid_data['appearance_settings']['show_datetime_selector'] |
|
300 | + ); |
|
301 | + $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold( |
|
302 | + $valid_data['appearance_settings']['datetime_selector_threshold'] |
|
303 | + ); |
|
304 | + $CFG->EED_Ticket_Selector->setDatetimeSelectorMaxChecked( |
|
305 | + $valid_data['appearance_settings']['datetime_selector_max_checked'] |
|
306 | + ); |
|
307 | + } else { |
|
308 | + if ($ticket_selector_form->submission_error_message() !== '') { |
|
309 | + EE_Error::add_error( |
|
310 | + $ticket_selector_form->submission_error_message(), |
|
311 | + __FILE__, |
|
312 | + __FUNCTION__, |
|
313 | + __LINE__ |
|
314 | + ); |
|
315 | + } |
|
316 | + } |
|
317 | + } |
|
318 | + } catch (EE_Error $e) { |
|
319 | + $e->get_error(); |
|
320 | + } |
|
321 | 321 | |
322 | - return $CFG; |
|
323 | - } |
|
322 | + return $CFG; |
|
323 | + } |
|
324 | 324 | |
325 | 325 | |
326 | - /** |
|
327 | - * @param EE_Ticket $ticket |
|
328 | - * @param float $ticket_price |
|
329 | - * @param bool $display_ticket_price |
|
330 | - */ |
|
331 | - public static function ticket_price_details(EE_Ticket $ticket, float $ticket_price = 0, bool $display_ticket_price = false) |
|
332 | - { |
|
333 | - require str_replace('\\', '/', plugin_dir_path(__FILE__)) |
|
334 | - . 'templates/ticket_selector_price_details.template.php'; |
|
335 | - } |
|
326 | + /** |
|
327 | + * @param EE_Ticket $ticket |
|
328 | + * @param float $ticket_price |
|
329 | + * @param bool $display_ticket_price |
|
330 | + */ |
|
331 | + public static function ticket_price_details(EE_Ticket $ticket, float $ticket_price = 0, bool $display_ticket_price = false) |
|
332 | + { |
|
333 | + require str_replace('\\', '/', plugin_dir_path(__FILE__)) |
|
334 | + . 'templates/ticket_selector_price_details.template.php'; |
|
335 | + } |
|
336 | 336 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | define( |
55 | 55 | 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', |
56 | - str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/' |
|
56 | + str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/' |
|
57 | 57 | ); |
58 | 58 | add_action( |
59 | 59 | 'AHEE__template_settings__template__before_settings_form', |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
106 | 106 | array( |
107 | 107 | 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
108 | - EEH_HTML::br(2) . |
|
108 | + EEH_HTML::br(2). |
|
109 | 109 | EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
110 | 110 | ), |
111 | 111 | 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(), |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | { |
272 | 272 | /** @var EE_Capabilities $capabilities */ |
273 | 273 | $capabilities = LoaderFactory::getLoader()->getShared(EE_Capabilities::class); |
274 | - if (! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
274 | + if ( ! $capabilities->current_user_can('ee_edit_events', 'edit-event-template-settings')) { |
|
275 | 275 | wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); |
276 | 276 | } |
277 | - if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
277 | + if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
278 | 278 | EED_Ticket_Selector::instance()->set_config(); |
279 | 279 | $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config(); |
280 | 280 | } |
@@ -13,238 +13,238 @@ |
||
13 | 13 | */ |
14 | 14 | class EEG_PayPalCheckout extends EE_Onsite_Gateway |
15 | 15 | { |
16 | - /** |
|
17 | - * Currencies supported by this gateway. |
|
18 | - * |
|
19 | - * @var array |
|
20 | - */ |
|
21 | - protected $_currencies_supported = [ |
|
22 | - 'AUD', |
|
23 | - 'BRL', |
|
24 | - 'CAD', |
|
25 | - 'CNY', |
|
26 | - 'CZK', |
|
27 | - 'DKK', |
|
28 | - 'EUR', |
|
29 | - 'HKD', |
|
30 | - 'HUF', |
|
31 | - 'ILS', |
|
32 | - 'JPY', |
|
33 | - 'MYR', |
|
34 | - 'MXN', |
|
35 | - 'TWD', |
|
36 | - 'NZD', |
|
37 | - 'NOK', |
|
38 | - 'PHP', |
|
39 | - 'PLN', |
|
40 | - 'GBP', |
|
41 | - 'RUB', |
|
42 | - 'SGD', |
|
43 | - 'SEK', |
|
44 | - 'CHF', |
|
45 | - 'THB', |
|
46 | - 'USD', |
|
47 | - ]; |
|
16 | + /** |
|
17 | + * Currencies supported by this gateway. |
|
18 | + * |
|
19 | + * @var array |
|
20 | + */ |
|
21 | + protected $_currencies_supported = [ |
|
22 | + 'AUD', |
|
23 | + 'BRL', |
|
24 | + 'CAD', |
|
25 | + 'CNY', |
|
26 | + 'CZK', |
|
27 | + 'DKK', |
|
28 | + 'EUR', |
|
29 | + 'HKD', |
|
30 | + 'HUF', |
|
31 | + 'ILS', |
|
32 | + 'JPY', |
|
33 | + 'MYR', |
|
34 | + 'MXN', |
|
35 | + 'TWD', |
|
36 | + 'NZD', |
|
37 | + 'NOK', |
|
38 | + 'PHP', |
|
39 | + 'PLN', |
|
40 | + 'GBP', |
|
41 | + 'RUB', |
|
42 | + 'SGD', |
|
43 | + 'SEK', |
|
44 | + 'CHF', |
|
45 | + 'THB', |
|
46 | + 'USD', |
|
47 | + ]; |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * Override the parent. |
|
52 | - * |
|
53 | - * @param EE_Payment|null $payment |
|
54 | - * @param array|null $billing_info |
|
55 | - * @return EE_Payment |
|
56 | - */ |
|
57 | - public function do_direct_payment($payment, $billing_info = null) |
|
58 | - { |
|
59 | - // Normally we shouldn't be getting here because the payment should have been processed |
|
60 | - // along with the PP Order Charge. |
|
61 | - return $payment; |
|
62 | - } |
|
50 | + /** |
|
51 | + * Override the parent. |
|
52 | + * |
|
53 | + * @param EE_Payment|null $payment |
|
54 | + * @param array|null $billing_info |
|
55 | + * @return EE_Payment |
|
56 | + */ |
|
57 | + public function do_direct_payment($payment, $billing_info = null) |
|
58 | + { |
|
59 | + // Normally we shouldn't be getting here because the payment should have been processed |
|
60 | + // along with the PP Order Charge. |
|
61 | + return $payment; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * Validate the Order. |
|
67 | - * |
|
68 | - * @param $order |
|
69 | - * @param null $provided_order_id |
|
70 | - * @return array ['completed' => {boolean}, 'message' => {string}] |
|
71 | - */ |
|
72 | - public static function isOrderCompleted($order, $provided_order_id = null): array |
|
73 | - { |
|
74 | - $conclusion = [ |
|
75 | - 'completed' => false, |
|
76 | - 'message' => esc_html__('Could not validate this Order.', 'event_espresso'), |
|
77 | - ]; |
|
78 | - if (! empty($order) && ! empty($provided_order_id) && $order['id'] !== $provided_order_id) { |
|
79 | - $conclusion['message'] = esc_html__('Order ID mismatch.', 'event_espresso'); |
|
80 | - } |
|
81 | - if (! $order || ! is_array($order)) { |
|
82 | - $conclusion['message'] = esc_html__('The Order data is incorrectly formatted.', 'event_espresso'); |
|
83 | - } elseif (empty($order['status'])) { |
|
84 | - $conclusion['message'] = esc_html__( |
|
85 | - 'There was an error with this payment. The status of the Order could not be determined.', |
|
86 | - 'event_espresso' |
|
87 | - ); |
|
88 | - } elseif ($order['status'] !== 'COMPLETED') { |
|
89 | - $conclusion['message'] = esc_html__( |
|
90 | - 'There was an error with this payment. Order was not approved.', |
|
91 | - 'event_espresso' |
|
92 | - ); |
|
93 | - } elseif (empty($order['purchase_units'][0]['payments']['captures'][0]['status'])) { |
|
94 | - $conclusion['message'] = esc_html__( |
|
95 | - 'There was an error with this payment. The status of the Payment could not be determined.', |
|
96 | - 'event_espresso' |
|
97 | - ); |
|
98 | - } elseif ($order['purchase_units'][0]['payments']['captures'][0]['status'] !== 'COMPLETED') { |
|
99 | - $conclusion['message'] = esc_html__( |
|
100 | - 'This payment was declined or failed validation. Please check the billing information you provided.', |
|
101 | - 'event_espresso' |
|
102 | - ); |
|
103 | - } else { |
|
104 | - // If we didn't fail on the above, the Order should be considered valid. |
|
105 | - $conclusion['completed'] = true; |
|
106 | - } |
|
107 | - return $conclusion; |
|
108 | - } |
|
65 | + /** |
|
66 | + * Validate the Order. |
|
67 | + * |
|
68 | + * @param $order |
|
69 | + * @param null $provided_order_id |
|
70 | + * @return array ['completed' => {boolean}, 'message' => {string}] |
|
71 | + */ |
|
72 | + public static function isOrderCompleted($order, $provided_order_id = null): array |
|
73 | + { |
|
74 | + $conclusion = [ |
|
75 | + 'completed' => false, |
|
76 | + 'message' => esc_html__('Could not validate this Order.', 'event_espresso'), |
|
77 | + ]; |
|
78 | + if (! empty($order) && ! empty($provided_order_id) && $order['id'] !== $provided_order_id) { |
|
79 | + $conclusion['message'] = esc_html__('Order ID mismatch.', 'event_espresso'); |
|
80 | + } |
|
81 | + if (! $order || ! is_array($order)) { |
|
82 | + $conclusion['message'] = esc_html__('The Order data is incorrectly formatted.', 'event_espresso'); |
|
83 | + } elseif (empty($order['status'])) { |
|
84 | + $conclusion['message'] = esc_html__( |
|
85 | + 'There was an error with this payment. The status of the Order could not be determined.', |
|
86 | + 'event_espresso' |
|
87 | + ); |
|
88 | + } elseif ($order['status'] !== 'COMPLETED') { |
|
89 | + $conclusion['message'] = esc_html__( |
|
90 | + 'There was an error with this payment. Order was not approved.', |
|
91 | + 'event_espresso' |
|
92 | + ); |
|
93 | + } elseif (empty($order['purchase_units'][0]['payments']['captures'][0]['status'])) { |
|
94 | + $conclusion['message'] = esc_html__( |
|
95 | + 'There was an error with this payment. The status of the Payment could not be determined.', |
|
96 | + 'event_espresso' |
|
97 | + ); |
|
98 | + } elseif ($order['purchase_units'][0]['payments']['captures'][0]['status'] !== 'COMPLETED') { |
|
99 | + $conclusion['message'] = esc_html__( |
|
100 | + 'This payment was declined or failed validation. Please check the billing information you provided.', |
|
101 | + 'event_espresso' |
|
102 | + ); |
|
103 | + } else { |
|
104 | + // If we didn't fail on the above, the Order should be considered valid. |
|
105 | + $conclusion['completed'] = true; |
|
106 | + } |
|
107 | + return $conclusion; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * Create an EE Payment. |
|
113 | - * |
|
114 | - * @param EE_Transaction $transaction |
|
115 | - * @param EE_Payment_Method $payment_method |
|
116 | - * @return EE_Payment |
|
117 | - * @throws EE_Error |
|
118 | - * @throws ReflectionException |
|
119 | - */ |
|
120 | - public static function createPayment(EE_Transaction $transaction, EE_Payment_Method $payment_method): EE_Payment |
|
121 | - { |
|
122 | - // No payment for this transaction was created at this point. |
|
123 | - $payment = EE_Payment::new_instance([ |
|
124 | - 'PAY_timestamp' => time(), |
|
125 | - 'TXN_ID' => $transaction->ID(), |
|
126 | - 'PMD_ID' => $payment_method->ID(), |
|
127 | - 'PAY_po_number' => null, |
|
128 | - 'PAY_extra_accntng' => null, |
|
129 | - 'PAY_details' => null, |
|
130 | - ]); |
|
131 | - $payment->save(); |
|
132 | - return $payment; |
|
133 | - } |
|
111 | + /** |
|
112 | + * Create an EE Payment. |
|
113 | + * |
|
114 | + * @param EE_Transaction $transaction |
|
115 | + * @param EE_Payment_Method $payment_method |
|
116 | + * @return EE_Payment |
|
117 | + * @throws EE_Error |
|
118 | + * @throws ReflectionException |
|
119 | + */ |
|
120 | + public static function createPayment(EE_Transaction $transaction, EE_Payment_Method $payment_method): EE_Payment |
|
121 | + { |
|
122 | + // No payment for this transaction was created at this point. |
|
123 | + $payment = EE_Payment::new_instance([ |
|
124 | + 'PAY_timestamp' => time(), |
|
125 | + 'TXN_ID' => $transaction->ID(), |
|
126 | + 'PMD_ID' => $payment_method->ID(), |
|
127 | + 'PAY_po_number' => null, |
|
128 | + 'PAY_extra_accntng' => null, |
|
129 | + 'PAY_details' => null, |
|
130 | + ]); |
|
131 | + $payment->save(); |
|
132 | + return $payment; |
|
133 | + } |
|
134 | 134 | |
135 | 135 | |
136 | - /** |
|
137 | - * Set a payment error and log the data. |
|
138 | - * |
|
139 | - * @param EE_Payment $payment |
|
140 | - * @param string $status |
|
141 | - * @param array|string $response_data |
|
142 | - * @param string $update_message |
|
143 | - * @return EE_Payment |
|
144 | - * @throws EE_Error|ReflectionException |
|
145 | - */ |
|
146 | - public static function updatePaymentStatus( |
|
147 | - EE_Payment $payment, |
|
148 | - string $status, |
|
149 | - $response_data, |
|
150 | - string $update_message = '' |
|
151 | - ): EE_Payment { |
|
152 | - $paypal_pm = ! empty($payment->payment_method()) |
|
153 | - ? EEM_Payment_Method::instance()->get_one_by_slug($payment->payment_method()->name()) |
|
154 | - : null; |
|
155 | - // Is this a successful payment ? |
|
156 | - if ($status === EEM_Payment::status_id_approved) { |
|
157 | - $default_message = esc_html__('Successful payment.', 'event_espresso'); |
|
158 | - $amount = $response_data['purchase_units'][0]['payments']['captures'][0]['amount']['value'] ?? 0; |
|
159 | - // Don't set the amount if there is no info on that with this order. |
|
160 | - if (! empty($amount)) { |
|
161 | - $payment->set_amount((float) $amount); |
|
162 | - } |
|
163 | - $payment->set_txn_id_chq_nmbr( |
|
164 | - $order['purchase_units'][0]['payments']['captures'][0]['id'] ?? $response_data['id'] |
|
165 | - ); |
|
166 | - } else { |
|
167 | - $default_message = sprintf( |
|
168 | - esc_html__( |
|
169 | - 'Your payment could not be processed successfully due to a technical issue.%1$sPlease try again or contact%2$s for assistance.', |
|
170 | - 'event_espresso' |
|
171 | - ), |
|
172 | - '<br/>', |
|
173 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
174 | - ); |
|
175 | - } |
|
176 | - $log_message = $update_message ?: $default_message; |
|
177 | - PayPalLogger::errorLog($log_message, $response_data, $paypal_pm, false, $payment->transaction()); |
|
178 | - $payment->set_status($status); |
|
179 | - $payment->set_details($log_message); |
|
180 | - $payment->set_gateway_response($log_message); |
|
181 | - $payment->save(); |
|
182 | - return $payment; |
|
183 | - } |
|
136 | + /** |
|
137 | + * Set a payment error and log the data. |
|
138 | + * |
|
139 | + * @param EE_Payment $payment |
|
140 | + * @param string $status |
|
141 | + * @param array|string $response_data |
|
142 | + * @param string $update_message |
|
143 | + * @return EE_Payment |
|
144 | + * @throws EE_Error|ReflectionException |
|
145 | + */ |
|
146 | + public static function updatePaymentStatus( |
|
147 | + EE_Payment $payment, |
|
148 | + string $status, |
|
149 | + $response_data, |
|
150 | + string $update_message = '' |
|
151 | + ): EE_Payment { |
|
152 | + $paypal_pm = ! empty($payment->payment_method()) |
|
153 | + ? EEM_Payment_Method::instance()->get_one_by_slug($payment->payment_method()->name()) |
|
154 | + : null; |
|
155 | + // Is this a successful payment ? |
|
156 | + if ($status === EEM_Payment::status_id_approved) { |
|
157 | + $default_message = esc_html__('Successful payment.', 'event_espresso'); |
|
158 | + $amount = $response_data['purchase_units'][0]['payments']['captures'][0]['amount']['value'] ?? 0; |
|
159 | + // Don't set the amount if there is no info on that with this order. |
|
160 | + if (! empty($amount)) { |
|
161 | + $payment->set_amount((float) $amount); |
|
162 | + } |
|
163 | + $payment->set_txn_id_chq_nmbr( |
|
164 | + $order['purchase_units'][0]['payments']['captures'][0]['id'] ?? $response_data['id'] |
|
165 | + ); |
|
166 | + } else { |
|
167 | + $default_message = sprintf( |
|
168 | + esc_html__( |
|
169 | + 'Your payment could not be processed successfully due to a technical issue.%1$sPlease try again or contact%2$s for assistance.', |
|
170 | + 'event_espresso' |
|
171 | + ), |
|
172 | + '<br/>', |
|
173 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
174 | + ); |
|
175 | + } |
|
176 | + $log_message = $update_message ?: $default_message; |
|
177 | + PayPalLogger::errorLog($log_message, $response_data, $paypal_pm, false, $payment->transaction()); |
|
178 | + $payment->set_status($status); |
|
179 | + $payment->set_details($log_message); |
|
180 | + $payment->set_gateway_response($log_message); |
|
181 | + $payment->save(); |
|
182 | + return $payment; |
|
183 | + } |
|
184 | 184 | |
185 | 185 | |
186 | - /** |
|
187 | - * Save some transaction details, like billing information. |
|
188 | - * |
|
189 | - * @param EE_Payment $payment |
|
190 | - * @param EE_Transaction $transaction |
|
191 | - * @param array $order |
|
192 | - * @param array $billing_info |
|
193 | - * @return void |
|
194 | - * @throws EE_Error |
|
195 | - * @throws ReflectionException |
|
196 | - */ |
|
197 | - public static function saveBillingDetails( |
|
198 | - EE_Payment $payment, |
|
199 | - EE_Transaction $transaction, |
|
200 | - array $order, |
|
201 | - array $billing_info |
|
202 | - ): void { |
|
203 | - $primary_reg = $transaction->primary_registration(); |
|
204 | - $attendee = $primary_reg instanceof EE_Registration ? $primary_reg->attendee() : null; |
|
205 | - $payment_method = $transaction->payment_method(); |
|
206 | - $postmeta_name = $payment_method->type_obj() instanceof EE_PMT_Base |
|
207 | - ? 'billing_info_' . $payment_method->type_obj()->system_name() |
|
208 | - : ''; |
|
209 | - if (empty($order['payment_source']) || ! $attendee instanceof EE_Attendee) { |
|
210 | - // I guess we are done here then. Just save what we have. |
|
211 | - $payment->set_details($order); |
|
212 | - return; |
|
213 | - } |
|
214 | - // Do we have order information from the express checkout (PayPal button) ? |
|
215 | - $billing_info['first_name'] = $billing_info['first_name'] ?? $attendee->fname(); |
|
216 | - $billing_info['last_name'] = $billing_info['last_name'] ?? $attendee->lname(); |
|
217 | - $billing_info['email'] = $billing_info['email'] ?? $attendee->email(); |
|
218 | - if (! empty($billing_info['address'])) { |
|
219 | - $attendee->set_address($billing_info['address']); |
|
220 | - } |
|
221 | - if (! empty($billing_info['address_2'])) { |
|
222 | - $attendee->set_address2($billing_info['address_2']); |
|
223 | - } |
|
224 | - if (! empty($billing_info['city'])) { |
|
225 | - $attendee->set_city($billing_info['city']); |
|
226 | - } |
|
227 | - if (! empty($billing_info['state_id'])) { |
|
228 | - $attendee->set_state((int) $billing_info['state_id']); |
|
229 | - } |
|
230 | - if (! empty($billing_info['country'])) { |
|
231 | - $attendee->set_country($billing_info['country']); |
|
232 | - } |
|
233 | - if (! empty($billing_info['zip'])) { |
|
234 | - $attendee->set_zip($billing_info['zip']); |
|
235 | - } |
|
236 | - // Or card information from ACDC ? |
|
237 | - if (! empty($order['payment_source']['card'])) { |
|
238 | - $payer_card = $order['payment_source']['card']; |
|
239 | - if (! empty($payer_card['name'])) { |
|
240 | - $full_name = explode(' ', $payer_card['name']); |
|
241 | - // Don't need to save each field because others should be populated from the billing form. |
|
242 | - $billing_info['credit_card'] = $payer_card['last_digits'] ?? ''; |
|
243 | - $billing_info['first_name'] = $full_name[0] ?? $attendee->fname(); |
|
244 | - $billing_info['last_name'] = $full_name[1] ?? $attendee->lname(); |
|
245 | - } |
|
246 | - } |
|
247 | - update_post_meta($attendee->ID(), $postmeta_name, $billing_info); |
|
248 | - $attendee->save(); |
|
249 | - } |
|
186 | + /** |
|
187 | + * Save some transaction details, like billing information. |
|
188 | + * |
|
189 | + * @param EE_Payment $payment |
|
190 | + * @param EE_Transaction $transaction |
|
191 | + * @param array $order |
|
192 | + * @param array $billing_info |
|
193 | + * @return void |
|
194 | + * @throws EE_Error |
|
195 | + * @throws ReflectionException |
|
196 | + */ |
|
197 | + public static function saveBillingDetails( |
|
198 | + EE_Payment $payment, |
|
199 | + EE_Transaction $transaction, |
|
200 | + array $order, |
|
201 | + array $billing_info |
|
202 | + ): void { |
|
203 | + $primary_reg = $transaction->primary_registration(); |
|
204 | + $attendee = $primary_reg instanceof EE_Registration ? $primary_reg->attendee() : null; |
|
205 | + $payment_method = $transaction->payment_method(); |
|
206 | + $postmeta_name = $payment_method->type_obj() instanceof EE_PMT_Base |
|
207 | + ? 'billing_info_' . $payment_method->type_obj()->system_name() |
|
208 | + : ''; |
|
209 | + if (empty($order['payment_source']) || ! $attendee instanceof EE_Attendee) { |
|
210 | + // I guess we are done here then. Just save what we have. |
|
211 | + $payment->set_details($order); |
|
212 | + return; |
|
213 | + } |
|
214 | + // Do we have order information from the express checkout (PayPal button) ? |
|
215 | + $billing_info['first_name'] = $billing_info['first_name'] ?? $attendee->fname(); |
|
216 | + $billing_info['last_name'] = $billing_info['last_name'] ?? $attendee->lname(); |
|
217 | + $billing_info['email'] = $billing_info['email'] ?? $attendee->email(); |
|
218 | + if (! empty($billing_info['address'])) { |
|
219 | + $attendee->set_address($billing_info['address']); |
|
220 | + } |
|
221 | + if (! empty($billing_info['address_2'])) { |
|
222 | + $attendee->set_address2($billing_info['address_2']); |
|
223 | + } |
|
224 | + if (! empty($billing_info['city'])) { |
|
225 | + $attendee->set_city($billing_info['city']); |
|
226 | + } |
|
227 | + if (! empty($billing_info['state_id'])) { |
|
228 | + $attendee->set_state((int) $billing_info['state_id']); |
|
229 | + } |
|
230 | + if (! empty($billing_info['country'])) { |
|
231 | + $attendee->set_country($billing_info['country']); |
|
232 | + } |
|
233 | + if (! empty($billing_info['zip'])) { |
|
234 | + $attendee->set_zip($billing_info['zip']); |
|
235 | + } |
|
236 | + // Or card information from ACDC ? |
|
237 | + if (! empty($order['payment_source']['card'])) { |
|
238 | + $payer_card = $order['payment_source']['card']; |
|
239 | + if (! empty($payer_card['name'])) { |
|
240 | + $full_name = explode(' ', $payer_card['name']); |
|
241 | + // Don't need to save each field because others should be populated from the billing form. |
|
242 | + $billing_info['credit_card'] = $payer_card['last_digits'] ?? ''; |
|
243 | + $billing_info['first_name'] = $full_name[0] ?? $attendee->fname(); |
|
244 | + $billing_info['last_name'] = $full_name[1] ?? $attendee->lname(); |
|
245 | + } |
|
246 | + } |
|
247 | + update_post_meta($attendee->ID(), $postmeta_name, $billing_info); |
|
248 | + $attendee->save(); |
|
249 | + } |
|
250 | 250 | } |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | 'completed' => false, |
76 | 76 | 'message' => esc_html__('Could not validate this Order.', 'event_espresso'), |
77 | 77 | ]; |
78 | - if (! empty($order) && ! empty($provided_order_id) && $order['id'] !== $provided_order_id) { |
|
78 | + if ( ! empty($order) && ! empty($provided_order_id) && $order['id'] !== $provided_order_id) { |
|
79 | 79 | $conclusion['message'] = esc_html__('Order ID mismatch.', 'event_espresso'); |
80 | 80 | } |
81 | - if (! $order || ! is_array($order)) { |
|
81 | + if ( ! $order || ! is_array($order)) { |
|
82 | 82 | $conclusion['message'] = esc_html__('The Order data is incorrectly formatted.', 'event_espresso'); |
83 | 83 | } elseif (empty($order['status'])) { |
84 | 84 | $conclusion['message'] = esc_html__( |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $default_message = esc_html__('Successful payment.', 'event_espresso'); |
158 | 158 | $amount = $response_data['purchase_units'][0]['payments']['captures'][0]['amount']['value'] ?? 0; |
159 | 159 | // Don't set the amount if there is no info on that with this order. |
160 | - if (! empty($amount)) { |
|
160 | + if ( ! empty($amount)) { |
|
161 | 161 | $payment->set_amount((float) $amount); |
162 | 162 | } |
163 | 163 | $payment->set_txn_id_chq_nmbr( |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $attendee = $primary_reg instanceof EE_Registration ? $primary_reg->attendee() : null; |
205 | 205 | $payment_method = $transaction->payment_method(); |
206 | 206 | $postmeta_name = $payment_method->type_obj() instanceof EE_PMT_Base |
207 | - ? 'billing_info_' . $payment_method->type_obj()->system_name() |
|
207 | + ? 'billing_info_'.$payment_method->type_obj()->system_name() |
|
208 | 208 | : ''; |
209 | 209 | if (empty($order['payment_source']) || ! $attendee instanceof EE_Attendee) { |
210 | 210 | // I guess we are done here then. Just save what we have. |
@@ -215,28 +215,28 @@ discard block |
||
215 | 215 | $billing_info['first_name'] = $billing_info['first_name'] ?? $attendee->fname(); |
216 | 216 | $billing_info['last_name'] = $billing_info['last_name'] ?? $attendee->lname(); |
217 | 217 | $billing_info['email'] = $billing_info['email'] ?? $attendee->email(); |
218 | - if (! empty($billing_info['address'])) { |
|
218 | + if ( ! empty($billing_info['address'])) { |
|
219 | 219 | $attendee->set_address($billing_info['address']); |
220 | 220 | } |
221 | - if (! empty($billing_info['address_2'])) { |
|
221 | + if ( ! empty($billing_info['address_2'])) { |
|
222 | 222 | $attendee->set_address2($billing_info['address_2']); |
223 | 223 | } |
224 | - if (! empty($billing_info['city'])) { |
|
224 | + if ( ! empty($billing_info['city'])) { |
|
225 | 225 | $attendee->set_city($billing_info['city']); |
226 | 226 | } |
227 | - if (! empty($billing_info['state_id'])) { |
|
227 | + if ( ! empty($billing_info['state_id'])) { |
|
228 | 228 | $attendee->set_state((int) $billing_info['state_id']); |
229 | 229 | } |
230 | - if (! empty($billing_info['country'])) { |
|
230 | + if ( ! empty($billing_info['country'])) { |
|
231 | 231 | $attendee->set_country($billing_info['country']); |
232 | 232 | } |
233 | - if (! empty($billing_info['zip'])) { |
|
233 | + if ( ! empty($billing_info['zip'])) { |
|
234 | 234 | $attendee->set_zip($billing_info['zip']); |
235 | 235 | } |
236 | 236 | // Or card information from ACDC ? |
237 | - if (! empty($order['payment_source']['card'])) { |
|
237 | + if ( ! empty($order['payment_source']['card'])) { |
|
238 | 238 | $payer_card = $order['payment_source']['card']; |
239 | - if (! empty($payer_card['name'])) { |
|
239 | + if ( ! empty($payer_card['name'])) { |
|
240 | 240 | $full_name = explode(' ', $payer_card['name']); |
241 | 241 | // Don't need to save each field because others should be populated from the billing form. |
242 | 242 | $billing_info['credit_card'] = $payer_card['last_digits'] ?? ''; |
@@ -16,186 +16,186 @@ |
||
16 | 16 | */ |
17 | 17 | class EE_PMT_PayPalCheckout extends EE_PMT_Base |
18 | 18 | { |
19 | - /** |
|
20 | - * @param EE_Payment_Method|null $pm_instance |
|
21 | - * @throws ReflectionException |
|
22 | - * @throws EE_Error |
|
23 | - */ |
|
24 | - public function __construct($pm_instance = null) |
|
25 | - { |
|
26 | - $this->_template_path = dirname(__FILE__) . DS . 'templates' . DS; |
|
27 | - $this->_default_description = esc_html__('Please provide the following billing information.', 'event_espresso'); |
|
28 | - $this->_default_button_url = $this->file_url() . 'lib/default-cc-logo.png'; |
|
29 | - $this->_pretty_name = esc_html__('PayPal Commerce', 'event_espresso'); |
|
30 | - $this->_cache_billing_form = true; |
|
31 | - $this->_requires_https = true; |
|
19 | + /** |
|
20 | + * @param EE_Payment_Method|null $pm_instance |
|
21 | + * @throws ReflectionException |
|
22 | + * @throws EE_Error |
|
23 | + */ |
|
24 | + public function __construct($pm_instance = null) |
|
25 | + { |
|
26 | + $this->_template_path = dirname(__FILE__) . DS . 'templates' . DS; |
|
27 | + $this->_default_description = esc_html__('Please provide the following billing information.', 'event_espresso'); |
|
28 | + $this->_default_button_url = $this->file_url() . 'lib/default-cc-logo.png'; |
|
29 | + $this->_pretty_name = esc_html__('PayPal Commerce', 'event_espresso'); |
|
30 | + $this->_cache_billing_form = true; |
|
31 | + $this->_requires_https = true; |
|
32 | 32 | |
33 | - // Load gateway. |
|
34 | - require_once( |
|
35 | - EEP_PAYPAL_COMMERCE_PATH . 'EEG_PayPalCheckout.gateway.php' |
|
36 | - ); |
|
37 | - $this->_gateway = new EEG_PayPalCheckout(); |
|
33 | + // Load gateway. |
|
34 | + require_once( |
|
35 | + EEP_PAYPAL_COMMERCE_PATH . 'EEG_PayPalCheckout.gateway.php' |
|
36 | + ); |
|
37 | + $this->_gateway = new EEG_PayPalCheckout(); |
|
38 | 38 | |
39 | - // Display a refund message at transactions actions area. |
|
40 | - add_action( |
|
41 | - 'AHEE__txn_admin_details_main_meta_box_txn_details__after_actions_buttons', |
|
42 | - [__CLASS__, 'refundNotice'] |
|
43 | - ); |
|
39 | + // Display a refund message at transactions actions area. |
|
40 | + add_action( |
|
41 | + 'AHEE__txn_admin_details_main_meta_box_txn_details__after_actions_buttons', |
|
42 | + [__CLASS__, 'refundNotice'] |
|
43 | + ); |
|
44 | 44 | |
45 | - parent::__construct($pm_instance); |
|
46 | - } |
|
45 | + parent::__construct($pm_instance); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Generate a new payment method settings form. |
|
51 | - * |
|
52 | - * @return EE_Payment_Method_Form |
|
53 | - * @throws EE_Error |
|
54 | - * @throws ReflectionException |
|
55 | - */ |
|
56 | - public function generate_new_settings_form() |
|
57 | - { |
|
58 | - // Settings form. |
|
59 | - $settings_form = new SettingsForm($this, $this->_pm_instance); |
|
60 | - // Filter the form contents. |
|
61 | - return apply_filters( |
|
62 | - 'FHEE__EE_PMT_PayPalCheckout__generate_new_settings_form__form_filtering', |
|
63 | - $settings_form, |
|
64 | - $this, |
|
65 | - $this->_pm_instance |
|
66 | - ); |
|
67 | - } |
|
49 | + /** |
|
50 | + * Generate a new payment method settings form. |
|
51 | + * |
|
52 | + * @return EE_Payment_Method_Form |
|
53 | + * @throws EE_Error |
|
54 | + * @throws ReflectionException |
|
55 | + */ |
|
56 | + public function generate_new_settings_form() |
|
57 | + { |
|
58 | + // Settings form. |
|
59 | + $settings_form = new SettingsForm($this, $this->_pm_instance); |
|
60 | + // Filter the form contents. |
|
61 | + return apply_filters( |
|
62 | + 'FHEE__EE_PMT_PayPalCheckout__generate_new_settings_form__form_filtering', |
|
63 | + $settings_form, |
|
64 | + $this, |
|
65 | + $this->_pm_instance |
|
66 | + ); |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * Creates a billing form for this payment method type. |
|
72 | - * |
|
73 | - * @param EE_Transaction|null $transaction |
|
74 | - * @param array|null $extra_args |
|
75 | - * @return EE_Billing_Info_Form|null |
|
76 | - * @throws EE_Error |
|
77 | - * @throws ReflectionException |
|
78 | - */ |
|
79 | - public function generate_new_billing_form(EE_Transaction $transaction = null, ?array $extra_args = []) |
|
80 | - { |
|
81 | - $request = LoaderFactory::getShared(Request::class); |
|
82 | - $request_params = $request->requestParams(); |
|
83 | - // Return the default billing form for the postbox if this is a WP admin transaction info page. |
|
84 | - if (! empty($request_params['page']) && $request_params['page'] === 'espresso_transactions') { |
|
85 | - $default_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, $extra_args); |
|
86 | - $default_form->add_subsections(['credit_card' => new EE_Credit_Card_Input()]); |
|
87 | - return $default_form; |
|
88 | - } |
|
89 | - // Just in case this is used on other admin pages. |
|
90 | - if (empty($transaction) && ! empty($request_params['TXN_ID'])) { |
|
91 | - $txn_instance = EEM_Transaction::instance()->get_one_by_ID($request_params['TXN_ID']); |
|
92 | - $transaction = $txn_instance instanceof EE_Transaction ? $txn_instance : null; |
|
93 | - } |
|
94 | - $options = array_merge( |
|
95 | - [ |
|
96 | - 'transaction' => $transaction, |
|
97 | - 'template_path' => $this->_template_path, |
|
98 | - ], |
|
99 | - $extra_args |
|
100 | - ); |
|
101 | - return LoaderFactory::getNew(BillingForm::class, [$this->_pm_instance, $options]); |
|
102 | - } |
|
70 | + /** |
|
71 | + * Creates a billing form for this payment method type. |
|
72 | + * |
|
73 | + * @param EE_Transaction|null $transaction |
|
74 | + * @param array|null $extra_args |
|
75 | + * @return EE_Billing_Info_Form|null |
|
76 | + * @throws EE_Error |
|
77 | + * @throws ReflectionException |
|
78 | + */ |
|
79 | + public function generate_new_billing_form(EE_Transaction $transaction = null, ?array $extra_args = []) |
|
80 | + { |
|
81 | + $request = LoaderFactory::getShared(Request::class); |
|
82 | + $request_params = $request->requestParams(); |
|
83 | + // Return the default billing form for the postbox if this is a WP admin transaction info page. |
|
84 | + if (! empty($request_params['page']) && $request_params['page'] === 'espresso_transactions') { |
|
85 | + $default_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, $extra_args); |
|
86 | + $default_form->add_subsections(['credit_card' => new EE_Credit_Card_Input()]); |
|
87 | + return $default_form; |
|
88 | + } |
|
89 | + // Just in case this is used on other admin pages. |
|
90 | + if (empty($transaction) && ! empty($request_params['TXN_ID'])) { |
|
91 | + $txn_instance = EEM_Transaction::instance()->get_one_by_ID($request_params['TXN_ID']); |
|
92 | + $transaction = $txn_instance instanceof EE_Transaction ? $txn_instance : null; |
|
93 | + } |
|
94 | + $options = array_merge( |
|
95 | + [ |
|
96 | + 'transaction' => $transaction, |
|
97 | + 'template_path' => $this->_template_path, |
|
98 | + ], |
|
99 | + $extra_args |
|
100 | + ); |
|
101 | + return LoaderFactory::getNew(BillingForm::class, [$this->_pm_instance, $options]); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * Adds PM info to the help tab. |
|
107 | - * |
|
108 | - * @return array |
|
109 | - * @see EE_PMT_Base::help_tabs_config() |
|
110 | - */ |
|
111 | - public function help_tabs_config(): array |
|
112 | - { |
|
113 | - return [ |
|
114 | - $this->get_help_tab_name() => [ |
|
115 | - 'title' => esc_html__('PayPal Commerce settings', 'event_espresso'), |
|
116 | - 'filename' => 'pp-commerce-overview', |
|
117 | - ], |
|
118 | - ]; |
|
119 | - } |
|
105 | + /** |
|
106 | + * Adds PM info to the help tab. |
|
107 | + * |
|
108 | + * @return array |
|
109 | + * @see EE_PMT_Base::help_tabs_config() |
|
110 | + */ |
|
111 | + public function help_tabs_config(): array |
|
112 | + { |
|
113 | + return [ |
|
114 | + $this->get_help_tab_name() => [ |
|
115 | + 'title' => esc_html__('PayPal Commerce settings', 'event_espresso'), |
|
116 | + 'filename' => 'pp-commerce-overview', |
|
117 | + ], |
|
118 | + ]; |
|
119 | + } |
|
120 | 120 | |
121 | 121 | |
122 | - /** |
|
123 | - * Adds a refund related message section. |
|
124 | - * |
|
125 | - * @param bool $can_edit_payments Flag that tells if user can edit payments. |
|
126 | - * @access public |
|
127 | - * @return void |
|
128 | - */ |
|
129 | - public static function refundNotice(bool $can_edit_payments) |
|
130 | - { |
|
131 | - if (! $can_edit_payments) { |
|
132 | - return; |
|
133 | - } |
|
134 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
135 | - $txn_id = $request->getRequestParam('TXN_ID', 0, DataType::INT); |
|
136 | - try { |
|
137 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($txn_id); |
|
138 | - if (! $transaction instanceof EE_Transaction) { |
|
139 | - return; |
|
140 | - } |
|
141 | - // Was this transaction paid using PayPal ? |
|
142 | - if (strpos((string) $transaction->payment_method(), 'PayPal Commerce') === false) { |
|
143 | - return; |
|
144 | - } |
|
145 | - // Try loading the template. |
|
146 | - EE_Registry::instance()->load_helper('Template'); |
|
147 | - } catch (EE_Error|ReflectionException $e) { |
|
148 | - // Just return, adding nothing. |
|
149 | - return; |
|
150 | - } |
|
151 | - $html = EEH_Template::locate_template( |
|
152 | - apply_filters( |
|
153 | - 'FHEEA__EE_PMT_PayPalCheckout__refundNotice', |
|
154 | - dirname(__FILE__) . DS . 'templates' . DS . 'apply-refund-notice.template.php' |
|
155 | - ) |
|
156 | - ); |
|
157 | - echo $html; |
|
158 | - } |
|
122 | + /** |
|
123 | + * Adds a refund related message section. |
|
124 | + * |
|
125 | + * @param bool $can_edit_payments Flag that tells if user can edit payments. |
|
126 | + * @access public |
|
127 | + * @return void |
|
128 | + */ |
|
129 | + public static function refundNotice(bool $can_edit_payments) |
|
130 | + { |
|
131 | + if (! $can_edit_payments) { |
|
132 | + return; |
|
133 | + } |
|
134 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
135 | + $txn_id = $request->getRequestParam('TXN_ID', 0, DataType::INT); |
|
136 | + try { |
|
137 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($txn_id); |
|
138 | + if (! $transaction instanceof EE_Transaction) { |
|
139 | + return; |
|
140 | + } |
|
141 | + // Was this transaction paid using PayPal ? |
|
142 | + if (strpos((string) $transaction->payment_method(), 'PayPal Commerce') === false) { |
|
143 | + return; |
|
144 | + } |
|
145 | + // Try loading the template. |
|
146 | + EE_Registry::instance()->load_helper('Template'); |
|
147 | + } catch (EE_Error|ReflectionException $e) { |
|
148 | + // Just return, adding nothing. |
|
149 | + return; |
|
150 | + } |
|
151 | + $html = EEH_Template::locate_template( |
|
152 | + apply_filters( |
|
153 | + 'FHEEA__EE_PMT_PayPalCheckout__refundNotice', |
|
154 | + dirname(__FILE__) . DS . 'templates' . DS . 'apply-refund-notice.template.php' |
|
155 | + ) |
|
156 | + ); |
|
157 | + echo $html; |
|
158 | + } |
|
159 | 159 | |
160 | 160 | |
161 | - /** |
|
162 | - * Override the parent. |
|
163 | - * |
|
164 | - * @param EE_Transaction $transaction |
|
165 | - * @param float|null $amount |
|
166 | - * @param EE_Billing_Info_Form|null $billing_info |
|
167 | - * @param string|null $return_url |
|
168 | - * @param string $fail_url |
|
169 | - * @param string $method |
|
170 | - * @param bool $by_admin |
|
171 | - * @return EE_Payment |
|
172 | - * @throws EE_Error |
|
173 | - * @throws ReflectionException |
|
174 | - */ |
|
175 | - public function process_payment( |
|
176 | - EE_Transaction $transaction, |
|
177 | - $amount = null, |
|
178 | - $billing_info = null, |
|
179 | - $return_url = null, |
|
180 | - $fail_url = '', |
|
181 | - $method = 'CART', |
|
182 | - $by_admin = false |
|
183 | - ): EE_Payment { |
|
184 | - // This payment should have been processed in the background, while the Order was created and charged. |
|
185 | - // So simply return the last payment. Unless it's somehow missing. |
|
186 | - $payment = $transaction->last_payment(); |
|
187 | - if (empty($payment) || $payment->status() === EEM_Payment::status_id_failed) { |
|
188 | - // Then we try processing the payment as usual. |
|
189 | - return parent::process_payment( |
|
190 | - $transaction, |
|
191 | - $amount, |
|
192 | - $billing_info, |
|
193 | - $return_url, |
|
194 | - $fail_url, |
|
195 | - $method, |
|
196 | - $by_admin |
|
197 | - ); |
|
198 | - } |
|
199 | - return $transaction->last_payment(); |
|
200 | - } |
|
161 | + /** |
|
162 | + * Override the parent. |
|
163 | + * |
|
164 | + * @param EE_Transaction $transaction |
|
165 | + * @param float|null $amount |
|
166 | + * @param EE_Billing_Info_Form|null $billing_info |
|
167 | + * @param string|null $return_url |
|
168 | + * @param string $fail_url |
|
169 | + * @param string $method |
|
170 | + * @param bool $by_admin |
|
171 | + * @return EE_Payment |
|
172 | + * @throws EE_Error |
|
173 | + * @throws ReflectionException |
|
174 | + */ |
|
175 | + public function process_payment( |
|
176 | + EE_Transaction $transaction, |
|
177 | + $amount = null, |
|
178 | + $billing_info = null, |
|
179 | + $return_url = null, |
|
180 | + $fail_url = '', |
|
181 | + $method = 'CART', |
|
182 | + $by_admin = false |
|
183 | + ): EE_Payment { |
|
184 | + // This payment should have been processed in the background, while the Order was created and charged. |
|
185 | + // So simply return the last payment. Unless it's somehow missing. |
|
186 | + $payment = $transaction->last_payment(); |
|
187 | + if (empty($payment) || $payment->status() === EEM_Payment::status_id_failed) { |
|
188 | + // Then we try processing the payment as usual. |
|
189 | + return parent::process_payment( |
|
190 | + $transaction, |
|
191 | + $amount, |
|
192 | + $billing_info, |
|
193 | + $return_url, |
|
194 | + $fail_url, |
|
195 | + $method, |
|
196 | + $by_admin |
|
197 | + ); |
|
198 | + } |
|
199 | + return $transaction->last_payment(); |
|
200 | + } |
|
201 | 201 | } |
@@ -21,75 +21,75 @@ |
||
21 | 21 | */ |
22 | 22 | class PayPalCommerce |
23 | 23 | { |
24 | - public function __construct() |
|
25 | - { |
|
26 | - } |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * Register with EE and load this payment method dependencies. |
|
31 | - * |
|
32 | - * @return void |
|
33 | - * @throws EE_Error |
|
34 | - */ |
|
35 | - public function initialize() |
|
36 | - { |
|
37 | - $this->registerDependencies(); |
|
38 | - // Register payment method through a legacy manager. |
|
39 | - add_filter( |
|
40 | - 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
41 | - [__CLASS__, 'injectPaymentMethod'] |
|
42 | - ); |
|
43 | - // Load modules. |
|
44 | - /** @var LegacyModulesManager $legacy_modules_manager */ |
|
45 | - $legacy_modules_manager = LoaderFactory::getShared(LegacyModulesManager::class); |
|
46 | - $legacy_modules_manager->registerModule(__DIR__ . '/modules/EED_PayPalCommerce.module.php'); |
|
47 | - $legacy_modules_manager->registerModule(__DIR__ . '/modules/EED_PayPalOnboard.module.php'); |
|
29 | + /** |
|
30 | + * Register with EE and load this payment method dependencies. |
|
31 | + * |
|
32 | + * @return void |
|
33 | + * @throws EE_Error |
|
34 | + */ |
|
35 | + public function initialize() |
|
36 | + { |
|
37 | + $this->registerDependencies(); |
|
38 | + // Register payment method through a legacy manager. |
|
39 | + add_filter( |
|
40 | + 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
41 | + [__CLASS__, 'injectPaymentMethod'] |
|
42 | + ); |
|
43 | + // Load modules. |
|
44 | + /** @var LegacyModulesManager $legacy_modules_manager */ |
|
45 | + $legacy_modules_manager = LoaderFactory::getShared(LegacyModulesManager::class); |
|
46 | + $legacy_modules_manager->registerModule(__DIR__ . '/modules/EED_PayPalCommerce.module.php'); |
|
47 | + $legacy_modules_manager->registerModule(__DIR__ . '/modules/EED_PayPalOnboard.module.php'); |
|
48 | 48 | |
49 | - // Setup auto loaders. |
|
50 | - EEH_Autoloader::instance()->register_autoloader([ |
|
51 | - 'SettingsForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/SettingsForm.php', |
|
52 | - 'OnboardingForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/OnboardingForm.php', |
|
53 | - 'BillingForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/BillingForm.php', |
|
54 | - ]); |
|
55 | - } |
|
49 | + // Setup auto loaders. |
|
50 | + EEH_Autoloader::instance()->register_autoloader([ |
|
51 | + 'SettingsForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/SettingsForm.php', |
|
52 | + 'OnboardingForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/OnboardingForm.php', |
|
53 | + 'BillingForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/BillingForm.php', |
|
54 | + ]); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * Add this payment to the list of PMs to be registered. |
|
60 | - * |
|
61 | - * @param array $pms_to_register |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - public static function injectPaymentMethod(array $pms_to_register): array |
|
65 | - { |
|
66 | - $pms_to_register[] = EEP_PAYPAL_COMMERCE_PATH; |
|
67 | - return $pms_to_register; |
|
68 | - } |
|
58 | + /** |
|
59 | + * Add this payment to the list of PMs to be registered. |
|
60 | + * |
|
61 | + * @param array $pms_to_register |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + public static function injectPaymentMethod(array $pms_to_register): array |
|
65 | + { |
|
66 | + $pms_to_register[] = EEP_PAYPAL_COMMERCE_PATH; |
|
67 | + return $pms_to_register; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * Register class dependencies. |
|
73 | - * |
|
74 | - * @return void |
|
75 | - * @since 5.0.22.p |
|
76 | - */ |
|
77 | - protected function registerDependencies(): void |
|
78 | - { |
|
79 | - EE_Dependency_Map::instance()->registerDependencies( |
|
80 | - 'EventEspresso\PaymentMethods\PayPalCommerce\api\orders\CreateOrder', |
|
81 | - [ |
|
82 | - null, |
|
83 | - null, |
|
84 | - null, |
|
85 | - 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => EE_Dependency_Map::load_from_cache, |
|
86 | - ] |
|
87 | - ); |
|
88 | - EE_Dependency_Map::instance()->registerDependencies( |
|
89 | - 'EventEspresso\PaymentMethods\PayPalCommerce\tools\fees\PartnerPaymentFees', |
|
90 | - [ |
|
91 | - 'EventEspresso\core\services\payments\PaymentProcessorFees' => EE_Dependency_Map::load_from_cache, |
|
92 | - ] |
|
93 | - ); |
|
94 | - } |
|
71 | + /** |
|
72 | + * Register class dependencies. |
|
73 | + * |
|
74 | + * @return void |
|
75 | + * @since 5.0.22.p |
|
76 | + */ |
|
77 | + protected function registerDependencies(): void |
|
78 | + { |
|
79 | + EE_Dependency_Map::instance()->registerDependencies( |
|
80 | + 'EventEspresso\PaymentMethods\PayPalCommerce\api\orders\CreateOrder', |
|
81 | + [ |
|
82 | + null, |
|
83 | + null, |
|
84 | + null, |
|
85 | + 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => EE_Dependency_Map::load_from_cache, |
|
86 | + ] |
|
87 | + ); |
|
88 | + EE_Dependency_Map::instance()->registerDependencies( |
|
89 | + 'EventEspresso\PaymentMethods\PayPalCommerce\tools\fees\PartnerPaymentFees', |
|
90 | + [ |
|
91 | + 'EventEspresso\core\services\payments\PaymentProcessorFees' => EE_Dependency_Map::load_from_cache, |
|
92 | + ] |
|
93 | + ); |
|
94 | + } |
|
95 | 95 | } |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | use EventEspresso\core\services\loaders\LoaderFactory; |
9 | 9 | use EventEspresso\core\services\modules\LegacyModulesManager; |
10 | 10 | |
11 | -define('EEP_PAYPAL_COMMERCE_DIR', __DIR__ . DS); |
|
12 | -define('EEP_PAYPAL_COMMERCE_PATH', __DIR__ . DS . 'PayPalCheckout' . DS); |
|
11 | +define('EEP_PAYPAL_COMMERCE_DIR', __DIR__.DS); |
|
12 | +define('EEP_PAYPAL_COMMERCE_PATH', __DIR__.DS.'PayPalCheckout'.DS); |
|
13 | 13 | define('EEP_PAYPAL_COMMERCE_URL', plugin_dir_url(__FILE__)); |
14 | 14 | |
15 | 15 | /** |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | // Load modules. |
44 | 44 | /** @var LegacyModulesManager $legacy_modules_manager */ |
45 | 45 | $legacy_modules_manager = LoaderFactory::getShared(LegacyModulesManager::class); |
46 | - $legacy_modules_manager->registerModule(__DIR__ . '/modules/EED_PayPalCommerce.module.php'); |
|
47 | - $legacy_modules_manager->registerModule(__DIR__ . '/modules/EED_PayPalOnboard.module.php'); |
|
46 | + $legacy_modules_manager->registerModule(__DIR__.'/modules/EED_PayPalCommerce.module.php'); |
|
47 | + $legacy_modules_manager->registerModule(__DIR__.'/modules/EED_PayPalOnboard.module.php'); |
|
48 | 48 | |
49 | 49 | // Setup auto loaders. |
50 | 50 | EEH_Autoloader::instance()->register_autoloader([ |
51 | - 'SettingsForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/SettingsForm.php', |
|
52 | - 'OnboardingForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/OnboardingForm.php', |
|
53 | - 'BillingForm' => EEP_PAYPAL_COMMERCE_PATH . 'forms/BillingForm.php', |
|
51 | + 'SettingsForm' => EEP_PAYPAL_COMMERCE_PATH.'forms/SettingsForm.php', |
|
52 | + 'OnboardingForm' => EEP_PAYPAL_COMMERCE_PATH.'forms/OnboardingForm.php', |
|
53 | + 'BillingForm' => EEP_PAYPAL_COMMERCE_PATH.'forms/BillingForm.php', |
|
54 | 54 | ]); |
55 | 55 | } |
56 | 56 |
@@ -17,176 +17,176 @@ |
||
17 | 17 | */ |
18 | 18 | class Domain |
19 | 19 | { |
20 | - /** |
|
21 | - * Name of the extra meta key that stores this PM options as one meta. |
|
22 | - */ |
|
23 | - public const META_KEY_PAYPAL_DATA = 'paypal_data'; |
|
24 | - /** |
|
25 | - * Name of the extra meta key that stores this PM options as one meta. |
|
26 | - */ |
|
27 | - public const META_KEY_PAYPAL_DATA_SANDBOX = 'paypal_data_sandbox'; |
|
28 | - |
|
29 | - /** |
|
30 | - * Name of the extra meta that stores whether the credentials were for the sandbox or live mode. |
|
31 | - */ |
|
32 | - public const META_KEY_SANDBOX_MODE = 'sandbox_mode'; |
|
33 | - |
|
34 | - /** |
|
35 | - * Name of the extra meta that stores the Access Token that is used to auth in API requests to PayPal. |
|
36 | - */ |
|
37 | - public const META_KEY_ACCESS_TOKEN = 'access_token'; |
|
38 | - |
|
39 | - /** |
|
40 | - * Name of the extra meta that stores the last request tracking ID. |
|
41 | - */ |
|
42 | - public const META_KEY_TRACKING_ID = 'tracking_id'; |
|
43 | - |
|
44 | - /** |
|
45 | - * Name of the extra meta that stores the Event Espresso PayPal Account's merchant id. |
|
46 | - */ |
|
47 | - public const META_KEY_APP_ID = 'app_id'; |
|
48 | - |
|
49 | - /** |
|
50 | - * Name of the extra meta that holds the seller client ID. |
|
51 | - */ |
|
52 | - public const META_KEY_CLIENT_ID = 'client_id'; |
|
53 | - |
|
54 | - /** |
|
55 | - * Name of the extra meta that holds the seller secret. |
|
56 | - */ |
|
57 | - public const META_KEY_CLIENT_SECRET = 'client_secret'; |
|
58 | - |
|
59 | - /** |
|
60 | - * Name of the extra meta that stores the expiration date of the Access Token. |
|
61 | - */ |
|
62 | - public const META_KEY_TOKEN_EXPIRES_IN = 'expires_in'; |
|
63 | - |
|
64 | - /** |
|
65 | - * Name of the extra meta that holds the partner client ID. |
|
66 | - */ |
|
67 | - public const META_KEY_PARTNER_CLIENT_ID = 'partner_client_id'; |
|
68 | - |
|
69 | - /** |
|
70 | - * Name of the extra meta that holds the partner merchant ID. |
|
71 | - */ |
|
72 | - public const META_KEY_PARTNER_MERCHANT_ID = 'partner_merchant_id'; |
|
73 | - |
|
74 | - /** |
|
75 | - * Name of the extra meta that holds the seller merchant ID. |
|
76 | - */ |
|
77 | - public const META_KEY_SELLER_MERCHANT_ID = 'merchantIdInPayPal'; |
|
78 | - |
|
79 | - /** |
|
80 | - * Name of the extra meta that holds the BN / request tracking code. |
|
81 | - */ |
|
82 | - public const META_KEY_BN_CODE = 'bn_code'; |
|
83 | - |
|
84 | - /** |
|
85 | - * Name of the extra meta that holds the last order details. |
|
86 | - */ |
|
87 | - public const META_KEY_LAST_ORDER = 'last_order_details'; |
|
88 | - |
|
89 | - /** |
|
90 | - * Name of the extra meta that holds the list of in progress orders. |
|
91 | - */ |
|
92 | - public const META_KEY_PAYPAL_ORDERS = 'paypal_orders_list'; |
|
93 | - |
|
94 | - /** |
|
95 | - * Name of the extra meta that stores the allowed PP checkout type selected by merchant while onboarding. |
|
96 | - */ |
|
97 | - public const META_KEY_ALLOWED_CHECKOUT_TYPE = 'allowed_checkout_type'; |
|
98 | - |
|
99 | - /** |
|
100 | - * Name of the extra meta that stores the merchant authorized scopes for our app to work within. |
|
101 | - */ |
|
102 | - public const META_KEY_AUTHORIZED_SCOPES = 'authorized_scopes'; |
|
103 | - |
|
104 | - /** |
|
105 | - * Name of the extra meta that stores the PP checkout type selected by merchant after onboarding. |
|
106 | - */ |
|
107 | - public const META_KEY_CHECKOUT_TYPE = 'checkout_type'; |
|
108 | - |
|
109 | - /** |
|
110 | - * Name of the PayPal API parameter that holds the auth code. |
|
111 | - */ |
|
112 | - public const API_KEY_AUTH_CODE = 'authCode'; |
|
113 | - |
|
114 | - /** |
|
115 | - * Name of the PayPal API parameter that holds the client token. |
|
116 | - */ |
|
117 | - public const API_KEY_CLIENT_TOKEN = 'client_token'; |
|
118 | - |
|
119 | - /** |
|
120 | - * Name of the extra meta that holds the seller payer ID. |
|
121 | - */ |
|
122 | - public const META_KEY_PAYER_ID = 'payer_id'; |
|
123 | - |
|
124 | - /** |
|
125 | - * Name of the PayPal API parameter that holds the client token expiration time. |
|
126 | - */ |
|
127 | - public const API_KEY_EXPIRES_IN = 'expires_in'; |
|
128 | - |
|
129 | - /** |
|
130 | - * Name of the PayPal API parameter that holds the list of oAuth integrations related to the merchant. |
|
131 | - */ |
|
132 | - public const API_PARAM_OAUTH_INTEGRATIONS = 'oauth_integrations'; |
|
133 | - |
|
134 | - /** |
|
135 | - * Name of the PayPal API parameter that holds the list of third party permissions that were granted. |
|
136 | - */ |
|
137 | - public const API_PARAM_PERMISSIONS_GRANTED = 'oauth_third_party'; |
|
138 | - |
|
139 | - /** |
|
140 | - * Name of the PayPal API parameter that holds the bool of if the primary email was confirmed. |
|
141 | - */ |
|
142 | - public const API_PARAM_PRIM_EMAIL_CONFIRMED = 'primary_email_confirmed'; |
|
143 | - |
|
144 | - /** |
|
145 | - * Name of the PayPal API parameter that holds the bool of if email was confirmed. |
|
146 | - */ |
|
147 | - public const API_PARAM_EMAIL_CONFIRMED = 'isEmailConfirmed'; |
|
148 | - |
|
149 | - /** |
|
150 | - * Name of the PayPal API parameter that holds the partner ID. |
|
151 | - */ |
|
152 | - public const API_PARAM_PARTNER_ID = 'merchantId'; |
|
153 | - |
|
154 | - /** |
|
155 | - * Name of the PayPal API parameter that holds the merchant ID in the Track seller onboarding status request. |
|
156 | - */ |
|
157 | - public const API_PARAM_TRACK_MERCHANT_ID = 'merchant_id'; |
|
158 | - |
|
159 | - /** |
|
160 | - * Name of the PayPal API parameter that holds the payments_receivable status. |
|
161 | - */ |
|
162 | - public const API_PARAM_PAYMENTS_RECEIVABLE = 'payments_receivable'; |
|
163 | - |
|
164 | - /** |
|
165 | - * Name of the nonce used in the capture order request. |
|
166 | - */ |
|
167 | - public const CAPTURE_ORDER_NONCE_NAME = 'eea_pp_commerce_capture_order_payment'; |
|
168 | - |
|
169 | - /** |
|
170 | - * Name of the nonce used in the onboarding process. |
|
171 | - */ |
|
172 | - public const NONCE_NAME_ONBOARDING_RETURN = 'eea_pp_commerce_onboarding_return'; |
|
173 | - |
|
174 | - /** |
|
175 | - * Holds this payment method slug. |
|
176 | - */ |
|
177 | - public const PM_SLUG = 'paypalcheckout'; |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * Returns the base PayPal API URL. |
|
182 | - * |
|
183 | - * @param EE_Payment_Method $payment_method |
|
184 | - * @return string |
|
185 | - * @throws EE_Error |
|
186 | - * @throws ReflectionException |
|
187 | - */ |
|
188 | - public static function getPayPalApiUrl(EE_Payment_Method $payment_method): string |
|
189 | - { |
|
190 | - return $payment_method->debug_mode() ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com'; |
|
191 | - } |
|
20 | + /** |
|
21 | + * Name of the extra meta key that stores this PM options as one meta. |
|
22 | + */ |
|
23 | + public const META_KEY_PAYPAL_DATA = 'paypal_data'; |
|
24 | + /** |
|
25 | + * Name of the extra meta key that stores this PM options as one meta. |
|
26 | + */ |
|
27 | + public const META_KEY_PAYPAL_DATA_SANDBOX = 'paypal_data_sandbox'; |
|
28 | + |
|
29 | + /** |
|
30 | + * Name of the extra meta that stores whether the credentials were for the sandbox or live mode. |
|
31 | + */ |
|
32 | + public const META_KEY_SANDBOX_MODE = 'sandbox_mode'; |
|
33 | + |
|
34 | + /** |
|
35 | + * Name of the extra meta that stores the Access Token that is used to auth in API requests to PayPal. |
|
36 | + */ |
|
37 | + public const META_KEY_ACCESS_TOKEN = 'access_token'; |
|
38 | + |
|
39 | + /** |
|
40 | + * Name of the extra meta that stores the last request tracking ID. |
|
41 | + */ |
|
42 | + public const META_KEY_TRACKING_ID = 'tracking_id'; |
|
43 | + |
|
44 | + /** |
|
45 | + * Name of the extra meta that stores the Event Espresso PayPal Account's merchant id. |
|
46 | + */ |
|
47 | + public const META_KEY_APP_ID = 'app_id'; |
|
48 | + |
|
49 | + /** |
|
50 | + * Name of the extra meta that holds the seller client ID. |
|
51 | + */ |
|
52 | + public const META_KEY_CLIENT_ID = 'client_id'; |
|
53 | + |
|
54 | + /** |
|
55 | + * Name of the extra meta that holds the seller secret. |
|
56 | + */ |
|
57 | + public const META_KEY_CLIENT_SECRET = 'client_secret'; |
|
58 | + |
|
59 | + /** |
|
60 | + * Name of the extra meta that stores the expiration date of the Access Token. |
|
61 | + */ |
|
62 | + public const META_KEY_TOKEN_EXPIRES_IN = 'expires_in'; |
|
63 | + |
|
64 | + /** |
|
65 | + * Name of the extra meta that holds the partner client ID. |
|
66 | + */ |
|
67 | + public const META_KEY_PARTNER_CLIENT_ID = 'partner_client_id'; |
|
68 | + |
|
69 | + /** |
|
70 | + * Name of the extra meta that holds the partner merchant ID. |
|
71 | + */ |
|
72 | + public const META_KEY_PARTNER_MERCHANT_ID = 'partner_merchant_id'; |
|
73 | + |
|
74 | + /** |
|
75 | + * Name of the extra meta that holds the seller merchant ID. |
|
76 | + */ |
|
77 | + public const META_KEY_SELLER_MERCHANT_ID = 'merchantIdInPayPal'; |
|
78 | + |
|
79 | + /** |
|
80 | + * Name of the extra meta that holds the BN / request tracking code. |
|
81 | + */ |
|
82 | + public const META_KEY_BN_CODE = 'bn_code'; |
|
83 | + |
|
84 | + /** |
|
85 | + * Name of the extra meta that holds the last order details. |
|
86 | + */ |
|
87 | + public const META_KEY_LAST_ORDER = 'last_order_details'; |
|
88 | + |
|
89 | + /** |
|
90 | + * Name of the extra meta that holds the list of in progress orders. |
|
91 | + */ |
|
92 | + public const META_KEY_PAYPAL_ORDERS = 'paypal_orders_list'; |
|
93 | + |
|
94 | + /** |
|
95 | + * Name of the extra meta that stores the allowed PP checkout type selected by merchant while onboarding. |
|
96 | + */ |
|
97 | + public const META_KEY_ALLOWED_CHECKOUT_TYPE = 'allowed_checkout_type'; |
|
98 | + |
|
99 | + /** |
|
100 | + * Name of the extra meta that stores the merchant authorized scopes for our app to work within. |
|
101 | + */ |
|
102 | + public const META_KEY_AUTHORIZED_SCOPES = 'authorized_scopes'; |
|
103 | + |
|
104 | + /** |
|
105 | + * Name of the extra meta that stores the PP checkout type selected by merchant after onboarding. |
|
106 | + */ |
|
107 | + public const META_KEY_CHECKOUT_TYPE = 'checkout_type'; |
|
108 | + |
|
109 | + /** |
|
110 | + * Name of the PayPal API parameter that holds the auth code. |
|
111 | + */ |
|
112 | + public const API_KEY_AUTH_CODE = 'authCode'; |
|
113 | + |
|
114 | + /** |
|
115 | + * Name of the PayPal API parameter that holds the client token. |
|
116 | + */ |
|
117 | + public const API_KEY_CLIENT_TOKEN = 'client_token'; |
|
118 | + |
|
119 | + /** |
|
120 | + * Name of the extra meta that holds the seller payer ID. |
|
121 | + */ |
|
122 | + public const META_KEY_PAYER_ID = 'payer_id'; |
|
123 | + |
|
124 | + /** |
|
125 | + * Name of the PayPal API parameter that holds the client token expiration time. |
|
126 | + */ |
|
127 | + public const API_KEY_EXPIRES_IN = 'expires_in'; |
|
128 | + |
|
129 | + /** |
|
130 | + * Name of the PayPal API parameter that holds the list of oAuth integrations related to the merchant. |
|
131 | + */ |
|
132 | + public const API_PARAM_OAUTH_INTEGRATIONS = 'oauth_integrations'; |
|
133 | + |
|
134 | + /** |
|
135 | + * Name of the PayPal API parameter that holds the list of third party permissions that were granted. |
|
136 | + */ |
|
137 | + public const API_PARAM_PERMISSIONS_GRANTED = 'oauth_third_party'; |
|
138 | + |
|
139 | + /** |
|
140 | + * Name of the PayPal API parameter that holds the bool of if the primary email was confirmed. |
|
141 | + */ |
|
142 | + public const API_PARAM_PRIM_EMAIL_CONFIRMED = 'primary_email_confirmed'; |
|
143 | + |
|
144 | + /** |
|
145 | + * Name of the PayPal API parameter that holds the bool of if email was confirmed. |
|
146 | + */ |
|
147 | + public const API_PARAM_EMAIL_CONFIRMED = 'isEmailConfirmed'; |
|
148 | + |
|
149 | + /** |
|
150 | + * Name of the PayPal API parameter that holds the partner ID. |
|
151 | + */ |
|
152 | + public const API_PARAM_PARTNER_ID = 'merchantId'; |
|
153 | + |
|
154 | + /** |
|
155 | + * Name of the PayPal API parameter that holds the merchant ID in the Track seller onboarding status request. |
|
156 | + */ |
|
157 | + public const API_PARAM_TRACK_MERCHANT_ID = 'merchant_id'; |
|
158 | + |
|
159 | + /** |
|
160 | + * Name of the PayPal API parameter that holds the payments_receivable status. |
|
161 | + */ |
|
162 | + public const API_PARAM_PAYMENTS_RECEIVABLE = 'payments_receivable'; |
|
163 | + |
|
164 | + /** |
|
165 | + * Name of the nonce used in the capture order request. |
|
166 | + */ |
|
167 | + public const CAPTURE_ORDER_NONCE_NAME = 'eea_pp_commerce_capture_order_payment'; |
|
168 | + |
|
169 | + /** |
|
170 | + * Name of the nonce used in the onboarding process. |
|
171 | + */ |
|
172 | + public const NONCE_NAME_ONBOARDING_RETURN = 'eea_pp_commerce_onboarding_return'; |
|
173 | + |
|
174 | + /** |
|
175 | + * Holds this payment method slug. |
|
176 | + */ |
|
177 | + public const PM_SLUG = 'paypalcheckout'; |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * Returns the base PayPal API URL. |
|
182 | + * |
|
183 | + * @param EE_Payment_Method $payment_method |
|
184 | + * @return string |
|
185 | + * @throws EE_Error |
|
186 | + * @throws ReflectionException |
|
187 | + */ |
|
188 | + public static function getPayPalApiUrl(EE_Payment_Method $payment_method): string |
|
189 | + { |
|
190 | + return $payment_method->debug_mode() ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com'; |
|
191 | + } |
|
192 | 192 | } |
@@ -16,24 +16,24 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class ClientsApi |
18 | 18 | { |
19 | - protected PayPalApi $api; |
|
19 | + protected PayPalApi $api; |
|
20 | 20 | |
21 | - protected string $request_url; |
|
21 | + protected string $request_url; |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * ClientsApi constructor. |
|
26 | - * |
|
27 | - * @param PayPalApi $api |
|
28 | - * @param bool $sandbox_mode |
|
29 | - */ |
|
30 | - public function __construct(PayPalApi $api, bool $sandbox_mode = true) |
|
31 | - { |
|
32 | - $this->api = $api; |
|
33 | - // Is this a sandbox request. |
|
34 | - $api_endpoint = $sandbox_mode |
|
35 | - ? 'https://api-m.sandbox.paypal.com/' |
|
36 | - : 'https://api-m.paypal.com/'; |
|
37 | - $this->request_url = $api_endpoint . 'v1/identity'; |
|
38 | - } |
|
24 | + /** |
|
25 | + * ClientsApi constructor. |
|
26 | + * |
|
27 | + * @param PayPalApi $api |
|
28 | + * @param bool $sandbox_mode |
|
29 | + */ |
|
30 | + public function __construct(PayPalApi $api, bool $sandbox_mode = true) |
|
31 | + { |
|
32 | + $this->api = $api; |
|
33 | + // Is this a sandbox request. |
|
34 | + $api_endpoint = $sandbox_mode |
|
35 | + ? 'https://api-m.sandbox.paypal.com/' |
|
36 | + : 'https://api-m.paypal.com/'; |
|
37 | + $this->request_url = $api_endpoint . 'v1/identity'; |
|
38 | + } |
|
39 | 39 | } |
@@ -18,57 +18,57 @@ |
||
18 | 18 | */ |
19 | 19 | class ClientToken extends ClientsApi |
20 | 20 | { |
21 | - /** |
|
22 | - * ClientToken constructor. |
|
23 | - * |
|
24 | - * @param PayPalApi $api |
|
25 | - * @param bool $sandbox_mode |
|
26 | - */ |
|
27 | - public function __construct(PayPalApi $api, bool $sandbox_mode) |
|
28 | - { |
|
29 | - parent::__construct($api, $sandbox_mode); |
|
30 | - $this->request_url = $this->request_url . "/generate-token"; |
|
31 | - } |
|
21 | + /** |
|
22 | + * ClientToken constructor. |
|
23 | + * |
|
24 | + * @param PayPalApi $api |
|
25 | + * @param bool $sandbox_mode |
|
26 | + */ |
|
27 | + public function __construct(PayPalApi $api, bool $sandbox_mode) |
|
28 | + { |
|
29 | + parent::__construct($api, $sandbox_mode); |
|
30 | + $this->request_url = $this->request_url . "/generate-token"; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Get the onboarding status and validate it. |
|
36 | - * |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function getToken(): array |
|
40 | - { |
|
41 | - // Send GET request. |
|
42 | - $response = $this->api->sendRequest([], $this->request_url); |
|
43 | - return $this->validateResponse($response); |
|
44 | - } |
|
34 | + /** |
|
35 | + * Get the onboarding status and validate it. |
|
36 | + * |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function getToken(): array |
|
40 | + { |
|
41 | + // Send GET request. |
|
42 | + $response = $this->api->sendRequest([], $this->request_url); |
|
43 | + return $this->validateResponse($response); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * Makes sure that we have received the client token. Returns an error as array if not. |
|
49 | - * |
|
50 | - * @param array $response |
|
51 | - * @return array |
|
52 | - */ |
|
53 | - public function validateResponse(array $response): array |
|
54 | - { |
|
55 | - // Could this be an error ? |
|
56 | - if (! empty($response['error'])) { |
|
57 | - return $response; |
|
58 | - } |
|
59 | - if (! empty($response['name']) && ! empty($response['message'])) { |
|
60 | - return ['error' => $response['name'], 'message' => $response['message']]; |
|
61 | - } |
|
62 | - // Check the data we received. |
|
63 | - if (empty($response[ Domain::API_KEY_CLIENT_TOKEN ])) { |
|
64 | - $err_msg = esc_html__('No client token was found in the Client Token request response.', 'event_espresso'); |
|
65 | - PayPalLogger::errorLog($err_msg, $response); |
|
66 | - return ['error' => 'ONBOARDING_MISSING_CLIENT_TOKEN', 'message' => $err_msg]; |
|
67 | - } |
|
68 | - return [ |
|
69 | - 'valid' => true, |
|
70 | - 'client_token' => $response[ Domain::API_KEY_CLIENT_TOKEN ], |
|
71 | - 'expires_in' => $response[ Domain::API_KEY_EXPIRES_IN ], |
|
72 | - ]; |
|
73 | - } |
|
47 | + /** |
|
48 | + * Makes sure that we have received the client token. Returns an error as array if not. |
|
49 | + * |
|
50 | + * @param array $response |
|
51 | + * @return array |
|
52 | + */ |
|
53 | + public function validateResponse(array $response): array |
|
54 | + { |
|
55 | + // Could this be an error ? |
|
56 | + if (! empty($response['error'])) { |
|
57 | + return $response; |
|
58 | + } |
|
59 | + if (! empty($response['name']) && ! empty($response['message'])) { |
|
60 | + return ['error' => $response['name'], 'message' => $response['message']]; |
|
61 | + } |
|
62 | + // Check the data we received. |
|
63 | + if (empty($response[ Domain::API_KEY_CLIENT_TOKEN ])) { |
|
64 | + $err_msg = esc_html__('No client token was found in the Client Token request response.', 'event_espresso'); |
|
65 | + PayPalLogger::errorLog($err_msg, $response); |
|
66 | + return ['error' => 'ONBOARDING_MISSING_CLIENT_TOKEN', 'message' => $err_msg]; |
|
67 | + } |
|
68 | + return [ |
|
69 | + 'valid' => true, |
|
70 | + 'client_token' => $response[ Domain::API_KEY_CLIENT_TOKEN ], |
|
71 | + 'expires_in' => $response[ Domain::API_KEY_EXPIRES_IN ], |
|
72 | + ]; |
|
73 | + } |
|
74 | 74 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public function __construct(PayPalApi $api, bool $sandbox_mode) |
28 | 28 | { |
29 | 29 | parent::__construct($api, $sandbox_mode); |
30 | - $this->request_url = $this->request_url . "/generate-token"; |
|
30 | + $this->request_url = $this->request_url."/generate-token"; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -53,22 +53,22 @@ discard block |
||
53 | 53 | public function validateResponse(array $response): array |
54 | 54 | { |
55 | 55 | // Could this be an error ? |
56 | - if (! empty($response['error'])) { |
|
56 | + if ( ! empty($response['error'])) { |
|
57 | 57 | return $response; |
58 | 58 | } |
59 | - if (! empty($response['name']) && ! empty($response['message'])) { |
|
59 | + if ( ! empty($response['name']) && ! empty($response['message'])) { |
|
60 | 60 | return ['error' => $response['name'], 'message' => $response['message']]; |
61 | 61 | } |
62 | 62 | // Check the data we received. |
63 | - if (empty($response[ Domain::API_KEY_CLIENT_TOKEN ])) { |
|
63 | + if (empty($response[Domain::API_KEY_CLIENT_TOKEN])) { |
|
64 | 64 | $err_msg = esc_html__('No client token was found in the Client Token request response.', 'event_espresso'); |
65 | 65 | PayPalLogger::errorLog($err_msg, $response); |
66 | 66 | return ['error' => 'ONBOARDING_MISSING_CLIENT_TOKEN', 'message' => $err_msg]; |
67 | 67 | } |
68 | 68 | return [ |
69 | 69 | 'valid' => true, |
70 | - 'client_token' => $response[ Domain::API_KEY_CLIENT_TOKEN ], |
|
71 | - 'expires_in' => $response[ Domain::API_KEY_EXPIRES_IN ], |
|
70 | + 'client_token' => $response[Domain::API_KEY_CLIENT_TOKEN], |
|
71 | + 'expires_in' => $response[Domain::API_KEY_EXPIRES_IN], |
|
72 | 72 | ]; |
73 | 73 | } |
74 | 74 | } |