@@ -5,38 +5,38 @@ |
||
5 | 5 | |
6 | 6 | <?php |
7 | 7 | $settings_array = array( |
8 | - 'max_registrants' => '<p> |
|
8 | + 'max_registrants' => '<p> |
|
9 | 9 | <label for="max-registrants">' |
10 | - . esc_html__( |
|
11 | - 'Maximum number of tickets allowed per order for this event: ', |
|
12 | - 'event_espresso' |
|
13 | - ) . '</label> |
|
10 | + . esc_html__( |
|
11 | + 'Maximum number of tickets allowed per order for this event: ', |
|
12 | + 'event_espresso' |
|
13 | + ) . '</label> |
|
14 | 14 | <input class="ee-numeric" type="text" id="max-registrants" name="additional_limit" value="' . $additional_limit . '" size="4" /> |
15 | 15 | </p>', |
16 | - 'additional_registration_options' => $additional_registration_options, |
|
17 | - 'display_ticket_selector' => '<p> |
|
16 | + 'additional_registration_options' => $additional_registration_options, |
|
17 | + 'display_ticket_selector' => '<p> |
|
18 | 18 | <label>' . esc_html__('Display Ticket Selector', 'event_espresso') . '</label>' . $display_ticket_selector . '</p>', |
19 | - 'alternative_registration_page' => '<p> |
|
19 | + 'alternative_registration_page' => '<p> |
|
20 | 20 | <label>' . esc_html__('Alternative Registration Page', 'event_espresso') . '</label> |
21 | 21 | <input name="externalURL" size="20" type="text" value="' . $_event->external_url() . '"> |
22 | 22 | </p>', |
23 | - 'event_phone_number' => '<p> |
|
23 | + 'event_phone_number' => '<p> |
|
24 | 24 | <label>' . esc_html__('Event Phone Number', 'event_espresso') . '</label> |
25 | 25 | <input name="event_phone" size="20" type="text" value="' . $_event->phone() . '"> |
26 | 26 | </p>', |
27 | - 'default_registration_status' => '<p> |
|
27 | + 'default_registration_status' => '<p> |
|
28 | 28 | <label>' |
29 | - . esc_html__( |
|
30 | - 'Default Registration Status', |
|
31 | - 'event_espresso' |
|
32 | - ) . '</label>' |
|
33 | - . EEH_Template::get_help_tab_link('event_editor_event_registration_options_help_tab') |
|
34 | - . $EVT_default_registration_status . '</p>', |
|
29 | + . esc_html__( |
|
30 | + 'Default Registration Status', |
|
31 | + 'event_espresso' |
|
32 | + ) . '</label>' |
|
33 | + . EEH_Template::get_help_tab_link('event_editor_event_registration_options_help_tab') |
|
34 | + . $EVT_default_registration_status . '</p>', |
|
35 | 35 | ); |
36 | 36 | // filter |
37 | 37 | $settings_array = apply_filters('FHEE__caffeinated_event_registration_options__template__settings', $settings_array); |
38 | 38 | |
39 | 39 | // echo |
40 | 40 | foreach ($settings_array as $item) { |
41 | - echo $item; |
|
41 | + echo $item; |
|
42 | 42 | } |
@@ -10,28 +10,28 @@ |
||
10 | 10 | . esc_html__( |
11 | 11 | 'Maximum number of tickets allowed per order for this event: ', |
12 | 12 | 'event_espresso' |
13 | - ) . '</label> |
|
14 | - <input class="ee-numeric" type="text" id="max-registrants" name="additional_limit" value="' . $additional_limit . '" size="4" /> |
|
13 | + ).'</label> |
|
14 | + <input class="ee-numeric" type="text" id="max-registrants" name="additional_limit" value="' . $additional_limit.'" size="4" /> |
|
15 | 15 | </p>', |
16 | 16 | 'additional_registration_options' => $additional_registration_options, |
17 | 17 | 'display_ticket_selector' => '<p> |
18 | - <label>' . esc_html__('Display Ticket Selector', 'event_espresso') . '</label>' . $display_ticket_selector . '</p>', |
|
18 | + <label>' . esc_html__('Display Ticket Selector', 'event_espresso').'</label>'.$display_ticket_selector.'</p>', |
|
19 | 19 | 'alternative_registration_page' => '<p> |
20 | - <label>' . esc_html__('Alternative Registration Page', 'event_espresso') . '</label> |
|
21 | - <input name="externalURL" size="20" type="text" value="' . $_event->external_url() . '"> |
|
20 | + <label>' . esc_html__('Alternative Registration Page', 'event_espresso').'</label> |
|
21 | + <input name="externalURL" size="20" type="text" value="' . $_event->external_url().'"> |
|
22 | 22 | </p>', |
23 | 23 | 'event_phone_number' => '<p> |
24 | - <label>' . esc_html__('Event Phone Number', 'event_espresso') . '</label> |
|
25 | - <input name="event_phone" size="20" type="text" value="' . $_event->phone() . '"> |
|
24 | + <label>' . esc_html__('Event Phone Number', 'event_espresso').'</label> |
|
25 | + <input name="event_phone" size="20" type="text" value="' . $_event->phone().'"> |
|
26 | 26 | </p>', |
27 | 27 | 'default_registration_status' => '<p> |
28 | 28 | <label>' |
29 | 29 | . esc_html__( |
30 | 30 | 'Default Registration Status', |
31 | 31 | 'event_espresso' |
32 | - ) . '</label>' |
|
32 | + ).'</label>' |
|
33 | 33 | . EEH_Template::get_help_tab_link('event_editor_event_registration_options_help_tab') |
34 | - . $EVT_default_registration_status . '</p>', |
|
34 | + . $EVT_default_registration_status.'</p>', |
|
35 | 35 | ); |
36 | 36 | // filter |
37 | 37 | $settings_array = apply_filters('FHEE__caffeinated_event_registration_options__template__settings', $settings_array); |
@@ -57,38 +57,38 @@ |
||
57 | 57 | <div> |
58 | 58 | <strong><?php echo EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'); ?></strong><br /> |
59 | 59 | <?php printf( |
60 | - esc_html__( |
|
61 | - /* translators: Approved Registration status */ |
|
62 | - 'A status of %s means that a registration has been accepted as complete. The registration will count towards the registration limit, remaining tickets, and calculations for available seats. Payments (if necessary) can also be made by primary registrants with this status.', |
|
63 | - 'event_espresso' |
|
64 | - ), |
|
65 | - EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') |
|
60 | + esc_html__( |
|
61 | + /* translators: Approved Registration status */ |
|
62 | + 'A status of %s means that a registration has been accepted as complete. The registration will count towards the registration limit, remaining tickets, and calculations for available seats. Payments (if necessary) can also be made by primary registrants with this status.', |
|
63 | + 'event_espresso' |
|
64 | + ), |
|
65 | + EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') |
|
66 | 66 | ); ?> |
67 | 67 | </div> |
68 | 68 | <div> |
69 | 69 | <strong><?php echo EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'); ?></strong><br /> |
70 | 70 | <?php printf( |
71 | - esc_html__( |
|
72 | - /* translators: 1: Pending Payment, 2: Pending Payment, 3: Approved */ |
|
73 | - 'A status of %1$s means that a registration has not paid but they ARE able to make payments (if necessary). %2$s registrations do NOT count towards registration limits, remaining tickets, and calculations for available seats. If registration for a free event occurs, then registrations are automatically set to %3$s. For paid tickets, %1$s registrations are set to %3$s when full payment is recorded.', |
|
74 | - 'event_espresso' |
|
75 | - ), |
|
76 | - EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
77 | - EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
78 | - EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') |
|
71 | + esc_html__( |
|
72 | + /* translators: 1: Pending Payment, 2: Pending Payment, 3: Approved */ |
|
73 | + 'A status of %1$s means that a registration has not paid but they ARE able to make payments (if necessary). %2$s registrations do NOT count towards registration limits, remaining tickets, and calculations for available seats. If registration for a free event occurs, then registrations are automatically set to %3$s. For paid tickets, %1$s registrations are set to %3$s when full payment is recorded.', |
|
74 | + 'event_espresso' |
|
75 | + ), |
|
76 | + EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
77 | + EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
78 | + EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') |
|
79 | 79 | ); ?> |
80 | 80 | </div> |
81 | 81 | <div> |
82 | 82 | <strong><?php echo EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'); ?></strong><br /> |
83 | 83 | <?php printf( |
84 | - esc_html__( |
|
85 | - /* translators: 1: Not Approved, 2: Pending Payment, 3: Approved */ |
|
86 | - 'A status of %1$s means that a registration has not paid and they cannot make payments for towards an event. Un-approved registrations do NOT count towards registration limits, remaining tickets, and calculations for available seats. This setting differs from the "%2$s" default in that free ticket registrations and paid in full ticket registrations do NOT automatically switch the Registration to %3$s. Instead, the event admin must manually set the registration to either "%2$s" for registrations requiring payments, or "%3$s" for free events.', |
|
87 | - 'event_espresso' |
|
88 | - ), |
|
89 | - EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
90 | - EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'upper'), |
|
91 | - EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'upper') |
|
84 | + esc_html__( |
|
85 | + /* translators: 1: Not Approved, 2: Pending Payment, 3: Approved */ |
|
86 | + 'A status of %1$s means that a registration has not paid and they cannot make payments for towards an event. Un-approved registrations do NOT count towards registration limits, remaining tickets, and calculations for available seats. This setting differs from the "%2$s" default in that free ticket registrations and paid in full ticket registrations do NOT automatically switch the Registration to %3$s. Instead, the event admin must manually set the registration to either "%2$s" for registrations requiring payments, or "%3$s" for free events.', |
|
87 | + 'event_espresso' |
|
88 | + ), |
|
89 | + EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
90 | + EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'upper'), |
|
91 | + EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'upper') |
|
92 | 92 | ); ?> |
93 | 93 | </div> |
94 | 94 | </li> |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function getLoader() |
115 | 115 | { |
116 | - if (!$this->loader instanceof LoaderInterface) { |
|
116 | + if ( ! $this->loader instanceof LoaderInterface) { |
|
117 | 117 | $this->loader = LoaderFactory::getLoader(); |
118 | 118 | } |
119 | 119 | return $this->loader; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
151 | 151 | wp_enqueue_script( |
152 | 152 | 'batch_runner_init', |
153 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
153 | + BATCH_URL.'assets/batch_runner_init.js', |
|
154 | 154 | array('batch_runner'), |
155 | 155 | EVENT_ESPRESSO_VERSION, |
156 | 156 | true |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
175 | 175 | wp_enqueue_script( |
176 | 176 | 'batch_file_runner_init', |
177 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
177 | + BATCH_URL.'assets/batch_file_runner_init.js', |
|
178 | 178 | array('batch_runner'), |
179 | 179 | EVENT_ESPRESSO_VERSION, |
180 | 180 | true |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | array( |
187 | 187 | 'download_and_redirecting' => sprintf( |
188 | 188 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
189 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
189 | + '<a href="'.$_REQUEST['return_url'].'">', |
|
190 | 190 | '</a>' |
191 | 191 | ), |
192 | 192 | 'return_url' => $_REQUEST['return_url'], |
@@ -204,26 +204,26 @@ discard block |
||
204 | 204 | protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
205 | 205 | { |
206 | 206 | // just copy the bits of EE admin's eei18n that we need in the JS |
207 | - EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
207 | + EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
208 | 208 | 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
209 | 209 | 'event_espresso' |
210 | 210 | ); |
211 | 211 | wp_register_script( |
212 | 212 | 'progress_bar', |
213 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
213 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', |
|
214 | 214 | array('jquery'), |
215 | 215 | EVENT_ESPRESSO_VERSION, |
216 | 216 | true |
217 | 217 | ); |
218 | 218 | wp_enqueue_style( |
219 | 219 | 'progress_bar', |
220 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
220 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', |
|
221 | 221 | array(), |
222 | 222 | EVENT_ESPRESSO_VERSION |
223 | 223 | ); |
224 | 224 | wp_enqueue_script( |
225 | 225 | 'batch_runner', |
226 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
226 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', |
|
227 | 227 | array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
228 | 228 | EVENT_ESPRESSO_VERSION, |
229 | 229 | true |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | public function override_template($template) |
251 | 251 | { |
252 | 252 | if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
253 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
253 | + return EE_MODULES.'batch'.DS.'templates'.DS.'batch_frontend_wrapper.template.html'; |
|
254 | 254 | } |
255 | 255 | return $template; |
256 | 256 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | public function show_admin_page() |
278 | 278 | { |
279 | 279 | echo EEH_Template::locate_template( |
280 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
280 | + EE_MODULES.'batch'.DS.'templates'.DS.'batch_wrapper.template.html', |
|
281 | 281 | array('batch_request_type' => $this->batch_request_type()) |
282 | 282 | ); |
283 | 283 | } |
@@ -29,355 +29,355 @@ |
||
29 | 29 | class EED_Batch extends EED_Module |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
34 | - * processes data only |
|
35 | - */ |
|
36 | - const batch_job = 'job'; |
|
37 | - /** |
|
38 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
39 | - * produces a file for download |
|
40 | - */ |
|
41 | - const batch_file_job = 'file'; |
|
42 | - /** |
|
43 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
44 | - * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
45 | - * at all |
|
46 | - */ |
|
47 | - const batch_not_job = 'none'; |
|
32 | + /** |
|
33 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
34 | + * processes data only |
|
35 | + */ |
|
36 | + const batch_job = 'job'; |
|
37 | + /** |
|
38 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
39 | + * produces a file for download |
|
40 | + */ |
|
41 | + const batch_file_job = 'file'; |
|
42 | + /** |
|
43 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
44 | + * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
45 | + * at all |
|
46 | + */ |
|
47 | + const batch_not_job = 'none'; |
|
48 | 48 | |
49 | - /** |
|
50 | - * |
|
51 | - * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
52 | - */ |
|
53 | - protected $_batch_request_type = null; |
|
49 | + /** |
|
50 | + * |
|
51 | + * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
52 | + */ |
|
53 | + protected $_batch_request_type = null; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Because we want to use the response in both the localized JS and in the body |
|
57 | - * we need to make this response available between method calls |
|
58 | - * |
|
59 | - * @var \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
60 | - */ |
|
61 | - protected $_job_step_response = null; |
|
55 | + /** |
|
56 | + * Because we want to use the response in both the localized JS and in the body |
|
57 | + * we need to make this response available between method calls |
|
58 | + * |
|
59 | + * @var \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
60 | + */ |
|
61 | + protected $_job_step_response = null; |
|
62 | 62 | |
63 | - /** |
|
64 | - * @var LoaderInterface |
|
65 | - */ |
|
66 | - protected $loader; |
|
63 | + /** |
|
64 | + * @var LoaderInterface |
|
65 | + */ |
|
66 | + protected $loader; |
|
67 | 67 | |
68 | - /** |
|
69 | - * Gets the batch instance |
|
70 | - * |
|
71 | - * @return EED_Batch |
|
72 | - */ |
|
73 | - public static function instance() |
|
74 | - { |
|
75 | - return self::get_instance(); |
|
76 | - } |
|
68 | + /** |
|
69 | + * Gets the batch instance |
|
70 | + * |
|
71 | + * @return EED_Batch |
|
72 | + */ |
|
73 | + public static function instance() |
|
74 | + { |
|
75 | + return self::get_instance(); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
80 | - * because it's an attack vector and there are currently no implementations |
|
81 | - */ |
|
82 | - public static function set_hooks() |
|
83 | - { |
|
84 | - // because this is a possibel attack vector, let's have this disabled until |
|
85 | - // we at least have a real use for it on the frontend |
|
86 | - if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
87 | - add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
88 | - add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
89 | - } |
|
90 | - } |
|
78 | + /** |
|
79 | + * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
80 | + * because it's an attack vector and there are currently no implementations |
|
81 | + */ |
|
82 | + public static function set_hooks() |
|
83 | + { |
|
84 | + // because this is a possibel attack vector, let's have this disabled until |
|
85 | + // we at least have a real use for it on the frontend |
|
86 | + if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
87 | + add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
88 | + add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Initializes some hooks for the admin in order to run batch jobs |
|
94 | - */ |
|
95 | - public static function set_hooks_admin() |
|
96 | - { |
|
97 | - add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
98 | - add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
92 | + /** |
|
93 | + * Initializes some hooks for the admin in order to run batch jobs |
|
94 | + */ |
|
95 | + public static function set_hooks_admin() |
|
96 | + { |
|
97 | + add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
98 | + add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
99 | 99 | |
100 | - // ajax |
|
101 | - add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
102 | - add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
103 | - add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
104 | - add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
105 | - } |
|
100 | + // ajax |
|
101 | + add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
102 | + add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
103 | + add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
104 | + add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @since 4.9.80.p |
|
109 | - * @return LoaderInterface |
|
110 | - * @throws InvalidArgumentException |
|
111 | - * @throws InvalidDataTypeException |
|
112 | - * @throws InvalidInterfaceException |
|
113 | - */ |
|
114 | - protected function getLoader() |
|
115 | - { |
|
116 | - if (!$this->loader instanceof LoaderInterface) { |
|
117 | - $this->loader = LoaderFactory::getLoader(); |
|
118 | - } |
|
119 | - return $this->loader; |
|
120 | - } |
|
107 | + /** |
|
108 | + * @since 4.9.80.p |
|
109 | + * @return LoaderInterface |
|
110 | + * @throws InvalidArgumentException |
|
111 | + * @throws InvalidDataTypeException |
|
112 | + * @throws InvalidInterfaceException |
|
113 | + */ |
|
114 | + protected function getLoader() |
|
115 | + { |
|
116 | + if (!$this->loader instanceof LoaderInterface) { |
|
117 | + $this->loader = LoaderFactory::getLoader(); |
|
118 | + } |
|
119 | + return $this->loader; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Enqueues batch scripts on the frontend or admin, and creates a job |
|
124 | - */ |
|
125 | - public function enqueue_scripts() |
|
126 | - { |
|
127 | - if (isset($_REQUEST['espresso_batch']) |
|
128 | - || |
|
129 | - ( |
|
130 | - isset($_REQUEST['page']) |
|
131 | - && $_REQUEST['page'] == 'espresso_batch' |
|
132 | - ) |
|
133 | - ) { |
|
134 | - switch ($this->batch_request_type()) { |
|
135 | - case self::batch_job: |
|
136 | - $this->enqueue_scripts_styles_batch_create(); |
|
137 | - break; |
|
138 | - case self::batch_file_job: |
|
139 | - $this->enqueue_scripts_styles_batch_file_create(); |
|
140 | - break; |
|
141 | - } |
|
142 | - } |
|
143 | - } |
|
122 | + /** |
|
123 | + * Enqueues batch scripts on the frontend or admin, and creates a job |
|
124 | + */ |
|
125 | + public function enqueue_scripts() |
|
126 | + { |
|
127 | + if (isset($_REQUEST['espresso_batch']) |
|
128 | + || |
|
129 | + ( |
|
130 | + isset($_REQUEST['page']) |
|
131 | + && $_REQUEST['page'] == 'espresso_batch' |
|
132 | + ) |
|
133 | + ) { |
|
134 | + switch ($this->batch_request_type()) { |
|
135 | + case self::batch_job: |
|
136 | + $this->enqueue_scripts_styles_batch_create(); |
|
137 | + break; |
|
138 | + case self::batch_file_job: |
|
139 | + $this->enqueue_scripts_styles_batch_file_create(); |
|
140 | + break; |
|
141 | + } |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
147 | - */ |
|
148 | - public function enqueue_scripts_styles_batch_create() |
|
149 | - { |
|
150 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
151 | - wp_enqueue_script( |
|
152 | - 'batch_runner_init', |
|
153 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
154 | - array('batch_runner'), |
|
155 | - EVENT_ESPRESSO_VERSION, |
|
156 | - true |
|
157 | - ); |
|
158 | - wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
159 | - wp_localize_script( |
|
160 | - 'batch_runner_init', |
|
161 | - 'ee_job_i18n', |
|
162 | - array( |
|
163 | - 'return_url' => $_REQUEST['return_url'], |
|
164 | - ) |
|
165 | - ); |
|
166 | - } |
|
145 | + /** |
|
146 | + * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
147 | + */ |
|
148 | + public function enqueue_scripts_styles_batch_create() |
|
149 | + { |
|
150 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
151 | + wp_enqueue_script( |
|
152 | + 'batch_runner_init', |
|
153 | + BATCH_URL . 'assets/batch_runner_init.js', |
|
154 | + array('batch_runner'), |
|
155 | + EVENT_ESPRESSO_VERSION, |
|
156 | + true |
|
157 | + ); |
|
158 | + wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
159 | + wp_localize_script( |
|
160 | + 'batch_runner_init', |
|
161 | + 'ee_job_i18n', |
|
162 | + array( |
|
163 | + 'return_url' => $_REQUEST['return_url'], |
|
164 | + ) |
|
165 | + ); |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
170 | - */ |
|
171 | - public function enqueue_scripts_styles_batch_file_create() |
|
172 | - { |
|
173 | - // creates a job based on the request variable |
|
174 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
175 | - wp_enqueue_script( |
|
176 | - 'batch_file_runner_init', |
|
177 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
178 | - array('batch_runner'), |
|
179 | - EVENT_ESPRESSO_VERSION, |
|
180 | - true |
|
181 | - ); |
|
182 | - wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
183 | - wp_localize_script( |
|
184 | - 'batch_file_runner_init', |
|
185 | - 'ee_job_i18n', |
|
186 | - array( |
|
187 | - 'download_and_redirecting' => sprintf( |
|
188 | - __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
189 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
190 | - '</a>' |
|
191 | - ), |
|
192 | - 'return_url' => $_REQUEST['return_url'], |
|
193 | - ) |
|
194 | - ); |
|
195 | - } |
|
168 | + /** |
|
169 | + * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
170 | + */ |
|
171 | + public function enqueue_scripts_styles_batch_file_create() |
|
172 | + { |
|
173 | + // creates a job based on the request variable |
|
174 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
175 | + wp_enqueue_script( |
|
176 | + 'batch_file_runner_init', |
|
177 | + BATCH_URL . 'assets/batch_file_runner_init.js', |
|
178 | + array('batch_runner'), |
|
179 | + EVENT_ESPRESSO_VERSION, |
|
180 | + true |
|
181 | + ); |
|
182 | + wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
183 | + wp_localize_script( |
|
184 | + 'batch_file_runner_init', |
|
185 | + 'ee_job_i18n', |
|
186 | + array( |
|
187 | + 'download_and_redirecting' => sprintf( |
|
188 | + __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
189 | + '<a href="' . $_REQUEST['return_url'] . '">', |
|
190 | + '</a>' |
|
191 | + ), |
|
192 | + 'return_url' => $_REQUEST['return_url'], |
|
193 | + ) |
|
194 | + ); |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * Enqueues scripts and styles common to any batch job, and creates |
|
199 | - * a job from the request data, and stores the response in the |
|
200 | - * $this->_job_step_response property |
|
201 | - * |
|
202 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
203 | - */ |
|
204 | - protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
205 | - { |
|
206 | - // just copy the bits of EE admin's eei18n that we need in the JS |
|
207 | - EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
208 | - 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
209 | - 'event_espresso' |
|
210 | - ); |
|
211 | - wp_register_script( |
|
212 | - 'progress_bar', |
|
213 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
214 | - array('jquery'), |
|
215 | - EVENT_ESPRESSO_VERSION, |
|
216 | - true |
|
217 | - ); |
|
218 | - wp_enqueue_style( |
|
219 | - 'progress_bar', |
|
220 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
221 | - array(), |
|
222 | - EVENT_ESPRESSO_VERSION |
|
223 | - ); |
|
224 | - wp_enqueue_script( |
|
225 | - 'batch_runner', |
|
226 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
227 | - array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
|
228 | - EVENT_ESPRESSO_VERSION, |
|
229 | - true |
|
230 | - ); |
|
231 | - $job_handler_classname = stripslashes($_GET['job_handler']); |
|
232 | - $request_data = array_diff_key( |
|
233 | - $_REQUEST, |
|
234 | - array_flip(array('action', 'page', 'ee', 'batch')) |
|
235 | - ); |
|
236 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
237 | - // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
238 | - $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
239 | - // remember the response for later. We need it to display the page body |
|
240 | - $this->_job_step_response = $job_response; |
|
241 | - return $job_response; |
|
242 | - } |
|
197 | + /** |
|
198 | + * Enqueues scripts and styles common to any batch job, and creates |
|
199 | + * a job from the request data, and stores the response in the |
|
200 | + * $this->_job_step_response property |
|
201 | + * |
|
202 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
203 | + */ |
|
204 | + protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
205 | + { |
|
206 | + // just copy the bits of EE admin's eei18n that we need in the JS |
|
207 | + EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
208 | + 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
209 | + 'event_espresso' |
|
210 | + ); |
|
211 | + wp_register_script( |
|
212 | + 'progress_bar', |
|
213 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
214 | + array('jquery'), |
|
215 | + EVENT_ESPRESSO_VERSION, |
|
216 | + true |
|
217 | + ); |
|
218 | + wp_enqueue_style( |
|
219 | + 'progress_bar', |
|
220 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
221 | + array(), |
|
222 | + EVENT_ESPRESSO_VERSION |
|
223 | + ); |
|
224 | + wp_enqueue_script( |
|
225 | + 'batch_runner', |
|
226 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
227 | + array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
|
228 | + EVENT_ESPRESSO_VERSION, |
|
229 | + true |
|
230 | + ); |
|
231 | + $job_handler_classname = stripslashes($_GET['job_handler']); |
|
232 | + $request_data = array_diff_key( |
|
233 | + $_REQUEST, |
|
234 | + array_flip(array('action', 'page', 'ee', 'batch')) |
|
235 | + ); |
|
236 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
237 | + // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
238 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
239 | + // remember the response for later. We need it to display the page body |
|
240 | + $this->_job_step_response = $job_response; |
|
241 | + return $job_response; |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
246 | - * |
|
247 | - * @param string $template |
|
248 | - * @return string |
|
249 | - */ |
|
250 | - public function override_template($template) |
|
251 | - { |
|
252 | - if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
253 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
254 | - } |
|
255 | - return $template; |
|
256 | - } |
|
244 | + /** |
|
245 | + * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
246 | + * |
|
247 | + * @param string $template |
|
248 | + * @return string |
|
249 | + */ |
|
250 | + public function override_template($template) |
|
251 | + { |
|
252 | + if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
253 | + return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
254 | + } |
|
255 | + return $template; |
|
256 | + } |
|
257 | 257 | |
258 | - /** |
|
259 | - * Adds an admin page which doesn't appear in the admin menu |
|
260 | - */ |
|
261 | - public function register_admin_pages() |
|
262 | - { |
|
263 | - add_submenu_page( |
|
264 | - '', // parent slug. we don't want this to actually appear in the menu |
|
265 | - __('Batch Job', 'event_espresso'), // page title |
|
266 | - 'n/a', // menu title |
|
267 | - 'read', // we want this page to actually be accessible to anyone, |
|
268 | - 'espresso_batch', // menu slug |
|
269 | - array(self::instance(), 'show_admin_page') |
|
270 | - ); |
|
271 | - } |
|
258 | + /** |
|
259 | + * Adds an admin page which doesn't appear in the admin menu |
|
260 | + */ |
|
261 | + public function register_admin_pages() |
|
262 | + { |
|
263 | + add_submenu_page( |
|
264 | + '', // parent slug. we don't want this to actually appear in the menu |
|
265 | + __('Batch Job', 'event_espresso'), // page title |
|
266 | + 'n/a', // menu title |
|
267 | + 'read', // we want this page to actually be accessible to anyone, |
|
268 | + 'espresso_batch', // menu slug |
|
269 | + array(self::instance(), 'show_admin_page') |
|
270 | + ); |
|
271 | + } |
|
272 | 272 | |
273 | - /** |
|
274 | - * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
275 | - * of creating the job and localizing some data |
|
276 | - */ |
|
277 | - public function show_admin_page() |
|
278 | - { |
|
279 | - echo EEH_Template::locate_template( |
|
280 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
281 | - array('batch_request_type' => $this->batch_request_type()) |
|
282 | - ); |
|
283 | - } |
|
273 | + /** |
|
274 | + * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
275 | + * of creating the job and localizing some data |
|
276 | + */ |
|
277 | + public function show_admin_page() |
|
278 | + { |
|
279 | + echo EEH_Template::locate_template( |
|
280 | + EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
281 | + array('batch_request_type' => $this->batch_request_type()) |
|
282 | + ); |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
286 | - * Receives ajax calls for continuing a job |
|
287 | - */ |
|
288 | - public function batch_continue() |
|
289 | - { |
|
290 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
291 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
292 | - $response_obj = $batch_runner->continue_job($job_id); |
|
293 | - $this->_return_json($response_obj->to_array()); |
|
294 | - } |
|
285 | + /** |
|
286 | + * Receives ajax calls for continuing a job |
|
287 | + */ |
|
288 | + public function batch_continue() |
|
289 | + { |
|
290 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
291 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
292 | + $response_obj = $batch_runner->continue_job($job_id); |
|
293 | + $this->_return_json($response_obj->to_array()); |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
297 | - * Receives the ajax call to cleanup a job |
|
298 | - * |
|
299 | - * @return type |
|
300 | - */ |
|
301 | - public function batch_cleanup() |
|
302 | - { |
|
303 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
304 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
305 | - $response_obj = $batch_runner->cleanup_job($job_id); |
|
306 | - $this->_return_json($response_obj->to_array()); |
|
307 | - } |
|
296 | + /** |
|
297 | + * Receives the ajax call to cleanup a job |
|
298 | + * |
|
299 | + * @return type |
|
300 | + */ |
|
301 | + public function batch_cleanup() |
|
302 | + { |
|
303 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
304 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
305 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
306 | + $this->_return_json($response_obj->to_array()); |
|
307 | + } |
|
308 | 308 | |
309 | 309 | |
310 | - /** |
|
311 | - * Returns a json response |
|
312 | - * |
|
313 | - * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
314 | - * |
|
315 | - * The returned json object is created from an array in the following format: |
|
316 | - * array( |
|
317 | - * 'notices' => '', // - contains any EE_Error formatted notices |
|
318 | - * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
319 | - * We're also going to include the template args with every package (so js can pick out any specific template |
|
320 | - * args that might be included in here) |
|
321 | - * 'isEEajax' => true,//indicates this is a response from EE |
|
322 | - * ) |
|
323 | - */ |
|
324 | - protected function _return_json($data) |
|
325 | - { |
|
326 | - $json = array( |
|
327 | - 'notices' => EE_Error::get_notices(), |
|
328 | - 'data' => $data, |
|
329 | - 'isEEajax' => true |
|
330 | - // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
331 | - ); |
|
310 | + /** |
|
311 | + * Returns a json response |
|
312 | + * |
|
313 | + * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
314 | + * |
|
315 | + * The returned json object is created from an array in the following format: |
|
316 | + * array( |
|
317 | + * 'notices' => '', // - contains any EE_Error formatted notices |
|
318 | + * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
319 | + * We're also going to include the template args with every package (so js can pick out any specific template |
|
320 | + * args that might be included in here) |
|
321 | + * 'isEEajax' => true,//indicates this is a response from EE |
|
322 | + * ) |
|
323 | + */ |
|
324 | + protected function _return_json($data) |
|
325 | + { |
|
326 | + $json = array( |
|
327 | + 'notices' => EE_Error::get_notices(), |
|
328 | + 'data' => $data, |
|
329 | + 'isEEajax' => true |
|
330 | + // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
331 | + ); |
|
332 | 332 | |
333 | 333 | |
334 | - // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
335 | - if (null === error_get_last() || ! headers_sent()) { |
|
336 | - header('Content-Type: application/json; charset=UTF-8'); |
|
337 | - } |
|
338 | - echo wp_json_encode($json); |
|
339 | - exit(); |
|
340 | - } |
|
334 | + // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
335 | + if (null === error_get_last() || ! headers_sent()) { |
|
336 | + header('Content-Type: application/json; charset=UTF-8'); |
|
337 | + } |
|
338 | + echo wp_json_encode($json); |
|
339 | + exit(); |
|
340 | + } |
|
341 | 341 | |
342 | - /** |
|
343 | - * Gets the job step response which was done during the enqueuing of scripts |
|
344 | - * |
|
345 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
346 | - */ |
|
347 | - public function job_step_response() |
|
348 | - { |
|
349 | - return $this->_job_step_response; |
|
350 | - } |
|
342 | + /** |
|
343 | + * Gets the job step response which was done during the enqueuing of scripts |
|
344 | + * |
|
345 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
346 | + */ |
|
347 | + public function job_step_response() |
|
348 | + { |
|
349 | + return $this->_job_step_response; |
|
350 | + } |
|
351 | 351 | |
352 | - /** |
|
353 | - * Gets the batch request type indicated in the $_REQUEST |
|
354 | - * |
|
355 | - * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
356 | - */ |
|
357 | - public function batch_request_type() |
|
358 | - { |
|
359 | - if ($this->_batch_request_type === null) { |
|
360 | - if (isset($_GET['batch'])) { |
|
361 | - if ($_GET['batch'] == self::batch_job) { |
|
362 | - $this->_batch_request_type = self::batch_job; |
|
363 | - } elseif ($_GET['batch'] == self::batch_file_job) { |
|
364 | - $this->_batch_request_type = self::batch_file_job; |
|
365 | - } |
|
366 | - } |
|
367 | - // if we didn't find that it was a batch request, indicate it wasn't |
|
368 | - if ($this->_batch_request_type === null) { |
|
369 | - $this->_batch_request_type = self::batch_not_job; |
|
370 | - } |
|
371 | - } |
|
372 | - return $this->_batch_request_type; |
|
373 | - } |
|
352 | + /** |
|
353 | + * Gets the batch request type indicated in the $_REQUEST |
|
354 | + * |
|
355 | + * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
356 | + */ |
|
357 | + public function batch_request_type() |
|
358 | + { |
|
359 | + if ($this->_batch_request_type === null) { |
|
360 | + if (isset($_GET['batch'])) { |
|
361 | + if ($_GET['batch'] == self::batch_job) { |
|
362 | + $this->_batch_request_type = self::batch_job; |
|
363 | + } elseif ($_GET['batch'] == self::batch_file_job) { |
|
364 | + $this->_batch_request_type = self::batch_file_job; |
|
365 | + } |
|
366 | + } |
|
367 | + // if we didn't find that it was a batch request, indicate it wasn't |
|
368 | + if ($this->_batch_request_type === null) { |
|
369 | + $this->_batch_request_type = self::batch_not_job; |
|
370 | + } |
|
371 | + } |
|
372 | + return $this->_batch_request_type; |
|
373 | + } |
|
374 | 374 | |
375 | - /** |
|
376 | - * Unnecessary |
|
377 | - * |
|
378 | - * @param type $WP |
|
379 | - */ |
|
380 | - public function run($WP) |
|
381 | - { |
|
382 | - } |
|
375 | + /** |
|
376 | + * Unnecessary |
|
377 | + * |
|
378 | + * @param type $WP |
|
379 | + */ |
|
380 | + public function run($WP) |
|
381 | + { |
|
382 | + } |
|
383 | 383 | } |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @access protected |
479 | 479 | * @param EE_Payment_Method $payment_method |
480 | - * @return EE_Form_Section_Proper |
|
480 | + * @return EE_Form_Section_HTML |
|
481 | 481 | */ |
482 | 482 | protected function _pci_dss_compliance(EE_Payment_Method $payment_method) |
483 | 483 | { |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @access protected |
522 | 522 | * @param EE_Payment_Method $payment_method |
523 | - * @return EE_Form_Section_Proper |
|
523 | + * @return EE_Form_Section_HTML |
|
524 | 524 | */ |
525 | 525 | protected function _currency_support(EE_Payment_Method $payment_method) |
526 | 526 | { |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @access protected |
642 | 642 | * @param EE_Payment_Method $payment_method |
643 | - * @return EE_Form_Section_Proper |
|
643 | + * @return EE_Form_Section_HTML |
|
644 | 644 | */ |
645 | 645 | protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) |
646 | 646 | { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
183 | 183 | $all_pmt_help_tabs_config = array(); |
184 | 184 | foreach ($payment_method_types as $payment_method_type) { |
185 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
185 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
186 | 186 | $payment_method_type->cap_name(), |
187 | 187 | 'specific_payment_method_type_access' |
188 | 188 | ) |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
193 | 193 | $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
194 | 194 | $template_args['admin_page_obj'] = $this; |
195 | - $all_pmt_help_tabs_config[ $help_tab_name ] = array( |
|
195 | + $all_pmt_help_tabs_config[$help_tab_name] = array( |
|
196 | 196 | 'title' => $config['title'], |
197 | 197 | 'content' => EEH_Template::display_template( |
198 | - $payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php', |
|
198 | + $payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php', |
|
199 | 199 | $template_args, |
200 | 200 | true |
201 | 201 | ), |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | wp_enqueue_script('ee-text-links'); |
239 | 239 | wp_enqueue_script( |
240 | 240 | 'espresso_payments', |
241 | - EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', |
|
241 | + EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', |
|
242 | 242 | array('espresso-ui-theme', 'ee-datepicker'), |
243 | 243 | EVENT_ESPRESSO_VERSION, |
244 | 244 | true |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | // styles |
252 | 252 | wp_register_style( |
253 | 253 | 'espresso_payments', |
254 | - EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', |
|
254 | + EE_PAYMENTS_ASSETS_URL.'ee-payments.css', |
|
255 | 255 | array(), |
256 | 256 | EVENT_ESPRESSO_VERSION |
257 | 257 | ); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | continue; |
281 | 281 | } |
282 | 282 | // check access |
283 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
283 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
284 | 284 | $pmt_obj->cap_name(), |
285 | 285 | 'specific_payment_method_type_access' |
286 | 286 | ) |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | } |
290 | 290 | // check for any active pms of that type |
291 | 291 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
292 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
292 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
293 | 293 | $payment_method = EE_Payment_Method::new_instance( |
294 | 294 | array( |
295 | 295 | 'PMD_slug' => sanitize_key($pmt_obj->system_name()), |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | ) |
300 | 300 | ); |
301 | 301 | } |
302 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
302 | + $payment_methods[$payment_method->slug()] = $payment_method; |
|
303 | 303 | } |
304 | 304 | $payment_methods = apply_filters( |
305 | 305 | 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | if ($payment_method instanceof EE_Payment_Method) { |
310 | 310 | add_meta_box( |
311 | 311 | // html id |
312 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
312 | + 'espresso_'.$payment_method->slug().'_payment_settings', |
|
313 | 313 | // title |
314 | 314 | sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
315 | 315 | // callback |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | array('payment_method' => $payment_method) |
325 | 325 | ); |
326 | 326 | // setup for tabbed content |
327 | - $tabs[ $payment_method->slug() ] = array( |
|
327 | + $tabs[$payment_method->slug()] = array( |
|
328 | 328 | 'label' => $payment_method->admin_name(), |
329 | 329 | 'class' => $payment_method->active() ? 'gateway-active' : '', |
330 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
330 | + 'href' => 'espresso_'.$payment_method->slug().'_payment_settings', |
|
331 | 331 | 'title' => __('Modify this Payment Method', 'event_espresso'), |
332 | 332 | 'slug' => $payment_method->slug(), |
333 | 333 | ); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | } |
359 | 359 | $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
360 | 360 | // if that didn't work or wasn't provided, find another way to select the current pm |
361 | - if (! $this->_verify_payment_method($payment_method)) { |
|
361 | + if ( ! $this->_verify_payment_method($payment_method)) { |
|
362 | 362 | // like, looking for an active one |
363 | 363 | $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
364 | 364 | // test that one as well |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | { |
408 | 408 | $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) |
409 | 409 | ? $metabox['args']['payment_method'] : null; |
410 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
410 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
411 | 411 | throw new EE_Error( |
412 | 412 | sprintf( |
413 | 413 | __( |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | if ($form->form_data_present_in($this->_req_data)) { |
425 | 425 | $form->receive_form_submission($this->_req_data); |
426 | 426 | } |
427 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
427 | + echo $form->form_open().$form->get_html_and_js().$form->form_close(); |
|
428 | 428 | } else { |
429 | 429 | echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
430 | 430 | } |
@@ -440,13 +440,13 @@ discard block |
||
440 | 440 | */ |
441 | 441 | protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) |
442 | 442 | { |
443 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
443 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
444 | 444 | return new EE_Form_Section_Proper(); |
445 | 445 | } |
446 | 446 | return new EE_Form_Section_Proper( |
447 | 447 | array( |
448 | - 'name' => $payment_method->slug() . '_settings_form', |
|
449 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
448 | + 'name' => $payment_method->slug().'_settings_form', |
|
449 | + 'html_id' => $payment_method->slug().'_settings_form', |
|
450 | 450 | 'action' => EE_Admin_Page::add_query_args_and_nonce( |
451 | 451 | array( |
452 | 452 | 'action' => 'update_payment_method', |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | EEH_HTML::label( |
490 | 490 | EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
491 | 491 | ) |
492 | - ) . |
|
492 | + ). |
|
493 | 493 | EEH_HTML::td( |
494 | 494 | EEH_HTML::strong( |
495 | 495 | __( |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | */ |
525 | 525 | protected function _currency_support(EE_Payment_Method $payment_method) |
526 | 526 | { |
527 | - if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
527 | + if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
528 | 528 | return new EE_Form_Section_HTML( |
529 | 529 | EEH_HTML::table( |
530 | 530 | EEH_HTML::tr( |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | EEH_HTML::label( |
533 | 533 | EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
534 | 534 | ) |
535 | - ) . |
|
535 | + ). |
|
536 | 536 | EEH_HTML::td( |
537 | 537 | EEH_HTML::strong( |
538 | 538 | sprintf( |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | $update_button = new EE_Submit_Input( |
614 | 614 | array( |
615 | 615 | 'name' => 'submit', |
616 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
616 | + 'html_id' => 'save_'.$payment_method->slug().'_settings', |
|
617 | 617 | 'default' => sprintf( |
618 | 618 | __('Update %s Payment Settings', 'event_espresso'), |
619 | 619 | $payment_method->admin_name() |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | ); |
624 | 624 | return new EE_Form_Section_HTML( |
625 | 625 | EEH_HTML::table( |
626 | - EEH_HTML::no_row(EEH_HTML::br(2)) . |
|
626 | + EEH_HTML::no_row(EEH_HTML::br(2)). |
|
627 | 627 | EEH_HTML::tr( |
628 | - EEH_HTML::th(__('Update Settings', 'event_espresso')) . |
|
628 | + EEH_HTML::th(__('Update Settings', 'event_espresso')). |
|
629 | 629 | EEH_HTML::td( |
630 | 630 | $update_button->get_html_for_input() |
631 | 631 | ) |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | return new EE_Form_Section_HTML( |
652 | 652 | EEH_HTML::table( |
653 | 653 | EEH_HTML::tr( |
654 | - EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) . |
|
654 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')). |
|
655 | 655 | EEH_HTML::td( |
656 | 656 | EEH_HTML::link( |
657 | 657 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | ), |
664 | 664 | $link_text_and_title, |
665 | 665 | $link_text_and_title, |
666 | - 'deactivate_' . $payment_method->slug(), |
|
666 | + 'deactivate_'.$payment_method->slug(), |
|
667 | 667 | 'espresso-button button-secondary' |
668 | 668 | ) |
669 | 669 | ) |
@@ -688,8 +688,8 @@ discard block |
||
688 | 688 | ); |
689 | 689 | return new EE_Form_Section_Proper( |
690 | 690 | array( |
691 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
692 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
691 | + 'name' => 'activate_'.$payment_method->slug().'_settings_form', |
|
692 | + 'html_id' => 'activate_'.$payment_method->slug().'_settings_form', |
|
693 | 693 | 'action' => '#', |
694 | 694 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
695 | 695 | 'subsections' => apply_filters( |
@@ -705,11 +705,11 @@ discard block |
||
705 | 705 | '', |
706 | 706 | 'colspan="2"' |
707 | 707 | ) |
708 | - ) . |
|
708 | + ). |
|
709 | 709 | EEH_HTML::tr( |
710 | 710 | EEH_HTML::th( |
711 | 711 | EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
712 | - ) . |
|
712 | + ). |
|
713 | 713 | EEH_HTML::td( |
714 | 714 | EEH_HTML::link( |
715 | 715 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | ), |
722 | 722 | $link_text_and_title, |
723 | 723 | $link_text_and_title, |
724 | - 'activate_' . $payment_method->slug(), |
|
724 | + 'activate_'.$payment_method->slug(), |
|
725 | 725 | 'espresso-button-green button-primary' |
726 | 726 | ) |
727 | 727 | ) |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | return new EE_Form_Section_HTML( |
748 | 748 | EEH_HTML::table( |
749 | 749 | EEH_HTML::tr( |
750 | - EEH_HTML::th() . |
|
750 | + EEH_HTML::th(). |
|
751 | 751 | EEH_HTML::td( |
752 | 752 | EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
753 | 753 | ) |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | } |
832 | 832 | } |
833 | 833 | // if we couldn't find the correct payment method type... |
834 | - if (! $correct_pmt_form_to_use) { |
|
834 | + if ( ! $correct_pmt_form_to_use) { |
|
835 | 835 | EE_Error::add_error( |
836 | 836 | __( |
837 | 837 | "We could not find which payment method type your form submission related to. Please contact support", |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
847 | 847 | if ($correct_pmt_form_to_use->is_valid()) { |
848 | 848 | $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings'); |
849 | - if (! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
849 | + if ( ! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
850 | 850 | throw new EE_Error( |
851 | 851 | sprintf( |
852 | 852 | __( |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | $form = $this->getPaymentSettingsForm(); |
899 | 899 | $this->_set_add_edit_form_tags('update_payment_settings'); |
900 | 900 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
901 | - $this->_template_args['admin_page_content'] = $form->get_html_and_js(); |
|
901 | + $this->_template_args['admin_page_content'] = $form->get_html_and_js(); |
|
902 | 902 | $this->display_admin_page_with_sidebar(); |
903 | 903 | } |
904 | 904 | |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | EE_Registry::instance()->CFG |
935 | 935 | ); |
936 | 936 | |
937 | - $cfg = EE_Registry::instance()->CFG ; |
|
937 | + $cfg = EE_Registry::instance()->CFG; |
|
938 | 938 | |
939 | 939 | $what = __('Payment Settings', 'event_espresso'); |
940 | 940 | $success = $this->_update_espresso_configuration( |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | } |
1036 | 1036 | // take into account search |
1037 | 1037 | if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
1038 | - $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%'); |
|
1038 | + $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%'); |
|
1039 | 1039 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
1040 | 1040 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
1041 | 1041 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
@@ -1055,8 +1055,8 @@ discard block |
||
1055 | 1055 | $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
1056 | 1056 | $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
1057 | 1057 | // make sure our timestamps start and end right at the boundaries for each day |
1058 | - $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1059 | - $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1058 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
1059 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
1060 | 1060 | // convert to timestamps |
1061 | 1061 | $start_date = strtotime($start_date); |
1062 | 1062 | $end_date = strtotime($end_date); |
@@ -1089,15 +1089,15 @@ discard block |
||
1089 | 1089 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
1090 | 1090 | } |
1091 | 1091 | $offset = ($current_page - 1) * $per_page; |
1092 | - if (! isset($this->_req_data['download_results'])) { |
|
1092 | + if ( ! isset($this->_req_data['download_results'])) { |
|
1093 | 1093 | $query_params['limit'] = array($offset, $per_page); |
1094 | 1094 | } |
1095 | 1095 | // now they've requested to instead just download the file instead of viewing it. |
1096 | 1096 | if (isset($this->_req_data['download_results'])) { |
1097 | 1097 | $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
1098 | 1098 | header('Content-Disposition: attachment'); |
1099 | - header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url())); |
|
1100 | - echo "<h1>Payment Logs for " . site_url() . "</h1>"; |
|
1099 | + header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url())); |
|
1100 | + echo "<h1>Payment Logs for ".site_url()."</h1>"; |
|
1101 | 1101 | echo "<h3>Query:</h3>"; |
1102 | 1102 | var_dump($query_params); |
1103 | 1103 | echo "<h3>Results:</h3>"; |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | } |
1153 | 1153 | } |
1154 | 1154 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
1155 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
1155 | + EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php', |
|
1156 | 1156 | array( |
1157 | 1157 | 'payment_log' => $payment_log, |
1158 | 1158 | 'payment_method' => $payment_method, |
@@ -16,1150 +16,1150 @@ |
||
16 | 16 | class Payments_Admin_Page extends EE_Admin_Page |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Variables used for when we're re-sorting the logs results, in case |
|
21 | - * we needed to do two queries and we need to resort |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - private $_sort_logs_again_direction; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @Constructor |
|
30 | - * @access public |
|
31 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
32 | - * @throws EE_Error |
|
33 | - * @throws InvalidArgumentException |
|
34 | - * @throws InvalidDataTypeException |
|
35 | - * @throws InvalidInterfaceException |
|
36 | - * @throws ReflectionException |
|
37 | - */ |
|
38 | - public function __construct($routing = true) |
|
39 | - { |
|
40 | - parent::__construct($routing); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - protected function _init_page_props() |
|
45 | - { |
|
46 | - $this->page_slug = EE_PAYMENTS_PG_SLUG; |
|
47 | - $this->page_label = __('Payment Methods', 'event_espresso'); |
|
48 | - $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL; |
|
49 | - $this->_admin_base_path = EE_PAYMENTS_ADMIN; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - protected function _ajax_hooks() |
|
54 | - { |
|
55 | - // todo: all hooks for ajax goes here. |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - protected function _define_page_props() |
|
60 | - { |
|
61 | - $this->_admin_page_title = $this->page_label; |
|
62 | - $this->_labels = array( |
|
63 | - 'publishbox' => __('Update Settings', 'event_espresso'), |
|
64 | - ); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - protected function _set_page_routes() |
|
69 | - { |
|
70 | - /** |
|
71 | - * note that with payment method capabilities, although we've implemented |
|
72 | - * capability mapping which will be used for accessing payment methods owned by |
|
73 | - * other users. This is not fully implemented yet in the payment method ui. |
|
74 | - * Currently only the "plural" caps are in active use. |
|
75 | - * When cap mapping is implemented, some routes will need to use the singular form of |
|
76 | - * capability method and also include the $id of the payment method for the route. |
|
77 | - **/ |
|
78 | - $this->_page_routes = array( |
|
79 | - 'default' => array( |
|
80 | - 'func' => '_payment_methods_list', |
|
81 | - 'capability' => 'ee_edit_payment_methods', |
|
82 | - ), |
|
83 | - 'payment_settings' => array( |
|
84 | - 'func' => '_payment_settings', |
|
85 | - 'capability' => 'ee_manage_gateways', |
|
86 | - ), |
|
87 | - 'activate_payment_method' => array( |
|
88 | - 'func' => '_activate_payment_method', |
|
89 | - 'noheader' => true, |
|
90 | - 'capability' => 'ee_edit_payment_methods', |
|
91 | - ), |
|
92 | - 'deactivate_payment_method' => array( |
|
93 | - 'func' => '_deactivate_payment_method', |
|
94 | - 'noheader' => true, |
|
95 | - 'capability' => 'ee_delete_payment_methods', |
|
96 | - ), |
|
97 | - 'update_payment_method' => array( |
|
98 | - 'func' => '_update_payment_method', |
|
99 | - 'noheader' => true, |
|
100 | - 'headers_sent_route' => 'default', |
|
101 | - 'capability' => 'ee_edit_payment_methods', |
|
102 | - ), |
|
103 | - 'update_payment_settings' => array( |
|
104 | - 'func' => '_update_payment_settings', |
|
105 | - 'noheader' => true, |
|
106 | - 'capability' => 'ee_manage_gateways', |
|
107 | - ), |
|
108 | - 'payment_log' => array( |
|
109 | - 'func' => '_payment_log_overview_list_table', |
|
110 | - 'capability' => 'ee_read_payment_methods', |
|
111 | - ), |
|
112 | - 'payment_log_details' => array( |
|
113 | - 'func' => '_payment_log_details', |
|
114 | - 'capability' => 'ee_read_payment_methods', |
|
115 | - ), |
|
116 | - ); |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - protected function _set_page_config() |
|
121 | - { |
|
122 | - $payment_method_list_config = array( |
|
123 | - 'nav' => array( |
|
124 | - 'label' => __('Payment Methods', 'event_espresso'), |
|
125 | - 'order' => 10, |
|
126 | - ), |
|
127 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
128 | - 'help_tabs' => array_merge( |
|
129 | - array( |
|
130 | - 'payment_methods_overview_help_tab' => array( |
|
131 | - 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
132 | - 'filename' => 'payment_methods_overview', |
|
133 | - ), |
|
134 | - ), |
|
135 | - $this->_add_payment_method_help_tabs() |
|
136 | - ), |
|
137 | - 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
138 | - 'require_nonce' => false, |
|
139 | - ); |
|
140 | - $this->_page_config = array( |
|
141 | - 'default' => $payment_method_list_config, |
|
142 | - 'payment_settings' => array( |
|
143 | - 'nav' => array( |
|
144 | - 'label' => __('Settings', 'event_espresso'), |
|
145 | - 'order' => 20, |
|
146 | - ), |
|
147 | - 'help_tabs' => array( |
|
148 | - 'payment_methods_settings_help_tab' => array( |
|
149 | - 'title' => __('Payment Method Settings', 'event_espresso'), |
|
150 | - 'filename' => 'payment_methods_settings', |
|
151 | - ), |
|
152 | - ), |
|
153 | - // 'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
|
154 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
155 | - 'require_nonce' => false, |
|
156 | - ), |
|
157 | - 'payment_log' => array( |
|
158 | - 'nav' => array( |
|
159 | - 'label' => __("Logs", 'event_espresso'), |
|
160 | - 'order' => 30, |
|
161 | - ), |
|
162 | - 'list_table' => 'Payment_Log_Admin_List_Table', |
|
163 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
164 | - 'require_nonce' => false, |
|
165 | - ), |
|
166 | - ); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @return array |
|
172 | - * @throws DomainException |
|
173 | - * @throws EE_Error |
|
174 | - * @throws InvalidArgumentException |
|
175 | - * @throws InvalidDataTypeException |
|
176 | - * @throws InvalidInterfaceException |
|
177 | - * @throws ReflectionException |
|
178 | - */ |
|
179 | - protected function _add_payment_method_help_tabs() |
|
180 | - { |
|
181 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
182 | - $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
|
183 | - $all_pmt_help_tabs_config = array(); |
|
184 | - foreach ($payment_method_types as $payment_method_type) { |
|
185 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
186 | - $payment_method_type->cap_name(), |
|
187 | - 'specific_payment_method_type_access' |
|
188 | - ) |
|
189 | - ) { |
|
190 | - continue; |
|
191 | - } |
|
192 | - foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
193 | - $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
194 | - $template_args['admin_page_obj'] = $this; |
|
195 | - $all_pmt_help_tabs_config[ $help_tab_name ] = array( |
|
196 | - 'title' => $config['title'], |
|
197 | - 'content' => EEH_Template::display_template( |
|
198 | - $payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php', |
|
199 | - $template_args, |
|
200 | - true |
|
201 | - ), |
|
202 | - ); |
|
203 | - } |
|
204 | - } |
|
205 | - return $all_pmt_help_tabs_config; |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - // none of the below group are currently used for Gateway Settings |
|
210 | - protected function _add_screen_options() |
|
211 | - { |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - protected function _add_feature_pointers() |
|
216 | - { |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - public function admin_init() |
|
221 | - { |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - public function admin_notices() |
|
226 | - { |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - public function admin_footer_scripts() |
|
231 | - { |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - public function load_scripts_styles() |
|
236 | - { |
|
237 | - wp_enqueue_script('ee_admin_js'); |
|
238 | - wp_enqueue_script('ee-text-links'); |
|
239 | - wp_enqueue_script( |
|
240 | - 'espresso_payments', |
|
241 | - EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', |
|
242 | - array('espresso-ui-theme', 'ee-datepicker'), |
|
243 | - EVENT_ESPRESSO_VERSION, |
|
244 | - true |
|
245 | - ); |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - public function load_scripts_styles_default() |
|
250 | - { |
|
251 | - // styles |
|
252 | - wp_register_style( |
|
253 | - 'espresso_payments', |
|
254 | - EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', |
|
255 | - array(), |
|
256 | - EVENT_ESPRESSO_VERSION |
|
257 | - ); |
|
258 | - wp_enqueue_style('espresso_payments'); |
|
259 | - wp_enqueue_style('ee-text-links'); |
|
260 | - // scripts |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - protected function _payment_methods_list() |
|
265 | - { |
|
266 | - /** |
|
267 | - * first let's ensure payment methods have been setup. We do this here because when people activate a |
|
268 | - * payment method for the first time (as an addon), it may not setup its capabilities or get registered |
|
269 | - * correctly due to the loading process. However, people MUST setup the details for the payment method so its |
|
270 | - * safe to do a recheck here. |
|
271 | - */ |
|
272 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
273 | - EEM_Payment_Method::instance()->verify_button_urls(); |
|
274 | - // setup tabs, one for each payment method type |
|
275 | - $tabs = array(); |
|
276 | - $payment_methods = array(); |
|
277 | - foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
278 | - // we don't want to show admin-only PMTs for now |
|
279 | - if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
280 | - continue; |
|
281 | - } |
|
282 | - // check access |
|
283 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
284 | - $pmt_obj->cap_name(), |
|
285 | - 'specific_payment_method_type_access' |
|
286 | - ) |
|
287 | - ) { |
|
288 | - continue; |
|
289 | - } |
|
290 | - // check for any active pms of that type |
|
291 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
292 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
293 | - $payment_method = EE_Payment_Method::new_instance( |
|
294 | - array( |
|
295 | - 'PMD_slug' => sanitize_key($pmt_obj->system_name()), |
|
296 | - 'PMD_type' => $pmt_obj->system_name(), |
|
297 | - 'PMD_name' => $pmt_obj->pretty_name(), |
|
298 | - 'PMD_admin_name' => $pmt_obj->pretty_name(), |
|
299 | - ) |
|
300 | - ); |
|
301 | - } |
|
302 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
303 | - } |
|
304 | - $payment_methods = apply_filters( |
|
305 | - 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', |
|
306 | - $payment_methods |
|
307 | - ); |
|
308 | - foreach ($payment_methods as $payment_method) { |
|
309 | - if ($payment_method instanceof EE_Payment_Method) { |
|
310 | - add_meta_box( |
|
311 | - // html id |
|
312 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
313 | - // title |
|
314 | - sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
315 | - // callback |
|
316 | - array($this, 'payment_method_settings_meta_box'), |
|
317 | - // post type |
|
318 | - null, |
|
319 | - // context |
|
320 | - 'normal', |
|
321 | - // priority |
|
322 | - 'default', |
|
323 | - // callback args |
|
324 | - array('payment_method' => $payment_method) |
|
325 | - ); |
|
326 | - // setup for tabbed content |
|
327 | - $tabs[ $payment_method->slug() ] = array( |
|
328 | - 'label' => $payment_method->admin_name(), |
|
329 | - 'class' => $payment_method->active() ? 'gateway-active' : '', |
|
330 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
331 | - 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
332 | - 'slug' => $payment_method->slug(), |
|
333 | - ); |
|
334 | - } |
|
335 | - } |
|
336 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( |
|
337 | - $tabs, |
|
338 | - 'payment_method_links', |
|
339 | - '|', |
|
340 | - $this->_get_active_payment_method_slug() |
|
341 | - ); |
|
342 | - $this->display_admin_page_with_sidebar(); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * _get_active_payment_method_slug |
|
348 | - * |
|
349 | - * @return string |
|
350 | - */ |
|
351 | - protected function _get_active_payment_method_slug() |
|
352 | - { |
|
353 | - $payment_method_slug = false; |
|
354 | - // decide which payment method tab to open first, as dictated by the request's 'payment_method' |
|
355 | - if (isset($this->_req_data['payment_method'])) { |
|
356 | - // if they provided the current payment method, use it |
|
357 | - $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
358 | - } |
|
359 | - $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
360 | - // if that didn't work or wasn't provided, find another way to select the current pm |
|
361 | - if (! $this->_verify_payment_method($payment_method)) { |
|
362 | - // like, looking for an active one |
|
363 | - $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
364 | - // test that one as well |
|
365 | - if ($this->_verify_payment_method($payment_method)) { |
|
366 | - $payment_method_slug = $payment_method->slug(); |
|
367 | - } else { |
|
368 | - $payment_method_slug = 'paypal_standard'; |
|
369 | - } |
|
370 | - } |
|
371 | - return $payment_method_slug; |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * payment_method_settings_meta_box |
|
377 | - * returns TRUE if the passed payment method is properly constructed and the logged in user has the correct |
|
378 | - * capabilities to access it |
|
379 | - * |
|
380 | - * @param EE_Payment_Method $payment_method |
|
381 | - * @return boolean |
|
382 | - */ |
|
383 | - protected function _verify_payment_method($payment_method) |
|
384 | - { |
|
385 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base |
|
386 | - && EE_Registry::instance()->CAP->current_user_can( |
|
387 | - $payment_method->type_obj()->cap_name(), |
|
388 | - 'specific_payment_method_type_access' |
|
389 | - ) |
|
390 | - ) { |
|
391 | - return true; |
|
392 | - } |
|
393 | - return false; |
|
394 | - } |
|
395 | - |
|
396 | - |
|
397 | - /** |
|
398 | - * payment_method_settings_meta_box |
|
399 | - * |
|
400 | - * @param NULL $post_obj_which_is_null is an object containing the current post (as a $post object) |
|
401 | - * @param array $metabox is an array with metabox id, title, callback, and args elements. the value |
|
402 | - * at 'args' has key 'payment_method', as set within _payment_methods_list |
|
403 | - * @return string |
|
404 | - * @throws EE_Error |
|
405 | - */ |
|
406 | - public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) |
|
407 | - { |
|
408 | - $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) |
|
409 | - ? $metabox['args']['payment_method'] : null; |
|
410 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
411 | - throw new EE_Error( |
|
412 | - sprintf( |
|
413 | - __( |
|
414 | - 'Payment method metabox setup incorrectly. No Payment method object was supplied', |
|
415 | - 'event_espresso' |
|
416 | - ) |
|
417 | - ) |
|
418 | - ); |
|
419 | - } |
|
420 | - $payment_method_scopes = $payment_method->active(); |
|
421 | - // if the payment method really exists show its form, otherwise the activation template |
|
422 | - if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
423 | - $form = $this->_generate_payment_method_settings_form($payment_method); |
|
424 | - if ($form->form_data_present_in($this->_req_data)) { |
|
425 | - $form->receive_form_submission($this->_req_data); |
|
426 | - } |
|
427 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
428 | - } else { |
|
429 | - echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
430 | - } |
|
431 | - } |
|
432 | - |
|
433 | - |
|
434 | - /** |
|
435 | - * Gets the form for all the settings related to this payment method type |
|
436 | - * |
|
437 | - * @access protected |
|
438 | - * @param EE_Payment_Method $payment_method |
|
439 | - * @return EE_Form_Section_Proper |
|
440 | - */ |
|
441 | - protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) |
|
442 | - { |
|
443 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
444 | - return new EE_Form_Section_Proper(); |
|
445 | - } |
|
446 | - return new EE_Form_Section_Proper( |
|
447 | - array( |
|
448 | - 'name' => $payment_method->slug() . '_settings_form', |
|
449 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
450 | - 'action' => EE_Admin_Page::add_query_args_and_nonce( |
|
451 | - array( |
|
452 | - 'action' => 'update_payment_method', |
|
453 | - 'payment_method' => $payment_method->slug(), |
|
454 | - ), |
|
455 | - EE_PAYMENTS_ADMIN_URL |
|
456 | - ), |
|
457 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
458 | - 'subsections' => apply_filters( |
|
459 | - 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
|
460 | - array( |
|
461 | - 'pci_dss_compliance' => $this->_pci_dss_compliance($payment_method), |
|
462 | - 'currency_support' => $this->_currency_support($payment_method), |
|
463 | - 'payment_method_settings' => $this->_payment_method_settings($payment_method), |
|
464 | - 'update' => $this->_update_payment_method_button($payment_method), |
|
465 | - 'deactivate' => $this->_deactivate_payment_method_button($payment_method), |
|
466 | - 'fine_print' => $this->_fine_print(), |
|
467 | - ), |
|
468 | - $payment_method |
|
469 | - ), |
|
470 | - ) |
|
471 | - ); |
|
472 | - } |
|
473 | - |
|
474 | - |
|
475 | - /** |
|
476 | - * _pci_dss_compliance |
|
477 | - * |
|
478 | - * @access protected |
|
479 | - * @param EE_Payment_Method $payment_method |
|
480 | - * @return EE_Form_Section_Proper |
|
481 | - */ |
|
482 | - protected function _pci_dss_compliance(EE_Payment_Method $payment_method) |
|
483 | - { |
|
484 | - if ($payment_method->type_obj()->requires_https()) { |
|
485 | - return new EE_Form_Section_HTML( |
|
486 | - EEH_HTML::table( |
|
487 | - EEH_HTML::tr( |
|
488 | - EEH_HTML::th( |
|
489 | - EEH_HTML::label( |
|
490 | - EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
491 | - ) |
|
492 | - ) . |
|
493 | - EEH_HTML::td( |
|
494 | - EEH_HTML::strong( |
|
495 | - __( |
|
496 | - 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', |
|
497 | - 'event_espresso' |
|
498 | - ) |
|
499 | - ) |
|
500 | - . |
|
501 | - EEH_HTML::br() |
|
502 | - . |
|
503 | - __('Learn more about ', 'event_espresso') |
|
504 | - . EEH_HTML::link( |
|
505 | - 'https://www.pcisecuritystandards.org/merchants/index.php', |
|
506 | - __('PCI DSS compliance', 'event_espresso') |
|
507 | - ) |
|
508 | - ) |
|
509 | - ) |
|
510 | - ) |
|
511 | - ); |
|
512 | - } else { |
|
513 | - return new EE_Form_Section_HTML(''); |
|
514 | - } |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * _currency_support |
|
520 | - * |
|
521 | - * @access protected |
|
522 | - * @param EE_Payment_Method $payment_method |
|
523 | - * @return EE_Form_Section_Proper |
|
524 | - */ |
|
525 | - protected function _currency_support(EE_Payment_Method $payment_method) |
|
526 | - { |
|
527 | - if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
528 | - return new EE_Form_Section_HTML( |
|
529 | - EEH_HTML::table( |
|
530 | - EEH_HTML::tr( |
|
531 | - EEH_HTML::th( |
|
532 | - EEH_HTML::label( |
|
533 | - EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
534 | - ) |
|
535 | - ) . |
|
536 | - EEH_HTML::td( |
|
537 | - EEH_HTML::strong( |
|
538 | - sprintf( |
|
539 | - __( |
|
540 | - 'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.', |
|
541 | - 'event_espresso' |
|
542 | - ), |
|
543 | - EE_Config::instance()->currency->code |
|
544 | - ) |
|
545 | - ) |
|
546 | - ) |
|
547 | - ) |
|
548 | - ) |
|
549 | - ); |
|
550 | - } else { |
|
551 | - return new EE_Form_Section_HTML(''); |
|
552 | - } |
|
553 | - } |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * _update_payment_method_button |
|
558 | - * |
|
559 | - * @access protected |
|
560 | - * @param EE_Payment_Method $payment_method |
|
561 | - * @return EE_Payment_Method_Form |
|
562 | - */ |
|
563 | - protected function _payment_method_settings(EE_Payment_Method $payment_method) |
|
564 | - { |
|
565 | - // modify the form so we only have/show fields that will be implemented for this version |
|
566 | - return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
567 | - } |
|
568 | - |
|
569 | - |
|
570 | - /** |
|
571 | - * Simplifies the form to merely reproduce 4.1's gateway settings functionality |
|
572 | - * |
|
573 | - * @param EE_Form_Section_Proper $form_section |
|
574 | - * @param string $payment_method_name |
|
575 | - * @return EE_Payment_Method_Form |
|
576 | - * @throws EE_Error |
|
577 | - */ |
|
578 | - protected function _simplify_form($form_section, $payment_method_name = '') |
|
579 | - { |
|
580 | - if ($form_section instanceof EE_Payment_Method_Form) { |
|
581 | - $form_section->exclude( |
|
582 | - array( |
|
583 | - 'PMD_type', // dont want them changing the type |
|
584 | - 'PMD_slug', // or the slug (probably never) |
|
585 | - 'PMD_wp_user', // or the user's ID |
|
586 | - 'Currency' // or the currency, until the rest of EE supports simultaneous currencies |
|
587 | - ) |
|
588 | - ); |
|
589 | - return $form_section; |
|
590 | - } else { |
|
591 | - throw new EE_Error( |
|
592 | - sprintf( |
|
593 | - __( |
|
594 | - 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', |
|
595 | - 'event_espresso' |
|
596 | - ), |
|
597 | - $payment_method_name |
|
598 | - ) |
|
599 | - ); |
|
600 | - } |
|
601 | - } |
|
602 | - |
|
603 | - |
|
604 | - /** |
|
605 | - * _update_payment_method_button |
|
606 | - * |
|
607 | - * @access protected |
|
608 | - * @param EE_Payment_Method $payment_method |
|
609 | - * @return EE_Form_Section_HTML |
|
610 | - */ |
|
611 | - protected function _update_payment_method_button(EE_Payment_Method $payment_method) |
|
612 | - { |
|
613 | - $update_button = new EE_Submit_Input( |
|
614 | - array( |
|
615 | - 'name' => 'submit', |
|
616 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
617 | - 'default' => sprintf( |
|
618 | - __('Update %s Payment Settings', 'event_espresso'), |
|
619 | - $payment_method->admin_name() |
|
620 | - ), |
|
621 | - 'html_label' => EEH_HTML::nbsp(), |
|
622 | - ) |
|
623 | - ); |
|
624 | - return new EE_Form_Section_HTML( |
|
625 | - EEH_HTML::table( |
|
626 | - EEH_HTML::no_row(EEH_HTML::br(2)) . |
|
627 | - EEH_HTML::tr( |
|
628 | - EEH_HTML::th(__('Update Settings', 'event_espresso')) . |
|
629 | - EEH_HTML::td( |
|
630 | - $update_button->get_html_for_input() |
|
631 | - ) |
|
632 | - ) |
|
633 | - ) |
|
634 | - ); |
|
635 | - } |
|
636 | - |
|
637 | - |
|
638 | - /** |
|
639 | - * _deactivate_payment_method_button |
|
640 | - * |
|
641 | - * @access protected |
|
642 | - * @param EE_Payment_Method $payment_method |
|
643 | - * @return EE_Form_Section_Proper |
|
644 | - */ |
|
645 | - protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) |
|
646 | - { |
|
647 | - $link_text_and_title = sprintf( |
|
648 | - __('Deactivate %1$s Payments?', 'event_espresso'), |
|
649 | - $payment_method->admin_name() |
|
650 | - ); |
|
651 | - return new EE_Form_Section_HTML( |
|
652 | - EEH_HTML::table( |
|
653 | - EEH_HTML::tr( |
|
654 | - EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) . |
|
655 | - EEH_HTML::td( |
|
656 | - EEH_HTML::link( |
|
657 | - EE_Admin_Page::add_query_args_and_nonce( |
|
658 | - array( |
|
659 | - 'action' => 'deactivate_payment_method', |
|
660 | - 'payment_method' => $payment_method->slug(), |
|
661 | - ), |
|
662 | - EE_PAYMENTS_ADMIN_URL |
|
663 | - ), |
|
664 | - $link_text_and_title, |
|
665 | - $link_text_and_title, |
|
666 | - 'deactivate_' . $payment_method->slug(), |
|
667 | - 'espresso-button button-secondary' |
|
668 | - ) |
|
669 | - ) |
|
670 | - ) |
|
671 | - ) |
|
672 | - ); |
|
673 | - } |
|
674 | - |
|
675 | - |
|
676 | - /** |
|
677 | - * _activate_payment_method_button |
|
678 | - * |
|
679 | - * @access protected |
|
680 | - * @param EE_Payment_Method $payment_method |
|
681 | - * @return EE_Form_Section_Proper |
|
682 | - */ |
|
683 | - protected function _activate_payment_method_button(EE_Payment_Method $payment_method) |
|
684 | - { |
|
685 | - $link_text_and_title = sprintf( |
|
686 | - __('Activate %1$s Payment Method?', 'event_espresso'), |
|
687 | - $payment_method->admin_name() |
|
688 | - ); |
|
689 | - return new EE_Form_Section_Proper( |
|
690 | - array( |
|
691 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
692 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
693 | - 'action' => '#', |
|
694 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
695 | - 'subsections' => apply_filters( |
|
696 | - 'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections', |
|
697 | - array( |
|
698 | - new EE_Form_Section_HTML( |
|
699 | - EEH_HTML::table( |
|
700 | - EEH_HTML::tr( |
|
701 | - EEH_HTML::td( |
|
702 | - $payment_method->type_obj()->introductory_html(), |
|
703 | - '', |
|
704 | - '', |
|
705 | - '', |
|
706 | - 'colspan="2"' |
|
707 | - ) |
|
708 | - ) . |
|
709 | - EEH_HTML::tr( |
|
710 | - EEH_HTML::th( |
|
711 | - EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
712 | - ) . |
|
713 | - EEH_HTML::td( |
|
714 | - EEH_HTML::link( |
|
715 | - EE_Admin_Page::add_query_args_and_nonce( |
|
716 | - array( |
|
717 | - 'action' => 'activate_payment_method', |
|
718 | - 'payment_method_type' => $payment_method->type(), |
|
719 | - ), |
|
720 | - EE_PAYMENTS_ADMIN_URL |
|
721 | - ), |
|
722 | - $link_text_and_title, |
|
723 | - $link_text_and_title, |
|
724 | - 'activate_' . $payment_method->slug(), |
|
725 | - 'espresso-button-green button-primary' |
|
726 | - ) |
|
727 | - ) |
|
728 | - ) |
|
729 | - ) |
|
730 | - ), |
|
731 | - ), |
|
732 | - $payment_method |
|
733 | - ), |
|
734 | - ) |
|
735 | - ); |
|
736 | - } |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * _fine_print |
|
741 | - * |
|
742 | - * @access protected |
|
743 | - * @return EE_Form_Section_HTML |
|
744 | - */ |
|
745 | - protected function _fine_print() |
|
746 | - { |
|
747 | - return new EE_Form_Section_HTML( |
|
748 | - EEH_HTML::table( |
|
749 | - EEH_HTML::tr( |
|
750 | - EEH_HTML::th() . |
|
751 | - EEH_HTML::td( |
|
752 | - EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
753 | - ) |
|
754 | - ) |
|
755 | - ) |
|
756 | - ); |
|
757 | - } |
|
758 | - |
|
759 | - |
|
760 | - /** |
|
761 | - * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
|
762 | - * |
|
763 | - * @global WP_User $current_user |
|
764 | - */ |
|
765 | - protected function _activate_payment_method() |
|
766 | - { |
|
767 | - if (isset($this->_req_data['payment_method_type'])) { |
|
768 | - $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
|
769 | - // see if one exists |
|
770 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
771 | - $payment_method = EE_Payment_Method_Manager::instance() |
|
772 | - ->activate_a_payment_method_of_type($payment_method_type); |
|
773 | - $this->_redirect_after_action( |
|
774 | - 1, |
|
775 | - 'Payment Method', |
|
776 | - 'activated', |
|
777 | - array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
778 | - ); |
|
779 | - } else { |
|
780 | - $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
781 | - } |
|
782 | - } |
|
783 | - |
|
784 | - |
|
785 | - /** |
|
786 | - * Deactivates the payment method with the specified slug, and redirects. |
|
787 | - */ |
|
788 | - protected function _deactivate_payment_method() |
|
789 | - { |
|
790 | - if (isset($this->_req_data['payment_method'])) { |
|
791 | - $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
792 | - // deactivate it |
|
793 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
794 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
795 | - $this->_redirect_after_action( |
|
796 | - $count_updated, |
|
797 | - 'Payment Method', |
|
798 | - 'deactivated', |
|
799 | - array('action' => 'default', 'payment_method' => $payment_method_slug) |
|
800 | - ); |
|
801 | - } else { |
|
802 | - $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default')); |
|
803 | - } |
|
804 | - } |
|
805 | - |
|
806 | - |
|
807 | - /** |
|
808 | - * Processes the payment method form that was submitted. This is slightly trickier than usual form |
|
809 | - * processing because we first need to identify WHICH form was processed and which payment method |
|
810 | - * it corresponds to. Once we have done that, we see if the form is valid. If it is, the |
|
811 | - * form's data is saved and we redirect to the default payment methods page, setting the updated payment method |
|
812 | - * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the |
|
813 | - * subsequently called 'headers_sent_func' which is _payment_methods_list) |
|
814 | - * |
|
815 | - * @return void |
|
816 | - */ |
|
817 | - protected function _update_payment_method() |
|
818 | - { |
|
819 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
820 | - // ok let's find which gateway form to use based on the form input |
|
821 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
822 | - /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
|
823 | - $correct_pmt_form_to_use = null; |
|
824 | - $payment_method = null; |
|
825 | - foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) { |
|
826 | - // get the form and simplify it, like what we do when we display it |
|
827 | - $pmt_form = $this->_generate_payment_method_settings_form($payment_method); |
|
828 | - if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
829 | - $correct_pmt_form_to_use = $pmt_form; |
|
830 | - break; |
|
831 | - } |
|
832 | - } |
|
833 | - // if we couldn't find the correct payment method type... |
|
834 | - if (! $correct_pmt_form_to_use) { |
|
835 | - EE_Error::add_error( |
|
836 | - __( |
|
837 | - "We could not find which payment method type your form submission related to. Please contact support", |
|
838 | - 'event_espresso' |
|
839 | - ), |
|
840 | - __FILE__, |
|
841 | - __FUNCTION__, |
|
842 | - __LINE__ |
|
843 | - ); |
|
844 | - $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
845 | - } |
|
846 | - $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
|
847 | - if ($correct_pmt_form_to_use->is_valid()) { |
|
848 | - $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings'); |
|
849 | - if (! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
850 | - throw new EE_Error( |
|
851 | - sprintf( |
|
852 | - __( |
|
853 | - 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', |
|
854 | - 'event_espresso' |
|
855 | - ), |
|
856 | - 'payment_method_settings' |
|
857 | - ) |
|
858 | - ); |
|
859 | - } |
|
860 | - $payment_settings_subform->save(); |
|
861 | - /** @var $pm EE_Payment_Method */ |
|
862 | - $this->_redirect_after_action( |
|
863 | - true, |
|
864 | - 'Payment Method', |
|
865 | - 'updated', |
|
866 | - array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
867 | - ); |
|
868 | - } else { |
|
869 | - EE_Error::add_error( |
|
870 | - sprintf( |
|
871 | - __( |
|
872 | - 'Payment method of type %s was not saved because there were validation errors. They have been marked in the form', |
|
873 | - 'event_espresso' |
|
874 | - ), |
|
875 | - $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name() |
|
876 | - : __('"(unknown)"', 'event_espresso') |
|
877 | - ), |
|
878 | - __FILE__, |
|
879 | - __FUNCTION__, |
|
880 | - __LINE__ |
|
881 | - ); |
|
882 | - } |
|
883 | - } |
|
884 | - return; |
|
885 | - } |
|
886 | - |
|
887 | - |
|
888 | - /** |
|
889 | - * Displays payment settings (not payment METHOD settings, that's _payment_method_settings) |
|
890 | - * @throws DomainException |
|
891 | - * @throws EE_Error |
|
892 | - * @throws InvalidArgumentException |
|
893 | - * @throws InvalidDataTypeException |
|
894 | - * @throws InvalidInterfaceException |
|
895 | - */ |
|
896 | - protected function _payment_settings() |
|
897 | - { |
|
898 | - $form = $this->getPaymentSettingsForm(); |
|
899 | - $this->_set_add_edit_form_tags('update_payment_settings'); |
|
900 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
901 | - $this->_template_args['admin_page_content'] = $form->get_html_and_js(); |
|
902 | - $this->display_admin_page_with_sidebar(); |
|
903 | - } |
|
904 | - |
|
905 | - |
|
906 | - /** |
|
907 | - * _update_payment_settings |
|
908 | - * |
|
909 | - * @access protected |
|
910 | - * @return void |
|
911 | - * @throws EE_Error |
|
912 | - * @throws InvalidArgumentException |
|
913 | - * @throws InvalidDataTypeException |
|
914 | - * @throws InvalidInterfaceException |
|
915 | - */ |
|
916 | - protected function _update_payment_settings() |
|
917 | - { |
|
918 | - $form = $this->getPaymentSettingsForm(); |
|
919 | - if ($form->was_submitted($this->_req_data)) { |
|
920 | - $form->receive_form_submission($this->_req_data); |
|
921 | - if ($form->is_valid()) { |
|
922 | - /** |
|
923 | - * @var $reg_config EE_Registration_Config |
|
924 | - */ |
|
925 | - $loader = LoaderFactory::getLoader(); |
|
926 | - $reg_config = $loader->getShared('EE_Registration_Config'); |
|
927 | - $valid_data = $form->valid_data(); |
|
928 | - $reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options']; |
|
929 | - $reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan']; |
|
930 | - } |
|
931 | - } |
|
932 | - EE_Registry::instance()->CFG = apply_filters( |
|
933 | - 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', |
|
934 | - EE_Registry::instance()->CFG |
|
935 | - ); |
|
936 | - |
|
937 | - $cfg = EE_Registry::instance()->CFG ; |
|
938 | - |
|
939 | - $what = __('Payment Settings', 'event_espresso'); |
|
940 | - $success = $this->_update_espresso_configuration( |
|
941 | - $what, |
|
942 | - EE_Registry::instance()->CFG, |
|
943 | - __FILE__, |
|
944 | - __FUNCTION__, |
|
945 | - __LINE__ |
|
946 | - ); |
|
947 | - $this->_redirect_after_action( |
|
948 | - $success, |
|
949 | - $what, |
|
950 | - __('updated', 'event_espresso'), |
|
951 | - array('action' => 'payment_settings') |
|
952 | - ); |
|
953 | - } |
|
954 | - |
|
955 | - |
|
956 | - /** |
|
957 | - * Gets the form used for updating payment settings |
|
958 | - * |
|
959 | - * @return EE_Form_Section_Proper |
|
960 | - * @throws EE_Error |
|
961 | - * @throws InvalidArgumentException |
|
962 | - * @throws InvalidDataTypeException |
|
963 | - * @throws InvalidInterfaceException |
|
964 | - */ |
|
965 | - protected function getPaymentSettingsForm() |
|
966 | - { |
|
967 | - /** |
|
968 | - * @var $reg_config EE_Registration_Config |
|
969 | - */ |
|
970 | - $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
971 | - return new EE_Form_Section_Proper( |
|
972 | - array( |
|
973 | - 'name' => 'payment-settings', |
|
974 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
975 | - 'subsections' => array( |
|
976 | - 'show_pending_payment_options' => new EE_Yes_No_Input( |
|
977 | - array( |
|
978 | - 'html_name' => 'show_pending_payment_options', |
|
979 | - 'default' => $reg_config->show_pending_payment_options, |
|
980 | - 'html_help_text' => esc_html__( |
|
981 | - "If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ", |
|
982 | - 'event_espresso' |
|
983 | - ) |
|
984 | - ) |
|
985 | - ), |
|
986 | - 'gateway_log_lifespan' => new EE_Select_Input( |
|
987 | - $reg_config->gatewayLogLifespanOptions(), |
|
988 | - array( |
|
989 | - 'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'), |
|
990 | - 'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'), |
|
991 | - 'default' => $reg_config->gateway_log_lifespan, |
|
992 | - ) |
|
993 | - ) |
|
994 | - ) |
|
995 | - ) |
|
996 | - ); |
|
997 | - } |
|
998 | - |
|
999 | - |
|
1000 | - protected function _payment_log_overview_list_table() |
|
1001 | - { |
|
1002 | - $this->display_admin_list_table_page_with_sidebar(); |
|
1003 | - } |
|
1004 | - |
|
1005 | - |
|
1006 | - protected function _set_list_table_views_payment_log() |
|
1007 | - { |
|
1008 | - $this->_views = array( |
|
1009 | - 'all' => array( |
|
1010 | - 'slug' => 'all', |
|
1011 | - 'label' => __('View All Logs', 'event_espresso'), |
|
1012 | - 'count' => 0, |
|
1013 | - ), |
|
1014 | - ); |
|
1015 | - } |
|
1016 | - |
|
1017 | - |
|
1018 | - /** |
|
1019 | - * @param int $per_page |
|
1020 | - * @param int $current_page |
|
1021 | - * @param bool $count |
|
1022 | - * @return array |
|
1023 | - */ |
|
1024 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) |
|
1025 | - { |
|
1026 | - EE_Registry::instance()->load_model('Change_Log'); |
|
1027 | - // we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
|
1028 | - $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway)); |
|
1029 | - // check if they've selected a specific payment method |
|
1030 | - if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
1031 | - $query_params[0]['OR*pm_or_pay_pm'] = array( |
|
1032 | - 'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1033 | - 'Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1034 | - ); |
|
1035 | - } |
|
1036 | - // take into account search |
|
1037 | - if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
1038 | - $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%'); |
|
1039 | - $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
|
1040 | - $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
|
1041 | - $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
|
1042 | - $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string; |
|
1043 | - $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1044 | - $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string; |
|
1045 | - $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1046 | - $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string; |
|
1047 | - $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1048 | - $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string; |
|
1049 | - $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1050 | - } |
|
1051 | - if (isset($this->_req_data['payment-filter-start-date']) |
|
1052 | - && isset($this->_req_data['payment-filter-end-date']) |
|
1053 | - ) { |
|
1054 | - // add date |
|
1055 | - $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
1056 | - $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
1057 | - // make sure our timestamps start and end right at the boundaries for each day |
|
1058 | - $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1059 | - $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1060 | - // convert to timestamps |
|
1061 | - $start_date = strtotime($start_date); |
|
1062 | - $end_date = strtotime($end_date); |
|
1063 | - // makes sure start date is the lowest value and vice versa |
|
1064 | - $start_date = min($start_date, $end_date); |
|
1065 | - $end_date = max($start_date, $end_date); |
|
1066 | - // convert for query |
|
1067 | - $start_date = EEM_Change_Log::instance() |
|
1068 | - ->convert_datetime_for_query( |
|
1069 | - 'LOG_time', |
|
1070 | - date('Y-m-d H:i:s', $start_date), |
|
1071 | - 'Y-m-d H:i:s' |
|
1072 | - ); |
|
1073 | - $end_date = EEM_Change_Log::instance() |
|
1074 | - ->convert_datetime_for_query( |
|
1075 | - 'LOG_time', |
|
1076 | - date('Y-m-d H:i:s', $end_date), |
|
1077 | - 'Y-m-d H:i:s' |
|
1078 | - ); |
|
1079 | - $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
1080 | - } |
|
1081 | - if ($count) { |
|
1082 | - return EEM_Change_Log::instance()->count($query_params); |
|
1083 | - } |
|
1084 | - if (isset($this->_req_data['order'])) { |
|
1085 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
1086 | - : 'DESC'; |
|
1087 | - $query_params['order_by'] = array('LOG_time' => $sort); |
|
1088 | - } else { |
|
1089 | - $query_params['order_by'] = array('LOG_time' => 'DESC'); |
|
1090 | - } |
|
1091 | - $offset = ($current_page - 1) * $per_page; |
|
1092 | - if (! isset($this->_req_data['download_results'])) { |
|
1093 | - $query_params['limit'] = array($offset, $per_page); |
|
1094 | - } |
|
1095 | - // now they've requested to instead just download the file instead of viewing it. |
|
1096 | - if (isset($this->_req_data['download_results'])) { |
|
1097 | - $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
|
1098 | - header('Content-Disposition: attachment'); |
|
1099 | - header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url())); |
|
1100 | - echo "<h1>Payment Logs for " . site_url() . "</h1>"; |
|
1101 | - echo "<h3>Query:</h3>"; |
|
1102 | - var_dump($query_params); |
|
1103 | - echo "<h3>Results:</h3>"; |
|
1104 | - var_dump($wpdb_results); |
|
1105 | - die; |
|
1106 | - } |
|
1107 | - $results = EEM_Change_Log::instance()->get_all($query_params); |
|
1108 | - return $results; |
|
1109 | - } |
|
1110 | - |
|
1111 | - |
|
1112 | - /** |
|
1113 | - * Used by usort to RE-sort log query results, because we lose the ordering |
|
1114 | - * because we're possibly combining the results from two queries |
|
1115 | - * |
|
1116 | - * @param EE_Change_Log $logA |
|
1117 | - * @param EE_Change_Log $logB |
|
1118 | - * @return int |
|
1119 | - */ |
|
1120 | - protected function _sort_logs_again($logA, $logB) |
|
1121 | - { |
|
1122 | - $timeA = $logA->get_raw('LOG_time'); |
|
1123 | - $timeB = $logB->get_raw('LOG_time'); |
|
1124 | - if ($timeA == $timeB) { |
|
1125 | - return 0; |
|
1126 | - } |
|
1127 | - $comparison = $timeA < $timeB ? -1 : 1; |
|
1128 | - if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
1129 | - return $comparison * -1; |
|
1130 | - } else { |
|
1131 | - return $comparison; |
|
1132 | - } |
|
1133 | - } |
|
1134 | - |
|
1135 | - |
|
1136 | - protected function _payment_log_details() |
|
1137 | - { |
|
1138 | - EE_Registry::instance()->load_model('Change_Log'); |
|
1139 | - /** @var $payment_log EE_Change_Log */ |
|
1140 | - $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
|
1141 | - $payment_method = null; |
|
1142 | - $transaction = null; |
|
1143 | - if ($payment_log instanceof EE_Change_Log) { |
|
1144 | - if ($payment_log->object() instanceof EE_Payment) { |
|
1145 | - $payment_method = $payment_log->object()->payment_method(); |
|
1146 | - $transaction = $payment_log->object()->transaction(); |
|
1147 | - } elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
1148 | - $payment_method = $payment_log->object(); |
|
1149 | - } elseif ($payment_log->object() instanceof EE_Transaction) { |
|
1150 | - $transaction = $payment_log->object(); |
|
1151 | - $payment_method = $transaction->payment_method(); |
|
1152 | - } |
|
1153 | - } |
|
1154 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1155 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
1156 | - array( |
|
1157 | - 'payment_log' => $payment_log, |
|
1158 | - 'payment_method' => $payment_method, |
|
1159 | - 'transaction' => $transaction, |
|
1160 | - ), |
|
1161 | - true |
|
1162 | - ); |
|
1163 | - $this->display_admin_page_with_sidebar(); |
|
1164 | - } |
|
19 | + /** |
|
20 | + * Variables used for when we're re-sorting the logs results, in case |
|
21 | + * we needed to do two queries and we need to resort |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + private $_sort_logs_again_direction; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @Constructor |
|
30 | + * @access public |
|
31 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
32 | + * @throws EE_Error |
|
33 | + * @throws InvalidArgumentException |
|
34 | + * @throws InvalidDataTypeException |
|
35 | + * @throws InvalidInterfaceException |
|
36 | + * @throws ReflectionException |
|
37 | + */ |
|
38 | + public function __construct($routing = true) |
|
39 | + { |
|
40 | + parent::__construct($routing); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + protected function _init_page_props() |
|
45 | + { |
|
46 | + $this->page_slug = EE_PAYMENTS_PG_SLUG; |
|
47 | + $this->page_label = __('Payment Methods', 'event_espresso'); |
|
48 | + $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL; |
|
49 | + $this->_admin_base_path = EE_PAYMENTS_ADMIN; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + protected function _ajax_hooks() |
|
54 | + { |
|
55 | + // todo: all hooks for ajax goes here. |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + protected function _define_page_props() |
|
60 | + { |
|
61 | + $this->_admin_page_title = $this->page_label; |
|
62 | + $this->_labels = array( |
|
63 | + 'publishbox' => __('Update Settings', 'event_espresso'), |
|
64 | + ); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + protected function _set_page_routes() |
|
69 | + { |
|
70 | + /** |
|
71 | + * note that with payment method capabilities, although we've implemented |
|
72 | + * capability mapping which will be used for accessing payment methods owned by |
|
73 | + * other users. This is not fully implemented yet in the payment method ui. |
|
74 | + * Currently only the "plural" caps are in active use. |
|
75 | + * When cap mapping is implemented, some routes will need to use the singular form of |
|
76 | + * capability method and also include the $id of the payment method for the route. |
|
77 | + **/ |
|
78 | + $this->_page_routes = array( |
|
79 | + 'default' => array( |
|
80 | + 'func' => '_payment_methods_list', |
|
81 | + 'capability' => 'ee_edit_payment_methods', |
|
82 | + ), |
|
83 | + 'payment_settings' => array( |
|
84 | + 'func' => '_payment_settings', |
|
85 | + 'capability' => 'ee_manage_gateways', |
|
86 | + ), |
|
87 | + 'activate_payment_method' => array( |
|
88 | + 'func' => '_activate_payment_method', |
|
89 | + 'noheader' => true, |
|
90 | + 'capability' => 'ee_edit_payment_methods', |
|
91 | + ), |
|
92 | + 'deactivate_payment_method' => array( |
|
93 | + 'func' => '_deactivate_payment_method', |
|
94 | + 'noheader' => true, |
|
95 | + 'capability' => 'ee_delete_payment_methods', |
|
96 | + ), |
|
97 | + 'update_payment_method' => array( |
|
98 | + 'func' => '_update_payment_method', |
|
99 | + 'noheader' => true, |
|
100 | + 'headers_sent_route' => 'default', |
|
101 | + 'capability' => 'ee_edit_payment_methods', |
|
102 | + ), |
|
103 | + 'update_payment_settings' => array( |
|
104 | + 'func' => '_update_payment_settings', |
|
105 | + 'noheader' => true, |
|
106 | + 'capability' => 'ee_manage_gateways', |
|
107 | + ), |
|
108 | + 'payment_log' => array( |
|
109 | + 'func' => '_payment_log_overview_list_table', |
|
110 | + 'capability' => 'ee_read_payment_methods', |
|
111 | + ), |
|
112 | + 'payment_log_details' => array( |
|
113 | + 'func' => '_payment_log_details', |
|
114 | + 'capability' => 'ee_read_payment_methods', |
|
115 | + ), |
|
116 | + ); |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + protected function _set_page_config() |
|
121 | + { |
|
122 | + $payment_method_list_config = array( |
|
123 | + 'nav' => array( |
|
124 | + 'label' => __('Payment Methods', 'event_espresso'), |
|
125 | + 'order' => 10, |
|
126 | + ), |
|
127 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
128 | + 'help_tabs' => array_merge( |
|
129 | + array( |
|
130 | + 'payment_methods_overview_help_tab' => array( |
|
131 | + 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
132 | + 'filename' => 'payment_methods_overview', |
|
133 | + ), |
|
134 | + ), |
|
135 | + $this->_add_payment_method_help_tabs() |
|
136 | + ), |
|
137 | + 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
138 | + 'require_nonce' => false, |
|
139 | + ); |
|
140 | + $this->_page_config = array( |
|
141 | + 'default' => $payment_method_list_config, |
|
142 | + 'payment_settings' => array( |
|
143 | + 'nav' => array( |
|
144 | + 'label' => __('Settings', 'event_espresso'), |
|
145 | + 'order' => 20, |
|
146 | + ), |
|
147 | + 'help_tabs' => array( |
|
148 | + 'payment_methods_settings_help_tab' => array( |
|
149 | + 'title' => __('Payment Method Settings', 'event_espresso'), |
|
150 | + 'filename' => 'payment_methods_settings', |
|
151 | + ), |
|
152 | + ), |
|
153 | + // 'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
|
154 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
155 | + 'require_nonce' => false, |
|
156 | + ), |
|
157 | + 'payment_log' => array( |
|
158 | + 'nav' => array( |
|
159 | + 'label' => __("Logs", 'event_espresso'), |
|
160 | + 'order' => 30, |
|
161 | + ), |
|
162 | + 'list_table' => 'Payment_Log_Admin_List_Table', |
|
163 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
164 | + 'require_nonce' => false, |
|
165 | + ), |
|
166 | + ); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @return array |
|
172 | + * @throws DomainException |
|
173 | + * @throws EE_Error |
|
174 | + * @throws InvalidArgumentException |
|
175 | + * @throws InvalidDataTypeException |
|
176 | + * @throws InvalidInterfaceException |
|
177 | + * @throws ReflectionException |
|
178 | + */ |
|
179 | + protected function _add_payment_method_help_tabs() |
|
180 | + { |
|
181 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
182 | + $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
|
183 | + $all_pmt_help_tabs_config = array(); |
|
184 | + foreach ($payment_method_types as $payment_method_type) { |
|
185 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
186 | + $payment_method_type->cap_name(), |
|
187 | + 'specific_payment_method_type_access' |
|
188 | + ) |
|
189 | + ) { |
|
190 | + continue; |
|
191 | + } |
|
192 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
193 | + $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
194 | + $template_args['admin_page_obj'] = $this; |
|
195 | + $all_pmt_help_tabs_config[ $help_tab_name ] = array( |
|
196 | + 'title' => $config['title'], |
|
197 | + 'content' => EEH_Template::display_template( |
|
198 | + $payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php', |
|
199 | + $template_args, |
|
200 | + true |
|
201 | + ), |
|
202 | + ); |
|
203 | + } |
|
204 | + } |
|
205 | + return $all_pmt_help_tabs_config; |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + // none of the below group are currently used for Gateway Settings |
|
210 | + protected function _add_screen_options() |
|
211 | + { |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + protected function _add_feature_pointers() |
|
216 | + { |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + public function admin_init() |
|
221 | + { |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + public function admin_notices() |
|
226 | + { |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + public function admin_footer_scripts() |
|
231 | + { |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + public function load_scripts_styles() |
|
236 | + { |
|
237 | + wp_enqueue_script('ee_admin_js'); |
|
238 | + wp_enqueue_script('ee-text-links'); |
|
239 | + wp_enqueue_script( |
|
240 | + 'espresso_payments', |
|
241 | + EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', |
|
242 | + array('espresso-ui-theme', 'ee-datepicker'), |
|
243 | + EVENT_ESPRESSO_VERSION, |
|
244 | + true |
|
245 | + ); |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + public function load_scripts_styles_default() |
|
250 | + { |
|
251 | + // styles |
|
252 | + wp_register_style( |
|
253 | + 'espresso_payments', |
|
254 | + EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', |
|
255 | + array(), |
|
256 | + EVENT_ESPRESSO_VERSION |
|
257 | + ); |
|
258 | + wp_enqueue_style('espresso_payments'); |
|
259 | + wp_enqueue_style('ee-text-links'); |
|
260 | + // scripts |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + protected function _payment_methods_list() |
|
265 | + { |
|
266 | + /** |
|
267 | + * first let's ensure payment methods have been setup. We do this here because when people activate a |
|
268 | + * payment method for the first time (as an addon), it may not setup its capabilities or get registered |
|
269 | + * correctly due to the loading process. However, people MUST setup the details for the payment method so its |
|
270 | + * safe to do a recheck here. |
|
271 | + */ |
|
272 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
273 | + EEM_Payment_Method::instance()->verify_button_urls(); |
|
274 | + // setup tabs, one for each payment method type |
|
275 | + $tabs = array(); |
|
276 | + $payment_methods = array(); |
|
277 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
278 | + // we don't want to show admin-only PMTs for now |
|
279 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
280 | + continue; |
|
281 | + } |
|
282 | + // check access |
|
283 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
284 | + $pmt_obj->cap_name(), |
|
285 | + 'specific_payment_method_type_access' |
|
286 | + ) |
|
287 | + ) { |
|
288 | + continue; |
|
289 | + } |
|
290 | + // check for any active pms of that type |
|
291 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
292 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
293 | + $payment_method = EE_Payment_Method::new_instance( |
|
294 | + array( |
|
295 | + 'PMD_slug' => sanitize_key($pmt_obj->system_name()), |
|
296 | + 'PMD_type' => $pmt_obj->system_name(), |
|
297 | + 'PMD_name' => $pmt_obj->pretty_name(), |
|
298 | + 'PMD_admin_name' => $pmt_obj->pretty_name(), |
|
299 | + ) |
|
300 | + ); |
|
301 | + } |
|
302 | + $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
303 | + } |
|
304 | + $payment_methods = apply_filters( |
|
305 | + 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', |
|
306 | + $payment_methods |
|
307 | + ); |
|
308 | + foreach ($payment_methods as $payment_method) { |
|
309 | + if ($payment_method instanceof EE_Payment_Method) { |
|
310 | + add_meta_box( |
|
311 | + // html id |
|
312 | + 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
313 | + // title |
|
314 | + sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
315 | + // callback |
|
316 | + array($this, 'payment_method_settings_meta_box'), |
|
317 | + // post type |
|
318 | + null, |
|
319 | + // context |
|
320 | + 'normal', |
|
321 | + // priority |
|
322 | + 'default', |
|
323 | + // callback args |
|
324 | + array('payment_method' => $payment_method) |
|
325 | + ); |
|
326 | + // setup for tabbed content |
|
327 | + $tabs[ $payment_method->slug() ] = array( |
|
328 | + 'label' => $payment_method->admin_name(), |
|
329 | + 'class' => $payment_method->active() ? 'gateway-active' : '', |
|
330 | + 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
331 | + 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
332 | + 'slug' => $payment_method->slug(), |
|
333 | + ); |
|
334 | + } |
|
335 | + } |
|
336 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( |
|
337 | + $tabs, |
|
338 | + 'payment_method_links', |
|
339 | + '|', |
|
340 | + $this->_get_active_payment_method_slug() |
|
341 | + ); |
|
342 | + $this->display_admin_page_with_sidebar(); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * _get_active_payment_method_slug |
|
348 | + * |
|
349 | + * @return string |
|
350 | + */ |
|
351 | + protected function _get_active_payment_method_slug() |
|
352 | + { |
|
353 | + $payment_method_slug = false; |
|
354 | + // decide which payment method tab to open first, as dictated by the request's 'payment_method' |
|
355 | + if (isset($this->_req_data['payment_method'])) { |
|
356 | + // if they provided the current payment method, use it |
|
357 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
358 | + } |
|
359 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
360 | + // if that didn't work or wasn't provided, find another way to select the current pm |
|
361 | + if (! $this->_verify_payment_method($payment_method)) { |
|
362 | + // like, looking for an active one |
|
363 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
364 | + // test that one as well |
|
365 | + if ($this->_verify_payment_method($payment_method)) { |
|
366 | + $payment_method_slug = $payment_method->slug(); |
|
367 | + } else { |
|
368 | + $payment_method_slug = 'paypal_standard'; |
|
369 | + } |
|
370 | + } |
|
371 | + return $payment_method_slug; |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * payment_method_settings_meta_box |
|
377 | + * returns TRUE if the passed payment method is properly constructed and the logged in user has the correct |
|
378 | + * capabilities to access it |
|
379 | + * |
|
380 | + * @param EE_Payment_Method $payment_method |
|
381 | + * @return boolean |
|
382 | + */ |
|
383 | + protected function _verify_payment_method($payment_method) |
|
384 | + { |
|
385 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base |
|
386 | + && EE_Registry::instance()->CAP->current_user_can( |
|
387 | + $payment_method->type_obj()->cap_name(), |
|
388 | + 'specific_payment_method_type_access' |
|
389 | + ) |
|
390 | + ) { |
|
391 | + return true; |
|
392 | + } |
|
393 | + return false; |
|
394 | + } |
|
395 | + |
|
396 | + |
|
397 | + /** |
|
398 | + * payment_method_settings_meta_box |
|
399 | + * |
|
400 | + * @param NULL $post_obj_which_is_null is an object containing the current post (as a $post object) |
|
401 | + * @param array $metabox is an array with metabox id, title, callback, and args elements. the value |
|
402 | + * at 'args' has key 'payment_method', as set within _payment_methods_list |
|
403 | + * @return string |
|
404 | + * @throws EE_Error |
|
405 | + */ |
|
406 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) |
|
407 | + { |
|
408 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) |
|
409 | + ? $metabox['args']['payment_method'] : null; |
|
410 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
411 | + throw new EE_Error( |
|
412 | + sprintf( |
|
413 | + __( |
|
414 | + 'Payment method metabox setup incorrectly. No Payment method object was supplied', |
|
415 | + 'event_espresso' |
|
416 | + ) |
|
417 | + ) |
|
418 | + ); |
|
419 | + } |
|
420 | + $payment_method_scopes = $payment_method->active(); |
|
421 | + // if the payment method really exists show its form, otherwise the activation template |
|
422 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
423 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
424 | + if ($form->form_data_present_in($this->_req_data)) { |
|
425 | + $form->receive_form_submission($this->_req_data); |
|
426 | + } |
|
427 | + echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
428 | + } else { |
|
429 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
430 | + } |
|
431 | + } |
|
432 | + |
|
433 | + |
|
434 | + /** |
|
435 | + * Gets the form for all the settings related to this payment method type |
|
436 | + * |
|
437 | + * @access protected |
|
438 | + * @param EE_Payment_Method $payment_method |
|
439 | + * @return EE_Form_Section_Proper |
|
440 | + */ |
|
441 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) |
|
442 | + { |
|
443 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
444 | + return new EE_Form_Section_Proper(); |
|
445 | + } |
|
446 | + return new EE_Form_Section_Proper( |
|
447 | + array( |
|
448 | + 'name' => $payment_method->slug() . '_settings_form', |
|
449 | + 'html_id' => $payment_method->slug() . '_settings_form', |
|
450 | + 'action' => EE_Admin_Page::add_query_args_and_nonce( |
|
451 | + array( |
|
452 | + 'action' => 'update_payment_method', |
|
453 | + 'payment_method' => $payment_method->slug(), |
|
454 | + ), |
|
455 | + EE_PAYMENTS_ADMIN_URL |
|
456 | + ), |
|
457 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
458 | + 'subsections' => apply_filters( |
|
459 | + 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
|
460 | + array( |
|
461 | + 'pci_dss_compliance' => $this->_pci_dss_compliance($payment_method), |
|
462 | + 'currency_support' => $this->_currency_support($payment_method), |
|
463 | + 'payment_method_settings' => $this->_payment_method_settings($payment_method), |
|
464 | + 'update' => $this->_update_payment_method_button($payment_method), |
|
465 | + 'deactivate' => $this->_deactivate_payment_method_button($payment_method), |
|
466 | + 'fine_print' => $this->_fine_print(), |
|
467 | + ), |
|
468 | + $payment_method |
|
469 | + ), |
|
470 | + ) |
|
471 | + ); |
|
472 | + } |
|
473 | + |
|
474 | + |
|
475 | + /** |
|
476 | + * _pci_dss_compliance |
|
477 | + * |
|
478 | + * @access protected |
|
479 | + * @param EE_Payment_Method $payment_method |
|
480 | + * @return EE_Form_Section_Proper |
|
481 | + */ |
|
482 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) |
|
483 | + { |
|
484 | + if ($payment_method->type_obj()->requires_https()) { |
|
485 | + return new EE_Form_Section_HTML( |
|
486 | + EEH_HTML::table( |
|
487 | + EEH_HTML::tr( |
|
488 | + EEH_HTML::th( |
|
489 | + EEH_HTML::label( |
|
490 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
491 | + ) |
|
492 | + ) . |
|
493 | + EEH_HTML::td( |
|
494 | + EEH_HTML::strong( |
|
495 | + __( |
|
496 | + 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', |
|
497 | + 'event_espresso' |
|
498 | + ) |
|
499 | + ) |
|
500 | + . |
|
501 | + EEH_HTML::br() |
|
502 | + . |
|
503 | + __('Learn more about ', 'event_espresso') |
|
504 | + . EEH_HTML::link( |
|
505 | + 'https://www.pcisecuritystandards.org/merchants/index.php', |
|
506 | + __('PCI DSS compliance', 'event_espresso') |
|
507 | + ) |
|
508 | + ) |
|
509 | + ) |
|
510 | + ) |
|
511 | + ); |
|
512 | + } else { |
|
513 | + return new EE_Form_Section_HTML(''); |
|
514 | + } |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * _currency_support |
|
520 | + * |
|
521 | + * @access protected |
|
522 | + * @param EE_Payment_Method $payment_method |
|
523 | + * @return EE_Form_Section_Proper |
|
524 | + */ |
|
525 | + protected function _currency_support(EE_Payment_Method $payment_method) |
|
526 | + { |
|
527 | + if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
528 | + return new EE_Form_Section_HTML( |
|
529 | + EEH_HTML::table( |
|
530 | + EEH_HTML::tr( |
|
531 | + EEH_HTML::th( |
|
532 | + EEH_HTML::label( |
|
533 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
534 | + ) |
|
535 | + ) . |
|
536 | + EEH_HTML::td( |
|
537 | + EEH_HTML::strong( |
|
538 | + sprintf( |
|
539 | + __( |
|
540 | + 'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.', |
|
541 | + 'event_espresso' |
|
542 | + ), |
|
543 | + EE_Config::instance()->currency->code |
|
544 | + ) |
|
545 | + ) |
|
546 | + ) |
|
547 | + ) |
|
548 | + ) |
|
549 | + ); |
|
550 | + } else { |
|
551 | + return new EE_Form_Section_HTML(''); |
|
552 | + } |
|
553 | + } |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * _update_payment_method_button |
|
558 | + * |
|
559 | + * @access protected |
|
560 | + * @param EE_Payment_Method $payment_method |
|
561 | + * @return EE_Payment_Method_Form |
|
562 | + */ |
|
563 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) |
|
564 | + { |
|
565 | + // modify the form so we only have/show fields that will be implemented for this version |
|
566 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
567 | + } |
|
568 | + |
|
569 | + |
|
570 | + /** |
|
571 | + * Simplifies the form to merely reproduce 4.1's gateway settings functionality |
|
572 | + * |
|
573 | + * @param EE_Form_Section_Proper $form_section |
|
574 | + * @param string $payment_method_name |
|
575 | + * @return EE_Payment_Method_Form |
|
576 | + * @throws EE_Error |
|
577 | + */ |
|
578 | + protected function _simplify_form($form_section, $payment_method_name = '') |
|
579 | + { |
|
580 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
581 | + $form_section->exclude( |
|
582 | + array( |
|
583 | + 'PMD_type', // dont want them changing the type |
|
584 | + 'PMD_slug', // or the slug (probably never) |
|
585 | + 'PMD_wp_user', // or the user's ID |
|
586 | + 'Currency' // or the currency, until the rest of EE supports simultaneous currencies |
|
587 | + ) |
|
588 | + ); |
|
589 | + return $form_section; |
|
590 | + } else { |
|
591 | + throw new EE_Error( |
|
592 | + sprintf( |
|
593 | + __( |
|
594 | + 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', |
|
595 | + 'event_espresso' |
|
596 | + ), |
|
597 | + $payment_method_name |
|
598 | + ) |
|
599 | + ); |
|
600 | + } |
|
601 | + } |
|
602 | + |
|
603 | + |
|
604 | + /** |
|
605 | + * _update_payment_method_button |
|
606 | + * |
|
607 | + * @access protected |
|
608 | + * @param EE_Payment_Method $payment_method |
|
609 | + * @return EE_Form_Section_HTML |
|
610 | + */ |
|
611 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) |
|
612 | + { |
|
613 | + $update_button = new EE_Submit_Input( |
|
614 | + array( |
|
615 | + 'name' => 'submit', |
|
616 | + 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
617 | + 'default' => sprintf( |
|
618 | + __('Update %s Payment Settings', 'event_espresso'), |
|
619 | + $payment_method->admin_name() |
|
620 | + ), |
|
621 | + 'html_label' => EEH_HTML::nbsp(), |
|
622 | + ) |
|
623 | + ); |
|
624 | + return new EE_Form_Section_HTML( |
|
625 | + EEH_HTML::table( |
|
626 | + EEH_HTML::no_row(EEH_HTML::br(2)) . |
|
627 | + EEH_HTML::tr( |
|
628 | + EEH_HTML::th(__('Update Settings', 'event_espresso')) . |
|
629 | + EEH_HTML::td( |
|
630 | + $update_button->get_html_for_input() |
|
631 | + ) |
|
632 | + ) |
|
633 | + ) |
|
634 | + ); |
|
635 | + } |
|
636 | + |
|
637 | + |
|
638 | + /** |
|
639 | + * _deactivate_payment_method_button |
|
640 | + * |
|
641 | + * @access protected |
|
642 | + * @param EE_Payment_Method $payment_method |
|
643 | + * @return EE_Form_Section_Proper |
|
644 | + */ |
|
645 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) |
|
646 | + { |
|
647 | + $link_text_and_title = sprintf( |
|
648 | + __('Deactivate %1$s Payments?', 'event_espresso'), |
|
649 | + $payment_method->admin_name() |
|
650 | + ); |
|
651 | + return new EE_Form_Section_HTML( |
|
652 | + EEH_HTML::table( |
|
653 | + EEH_HTML::tr( |
|
654 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) . |
|
655 | + EEH_HTML::td( |
|
656 | + EEH_HTML::link( |
|
657 | + EE_Admin_Page::add_query_args_and_nonce( |
|
658 | + array( |
|
659 | + 'action' => 'deactivate_payment_method', |
|
660 | + 'payment_method' => $payment_method->slug(), |
|
661 | + ), |
|
662 | + EE_PAYMENTS_ADMIN_URL |
|
663 | + ), |
|
664 | + $link_text_and_title, |
|
665 | + $link_text_and_title, |
|
666 | + 'deactivate_' . $payment_method->slug(), |
|
667 | + 'espresso-button button-secondary' |
|
668 | + ) |
|
669 | + ) |
|
670 | + ) |
|
671 | + ) |
|
672 | + ); |
|
673 | + } |
|
674 | + |
|
675 | + |
|
676 | + /** |
|
677 | + * _activate_payment_method_button |
|
678 | + * |
|
679 | + * @access protected |
|
680 | + * @param EE_Payment_Method $payment_method |
|
681 | + * @return EE_Form_Section_Proper |
|
682 | + */ |
|
683 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) |
|
684 | + { |
|
685 | + $link_text_and_title = sprintf( |
|
686 | + __('Activate %1$s Payment Method?', 'event_espresso'), |
|
687 | + $payment_method->admin_name() |
|
688 | + ); |
|
689 | + return new EE_Form_Section_Proper( |
|
690 | + array( |
|
691 | + 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
692 | + 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
693 | + 'action' => '#', |
|
694 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
695 | + 'subsections' => apply_filters( |
|
696 | + 'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections', |
|
697 | + array( |
|
698 | + new EE_Form_Section_HTML( |
|
699 | + EEH_HTML::table( |
|
700 | + EEH_HTML::tr( |
|
701 | + EEH_HTML::td( |
|
702 | + $payment_method->type_obj()->introductory_html(), |
|
703 | + '', |
|
704 | + '', |
|
705 | + '', |
|
706 | + 'colspan="2"' |
|
707 | + ) |
|
708 | + ) . |
|
709 | + EEH_HTML::tr( |
|
710 | + EEH_HTML::th( |
|
711 | + EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
712 | + ) . |
|
713 | + EEH_HTML::td( |
|
714 | + EEH_HTML::link( |
|
715 | + EE_Admin_Page::add_query_args_and_nonce( |
|
716 | + array( |
|
717 | + 'action' => 'activate_payment_method', |
|
718 | + 'payment_method_type' => $payment_method->type(), |
|
719 | + ), |
|
720 | + EE_PAYMENTS_ADMIN_URL |
|
721 | + ), |
|
722 | + $link_text_and_title, |
|
723 | + $link_text_and_title, |
|
724 | + 'activate_' . $payment_method->slug(), |
|
725 | + 'espresso-button-green button-primary' |
|
726 | + ) |
|
727 | + ) |
|
728 | + ) |
|
729 | + ) |
|
730 | + ), |
|
731 | + ), |
|
732 | + $payment_method |
|
733 | + ), |
|
734 | + ) |
|
735 | + ); |
|
736 | + } |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * _fine_print |
|
741 | + * |
|
742 | + * @access protected |
|
743 | + * @return EE_Form_Section_HTML |
|
744 | + */ |
|
745 | + protected function _fine_print() |
|
746 | + { |
|
747 | + return new EE_Form_Section_HTML( |
|
748 | + EEH_HTML::table( |
|
749 | + EEH_HTML::tr( |
|
750 | + EEH_HTML::th() . |
|
751 | + EEH_HTML::td( |
|
752 | + EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
753 | + ) |
|
754 | + ) |
|
755 | + ) |
|
756 | + ); |
|
757 | + } |
|
758 | + |
|
759 | + |
|
760 | + /** |
|
761 | + * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
|
762 | + * |
|
763 | + * @global WP_User $current_user |
|
764 | + */ |
|
765 | + protected function _activate_payment_method() |
|
766 | + { |
|
767 | + if (isset($this->_req_data['payment_method_type'])) { |
|
768 | + $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
|
769 | + // see if one exists |
|
770 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
771 | + $payment_method = EE_Payment_Method_Manager::instance() |
|
772 | + ->activate_a_payment_method_of_type($payment_method_type); |
|
773 | + $this->_redirect_after_action( |
|
774 | + 1, |
|
775 | + 'Payment Method', |
|
776 | + 'activated', |
|
777 | + array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
778 | + ); |
|
779 | + } else { |
|
780 | + $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
781 | + } |
|
782 | + } |
|
783 | + |
|
784 | + |
|
785 | + /** |
|
786 | + * Deactivates the payment method with the specified slug, and redirects. |
|
787 | + */ |
|
788 | + protected function _deactivate_payment_method() |
|
789 | + { |
|
790 | + if (isset($this->_req_data['payment_method'])) { |
|
791 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
792 | + // deactivate it |
|
793 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
794 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
795 | + $this->_redirect_after_action( |
|
796 | + $count_updated, |
|
797 | + 'Payment Method', |
|
798 | + 'deactivated', |
|
799 | + array('action' => 'default', 'payment_method' => $payment_method_slug) |
|
800 | + ); |
|
801 | + } else { |
|
802 | + $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default')); |
|
803 | + } |
|
804 | + } |
|
805 | + |
|
806 | + |
|
807 | + /** |
|
808 | + * Processes the payment method form that was submitted. This is slightly trickier than usual form |
|
809 | + * processing because we first need to identify WHICH form was processed and which payment method |
|
810 | + * it corresponds to. Once we have done that, we see if the form is valid. If it is, the |
|
811 | + * form's data is saved and we redirect to the default payment methods page, setting the updated payment method |
|
812 | + * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the |
|
813 | + * subsequently called 'headers_sent_func' which is _payment_methods_list) |
|
814 | + * |
|
815 | + * @return void |
|
816 | + */ |
|
817 | + protected function _update_payment_method() |
|
818 | + { |
|
819 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
820 | + // ok let's find which gateway form to use based on the form input |
|
821 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
822 | + /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
|
823 | + $correct_pmt_form_to_use = null; |
|
824 | + $payment_method = null; |
|
825 | + foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) { |
|
826 | + // get the form and simplify it, like what we do when we display it |
|
827 | + $pmt_form = $this->_generate_payment_method_settings_form($payment_method); |
|
828 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
829 | + $correct_pmt_form_to_use = $pmt_form; |
|
830 | + break; |
|
831 | + } |
|
832 | + } |
|
833 | + // if we couldn't find the correct payment method type... |
|
834 | + if (! $correct_pmt_form_to_use) { |
|
835 | + EE_Error::add_error( |
|
836 | + __( |
|
837 | + "We could not find which payment method type your form submission related to. Please contact support", |
|
838 | + 'event_espresso' |
|
839 | + ), |
|
840 | + __FILE__, |
|
841 | + __FUNCTION__, |
|
842 | + __LINE__ |
|
843 | + ); |
|
844 | + $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
845 | + } |
|
846 | + $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
|
847 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
848 | + $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings'); |
|
849 | + if (! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
850 | + throw new EE_Error( |
|
851 | + sprintf( |
|
852 | + __( |
|
853 | + 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', |
|
854 | + 'event_espresso' |
|
855 | + ), |
|
856 | + 'payment_method_settings' |
|
857 | + ) |
|
858 | + ); |
|
859 | + } |
|
860 | + $payment_settings_subform->save(); |
|
861 | + /** @var $pm EE_Payment_Method */ |
|
862 | + $this->_redirect_after_action( |
|
863 | + true, |
|
864 | + 'Payment Method', |
|
865 | + 'updated', |
|
866 | + array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
867 | + ); |
|
868 | + } else { |
|
869 | + EE_Error::add_error( |
|
870 | + sprintf( |
|
871 | + __( |
|
872 | + 'Payment method of type %s was not saved because there were validation errors. They have been marked in the form', |
|
873 | + 'event_espresso' |
|
874 | + ), |
|
875 | + $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name() |
|
876 | + : __('"(unknown)"', 'event_espresso') |
|
877 | + ), |
|
878 | + __FILE__, |
|
879 | + __FUNCTION__, |
|
880 | + __LINE__ |
|
881 | + ); |
|
882 | + } |
|
883 | + } |
|
884 | + return; |
|
885 | + } |
|
886 | + |
|
887 | + |
|
888 | + /** |
|
889 | + * Displays payment settings (not payment METHOD settings, that's _payment_method_settings) |
|
890 | + * @throws DomainException |
|
891 | + * @throws EE_Error |
|
892 | + * @throws InvalidArgumentException |
|
893 | + * @throws InvalidDataTypeException |
|
894 | + * @throws InvalidInterfaceException |
|
895 | + */ |
|
896 | + protected function _payment_settings() |
|
897 | + { |
|
898 | + $form = $this->getPaymentSettingsForm(); |
|
899 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
900 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
901 | + $this->_template_args['admin_page_content'] = $form->get_html_and_js(); |
|
902 | + $this->display_admin_page_with_sidebar(); |
|
903 | + } |
|
904 | + |
|
905 | + |
|
906 | + /** |
|
907 | + * _update_payment_settings |
|
908 | + * |
|
909 | + * @access protected |
|
910 | + * @return void |
|
911 | + * @throws EE_Error |
|
912 | + * @throws InvalidArgumentException |
|
913 | + * @throws InvalidDataTypeException |
|
914 | + * @throws InvalidInterfaceException |
|
915 | + */ |
|
916 | + protected function _update_payment_settings() |
|
917 | + { |
|
918 | + $form = $this->getPaymentSettingsForm(); |
|
919 | + if ($form->was_submitted($this->_req_data)) { |
|
920 | + $form->receive_form_submission($this->_req_data); |
|
921 | + if ($form->is_valid()) { |
|
922 | + /** |
|
923 | + * @var $reg_config EE_Registration_Config |
|
924 | + */ |
|
925 | + $loader = LoaderFactory::getLoader(); |
|
926 | + $reg_config = $loader->getShared('EE_Registration_Config'); |
|
927 | + $valid_data = $form->valid_data(); |
|
928 | + $reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options']; |
|
929 | + $reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan']; |
|
930 | + } |
|
931 | + } |
|
932 | + EE_Registry::instance()->CFG = apply_filters( |
|
933 | + 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', |
|
934 | + EE_Registry::instance()->CFG |
|
935 | + ); |
|
936 | + |
|
937 | + $cfg = EE_Registry::instance()->CFG ; |
|
938 | + |
|
939 | + $what = __('Payment Settings', 'event_espresso'); |
|
940 | + $success = $this->_update_espresso_configuration( |
|
941 | + $what, |
|
942 | + EE_Registry::instance()->CFG, |
|
943 | + __FILE__, |
|
944 | + __FUNCTION__, |
|
945 | + __LINE__ |
|
946 | + ); |
|
947 | + $this->_redirect_after_action( |
|
948 | + $success, |
|
949 | + $what, |
|
950 | + __('updated', 'event_espresso'), |
|
951 | + array('action' => 'payment_settings') |
|
952 | + ); |
|
953 | + } |
|
954 | + |
|
955 | + |
|
956 | + /** |
|
957 | + * Gets the form used for updating payment settings |
|
958 | + * |
|
959 | + * @return EE_Form_Section_Proper |
|
960 | + * @throws EE_Error |
|
961 | + * @throws InvalidArgumentException |
|
962 | + * @throws InvalidDataTypeException |
|
963 | + * @throws InvalidInterfaceException |
|
964 | + */ |
|
965 | + protected function getPaymentSettingsForm() |
|
966 | + { |
|
967 | + /** |
|
968 | + * @var $reg_config EE_Registration_Config |
|
969 | + */ |
|
970 | + $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
971 | + return new EE_Form_Section_Proper( |
|
972 | + array( |
|
973 | + 'name' => 'payment-settings', |
|
974 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
975 | + 'subsections' => array( |
|
976 | + 'show_pending_payment_options' => new EE_Yes_No_Input( |
|
977 | + array( |
|
978 | + 'html_name' => 'show_pending_payment_options', |
|
979 | + 'default' => $reg_config->show_pending_payment_options, |
|
980 | + 'html_help_text' => esc_html__( |
|
981 | + "If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ", |
|
982 | + 'event_espresso' |
|
983 | + ) |
|
984 | + ) |
|
985 | + ), |
|
986 | + 'gateway_log_lifespan' => new EE_Select_Input( |
|
987 | + $reg_config->gatewayLogLifespanOptions(), |
|
988 | + array( |
|
989 | + 'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'), |
|
990 | + 'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'), |
|
991 | + 'default' => $reg_config->gateway_log_lifespan, |
|
992 | + ) |
|
993 | + ) |
|
994 | + ) |
|
995 | + ) |
|
996 | + ); |
|
997 | + } |
|
998 | + |
|
999 | + |
|
1000 | + protected function _payment_log_overview_list_table() |
|
1001 | + { |
|
1002 | + $this->display_admin_list_table_page_with_sidebar(); |
|
1003 | + } |
|
1004 | + |
|
1005 | + |
|
1006 | + protected function _set_list_table_views_payment_log() |
|
1007 | + { |
|
1008 | + $this->_views = array( |
|
1009 | + 'all' => array( |
|
1010 | + 'slug' => 'all', |
|
1011 | + 'label' => __('View All Logs', 'event_espresso'), |
|
1012 | + 'count' => 0, |
|
1013 | + ), |
|
1014 | + ); |
|
1015 | + } |
|
1016 | + |
|
1017 | + |
|
1018 | + /** |
|
1019 | + * @param int $per_page |
|
1020 | + * @param int $current_page |
|
1021 | + * @param bool $count |
|
1022 | + * @return array |
|
1023 | + */ |
|
1024 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) |
|
1025 | + { |
|
1026 | + EE_Registry::instance()->load_model('Change_Log'); |
|
1027 | + // we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
|
1028 | + $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway)); |
|
1029 | + // check if they've selected a specific payment method |
|
1030 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
1031 | + $query_params[0]['OR*pm_or_pay_pm'] = array( |
|
1032 | + 'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1033 | + 'Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1034 | + ); |
|
1035 | + } |
|
1036 | + // take into account search |
|
1037 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
1038 | + $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%'); |
|
1039 | + $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
|
1040 | + $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
|
1041 | + $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
|
1042 | + $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string; |
|
1043 | + $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1044 | + $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string; |
|
1045 | + $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1046 | + $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string; |
|
1047 | + $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1048 | + $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string; |
|
1049 | + $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1050 | + } |
|
1051 | + if (isset($this->_req_data['payment-filter-start-date']) |
|
1052 | + && isset($this->_req_data['payment-filter-end-date']) |
|
1053 | + ) { |
|
1054 | + // add date |
|
1055 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
1056 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
1057 | + // make sure our timestamps start and end right at the boundaries for each day |
|
1058 | + $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1059 | + $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1060 | + // convert to timestamps |
|
1061 | + $start_date = strtotime($start_date); |
|
1062 | + $end_date = strtotime($end_date); |
|
1063 | + // makes sure start date is the lowest value and vice versa |
|
1064 | + $start_date = min($start_date, $end_date); |
|
1065 | + $end_date = max($start_date, $end_date); |
|
1066 | + // convert for query |
|
1067 | + $start_date = EEM_Change_Log::instance() |
|
1068 | + ->convert_datetime_for_query( |
|
1069 | + 'LOG_time', |
|
1070 | + date('Y-m-d H:i:s', $start_date), |
|
1071 | + 'Y-m-d H:i:s' |
|
1072 | + ); |
|
1073 | + $end_date = EEM_Change_Log::instance() |
|
1074 | + ->convert_datetime_for_query( |
|
1075 | + 'LOG_time', |
|
1076 | + date('Y-m-d H:i:s', $end_date), |
|
1077 | + 'Y-m-d H:i:s' |
|
1078 | + ); |
|
1079 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
1080 | + } |
|
1081 | + if ($count) { |
|
1082 | + return EEM_Change_Log::instance()->count($query_params); |
|
1083 | + } |
|
1084 | + if (isset($this->_req_data['order'])) { |
|
1085 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
1086 | + : 'DESC'; |
|
1087 | + $query_params['order_by'] = array('LOG_time' => $sort); |
|
1088 | + } else { |
|
1089 | + $query_params['order_by'] = array('LOG_time' => 'DESC'); |
|
1090 | + } |
|
1091 | + $offset = ($current_page - 1) * $per_page; |
|
1092 | + if (! isset($this->_req_data['download_results'])) { |
|
1093 | + $query_params['limit'] = array($offset, $per_page); |
|
1094 | + } |
|
1095 | + // now they've requested to instead just download the file instead of viewing it. |
|
1096 | + if (isset($this->_req_data['download_results'])) { |
|
1097 | + $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
|
1098 | + header('Content-Disposition: attachment'); |
|
1099 | + header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url())); |
|
1100 | + echo "<h1>Payment Logs for " . site_url() . "</h1>"; |
|
1101 | + echo "<h3>Query:</h3>"; |
|
1102 | + var_dump($query_params); |
|
1103 | + echo "<h3>Results:</h3>"; |
|
1104 | + var_dump($wpdb_results); |
|
1105 | + die; |
|
1106 | + } |
|
1107 | + $results = EEM_Change_Log::instance()->get_all($query_params); |
|
1108 | + return $results; |
|
1109 | + } |
|
1110 | + |
|
1111 | + |
|
1112 | + /** |
|
1113 | + * Used by usort to RE-sort log query results, because we lose the ordering |
|
1114 | + * because we're possibly combining the results from two queries |
|
1115 | + * |
|
1116 | + * @param EE_Change_Log $logA |
|
1117 | + * @param EE_Change_Log $logB |
|
1118 | + * @return int |
|
1119 | + */ |
|
1120 | + protected function _sort_logs_again($logA, $logB) |
|
1121 | + { |
|
1122 | + $timeA = $logA->get_raw('LOG_time'); |
|
1123 | + $timeB = $logB->get_raw('LOG_time'); |
|
1124 | + if ($timeA == $timeB) { |
|
1125 | + return 0; |
|
1126 | + } |
|
1127 | + $comparison = $timeA < $timeB ? -1 : 1; |
|
1128 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
1129 | + return $comparison * -1; |
|
1130 | + } else { |
|
1131 | + return $comparison; |
|
1132 | + } |
|
1133 | + } |
|
1134 | + |
|
1135 | + |
|
1136 | + protected function _payment_log_details() |
|
1137 | + { |
|
1138 | + EE_Registry::instance()->load_model('Change_Log'); |
|
1139 | + /** @var $payment_log EE_Change_Log */ |
|
1140 | + $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
|
1141 | + $payment_method = null; |
|
1142 | + $transaction = null; |
|
1143 | + if ($payment_log instanceof EE_Change_Log) { |
|
1144 | + if ($payment_log->object() instanceof EE_Payment) { |
|
1145 | + $payment_method = $payment_log->object()->payment_method(); |
|
1146 | + $transaction = $payment_log->object()->transaction(); |
|
1147 | + } elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
1148 | + $payment_method = $payment_log->object(); |
|
1149 | + } elseif ($payment_log->object() instanceof EE_Transaction) { |
|
1150 | + $transaction = $payment_log->object(); |
|
1151 | + $payment_method = $transaction->payment_method(); |
|
1152 | + } |
|
1153 | + } |
|
1154 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1155 | + EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
1156 | + array( |
|
1157 | + 'payment_log' => $payment_log, |
|
1158 | + 'payment_method' => $payment_method, |
|
1159 | + 'transaction' => $transaction, |
|
1160 | + ), |
|
1161 | + true |
|
1162 | + ); |
|
1163 | + $this->display_admin_page_with_sidebar(); |
|
1164 | + } |
|
1165 | 1165 | } |
@@ -5,81 +5,81 @@ |
||
5 | 5 | class EE_Two_Column_Layout extends EE_Form_Section_Layout_Base |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
10 | - * |
|
11 | - * @param array $additional_args |
|
12 | - * @return string |
|
13 | - */ |
|
14 | - public function layout_form_begin($additional_args = array()) |
|
15 | - { |
|
16 | - return $this->display_form_wide_errors() |
|
17 | - . EEH_HTML::table( |
|
18 | - '', |
|
19 | - $this->_form_section->html_id(), |
|
20 | - $this->_form_section->html_class(), |
|
21 | - $this->_form_section->html_style() |
|
22 | - ) . EEH_HTML::tbody(); |
|
23 | - } |
|
8 | + /** |
|
9 | + * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
10 | + * |
|
11 | + * @param array $additional_args |
|
12 | + * @return string |
|
13 | + */ |
|
14 | + public function layout_form_begin($additional_args = array()) |
|
15 | + { |
|
16 | + return $this->display_form_wide_errors() |
|
17 | + . EEH_HTML::table( |
|
18 | + '', |
|
19 | + $this->_form_section->html_id(), |
|
20 | + $this->_form_section->html_class(), |
|
21 | + $this->_form_section->html_style() |
|
22 | + ) . EEH_HTML::tbody(); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
29 | - * |
|
30 | - * @param array $additional_args |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function layout_form_end($additional_args = array()) |
|
34 | - { |
|
35 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
36 | - } |
|
27 | + /** |
|
28 | + * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
29 | + * |
|
30 | + * @param array $additional_args |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function layout_form_end($additional_args = array()) |
|
34 | + { |
|
35 | + return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * Lays out the row for the input, including label and errors |
|
42 | - * |
|
43 | - * @param EE_Form_Input_Base $input |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function layout_input($input) |
|
47 | - { |
|
48 | - $html = ''; |
|
49 | - if ($input instanceof EE_Hidden_Input) { |
|
50 | - $html .= $input->get_html_for_input(); |
|
51 | - } else { |
|
52 | - $html_for_input = $input->get_html_for_input(); |
|
53 | - $html_for_input .= $input->get_html_for_errors() != '' |
|
54 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
55 | - : ''; |
|
56 | - $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
57 | - $html .= EEH_HTML::tr( |
|
58 | - EEH_HTML::th($input->get_html_for_label()) . |
|
59 | - EEH_HTML::td($html_for_input) |
|
60 | - ); |
|
61 | - } |
|
62 | - return $html; |
|
63 | - } |
|
40 | + /** |
|
41 | + * Lays out the row for the input, including label and errors |
|
42 | + * |
|
43 | + * @param EE_Form_Input_Base $input |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function layout_input($input) |
|
47 | + { |
|
48 | + $html = ''; |
|
49 | + if ($input instanceof EE_Hidden_Input) { |
|
50 | + $html .= $input->get_html_for_input(); |
|
51 | + } else { |
|
52 | + $html_for_input = $input->get_html_for_input(); |
|
53 | + $html_for_input .= $input->get_html_for_errors() != '' |
|
54 | + ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
55 | + : ''; |
|
56 | + $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
57 | + $html .= EEH_HTML::tr( |
|
58 | + EEH_HTML::th($input->get_html_for_label()) . |
|
59 | + EEH_HTML::td($html_for_input) |
|
60 | + ); |
|
61 | + } |
|
62 | + return $html; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * Lays out a row for the subsection. Please note that if you have a subsection which you don't want wrapped in |
|
69 | - * a tr and td with a colspan=2, you should use a different layout strategy, like EE_No_Layout, EE_Template_Layout, |
|
70 | - * or EE_Div_Per_Section_Layout, and create subsections using EE_Two_Column_Layout for everywhere you want the |
|
71 | - * two-column layout, and then other sub-sections can be outside the EE_Two_Column_Layout table. |
|
72 | - * |
|
73 | - * @param EE_Form_Section_Proper $form_section |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public function layout_subsection($form_section) |
|
77 | - { |
|
78 | - if ($form_section instanceof EE_Form_Section_Proper |
|
79 | - || $form_section instanceof EE_Form_Section_HTML |
|
80 | - ) { |
|
81 | - return EEH_HTML::no_row($form_section->get_html()); |
|
82 | - } |
|
83 | - return ''; |
|
84 | - } |
|
67 | + /** |
|
68 | + * Lays out a row for the subsection. Please note that if you have a subsection which you don't want wrapped in |
|
69 | + * a tr and td with a colspan=2, you should use a different layout strategy, like EE_No_Layout, EE_Template_Layout, |
|
70 | + * or EE_Div_Per_Section_Layout, and create subsections using EE_Two_Column_Layout for everywhere you want the |
|
71 | + * two-column layout, and then other sub-sections can be outside the EE_Two_Column_Layout table. |
|
72 | + * |
|
73 | + * @param EE_Form_Section_Proper $form_section |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public function layout_subsection($form_section) |
|
77 | + { |
|
78 | + if ($form_section instanceof EE_Form_Section_Proper |
|
79 | + || $form_section instanceof EE_Form_Section_HTML |
|
80 | + ) { |
|
81 | + return EEH_HTML::no_row($form_section->get_html()); |
|
82 | + } |
|
83 | + return ''; |
|
84 | + } |
|
85 | 85 | } |
@@ -7,62 +7,62 @@ |
||
7 | 7 | class EE_Admin_Two_Column_Layout extends EE_Two_Column_Layout |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * Overriding the parent table layout to include <tbody> tags |
|
12 | - * |
|
13 | - * @param array $additional_args |
|
14 | - * @return string |
|
15 | - */ |
|
16 | - public function layout_form_begin($additional_args = array()) |
|
17 | - { |
|
18 | - $this->_form_section->set_html_class($this->_form_section->html_class() . ' form-table'); |
|
19 | - return parent::layout_form_begin($additional_args); |
|
20 | - } |
|
10 | + /** |
|
11 | + * Overriding the parent table layout to include <tbody> tags |
|
12 | + * |
|
13 | + * @param array $additional_args |
|
14 | + * @return string |
|
15 | + */ |
|
16 | + public function layout_form_begin($additional_args = array()) |
|
17 | + { |
|
18 | + $this->_form_section->set_html_class($this->_form_section->html_class() . ' form-table'); |
|
19 | + return parent::layout_form_begin($additional_args); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * Lays out the row for the input, including label and errors |
|
26 | - * |
|
27 | - * @param EE_Form_Input_Base $input |
|
28 | - * @return string |
|
29 | - * @throws EE_Error |
|
30 | - */ |
|
31 | - public function layout_input($input) |
|
32 | - { |
|
33 | - if ($input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
34 | - || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
35 | - || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
36 | - ) { |
|
37 | - $input->set_html_class($input->html_class() . ' large-text'); |
|
38 | - } |
|
39 | - if ($input instanceof EE_Text_Area_Input) { |
|
40 | - $input->set_rows(4); |
|
41 | - $input->set_cols(60); |
|
42 | - } |
|
43 | - $input_html = $input->get_html_for_input(); |
|
44 | - // maybe add errors and help text ? |
|
45 | - $input_html .= $input->get_html_for_errors() !== '' |
|
46 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
47 | - : ''; |
|
48 | - $input_html .= $input->get_html_for_help() !== '' |
|
49 | - ? EEH_HTML::nl() . $input->get_html_for_help() |
|
50 | - : ''; |
|
51 | - // overriding parent to add wp admin specific things. |
|
52 | - $html = ''; |
|
53 | - if ($input instanceof EE_Hidden_Input) { |
|
54 | - $html .= EEH_HTML::no_row($input->get_html_for_input()); |
|
55 | - } else { |
|
56 | - $html .= EEH_HTML::tr( |
|
57 | - EEH_HTML::th( |
|
58 | - $input->get_html_for_label(), |
|
59 | - '', |
|
60 | - '', |
|
61 | - '', |
|
62 | - 'scope="row"' |
|
63 | - ) . EEH_HTML::td($input_html) |
|
64 | - ); |
|
65 | - } |
|
66 | - return $html; |
|
67 | - } |
|
24 | + /** |
|
25 | + * Lays out the row for the input, including label and errors |
|
26 | + * |
|
27 | + * @param EE_Form_Input_Base $input |
|
28 | + * @return string |
|
29 | + * @throws EE_Error |
|
30 | + */ |
|
31 | + public function layout_input($input) |
|
32 | + { |
|
33 | + if ($input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
34 | + || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
35 | + || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
36 | + ) { |
|
37 | + $input->set_html_class($input->html_class() . ' large-text'); |
|
38 | + } |
|
39 | + if ($input instanceof EE_Text_Area_Input) { |
|
40 | + $input->set_rows(4); |
|
41 | + $input->set_cols(60); |
|
42 | + } |
|
43 | + $input_html = $input->get_html_for_input(); |
|
44 | + // maybe add errors and help text ? |
|
45 | + $input_html .= $input->get_html_for_errors() !== '' |
|
46 | + ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
47 | + : ''; |
|
48 | + $input_html .= $input->get_html_for_help() !== '' |
|
49 | + ? EEH_HTML::nl() . $input->get_html_for_help() |
|
50 | + : ''; |
|
51 | + // overriding parent to add wp admin specific things. |
|
52 | + $html = ''; |
|
53 | + if ($input instanceof EE_Hidden_Input) { |
|
54 | + $html .= EEH_HTML::no_row($input->get_html_for_input()); |
|
55 | + } else { |
|
56 | + $html .= EEH_HTML::tr( |
|
57 | + EEH_HTML::th( |
|
58 | + $input->get_html_for_label(), |
|
59 | + '', |
|
60 | + '', |
|
61 | + '', |
|
62 | + 'scope="row"' |
|
63 | + ) . EEH_HTML::td($input_html) |
|
64 | + ); |
|
65 | + } |
|
66 | + return $html; |
|
67 | + } |
|
68 | 68 | } |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <table> |
2 | 2 | <tr> |
3 | 3 | <th><?php _e("Mijireh Checkout Page Design", 'event_espresso'); ?><?php |
4 | - echo EEH_Template::get_help_tab_link( |
|
5 | - 'ee_mijireh_help_tab' |
|
6 | - ); ?></th> |
|
4 | + echo EEH_Template::get_help_tab_link( |
|
5 | + 'ee_mijireh_help_tab' |
|
6 | + ); ?></th> |
|
7 | 7 | <td> |
8 | 8 | <a href="?mijireh_edit_slurp_page=true"><?php _e("Edit Slurp Page", 'event_espresso'); ?></a> |
9 | 9 | </td> |
@@ -16,9 +16,9 @@ |
||
16 | 16 | <td> |
17 | 17 | <span class="description"> |
18 | 18 | <?php _e( |
19 | - "The following settings affect the content and/or appearance of the downloadable PDF invoice.", |
|
20 | - 'event_espresso' |
|
21 | - ); ?></span> |
|
19 | + "The following settings affect the content and/or appearance of the downloadable PDF invoice.", |
|
20 | + 'event_espresso' |
|
21 | + ); ?></span> |
|
22 | 22 | </td> |
23 | 23 | </tr> |
24 | 24 | </table> |
25 | 25 | \ No newline at end of file |
@@ -16,9 +16,9 @@ |
||
16 | 16 | <td> |
17 | 17 | <span class="description"> |
18 | 18 | <?php _e( |
19 | - "The following settings affect the functioning of the Invoice gateway.", |
|
20 | - 'event_espresso' |
|
21 | - ); ?></span> |
|
19 | + "The following settings affect the functioning of the Invoice gateway.", |
|
20 | + 'event_espresso' |
|
21 | + ); ?></span> |
|
22 | 22 | </td> |
23 | 23 | </tr> |
24 | 24 | </table> |
25 | 25 | \ No newline at end of file |