@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | give_ignore_user_abort(); |
42 | 42 | |
43 | 43 | nocache_headers(); |
44 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
45 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' ); |
|
46 | - header( "Expires: 0" ); |
|
44 | + header('Content-Type: text/csv; charset=utf-8'); |
|
45 | + header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv'); |
|
46 | + header("Expires: 0"); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | public function csv_cols() { |
58 | 58 | |
59 | 59 | $cols = array( |
60 | - 'date' => __( 'Date', 'give' ), |
|
61 | - 'donations' => __( 'Donations', 'give' ), |
|
60 | + 'date' => __('Date', 'give'), |
|
61 | + 'donations' => __('Donations', 'give'), |
|
62 | 62 | /* translators: %s: currency */ |
63 | - 'earnings' => sprintf( __( 'Income (%s)', 'give' ), give_currency_symbol('', true) ) |
|
63 | + 'earnings' => sprintf(__('Income (%s)', 'give'), give_currency_symbol('', true)) |
|
64 | 64 | ); |
65 | 65 | |
66 | 66 | return $cols; |
@@ -75,28 +75,28 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function get_data() { |
77 | 77 | |
78 | - $start_year = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' ); |
|
79 | - $end_year = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' ); |
|
80 | - $start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' ); |
|
81 | - $end_month = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' ); |
|
78 | + $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y'); |
|
79 | + $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y'); |
|
80 | + $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n'); |
|
81 | + $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n'); |
|
82 | 82 | |
83 | 83 | $data = array(); |
84 | 84 | $year = $start_year; |
85 | 85 | $stats = new Give_Payment_Stats; |
86 | 86 | |
87 | - while ( $year <= $end_year ) { |
|
87 | + while ($year <= $end_year) { |
|
88 | 88 | |
89 | - if ( $year == $start_year && $year == $end_year ) { |
|
89 | + if ($year == $start_year && $year == $end_year) { |
|
90 | 90 | |
91 | 91 | $m1 = $start_month; |
92 | 92 | $m2 = $end_month; |
93 | 93 | |
94 | - } elseif ( $year == $start_year ) { |
|
94 | + } elseif ($year == $start_year) { |
|
95 | 95 | |
96 | 96 | $m1 = $start_month; |
97 | 97 | $m2 = 12; |
98 | 98 | |
99 | - } elseif ( $year == $end_year ) { |
|
99 | + } elseif ($year == $end_year) { |
|
100 | 100 | |
101 | 101 | $m1 = 1; |
102 | 102 | $m2 = $end_month; |
@@ -108,28 +108,28 @@ discard block |
||
108 | 108 | |
109 | 109 | } |
110 | 110 | |
111 | - while ( $m1 <= $m2 ) { |
|
111 | + while ($m1 <= $m2) { |
|
112 | 112 | |
113 | - $date1 = mktime( 0, 0, 0, $m1, 1, $year ); |
|
114 | - $date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year ); |
|
113 | + $date1 = mktime(0, 0, 0, $m1, 1, $year); |
|
114 | + $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year); |
|
115 | 115 | |
116 | 116 | $data[] = array( |
117 | - 'date' => date_i18n( 'F Y', $date1 ), |
|
118 | - 'donations' => $stats->get_sales( 0, $date1, $date2 ), |
|
119 | - 'earnings' => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ), array( 'sanitize' => false ) ), |
|
117 | + 'date' => date_i18n('F Y', $date1), |
|
118 | + 'donations' => $stats->get_sales(0, $date1, $date2), |
|
119 | + 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2), array('sanitize' => false)), |
|
120 | 120 | ); |
121 | 121 | |
122 | - $m1 ++; |
|
122 | + $m1++; |
|
123 | 123 | |
124 | 124 | } |
125 | 125 | |
126 | 126 | |
127 | - $year ++; |
|
127 | + $year++; |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
132 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
131 | + $data = apply_filters('give_export_get_data', $data); |
|
132 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
133 | 133 | |
134 | 134 | return $data; |
135 | 135 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
39 | - add_filter( 'woocommerce_disable_admin_bar', array( $this, 'manage_admin_dashboard' ), 10, 1 ); |
|
40 | - add_filter( 'woocommerce_prevent_admin_access', array( $this, 'manage_admin_dashboard' ), 10 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | + add_filter('woocommerce_disable_admin_bar', array($this, 'manage_admin_dashboard'), 10, 1); |
|
40 | + add_filter('woocommerce_prevent_admin_access', array($this, 'manage_admin_dashboard'), 10); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return void |
52 | 52 | */ |
53 | 53 | public function add_roles() { |
54 | - add_role( 'give_manager', __( 'Give Manager', 'give' ), array( |
|
54 | + add_role('give_manager', __('Give Manager', 'give'), array( |
|
55 | 55 | 'read' => true, |
56 | 56 | 'edit_posts' => true, |
57 | 57 | 'delete_posts' => true, |
@@ -80,25 +80,25 @@ discard block |
||
80 | 80 | 'publish_posts' => true, |
81 | 81 | 'read_private_pages' => true, |
82 | 82 | 'read_private_posts' => true, |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | |
85 | - add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array( |
|
85 | + add_role('give_accountant', __('Give Accountant', 'give'), array( |
|
86 | 86 | 'read' => true, |
87 | 87 | 'edit_posts' => false, |
88 | 88 | 'delete_posts' => false, |
89 | - ) ); |
|
89 | + )); |
|
90 | 90 | |
91 | - add_role( 'give_worker', __( 'Give Worker', 'give' ), array( |
|
91 | + add_role('give_worker', __('Give Worker', 'give'), array( |
|
92 | 92 | 'read' => true, |
93 | 93 | 'edit_posts' => true, |
94 | 94 | 'edit_pages' => true, |
95 | 95 | 'upload_files' => true, |
96 | 96 | 'delete_posts' => false, |
97 | - ) ); |
|
97 | + )); |
|
98 | 98 | |
99 | - add_role( 'give_donor', __( 'Give Donor', 'give' ), array( |
|
99 | + add_role('give_donor', __('Give Donor', 'give'), array( |
|
100 | 100 | 'read' => true, |
101 | - ) ); |
|
101 | + )); |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | |
@@ -117,53 +117,53 @@ discard block |
||
117 | 117 | public function add_caps() { |
118 | 118 | global $wp_roles; |
119 | 119 | |
120 | - if ( class_exists( 'WP_Roles' ) ) { |
|
121 | - if ( ! isset( $wp_roles ) ) { |
|
120 | + if (class_exists('WP_Roles')) { |
|
121 | + if ( ! isset($wp_roles)) { |
|
122 | 122 | $wp_roles = new WP_Roles(); |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - if ( is_object( $wp_roles ) ) { |
|
127 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
128 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
129 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
130 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
126 | + if (is_object($wp_roles)) { |
|
127 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
128 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
129 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
130 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
131 | 131 | |
132 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
133 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
134 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
135 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
136 | - $wp_roles->add_cap( 'administrator', 'view_give_payments' ); |
|
132 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
133 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
134 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
135 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
136 | + $wp_roles->add_cap('administrator', 'view_give_payments'); |
|
137 | 137 | |
138 | 138 | // Add the main post type capabilities. |
139 | 139 | $capabilities = $this->get_core_caps(); |
140 | - foreach ( $capabilities as $cap_group ) { |
|
141 | - foreach ( $cap_group as $cap ) { |
|
142 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
143 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
140 | + foreach ($capabilities as $cap_group) { |
|
141 | + foreach ($cap_group as $cap) { |
|
142 | + $wp_roles->add_cap('administrator', $cap); |
|
143 | + $wp_roles->add_cap('give_manager', $cap); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Add Capabilities to Give Workers User Role. |
148 | - $wp_roles->add_cap( 'give_worker', 'edit_give_payments' ); |
|
149 | - $wp_roles->add_cap( 'give_worker', 'delete_give_forms' ); |
|
150 | - $wp_roles->add_cap( 'give_worker', 'delete_others_give_forms' ); |
|
151 | - $wp_roles->add_cap( 'give_worker', 'delete_private_give_forms' ); |
|
152 | - $wp_roles->add_cap( 'give_worker', 'delete_published_give_forms' ); |
|
153 | - $wp_roles->add_cap( 'give_worker', 'edit_give_forms' ); |
|
154 | - $wp_roles->add_cap( 'give_worker', 'edit_others_give_forms' ); |
|
155 | - $wp_roles->add_cap( 'give_worker', 'edit_private_give_forms' ); |
|
156 | - $wp_roles->add_cap( 'give_worker', 'edit_published_give_forms' ); |
|
157 | - $wp_roles->add_cap( 'give_worker', 'publish_give_forms' ); |
|
158 | - $wp_roles->add_cap( 'give_worker', 'read_private_give_forms' ); |
|
148 | + $wp_roles->add_cap('give_worker', 'edit_give_payments'); |
|
149 | + $wp_roles->add_cap('give_worker', 'delete_give_forms'); |
|
150 | + $wp_roles->add_cap('give_worker', 'delete_others_give_forms'); |
|
151 | + $wp_roles->add_cap('give_worker', 'delete_private_give_forms'); |
|
152 | + $wp_roles->add_cap('give_worker', 'delete_published_give_forms'); |
|
153 | + $wp_roles->add_cap('give_worker', 'edit_give_forms'); |
|
154 | + $wp_roles->add_cap('give_worker', 'edit_others_give_forms'); |
|
155 | + $wp_roles->add_cap('give_worker', 'edit_private_give_forms'); |
|
156 | + $wp_roles->add_cap('give_worker', 'edit_published_give_forms'); |
|
157 | + $wp_roles->add_cap('give_worker', 'publish_give_forms'); |
|
158 | + $wp_roles->add_cap('give_worker', 'read_private_give_forms'); |
|
159 | 159 | |
160 | 160 | // Add Capabilities to Give Accountant User Role. |
161 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
162 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
163 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
164 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
165 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
166 | - $wp_roles->add_cap( 'give_accountant', 'view_give_payments' ); |
|
161 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
162 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
163 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
164 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
165 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
166 | + $wp_roles->add_cap('give_accountant', 'view_give_payments'); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | } |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | public function get_core_caps() { |
182 | 182 | $capabilities = array(); |
183 | 183 | |
184 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
184 | + $capability_types = array('give_form', 'give_payment'); |
|
185 | 185 | |
186 | - foreach ( $capability_types as $capability_type ) { |
|
187 | - $capabilities[ $capability_type ] = array( |
|
186 | + foreach ($capability_types as $capability_type) { |
|
187 | + $capabilities[$capability_type] = array( |
|
188 | 188 | // Post type. |
189 | 189 | "edit_{$capability_type}", |
190 | 190 | "read_{$capability_type}", |
@@ -230,22 +230,22 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return array $caps Meta capabilities. |
232 | 232 | */ |
233 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
233 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
234 | 234 | |
235 | - switch ( $cap ) { |
|
235 | + switch ($cap) { |
|
236 | 236 | |
237 | 237 | case 'view_give_form_stats' : |
238 | 238 | |
239 | - if ( empty( $args[0] ) ) { |
|
239 | + if (empty($args[0])) { |
|
240 | 240 | break; |
241 | 241 | } |
242 | 242 | |
243 | - $form = get_post( $args[0] ); |
|
244 | - if ( empty( $form ) ) { |
|
243 | + $form = get_post($args[0]); |
|
244 | + if (empty($form)) { |
|
245 | 245 | break; |
246 | 246 | } |
247 | 247 | |
248 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
248 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
249 | 249 | $caps = array(); |
250 | 250 | } |
251 | 251 | |
@@ -272,57 +272,57 @@ discard block |
||
272 | 272 | |
273 | 273 | global $wp_roles; |
274 | 274 | |
275 | - if ( class_exists( 'WP_Roles' ) ) { |
|
276 | - if ( ! isset( $wp_roles ) ) { |
|
275 | + if (class_exists('WP_Roles')) { |
|
276 | + if ( ! isset($wp_roles)) { |
|
277 | 277 | $wp_roles = new WP_Roles(); |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - if ( is_object( $wp_roles ) ) { |
|
281 | + if (is_object($wp_roles)) { |
|
282 | 282 | // Give Manager Capabilities. |
283 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
284 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
285 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
286 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
283 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
284 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
285 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
286 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
287 | 287 | |
288 | 288 | // Site Administrator Capabilities. |
289 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
290 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
291 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
292 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
293 | - $wp_roles->remove_cap( 'administrator', 'view_give_payments' ); |
|
289 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
290 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
291 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
292 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
293 | + $wp_roles->remove_cap('administrator', 'view_give_payments'); |
|
294 | 294 | |
295 | 295 | // Remove the Main Post Type Capabilities. |
296 | 296 | $capabilities = $this->get_core_caps(); |
297 | 297 | |
298 | - foreach ( $capabilities as $cap_group ) { |
|
299 | - foreach ( $cap_group as $cap ) { |
|
300 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
301 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
298 | + foreach ($capabilities as $cap_group) { |
|
299 | + foreach ($cap_group as $cap) { |
|
300 | + $wp_roles->remove_cap('give_manager', $cap); |
|
301 | + $wp_roles->remove_cap('administrator', $cap); |
|
302 | 302 | |
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | 306 | // Remove capabilities from the Give Worker role. |
307 | - $wp_roles->remove_cap( 'give_worker', 'edit_give_payments' ); |
|
308 | - $wp_roles->remove_cap( 'give_worker', 'delete_give_forms' ); |
|
309 | - $wp_roles->remove_cap( 'give_worker', 'delete_others_give_forms' ); |
|
310 | - $wp_roles->remove_cap( 'give_worker', 'delete_private_give_forms' ); |
|
311 | - $wp_roles->remove_cap( 'give_worker', 'delete_published_give_forms' ); |
|
312 | - $wp_roles->remove_cap( 'give_worker', 'edit_give_forms' ); |
|
313 | - $wp_roles->remove_cap( 'give_worker', 'edit_others_give_forms' ); |
|
314 | - $wp_roles->remove_cap( 'give_worker', 'edit_private_give_forms' ); |
|
315 | - $wp_roles->remove_cap( 'give_worker', 'edit_published_give_forms' ); |
|
316 | - $wp_roles->remove_cap( 'give_worker', 'publish_give_forms' ); |
|
317 | - $wp_roles->remove_cap( 'give_worker', 'read_private_give_forms' ); |
|
307 | + $wp_roles->remove_cap('give_worker', 'edit_give_payments'); |
|
308 | + $wp_roles->remove_cap('give_worker', 'delete_give_forms'); |
|
309 | + $wp_roles->remove_cap('give_worker', 'delete_others_give_forms'); |
|
310 | + $wp_roles->remove_cap('give_worker', 'delete_private_give_forms'); |
|
311 | + $wp_roles->remove_cap('give_worker', 'delete_published_give_forms'); |
|
312 | + $wp_roles->remove_cap('give_worker', 'edit_give_forms'); |
|
313 | + $wp_roles->remove_cap('give_worker', 'edit_others_give_forms'); |
|
314 | + $wp_roles->remove_cap('give_worker', 'edit_private_give_forms'); |
|
315 | + $wp_roles->remove_cap('give_worker', 'edit_published_give_forms'); |
|
316 | + $wp_roles->remove_cap('give_worker', 'publish_give_forms'); |
|
317 | + $wp_roles->remove_cap('give_worker', 'read_private_give_forms'); |
|
318 | 318 | |
319 | 319 | // Remove Capabilities from Give Accountant User Role. |
320 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
321 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
322 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
323 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
324 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_payments' ); |
|
325 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_payments' ); |
|
320 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
321 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
322 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
323 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
324 | + $wp_roles->remove_cap('give_accountant', 'edit_give_payments'); |
|
325 | + $wp_roles->remove_cap('give_accountant', 'view_give_payments'); |
|
326 | 326 | |
327 | 327 | } |
328 | 328 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $current_user = wp_get_current_user(); |
346 | 346 | |
347 | 347 | // If user with "Give Accountant" user role is logged-in . |
348 | - if ( 0 !== $current_user->ID && in_array( 'give_accountant', (array) $current_user->roles, true ) ) { |
|
348 | + if (0 !== $current_user->ID && in_array('give_accountant', (array) $current_user->roles, true)) { |
|
349 | 349 | |
350 | 350 | // Return false, means no prevention. |
351 | 351 | return false; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @since 1.8 |
42 | 42 | * |
43 | - * @return bool |
|
43 | + * @return false|null |
|
44 | 44 | */ |
45 | 45 | function give_redirect_to_clean_url_admin_pages() { |
46 | 46 | // Give admin pages. |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | * @access public |
993 | 993 | * @since 2.0 |
994 | 994 | * |
995 | - * @return bool |
|
995 | + * @return false|null |
|
996 | 996 | */ |
997 | 997 | function give_update_donor_name_on_user_update( $user_id = 0 ) { |
998 | 998 | |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | * @param int $user_id User ID. |
1033 | 1033 | * @param WP_User|bool $old_user_data User data. |
1034 | 1034 | * |
1035 | - * @return bool |
|
1035 | + * @return false|null |
|
1036 | 1036 | */ |
1037 | 1037 | function give_update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) { |
1038 | 1038 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | * @since 1.8 |
21 | 21 | */ |
22 | 22 | function give_load_wp_editor() { |
23 | - if ( ! isset( $_POST['wp_editor'] ) ) { |
|
23 | + if ( ! isset($_POST['wp_editor'])) { |
|
24 | 24 | die(); |
25 | 25 | } |
26 | 26 | |
27 | - $wp_editor = json_decode( base64_decode( $_POST['wp_editor'] ), true ); |
|
27 | + $wp_editor = json_decode(base64_decode($_POST['wp_editor']), true); |
|
28 | 28 | $wp_editor[2]['textarea_name'] = $_POST['textarea_name']; |
29 | 29 | |
30 | - wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] ); |
|
30 | + wp_editor($wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2]); |
|
31 | 31 | |
32 | 32 | die(); |
33 | 33 | } |
34 | 34 | |
35 | -add_action( 'wp_ajax_give_load_wp_editor', 'give_load_wp_editor' ); |
|
35 | +add_action('wp_ajax_give_load_wp_editor', 'give_load_wp_editor'); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | ); |
53 | 53 | |
54 | 54 | // Get current page. |
55 | - $current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : ''; |
|
55 | + $current_page = isset($_GET['page']) ? esc_attr($_GET['page']) : ''; |
|
56 | 56 | |
57 | 57 | // Bailout. |
58 | 58 | if ( |
59 | - empty( $current_page ) |
|
60 | - || empty( $_GET['_wp_http_referer'] ) |
|
61 | - || ! in_array( $current_page, $give_pages ) |
|
59 | + empty($current_page) |
|
60 | + || empty($_GET['_wp_http_referer']) |
|
61 | + || ! in_array($current_page, $give_pages) |
|
62 | 62 | ) { |
63 | 63 | return false; |
64 | 64 | } |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @since 1.8 |
70 | 70 | */ |
71 | - $redirect = apply_filters( "give_validate_{$current_page}", true ); |
|
71 | + $redirect = apply_filters("give_validate_{$current_page}", true); |
|
72 | 72 | |
73 | - if ( $redirect ) { |
|
73 | + if ($redirect) { |
|
74 | 74 | // Redirect. |
75 | 75 | wp_redirect( |
76 | 76 | remove_query_arg( |
77 | - array( '_wp_http_referer', '_wpnonce' ), |
|
78 | - wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
77 | + array('_wp_http_referer', '_wpnonce'), |
|
78 | + wp_unslash($_SERVER['REQUEST_URI']) |
|
79 | 79 | ) |
80 | 80 | ); |
81 | 81 | exit; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' ); |
|
85 | +add_action('admin_init', 'give_redirect_to_clean_url_admin_pages'); |
|
86 | 86 | |
87 | 87 | |
88 | 88 | /** |
@@ -96,25 +96,25 @@ discard block |
||
96 | 96 | */ |
97 | 97 | function give_hide_outdated_php_notice() { |
98 | 98 | |
99 | - if ( ! isset( $_POST['_give_hide_outdated_php_notices_shortly'] ) ) { |
|
99 | + if ( ! isset($_POST['_give_hide_outdated_php_notices_shortly'])) { |
|
100 | 100 | give_die(); |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Transient key name. |
104 | 104 | $transient_key = '_give_hide_outdated_php_notices_shortly'; |
105 | 105 | |
106 | - if ( Give_Cache::get( $transient_key, true ) ) { |
|
106 | + if (Give_Cache::get($transient_key, true)) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Hide notice for 24 hours. |
111 | - Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
111 | + Give_Cache::set($transient_key, true, DAY_IN_SECONDS, true); |
|
112 | 112 | |
113 | 113 | give_die(); |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | -add_action( 'wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice' ); |
|
117 | +add_action('wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice'); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Register admin notices. |
@@ -123,27 +123,27 @@ discard block |
||
123 | 123 | */ |
124 | 124 | function _give_register_admin_notices() { |
125 | 125 | // Bailout. |
126 | - if ( ! is_admin() ) { |
|
126 | + if ( ! is_admin()) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | 130 | // Bulk action notices. |
131 | 131 | if ( |
132 | - isset( $_GET['action'] ) && |
|
133 | - ! empty( $_GET['action'] ) |
|
132 | + isset($_GET['action']) && |
|
133 | + ! empty($_GET['action']) |
|
134 | 134 | ) { |
135 | 135 | |
136 | 136 | // Add payment bulk notice. |
137 | 137 | if ( |
138 | - current_user_can( 'edit_give_payments' ) && |
|
139 | - isset( $_GET['payment'] ) && |
|
140 | - ! empty( $_GET['payment'] ) |
|
138 | + current_user_can('edit_give_payments') && |
|
139 | + isset($_GET['payment']) && |
|
140 | + ! empty($_GET['payment']) |
|
141 | 141 | ) { |
142 | - $payment_count = isset( $_GET['payment'] ) ? count( $_GET['payment'] ) : 0; |
|
142 | + $payment_count = isset($_GET['payment']) ? count($_GET['payment']) : 0; |
|
143 | 143 | |
144 | - switch ( $_GET['action'] ) { |
|
144 | + switch ($_GET['action']) { |
|
145 | 145 | case 'delete': |
146 | - Give()->notices->register_notice( array( |
|
146 | + Give()->notices->register_notice(array( |
|
147 | 147 | 'id' => 'bulk_action_delete', |
148 | 148 | 'type' => 'updated', |
149 | 149 | 'description' => sprintf( |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | ), |
156 | 156 | $payment_count ), |
157 | 157 | 'show' => true, |
158 | - ) ); |
|
158 | + )); |
|
159 | 159 | |
160 | 160 | break; |
161 | 161 | |
162 | 162 | case 'resend-receipt': |
163 | - Give()->notices->register_notice( array( |
|
163 | + Give()->notices->register_notice(array( |
|
164 | 164 | 'id' => 'bulk_action_resend_receipt', |
165 | 165 | 'type' => 'updated', |
166 | 166 | 'description' => sprintf( |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $payment_count |
174 | 174 | ), |
175 | 175 | 'show' => true, |
176 | - ) ); |
|
176 | + )); |
|
177 | 177 | break; |
178 | 178 | |
179 | 179 | case 'set-status-publish' : |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | case 'set-status-cancelled' : |
186 | 186 | case 'set-status-abandoned' : |
187 | 187 | case 'set-status-preapproval' : |
188 | - Give()->notices->register_notice( array( |
|
188 | + Give()->notices->register_notice(array( |
|
189 | 189 | 'id' => 'bulk_action_status_change', |
190 | 190 | 'type' => 'updated', |
191 | 191 | 'description' => _n( |
@@ -195,251 +195,251 @@ discard block |
||
195 | 195 | 'give' |
196 | 196 | ), |
197 | 197 | 'show' => true, |
198 | - ) ); |
|
198 | + )); |
|
199 | 199 | break; |
200 | 200 | }// End switch(). |
201 | 201 | }// End if(). |
202 | 202 | }// End if(). |
203 | 203 | |
204 | 204 | // Add give message notices. |
205 | - if ( ! empty( $_GET['give-message'] ) ) { |
|
205 | + if ( ! empty($_GET['give-message'])) { |
|
206 | 206 | // Donation reports errors. |
207 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
208 | - switch ( $_GET['give-message'] ) { |
|
207 | + if (current_user_can('view_give_reports')) { |
|
208 | + switch ($_GET['give-message']) { |
|
209 | 209 | case 'donation_deleted' : |
210 | - Give()->notices->register_notice( array( |
|
210 | + Give()->notices->register_notice(array( |
|
211 | 211 | 'id' => 'give-donation-deleted', |
212 | 212 | 'type' => 'updated', |
213 | - 'description' => __( 'The donation has been deleted.', 'give' ), |
|
213 | + 'description' => __('The donation has been deleted.', 'give'), |
|
214 | 214 | 'show' => true, |
215 | - ) ); |
|
215 | + )); |
|
216 | 216 | break; |
217 | 217 | case 'email_sent' : |
218 | - Give()->notices->register_notice( array( |
|
218 | + Give()->notices->register_notice(array( |
|
219 | 219 | 'id' => 'give-payment-sent', |
220 | 220 | 'type' => 'updated', |
221 | - 'description' => __( 'The donation receipt has been resent.', 'give' ), |
|
221 | + 'description' => __('The donation receipt has been resent.', 'give'), |
|
222 | 222 | 'show' => true, |
223 | - ) ); |
|
223 | + )); |
|
224 | 224 | break; |
225 | 225 | case 'refreshed-reports' : |
226 | - Give()->notices->register_notice( array( |
|
226 | + Give()->notices->register_notice(array( |
|
227 | 227 | 'id' => 'give-refreshed-reports', |
228 | 228 | 'type' => 'updated', |
229 | - 'description' => __( 'The reports cache has been cleared.', 'give' ), |
|
229 | + 'description' => __('The reports cache has been cleared.', 'give'), |
|
230 | 230 | 'show' => true, |
231 | - ) ); |
|
231 | + )); |
|
232 | 232 | break; |
233 | 233 | case 'donation-note-deleted' : |
234 | - Give()->notices->register_notice( array( |
|
234 | + Give()->notices->register_notice(array( |
|
235 | 235 | 'id' => 'give-donation-note-deleted', |
236 | 236 | 'type' => 'updated', |
237 | - 'description' => __( 'The donation note has been deleted.', 'give' ), |
|
237 | + 'description' => __('The donation note has been deleted.', 'give'), |
|
238 | 238 | 'show' => true, |
239 | - ) ); |
|
239 | + )); |
|
240 | 240 | break; |
241 | 241 | } |
242 | 242 | }// End if(). |
243 | 243 | |
244 | 244 | // Give settings notices and errors. |
245 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
246 | - switch ( $_GET['give-message'] ) { |
|
245 | + if (current_user_can('manage_give_settings')) { |
|
246 | + switch ($_GET['give-message']) { |
|
247 | 247 | case 'settings-imported' : |
248 | - Give()->notices->register_notice( array( |
|
248 | + Give()->notices->register_notice(array( |
|
249 | 249 | 'id' => 'give-settings-imported', |
250 | 250 | 'type' => 'updated', |
251 | - 'description' => __( 'The settings have been imported.', 'give' ), |
|
251 | + 'description' => __('The settings have been imported.', 'give'), |
|
252 | 252 | 'show' => true, |
253 | - ) ); |
|
253 | + )); |
|
254 | 254 | break; |
255 | 255 | case 'api-key-generated' : |
256 | - Give()->notices->register_notice( array( |
|
256 | + Give()->notices->register_notice(array( |
|
257 | 257 | 'id' => 'give-api-key-generated', |
258 | 258 | 'type' => 'updated', |
259 | - 'description' => __( 'API keys have been generated.', 'give' ), |
|
259 | + 'description' => __('API keys have been generated.', 'give'), |
|
260 | 260 | 'show' => true, |
261 | - ) ); |
|
261 | + )); |
|
262 | 262 | break; |
263 | 263 | case 'api-key-exists' : |
264 | - Give()->notices->register_notice( array( |
|
264 | + Give()->notices->register_notice(array( |
|
265 | 265 | 'id' => 'give-api-key-exists', |
266 | 266 | 'type' => 'updated', |
267 | - 'description' => __( 'The specified user already has API keys.', 'give' ), |
|
267 | + 'description' => __('The specified user already has API keys.', 'give'), |
|
268 | 268 | 'show' => true, |
269 | - ) ); |
|
269 | + )); |
|
270 | 270 | break; |
271 | 271 | case 'api-key-regenerated' : |
272 | - Give()->notices->register_notice( array( |
|
272 | + Give()->notices->register_notice(array( |
|
273 | 273 | 'id' => 'give-api-key-regenerated', |
274 | 274 | 'type' => 'updated', |
275 | - 'description' => __( 'API keys have been regenerated.', 'give' ), |
|
275 | + 'description' => __('API keys have been regenerated.', 'give'), |
|
276 | 276 | 'show' => true, |
277 | - ) ); |
|
277 | + )); |
|
278 | 278 | break; |
279 | 279 | case 'api-key-revoked' : |
280 | - Give()->notices->register_notice( array( |
|
280 | + Give()->notices->register_notice(array( |
|
281 | 281 | 'id' => 'give-api-key-revoked', |
282 | 282 | 'type' => 'updated', |
283 | - 'description' => __( 'API keys have been revoked.', 'give' ), |
|
283 | + 'description' => __('API keys have been revoked.', 'give'), |
|
284 | 284 | 'show' => true, |
285 | - ) ); |
|
285 | + )); |
|
286 | 286 | break; |
287 | 287 | case 'sent-test-email' : |
288 | - Give()->notices->register_notice( array( |
|
288 | + Give()->notices->register_notice(array( |
|
289 | 289 | 'id' => 'give-sent-test-email', |
290 | 290 | 'type' => 'updated', |
291 | - 'description' => __( 'The test email has been sent.', 'give' ), |
|
291 | + 'description' => __('The test email has been sent.', 'give'), |
|
292 | 292 | 'show' => true, |
293 | - ) ); |
|
293 | + )); |
|
294 | 294 | break; |
295 | 295 | case 'matched-success-failure-page': |
296 | - Give()->notices->register_notice( array( |
|
296 | + Give()->notices->register_notice(array( |
|
297 | 297 | 'id' => 'give-matched-success-failure-page', |
298 | 298 | 'type' => 'updated', |
299 | - 'description' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
299 | + 'description' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
300 | 300 | 'show' => true, |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | break; |
303 | 303 | }// End switch(). |
304 | 304 | }// End if(). |
305 | 305 | // Payments errors. |
306 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
307 | - switch ( $_GET['give-message'] ) { |
|
306 | + if (current_user_can('edit_give_payments')) { |
|
307 | + switch ($_GET['give-message']) { |
|
308 | 308 | case 'note-added' : |
309 | - Give()->notices->register_notice( array( |
|
309 | + Give()->notices->register_notice(array( |
|
310 | 310 | 'id' => 'give-note-added', |
311 | 311 | 'type' => 'updated', |
312 | - 'description' => __( 'The donation note has been added.', 'give' ), |
|
312 | + 'description' => __('The donation note has been added.', 'give'), |
|
313 | 313 | 'show' => true, |
314 | - ) ); |
|
314 | + )); |
|
315 | 315 | break; |
316 | 316 | case 'payment-updated' : |
317 | - Give()->notices->register_notice( array( |
|
317 | + Give()->notices->register_notice(array( |
|
318 | 318 | 'id' => 'give-payment-updated', |
319 | 319 | 'type' => 'updated', |
320 | - 'description' => __( 'The donation has been updated.', 'give' ), |
|
320 | + 'description' => __('The donation has been updated.', 'give'), |
|
321 | 321 | 'show' => true, |
322 | - ) ); |
|
322 | + )); |
|
323 | 323 | break; |
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | 327 | // Donor Notices. |
328 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
329 | - switch ( $_GET['give-message'] ) { |
|
328 | + if (current_user_can('edit_give_payments')) { |
|
329 | + switch ($_GET['give-message']) { |
|
330 | 330 | case 'donor-deleted' : |
331 | - Give()->notices->register_notice( array( |
|
331 | + Give()->notices->register_notice(array( |
|
332 | 332 | 'id' => 'give-donor-deleted', |
333 | 333 | 'type' => 'updated', |
334 | - 'description' => __( 'The selected donor(s) has been deleted.', 'give' ), |
|
334 | + 'description' => __('The selected donor(s) has been deleted.', 'give'), |
|
335 | 335 | 'show' => true, |
336 | - ) ); |
|
336 | + )); |
|
337 | 337 | break; |
338 | 338 | |
339 | 339 | case 'donor-donations-deleted' : |
340 | - Give()->notices->register_notice( array( |
|
340 | + Give()->notices->register_notice(array( |
|
341 | 341 | 'id' => 'give-donor-donations-deleted', |
342 | 342 | 'type' => 'updated', |
343 | - 'description' => __( 'The selected donor(s) and the associated donation(s) has been deleted.', 'give' ), |
|
343 | + 'description' => __('The selected donor(s) and the associated donation(s) has been deleted.', 'give'), |
|
344 | 344 | 'show' => true, |
345 | - ) ); |
|
345 | + )); |
|
346 | 346 | break; |
347 | 347 | |
348 | 348 | case 'confirm-delete-donor' : |
349 | - Give()->notices->register_notice( array( |
|
349 | + Give()->notices->register_notice(array( |
|
350 | 350 | 'id' => 'give-confirm-delete-donor', |
351 | 351 | 'type' => 'updated', |
352 | - 'description' => __( 'You must confirm to delete the selected donor(s).', 'give' ), |
|
352 | + 'description' => __('You must confirm to delete the selected donor(s).', 'give'), |
|
353 | 353 | 'show' => true, |
354 | - ) ); |
|
354 | + )); |
|
355 | 355 | break; |
356 | 356 | |
357 | 357 | case 'invalid-donor-id' : |
358 | - Give()->notices->register_notice( array( |
|
358 | + Give()->notices->register_notice(array( |
|
359 | 359 | 'id' => 'give-invalid-donor-id', |
360 | 360 | 'type' => 'updated', |
361 | - 'description' => __( 'Invalid Donor ID.', 'give' ), |
|
361 | + 'description' => __('Invalid Donor ID.', 'give'), |
|
362 | 362 | 'show' => true, |
363 | - ) ); |
|
363 | + )); |
|
364 | 364 | break; |
365 | 365 | |
366 | 366 | case 'donor-delete-failed' : |
367 | - Give()->notices->register_notice( array( |
|
367 | + Give()->notices->register_notice(array( |
|
368 | 368 | 'id' => 'give-donor-delete-failed', |
369 | 369 | 'type' => 'error', |
370 | - 'description' => __( 'Unable to delete selected donor(s).', 'give' ), |
|
370 | + 'description' => __('Unable to delete selected donor(s).', 'give'), |
|
371 | 371 | 'show' => true, |
372 | - ) ); |
|
372 | + )); |
|
373 | 373 | break; |
374 | 374 | |
375 | 375 | case 'email-added' : |
376 | - Give()->notices->register_notice( array( |
|
376 | + Give()->notices->register_notice(array( |
|
377 | 377 | 'id' => 'give-donor-email-added', |
378 | 378 | 'type' => 'updated', |
379 | - 'description' => __( 'Donor email added.', 'give' ), |
|
379 | + 'description' => __('Donor email added.', 'give'), |
|
380 | 380 | 'show' => true, |
381 | - ) ); |
|
381 | + )); |
|
382 | 382 | break; |
383 | 383 | |
384 | 384 | case 'email-removed' : |
385 | - Give()->notices->register_notice( array( |
|
385 | + Give()->notices->register_notice(array( |
|
386 | 386 | 'id' => 'give-donor-email-removed', |
387 | 387 | 'type' => 'updated', |
388 | - 'description' => __( 'Donor email removed.', 'give' ), |
|
388 | + 'description' => __('Donor email removed.', 'give'), |
|
389 | 389 | 'show' => true, |
390 | - ) ); |
|
390 | + )); |
|
391 | 391 | break; |
392 | 392 | |
393 | 393 | case 'email-remove-failed' : |
394 | - Give()->notices->register_notice( array( |
|
394 | + Give()->notices->register_notice(array( |
|
395 | 395 | 'id' => 'give-donor-email-remove-failed', |
396 | 396 | 'type' => 'updated', |
397 | - 'description' => __( 'Failed to remove donor email.', 'give' ), |
|
397 | + 'description' => __('Failed to remove donor email.', 'give'), |
|
398 | 398 | 'show' => true, |
399 | - ) ); |
|
399 | + )); |
|
400 | 400 | break; |
401 | 401 | |
402 | 402 | case 'primary-email-updated' : |
403 | - Give()->notices->register_notice( array( |
|
403 | + Give()->notices->register_notice(array( |
|
404 | 404 | 'id' => 'give-donor-primary-email-updated', |
405 | 405 | 'type' => 'updated', |
406 | - 'description' => __( 'Primary email updated for donor.', 'give' ), |
|
406 | + 'description' => __('Primary email updated for donor.', 'give'), |
|
407 | 407 | 'show' => true, |
408 | - ) ); |
|
408 | + )); |
|
409 | 409 | break; |
410 | 410 | |
411 | 411 | case 'primary-email-failed' : |
412 | - Give()->notices->register_notice( array( |
|
412 | + Give()->notices->register_notice(array( |
|
413 | 413 | 'id' => 'give-donor-primary-email-failed', |
414 | 414 | 'type' => 'updated', |
415 | - 'description' => __( 'Failed to set primary email.', 'give' ), |
|
415 | + 'description' => __('Failed to set primary email.', 'give'), |
|
416 | 416 | 'show' => true, |
417 | - ) ); |
|
417 | + )); |
|
418 | 418 | break; |
419 | 419 | |
420 | 420 | case 'reconnect-user' : |
421 | - Give()->notices->register_notice( array( |
|
421 | + Give()->notices->register_notice(array( |
|
422 | 422 | 'id' => 'give-donor-reconnect-user', |
423 | 423 | 'type' => 'updated', |
424 | - 'description' => __( 'User has been successfully connected with Donor.', 'give' ), |
|
424 | + 'description' => __('User has been successfully connected with Donor.', 'give'), |
|
425 | 425 | 'show' => true, |
426 | - ) ); |
|
426 | + )); |
|
427 | 427 | break; |
428 | 428 | |
429 | 429 | case 'profile-updated' : |
430 | - Give()->notices->register_notice( array( |
|
430 | + Give()->notices->register_notice(array( |
|
431 | 431 | 'id' => 'give-donor-profile-updated', |
432 | 432 | 'type' => 'updated', |
433 | - 'description' => __( 'Donor information updated successfully.', 'give' ), |
|
433 | + 'description' => __('Donor information updated successfully.', 'give'), |
|
434 | 434 | 'show' => true, |
435 | - ) ); |
|
435 | + )); |
|
436 | 436 | break; |
437 | 437 | }// End switch(). |
438 | 438 | }// End if(). |
439 | 439 | }// End if(). |
440 | 440 | } |
441 | 441 | |
442 | -add_action( 'admin_notices', '_give_register_admin_notices', - 1 ); |
|
442 | +add_action('admin_notices', '_give_register_admin_notices', - 1); |
|
443 | 443 | |
444 | 444 | |
445 | 445 | /** |
@@ -449,39 +449,38 @@ discard block |
||
449 | 449 | * |
450 | 450 | * @return bool |
451 | 451 | */ |
452 | -function _give_show_test_mode_notice_in_admin_bar( $wp_admin_bar ) { |
|
453 | - $is_test_mode = ! empty( $_POST['test_mode'] ) ? |
|
454 | - give_is_setting_enabled( $_POST['test_mode'] ) : |
|
455 | - give_is_test_mode(); |
|
452 | +function _give_show_test_mode_notice_in_admin_bar($wp_admin_bar) { |
|
453 | + $is_test_mode = ! empty($_POST['test_mode']) ? |
|
454 | + give_is_setting_enabled($_POST['test_mode']) : give_is_test_mode(); |
|
456 | 455 | |
457 | 456 | if ( |
458 | - ! current_user_can( 'view_give_reports' ) || |
|
457 | + ! current_user_can('view_give_reports') || |
|
459 | 458 | ! $is_test_mode |
460 | 459 | ) { |
461 | 460 | return false; |
462 | 461 | } |
463 | 462 | |
464 | 463 | // Add the main site admin menu item. |
465 | - $wp_admin_bar->add_menu( array( |
|
464 | + $wp_admin_bar->add_menu(array( |
|
466 | 465 | 'id' => 'give-test-notice', |
467 | - 'href' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ), |
|
466 | + 'href' => admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways'), |
|
468 | 467 | 'parent' => 'top-secondary', |
469 | - 'title' => __( 'Give Test Mode Active', 'give' ), |
|
468 | + 'title' => __('Give Test Mode Active', 'give'), |
|
470 | 469 | 'meta' => array( |
471 | 470 | 'class' => 'give-test-mode-active', |
472 | 471 | ), |
473 | - ) ); |
|
472 | + )); |
|
474 | 473 | |
475 | 474 | return true; |
476 | 475 | } |
477 | 476 | |
478 | -add_action( 'admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1 ); |
|
477 | +add_action('admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1); |
|
479 | 478 | |
480 | 479 | /** |
481 | 480 | * Outputs the Give admin bar CSS. |
482 | 481 | */ |
483 | 482 | function _give_test_mode_notice_admin_bar_css() { |
484 | - if ( ! give_is_test_mode() ) { |
|
483 | + if ( ! give_is_test_mode()) { |
|
485 | 484 | return; |
486 | 485 | } |
487 | 486 | ?> |
@@ -499,7 +498,7 @@ discard block |
||
499 | 498 | <?php |
500 | 499 | } |
501 | 500 | |
502 | -add_action( 'admin_head', '_give_test_mode_notice_admin_bar_css' ); |
|
501 | +add_action('admin_head', '_give_test_mode_notice_admin_bar_css'); |
|
503 | 502 | |
504 | 503 | |
505 | 504 | /** |
@@ -509,12 +508,12 @@ discard block |
||
509 | 508 | */ |
510 | 509 | function give_import_page_link_callback() { |
511 | 510 | ?> |
512 | - <a href="<?php echo esc_url( give_import_page_url() ); ?>" |
|
513 | - class="page-import-action page-title-action"><?php _e( 'Import Donations', 'give' ); ?></a> |
|
511 | + <a href="<?php echo esc_url(give_import_page_url()); ?>" |
|
512 | + class="page-import-action page-title-action"><?php _e('Import Donations', 'give'); ?></a> |
|
514 | 513 | |
515 | 514 | <?php |
516 | 515 | // Check if view donation single page only. |
517 | - if ( ! empty( $_REQUEST['view'] ) && 'view-payment-details' === (string) give_clean( $_REQUEST['view'] ) && 'give-payment-history' === give_clean( $_REQUEST['page'] ) ) { |
|
516 | + if ( ! empty($_REQUEST['view']) && 'view-payment-details' === (string) give_clean($_REQUEST['view']) && 'give-payment-history' === give_clean($_REQUEST['page'])) { |
|
518 | 517 | ?> |
519 | 518 | <style type="text/css"> |
520 | 519 | .wrap #transaction-details-heading { |
@@ -525,7 +524,7 @@ discard block |
||
525 | 524 | } |
526 | 525 | } |
527 | 526 | |
528 | -add_action( 'give_payments_page_top', 'give_import_page_link_callback', 11 ); |
|
527 | +add_action('give_payments_page_top', 'give_import_page_link_callback', 11); |
|
529 | 528 | |
530 | 529 | /** |
531 | 530 | * Load donation import ajax callback |
@@ -541,9 +540,9 @@ discard block |
||
541 | 540 | Give_Cache::get_instance()->disable(); |
542 | 541 | |
543 | 542 | $import_setting = array(); |
544 | - $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null; |
|
543 | + $fields = isset($_POST['fields']) ? $_POST['fields'] : null; |
|
545 | 544 | |
546 | - parse_str( $fields ); |
|
545 | + parse_str($fields); |
|
547 | 546 | |
548 | 547 | $import_setting['create_user'] = $create_user; |
549 | 548 | $import_setting['mode'] = $mode; |
@@ -553,67 +552,67 @@ discard block |
||
553 | 552 | $import_setting['dry_run'] = $dry_run; |
554 | 553 | |
555 | 554 | // Parent key id. |
556 | - $main_key = maybe_unserialize( $main_key ); |
|
557 | - |
|
558 | - $current = absint( $_REQUEST['current'] ); |
|
559 | - $total_ajax = absint( $_REQUEST['total_ajax'] ); |
|
560 | - $start = absint( $_REQUEST['start'] ); |
|
561 | - $end = absint( $_REQUEST['end'] ); |
|
562 | - $next = absint( $_REQUEST['next'] ); |
|
563 | - $total = absint( $_REQUEST['total'] ); |
|
564 | - $per_page = absint( $_REQUEST['per_page'] ); |
|
565 | - if ( empty( $delimiter ) ) { |
|
555 | + $main_key = maybe_unserialize($main_key); |
|
556 | + |
|
557 | + $current = absint($_REQUEST['current']); |
|
558 | + $total_ajax = absint($_REQUEST['total_ajax']); |
|
559 | + $start = absint($_REQUEST['start']); |
|
560 | + $end = absint($_REQUEST['end']); |
|
561 | + $next = absint($_REQUEST['next']); |
|
562 | + $total = absint($_REQUEST['total']); |
|
563 | + $per_page = absint($_REQUEST['per_page']); |
|
564 | + if (empty($delimiter)) { |
|
566 | 565 | $delimiter = ','; |
567 | 566 | } |
568 | 567 | |
569 | 568 | // Processing done here. |
570 | - $raw_data = give_get_donation_data_from_csv( $csv, $start, $end, $delimiter ); |
|
571 | - $raw_key = maybe_unserialize( $mapto ); |
|
569 | + $raw_data = give_get_donation_data_from_csv($csv, $start, $end, $delimiter); |
|
570 | + $raw_key = maybe_unserialize($mapto); |
|
572 | 571 | $import_setting['raw_key'] = $raw_key; |
573 | 572 | |
574 | - if ( ! empty( $dry_run ) ) { |
|
575 | - $import_setting['csv_raw_data'] = give_get_donation_data_from_csv( $csv, 1, $end, $delimiter ); |
|
573 | + if ( ! empty($dry_run)) { |
|
574 | + $import_setting['csv_raw_data'] = give_get_donation_data_from_csv($csv, 1, $end, $delimiter); |
|
576 | 575 | |
577 | - $import_setting['donors_list'] = Give()->donors->get_donors( array( |
|
578 | - 'number' => - 1, |
|
579 | - 'fields' => array( 'id', 'user_id', 'email' ), |
|
580 | - ) ); |
|
576 | + $import_setting['donors_list'] = Give()->donors->get_donors(array( |
|
577 | + 'number' => -1, |
|
578 | + 'fields' => array('id', 'user_id', 'email'), |
|
579 | + )); |
|
581 | 580 | } |
582 | 581 | |
583 | 582 | // Prevent normal emails. |
584 | - remove_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 ); |
|
585 | - remove_action( 'give_insert_user', 'give_new_user_notification', 10 ); |
|
586 | - remove_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
583 | + remove_action('give_complete_donation', 'give_trigger_donation_receipt', 999); |
|
584 | + remove_action('give_insert_user', 'give_new_user_notification', 10); |
|
585 | + remove_action('give_insert_payment', 'give_payment_save_page_data'); |
|
587 | 586 | |
588 | 587 | $current_key = $start; |
589 | - foreach ( $raw_data as $row_data ) { |
|
588 | + foreach ($raw_data as $row_data) { |
|
590 | 589 | $import_setting['donation_key'] = $current_key; |
591 | - give_save_import_donation_to_db( $raw_key, $row_data, $main_key, $import_setting ); |
|
592 | - $current_key ++; |
|
590 | + give_save_import_donation_to_db($raw_key, $row_data, $main_key, $import_setting); |
|
591 | + $current_key++; |
|
593 | 592 | } |
594 | 593 | |
595 | 594 | // Check if function exists or not. |
596 | - if ( function_exists( 'give_payment_save_page_data' ) ) { |
|
597 | - add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
595 | + if (function_exists('give_payment_save_page_data')) { |
|
596 | + add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
598 | 597 | } |
599 | - add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
600 | - add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 ); |
|
598 | + add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
599 | + add_action('give_complete_donation', 'give_trigger_donation_receipt', 999); |
|
601 | 600 | |
602 | - if ( $next == false ) { |
|
601 | + if ($next == false) { |
|
603 | 602 | $json_data = array( |
604 | 603 | 'success' => true, |
605 | - 'message' => __( 'All donation uploaded successfully!', 'give' ), |
|
604 | + 'message' => __('All donation uploaded successfully!', 'give'), |
|
606 | 605 | ); |
607 | 606 | } else { |
608 | 607 | $index_start = $start; |
609 | 608 | $index_end = $end; |
610 | 609 | $last = false; |
611 | 610 | $next = true; |
612 | - if ( $next ) { |
|
611 | + if ($next) { |
|
613 | 612 | $index_start = $index_start + $per_page; |
614 | - $index_end = $per_page + ( $index_start - 1 ); |
|
613 | + $index_end = $per_page + ($index_start - 1); |
|
615 | 614 | } |
616 | - if ( $index_end >= $total ) { |
|
615 | + if ($index_end >= $total) { |
|
617 | 616 | $index_end = $total; |
618 | 617 | $last = true; |
619 | 618 | } |
@@ -627,31 +626,31 @@ discard block |
||
627 | 626 | ); |
628 | 627 | } |
629 | 628 | |
630 | - $url = give_import_page_url( array( |
|
629 | + $url = give_import_page_url(array( |
|
631 | 630 | 'step' => '4', |
632 | 631 | 'importer-type' => 'import_donations', |
633 | 632 | 'csv' => $csv, |
634 | 633 | 'total' => $total, |
635 | 634 | 'delete_csv' => $import_setting['delete_csv'], |
636 | - 'success' => ( isset( $json_data['success'] ) ? $json_data['success'] : '' ), |
|
635 | + 'success' => (isset($json_data['success']) ? $json_data['success'] : ''), |
|
637 | 636 | 'dry_run' => $dry_run, |
638 | - ) ); |
|
637 | + )); |
|
639 | 638 | $json_data['url'] = $url; |
640 | 639 | |
641 | - $current ++; |
|
640 | + $current++; |
|
642 | 641 | $json_data['current'] = $current; |
643 | 642 | |
644 | - $percentage = ( 100 / ( $total_ajax + 1 ) ) * $current; |
|
643 | + $percentage = (100 / ($total_ajax + 1)) * $current; |
|
645 | 644 | $json_data['percentage'] = $percentage; |
646 | 645 | |
647 | 646 | // Enable Give cache |
648 | 647 | Give_Cache::get_instance()->enable(); |
649 | 648 | |
650 | - $json_data = apply_filters( 'give_import_ajax_responces', $json_data, $fields ); |
|
651 | - wp_die( json_encode( $json_data ) ); |
|
649 | + $json_data = apply_filters('give_import_ajax_responces', $json_data, $fields); |
|
650 | + wp_die(json_encode($json_data)); |
|
652 | 651 | } |
653 | 652 | |
654 | -add_action( 'wp_ajax_give_donation_import', 'give_donation_import_callback' ); |
|
653 | +add_action('wp_ajax_give_donation_import', 'give_donation_import_callback'); |
|
655 | 654 | |
656 | 655 | /** |
657 | 656 | * Load core settings import ajax callback |
@@ -663,8 +662,8 @@ discard block |
||
663 | 662 | */ |
664 | 663 | |
665 | 664 | function give_core_settings_import_callback() { |
666 | - $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null; |
|
667 | - parse_str( $fields, $fields ); |
|
665 | + $fields = isset($_POST['fields']) ? $_POST['fields'] : null; |
|
666 | + parse_str($fields, $fields); |
|
668 | 667 | |
669 | 668 | $json_data['success'] = false; |
670 | 669 | |
@@ -679,22 +678,22 @@ discard block |
||
679 | 678 | * |
680 | 679 | * @return array $fields |
681 | 680 | */ |
682 | - $fields = (array) apply_filters( 'give_import_core_settings_fields', $fields ); |
|
681 | + $fields = (array) apply_filters('give_import_core_settings_fields', $fields); |
|
683 | 682 | |
684 | - $file_name = ( ! empty( $fields['file_name'] ) ? give_clean( $fields['file_name'] ) : false ); |
|
683 | + $file_name = ( ! empty($fields['file_name']) ? give_clean($fields['file_name']) : false); |
|
685 | 684 | |
686 | - if ( ! empty( $file_name ) ) { |
|
687 | - $type = ( ! empty( $fields['type'] ) ? give_clean( $fields['type'] ) : 'merge' ); |
|
685 | + if ( ! empty($file_name)) { |
|
686 | + $type = ( ! empty($fields['type']) ? give_clean($fields['type']) : 'merge'); |
|
688 | 687 | |
689 | 688 | // Get the json data from the file and then alter it in array format |
690 | - $json_string = give_get_core_settings_json( $file_name ); |
|
691 | - $json_to_array = json_decode( $json_string, true ); |
|
689 | + $json_string = give_get_core_settings_json($file_name); |
|
690 | + $json_to_array = json_decode($json_string, true); |
|
692 | 691 | |
693 | 692 | // get the current settign from the options table. |
694 | - $host_give_options = get_option( 'give_settings', array() ); |
|
693 | + $host_give_options = get_option('give_settings', array()); |
|
695 | 694 | |
696 | 695 | // Save old settins for backup. |
697 | - update_option( 'give_settings_old', $host_give_options ); |
|
696 | + update_option('give_settings_old', $host_give_options); |
|
698 | 697 | |
699 | 698 | /** |
700 | 699 | * Filter to Modify Core Settings that are being going to get import in options table as give settings. |
@@ -710,9 +709,9 @@ discard block |
||
710 | 709 | * |
711 | 710 | * @return array $json_to_array Setting that are being going to get imported |
712 | 711 | */ |
713 | - $json_to_array = (array) apply_filters( 'give_import_core_settings_data', $json_to_array, $type, $host_give_options, $fields ); |
|
712 | + $json_to_array = (array) apply_filters('give_import_core_settings_data', $json_to_array, $type, $host_give_options, $fields); |
|
714 | 713 | |
715 | - update_option( 'give_settings', $json_to_array ); |
|
714 | + update_option('give_settings', $json_to_array); |
|
716 | 715 | |
717 | 716 | $json_data['success'] = true; |
718 | 717 | } |
@@ -728,16 +727,16 @@ discard block |
||
728 | 727 | * |
729 | 728 | * @return array $url |
730 | 729 | */ |
731 | - $json_data['url'] = give_import_page_url( (array) apply_filters( 'give_import_core_settings_success_url', array( |
|
732 | - 'step' => ( empty( $json_data['success'] ) ? '1' : '3' ), |
|
730 | + $json_data['url'] = give_import_page_url((array) apply_filters('give_import_core_settings_success_url', array( |
|
731 | + 'step' => (empty($json_data['success']) ? '1' : '3'), |
|
733 | 732 | 'importer-type' => 'import_core_setting', |
734 | - 'success' => ( empty( $json_data['success'] ) ? '0' : '1' ), |
|
735 | - ) ) ); |
|
733 | + 'success' => (empty($json_data['success']) ? '0' : '1'), |
|
734 | + ))); |
|
736 | 735 | |
737 | - wp_send_json( $json_data ); |
|
736 | + wp_send_json($json_data); |
|
738 | 737 | } |
739 | 738 | |
740 | -add_action( 'wp_ajax_give_core_settings_import', 'give_core_settings_import_callback' ); |
|
739 | +add_action('wp_ajax_give_core_settings_import', 'give_core_settings_import_callback'); |
|
741 | 740 | |
742 | 741 | /** |
743 | 742 | * Initializes blank slate content if a list table is empty. |
@@ -749,7 +748,7 @@ discard block |
||
749 | 748 | $blank_slate->init(); |
750 | 749 | } |
751 | 750 | |
752 | -add_action( 'current_screen', 'give_blank_slate' ); |
|
751 | +add_action('current_screen', 'give_blank_slate'); |
|
753 | 752 | |
754 | 753 | /** |
755 | 754 | * Validate Fields of User Profile |
@@ -762,24 +761,24 @@ discard block |
||
762 | 761 | * |
763 | 762 | * @return mixed |
764 | 763 | */ |
765 | -function give_validate_user_profile( $errors, $update, $user ) { |
|
764 | +function give_validate_user_profile($errors, $update, $user) { |
|
766 | 765 | |
767 | - if ( ! empty( $_POST['action'] ) && ( 'adduser' === $_POST['action'] || 'createuser' === $_POST['action'] ) ) { |
|
766 | + if ( ! empty($_POST['action']) && ('adduser' === $_POST['action'] || 'createuser' === $_POST['action'])) { |
|
768 | 767 | return; |
769 | 768 | } |
770 | 769 | |
771 | - if ( ! empty( $user->ID ) ) { |
|
772 | - $donor = Give()->donors->get_donor_by( 'user_id', $user->ID ); |
|
770 | + if ( ! empty($user->ID)) { |
|
771 | + $donor = Give()->donors->get_donor_by('user_id', $user->ID); |
|
773 | 772 | |
774 | - if ( $donor ) { |
|
773 | + if ($donor) { |
|
775 | 774 | // If Donor is attached with User, then validate first name. |
776 | - if ( empty( $_POST['first_name'] ) ) { |
|
775 | + if (empty($_POST['first_name'])) { |
|
777 | 776 | $errors->add( |
778 | 777 | 'empty_first_name', |
779 | 778 | sprintf( |
780 | 779 | '<strong>%1$s:</strong> %2$s', |
781 | - __( 'ERROR', 'give' ), |
|
782 | - __( 'Please enter your first name.', 'give' ) |
|
780 | + __('ERROR', 'give'), |
|
781 | + __('Please enter your first name.', 'give') |
|
783 | 782 | ) |
784 | 783 | ); |
785 | 784 | } |
@@ -788,7 +787,7 @@ discard block |
||
788 | 787 | |
789 | 788 | } |
790 | 789 | |
791 | -add_action( 'user_profile_update_errors', 'give_validate_user_profile', 10, 3 ); |
|
790 | +add_action('user_profile_update_errors', 'give_validate_user_profile', 10, 3); |
|
792 | 791 | |
793 | 792 | /** |
794 | 793 | * Show Donor Information on User Profile Page. |
@@ -797,19 +796,19 @@ discard block |
||
797 | 796 | * |
798 | 797 | * @since 2.0 |
799 | 798 | */ |
800 | -function give_donor_information_profile_fields( $user ) { |
|
801 | - $donor = Give()->donors->get_donor_by( 'user_id', $user->ID ); |
|
799 | +function give_donor_information_profile_fields($user) { |
|
800 | + $donor = Give()->donors->get_donor_by('user_id', $user->ID); |
|
802 | 801 | |
803 | 802 | // Display Donor Information, only if donor is attached with User. |
804 | - if ( ! empty( $donor->user_id ) ) { |
|
803 | + if ( ! empty($donor->user_id)) { |
|
805 | 804 | ?> |
806 | 805 | <table class="form-table"> |
807 | 806 | <tbody> |
808 | 807 | <tr> |
809 | - <th scope="row"><?php _e( 'Donor', 'give' ); ?></th> |
|
808 | + <th scope="row"><?php _e('Donor', 'give'); ?></th> |
|
810 | 809 | <td> |
811 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"> |
|
812 | - <?php _e( 'View Donor Information', 'give' ); ?> |
|
810 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>"> |
|
811 | + <?php _e('View Donor Information', 'give'); ?> |
|
813 | 812 | </a> |
814 | 813 | </td> |
815 | 814 | </tr> |
@@ -819,7 +818,7 @@ discard block |
||
819 | 818 | } |
820 | 819 | } |
821 | 820 | |
822 | -add_action( 'personal_options', 'give_donor_information_profile_fields' ); |
|
821 | +add_action('personal_options', 'give_donor_information_profile_fields'); |
|
823 | 822 | /** |
824 | 823 | * Get Array of WP User Roles. |
825 | 824 | * |
@@ -831,8 +830,8 @@ discard block |
||
831 | 830 | $user_roles = array(); |
832 | 831 | |
833 | 832 | // Loop through User Roles. |
834 | - foreach ( get_editable_roles() as $role_name => $role_info ) : |
|
835 | - $user_roles[ $role_name ] = $role_info['name']; |
|
833 | + foreach (get_editable_roles() as $role_name => $role_info) : |
|
834 | + $user_roles[$role_name] = $role_info['name']; |
|
836 | 835 | endforeach; |
837 | 836 | |
838 | 837 | return $user_roles; |
@@ -849,48 +848,46 @@ discard block |
||
849 | 848 | function __give_ajax_donor_manage_addresses() { |
850 | 849 | // Bailout. |
851 | 850 | if ( |
852 | - empty( $_POST['form'] ) || |
|
853 | - empty( $_POST['donorID'] ) |
|
851 | + empty($_POST['form']) || |
|
852 | + empty($_POST['donorID']) |
|
854 | 853 | ) { |
855 | - wp_send_json_error( array( |
|
854 | + wp_send_json_error(array( |
|
856 | 855 | 'error' => 1, |
857 | - ) ); |
|
856 | + )); |
|
858 | 857 | } |
859 | 858 | |
860 | - $post = give_clean( wp_parse_args( $_POST ) ); |
|
861 | - $donorID = absint( $post['donorID'] ); |
|
862 | - $form_data = give_clean( wp_parse_args( $post['form'] ) ); |
|
863 | - $is_multi_address_type = ( 'billing' === $form_data['address-id'] || false !== strpos( $form_data['address-id'], '_' ) ); |
|
864 | - $address_type = false !== strpos( $form_data['address-id'], '_' ) ? |
|
865 | - array_shift( explode( '_', $form_data['address-id'] ) ) : |
|
866 | - $form_data['address-id']; |
|
867 | - $address_id = false !== strpos( $form_data['address-id'], '_' ) ? |
|
868 | - array_pop( explode( '_', $form_data['address-id'] ) ) : |
|
869 | - null; |
|
859 | + $post = give_clean(wp_parse_args($_POST)); |
|
860 | + $donorID = absint($post['donorID']); |
|
861 | + $form_data = give_clean(wp_parse_args($post['form'])); |
|
862 | + $is_multi_address_type = ('billing' === $form_data['address-id'] || false !== strpos($form_data['address-id'], '_')); |
|
863 | + $address_type = false !== strpos($form_data['address-id'], '_') ? |
|
864 | + array_shift(explode('_', $form_data['address-id'])) : $form_data['address-id']; |
|
865 | + $address_id = false !== strpos($form_data['address-id'], '_') ? |
|
866 | + array_pop(explode('_', $form_data['address-id'])) : null; |
|
870 | 867 | $response_data = array( |
871 | 868 | 'action' => $form_data['address-action'], |
872 | 869 | 'id' => $form_data['address-id'], |
873 | 870 | ); |
874 | 871 | |
875 | 872 | // Security check. |
876 | - if ( ! wp_verify_nonce( $form_data['_wpnonce'], 'give-manage-donor-addresses' ) ) { |
|
877 | - wp_send_json_error( array( |
|
873 | + if ( ! wp_verify_nonce($form_data['_wpnonce'], 'give-manage-donor-addresses')) { |
|
874 | + wp_send_json_error(array( |
|
878 | 875 | 'error' => 1, |
879 | 876 | 'error_msg' => wp_sprintf( |
880 | 877 | '<div class="notice notice-error"><p>%s</p></div>', |
881 | - __( 'Error: Security issue.', 'give' ) |
|
878 | + __('Error: Security issue.', 'give') |
|
882 | 879 | ), |
883 | 880 | ) |
884 | 881 | ); |
885 | 882 | } |
886 | 883 | |
887 | - $donor = new Give_Donor( $donorID ); |
|
884 | + $donor = new Give_Donor($donorID); |
|
888 | 885 | |
889 | 886 | // Verify donor. |
890 | - if ( ! $donor->id ) { |
|
891 | - wp_send_json_error( array( |
|
887 | + if ( ! $donor->id) { |
|
888 | + wp_send_json_error(array( |
|
892 | 889 | 'error' => 3, |
893 | - ) ); |
|
890 | + )); |
|
894 | 891 | } |
895 | 892 | |
896 | 893 | // Unset all data except address. |
@@ -901,57 +898,55 @@ discard block |
||
901 | 898 | ); |
902 | 899 | |
903 | 900 | // Process action. |
904 | - switch ( $response_data['action'] ) { |
|
901 | + switch ($response_data['action']) { |
|
905 | 902 | |
906 | 903 | case 'add': |
907 | - if ( ! $donor->add_address( "{$address_type}[]", $form_data ) ) { |
|
908 | - wp_send_json_error( array( |
|
904 | + if ( ! $donor->add_address("{$address_type}[]", $form_data)) { |
|
905 | + wp_send_json_error(array( |
|
909 | 906 | 'error' => 1, |
910 | 907 | 'error_msg' => wp_sprintf( |
911 | 908 | '<div class="notice notice-error"><p>%s</p></div>', |
912 | - __( 'Error: Unable to save the address. Please check if address already exist.', 'give' ) |
|
909 | + __('Error: Unable to save the address. Please check if address already exist.', 'give') |
|
913 | 910 | ), |
914 | 911 | ) |
915 | 912 | ); |
916 | 913 | } |
917 | 914 | |
918 | - $total_addresses = count( $donor->address[ $address_type ] ); |
|
915 | + $total_addresses = count($donor->address[$address_type]); |
|
919 | 916 | |
920 | 917 | $address_index = $is_multi_address_type ? |
921 | - $total_addresses - 1 : |
|
922 | - $address_type; |
|
918 | + $total_addresses - 1 : $address_type; |
|
923 | 919 | |
924 | 920 | $address_id = $is_multi_address_type ? |
925 | - end( array_keys( $donor->address[ $address_type ] ) ) : |
|
926 | - $address_type; |
|
921 | + end(array_keys($donor->address[$address_type])) : $address_type; |
|
927 | 922 | |
928 | 923 | $response_data['address_html'] = __give_get_format_address( |
929 | - end( $donor->address['billing'] ), |
|
924 | + end($donor->address['billing']), |
|
930 | 925 | array( |
931 | 926 | // We can add only billing address from donor screen. |
932 | 927 | 'type' => 'billing', |
933 | 928 | 'id' => $address_id, |
934 | - 'index' => ++ $address_index, |
|
929 | + 'index' => ++$address_index, |
|
935 | 930 | ) |
936 | 931 | ); |
937 | - $response_data['success_msg'] = wp_sprintf( |
|
932 | + $response_data['success_msg'] = wp_sprintf( |
|
938 | 933 | '<div class="notice updated"><p>%s</p></div>', |
939 | - __( 'Successfully added a new address to the donor.', 'give' ) |
|
934 | + __('Successfully added a new address to the donor.', 'give') |
|
940 | 935 | ); |
941 | 936 | |
942 | - if ( $is_multi_address_type ) { |
|
937 | + if ($is_multi_address_type) { |
|
943 | 938 | $response_data['id'] = "{$response_data['id']}_{$address_index}"; |
944 | 939 | } |
945 | 940 | |
946 | 941 | break; |
947 | 942 | |
948 | 943 | case 'remove': |
949 | - if ( ! $donor->remove_address( $response_data['id'] ) ) { |
|
950 | - wp_send_json_error( array( |
|
944 | + if ( ! $donor->remove_address($response_data['id'])) { |
|
945 | + wp_send_json_error(array( |
|
951 | 946 | 'error' => 2, |
952 | 947 | 'error_msg' => wp_sprintf( |
953 | 948 | '<div class="notice notice-error"><p>%s</p></div>', |
954 | - __( 'Error: Unable to delete address.', 'give' ) |
|
949 | + __('Error: Unable to delete address.', 'give') |
|
955 | 950 | ), |
956 | 951 | ) |
957 | 952 | ); |
@@ -959,18 +954,18 @@ discard block |
||
959 | 954 | |
960 | 955 | $response_data['success_msg'] = wp_sprintf( |
961 | 956 | '<div class="notice updated"><p>%s</p></div>', |
962 | - __( 'Successfully removed a address of donor.', 'give' ) |
|
957 | + __('Successfully removed a address of donor.', 'give') |
|
963 | 958 | ); |
964 | 959 | |
965 | 960 | break; |
966 | 961 | |
967 | 962 | case 'update': |
968 | - if ( ! $donor->update_address( $response_data['id'], $form_data ) ) { |
|
969 | - wp_send_json_error( array( |
|
963 | + if ( ! $donor->update_address($response_data['id'], $form_data)) { |
|
964 | + wp_send_json_error(array( |
|
970 | 965 | 'error' => 3, |
971 | 966 | 'error_msg' => wp_sprintf( |
972 | 967 | '<div class="notice notice-error"><p>%s</p></div>', |
973 | - __( 'Error: Unable to update address. Please check if address already exist.', 'give' ) |
|
968 | + __('Error: Unable to update address. Please check if address already exist.', 'give') |
|
974 | 969 | ), |
975 | 970 | ) |
976 | 971 | ); |
@@ -978,26 +973,25 @@ discard block |
||
978 | 973 | |
979 | 974 | $response_data['address_html'] = __give_get_format_address( |
980 | 975 | $is_multi_address_type ? |
981 | - $donor->address[ $address_type ][ $address_id ] : |
|
982 | - $donor->address[ $address_type ], |
|
976 | + $donor->address[$address_type][$address_id] : $donor->address[$address_type], |
|
983 | 977 | array( |
984 | 978 | 'type' => $address_type, |
985 | 979 | 'id' => $address_id, |
986 | 980 | 'index' => $address_id, |
987 | 981 | ) |
988 | 982 | ); |
989 | - $response_data['success_msg'] = wp_sprintf( |
|
983 | + $response_data['success_msg'] = wp_sprintf( |
|
990 | 984 | '<div class="notice updated"><p>%s</p></div>', |
991 | - __( 'Successfully updated a address of donor', 'give' ) |
|
985 | + __('Successfully updated a address of donor', 'give') |
|
992 | 986 | ); |
993 | 987 | |
994 | 988 | break; |
995 | 989 | }// End switch(). |
996 | 990 | |
997 | - wp_send_json_success( $response_data ); |
|
991 | + wp_send_json_success($response_data); |
|
998 | 992 | } |
999 | 993 | |
1000 | -add_action( 'wp_ajax_donor_manage_addresses', '__give_ajax_donor_manage_addresses' ); |
|
994 | +add_action('wp_ajax_donor_manage_addresses', '__give_ajax_donor_manage_addresses'); |
|
1001 | 995 | |
1002 | 996 | /** |
1003 | 997 | * Admin donor billing address label |
@@ -1008,13 +1002,13 @@ discard block |
||
1008 | 1002 | * |
1009 | 1003 | * @return string |
1010 | 1004 | */ |
1011 | -function __give_donor_billing_address_label( $address_label ) { |
|
1012 | - $address_label = __( 'Billing Address', 'give' ); |
|
1005 | +function __give_donor_billing_address_label($address_label) { |
|
1006 | + $address_label = __('Billing Address', 'give'); |
|
1013 | 1007 | |
1014 | 1008 | return $address_label; |
1015 | 1009 | } |
1016 | 1010 | |
1017 | -add_action( 'give_donor_billing_address_label', '__give_donor_billing_address_label' ); |
|
1011 | +add_action('give_donor_billing_address_label', '__give_donor_billing_address_label'); |
|
1018 | 1012 | |
1019 | 1013 | /** |
1020 | 1014 | * Admin donor personal address label |
@@ -1025,13 +1019,13 @@ discard block |
||
1025 | 1019 | * |
1026 | 1020 | * @return string |
1027 | 1021 | */ |
1028 | -function __give_donor_personal_address_label( $address_label ) { |
|
1029 | - $address_label = __( 'Personal Address', 'give' ); |
|
1022 | +function __give_donor_personal_address_label($address_label) { |
|
1023 | + $address_label = __('Personal Address', 'give'); |
|
1030 | 1024 | |
1031 | 1025 | return $address_label; |
1032 | 1026 | } |
1033 | 1027 | |
1034 | -add_action( 'give_donor_personal_address_label', '__give_donor_personal_address_label' ); |
|
1028 | +add_action('give_donor_personal_address_label', '__give_donor_personal_address_label'); |
|
1035 | 1029 | |
1036 | 1030 | /** |
1037 | 1031 | * Update Donor Information when User Profile is updated from admin. |
@@ -1044,34 +1038,34 @@ discard block |
||
1044 | 1038 | * |
1045 | 1039 | * @return bool |
1046 | 1040 | */ |
1047 | -function give_update_donor_name_on_user_update( $user_id = 0 ) { |
|
1041 | +function give_update_donor_name_on_user_update($user_id = 0) { |
|
1048 | 1042 | |
1049 | - if ( current_user_can( 'edit_user', $user_id ) ) { |
|
1043 | + if (current_user_can('edit_user', $user_id)) { |
|
1050 | 1044 | |
1051 | - $donor = new Give_Donor( $user_id, true ); |
|
1045 | + $donor = new Give_Donor($user_id, true); |
|
1052 | 1046 | |
1053 | 1047 | // Bailout, if donor doesn't exists. |
1054 | - if ( ! $donor ) { |
|
1048 | + if ( ! $donor) { |
|
1055 | 1049 | return false; |
1056 | 1050 | } |
1057 | 1051 | |
1058 | 1052 | // Get User First name and Last name. |
1059 | - $first_name = ( $_POST['first_name'] ) ? give_clean( $_POST['first_name'] ) : get_user_meta( $user_id, 'first_name', true ); |
|
1060 | - $last_name = ( $_POST['last_name'] ) ? give_clean( $_POST['last_name'] ) : get_user_meta( $user_id, 'last_name', true ); |
|
1061 | - $full_name = strip_tags( wp_unslash( trim( "{$first_name} {$last_name}" ) ) ); |
|
1053 | + $first_name = ($_POST['first_name']) ? give_clean($_POST['first_name']) : get_user_meta($user_id, 'first_name', true); |
|
1054 | + $last_name = ($_POST['last_name']) ? give_clean($_POST['last_name']) : get_user_meta($user_id, 'last_name', true); |
|
1055 | + $full_name = strip_tags(wp_unslash(trim("{$first_name} {$last_name}"))); |
|
1062 | 1056 | |
1063 | 1057 | // Assign User First name and Last name to Donor. |
1064 | - Give()->donors->update( $donor->id, array( |
|
1058 | + Give()->donors->update($donor->id, array( |
|
1065 | 1059 | 'name' => $full_name, |
1066 | - ) ); |
|
1067 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name ); |
|
1068 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name ); |
|
1060 | + )); |
|
1061 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name); |
|
1062 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name); |
|
1069 | 1063 | |
1070 | 1064 | } |
1071 | 1065 | } |
1072 | 1066 | |
1073 | -add_action( 'edit_user_profile_update', 'give_update_donor_name_on_user_update', 10 ); |
|
1074 | -add_action( 'personal_options_update', 'give_update_donor_name_on_user_update', 10 ); |
|
1067 | +add_action('edit_user_profile_update', 'give_update_donor_name_on_user_update', 10); |
|
1068 | +add_action('personal_options_update', 'give_update_donor_name_on_user_update', 10); |
|
1075 | 1069 | |
1076 | 1070 | |
1077 | 1071 | /** |
@@ -1086,31 +1080,31 @@ discard block |
||
1086 | 1080 | * |
1087 | 1081 | * @return bool |
1088 | 1082 | */ |
1089 | -function give_update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) { |
|
1083 | +function give_update_donor_email_on_user_update($user_id = 0, $old_user_data = false) { |
|
1090 | 1084 | |
1091 | - $donor = new Give_Donor( $user_id, true ); |
|
1085 | + $donor = new Give_Donor($user_id, true); |
|
1092 | 1086 | |
1093 | - if ( ! $donor ) { |
|
1087 | + if ( ! $donor) { |
|
1094 | 1088 | return false; |
1095 | 1089 | } |
1096 | 1090 | |
1097 | - $user = get_userdata( $user_id ); |
|
1091 | + $user = get_userdata($user_id); |
|
1098 | 1092 | |
1099 | - if ( ! empty( $user ) && $user->user_email !== $donor->email ) { |
|
1093 | + if ( ! empty($user) && $user->user_email !== $donor->email) { |
|
1100 | 1094 | |
1101 | - $success = Give()->donors->update( $donor->id, array( |
|
1095 | + $success = Give()->donors->update($donor->id, array( |
|
1102 | 1096 | 'email' => $user->user_email, |
1103 | - ) ); |
|
1097 | + )); |
|
1104 | 1098 | |
1105 | - if ( $success ) { |
|
1099 | + if ($success) { |
|
1106 | 1100 | // Update some payment meta if we need to |
1107 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
1101 | + $payments_array = explode(',', $donor->payment_ids); |
|
1108 | 1102 | |
1109 | - if ( ! empty( $payments_array ) ) { |
|
1103 | + if ( ! empty($payments_array)) { |
|
1110 | 1104 | |
1111 | - foreach ( $payments_array as $payment_id ) { |
|
1105 | + foreach ($payments_array as $payment_id) { |
|
1112 | 1106 | |
1113 | - give_update_payment_meta( $payment_id, 'email', $user->user_email ); |
|
1107 | + give_update_payment_meta($payment_id, 'email', $user->user_email); |
|
1114 | 1108 | |
1115 | 1109 | } |
1116 | 1110 | } |
@@ -1123,14 +1117,14 @@ discard block |
||
1123 | 1117 | * @param WP_User $user WordPress User object. |
1124 | 1118 | * @param Give_Donor $donor Give donor object. |
1125 | 1119 | */ |
1126 | - do_action( 'give_update_donor_email_on_user_update', $user, $donor ); |
|
1120 | + do_action('give_update_donor_email_on_user_update', $user, $donor); |
|
1127 | 1121 | |
1128 | 1122 | } |
1129 | 1123 | } |
1130 | 1124 | |
1131 | 1125 | } |
1132 | 1126 | |
1133 | -add_action( 'profile_update', 'give_update_donor_email_on_user_update', 10, 2 ); |
|
1127 | +add_action('profile_update', 'give_update_donor_email_on_user_update', 10, 2); |
|
1134 | 1128 | |
1135 | 1129 | |
1136 | 1130 | /** |
@@ -1139,15 +1133,15 @@ discard block |
||
1139 | 1133 | function give_cache_flush() { |
1140 | 1134 | $result = Give_Cache::flush_cache(); |
1141 | 1135 | |
1142 | - if ( $result ) { |
|
1143 | - wp_send_json_success( array( |
|
1144 | - 'message' => __( 'Cache flushed successfully.', 'give' ), |
|
1136 | + if ($result) { |
|
1137 | + wp_send_json_success(array( |
|
1138 | + 'message' => __('Cache flushed successfully.', 'give'), |
|
1145 | 1139 | )); |
1146 | 1140 | } else { |
1147 | - wp_send_json_error( array( |
|
1148 | - 'message' => __( 'An error occured while flushing the cache.', 'give' ), |
|
1141 | + wp_send_json_error(array( |
|
1142 | + 'message' => __('An error occured while flushing the cache.', 'give'), |
|
1149 | 1143 | )); |
1150 | 1144 | } |
1151 | 1145 | } |
1152 | 1146 | |
1153 | -add_action( 'wp_ajax_give_cache_flush', 'give_cache_flush', 10, 0 ); |
|
1147 | +add_action('wp_ajax_give_cache_flush', 'give_cache_flush', 10, 0); |
@@ -89,7 +89,7 @@ |
||
89 | 89 | * Connect and Reconnect Donor with User profile. |
90 | 90 | * @todo $address is unnecessary param because we are store address to user. |
91 | 91 | * |
92 | - * @param object $donor Donor Object. |
|
92 | + * @param Give_Donor $donor Donor Object. |
|
93 | 93 | * @param array $donor_data Donor Post Variables. |
94 | 94 | * @param array $address Address Information. |
95 | 95 | * |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array The altered list of views. |
25 | 25 | */ |
26 | -function give_register_default_donor_views( $views ) { |
|
26 | +function give_register_default_donor_views($views) { |
|
27 | 27 | |
28 | 28 | $default_views = array( |
29 | 29 | 'overview' => 'give_donor_view', |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | 'notes' => 'give_donor_notes_view', |
32 | 32 | ); |
33 | 33 | |
34 | - return array_merge( $views, $default_views ); |
|
34 | + return array_merge($views, $default_views); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'give_donor_views', 'give_register_default_donor_views', 1, 1 ); |
|
38 | +add_filter('give_donor_views', 'give_register_default_donor_views', 1, 1); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register a tab for the single donor view. |
@@ -46,23 +46,23 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return array The altered list of tabs |
48 | 48 | */ |
49 | -function give_register_default_donor_tabs( $tabs ) { |
|
49 | +function give_register_default_donor_tabs($tabs) { |
|
50 | 50 | |
51 | 51 | $default_tabs = array( |
52 | 52 | 'overview' => array( |
53 | 53 | 'dashicon' => 'dashicons-admin-users', |
54 | - 'title' => __( 'Donor Profile', 'give' ), |
|
54 | + 'title' => __('Donor Profile', 'give'), |
|
55 | 55 | ), |
56 | 56 | 'notes' => array( |
57 | 57 | 'dashicon' => 'dashicons-admin-comments', |
58 | - 'title' => __( 'Donor Notes', 'give' ), |
|
58 | + 'title' => __('Donor Notes', 'give'), |
|
59 | 59 | ), |
60 | 60 | ); |
61 | 61 | |
62 | - return array_merge( $tabs, $default_tabs ); |
|
62 | + return array_merge($tabs, $default_tabs); |
|
63 | 63 | } |
64 | 64 | |
65 | -add_filter( 'give_donor_tabs', 'give_register_default_donor_tabs', 1, 1 ); |
|
65 | +add_filter('give_donor_tabs', 'give_register_default_donor_tabs', 1, 1); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Register the Delete icon as late as possible so it's at the bottom. |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array The altered list of tabs, with 'delete' at the bottom. |
75 | 75 | */ |
76 | -function give_register_delete_donor_tab( $tabs ) { |
|
76 | +function give_register_delete_donor_tab($tabs) { |
|
77 | 77 | |
78 | 78 | $tabs['delete'] = array( |
79 | 79 | 'dashicon' => 'dashicons-trash', |
80 | - 'title' => __( 'Delete Donor', 'give' ), |
|
80 | + 'title' => __('Delete Donor', 'give'), |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | return $tabs; |
84 | 84 | } |
85 | 85 | |
86 | -add_filter( 'give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1 ); |
|
86 | +add_filter('give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Connect and Reconnect Donor with User profile. |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return array |
99 | 99 | */ |
100 | -function give_connect_user_donor_profile( $donor, $donor_data, $address ) { |
|
100 | +function give_connect_user_donor_profile($donor, $donor_data, $address) { |
|
101 | 101 | |
102 | 102 | $donor_id = $donor->id; |
103 | 103 | $previous_user_id = $donor->user_id; |
@@ -111,31 +111,31 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @since 1.0 |
113 | 113 | */ |
114 | - do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address ); |
|
114 | + do_action('give_pre_edit_donor', $donor_id, $donor_data, $address); |
|
115 | 115 | |
116 | 116 | $output = array(); |
117 | 117 | |
118 | - if ( $donor->update( $donor_data ) ) { |
|
118 | + if ($donor->update($donor_data)) { |
|
119 | 119 | |
120 | 120 | // Create and Update Donor First Name and Last Name in Meta Fields. |
121 | - $donor->update_meta( '_give_donor_first_name', $donor_data['first_name'] ); |
|
122 | - $donor->update_meta( '_give_donor_last_name', $donor_data['last_name'] ); |
|
121 | + $donor->update_meta('_give_donor_first_name', $donor_data['first_name']); |
|
122 | + $donor->update_meta('_give_donor_last_name', $donor_data['last_name']); |
|
123 | 123 | |
124 | 124 | // Fetch disconnected user id, if exists. |
125 | - $disconnected_user_id = $donor->get_meta( '_give_disconnected_user_id', true ); |
|
125 | + $disconnected_user_id = $donor->get_meta('_give_disconnected_user_id', true); |
|
126 | 126 | |
127 | 127 | // Flag User and Donor Disconnection. |
128 | - delete_user_meta( $disconnected_user_id, '_give_is_donor_disconnected' ); |
|
128 | + delete_user_meta($disconnected_user_id, '_give_is_donor_disconnected'); |
|
129 | 129 | |
130 | 130 | // Check whether the disconnected user id and the reconnected user id are same or not. |
131 | 131 | // If both are same then delete user id store in donor meta. |
132 | - if( $donor_data['user_id'] === $disconnected_user_id ) { |
|
133 | - delete_user_meta( $disconnected_user_id, '_give_disconnected_donor_id' ); |
|
134 | - $donor->delete_meta( '_give_disconnected_user_id' ); |
|
132 | + if ($donor_data['user_id'] === $disconnected_user_id) { |
|
133 | + delete_user_meta($disconnected_user_id, '_give_disconnected_donor_id'); |
|
134 | + $donor->delete_meta('_give_disconnected_user_id'); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $output['success'] = true; |
138 | - $donor_data = array_merge( $donor_data, $address ); |
|
138 | + $donor_data = array_merge($donor_data, $address); |
|
139 | 139 | $output['customer_info'] = $donor_data; |
140 | 140 | |
141 | 141 | } else { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @since 1.0 |
154 | 154 | */ |
155 | - do_action( 'give_post_edit_donor', $donor_id, $donor_data ); |
|
155 | + do_action('give_post_edit_donor', $donor_id, $donor_data); |
|
156 | 156 | |
157 | 157 | |
158 | 158 | return $output; |
@@ -600,7 +600,7 @@ |
||
600 | 600 | * |
601 | 601 | * @param int $form_id |
602 | 602 | * |
603 | - * @return array|string |
|
603 | + * @return string |
|
604 | 604 | */ |
605 | 605 | public function get_preview_email_recipient( $form_id = null ) { |
606 | 606 | $recipients = $this->get_recipient( $form_id ); |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if access directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | -if ( ! class_exists( 'Give_Email_Notification' ) ) : |
|
19 | +if ( ! class_exists('Give_Email_Notification')) : |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Give_Email_Notification |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return Give_Email_Notification |
95 | 95 | */ |
96 | - public static function get_instance( $email_notification_id = '' ) { |
|
96 | + public static function get_instance($email_notification_id = '') { |
|
97 | 97 | $class = ''; |
98 | 98 | |
99 | - if ( ! empty( $email_notification_id ) ) { |
|
99 | + if ( ! empty($email_notification_id)) { |
|
100 | 100 | /* @var Give_Email_Notification $class */ |
101 | - foreach ( self::$singleton as $class ) { |
|
102 | - if ( $email_notification_id === $class->config['id'] ) { |
|
103 | - $class = get_class( $class ); |
|
101 | + foreach (self::$singleton as $class) { |
|
102 | + if ($email_notification_id === $class->config['id']) { |
|
103 | + $class = get_class($class); |
|
104 | 104 | break; |
105 | 105 | } |
106 | 106 | } |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | $class = get_called_class(); |
109 | 109 | } |
110 | 110 | |
111 | - if ( ! empty( $class ) && ( ! array_key_exists( $class, self::$singleton ) || is_null( self::$singleton[ $class ] ) ) ) { |
|
112 | - self::$singleton[ $class ] = new $class(); |
|
111 | + if ( ! empty($class) && ( ! array_key_exists($class, self::$singleton) || is_null(self::$singleton[$class]))) { |
|
112 | + self::$singleton[$class] = new $class(); |
|
113 | 113 | } |
114 | 114 | |
115 | - return ( isset( self::$singleton[ $class ] ) ? self::$singleton[ $class ] : null ); |
|
115 | + return (isset(self::$singleton[$class]) ? self::$singleton[$class] : null); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -123,35 +123,35 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param array $config |
125 | 125 | */ |
126 | - public function load( $config ) { |
|
126 | + public function load($config) { |
|
127 | 127 | // Set notification configuration. |
128 | - $this->config = wp_parse_args( $config, $this->config ); |
|
128 | + $this->config = wp_parse_args($config, $this->config); |
|
129 | 129 | |
130 | 130 | // Set email preview header status. |
131 | 131 | $this->config['has_preview_header'] = $this->config['has_preview'] && $this->config['has_preview_header'] ? true : false; |
132 | 132 | |
133 | 133 | // Set email content type |
134 | - $this->config['content_type'] = empty( $this->config['content_type'] ) || ! in_array( $this->config['content_type'], array( |
|
134 | + $this->config['content_type'] = empty($this->config['content_type']) || ! in_array($this->config['content_type'], array( |
|
135 | 135 | 'text/html', |
136 | 136 | 'text/plain', |
137 | - ) ) |
|
137 | + )) |
|
138 | 138 | ? Give()->emails->get_content_type() |
139 | 139 | : $this->config['content_type']; |
140 | - $this->config['content_type'] = give_get_option( Give_Email_Setting_Field::get_prefix( $this ) . 'email_content_type', $this->config['content_type'] ); |
|
140 | + $this->config['content_type'] = give_get_option(Give_Email_Setting_Field::get_prefix($this).'email_content_type', $this->config['content_type']); |
|
141 | 141 | |
142 | 142 | // Set email template type. |
143 | - $this->config['email_template'] = empty( $this->config['email_template'] ) |
|
144 | - ? give_get_option( 'email_template' ) |
|
143 | + $this->config['email_template'] = empty($this->config['email_template']) |
|
144 | + ? give_get_option('email_template') |
|
145 | 145 | : $this->config['email_template']; |
146 | 146 | |
147 | 147 | // Set recipient group name. |
148 | - $this->config['recipient_group_name'] = empty( $this->config['recipient_group_name'] ) |
|
149 | - ? ( ! Give_Email_Notification_Util::has_recipient_field( $this ) ? __( 'Donor', 'give' ) : '' ) |
|
148 | + $this->config['recipient_group_name'] = empty($this->config['recipient_group_name']) |
|
149 | + ? ( ! Give_Email_Notification_Util::has_recipient_field($this) ? __('Donor', 'give') : '') |
|
150 | 150 | : $this->config['recipient_group_name']; |
151 | 151 | |
152 | 152 | // Non notification status editable notice. |
153 | - $this->config['notices']['non-notification-status-editable'] = empty( $this->config['notices']['non-notification-status-editable'] ) |
|
154 | - ? __( 'You can not edit notification status from here.', 'give' ) |
|
153 | + $this->config['notices']['non-notification-status-editable'] = empty($this->config['notices']['non-notification-status-editable']) |
|
154 | + ? __('You can not edit notification status from here.', 'give') |
|
155 | 155 | : $this->config['notices']['non-notification-status-editable']; |
156 | 156 | |
157 | 157 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param array Give_Email_Notification::config |
163 | 163 | * @param Give_Email_Notification $this |
164 | 164 | */ |
165 | - $this->config = apply_filters( 'give_email_api_notification_config', $this->config, $this ); |
|
165 | + $this->config = apply_filters('give_email_api_notification_config', $this->config, $this); |
|
166 | 166 | |
167 | 167 | // Setup filters. |
168 | 168 | $this->setup_filters(); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | private function setup_filters() { |
179 | 179 | // Apply filter only for current email notification section. |
180 | - if ( give_get_current_setting_section() === $this->config['id'] ) { |
|
180 | + if (give_get_current_setting_section() === $this->config['id']) { |
|
181 | 181 | // Initialize email context for email notification. |
182 | 182 | $this->config['email_tag_context'] = apply_filters( |
183 | 183 | "give_{$this->config['id']}_email_tag_context", |
@@ -187,23 +187,23 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | // Setup setting fields. |
190 | - if( $this->config['show_on_emails_setting_page'] ) { |
|
191 | - add_filter( 'give_get_settings_emails', array( $this, 'add_setting_fields' ), 10, 2 ); |
|
190 | + if ($this->config['show_on_emails_setting_page']) { |
|
191 | + add_filter('give_get_settings_emails', array($this, 'add_setting_fields'), 10, 2); |
|
192 | 192 | } |
193 | 193 | |
194 | - if ( $this->config['form_metabox_setting'] ) { |
|
194 | + if ($this->config['form_metabox_setting']) { |
|
195 | 195 | add_filter( |
196 | 196 | 'give_email_notification_options_metabox_fields', |
197 | - array( $this, 'add_metabox_setting_field' ), |
|
197 | + array($this, 'add_metabox_setting_field'), |
|
198 | 198 | 10, |
199 | 199 | 2 |
200 | 200 | ); |
201 | 201 | } |
202 | 202 | |
203 | - if( $this->config['has_recipient_field'] ) { |
|
203 | + if ($this->config['has_recipient_field']) { |
|
204 | 204 | add_action( |
205 | 205 | "give_save__give_{$this->config['id']}_recipient", |
206 | - array( $this, 'validate_form_recipient_field_value' ), |
|
206 | + array($this, 'validate_form_recipient_field_value'), |
|
207 | 207 | 10, |
208 | 208 | 3 |
209 | 209 | ); |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return array |
243 | 243 | */ |
244 | - public function add_section( $sections ) { |
|
245 | - $sections[ $this->config['id'] ] = $this->config['label']; |
|
244 | + public function add_section($sections) { |
|
245 | + $sections[$this->config['id']] = $this->config['label']; |
|
246 | 246 | |
247 | 247 | return $sections; |
248 | 248 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return bool |
258 | 258 | */ |
259 | - public function hide_section( $hide_section ) { |
|
259 | + public function hide_section($hide_section) { |
|
260 | 260 | $hide_section = true; |
261 | 261 | |
262 | 262 | return $hide_section; |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return array |
274 | 274 | */ |
275 | - public function add_setting_fields( $settings ) { |
|
276 | - if ( $this->config['id'] === give_get_current_setting_section() ) { |
|
275 | + public function add_setting_fields($settings) { |
|
276 | + if ($this->config['id'] === give_get_current_setting_section()) { |
|
277 | 277 | $settings = $this->get_setting_fields(); |
278 | 278 | } |
279 | 279 | |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * |
292 | 292 | * @return array |
293 | 293 | */ |
294 | - public function get_setting_fields( $form_id = null ) { |
|
295 | - return Give_Email_Setting_Field::get_setting_fields( $this, $form_id ); |
|
294 | + public function get_setting_fields($form_id = null) { |
|
295 | + return Give_Email_Setting_Field::get_setting_fields($this, $form_id); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -307,13 +307,13 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @return array |
309 | 309 | */ |
310 | - public function add_metabox_setting_field( $settings, $form_id ) { |
|
310 | + public function add_metabox_setting_field($settings, $form_id) { |
|
311 | 311 | |
312 | - if( Give_Email_Notification_Util::is_email_notification_active( $this ) ) { |
|
312 | + if (Give_Email_Notification_Util::is_email_notification_active($this)) { |
|
313 | 313 | $settings[] = array( |
314 | 314 | 'id' => $this->config['id'], |
315 | 315 | 'title' => $this->config['label'], |
316 | - 'fields' => $this->get_setting_fields( $form_id ), |
|
316 | + 'fields' => $this->get_setting_fields($form_id), |
|
317 | 317 | ); |
318 | 318 | } |
319 | 319 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return array |
333 | 333 | */ |
334 | - public function get_extra_setting_fields( $form_id = null ) { |
|
334 | + public function get_extra_setting_fields($form_id = null) { |
|
335 | 335 | return array(); |
336 | 336 | } |
337 | 337 | |
@@ -348,11 +348,11 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return string|array |
350 | 350 | */ |
351 | - public function get_recipient( $form_id = null ) { |
|
352 | - if ( empty( $this->recipient_email ) && $this->config['has_recipient_field'] ) { |
|
351 | + public function get_recipient($form_id = null) { |
|
352 | + if (empty($this->recipient_email) && $this->config['has_recipient_field']) { |
|
353 | 353 | $this->recipient_email = Give_Email_Notification_Util::get_value( |
354 | 354 | $this, |
355 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'recipient', |
|
355 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'recipient', |
|
356 | 356 | $form_id |
357 | 357 | ); |
358 | 358 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @since 1.0 |
364 | 364 | * @deprecated 2.0 |
365 | 365 | */ |
366 | - $this->recipient_email = apply_filters( 'give_admin_notice_emails', $this->recipient_email, $this, $form_id ); |
|
366 | + $this->recipient_email = apply_filters('give_admin_notice_emails', $this->recipient_email, $this, $form_id); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return bool |
395 | 395 | */ |
396 | - public function get_notification_status( $form_id = null ) { |
|
397 | - $notification_status = empty( $form_id ) |
|
398 | - ? give_get_option( "{$this->config['id']}_notification", $this->config['notification_status'] ) |
|
399 | - : give_get_meta( $form_id, Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'notification', true, 'global' ); |
|
396 | + public function get_notification_status($form_id = null) { |
|
397 | + $notification_status = empty($form_id) |
|
398 | + ? give_get_option("{$this->config['id']}_notification", $this->config['notification_status']) |
|
399 | + : give_get_meta($form_id, Give_Email_Setting_Field::get_prefix($this, $form_id).'notification', true, 'global'); |
|
400 | 400 | |
401 | 401 | /** |
402 | 402 | * Filter the notification status. |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return string |
423 | 423 | */ |
424 | - function get_email_subject( $form_id = null ) { |
|
424 | + function get_email_subject($form_id = null) { |
|
425 | 425 | $subject = wp_strip_all_tags( |
426 | 426 | Give_Email_Notification_Util::get_value( |
427 | 427 | $this, |
428 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject', |
|
428 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject', |
|
429 | 429 | $form_id, |
430 | 430 | $this->config['default_email_subject'] |
431 | 431 | ) |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - public function get_email_message( $form_id = null ) { |
|
457 | + public function get_email_message($form_id = null) { |
|
458 | 458 | $message = Give_Email_Notification_Util::get_value( |
459 | 459 | $this, |
460 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message', |
|
460 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message', |
|
461 | 461 | $form_id, |
462 | 462 | $this->config['default_email_message'] |
463 | 463 | ); |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | * |
487 | 487 | * @return string |
488 | 488 | */ |
489 | - public function get_email_content_type( $form_id ) { |
|
489 | + public function get_email_content_type($form_id) { |
|
490 | 490 | $content_type = Give_Email_Notification_Util::get_value( |
491 | 491 | $this, |
492 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_content_type', |
|
492 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_content_type', |
|
493 | 493 | $form_id, |
494 | 494 | $this->config['content_type'] |
495 | 495 | ); |
@@ -517,15 +517,14 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return string |
519 | 519 | */ |
520 | - public function get_email_template( $form_id ) { |
|
521 | - $email_template = give_get_meta( $form_id, '_give_email_template', true ); |
|
520 | + public function get_email_template($form_id) { |
|
521 | + $email_template = give_get_meta($form_id, '_give_email_template', true); |
|
522 | 522 | $email_template = Give_Email_Notification_Util::get_value( |
523 | 523 | $this, |
524 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) .'email_template', |
|
524 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_template', |
|
525 | 525 | $form_id, |
526 | - ! empty( $email_template ) && Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ? |
|
527 | - $email_template : |
|
528 | - $this->config['email_template'] |
|
526 | + ! empty($email_template) && Give_Email_Notification_Util::can_use_form_email_options($this, $form_id) ? |
|
527 | + $email_template : $this->config['email_template'] |
|
529 | 528 | ); |
530 | 529 | |
531 | 530 | /** |
@@ -552,34 +551,34 @@ discard block |
||
552 | 551 | * |
553 | 552 | * @return array |
554 | 553 | */ |
555 | - public function get_allowed_email_tags( $formatted = false ) { |
|
554 | + public function get_allowed_email_tags($formatted = false) { |
|
556 | 555 | // Get all email tags. |
557 | 556 | $email_tags = Give()->email_tags->get_tags(); |
558 | 557 | |
559 | 558 | // Skip if all email template tags context setup exit. |
560 | - if ( $this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context'] ) { |
|
561 | - if ( is_array( $this->config['email_tag_context'] ) ) { |
|
562 | - foreach ( $email_tags as $index => $email_tag ) { |
|
563 | - if ( in_array( $email_tag['context'], $this->config['email_tag_context'] ) ) { |
|
559 | + if ($this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context']) { |
|
560 | + if (is_array($this->config['email_tag_context'])) { |
|
561 | + foreach ($email_tags as $index => $email_tag) { |
|
562 | + if (in_array($email_tag['context'], $this->config['email_tag_context'])) { |
|
564 | 563 | continue; |
565 | 564 | } |
566 | 565 | |
567 | - unset( $email_tags[ $index ] ); |
|
566 | + unset($email_tags[$index]); |
|
568 | 567 | } |
569 | 568 | } else { |
570 | - foreach ( $email_tags as $index => $email_tag ) { |
|
571 | - if ( $this->config['email_tag_context'] === $email_tag['context'] ) { |
|
569 | + foreach ($email_tags as $index => $email_tag) { |
|
570 | + if ($this->config['email_tag_context'] === $email_tag['context']) { |
|
572 | 571 | continue; |
573 | 572 | } |
574 | 573 | |
575 | - unset( $email_tags[ $index ] ); |
|
574 | + unset($email_tags[$index]); |
|
576 | 575 | } |
577 | 576 | } |
578 | 577 | } |
579 | 578 | |
580 | - if ( count( $email_tags ) && $formatted ) : ob_start() ?> |
|
579 | + if (count($email_tags) && $formatted) : ob_start() ?> |
|
581 | 580 | <ul class="give-email-tags-wrap"> |
582 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
581 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
583 | 582 | <li class="give_<?php echo $email_tag['tag']; ?>_tag"> |
584 | 583 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
585 | 584 | </li> |
@@ -602,8 +601,8 @@ discard block |
||
602 | 601 | * |
603 | 602 | * @return array|string |
604 | 603 | */ |
605 | - public function get_preview_email_recipient( $form_id = null ) { |
|
606 | - $recipients = $this->get_recipient( $form_id ); |
|
604 | + public function get_preview_email_recipient($form_id = null) { |
|
605 | + $recipients = $this->get_recipient($form_id); |
|
607 | 606 | |
608 | 607 | /** |
609 | 608 | * Filter the preview email recipients. |
@@ -613,7 +612,7 @@ discard block |
||
613 | 612 | * @param string|array $recipients List of recipients. |
614 | 613 | * @param Give_Email_Notification $this |
615 | 614 | */ |
616 | - $recipients = apply_filters( 'give_get_preview_email_recipient', $recipients, $this, $form_id ); |
|
615 | + $recipients = apply_filters('give_get_preview_email_recipient', $recipients, $this, $form_id); |
|
617 | 616 | |
618 | 617 | return $recipients; |
619 | 618 | } |
@@ -628,13 +627,13 @@ discard block |
||
628 | 627 | * |
629 | 628 | * @return array |
630 | 629 | */ |
631 | - public function get_email_attachments( $form_id = null ) { |
|
630 | + public function get_email_attachments($form_id = null) { |
|
632 | 631 | /** |
633 | 632 | * Filter the attachment. |
634 | 633 | * |
635 | 634 | * @since 2.0 |
636 | 635 | */ |
637 | - return apply_filters( "give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id ); |
|
636 | + return apply_filters("give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id); |
|
638 | 637 | } |
639 | 638 | |
640 | 639 | |
@@ -646,37 +645,37 @@ discard block |
||
646 | 645 | */ |
647 | 646 | public function send_preview_email() { |
648 | 647 | // Get form id |
649 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
648 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
650 | 649 | |
651 | 650 | // setup email data. |
652 | 651 | $this->setup_email_data(); |
653 | 652 | |
654 | 653 | $attachments = $this->get_email_attachments(); |
655 | - $message = $this->preview_email_template_tags( $this->get_email_message( $form_id ) ); |
|
656 | - $subject = $this->preview_email_template_tags( $this->get_email_subject( $form_id ) ); |
|
657 | - $content_type = $this->get_email_content_type( $form_id ); |
|
654 | + $message = $this->preview_email_template_tags($this->get_email_message($form_id)); |
|
655 | + $subject = $this->preview_email_template_tags($this->get_email_subject($form_id)); |
|
656 | + $content_type = $this->get_email_content_type($form_id); |
|
658 | 657 | |
659 | 658 | // Setup email content type. |
660 | - Give()->emails->__set( 'content_type', $content_type ); |
|
661 | - Give()->emails->__set( 'html', true ); |
|
659 | + Give()->emails->__set('content_type', $content_type); |
|
660 | + Give()->emails->__set('html', true); |
|
662 | 661 | |
663 | 662 | // Setup email template |
664 | - Give()->emails->__set( 'template', $this->get_email_template( $form_id ) ); |
|
663 | + Give()->emails->__set('template', $this->get_email_template($form_id)); |
|
665 | 664 | |
666 | 665 | // Format plain content type email. |
667 | - if ( 'text/plain' === $content_type ) { |
|
668 | - Give()->emails->__set( 'html', false ); |
|
669 | - Give()->emails->__set( 'template', 'none' ); |
|
670 | - $message = strip_tags( $message ); |
|
666 | + if ('text/plain' === $content_type) { |
|
667 | + Give()->emails->__set('html', false); |
|
668 | + Give()->emails->__set('template', 'none'); |
|
669 | + $message = strip_tags($message); |
|
671 | 670 | } |
672 | 671 | |
673 | - if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) { |
|
672 | + if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) { |
|
674 | 673 | Give()->emails->form_id = $form_id; |
675 | - Give()->emails->from_name = give_get_meta( $form_id, '_give_from_name', true ); |
|
676 | - Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true ); |
|
674 | + Give()->emails->from_name = give_get_meta($form_id, '_give_from_name', true); |
|
675 | + Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true); |
|
677 | 676 | } |
678 | 677 | |
679 | - return Give()->emails->send( $this->get_preview_email_recipient( $form_id ), $subject, $message, $attachments ); |
|
678 | + return Give()->emails->send($this->get_preview_email_recipient($form_id), $subject, $message, $attachments); |
|
680 | 679 | } |
681 | 680 | |
682 | 681 | |
@@ -697,7 +696,7 @@ discard block |
||
697 | 696 | * |
698 | 697 | * @return bool |
699 | 698 | */ |
700 | - public function send_email_notification( $email_tag_args = array() ) { |
|
699 | + public function send_email_notification($email_tag_args = array()) { |
|
701 | 700 | // Add email content type email tags. |
702 | 701 | $email_tag_args['email_content_type'] = $this->config['content_type']; |
703 | 702 | |
@@ -706,16 +705,16 @@ discard block |
||
706 | 705 | * |
707 | 706 | * @since 2.0 |
708 | 707 | */ |
709 | - $email_tag_args = apply_filters( "give_{$this->config['id']}_email_tag_args", $email_tag_args, $this ); |
|
708 | + $email_tag_args = apply_filters("give_{$this->config['id']}_email_tag_args", $email_tag_args, $this); |
|
710 | 709 | |
711 | 710 | // Get form id. |
712 | - $form_id = ! empty( $email_tag_args['form_id'] ) |
|
713 | - ? absint( $email_tag_args['form_id'] ) |
|
714 | - : ( ! empty( $email_tag_args['payment_id'] ) ? give_get_payment_form_id( $email_tag_args['payment_id'] ) : null ); |
|
711 | + $form_id = ! empty($email_tag_args['form_id']) |
|
712 | + ? absint($email_tag_args['form_id']) |
|
713 | + : ( ! empty($email_tag_args['payment_id']) ? give_get_payment_form_id($email_tag_args['payment_id']) : null); |
|
715 | 714 | |
716 | 715 | |
717 | 716 | // Do not send email if notification is disable. |
718 | - if ( ! Give_Email_Notification_Util::is_email_notification_active( $this, $form_id ) ) { |
|
717 | + if ( ! Give_Email_Notification_Util::is_email_notification_active($this, $form_id)) { |
|
719 | 718 | return false; |
720 | 719 | } |
721 | 720 | |
@@ -724,41 +723,41 @@ discard block |
||
724 | 723 | * |
725 | 724 | * @since 2.0 |
726 | 725 | */ |
727 | - do_action( "give_{$this->config['id']}_email_send_before", $this, $form_id ); |
|
726 | + do_action("give_{$this->config['id']}_email_send_before", $this, $form_id); |
|
728 | 727 | |
729 | 728 | $attachments = $this->get_email_attachments(); |
730 | - $message = give_do_email_tags( $this->get_email_message( $form_id ), $email_tag_args ); |
|
731 | - $subject = give_do_email_tags( $this->get_email_subject( $form_id ), $email_tag_args ); |
|
732 | - $content_type = $this->get_email_content_type( $form_id ); |
|
729 | + $message = give_do_email_tags($this->get_email_message($form_id), $email_tag_args); |
|
730 | + $subject = give_do_email_tags($this->get_email_subject($form_id), $email_tag_args); |
|
731 | + $content_type = $this->get_email_content_type($form_id); |
|
733 | 732 | |
734 | 733 | // Setup email content type. |
735 | - Give()->emails->__set( 'content_type', $content_type ); |
|
736 | - Give()->emails->__set( 'html', true ); |
|
734 | + Give()->emails->__set('content_type', $content_type); |
|
735 | + Give()->emails->__set('html', true); |
|
737 | 736 | |
738 | 737 | // Set email template. |
739 | - Give()->emails->__set( 'template', $this->get_email_template( $form_id ) ); |
|
738 | + Give()->emails->__set('template', $this->get_email_template($form_id)); |
|
740 | 739 | |
741 | - if ( 'text/plain' === $content_type ) { |
|
742 | - Give()->emails->__set( 'html', false ); |
|
743 | - Give()->emails->__set( 'template', 'none' ); |
|
744 | - $message = strip_tags( $message ); |
|
740 | + if ('text/plain' === $content_type) { |
|
741 | + Give()->emails->__set('html', false); |
|
742 | + Give()->emails->__set('template', 'none'); |
|
743 | + $message = strip_tags($message); |
|
745 | 744 | } |
746 | 745 | |
747 | - if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) { |
|
746 | + if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) { |
|
748 | 747 | Give()->emails->form_id = $form_id; |
749 | - Give()->emails->from_name = give_get_meta( $form_id, '_give_from_name', true ); |
|
750 | - Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true ); |
|
748 | + Give()->emails->from_name = give_get_meta($form_id, '_give_from_name', true); |
|
749 | + Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true); |
|
751 | 750 | } |
752 | 751 | |
753 | 752 | // Send email. |
754 | - $email_status = Give()->emails->send( $this->get_recipient( $form_id ), $subject, $message, $attachments ); |
|
753 | + $email_status = Give()->emails->send($this->get_recipient($form_id), $subject, $message, $attachments); |
|
755 | 754 | |
756 | 755 | /** |
757 | 756 | * Fire action after after email send. |
758 | 757 | * |
759 | 758 | * @since 2.0 |
760 | 759 | */ |
761 | - do_action( "give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id ); |
|
760 | + do_action("give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id); |
|
762 | 761 | |
763 | 762 | return $email_status; |
764 | 763 | } |
@@ -773,67 +772,67 @@ discard block |
||
773 | 772 | * |
774 | 773 | * @return string |
775 | 774 | */ |
776 | - public function preview_email_template_tags( $message ) { |
|
775 | + public function preview_email_template_tags($message) { |
|
777 | 776 | // Set Payment. |
778 | - $payment_id = give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'preview_id' ); |
|
779 | - $payment = $payment_id ? new Give_Payment( $payment_id ) : new stdClass(); |
|
777 | + $payment_id = give_check_variable(give_clean($_GET), 'isset_empty', 0, 'preview_id'); |
|
778 | + $payment = $payment_id ? new Give_Payment($payment_id) : new stdClass(); |
|
780 | 779 | |
781 | 780 | // Set donor. |
782 | 781 | $user_id = $payment_id |
783 | 782 | ? $payment->user_id |
784 | - : give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'user_id' ); |
|
783 | + : give_check_variable(give_clean($_GET), 'isset_empty', 0, 'user_id'); |
|
785 | 784 | $user_id = $user_id ? $user_id : wp_get_current_user()->ID; |
786 | 785 | |
787 | 786 | // Set receipt. |
788 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
787 | + $receipt_id = strtolower(md5(uniqid())); |
|
789 | 788 | |
790 | - $receipt_link_url = esc_url( add_query_arg( array( |
|
789 | + $receipt_link_url = esc_url(add_query_arg(array( |
|
791 | 790 | 'payment_key' => $receipt_id, |
792 | - ), give_get_history_page_uri() ) ); |
|
791 | + ), give_get_history_page_uri())); |
|
793 | 792 | |
794 | 793 | $receipt_link = sprintf( |
795 | 794 | '<a href="%1$s">%2$s</a>', |
796 | 795 | $receipt_link_url, |
797 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
796 | + esc_html__('View the receipt in your browser »', 'give') |
|
798 | 797 | ); |
799 | 798 | |
800 | 799 | // Set default values for tags. |
801 | 800 | $this->config['preview_email_tags_values'] = wp_parse_args( |
802 | 801 | $this->config['preview_email_tags_values'], |
803 | 802 | array( |
804 | - 'name' => give_email_tag_first_name( array( |
|
803 | + 'name' => give_email_tag_first_name(array( |
|
805 | 804 | 'payment_id' => $payment_id, |
806 | 805 | 'user_id' => $user_id, |
807 | - ) ), |
|
808 | - 'fullname' => give_email_tag_fullname( array( |
|
806 | + )), |
|
807 | + 'fullname' => give_email_tag_fullname(array( |
|
809 | 808 | 'payment_id' => $payment_id, |
810 | 809 | 'user_id' => $user_id, |
811 | - ) ), |
|
812 | - 'username' => give_email_tag_username( array( |
|
810 | + )), |
|
811 | + 'username' => give_email_tag_username(array( |
|
813 | 812 | 'payment_id' => $payment_id, |
814 | 813 | 'user_id' => $user_id, |
815 | - ) ), |
|
816 | - 'user_email' => give_email_tag_user_email( array( |
|
814 | + )), |
|
815 | + 'user_email' => give_email_tag_user_email(array( |
|
817 | 816 | 'payment_id' => $payment_id, |
818 | 817 | 'user_id' => $user_id, |
819 | - ) ), |
|
820 | - 'payment_total' => $payment_id ? give_email_tag_payment_total( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
821 | - 'amount' => $payment_id ? give_email_tag_amount( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
822 | - 'price' => $payment_id ? give_email_tag_price( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
823 | - 'payment_method' => $payment_id ? give_email_tag_payment_method( array( 'payment_id' => $payment_id ) ) : __( 'PayPal', 'give' ), |
|
818 | + )), |
|
819 | + 'payment_total' => $payment_id ? give_email_tag_payment_total(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
820 | + 'amount' => $payment_id ? give_email_tag_amount(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
821 | + 'price' => $payment_id ? give_email_tag_price(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
822 | + 'payment_method' => $payment_id ? give_email_tag_payment_method(array('payment_id' => $payment_id)) : __('PayPal', 'give'), |
|
824 | 823 | 'receipt_id' => $receipt_id, |
825 | - 'payment_id' => $payment_id ? $payment_id : rand( 2000, 2050 ), |
|
824 | + 'payment_id' => $payment_id ? $payment_id : rand(2000, 2050), |
|
826 | 825 | 'receipt_link_url' => $receipt_link_url, |
827 | 826 | 'receipt_link' => $receipt_link, |
828 | - 'date' => $payment_id ? date( give_date_format(), strtotime( $payment->date ) ) : date( give_date_format(), current_time( 'timestamp' ) ), |
|
829 | - 'donation' => $payment_id ? give_email_tag_donation( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title', 'give' ), |
|
830 | - 'form_title' => $payment_id ? give_email_tag_form_title( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), |
|
831 | - 'sitename' => $payment_id ? give_email_tag_sitename( array( 'payment_id' => $payment_id ) ) : get_bloginfo( 'name' ), |
|
827 | + 'date' => $payment_id ? date(give_date_format(), strtotime($payment->date)) : date(give_date_format(), current_time('timestamp')), |
|
828 | + 'donation' => $payment_id ? give_email_tag_donation(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title', 'give'), |
|
829 | + 'form_title' => $payment_id ? give_email_tag_form_title(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), |
|
830 | + 'sitename' => $payment_id ? give_email_tag_sitename(array('payment_id' => $payment_id)) : get_bloginfo('name'), |
|
832 | 831 | 'pdf_receipt' => sprintf( |
833 | 832 | '<a href="#">%s</a>', |
834 | - __( 'Download Receipt', 'give' ) |
|
833 | + __('Download Receipt', 'give') |
|
835 | 834 | ), |
836 | - 'billing_address' => $payment_id ? give_email_tag_billing_address( array( 'payment_id' => $payment_id ) ) : '', |
|
835 | + 'billing_address' => $payment_id ? give_email_tag_billing_address(array('payment_id' => $payment_id)) : '', |
|
837 | 836 | 'email_access_link' => sprintf( |
838 | 837 | '<a href="%1$s">%2$s</a>', |
839 | 838 | add_query_arg( |
@@ -842,20 +841,20 @@ discard block |
||
842 | 841 | ), |
843 | 842 | give_get_history_page_uri() |
844 | 843 | ), |
845 | - __( 'View your donation history »', 'give' ) |
|
844 | + __('View your donation history »', 'give') |
|
846 | 845 | ), |
847 | - 'reset_password_link' => $user_id ? give_email_tag_reset_password_link( array( 'user_id' => $user_id ), $payment_id ) : '', |
|
846 | + 'reset_password_link' => $user_id ? give_email_tag_reset_password_link(array('user_id' => $user_id), $payment_id) : '', |
|
848 | 847 | ) |
849 | 848 | ); |
850 | 849 | |
851 | 850 | // Decode tags. |
852 | - foreach ( $this->config['preview_email_tags_values'] as $preview_tag => $value ) { |
|
853 | - if ( isset( $this->config['preview_email_tags_values'][ $preview_tag ] ) ) { |
|
854 | - $message = str_replace( "{{$preview_tag}}", $this->config['preview_email_tags_values'][ $preview_tag ], $message ); |
|
851 | + foreach ($this->config['preview_email_tags_values'] as $preview_tag => $value) { |
|
852 | + if (isset($this->config['preview_email_tags_values'][$preview_tag])) { |
|
853 | + $message = str_replace("{{$preview_tag}}", $this->config['preview_email_tags_values'][$preview_tag], $message); |
|
855 | 854 | } |
856 | 855 | } |
857 | 856 | |
858 | - return apply_filters( 'give_email_preview_template_tags', $message ); |
|
857 | + return apply_filters('give_email_preview_template_tags', $message); |
|
859 | 858 | } |
860 | 859 | |
861 | 860 | /** |
@@ -880,17 +879,17 @@ discard block |
||
880 | 879 | * @param $post_id |
881 | 880 | * |
882 | 881 | */ |
883 | - public function validate_form_recipient_field_value( $form_meta_key, $form_meta_value, $post_id ) { |
|
882 | + public function validate_form_recipient_field_value($form_meta_key, $form_meta_value, $post_id) { |
|
884 | 883 | // Get valid emails. |
885 | - $new_form_meta_value = array_filter( $form_meta_value, function ( $value ) { |
|
886 | - return ! empty( $value['email'] ) && is_email( $value['email'] ); |
|
884 | + $new_form_meta_value = array_filter($form_meta_value, function($value) { |
|
885 | + return ! empty($value['email']) && is_email($value['email']); |
|
887 | 886 | } ); |
888 | 887 | |
889 | 888 | // Remove duplicate emails from array. |
890 | 889 | $email_arr = array(); |
891 | - foreach ( $new_form_meta_value as $index => $email ) { |
|
892 | - if( in_array( $email['email'], $email_arr ) ) { |
|
893 | - unset( $new_form_meta_value[$index] ); |
|
890 | + foreach ($new_form_meta_value as $index => $email) { |
|
891 | + if (in_array($email['email'], $email_arr)) { |
|
892 | + unset($new_form_meta_value[$index]); |
|
894 | 893 | continue; |
895 | 894 | } |
896 | 895 | |
@@ -899,25 +898,25 @@ discard block |
||
899 | 898 | |
900 | 899 | $update = false; |
901 | 900 | |
902 | - if ( empty( $new_form_meta_value ) ) { |
|
901 | + if (empty($new_form_meta_value)) { |
|
903 | 902 | // Set default recipient. |
904 | 903 | $form_meta_value = array( |
905 | 904 | array( |
906 | - 'email' => get_bloginfo( 'admin_email' ) |
|
905 | + 'email' => get_bloginfo('admin_email') |
|
907 | 906 | ), |
908 | 907 | ); |
909 | 908 | |
910 | 909 | $update = true; |
911 | 910 | |
912 | - } elseif ( count( $new_form_meta_value ) !== count( $form_meta_value ) ) { |
|
911 | + } elseif (count($new_form_meta_value) !== count($form_meta_value)) { |
|
913 | 912 | // Filter recipient emails. |
914 | 913 | $form_meta_value = $new_form_meta_value; |
915 | 914 | |
916 | 915 | $update = true; |
917 | 916 | } |
918 | 917 | |
919 | - if( $update ) { |
|
920 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
918 | + if ($update) { |
|
919 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
921 | 920 | } |
922 | 921 | } |
923 | 922 | } |
@@ -120,7 +120,7 @@ |
||
120 | 120 | * @param string $email_preview_header |
121 | 121 | * @param Give_Donor_Register_Email $email |
122 | 122 | * |
123 | - * @return bool |
|
123 | + * @return string|null |
|
124 | 124 | */ |
125 | 125 | public function email_preview_header( $email_preview_header, $email ) { |
126 | 126 | // Bailout. |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if access directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | -if ( ! class_exists( 'Give_Donor_Register_Email' ) ) : |
|
17 | +if ( ! class_exists('Give_Donor_Register_Email')) : |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Give_Donor_Register_Email |
@@ -31,34 +31,34 @@ discard block |
||
31 | 31 | * @since 2.0 |
32 | 32 | */ |
33 | 33 | public function init() { |
34 | - $this->load( array( |
|
34 | + $this->load(array( |
|
35 | 35 | 'id' => 'donor-register', |
36 | - 'label' => __( 'User Registration Information', 'give' ), |
|
37 | - 'description' => __( 'Sent to the donor when they register for an account on the site.', 'give' ), |
|
36 | + 'label' => __('User Registration Information', 'give'), |
|
37 | + 'description' => __('Sent to the donor when they register for an account on the site.', 'give'), |
|
38 | 38 | 'notification_status' => 'enabled', |
39 | 39 | 'email_tag_contex' => 'donor', |
40 | 40 | 'form_metabox_setting' => false, |
41 | - 'recipient_group_name' => __( 'Donor', 'give' ), |
|
42 | - 'email_tag_context' => array( 'donor', 'general' ), |
|
41 | + 'recipient_group_name' => __('Donor', 'give'), |
|
42 | + 'email_tag_context' => array('donor', 'general'), |
|
43 | 43 | 'default_email_subject' => sprintf( |
44 | 44 | /* translators: %s: site name */ |
45 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
46 | - get_bloginfo( 'name' ) |
|
45 | + esc_attr__('[%s] Your username and password', 'give'), |
|
46 | + get_bloginfo('name') |
|
47 | 47 | ), |
48 | 48 | 'default_email_message' => $this->get_default_email_message(), |
49 | - ) ); |
|
49 | + )); |
|
50 | 50 | |
51 | 51 | // Setup action hook. |
52 | 52 | add_action( |
53 | 53 | "give_{$this->config['id']}_email_notification", |
54 | - array( $this, 'setup_email_notification' ), |
|
54 | + array($this, 'setup_email_notification'), |
|
55 | 55 | 10, |
56 | 56 | 2 |
57 | 57 | ); |
58 | 58 | |
59 | 59 | add_filter( |
60 | 60 | 'give_email_preview_header', |
61 | - array( $this, 'email_preview_header' ), |
|
61 | + array($this, 'email_preview_header'), |
|
62 | 62 | 10, |
63 | 63 | 2 |
64 | 64 | ); |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | * @return string |
74 | 74 | */ |
75 | 75 | function get_default_email_message() { |
76 | - $message = esc_attr__( 'Username: {username}', 'give' ) . "\r\n\r\n"; |
|
76 | + $message = esc_attr__('Username: {username}', 'give')."\r\n\r\n"; |
|
77 | 77 | |
78 | - $message .= __( 'To reset your password, simply click the link below which will take you to a web page where you can create a new password.', 'give' ) . "\r\n"; |
|
79 | - $message .= '{reset_password_link}' . "\r\n\r\n"; |
|
78 | + $message .= __('To reset your password, simply click the link below which will take you to a web page where you can create a new password.', 'give')."\r\n"; |
|
79 | + $message .= '{reset_password_link}'."\r\n\r\n"; |
|
80 | 80 | |
81 | - $message .= __( 'After resetting password, Please login to your account with link below.', 'give' ) . "\r\n"; |
|
82 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
81 | + $message .= __('After resetting password, Please login to your account with link below.', 'give')."\r\n"; |
|
82 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Filter the default email message |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @since 2.0 |
99 | 99 | */ |
100 | 100 | public function setup_email_data() { |
101 | - Give()->emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) ); |
|
101 | + Give()->emails->__set('heading', esc_html__('New User Registration', 'give')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return string |
114 | 114 | */ |
115 | - public function setup_email_notification( $user_id, $user_data ) { |
|
115 | + public function setup_email_notification($user_id, $user_data) { |
|
116 | 116 | $this->setup_email_data(); |
117 | 117 | |
118 | 118 | $this->recipient_email = $user_data['user_email']; |
119 | - $this->send_email_notification( array( |
|
119 | + $this->send_email_notification(array( |
|
120 | 120 | 'user_id' => $user_id, |
121 | - ) ); |
|
121 | + )); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -132,42 +132,42 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return bool |
134 | 134 | */ |
135 | - public function email_preview_header( $email_preview_header, $email ) { |
|
135 | + public function email_preview_header($email_preview_header, $email) { |
|
136 | 136 | // Bailout. |
137 | - if ( $this->config['id'] !== $email->config['id'] ) { |
|
137 | + if ($this->config['id'] !== $email->config['id']) { |
|
138 | 138 | return $email_preview_header; |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Payment receipt switcher |
142 | - $user_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' ); |
|
142 | + $user_id = give_check_variable(give_clean($_GET), 'isset', 0, 'user_id'); |
|
143 | 143 | |
144 | 144 | // Get payments. |
145 | 145 | $donors = new Give_API(); |
146 | - $donors = give_check_variable( $donors->get_donors(), 'empty', array(), 'donors' ); |
|
146 | + $donors = give_check_variable($donors->get_donors(), 'empty', array(), 'donors'); |
|
147 | 147 | $options = array(); |
148 | 148 | |
149 | 149 | // Default option. |
150 | - $options[0] = esc_html__( 'No donor(s) found.', 'give' ); |
|
150 | + $options[0] = esc_html__('No donor(s) found.', 'give'); |
|
151 | 151 | |
152 | 152 | // Provide nice human readable options. |
153 | - if ( $donors ) { |
|
154 | - $options[0] = esc_html__( '- Select a donor -', 'give' ); |
|
155 | - foreach ( $donors as $donor ) { |
|
153 | + if ($donors) { |
|
154 | + $options[0] = esc_html__('- Select a donor -', 'give'); |
|
155 | + foreach ($donors as $donor) { |
|
156 | 156 | // Exclude customers for which wp user not exist. |
157 | - if ( ! $donor['info']['user_id'] ) { |
|
157 | + if ( ! $donor['info']['user_id']) { |
|
158 | 158 | continue; |
159 | 159 | } |
160 | - $options[ $donor['info']['user_id'] ] = esc_html( '#' . $donor['info']['donor_id'] . ' - ' . $donor['info']['email'] ); |
|
160 | + $options[$donor['info']['user_id']] = esc_html('#'.$donor['info']['donor_id'].' - '.$donor['info']['email']); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | - $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] ); |
|
164 | + $request_url_data = wp_parse_url($_SERVER['REQUEST_URI']); |
|
165 | 165 | $query = $request_url_data['query']; |
166 | 166 | |
167 | 167 | // Remove user id query param if set from request url. |
168 | - $query = remove_query_arg( array( 'user_id' ), $query ); |
|
168 | + $query = remove_query_arg(array('user_id'), $query); |
|
169 | 169 | |
170 | - $request_url = home_url( '/?' . str_replace( '', '', $query ) ); |
|
170 | + $request_url = home_url('/?'.str_replace('', '', $query)); |
|
171 | 171 | ?> |
172 | 172 | |
173 | 173 | <!-- Start constructing HTML output.--> |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | </script> |
186 | 186 | |
187 | 187 | <label for="give_preview_email_user_id" style="font-size:12px;color:#333;margin:0 4px 0 0;"> |
188 | - <?php echo esc_html__( 'Preview email with a donor:', 'give' ); ?> |
|
188 | + <?php echo esc_html__('Preview email with a donor:', 'give'); ?> |
|
189 | 189 | </label> |
190 | 190 | |
191 | 191 | <?php |
192 | 192 | // The select field with 100 latest transactions |
193 | - echo Give()->html->select( array( |
|
193 | + echo Give()->html->select(array( |
|
194 | 194 | 'name' => 'preview_email_user_id', |
195 | 195 | 'selected' => $user_id, |
196 | 196 | 'id' => 'give_preview_email_user_id', |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | 'select_atts' => 'onchange="change_preview()"', |
201 | 201 | 'show_option_all' => false, |
202 | 202 | 'show_option_none' => false, |
203 | - ) ); |
|
203 | + )); |
|
204 | 204 | ?> |
205 | 205 | </div> |
206 | 206 | <?php |
@@ -178,7 +178,7 @@ |
||
178 | 178 | * @param Give_Email_Notification $email |
179 | 179 | * @param int $form_id |
180 | 180 | * |
181 | - * @return string |
|
181 | + * @return boolean |
|
182 | 182 | */ |
183 | 183 | public static function is_email_notification_active( Give_Email_Notification $email, $form_id = null ) { |
184 | 184 | $notification_status = $email->get_notification_status( $form_id ); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if access directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return static |
47 | 47 | */ |
48 | 48 | static function get_instance() { |
49 | - if ( null === static::$instance ) { |
|
49 | + if (null === static::$instance) { |
|
50 | 50 | self::$instance = new static(); |
51 | 51 | } |
52 | 52 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return bool |
66 | 66 | */ |
67 | - public static function has_preview( Give_Email_Notification $email ) { |
|
67 | + public static function has_preview(Give_Email_Notification $email) { |
|
68 | 68 | return $email->config['has_preview']; |
69 | 69 | } |
70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public static function has_recipient_field( Give_Email_Notification $email ) { |
|
81 | + public static function has_recipient_field(Give_Email_Notification $email) { |
|
82 | 82 | return $email->config['has_recipient_field']; |
83 | 83 | } |
84 | 84 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return bool |
94 | 94 | */ |
95 | - public static function is_notification_status_editable( Give_Email_Notification $email ) { |
|
95 | + public static function is_notification_status_editable(Give_Email_Notification $email) { |
|
96 | 96 | $user_can_edit = $email->config['notification_status_editable']; |
97 | 97 | |
98 | 98 | return (bool) $user_can_edit; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return bool |
110 | 110 | */ |
111 | - public static function is_content_type_editable( Give_Email_Notification $email ) { |
|
111 | + public static function is_content_type_editable(Give_Email_Notification $email) { |
|
112 | 112 | return $email->config['content_type_editable']; |
113 | 113 | } |
114 | 114 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return bool |
124 | 124 | */ |
125 | - public static function is_email_preview_has_header( Give_Email_Notification $email ) { |
|
125 | + public static function is_email_preview_has_header(Give_Email_Notification $email) { |
|
126 | 126 | return $email->config['has_preview_header']; |
127 | 127 | } |
128 | 128 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return bool |
138 | 138 | */ |
139 | - public static function is_email_preview( Give_Email_Notification $email ) { |
|
139 | + public static function is_email_preview(Give_Email_Notification $email) { |
|
140 | 140 | return $email->config['has_preview']; |
141 | 141 | } |
142 | 142 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return bool |
152 | 152 | */ |
153 | - public static function is_show_on_emails_setting_page( Give_Email_Notification $email ){ |
|
153 | + public static function is_show_on_emails_setting_page(Give_Email_Notification $email) { |
|
154 | 154 | return $email->config['show_on_emails_setting_page']; |
155 | 155 | } |
156 | 156 | |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return bool |
167 | 167 | */ |
168 | - public static function can_use_form_email_options( Give_Email_Notification $email, $form_id = null ){ |
|
169 | - return give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) ); |
|
168 | + public static function can_use_form_email_options(Give_Email_Notification $email, $form_id = null) { |
|
169 | + return give_is_setting_enabled(give_get_meta($form_id, '_give_email_options', true)); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return string |
182 | 182 | */ |
183 | - public static function is_email_notification_active( Give_Email_Notification $email, $form_id = null ) { |
|
184 | - $notification_status = $email->get_notification_status( $form_id ); |
|
183 | + public static function is_email_notification_active(Give_Email_Notification $email, $form_id = null) { |
|
184 | + $notification_status = $email->get_notification_status($form_id); |
|
185 | 185 | |
186 | 186 | |
187 | - $notification_status = empty( $form_id ) |
|
188 | - ? give_is_setting_enabled( $notification_status ) |
|
189 | - : give_is_setting_enabled( give_get_option( "{$email->config['id']}_notification", $email->config['notification_status'] ) ) && give_is_setting_enabled( $notification_status, array( 'enabled', 'global' ) ); |
|
187 | + $notification_status = empty($form_id) |
|
188 | + ? give_is_setting_enabled($notification_status) |
|
189 | + : give_is_setting_enabled(give_get_option("{$email->config['id']}_notification", $email->config['notification_status'])) && give_is_setting_enabled($notification_status, array('enabled', 'global')); |
|
190 | 190 | // To check if email notification is active or not on a per-form basis, email notification must be globally active—otherwise it will be considered disabled. |
191 | 191 | |
192 | 192 | return $notification_status; |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | $is_preview = false; |
204 | 204 | |
205 | 205 | if ( |
206 | - current_user_can( 'manage_give_settings' ) |
|
207 | - && ! empty( $_GET['give_action'] ) |
|
206 | + current_user_can('manage_give_settings') |
|
207 | + && ! empty($_GET['give_action']) |
|
208 | 208 | && 'preview_email' === $_GET['give_action'] |
209 | 209 | ) { |
210 | 210 | $is_preview = true; |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | $is_preview = false; |
225 | 225 | |
226 | 226 | if ( |
227 | - current_user_can( 'manage_give_settings' ) |
|
228 | - && ! empty( $_GET['give_action'] ) |
|
227 | + current_user_can('manage_give_settings') |
|
228 | + && ! empty($_GET['give_action']) |
|
229 | 229 | && 'send_preview_email' === $_GET['give_action'] |
230 | 230 | ) { |
231 | 231 | $is_preview = true; |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return string |
247 | 247 | */ |
248 | - public static function get_formatted_email_type( $content_type ) { |
|
248 | + public static function get_formatted_email_type($content_type) { |
|
249 | 249 | $email_contents = array( |
250 | - 'text/html' => __( 'HTML', 'give' ), |
|
251 | - 'text/plain' => __( 'Plain', 'give' ), |
|
250 | + 'text/html' => __('HTML', 'give'), |
|
251 | + 'text/plain' => __('Plain', 'give'), |
|
252 | 252 | ); |
253 | 253 | |
254 | - return $email_contents[ $content_type ]; |
|
254 | + return $email_contents[$content_type]; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | |
@@ -268,40 +268,40 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return mixed |
270 | 270 | */ |
271 | - public static function get_value( Give_Email_Notification $email, $option_name, $form_id = null, $default = false ) { |
|
271 | + public static function get_value(Give_Email_Notification $email, $option_name, $form_id = null, $default = false) { |
|
272 | 272 | // If form id set then option name can be contain _give_ prefix which is only used for meta key, |
273 | 273 | // So make sure you are using correct option name. |
274 | - $global_option_name = ( 0 === strpos( $option_name, '_give_' ) |
|
275 | - ? str_replace( '_give_', '', $option_name ) |
|
276 | - : $option_name ); |
|
277 | - $option_value = give_get_option( $global_option_name, $default ); |
|
274 | + $global_option_name = (0 === strpos($option_name, '_give_') |
|
275 | + ? str_replace('_give_', '', $option_name) |
|
276 | + : $option_name); |
|
277 | + $option_value = give_get_option($global_option_name, $default); |
|
278 | 278 | |
279 | 279 | if ( |
280 | - ! empty( $form_id ) |
|
280 | + ! empty($form_id) |
|
281 | 281 | && give_is_setting_enabled( |
282 | 282 | give_get_meta( |
283 | 283 | $form_id, |
284 | - Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'notification', |
|
284 | + Give_Email_Setting_Field::get_prefix($email, $form_id).'notification', |
|
285 | 285 | true, |
286 | 286 | 'global' |
287 | 287 | ) |
288 | 288 | ) |
289 | 289 | ) { |
290 | - $option_value = get_post_meta( $form_id, $option_name, true ); |
|
290 | + $option_value = get_post_meta($form_id, $option_name, true); |
|
291 | 291 | |
292 | 292 | // Get only email field value from recipients setting. |
293 | - if( Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'recipient' === $option_name ) { |
|
294 | - $option_value = wp_list_pluck( $option_value, 'email' ); |
|
293 | + if (Give_Email_Setting_Field::get_prefix($email, $form_id).'recipient' === $option_name) { |
|
294 | + $option_value = wp_list_pluck($option_value, 'email'); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | - $option_value = empty( $option_value ) ? $default : $option_value; |
|
298 | + $option_value = empty($option_value) ? $default : $option_value; |
|
299 | 299 | |
300 | 300 | /** |
301 | 301 | * Filter the setting value |
302 | 302 | * |
303 | 303 | * @since 2.0 |
304 | 304 | */ |
305 | - return apply_filters( 'give_email_setting_value', $option_value, $option_name, $email, $form_id, $default ); |
|
305 | + return apply_filters('give_email_setting_value', $option_value, $option_name, $email, $form_id, $default); |
|
306 | 306 | } |
307 | 307 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @since 2.0 |
233 | 233 | * @access public |
234 | - * @return bool|null |
|
234 | + * @return false|null |
|
235 | 235 | */ |
236 | 236 | public function preview_email() { |
237 | 237 | // Bailout. |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @since 2.0 |
371 | 371 | * @access public |
372 | - * @return bool|null |
|
372 | + * @return false|null |
|
373 | 373 | */ |
374 | 374 | public function send_preview_email() { |
375 | 375 | // Bailout. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return static |
53 | 53 | */ |
54 | 54 | static function get_instance() { |
55 | - if ( null === static::$instance ) { |
|
55 | + if (null === static::$instance) { |
|
56 | 56 | self::$instance = new static(); |
57 | 57 | } |
58 | 58 | |
@@ -66,31 +66,31 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function init() { |
68 | 68 | // Load files. |
69 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/ajax-handler.php'; |
|
70 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-setting-field.php'; |
|
71 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/filters.php'; |
|
69 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/ajax-handler.php'; |
|
70 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-setting-field.php'; |
|
71 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/filters.php'; |
|
72 | 72 | |
73 | 73 | // Load email notifications. |
74 | 74 | $this->add_emails_notifications(); |
75 | 75 | |
76 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_metabox_setting_fields' ), 10, 2 ); |
|
77 | - add_action( 'init', array( $this, 'preview_email' ) ); |
|
78 | - add_action( 'init', array( $this, 'send_preview_email' ) ); |
|
79 | - add_action( 'init', array( $this, 'validate_settings' ) ); |
|
76 | + add_filter('give_metabox_form_data_settings', array($this, 'add_metabox_setting_fields'), 10, 2); |
|
77 | + add_action('init', array($this, 'preview_email')); |
|
78 | + add_action('init', array($this, 'send_preview_email')); |
|
79 | + add_action('init', array($this, 'validate_settings')); |
|
80 | 80 | |
81 | 81 | /* @var Give_Email_Notification $email */ |
82 | - foreach ( $this->get_email_notifications() as $email ) { |
|
82 | + foreach ($this->get_email_notifications() as $email) { |
|
83 | 83 | // Setup email section. |
84 | - if( Give_Email_Notification_Util::is_show_on_emails_setting_page( $email ) ) { |
|
85 | - add_filter( 'give_get_sections_emails', array( $email, 'add_section' ) ); |
|
86 | - add_filter( "give_hide_section_{$email->config['id']}_on_emails_page", array( $email, 'hide_section' ) ); |
|
84 | + if (Give_Email_Notification_Util::is_show_on_emails_setting_page($email)) { |
|
85 | + add_filter('give_get_sections_emails', array($email, 'add_section')); |
|
86 | + add_filter("give_hide_section_{$email->config['id']}_on_emails_page", array($email, 'hide_section')); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | // Setup email preview. |
90 | - if ( Give_Email_Notification_Util::is_email_preview_has_header( $email ) ) { |
|
91 | - add_action( "give_{$email->config['id']}_email_preview", array( $this, 'email_preview_header' ) ); |
|
92 | - add_filter( "give_{$email->config['id']}_email_preview_data", array( $this, 'email_preview_data' ) ); |
|
93 | - add_filter( "give_{$email->config['id']}_email_preview_message", array( $this, 'email_preview_message' ), 1, 2 ); |
|
90 | + if (Give_Email_Notification_Util::is_email_preview_has_header($email)) { |
|
91 | + add_action("give_{$email->config['id']}_email_preview", array($this, 'email_preview_header')); |
|
92 | + add_filter("give_{$email->config['id']}_email_preview_data", array($this, 'email_preview_data')); |
|
93 | + add_filter("give_{$email->config['id']}_email_preview_message", array($this, 'email_preview_message'), 1, 2); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
@@ -107,63 +107,63 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return array |
109 | 109 | */ |
110 | - public function add_metabox_setting_fields( $settings, $post_id ) { |
|
110 | + public function add_metabox_setting_fields($settings, $post_id) { |
|
111 | 111 | $emails = $this->get_email_notifications(); |
112 | 112 | |
113 | 113 | // Bailout. |
114 | - if ( empty( $emails ) ) { |
|
114 | + if (empty($emails)) { |
|
115 | 115 | return $settings; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Email notification setting. |
119 | 119 | $settings['email_notification_options'] = array( |
120 | 120 | 'id' => 'email_notification_options', |
121 | - 'title' => __( 'Email Notifications', 'give' ), |
|
121 | + 'title' => __('Email Notifications', 'give'), |
|
122 | 122 | 'icon-html' => '<span class="dashicons dashicons-email-alt"></span>', |
123 | 123 | 'fields' => array( |
124 | 124 | array( |
125 | - 'name' => __( 'Email Options', 'give' ), |
|
125 | + 'name' => __('Email Options', 'give'), |
|
126 | 126 | 'id' => '_give_email_options', |
127 | 127 | 'type' => 'radio_inline', |
128 | 128 | 'default' => 'global', |
129 | 129 | 'options' => array( |
130 | - 'global' => __( 'Global Options' ), |
|
131 | - 'enabled' => __( 'Customize', 'give' ), |
|
130 | + 'global' => __('Global Options'), |
|
131 | + 'enabled' => __('Customize', 'give'), |
|
132 | 132 | ), |
133 | 133 | ), |
134 | 134 | array( |
135 | 135 | 'id' => '_give_email_template', |
136 | - 'name' => esc_html__( 'Email Template', 'give' ), |
|
137 | - 'desc' => esc_html__( 'Choose your template from the available registered template types.', 'give' ), |
|
136 | + 'name' => esc_html__('Email Template', 'give'), |
|
137 | + 'desc' => esc_html__('Choose your template from the available registered template types.', 'give'), |
|
138 | 138 | 'type' => 'select', |
139 | 139 | 'default' => 'default', |
140 | 140 | 'options' => give_get_email_templates(), |
141 | 141 | ), |
142 | 142 | array( |
143 | 143 | 'id' => '_give_email_logo', |
144 | - 'name' => esc_html__( 'Logo', 'give' ), |
|
145 | - 'desc' => esc_html__( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ), |
|
144 | + 'name' => esc_html__('Logo', 'give'), |
|
145 | + 'desc' => esc_html__('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'), |
|
146 | 146 | 'type' => 'file', |
147 | 147 | ), |
148 | 148 | array( |
149 | 149 | 'id' => '_give_from_name', |
150 | - 'name' => esc_html__( 'From Name', 'give' ), |
|
151 | - 'desc' => esc_html__( 'The name which appears in the "From" field in all Give donation emails.', 'give' ), |
|
152 | - 'default' => get_bloginfo( 'name' ), |
|
150 | + 'name' => esc_html__('From Name', 'give'), |
|
151 | + 'desc' => esc_html__('The name which appears in the "From" field in all Give donation emails.', 'give'), |
|
152 | + 'default' => get_bloginfo('name'), |
|
153 | 153 | 'type' => 'text', |
154 | 154 | ), |
155 | 155 | array( |
156 | 156 | 'id' => '_give_from_email', |
157 | - 'name' => esc_html__( 'From Email', 'give' ), |
|
158 | - 'desc' => esc_html__( 'Email address from which all Give emails are sent from. This will act as the "from" and "reply-to" email address.', 'give' ), |
|
159 | - 'default' => get_bloginfo( 'admin_email' ), |
|
157 | + 'name' => esc_html__('From Email', 'give'), |
|
158 | + 'desc' => esc_html__('Email address from which all Give emails are sent from. This will act as the "from" and "reply-to" email address.', 'give'), |
|
159 | + 'default' => get_bloginfo('admin_email'), |
|
160 | 160 | 'type' => 'text', |
161 | 161 | ), |
162 | 162 | array( |
163 | 163 | 'name' => 'email_notification_docs', |
164 | 164 | 'type' => 'docs_link', |
165 | 165 | 'url' => 'http://docs.givewp.com/email-notification', |
166 | - 'title' => __( 'Email Notification', 'give' ), |
|
166 | + 'title' => __('Email Notification', 'give'), |
|
167 | 167 | ), |
168 | 168 | ), |
169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @since 2.0 |
174 | 174 | */ |
175 | - 'sub-fields' => apply_filters( 'give_email_notification_options_metabox_fields', array(), $post_id ), |
|
175 | + 'sub-fields' => apply_filters('give_email_notification_options_metabox_fields', array(), $post_id), |
|
176 | 176 | ); |
177 | 177 | |
178 | 178 | return $settings; |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | */ |
187 | 187 | private function add_emails_notifications() { |
188 | 188 | $this->emails = array( |
189 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-donation-email.php', |
|
190 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-donation-receipt-email.php', |
|
191 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-offline-donation-email.php', |
|
192 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-offline-donation-instruction-email.php', |
|
193 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-donor-register-email.php', |
|
194 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-donor-register-email.php', |
|
195 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-access-email.php', |
|
189 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-donation-email.php', |
|
190 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-donation-receipt-email.php', |
|
191 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-offline-donation-email.php', |
|
192 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-offline-donation-instruction-email.php', |
|
193 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-donor-register-email.php', |
|
194 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-donor-register-email.php', |
|
195 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-access-email.php', |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | /** |
@@ -200,15 +200,15 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @since 2.0 |
202 | 202 | */ |
203 | - $this->emails = apply_filters( 'give_email_notifications', $this->emails, $this ); |
|
203 | + $this->emails = apply_filters('give_email_notifications', $this->emails, $this); |
|
204 | 204 | |
205 | 205 | // Bailout. |
206 | - if ( empty( $this->emails ) ) { |
|
206 | + if (empty($this->emails)) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Initiate email notifications. |
211 | - foreach ( $this->emails as $email ) { |
|
211 | + foreach ($this->emails as $email) { |
|
212 | 212 | $email->init(); |
213 | 213 | } |
214 | 214 | } |
@@ -235,41 +235,41 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function preview_email() { |
237 | 237 | // Bailout. |
238 | - if ( ! Give_Email_Notification_Util::can_preview_email() ) { |
|
238 | + if ( ! Give_Email_Notification_Util::can_preview_email()) { |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // Security check. |
243 | - give_validate_nonce( $_GET['_wpnonce'], 'give-preview-email' ); |
|
243 | + give_validate_nonce($_GET['_wpnonce'], 'give-preview-email'); |
|
244 | 244 | |
245 | 245 | // Get email type. |
246 | - $email_type = isset( $_GET['email_type'] ) ? esc_attr( $_GET['email_type'] ) : ''; |
|
246 | + $email_type = isset($_GET['email_type']) ? esc_attr($_GET['email_type']) : ''; |
|
247 | 247 | |
248 | 248 | /* @var Give_Email_Notification $email */ |
249 | - foreach ( $this->get_email_notifications() as $email ) { |
|
250 | - if ( $email_type !== $email->config['id'] ) { |
|
249 | + foreach ($this->get_email_notifications() as $email) { |
|
250 | + if ($email_type !== $email->config['id']) { |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | |
254 | 254 | // Set form id. |
255 | - $form_id = empty( $_GET['form_id'] ) ? null : absint( $_GET['form_id'] ); |
|
255 | + $form_id = empty($_GET['form_id']) ? null : absint($_GET['form_id']); |
|
256 | 256 | |
257 | 257 | // Call setup email data to apply filter and other thing to email. |
258 | 258 | $email->setup_email_data(); |
259 | 259 | |
260 | 260 | // Decode message. |
261 | - $email_message = $email->preview_email_template_tags( $email->get_email_message( $form_id ) ); |
|
261 | + $email_message = $email->preview_email_template_tags($email->get_email_message($form_id)); |
|
262 | 262 | |
263 | 263 | // Set email template. |
264 | - Give()->emails->html = true; |
|
265 | - Give()->emails->__set( 'template', $email->get_email_template( $form_id ) ); |
|
264 | + Give()->emails->html = true; |
|
265 | + Give()->emails->__set('template', $email->get_email_template($form_id)); |
|
266 | 266 | |
267 | - if ( 'text/plain' === $email->config['content_type'] ) { |
|
267 | + if ('text/plain' === $email->config['content_type']) { |
|
268 | 268 | // Give()->emails->__set( 'html', false ); |
269 | - Give()->emails->__set( 'template', 'none' ); |
|
269 | + Give()->emails->__set('template', 'none'); |
|
270 | 270 | } |
271 | 271 | |
272 | - if ( $email_message = Give()->emails->build_email( $email_message ) ) { |
|
272 | + if ($email_message = Give()->emails->build_email($email_message)) { |
|
273 | 273 | |
274 | 274 | /** |
275 | 275 | * Filter the email preview data |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @param array |
280 | 280 | */ |
281 | - $email_preview_data = apply_filters( "give_{$email_type}_email_preview_data", array() ); |
|
281 | + $email_preview_data = apply_filters("give_{$email_type}_email_preview_data", array()); |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * Fire the give_{$email_type}_email_preview action |
285 | 285 | * |
286 | 286 | * @since 2.0 |
287 | 287 | */ |
288 | - do_action( "give_{$email_type}_email_preview", $email ); |
|
288 | + do_action("give_{$email_type}_email_preview", $email); |
|
289 | 289 | |
290 | 290 | /** |
291 | 291 | * Filter the email message |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @param array $email_preview_data |
297 | 297 | * @param Give_Email_Notification $email |
298 | 298 | */ |
299 | - echo apply_filters( "give_{$email_type}_email_preview_message", $email_message, $email_preview_data, $email ); |
|
299 | + echo apply_filters("give_{$email_type}_email_preview_message", $email_message, $email_preview_data, $email); |
|
300 | 300 | |
301 | 301 | exit(); |
302 | 302 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @param Give_Email_Notification $email |
314 | 314 | */ |
315 | - public function email_preview_header( $email ) { |
|
315 | + public function email_preview_header($email) { |
|
316 | 316 | /** |
317 | 317 | * Filter the all email preview headers. |
318 | 318 | * |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @param Give_Email_Notification $email |
322 | 322 | */ |
323 | - $email_preview_header = apply_filters( 'give_email_preview_header', give_get_preview_email_header(), $email ); |
|
323 | + $email_preview_header = apply_filters('give_email_preview_header', give_get_preview_email_header(), $email); |
|
324 | 324 | |
325 | 325 | echo $email_preview_header; |
326 | 326 | } |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return array |
337 | 337 | */ |
338 | - public function email_preview_data( $email_preview_data ) { |
|
339 | - $email_preview_data['payment_id'] = absint( give_check_variable( give_clean( $_GET ), 'isset', 0, 'preview_id' ) ); |
|
340 | - $email_preview_data['user_id'] = absint( give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' ) ); |
|
338 | + public function email_preview_data($email_preview_data) { |
|
339 | + $email_preview_data['payment_id'] = absint(give_check_variable(give_clean($_GET), 'isset', 0, 'preview_id')); |
|
340 | + $email_preview_data['user_id'] = absint(give_check_variable(give_clean($_GET), 'isset', 0, 'user_id')); |
|
341 | 341 | |
342 | 342 | return $email_preview_data; |
343 | 343 | } |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return string |
355 | 355 | */ |
356 | - public function email_preview_message( $email_message, $email_preview_data ) { |
|
356 | + public function email_preview_message($email_message, $email_preview_data) { |
|
357 | 357 | if ( |
358 | - ! empty( $email_preview_data['payment_id'] ) |
|
359 | - || ! empty( $email_preview_data['user_id'] ) |
|
358 | + ! empty($email_preview_data['payment_id']) |
|
359 | + || ! empty($email_preview_data['user_id']) |
|
360 | 360 | ) { |
361 | - $email_message = give_do_email_tags( $email_message, $email_preview_data ); |
|
361 | + $email_message = give_do_email_tags($email_message, $email_preview_data); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | return $email_message; |
@@ -373,26 +373,26 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function send_preview_email() { |
375 | 375 | // Bailout. |
376 | - if ( ! Give_Email_Notification_Util::can_send_preview_email() ) { |
|
376 | + if ( ! Give_Email_Notification_Util::can_send_preview_email()) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | 380 | // Security check. |
381 | - give_validate_nonce( $_GET['_wpnonce'], 'give-send-preview-email' ); |
|
381 | + give_validate_nonce($_GET['_wpnonce'], 'give-send-preview-email'); |
|
382 | 382 | |
383 | 383 | // Get email type. |
384 | - $email_type = give_check_variable( give_clean( $_GET ), 'isset', '', 'email_type' ); |
|
384 | + $email_type = give_check_variable(give_clean($_GET), 'isset', '', 'email_type'); |
|
385 | 385 | |
386 | 386 | /* @var Give_Email_Notification $email */ |
387 | - foreach ( $this->get_email_notifications() as $email ) { |
|
388 | - if ( $email_type === $email->config['id'] && Give_Email_Notification_Util::is_email_preview( $email ) ) { |
|
387 | + foreach ($this->get_email_notifications() as $email) { |
|
388 | + if ($email_type === $email->config['id'] && Give_Email_Notification_Util::is_email_preview($email)) { |
|
389 | 389 | $email->send_preview_email(); |
390 | 390 | break; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | 394 | // Remove the test email query arg. |
395 | - wp_redirect( remove_query_arg( 'give_action' ) ); |
|
395 | + wp_redirect(remove_query_arg('give_action')); |
|
396 | 396 | exit; |
397 | 397 | } |
398 | 398 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @access public |
405 | 405 | */ |
406 | 406 | public function load() { |
407 | - add_action( 'init', array( $this, 'init' ), -1 ); |
|
407 | + add_action('init', array($this, 'init'), -1); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | if ( |
420 | 420 | ! Give_Admin_Settings::is_saving_settings() || |
421 | 421 | 'emails' !== give_get_current_setting_tab() || |
422 | - ! isset( $_GET['section'] ) |
|
422 | + ! isset($_GET['section']) |
|
423 | 423 | ) { |
424 | 424 | return; |
425 | 425 | } |
@@ -427,18 +427,18 @@ discard block |
||
427 | 427 | // Get email type. |
428 | 428 | $email_type = give_get_current_setting_section(); |
429 | 429 | |
430 | - if ( ! empty( $_POST["{$email_type}_recipient"] ) ) { |
|
431 | - $_POST["{$email_type}_recipient"] = array_unique( array_filter( $_POST["{$email_type}_recipient"] ) ); |
|
430 | + if ( ! empty($_POST["{$email_type}_recipient"])) { |
|
431 | + $_POST["{$email_type}_recipient"] = array_unique(array_filter($_POST["{$email_type}_recipient"])); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | } |
435 | 435 | |
436 | 436 | // Helper class. |
437 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/abstract-email-notification.php'; |
|
438 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notification-util.php'; |
|
437 | +require_once GIVE_PLUGIN_DIR.'includes/admin/emails/abstract-email-notification.php'; |
|
438 | +require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-notification-util.php'; |
|
439 | 439 | |
440 | 440 | // Add backward compatibility. |
441 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/backward-compatibility.php'; |
|
441 | +require_once GIVE_PLUGIN_DIR.'includes/admin/emails/backward-compatibility.php'; |
|
442 | 442 | |
443 | 443 | /** |
444 | 444 | * Initialize functionality. |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | /** |
529 | 529 | * Get donor email html. |
530 | 530 | * |
531 | - * @param object $payment Contains all the data of the payment. |
|
531 | + * @param Give_Payment $payment Contains all the data of the payment. |
|
532 | 532 | * |
533 | 533 | * @access public |
534 | 534 | * @since 1.0 |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * Get Row Actions |
558 | 558 | * |
559 | - * @param object $payment Payment Data. |
|
559 | + * @param Give_Payment $payment Payment Data. |
|
560 | 560 | * |
561 | 561 | * @since 1.6 |
562 | 562 | * |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | /** |
678 | 678 | * Get donor html. |
679 | 679 | * |
680 | - * @param object $payment Contains all the data of the payment. |
|
680 | + * @param Give_Payment $payment Contains all the data of the payment. |
|
681 | 681 | * |
682 | 682 | * @access public |
683 | 683 | * @since 1.0 |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load WP_List_Table if not loaded. |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | // Set parent defaults. |
137 | 137 | parent::__construct( |
138 | 138 | array( |
139 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
140 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
141 | - 'ajax' => false, // Does this table support ajax? |
|
139 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
140 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
141 | + 'ajax' => false, // Does this table support ajax? |
|
142 | 142 | ) |
143 | 143 | ); |
144 | 144 | |
145 | 145 | $this->process_bulk_action(); |
146 | 146 | $this->get_payment_counts(); |
147 | - $this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
|
147 | + $this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -153,31 +153,31 @@ discard block |
||
153 | 153 | * @return void |
154 | 154 | */ |
155 | 155 | public function advanced_filters() { |
156 | - $start_date = isset( $_GET['start-date'] ) ? give_clean( $_GET['start-date'] ) : null; |
|
157 | - $end_date = isset( $_GET['end-date'] ) ? give_clean( $_GET['end-date'] ) : null; |
|
158 | - $status = isset( $_GET['status'] ) ? give_clean( $_GET['status'] ) : ''; |
|
159 | - $donor = isset( $_GET['donor'] ) ? absint( $_GET['donor'] ) : ''; |
|
160 | - $search = isset( $_GET['s'] ) ? give_clean( $_GET['s'] ) : ''; |
|
161 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0; |
|
156 | + $start_date = isset($_GET['start-date']) ? give_clean($_GET['start-date']) : null; |
|
157 | + $end_date = isset($_GET['end-date']) ? give_clean($_GET['end-date']) : null; |
|
158 | + $status = isset($_GET['status']) ? give_clean($_GET['status']) : ''; |
|
159 | + $donor = isset($_GET['donor']) ? absint($_GET['donor']) : ''; |
|
160 | + $search = isset($_GET['s']) ? give_clean($_GET['s']) : ''; |
|
161 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : 0; |
|
162 | 162 | ?> |
163 | 163 | <div id="give-payment-filters" class="give-filters"> |
164 | - <?php $this->search_box( __( 'Search', 'give' ), 'give-payments' ); ?> |
|
164 | + <?php $this->search_box(__('Search', 'give'), 'give-payments'); ?> |
|
165 | 165 | <div id="give-payment-date-filters"> |
166 | 166 | <div class="give-filter give-filter-half"> |
167 | 167 | <label for="start-date" |
168 | - class="give-start-date-label"><?php _e( 'Start Date', 'give' ); ?></label> |
|
168 | + class="give-start-date-label"><?php _e('Start Date', 'give'); ?></label> |
|
169 | 169 | <input type="text" id="start-date" name="start-date" class="give_datepicker" |
170 | 170 | value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy"/> |
171 | 171 | </div> |
172 | 172 | <div class="give-filter give-filter-half"> |
173 | - <label for="end-date" class="give-end-date-label"><?php _e( 'End Date', 'give' ); ?></label> |
|
173 | + <label for="end-date" class="give-end-date-label"><?php _e('End Date', 'give'); ?></label> |
|
174 | 174 | <input type="text" id="end-date" name="end-date" class="give_datepicker" |
175 | 175 | value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy"/> |
176 | 176 | </div> |
177 | 177 | </div> |
178 | 178 | <div id="give-payment-form-filter" class="give-filter"> |
179 | 179 | <label for="give-donation-forms-filter" |
180 | - class="give-donation-forms-filter-label"><?php _e( 'Form', 'give' ); ?></label> |
|
180 | + class="give-donation-forms-filter-label"><?php _e('Form', 'give'); ?></label> |
|
181 | 181 | <?php |
182 | 182 | // Filter Donations by Donation Forms. |
183 | 183 | echo Give()->html->forms_dropdown( |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | 'class' => 'give-donation-forms-filter', |
188 | 188 | 'selected' => $form_id, // Make sure to have $form_id set to 0, if there is no selection. |
189 | 189 | 'chosen' => true, |
190 | - 'number' => - 1, |
|
190 | + 'number' => -1, |
|
191 | 191 | ) |
192 | 192 | ); |
193 | 193 | ?> |
@@ -199,26 +199,26 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @since 1.8.18 |
201 | 201 | */ |
202 | - do_action( 'give_payment_table_advanced_filters' ); |
|
202 | + do_action('give_payment_table_advanced_filters'); |
|
203 | 203 | |
204 | 204 | |
205 | - if ( ! empty( $status ) ) { |
|
206 | - echo sprintf( '<input type="hidden" name="status" value="%s"/>', esc_attr( $status ) ); |
|
205 | + if ( ! empty($status)) { |
|
206 | + echo sprintf('<input type="hidden" name="status" value="%s"/>', esc_attr($status)); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( ! empty( $donor ) ) { |
|
210 | - echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $donor ) ); |
|
209 | + if ( ! empty($donor)) { |
|
210 | + echo sprintf('<input type="hidden" name="donor" value="%s"/>', absint($donor)); |
|
211 | 211 | } |
212 | 212 | ?> |
213 | 213 | |
214 | 214 | <div class="give-filter"> |
215 | - <?php submit_button( __( 'Apply', 'give' ), 'secondary', '', false ); ?> |
|
215 | + <?php submit_button(__('Apply', 'give'), 'secondary', '', false); ?> |
|
216 | 216 | <?php |
217 | 217 | // Clear active filters button. |
218 | - if ( ! empty( $start_date ) || ! empty( $end_date ) || ! empty( $donor ) || ! empty( $search ) || ! empty( $status ) || ! empty( $form_id ) ) : |
|
218 | + if ( ! empty($start_date) || ! empty($end_date) || ! empty($donor) || ! empty($search) || ! empty($status) || ! empty($form_id)) : |
|
219 | 219 | ?> |
220 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>" |
|
221 | - class="button give-clear-filters-button"><?php _e( 'Clear Filters', 'give' ); ?></a> |
|
220 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>" |
|
221 | + class="button give-clear-filters-button"><?php _e('Clear Filters', 'give'); ?></a> |
|
222 | 222 | <?php endif; ?> |
223 | 223 | </div> |
224 | 224 | </div> |
@@ -237,18 +237,18 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - public function search_box( $text, $input_id ) { |
|
241 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
240 | + public function search_box($text, $input_id) { |
|
241 | + if (empty($_REQUEST['s']) && ! $this->has_items()) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | 244 | |
245 | - $input_id = $input_id . '-search-input'; |
|
245 | + $input_id = $input_id.'-search-input'; |
|
246 | 246 | |
247 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
248 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
247 | + if ( ! empty($_REQUEST['orderby'])) { |
|
248 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
249 | 249 | } |
250 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
251 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
250 | + if ( ! empty($_REQUEST['order'])) { |
|
251 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
252 | 252 | } |
253 | 253 | ?> |
254 | 254 | <div class="give-filter give-filter-search" role="search"> |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @since 1.7 |
262 | 262 | */ |
263 | - do_action( 'give_payment_history_search' ); |
|
263 | + do_action('give_payment_history_search'); |
|
264 | 264 | ?> |
265 | 265 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
266 | 266 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
267 | - <?php submit_button( $text, 'button', false, false, array( |
|
267 | + <?php submit_button($text, 'button', false, false, array( |
|
268 | 268 | 'ID' => 'search-submit', |
269 | - ) ); ?><br/> |
|
269 | + )); ?><br/> |
|
270 | 270 | </div> |
271 | 271 | <?php |
272 | 272 | } |
@@ -281,48 +281,48 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function get_views() { |
283 | 283 | |
284 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
284 | + $current = isset($_GET['status']) ? $_GET['status'] : ''; |
|
285 | 285 | $views = array(); |
286 | 286 | $tabs = array( |
287 | 287 | 'all' => array( |
288 | 288 | 'total_count', |
289 | - __( 'All', 'give' ), |
|
289 | + __('All', 'give'), |
|
290 | 290 | ), |
291 | 291 | 'publish' => array( |
292 | 292 | 'complete_count', |
293 | - __( 'Completed', 'give' ), |
|
293 | + __('Completed', 'give'), |
|
294 | 294 | ), |
295 | 295 | 'pending' => array( |
296 | 296 | 'pending_count', |
297 | - __( 'Pending', 'give' ), |
|
297 | + __('Pending', 'give'), |
|
298 | 298 | ), |
299 | 299 | 'processing' => array( |
300 | 300 | 'processing_count', |
301 | - __( 'Processing', 'give' ), |
|
301 | + __('Processing', 'give'), |
|
302 | 302 | ), |
303 | 303 | 'refunded' => array( |
304 | 304 | 'refunded_count', |
305 | - __( 'Refunded', 'give' ), |
|
305 | + __('Refunded', 'give'), |
|
306 | 306 | ), |
307 | 307 | 'revoked' => array( |
308 | 308 | 'revoked_count', |
309 | - __( 'Revoked', 'give' ), |
|
309 | + __('Revoked', 'give'), |
|
310 | 310 | ), |
311 | 311 | 'failed' => array( |
312 | 312 | 'failed_count', |
313 | - __( 'Failed', 'give' ), |
|
313 | + __('Failed', 'give'), |
|
314 | 314 | ), |
315 | 315 | 'cancelled' => array( |
316 | 316 | 'cancelled_count', |
317 | - __( 'Cancelled', 'give' ), |
|
317 | + __('Cancelled', 'give'), |
|
318 | 318 | ), |
319 | 319 | 'abandoned' => array( |
320 | 320 | 'abandoned_count', |
321 | - __( 'Abandoned', 'give' ), |
|
321 | + __('Abandoned', 'give'), |
|
322 | 322 | ), |
323 | 323 | 'preapproval' => array( |
324 | 324 | 'preapproval_count', |
325 | - __( 'Preapproval Pending', 'give' ), |
|
325 | + __('Preapproval Pending', 'give'), |
|
326 | 326 | ), |
327 | 327 | ); |
328 | 328 | |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @since 1.8.18 |
333 | 333 | */ |
334 | - $args = (array) apply_filters( 'give_payments_table_status_remove_query_arg', array( 'paged', '_wpnonce', '_wp_http_referer' ) ); |
|
334 | + $args = (array) apply_filters('give_payments_table_status_remove_query_arg', array('paged', '_wpnonce', '_wp_http_referer')); |
|
335 | 335 | |
336 | 336 | // Build URL. |
337 | - $staus_url = remove_query_arg( $args ); |
|
337 | + $staus_url = remove_query_arg($args); |
|
338 | 338 | |
339 | - foreach ( $tabs as $key => $tab ) { |
|
339 | + foreach ($tabs as $key => $tab) { |
|
340 | 340 | $count_key = $tab[0]; |
341 | 341 | $name = $tab[1]; |
342 | 342 | $count = $this->$count_key; |
@@ -351,16 +351,15 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @since 1.8.12 |
353 | 353 | */ |
354 | - if ( 'all' === $key || $key === $current || apply_filters( 'give_payments_table_show_all_status', 0 < $count, $key, $count ) ) { |
|
354 | + if ('all' === $key || $key === $current || apply_filters('give_payments_table_show_all_status', 0 < $count, $key, $count)) { |
|
355 | 355 | |
356 | 356 | $staus_url = 'all' === $key ? |
357 | - add_query_arg( array( 'status' => false ), $staus_url ) : |
|
358 | - add_query_arg( array( 'status' => $key ), $staus_url ); |
|
357 | + add_query_arg(array('status' => false), $staus_url) : add_query_arg(array('status' => $key), $staus_url); |
|
359 | 358 | |
360 | - $views[ $key ] = sprintf( |
|
359 | + $views[$key] = sprintf( |
|
361 | 360 | '<a href="%s"%s>%s <span class="count">(%s)</span></a>', |
362 | - esc_url( $staus_url ), |
|
363 | - ( ( 'all' === $key && empty( $current ) ) ) ? ' class="current"' : ( $current == $key ? 'class="current"' : '' ), |
|
361 | + esc_url($staus_url), |
|
362 | + (('all' === $key && empty($current))) ? ' class="current"' : ($current == $key ? 'class="current"' : ''), |
|
364 | 363 | $name, |
365 | 364 | $count |
366 | 365 | ); |
@@ -375,7 +374,7 @@ discard block |
||
375 | 374 | * @param array $views |
376 | 375 | * @param Give_Payment_History_Table |
377 | 376 | */ |
378 | - return apply_filters( 'give_payments_table_views', $views, $this ); |
|
377 | + return apply_filters('give_payments_table_views', $views, $this); |
|
379 | 378 | } |
380 | 379 | |
381 | 380 | /** |
@@ -389,18 +388,18 @@ discard block |
||
389 | 388 | public function get_columns() { |
390 | 389 | $columns = array( |
391 | 390 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text. |
392 | - 'donation' => __( 'Donation', 'give' ), |
|
393 | - 'donation_form' => __( 'Donation Form', 'give' ), |
|
394 | - 'status' => __( 'Status', 'give' ), |
|
395 | - 'date' => __( 'Date', 'give' ), |
|
396 | - 'amount' => __( 'Amount', 'give' ), |
|
391 | + 'donation' => __('Donation', 'give'), |
|
392 | + 'donation_form' => __('Donation Form', 'give'), |
|
393 | + 'status' => __('Status', 'give'), |
|
394 | + 'date' => __('Date', 'give'), |
|
395 | + 'amount' => __('Amount', 'give'), |
|
397 | 396 | ); |
398 | 397 | |
399 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
400 | - $columns['details'] = __( 'Details', 'give' ); |
|
398 | + if (current_user_can('view_give_payments')) { |
|
399 | + $columns['details'] = __('Details', 'give'); |
|
401 | 400 | } |
402 | 401 | |
403 | - return apply_filters( 'give_payments_table_columns', $columns ); |
|
402 | + return apply_filters('give_payments_table_columns', $columns); |
|
404 | 403 | } |
405 | 404 | |
406 | 405 | /** |
@@ -413,14 +412,14 @@ discard block |
||
413 | 412 | */ |
414 | 413 | public function get_sortable_columns() { |
415 | 414 | $columns = array( |
416 | - 'donation' => array( 'ID', true ), |
|
417 | - 'donation_form' => array( 'donation_form', false ), |
|
418 | - 'status' => array( 'status', false ), |
|
419 | - 'amount' => array( 'amount', false ), |
|
420 | - 'date' => array( 'date', false ), |
|
415 | + 'donation' => array('ID', true), |
|
416 | + 'donation_form' => array('donation_form', false), |
|
417 | + 'status' => array('status', false), |
|
418 | + 'amount' => array('amount', false), |
|
419 | + 'date' => array('date', false), |
|
421 | 420 | ); |
422 | 421 | |
423 | - return apply_filters( 'give_payments_table_sortable_columns', $columns ); |
|
422 | + return apply_filters('give_payments_table_sortable_columns', $columns); |
|
424 | 423 | } |
425 | 424 | |
426 | 425 | /** |
@@ -446,43 +445,43 @@ discard block |
||
446 | 445 | * |
447 | 446 | * @return string Column Name |
448 | 447 | */ |
449 | - public function column_default( $payment, $column_name ) { |
|
448 | + public function column_default($payment, $column_name) { |
|
450 | 449 | |
451 | - $single_donation_url = esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details' ) ) ); |
|
452 | - $row_actions = $this->get_row_actions( $payment ); |
|
450 | + $single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details'))); |
|
451 | + $row_actions = $this->get_row_actions($payment); |
|
453 | 452 | $value = ''; |
454 | 453 | |
455 | - switch ( $column_name ) { |
|
454 | + switch ($column_name) { |
|
456 | 455 | case 'donation' : |
457 | - $serial_code = Give()->seq_donation_number->get_serial_code( $payment ); |
|
458 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
459 | - $value = Give()->tooltips->render_link( array( |
|
460 | - 'label' => sprintf( __( 'View Donation %s', 'give' ), $serial_code ), |
|
456 | + $serial_code = Give()->seq_donation_number->get_serial_code($payment); |
|
457 | + if (current_user_can('view_give_payments')) { |
|
458 | + $value = Give()->tooltips->render_link(array( |
|
459 | + 'label' => sprintf(__('View Donation %s', 'give'), $serial_code), |
|
461 | 460 | 'tag_content' => $serial_code, |
462 | 461 | 'link' => $single_donation_url, |
463 | - ) ); |
|
462 | + )); |
|
464 | 463 | } else { |
465 | 464 | $value = $serial_code; |
466 | 465 | } |
467 | 466 | |
468 | 467 | $value .= sprintf( |
469 | 468 | ' %1$s %2$s<br>', |
470 | - __( 'by', 'give' ), |
|
471 | - $this->get_donor( $payment ) |
|
469 | + __('by', 'give'), |
|
470 | + $this->get_donor($payment) |
|
472 | 471 | ); |
473 | 472 | |
474 | - $value .= $this->get_donor_email( $payment ); |
|
475 | - $value .= $this->row_actions( $row_actions ); |
|
473 | + $value .= $this->get_donor_email($payment); |
|
474 | + $value .= $this->row_actions($row_actions); |
|
476 | 475 | break; |
477 | 476 | |
478 | 477 | case 'amount': |
479 | - $value = give_donation_amount( $payment, true ); |
|
480 | - $value .= sprintf( '<br><small>%1$s %2$s</small>', __( 'via', 'give' ), give_get_gateway_admin_label( $payment->gateway ) ); |
|
478 | + $value = give_donation_amount($payment, true); |
|
479 | + $value .= sprintf('<br><small>%1$s %2$s</small>', __('via', 'give'), give_get_gateway_admin_label($payment->gateway)); |
|
481 | 480 | break; |
482 | 481 | |
483 | 482 | case 'donation_form': |
484 | - $form_title = empty( $payment->form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $payment->form_id ) : $payment->form_title; |
|
485 | - $value = '<a href="' . admin_url( 'post.php?post=' . $payment->form_id . '&action=edit' ) . '">' . $form_title . '</a>'; |
|
483 | + $form_title = empty($payment->form_title) ? sprintf(__('Untitled (#%s)', 'give'), $payment->form_id) : $payment->form_title; |
|
484 | + $value = '<a href="'.admin_url('post.php?post='.$payment->form_id.'&action=edit').'">'.$form_title.'</a>'; |
|
486 | 485 | $level = give_get_donation_form_title( |
487 | 486 | $payment, |
488 | 487 | array( |
@@ -490,44 +489,44 @@ discard block |
||
490 | 489 | ) |
491 | 490 | ); |
492 | 491 | |
493 | - if ( ! empty( $level ) ) { |
|
492 | + if ( ! empty($level)) { |
|
494 | 493 | $value .= $level; |
495 | 494 | } |
496 | 495 | |
497 | 496 | break; |
498 | 497 | |
499 | 498 | case 'date': |
500 | - $date = strtotime( $payment->date ); |
|
501 | - $value = date_i18n( give_date_format(), $date ); |
|
499 | + $date = strtotime($payment->date); |
|
500 | + $value = date_i18n(give_date_format(), $date); |
|
502 | 501 | break; |
503 | 502 | |
504 | 503 | case 'status': |
505 | - $value = $this->get_payment_status( $payment ); |
|
504 | + $value = $this->get_payment_status($payment); |
|
506 | 505 | break; |
507 | 506 | |
508 | 507 | |
509 | 508 | case 'details' : |
510 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
511 | - $value = Give()->tooltips->render_link( array( |
|
512 | - 'label' => sprintf( __( 'View Donation #%s', 'give' ), $payment->ID ), |
|
509 | + if (current_user_can('view_give_payments')) { |
|
510 | + $value = Give()->tooltips->render_link(array( |
|
511 | + 'label' => sprintf(__('View Donation #%s', 'give'), $payment->ID), |
|
513 | 512 | 'tag_content' => '<span class="dashicons dashicons-visibility"></span>', |
514 | 513 | 'link' => $single_donation_url, |
515 | 514 | 'attributes' => array( |
516 | 515 | 'class' => 'give-payment-details-link button button-small', |
517 | 516 | ), |
518 | - ) ); |
|
517 | + )); |
|
519 | 518 | |
520 | 519 | $value = "<div class=\"give-payment-details-link-wrap\">{$value}</div>"; |
521 | 520 | } |
522 | 521 | break; |
523 | 522 | |
524 | 523 | default: |
525 | - $value = isset( $payment->$column_name ) ? $payment->$column_name : ''; |
|
524 | + $value = isset($payment->$column_name) ? $payment->$column_name : ''; |
|
526 | 525 | break; |
527 | 526 | |
528 | 527 | }// End switch(). |
529 | 528 | |
530 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name ); |
|
529 | + return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name); |
|
531 | 530 | } |
532 | 531 | |
533 | 532 | /** |
@@ -540,22 +539,22 @@ discard block |
||
540 | 539 | * |
541 | 540 | * @return string Data shown in the Email column |
542 | 541 | */ |
543 | - public function get_donor_email( $payment ) { |
|
542 | + public function get_donor_email($payment) { |
|
544 | 543 | |
545 | - $email = give_get_payment_user_email( $payment->ID ); |
|
544 | + $email = give_get_payment_user_email($payment->ID); |
|
546 | 545 | |
547 | - if ( empty( $email ) ) { |
|
548 | - $email = __( '(unknown)', 'give' ); |
|
546 | + if (empty($email)) { |
|
547 | + $email = __('(unknown)', 'give'); |
|
549 | 548 | } |
550 | 549 | |
551 | 550 | |
552 | - $value = Give()->tooltips->render_link( array( |
|
551 | + $value = Give()->tooltips->render_link(array( |
|
553 | 552 | 'link' => "mailto:{$email}", |
554 | - 'label' => __( 'Email donor', 'give' ), |
|
553 | + 'label' => __('Email donor', 'give'), |
|
555 | 554 | 'tag_content' => $email, |
556 | - ) ); |
|
555 | + )); |
|
557 | 556 | |
558 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' ); |
|
557 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'email'); |
|
559 | 558 | } |
560 | 559 | |
561 | 560 | /** |
@@ -567,18 +566,18 @@ discard block |
||
567 | 566 | * |
568 | 567 | * @return array $actions |
569 | 568 | */ |
570 | - function get_row_actions( $payment ) { |
|
569 | + function get_row_actions($payment) { |
|
571 | 570 | |
572 | 571 | $actions = array(); |
573 | - $email = give_get_payment_user_email( $payment->ID ); |
|
572 | + $email = give_get_payment_user_email($payment->ID); |
|
574 | 573 | |
575 | 574 | // Add search term string back to base URL. |
576 | - $search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' ); |
|
577 | - if ( ! empty( $search_terms ) ) { |
|
578 | - $this->base_url = add_query_arg( 's', $search_terms, $this->base_url ); |
|
575 | + $search_terms = (isset($_GET['s']) ? trim($_GET['s']) : ''); |
|
576 | + if ( ! empty($search_terms)) { |
|
577 | + $this->base_url = add_query_arg('s', $search_terms, $this->base_url); |
|
579 | 578 | } |
580 | 579 | |
581 | - if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) { |
|
580 | + if (give_is_payment_complete($payment->ID) && ! empty($email)) { |
|
582 | 581 | |
583 | 582 | $actions['email_links'] = sprintf( |
584 | 583 | '<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url( |
@@ -588,12 +587,12 @@ discard block |
||
588 | 587 | 'purchase_id' => $payment->ID, |
589 | 588 | ), $this->base_url |
590 | 589 | ), 'give_payment_nonce' |
591 | - ), sprintf( __( 'Resend Donation %s Receipt', 'give' ), $payment->ID ), __( 'Resend Receipt', 'give' ) |
|
590 | + ), sprintf(__('Resend Donation %s Receipt', 'give'), $payment->ID), __('Resend Receipt', 'give') |
|
592 | 591 | ); |
593 | 592 | |
594 | 593 | } |
595 | 594 | |
596 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
595 | + if (current_user_can('view_give_payments')) { |
|
597 | 596 | $actions['delete'] = sprintf( |
598 | 597 | '<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>', |
599 | 598 | wp_nonce_url( |
@@ -603,11 +602,11 @@ discard block |
||
603 | 602 | 'purchase_id' => $payment->ID, |
604 | 603 | ), $this->base_url |
605 | 604 | ), 'give_donation_nonce' |
606 | - ), sprintf( __( 'Delete Donation %s', 'give' ), $payment->ID ), __( 'Delete', 'give' ) |
|
605 | + ), sprintf(__('Delete Donation %s', 'give'), $payment->ID), __('Delete', 'give') |
|
607 | 606 | ); |
608 | 607 | } |
609 | 608 | |
610 | - return apply_filters( 'give_payment_row_actions', $actions, $payment ); |
|
609 | + return apply_filters('give_payment_row_actions', $actions, $payment); |
|
611 | 610 | } |
612 | 611 | |
613 | 612 | |
@@ -621,30 +620,30 @@ discard block |
||
621 | 620 | * |
622 | 621 | * @return string Data shown in the Email column |
623 | 622 | */ |
624 | - function get_payment_status( $payment ) { |
|
623 | + function get_payment_status($payment) { |
|
625 | 624 | $value = sprintf( |
626 | 625 | '<div class="give-donation-status status-%1$s"><span class="give-donation-status-icon"></span> %2$s</div>', |
627 | 626 | $payment->status, |
628 | - give_get_payment_status( $payment, true ) |
|
627 | + give_get_payment_status($payment, true) |
|
629 | 628 | ); |
630 | 629 | |
631 | - if ( $payment->mode == 'test' ) { |
|
632 | - $value .= Give()->tooltips->render_span( array( |
|
633 | - 'label' => __( 'This donation was made in test mode.', 'give' ), |
|
634 | - 'tag_content' => __( 'Test', 'give' ), |
|
630 | + if ($payment->mode == 'test') { |
|
631 | + $value .= Give()->tooltips->render_span(array( |
|
632 | + 'label' => __('This donation was made in test mode.', 'give'), |
|
633 | + 'tag_content' => __('Test', 'give'), |
|
635 | 634 | 'attributes' => array( |
636 | 635 | 'class' => 'give-item-label give-item-label-orange give-test-mode-transactions-label', |
637 | 636 | ), |
638 | 637 | |
639 | 638 | |
640 | - ) ); |
|
639 | + )); |
|
641 | 640 | } |
642 | 641 | |
643 | - if ( true === $payment->import && true === (bool) apply_filters( 'give_payment_show_importer_label', false ) ) { |
|
642 | + if (true === $payment->import && true === (bool) apply_filters('give_payment_show_importer_label', false)) { |
|
644 | 643 | $value .= sprintf( |
645 | 644 | ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="%1$s">%2$s</span>', |
646 | - __( 'This donation was imported.', 'give' ), |
|
647 | - __( 'Import', 'give' ) |
|
645 | + __('This donation was imported.', 'give'), |
|
646 | + __('Import', 'give') |
|
648 | 647 | ); |
649 | 648 | } |
650 | 649 | |
@@ -661,8 +660,8 @@ discard block |
||
661 | 660 | * |
662 | 661 | * @return string Displays a checkbox. |
663 | 662 | */ |
664 | - public function column_cb( $payment ) { |
|
665 | - return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID ); |
|
663 | + public function column_cb($payment) { |
|
664 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID); |
|
666 | 665 | } |
667 | 666 | |
668 | 667 | /** |
@@ -675,8 +674,8 @@ discard block |
||
675 | 674 | * |
676 | 675 | * @return string Displays a checkbox. |
677 | 676 | */ |
678 | - public function get_payment_id( $payment ) { |
|
679 | - return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>'; |
|
677 | + public function get_payment_id($payment) { |
|
678 | + return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>'; |
|
680 | 679 | } |
681 | 680 | |
682 | 681 | /** |
@@ -689,32 +688,32 @@ discard block |
||
689 | 688 | * |
690 | 689 | * @return string Data shown in the User column |
691 | 690 | */ |
692 | - public function get_donor( $payment ) { |
|
691 | + public function get_donor($payment) { |
|
693 | 692 | |
694 | - $donor_id = give_get_payment_donor_id( $payment->ID ); |
|
695 | - $donor_billing_name = give_get_donor_name_by( $payment->ID, 'donation' ); |
|
696 | - $donor_name = give_get_donor_name_by( $donor_id, 'donor' ); |
|
693 | + $donor_id = give_get_payment_donor_id($payment->ID); |
|
694 | + $donor_billing_name = give_get_donor_name_by($payment->ID, 'donation'); |
|
695 | + $donor_name = give_get_donor_name_by($donor_id, 'donor'); |
|
697 | 696 | |
698 | 697 | $value = ''; |
699 | - if ( ! empty( $donor_id ) ) { |
|
698 | + if ( ! empty($donor_id)) { |
|
700 | 699 | |
701 | 700 | // Check whether the donor name and WP_User name is same or not. |
702 | - if ( sanitize_title( $donor_billing_name ) !== sanitize_title( $donor_name ) ) { |
|
703 | - $value .= $donor_billing_name . ' ('; |
|
701 | + if (sanitize_title($donor_billing_name) !== sanitize_title($donor_name)) { |
|
702 | + $value .= $donor_billing_name.' ('; |
|
704 | 703 | } |
705 | 704 | |
706 | - $value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>'; |
|
705 | + $value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>'; |
|
707 | 706 | |
708 | 707 | // Check whether the donor name and WP_User name is same or not. |
709 | - if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) { |
|
708 | + if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) { |
|
710 | 709 | $value .= ')'; |
711 | 710 | } |
712 | 711 | } else { |
713 | - $email = give_get_payment_user_email( $payment->ID ); |
|
714 | - $value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . __( '(donor missing)', 'give' ) . '</a>'; |
|
712 | + $email = give_get_payment_user_email($payment->ID); |
|
713 | + $value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.__('(donor missing)', 'give').'</a>'; |
|
715 | 714 | } |
716 | 715 | |
717 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' ); |
|
716 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor'); |
|
718 | 717 | } |
719 | 718 | |
720 | 719 | /** |
@@ -727,20 +726,20 @@ discard block |
||
727 | 726 | */ |
728 | 727 | public function get_bulk_actions() { |
729 | 728 | $actions = array( |
730 | - 'delete' => __( 'Delete', 'give' ), |
|
731 | - 'set-status-publish' => __( 'Set To Completed', 'give' ), |
|
732 | - 'set-status-pending' => __( 'Set To Pending', 'give' ), |
|
733 | - 'set-status-processing' => __( 'Set To Processing', 'give' ), |
|
734 | - 'set-status-refunded' => __( 'Set To Refunded', 'give' ), |
|
735 | - 'set-status-revoked' => __( 'Set To Revoked', 'give' ), |
|
736 | - 'set-status-failed' => __( 'Set To Failed', 'give' ), |
|
737 | - 'set-status-cancelled' => __( 'Set To Cancelled', 'give' ), |
|
738 | - 'set-status-abandoned' => __( 'Set To Abandoned', 'give' ), |
|
739 | - 'set-status-preapproval' => __( 'Set To Preapproval', 'give' ), |
|
740 | - 'resend-receipt' => __( 'Resend Email Receipts', 'give' ), |
|
729 | + 'delete' => __('Delete', 'give'), |
|
730 | + 'set-status-publish' => __('Set To Completed', 'give'), |
|
731 | + 'set-status-pending' => __('Set To Pending', 'give'), |
|
732 | + 'set-status-processing' => __('Set To Processing', 'give'), |
|
733 | + 'set-status-refunded' => __('Set To Refunded', 'give'), |
|
734 | + 'set-status-revoked' => __('Set To Revoked', 'give'), |
|
735 | + 'set-status-failed' => __('Set To Failed', 'give'), |
|
736 | + 'set-status-cancelled' => __('Set To Cancelled', 'give'), |
|
737 | + 'set-status-abandoned' => __('Set To Abandoned', 'give'), |
|
738 | + 'set-status-preapproval' => __('Set To Preapproval', 'give'), |
|
739 | + 'resend-receipt' => __('Resend Email Receipts', 'give'), |
|
741 | 740 | ); |
742 | 741 | |
743 | - return apply_filters( 'give_payments_table_bulk_actions', $actions ); |
|
742 | + return apply_filters('give_payments_table_bulk_actions', $actions); |
|
744 | 743 | } |
745 | 744 | |
746 | 745 | /** |
@@ -752,59 +751,59 @@ discard block |
||
752 | 751 | * @return void |
753 | 752 | */ |
754 | 753 | public function process_bulk_action() { |
755 | - $ids = isset( $_GET['payment'] ) ? $_GET['payment'] : false; |
|
754 | + $ids = isset($_GET['payment']) ? $_GET['payment'] : false; |
|
756 | 755 | $action = $this->current_action(); |
757 | 756 | |
758 | - if ( ! is_array( $ids ) ) { |
|
759 | - $ids = array( $ids ); |
|
757 | + if ( ! is_array($ids)) { |
|
758 | + $ids = array($ids); |
|
760 | 759 | } |
761 | 760 | |
762 | - if ( empty( $action ) ) { |
|
761 | + if (empty($action)) { |
|
763 | 762 | return; |
764 | 763 | } |
765 | 764 | |
766 | - foreach ( $ids as $id ) { |
|
765 | + foreach ($ids as $id) { |
|
767 | 766 | |
768 | 767 | // Detect when a bulk action is being triggered. |
769 | - switch ( $this->current_action() ) { |
|
768 | + switch ($this->current_action()) { |
|
770 | 769 | |
771 | 770 | case 'delete': |
772 | - give_delete_donation( $id ); |
|
771 | + give_delete_donation($id); |
|
773 | 772 | break; |
774 | 773 | |
775 | 774 | case 'set-status-publish': |
776 | - give_update_payment_status( $id, 'publish' ); |
|
775 | + give_update_payment_status($id, 'publish'); |
|
777 | 776 | break; |
778 | 777 | |
779 | 778 | case 'set-status-pending': |
780 | - give_update_payment_status( $id, 'pending' ); |
|
779 | + give_update_payment_status($id, 'pending'); |
|
781 | 780 | break; |
782 | 781 | |
783 | 782 | case 'set-status-processing': |
784 | - give_update_payment_status( $id, 'processing' ); |
|
783 | + give_update_payment_status($id, 'processing'); |
|
785 | 784 | break; |
786 | 785 | |
787 | 786 | case 'set-status-refunded': |
788 | - give_update_payment_status( $id, 'refunded' ); |
|
787 | + give_update_payment_status($id, 'refunded'); |
|
789 | 788 | break; |
790 | 789 | case 'set-status-revoked': |
791 | - give_update_payment_status( $id, 'revoked' ); |
|
790 | + give_update_payment_status($id, 'revoked'); |
|
792 | 791 | break; |
793 | 792 | |
794 | 793 | case 'set-status-failed': |
795 | - give_update_payment_status( $id, 'failed' ); |
|
794 | + give_update_payment_status($id, 'failed'); |
|
796 | 795 | break; |
797 | 796 | |
798 | 797 | case 'set-status-cancelled': |
799 | - give_update_payment_status( $id, 'cancelled' ); |
|
798 | + give_update_payment_status($id, 'cancelled'); |
|
800 | 799 | break; |
801 | 800 | |
802 | 801 | case 'set-status-abandoned': |
803 | - give_update_payment_status( $id, 'abandoned' ); |
|
802 | + give_update_payment_status($id, 'abandoned'); |
|
804 | 803 | break; |
805 | 804 | |
806 | 805 | case 'set-status-preapproval': |
807 | - give_update_payment_status( $id, 'preapproval' ); |
|
806 | + give_update_payment_status($id, 'preapproval'); |
|
808 | 807 | break; |
809 | 808 | |
810 | 809 | case 'resend-receipt': |
@@ -813,7 +812,7 @@ discard block |
||
813 | 812 | * |
814 | 813 | * @since 2.0 |
815 | 814 | */ |
816 | - do_action( 'give_donation-receipt_email_notification', $id ); |
|
815 | + do_action('give_donation-receipt_email_notification', $id); |
|
817 | 816 | break; |
818 | 817 | }// End switch(). |
819 | 818 | |
@@ -825,7 +824,7 @@ discard block |
||
825 | 824 | * |
826 | 825 | * @since 1.7 |
827 | 826 | */ |
828 | - do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() ); |
|
827 | + do_action('give_payments_table_do_bulk_action', $id, $this->current_action()); |
|
829 | 828 | }// End foreach(). |
830 | 829 | |
831 | 830 | } |
@@ -842,32 +841,32 @@ discard block |
||
842 | 841 | |
843 | 842 | $args = array(); |
844 | 843 | |
845 | - if ( isset( $_GET['user'] ) ) { |
|
846 | - $args['user'] = urldecode( $_GET['user'] ); |
|
847 | - } elseif ( isset( $_GET['donor'] ) ) { |
|
848 | - $args['donor'] = absint( $_GET['donor'] ); |
|
849 | - } elseif ( isset( $_GET['s'] ) ) { |
|
850 | - $is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false; |
|
851 | - if ( $is_user ) { |
|
852 | - $args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) ); |
|
853 | - unset( $args['s'] ); |
|
844 | + if (isset($_GET['user'])) { |
|
845 | + $args['user'] = urldecode($_GET['user']); |
|
846 | + } elseif (isset($_GET['donor'])) { |
|
847 | + $args['donor'] = absint($_GET['donor']); |
|
848 | + } elseif (isset($_GET['s'])) { |
|
849 | + $is_user = strpos($_GET['s'], strtolower('user:')) !== false; |
|
850 | + if ($is_user) { |
|
851 | + $args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s'])))); |
|
852 | + unset($args['s']); |
|
854 | 853 | } else { |
855 | - $args['s'] = sanitize_text_field( $_GET['s'] ); |
|
854 | + $args['s'] = sanitize_text_field($_GET['s']); |
|
856 | 855 | } |
857 | 856 | } |
858 | 857 | |
859 | - if ( ! empty( $_GET['start-date'] ) ) { |
|
860 | - $args['start-date'] = urldecode( $_GET['start-date'] ); |
|
858 | + if ( ! empty($_GET['start-date'])) { |
|
859 | + $args['start-date'] = urldecode($_GET['start-date']); |
|
861 | 860 | } |
862 | 861 | |
863 | - if ( ! empty( $_GET['end-date'] ) ) { |
|
864 | - $args['end-date'] = urldecode( $_GET['end-date'] ); |
|
862 | + if ( ! empty($_GET['end-date'])) { |
|
863 | + $args['end-date'] = urldecode($_GET['end-date']); |
|
865 | 864 | } |
866 | 865 | |
867 | - $args['form_id'] = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
868 | - $args['gateway'] = ! empty( $_GET['gateway'] ) ? give_clean( $_GET['gateway'] ) : null; |
|
866 | + $args['form_id'] = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
867 | + $args['gateway'] = ! empty($_GET['gateway']) ? give_clean($_GET['gateway']) : null; |
|
869 | 868 | |
870 | - $payment_count = give_count_payments( $args ); |
|
869 | + $payment_count = give_count_payments($args); |
|
871 | 870 | $this->complete_count = $payment_count->publish; |
872 | 871 | $this->pending_count = $payment_count->pending; |
873 | 872 | $this->processing_count = $payment_count->processing; |
@@ -878,7 +877,7 @@ discard block |
||
878 | 877 | $this->abandoned_count = $payment_count->abandoned; |
879 | 878 | $this->preapproval_count = $payment_count->preapproval; |
880 | 879 | |
881 | - foreach ( $payment_count as $count ) { |
|
880 | + foreach ($payment_count as $count) { |
|
882 | 881 | $this->total_count += $count; |
883 | 882 | } |
884 | 883 | |
@@ -896,25 +895,25 @@ discard block |
||
896 | 895 | public function payments_data() { |
897 | 896 | |
898 | 897 | $per_page = $this->per_page; |
899 | - $orderby = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID'; |
|
900 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
901 | - $user = isset( $_GET['user'] ) ? $_GET['user'] : null; |
|
902 | - $donor = isset( $_GET['donor'] ) ? $_GET['donor'] : null; |
|
903 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys(); |
|
904 | - $meta_key = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null; |
|
905 | - $year = isset( $_GET['year'] ) ? $_GET['year'] : null; |
|
906 | - $month = isset( $_GET['m'] ) ? $_GET['m'] : null; |
|
907 | - $day = isset( $_GET['day'] ) ? $_GET['day'] : null; |
|
908 | - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null; |
|
909 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
910 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date; |
|
911 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
912 | - $gateway = ! empty( $_GET['gateway'] ) ? give_clean( $_GET['gateway'] ) : null; |
|
898 | + $orderby = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID'; |
|
899 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
900 | + $user = isset($_GET['user']) ? $_GET['user'] : null; |
|
901 | + $donor = isset($_GET['donor']) ? $_GET['donor'] : null; |
|
902 | + $status = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys(); |
|
903 | + $meta_key = isset($_GET['meta_key']) ? $_GET['meta_key'] : null; |
|
904 | + $year = isset($_GET['year']) ? $_GET['year'] : null; |
|
905 | + $month = isset($_GET['m']) ? $_GET['m'] : null; |
|
906 | + $day = isset($_GET['day']) ? $_GET['day'] : null; |
|
907 | + $search = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null; |
|
908 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
909 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date; |
|
910 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
911 | + $gateway = ! empty($_GET['gateway']) ? give_clean($_GET['gateway']) : null; |
|
913 | 912 | |
914 | 913 | $args = array( |
915 | 914 | 'output' => 'payments', |
916 | 915 | 'number' => $per_page, |
917 | - 'page' => isset( $_GET['paged'] ) ? $_GET['paged'] : null, |
|
916 | + 'page' => isset($_GET['paged']) ? $_GET['paged'] : null, |
|
918 | 917 | 'orderby' => $orderby, |
919 | 918 | 'order' => $order, |
920 | 919 | 'user' => $user, |
@@ -931,9 +930,9 @@ discard block |
||
931 | 930 | 'give_forms' => $form_id, |
932 | 931 | ); |
933 | 932 | |
934 | - if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) { |
|
933 | + if (is_string($search) && false !== strpos($search, 'txn:')) { |
|
935 | 934 | $args['search_in_notes'] = true; |
936 | - $args['s'] = trim( str_replace( 'txn:', '', $args['s'] ) ); |
|
935 | + $args['s'] = trim(str_replace('txn:', '', $args['s'])); |
|
937 | 936 | } |
938 | 937 | |
939 | 938 | /** |
@@ -941,9 +940,9 @@ discard block |
||
941 | 940 | * |
942 | 941 | * @since 1.8.18 |
943 | 942 | */ |
944 | - $args = (array) apply_filters( 'give_payment_table_payments_query', $args ); |
|
943 | + $args = (array) apply_filters('give_payment_table_payments_query', $args); |
|
945 | 944 | |
946 | - $p_query = new Give_Payments_Query( $args ); |
|
945 | + $p_query = new Give_Payments_Query($args); |
|
947 | 946 | |
948 | 947 | return $p_query->get_payments(); |
949 | 948 | |
@@ -964,17 +963,17 @@ discard block |
||
964 | 963 | */ |
965 | 964 | public function prepare_items() { |
966 | 965 | |
967 | - wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) ); |
|
966 | + wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's')); |
|
968 | 967 | |
969 | 968 | $columns = $this->get_columns(); |
970 | 969 | $hidden = array(); // No hidden columns. |
971 | 970 | $sortable = $this->get_sortable_columns(); |
972 | 971 | $data = $this->payments_data(); |
973 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
972 | + $status = isset($_GET['status']) ? $_GET['status'] : 'any'; |
|
974 | 973 | |
975 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
974 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
976 | 975 | |
977 | - switch ( $status ) { |
|
976 | + switch ($status) { |
|
978 | 977 | case 'publish': |
979 | 978 | $total_items = $this->complete_count; |
980 | 979 | break; |
@@ -1007,8 +1006,8 @@ discard block |
||
1007 | 1006 | break; |
1008 | 1007 | default: |
1009 | 1008 | // Retrieve the count of the non-default-Give status. |
1010 | - $count = wp_count_posts( 'give_payment' ); |
|
1011 | - $total_items = isset( $count->{$status} ) ? $count->{$status} : 0; |
|
1009 | + $count = wp_count_posts('give_payment'); |
|
1010 | + $total_items = isset($count->{$status} ) ? $count->{$status} : 0; |
|
1012 | 1011 | break; |
1013 | 1012 | } |
1014 | 1013 | |
@@ -1019,7 +1018,7 @@ discard block |
||
1019 | 1018 | * |
1020 | 1019 | * @since 1.8.19 |
1021 | 1020 | */ |
1022 | - $total_items = (int) apply_filters( 'give_payment_table_pagination_total_count', $total_items, $this ); |
|
1021 | + $total_items = (int) apply_filters('give_payment_table_pagination_total_count', $total_items, $this); |
|
1023 | 1022 | |
1024 | 1023 | $this->set_pagination_args( |
1025 | 1024 | array( |
@@ -1027,7 +1026,7 @@ discard block |
||
1027 | 1026 | // We have to calculate the total number of items. |
1028 | 1027 | 'per_page' => $this->per_page, |
1029 | 1028 | // We have to determine how many items to show on a page. |
1030 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
1029 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
1031 | 1030 | // We have to calculate the total number of pages. |
1032 | 1031 | ) |
1033 | 1032 | ); |